This is a first attempt to port gist_filter to Drupal 8.
The functionality of the module remains the same but I have extracted all the communication to GitHub api and cache to a new type to separate responsibilities.

Comments

capuleto created an issue. See original summary.

capuleto’s picture

StatusFileSize
new5.59 KB

And a tarball to make things easier to review.

fl3a’s picture

On a fresh 8.21 with standard profile:

  1. Installed module
  2. Created new input format 'Gist test' (gist_test) with 'Gist filter (Github Gists)' (only) enabled
  3. Create new content (article)
  4. leads to:

[Mon Oct 17 11:42:06.654488 2016] [:error] [pid 5432] [client 127.0.0.1:54296] Uncaught PHP Exception Exception: "Serialization of 'Closure' is not allowed" at /var/www/isl8/web/core/lib/Drupal/Core/Cache/DatabaseBackend.php line 211, referer: http://isl8.localhost/node/add

BTW: What about a 8.x branch?

capuleto’s picture

@fl3a.. Things might have changed since I opened this issue and submitted the D8 port.
I think we need a re-roll

fl3a’s picture

Hi capuleto,

i created a sandbox https://www.drupal.org/sandbox/fl3a/2819998 , just to have git, you should have all permissions.

Regards

capuleto’s picture

Thanks @fl3a.. I will have a look to the issue as soon as I get a second.
I've noticed that you have also committed several files that are not part of the submitted patch. http://cgit.drupalcode.org/sandbox-fl3a-2819998/commit/?id=251bb3f
Would it be possible to remove them from the sandbox repository?

swentel’s picture

Tested the sandbox version, don't have the fatal error, so not sure if that error is still in the module at all.

swentel’s picture

Actually scratch that last comment, got it now too, will test the patch in the sandbox queue.

fl3a’s picture

Sandbox is good to go. Asked Jake Bell (theunraveler) for co-maintainership regarding allignment or official 8.x release/dev snapshot,

Thx capuleto for initial work und swentel for reviewing/testing of capuletos patch!

MaskyS’s picture

Category: Feature request » Task
Issue tags: +Needs Review, +Needs tests
StatusFileSize
new6.02 KB

Attached a new patch that applies the changes mentioned in #7 of https://www.drupal.org/node/2624572.

gvso’s picture

Status: Needs review » Needs work

#10 is to respect to the sandbox project and not the 7.x version. This means that the patch can not be applied to the 7.x-1.x branch.

Also, can you please explain why you changed the gist type select for more filters?

MaskyS’s picture

Just realised what a mess I made. Sorry for any confusions I may have caused. Hiding up the previous patch; as gvso pointed out, that one wouldn't apply to the 7.1x branch. I'm now attaching two new patches, both of which will apply to the 7.x branch. One of them rerolls capuleto's patch (it wouldn't apply) and completes the port by adding a README file and removing the .info file. The second patch does the same as the first, but it also reworks the features to allow all three display methods to be used at once. (More details in https://www.drupal.org/project/2819998/issues/2931949) . Also attached an interdiff for making it easier to see the difference between the two attached patches.

gvso’s picture

+++ /dev/null
@@ -1,8 +0,0 @@
\ No newline at end of file

Correct all the "No newline at end of file" errors

I couldn't apply any of the patches at all. I got errors when applying them.

Also, please just provide a patch with an interdiff and remember to change the status to "Needs review"

MaskyS’s picture

Status: Needs work » Needs review
Issue tags: -Needs tests
StatusFileSize
new35.29 KB
new9.83 KB

Found out that I couldn't apply capuleto's patch and you couldn't apply mine because I was working on the master branch instead of the 7.1x branch. This should be good to go.

git clone --branch 7.x-1.x https://git.drupal.org/project/gist_filter.git
git apply -v rework-features-port-to-drupal8-2624384-14.patch

Checking patch README.md...
Checking patch gist_filter.info...
Checking patch gist_filter.info.yml...
Checking patch gist_filter.module...
Checking patch gist_filter.test...
Checking patch src/GistFilterCacheDecoratorClient.php...
Checking patch src/GistFilterClientInterface.php...
Checking patch src/GistFilterGitHubClient.php...
Checking patch src/GitHubRequestException.php...
Checking patch src/Plugin/Filter/GistFilter.php...
Checking patch src/Tests/GistFilterTestCase.php...
Checking patch templates/gist-filter-code.html.twig...
Checking patch tests/src/Unit/GistFilterCacheDecoratorClientTest.php...
Checking patch tests/src/Unit/GistFilterGithubClientTest.php...
Applied patch README.md cleanly.
Applied patch gist_filter.info cleanly.
Applied patch gist_filter.info.yml cleanly.
Applied patch gist_filter.module cleanly.
Applied patch gist_filter.test cleanly.
Applied patch src/GistFilterCacheDecoratorClient.php cleanly.
Applied patch src/GistFilterClientInterface.php cleanly.
Applied patch src/GistFilterGitHubClient.php cleanly.
Applied patch src/GitHubRequestException.php cleanly.
Applied patch src/Plugin/Filter/GistFilter.php cleanly.
Applied patch src/Tests/GistFilterTestCase.php cleanly.
Applied patch templates/gist-filter-code.html.twig cleanly.
Applied patch tests/src/Unit/GistFilterCacheDecoratorClientTest.php cleanly.
Applied patch tests/src/Unit/GistFilterGithubClientTest.php cleanly.
gvso’s picture

Status: Needs review » Needs work
  1. +++ b/src/GistFilterCacheDecoratorClient.php
    @@ -0,0 +1,74 @@
    +/**
    + * @file
    + * Contains \Drupal\gist_filter\GistFilterCacheDecoratorClient.
    + */
    

    Remove all the @file doc blocks from classes

  2. +++ b/src/Plugin/Filter/GistFilter.php
    @@ -0,0 +1,172 @@
    +    $text = preg_replace_callback('@\[gist\:(?<id>[\w/]+)(?:\:(?<file>[\w\.]+))?\]@', array($this, gistDisplayEmbed), $text);
    +    $text = preg_replace_callback('@\[gistcode\:(?<id>[\w/]+)(?:\:(?<file>[\w\.]+))?\]@', array($this, gistDisplayCode), $text);
    +    $text = preg_replace_callback('@\[gistlink\:(?<id>[\w/]+)(?:\:(?<file>[\w\.]+))?\]@', array($this, gistDisplayLink), $text);
    

    Pass the callbacks as strings

  3. +++ b/src/Plugin/Filter/GistFilter.php
    @@ -0,0 +1,172 @@
    +    $output = $this->t('Use <code>[gist:#####]

    for using the default embed method.', '
    ';
    + $output = $this->t('You can use [gist:#####] for displaying just the code of your gist, or [gistlink:#####] for displaying the link of your gist.', '
    ';

    The second statement is overwriting what the string has in the previous statement. You want to concatenate instead.

    Also the first statement is missing a parenthesis

  4. +++ b/templates/gist-filter-code.html.twig
    @@ -0,0 +1,19 @@
    \ No newline at end of file
    

    No newline at end of file

Please install CodeSniffer and fix all the coding standard violations.

MaskyS’s picture

StatusFileSize
new35.62 KB
new15.83 KB

Thanks gvso! I ran drupalcs and fixed the issues.

MaskyS’s picture

StatusFileSize
new15.83 KB

Some issue with the previous interdiff.

MaskyS’s picture

Status: Needs work » Needs review