I wanted to get the ball rolling on the D8 port. I would like to request the patch be reviewed and a 8.x branch to be created. The patch is attached in the comment below.

  • Converted info file to yml
  • Converted variables to CMI
  • Replaced deprecated functions accordingly
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

desmondmorris’s picture

Status: Active » Needs review
FileSize
22.98 KB
smartinm’s picture

Hi Desmond, thanks for your efforts to port this module to D8.

Please give me some time to review the patch ;-)

desmondmorris’s picture

No problem!

smartinm’s picture

Status: Needs review » Needs work
FileSize
2.22 KB
23.89 KB

I've been testing the patch on my dev site. Patch is fine but the module still don't work on D8 because prettify css/js is added on hook_init() and as of Drupal 8, hook_init() no longer exists (https://drupal.org/node/2013014).

If your module just needs to add css and/or javascript, hook_page_build() should be used instead

I've re-rolled the path and made a couple small changes.

desmondmorris’s picture

Good catch. I think hook_init was still alive and kicking in the version I patched against.

chertzog’s picture

FileSize
36.79 KB

chasing head, and restructuring accordingly.

chertzog’s picture

Status: Needs work » Needs review
chertzog’s picture

FileSize
59.8 KB

Here is a better patch that adds the missing files.

lolandese’s picture

Assigned: desmondmorris » Unassigned
Status: Needs review » Needs work

@ #8:
On a drupal 8.0-alpha3 it breaks the site (Server error, [error] [client 127.0.0.1] PHP Fatal error: Undefined class constant 'VERSION' in /home/martin/www/black/modules/prettify/prettify.module on line 84, referer: http://black.dev/admin/modules), even after adding (prettify.module line 85):

'dependencies' => array(
array('system', 'jquery'),
array('system', 'drupal'),
array('system', 'drupalSettings'),
),

It was mentioned in the article to use a certain HEAD checkout and indeed on the latest git grabbed version it went well.

As a minor can be mentioned the following Drupal error message:
Warning: Invalid argument supplied for foreach() in prettify_add_library() (line 304 of modules/prettify/prettify.module).
It disappeared after a while.

Furthermore I had the following in my error log:
[error] [client 127.0.0.1] (13)Permission denied: file permissions deny server access: /home/martin/www/beige/libraries/prettify/prettify.js, referer: http://beige.dev/admin/config/user-interface/prettify?render=overlay
I changed the file permissions manually.

The module works as expected. I think that after adding the dependencies in hook_library_info() and rerolling the patch this is ready for RTBC.

Thanks.

smartinm’s picture

Thanks for all the work done here. I'll create new a new branch for D8 and commit when it's RTBC.

Finn Lewis’s picture

Issue summary: View changes
FileSize
23.7 KB

Great work! This certainly got the ball rolling for me.
I read the fantastic blog post from cherzthog at http://chertzog.com/post/up-and-running-on-drupal-8 which lead me here.
The recent changes renaming drupal_add_js and drupal_add_css meant I had to make some more changes to get it working with the latest Drupal 8 HEAD.
I now have it working locally, which is nice.
Please see attached a patch against the latest 7.x-1.x-dev (2013-Oct-01)
This patch includes all the other changes from patch from comment #8.
Hope this helps someone.
Looking forward to an 8.x branch to work against.

Finn Lewis’s picture

Woops! I didn't create that last patch properly.
Please see revised patch, which I just tested against 7.x-1.x-dev (2013-Oct-01)
This time it works!
However,

Finn Lewis’s picture

eporama’s picture

Status: Needs work » Needs review
FileSize
47.88 KB
4.67 KB

I have gotten a patch that applies and gets part of the way there. But it does allow the module to not throw errors on installation or general configuration.

There do seem to be some issues once it's there.

  1. Pretty code is doubled. Once plain, once pretty.
  2. All formats seem to have "prettifying" whether it's selected in the format or not
  3. The gallery isn't working yet.

Hopefully soon we could open a 8.x branch so that commits and bugs could be filed a bit more selectively.

krisp1’s picture

When I apply the patch above #14 with git am --signoff it is telling me the patch does not have a valid e-mail address. The patch is also adding a lot of whitespace and does not allow me to enable the module once applied.

eporama’s picture

Here's a new patch that applies to 7.x-1.x from format-patch that does not have any of the whitespace errors and applies cleanly

Since the previous patch didn't apply, I didn't create an interdiff. Leaving the status at needs review.

~ $ git clone --branch 7.x-1.x http://git.drupal.org/project/prettify.git
Cloning into 'prettify'...
remote: Counting objects: 122, done.
remote: Compressing objects: 100% (120/120), done.
remote: Total 122 (delta 63), reused 0 (delta 0)
Receiving objects: 100% (122/122), 37.93 KiB, done.
Resolving deltas: 100% (63/63), done.
~ $ cd prettify/
prettify (7.x-1.x) $ git checkout -b 8.x-1.x
Switched to a new branch '8.x-1.x'
prettify (8.x-1.x) $ git apply ~/Desktop/prettify-d8-port-2015671-16.patch
prettify (8.x-1.x) $

eporama’s picture

quick fix to the problem 1 in comment #14

  1. Pretty code is doubled. Once plain, once pretty.

Simple fix. The drupal_render() of the prettified code is being appended to $text, not replacing it.

With this, I am able to enable the module, download the prettify js to sites/all/libraries, add it as a filter on "restricted HTML", and add code to a page with that format. So it's "working"

eporama’s picture

Hmm... "Back" in the browser removed my uploaded files. Whoops.

maciej.zgadzaj’s picture

Status: Needs review » Needs work

Quick update on this: First of all, "patched" version does not work with current D8 at all anymore. However, starting with patch from #18, I have done a basic port that seems to work with v8.3 - it's available at https://github.com/maciejzgadzaj/prettify if anyone's interested (and would like to take it any further) - I am not going to be working on it anymore, as I have switched to CodeSnippet.