General help

Geshi, editor plugin, M 2.5.1

 
 
Gmads
Geshi, editor plugin, M 2.5.1
 

Hi,

As trying to read through the Syntax Highlighting Feature for Moodle 2.0 thread opened by Jeremy W is getting a bit confusing, I'm opening a new thread just to summarize the files used and the steps followed (everything based on what Jeremy indicated) to have the Geshi plugin working in my Moodle 2.5.1 installation.

** For quickstarters

  • Go to the moodle/lib/editor/tinymce/ directory and backup the following three files:
  1. lib.php (tinymce/)
  2. editor_tinymce.php (tinymce/lang/en/)
  3. content.css (tinymce/tiny_mce/3.5.8/themes/advanced/skins/default/)
  • Download the one-file-installbk_tinymce_m251-04_rjic_final.7z (sha1: E8E462ADAA5033A6382D0CE3CC3A397435F0F2F7).
  • Move the file to moodle/lib/editor/ and unpack it; this will overwrite the lib.php, editor_tinymce.php and content.css files, and it will add the rj_insertcode plugin directory (under tinymce/tiny_mce/3.5.8/plugins/).
  • Go to your Moodle installation and purge all caches (Administration > Development > Purge all caches ).
  • The Insert/Edit Code button in the HTML editor toolbar will now be available.

I uploaded a course backup (bk-mdl2-c03-geshi101-130930-1608-nu.mbz, sha1: 75604C105C3DD0443758683F9492C223BD93292C) that has only two Page resources to show how the highlighted html and php sample codes look.

** Background

For those who might want to know, here's how everything went.

  1. Made a backup of directory tinymce (moodle/lib/editor/).
  2. Downloaded:
  3. Unpacked rj_insertcode under moodle/lib/editor/tinymce/tiny_mce/3.5.8/plugins/
  4. Unpacked geshihacks in a temporary folder, and after a bit of searching I only moved four of the five files included, into the corresponding directories:
    1. lib.php -- tinymce/
    2. editor_tinymce.php -- tinymce/lang/en/
    3. content.css -- tinymce/tiny_mce/3.5.8/themes/advanced/skins/default/
    4. rj_get_highlighted_code.php -- tinymce/tiny_mce/3.5.8/plugins/rj_insertcode/tinymce/php/
    • Note. I skipped file rj_common.php because it is exactly the same as the one in the RJ_InsertCode-1.2.0.zip file.
  5. I moved the latest lib.php file provided by Jeremy (https://moodle.org/pluginfile.php/143/mod_forum/attachment/1034629/lib.php) into the tinymce directory, overriding the one included in the geshihacks.zip (they are actually the same, only the comment line changes).
  6. I removed the ampersand character at line 58 ("$geshi =& new GeSHi...") of file rj_get_highlighted_code.php.
  7. Went into my Moodle installation and purged all caches (Administration > Development > Purge all caches ).
  8. Created a new course.
  9. Added a page resource, and there it was, the Insert/Edit Code button in the HTML editor toolbar smile

After confirming that the plugin was working, I then created a package only with the required files (the rj_insertcode and the three extra ones).

The uploaded file, geshi_files-originals.7z (sha1: 413B5F5162989A695830C03D49F7745CDF4B752F) has all the original files I used to create the "one file install" bk_tinymce_m251-04_rjic_final.7z file.

Hope this helps everyone.

All the files were packed with 7zip so they would not exceed the 500 KB file size attachment limit.

** Disclaimer

As I initially said, here I'm just summarizing the recommended steps and gathering the files developed by Jeremy W (see the original thread).

Picture of Bob Puffer
Re: Geshi, editor plugin, M 2.5.1
Group Particularly helpful MoodlersGroup Testers

You are a prince

 
Average of ratings: -
Gmads
Re: Geshi, editor plugin, M 2.5.1
 

You're welcome. It worked ok then?

 
Average of ratings: -
Picture of S Moodle
Re: Geshi, editor plugin, M 2.5.1
Group Particularly helpful Moodlers

Great!

Here are a couple of things you can work on:

  1. The percentage width doesn't work.  No matter what percent you put it will always default to 100%
  2. The external style sheet selector doesn't work.  So it uses inline styles which really bloats the rendering HTML for moodle. Just do a view source after you insert code, and you'll know what I mean.
  3. Figure out the non-hack way of making this an official non Moodle Hack plugin.  Since 2.4, there's an official way of installing Moodle TinyMCE plugins.  When you update to 2.5.2, you'll have to do all of this all over again.
 
Average of ratings: -
Picture of Bob Puffer
Re: Geshi, editor plugin, M 2.5.1
Group Particularly helpful MoodlersGroup Testers

Worked like a charm, except plugin was looking for lib/editor/tinymce/tiny_mce/3.5.8/tiny_mce_src.js which was non-existent so no editor would show. Just copied tiny_mce.js and it works.

 

 
Average of ratings: -
Picture of Susana Caixinha
Re: Geshi, editor plugin, M 2.5.1
 

Hi,

I'm having problems in installing your bk_tinymce_m251-04_rjic_final.7z in Moodle 2.5.3.

The text editor disappears when I try to install your files.

Can you help me?

Thanks,

Susana

 
Average of ratings: -
Gmads
Re: Geshi, editor plugin, M 2.5.1
 

Hi Susana,

I don't have the 2.5.3 package so I would have to check with a newer version.

Anyway, I would start by double checking everything and I would also enable the debugging messages.

 
Average of ratings: -
Picture of Bob Puffer
Re: Geshi, editor plugin, M 2.5.1
Group Particularly helpful MoodlersGroup Testers

Did you change the file name as mentioned in my previous post?

 
Average of ratings: -
Picture of Susana Caixinha
Re: Geshi, editor plugin, M 2.5.1
 

Hi,

No I didn´t, I'm going to try that.

Thanks

 
Average of ratings: -
Picture of Susana Caixinha
Re: Geshi, editor plugin, M 2.5.1
 

Hi,

It worked without changing a thing, The first time I tried it was in a test environment and maybe it has some bugs, but now I tried in another 2.5.3 and it worked just fine.

Thank you for all your help.

Susana

 
Average of ratings: -
Gmads
Re: Geshi, editor plugin, M 2.5.1
 

The location for the RJ_InsertCode-1.2.0.zip file has changed, now it is here:

www.ryanjuckett.com/projects/rj_insertcode/

-- http://www.ryanjuckett.com/projects/rj_insertcode/RJ_InsertCode-1.2.0.zip

 
Average of ratings: -
Picture of Carl LeBlond
Re: Geshi, editor plugin, M 2.5.1
 

I didn't realize there was another/newer thread covering this topic.  

I have an updated rj_insert code for Moodle 2.6.  You can find it on my github page available here.

Enjoy!

Carl

 
Average of ratings: -
Picture of Howard Miller
Re: Geshi, editor plugin, M 2.5.1
Group DevelopersGroup Documentation writersGroup Particularly helpful Moodlers

I'm a bit lost here... I have an rj_insertcode installation that involves a 'proper' (looking) Moodle plugin here...

lib/editor/tinymce/plugins/rj_insertcode

It has a version 2013012100 and is Copyright 'Mario Wehr'. Unfortunately it's broken because it tries to load a js file from an external URL that doesn't exist...

http://medit-eportal.cuas.at/lib/editor/tinymce/tiny_mce/3.5.8/tiny_mce_popup.js

This doesn't sound anything like the above...  what have I got here?

Are there any simpler solutions to this problem? All this hacking around with code from various sources is a massive pain sad

 
Average of ratings: -
Gmads
Re: Geshi, editor plugin, M 2.5.1
 

Hello Howard,

I'd say that your version (which is a plugin for Moodle 2.4, but that it also seems to work with version 2.5) came from here:

https://moodle.org/mod/forum/discuss.php?d=176780#p961145 (http://blog.fh-kaernten.at/wehr/?p=2186)

Mario must have taken down the javascript file.

Anyway, you could try and change the code so that it references the tiny_mce_popup.js file at:

{moodledir}/lib/editor/tinymce/tiny_mce/3.5.8

Also, you could try and use what I placed in this thread, which is based on Jeremy's work for Moodle 2.5:

https://moodle.org/mod/forum/discuss.php?d=176780#p1011562

In which case you would only need to uninstall and delete the plugin you have and use the one here.

It should be a matter of only backing-up these three files:

{moodledir}/lib/editor/tinymce/tinymce/lib.php
{moodledir}/lib/editor/tinymce/tinymce/lang/en/editor_tinymce.php
{moodledir}/lib/editor/tinymce/tinymce/tiny_mce/3.5.8/themes/advanced/skins/default/content.css

and downloading and unpacking the bk_tinymce_m251-04_rjic_final.7z file as indicated in the first post.

Cheers!

 
Average of ratings:Useful (1)
Picture of Howard Miller
Re: Geshi, editor plugin, M 2.5.1
Group DevelopersGroup Documentation writersGroup Particularly helpful Moodlers

Thanks...

It makes me all sorts of angry having to change core Moodle files. 

It becomes an administrative nightmare for site upgrades. The original plugin was a proper plugin rather than this 'bodge'. 

Of course, what happens with the new editor in 2.7?

Sigh!! sad

 
Average of ratings: -
Gmads
Re: Geshi, editor plugin, M 2.5.1
 

I couldn't agree more about doing this kind of things by hand. I don't know why it hasn't been packed or developed to be an installable plugin, but I guess there must be a (good?) reason. I did this consolidating and organizing just to help someone who wanted to use the geshi plugin; I actually don't use it. I guess you have already seen the original thread, so well.

Hopefully someone will develop it for the Atto editor.

Did you change the reference to the js file? Did it work?

 
Average of ratings: -
Picture of Howard Miller
Re: Geshi, editor plugin, M 2.5.1
Group DevelopersGroup Documentation writersGroup Particularly helpful Moodlers

I assumed that it was pointing to the external js file because it had been modified in some way.

Are you suggesting that it's just a 'typo' for want of a better way of putting it?

 
Average of ratings: -
Gmads
Re: Geshi, editor plugin, M 2.5.1
 

Hello Howard,

It could be that, now that you mention it. I thought that it was similar to the YUI libraries, regarding their local vs. online use (useexternalyui). I don't know but I don't think that file was customized. You could try and see what happens.

 
Average of ratings: -
Picture of S Moodle
Re: Geshi, editor plugin, M 2.5.1
Group Particularly helpful Moodlers

Guillermo Madero - I couldn't agree more about doing this kind of things by hand. I don't know why it hasn't been packed or developed to be an installable plugin, but I guess there must be a (good?) reason.

The rj_insertcode script was a plugin for the Joomla CMS and when Moodle finally dumped the 1.9 text editor for TinyMCE, we hacked it into the moodle core.

At Moodle 2.0/2.1/2.2/2.3 there was no way to really make easy TinyMCE plugins.  Even worse, Moodle developers made significant changes to the TinyMCE framework for Moodle so I had to figure out different ways of getting it to work.  The Geshi code does work fine for those versions of Moodle

Moodle 2.4 was the first version to have a consistent API for TinyMCE plugins but the documentation is scarce and I tried but failed -- hoping that someone else would take over.  There have been some attempts, but I haven't tested any of them.

Moodle 2.7 completely dumps TinyMCE for Atto. I have no clue how Atto really works or how to make a plugin for it as well.





 
Average of ratings:Useful (2)
Gmads
Re: Geshi, editor plugin, M 2.5.1
 

Thanks! It was interesting to know Yes

 

 
Average of ratings: -
Picture of Monica Franz
Re: Geshi, editor plugin, M 2.5.1
 

Hi,

I've made the 'GoLive' of this TinyMCE plugin for our Moodle platform (2.5.3) and it works fine, including some improvable bagatelles.

I've read that Atto in Moodle 2.7 is an additional editor and not a substitution of TinyMCE in Moodle (see also http://docs.moodle.org/27/en/New_features#Atto.2C_a_new.2C_simple-to-use_editor).

I didn't find an answer in this forum to why the TinyMCE Geshi plugin won't be a normal Moodle Add On, as a lot of Moodle users seem to use it or want to use it and the discussion in past seems to discourage them to install this great plugin (me too)! It took me a lot of time to figure out, the correct way to install this plugin!

Finally Guillermo tried to clean up this confusing discussion and nobody seems to continue his work as an 'official' Moodle developer for this plugin as a new feature. Why not?

Regards,

Monica

 
Average of ratings: -
Picture of Ellen Spertus
Re: Geshi, editor plugin, M 2.5.1
 

Will this work with Moodle 2.9?

Thank you.

 
Average of ratings: -