Clan Adverts

PhpNuke · Nuke Wysiwyg Syntax Highlighting 2.1.0

Posted on Wednesday, August 12, 2009 @ 19:17 by admin

Nuke Wysiwyg Syntax HighlightingI needed to post some code in an article / tutorial I am writing for beginners learning nuke modules.  I soon realized that nuke wysiwyg didn't have much capiblity for that.  So that lead me to another mission and what I found changed me forever.  I would like to introduce syntax highlighting for Nuke Wysiwyg 2.6.4.1.  I did make some minor changes, but 99% of the code was already done for me.  I simply integrated it into an already brilliant nuke hack.

Basic Features:

  • Highlighting available for ActionScript, Bash/Shell, C#, C++, CSS, Delphi, Diff, Groovy, Javascript, Java, JavaFX, Perl, PHP, Plain Text, Powershell, Python, Ruby, Scala, SQL, Visual Basic, XML  (please see note about XML)
  • Print Highlighted Code
  • Plain Text View
  • Copy to Clipboard
  • Focus attention on specific lines
  • Custom Highlighting Themes
  • much more...

Requirements:

 Nuke Wysiwyg from NukeSeo.com (registration required)

Original Authors:

http://psykoptic.com/ (FCKEditor Plugin for SyntaxHighlighter)

http://alexgorbatchev.com/ (Author of SyntaxHighlighter)

Download:

 http://www.clanthemes.com/downloaddetails-46-895-nuke-wysiwyg-syntax-highlighting.html

Installation:

Step 1) Download and extract Nuke_Wysiwyg_Syntax_Highlighting.zip.  Upload the contents of the html folder to your nuke root.

Step 2) Open nuke_root/includes/fckeditor/fckconfig.js

Find

FCKConfig.PreloadImages = [ FCKConfig.SkinPath + 'images/toolbar.start.gif', FCKConfig.SkinPath + 'images/toolbar.buttonarrow.gif' ] ;

FCKConfig.PluginsPath = FCKConfig.BasePath + 'plugins/' ;

 

Below On A New Line Add

// ----------------------
// Configure Syntax highlighter for 2.0.x
FCKConfig.Plugins.Add('syntaxhighlight2', 'en');
// default language options:
// c++,csharp,css,delphi,java,jscript,php,python,ruby,sql,vb,xhtml
FCKConfig.SyntaxHighlight2LangDefault = 'php';
//
// ----------------------

Find

FCKConfig.ToolbarSets["PHPNukeAdmin"] = [
	['Source','FitWindow','ShowBlocks','DocProps','-','Save','NewPage','-','Templates'],
	['Cut','Copy','Paste','PasteText','PasteWord','-','SpellCheck','Print'],
	['Undo','Redo','-','Find','-','SelectAll','RemoveFormat'],
	['Bold','Italic','Underline','StrikeThrough','-','Subscript','Superscript'],
	['OrderedList','UnorderedList','-','Outdent','Indent','Blockquote','CreateDiv'],
	['JustifyLeft','JustifyCenter','JustifyRight','JustifyFull'],
	['Link','Unlink','Anchor'],
	'/',
	['Image','Flash','Table','Rule','Smiley','SpecialChar','PageBreak'],
	['Style','FontFormat','FontName','FontSize'],
	['TextColor','BGColor'],
	['-','About',]
] ;

Change To

FCKConfig.ToolbarSets["PHPNukeAdmin"] = [
	['Source','FitWindow','ShowBlocks','DocProps','-','Save','NewPage','-','Templates'],
	['Cut','Copy','Paste','PasteText','PasteWord','-','SpellCheck','Print'],
	['Undo','Redo','-','Find','-','SelectAll','RemoveFormat'],
	['Bold','Italic','Underline','StrikeThrough','-','Subscript','Superscript'],
	['OrderedList','UnorderedList','-','Outdent','Indent','Blockquote','CreateDiv'],
	['JustifyLeft','JustifyCenter','JustifyRight','JustifyFull'],
	['Link','Unlink','Anchor'],
	'/',
	['Image','Flash','Table','Rule','Smiley','SpecialChar','PageBreak'],
	['Style','FontFormat','FontName','FontSize'],
	['TextColor','BGColor'],
	['SyntaxHighLight2','-','About',]
] ;

Save and Re-Upload to your nuke_root/includes/fckeditor folder.

Step 3)  Open nuke_root/header.php

Find

echo "</head>";

On a new line above add

echo '<script type="text/javascript" src="includes/syntax/scripts/shCore.js"></script>
<script type="text/javascript" src="includes/syntax/scripts/shBrushBash.js"></script>
<script type="text/javascript" src="includes/syntax/scripts/shBrushCpp.js"></script>
<script type="text/javascript" src="includes/syntax/scripts/shBrushCSharp.js"></script>
<script type="text/javascript" src="includes/syntax/scripts/shBrushCss.js"></script>
<script type="text/javascript" src="includes/syntax/scripts/shBrushDelphi.js"></script>
<script type="text/javascript" src="includes/syntax/scripts/shBrushDiff.js"></script>
<script type="text/javascript" src="includes/syntax/scripts/shBrushGroovy.js"></script>
<script type="text/javascript" src="includes/syntax/scripts/shBrushJava.js"></script>
<script type="text/javascript" src="includes/syntax/scripts/shBrushJavaFX.js"></script>
<script type="text/javascript" src="includes/syntax/scripts/shBrushJScript.js"></script>
<script type="text/javascript" src="includes/syntax/scripts/shBrushPhp.js"></script>
<script type="text/javascript" src="includes/syntax/scripts/shBrushPlain.js"></script>
<script type="text/javascript" src="includes/syntax/scripts/shBrushPython.js"></script>
<script type="text/javascript" src="includes/syntax/scripts/shBrushRuby.js"></script>
<script type="text/javascript" src="includes/syntax/scripts/shBrushScala.js"></script>
<script type="text/javascript" src="includes/syntax/scripts/shBrushSql.js"></script>
<script type="text/javascript" src="includes/syntax/scripts/shBrushVb.js"></script>
<script type="text/javascript" src="includes/syntax/scripts/shBrushXml.js"></script>
<link type="text/css" rel="stylesheet" href="includes/syntax/styles/shCore.css"/>
<link type="text/css" rel="stylesheet" href="includes/syntax/styles/shThemeDefault.css"/>';
echo '<script type="text/javascript">';
echo "SyntaxHighlighter.config.clipboardSwf = 'includes/syntax/scripts/clipboard.swf';
	SyntaxHighlighter.all();
</script>";

 You can customize the look of your highlighting with one of the included themes or design your own.  I changed it here on Clan Themes just for demo.  All you have to do is change the .css name in the above code.  (example below)

Find

<link type="text/css" rel="Stylesheet" href="/styles/shThemeDefault.css"/>

Change to

<!--Or Whatever you pick-->
<link type="text/css" rel="Stylesheet" href="/styles/shThemeEmacs.css"/>

 

Save and Re-Upload to your nuke_root/ folder.

Usuage:

 I only added it to the admin side of Nuke Wysiwyg to avoid potential security risks (I am testing for public side use).  In your news->admin for instance you will see a new tag beside the about image on the toolbar.

When you click it you are going to see a new window like the image below.

 

All you simply have to do is paste your code in that box and hit ok.  For more specific control you should check out the advanced tab.  For full docmentation please visit the SyntaxHighlighter Wiki.

Post in the forums if you have trouble installing.

Floppy,

Clan Themes


Votes up: 14 / Votes down: 1
Random Products

Snype

Snype writes ( Permalink )
I have seen this on many sites befor and never knew what it was called, I do think this is a great add on and may add it to my site(not that i need it just good to have it)

Wednesday, August 12, 2009 @ 20:03

floppy

floppy writes ( Permalink )
I needed it and it happens to be one of the few things that I have not customized so much that everyone can not use it. I realize it is not a mod everyone will use, but I will use it all the time.

Wednesday, August 12, 2009 @ 20:57

Raven

Raven writes ( Permalink )
Have you tried this with RavenNuke(tm)?

Wednesday, August 12, 2009 @ 23:38

floppy

floppy writes ( Permalink )
Have you tried this with RavenNuke(tm)?


Well Clan Themes is based on RavenNuke, just not the latest version. However, we are running Nuke Wysiwyg 2.6.4.1 and that is all it really relies on. I cant foresee any reason it wouldnt work.

Wednesday, August 12, 2009 @ 23:41

floppy

floppy writes ( Permalink )
Have you tried this with RavenNuke(tm)?


I just tested it on the latest version and I did find a very minor error, but I just fixed that. The error comes when you try to escape characters in mixed source like php & javascript. So I quickly rewrote the installation part so it would work properly.

Will have to address that mixing source languages later.

Wednesday, August 12, 2009 @ 23:56

Raven

Raven writes ( Permalink )
Thanks!

Thursday, August 13, 2009 @ 00:19

floppy

floppy writes ( Permalink )
One draw back we have discovered (or shall I say kgsuke) is that at current status of wysiwyg it will not work on the user side. I think in the future this can be corrected as nuke develops.

Tuesday, August 18, 2009 @ 08:39

Comments Closed for this Article!
Comments are always closed 1 month after the article has been published.
 

Advertisement