No need to figure the code type out, setup the autoloader.
authorMichael J. Rubinsky <mrubinsk@horde.org>
Fri, 8 Oct 2010 00:48:34 +0000 (20:48 -0400)
committerMichael J. Rubinsky <mrubinsk@horde.org>
Fri, 8 Oct 2010 00:48:34 +0000 (20:48 -0400)
jonah/lib/View/StoryView.php

index e483955..c2b6f49 100644 (file)
@@ -27,20 +27,48 @@ class Jonah_View_StoryView extends Jonah_View_Base
         extract($this->_params, EXTR_REFS);
 
         Horde::addScriptFile('syntaxhighlighter/scripts/shCore.js', 'horde', true);
+        Horde::addScriptFile('syntaxhighlighter/scripts/shAutoloader.js', 'horde', true);
+        $path = $GLOBALS['registry']->get('jsuri', 'horde') . '/syntaxhighlighter/scripts/';
+        $brushes = <<<EOT
+          SyntaxHighlighter.autoloader(
+          'applescript            {$path}shBrushAppleScript.js',
+          'actionscript3 as3      {$path}shBrushAS3.js',
+          'bash shell             {$path}shBrushBash.js',
+          'coldfusion cf          {$path}shBrushColdFusion.js',
+          'cpp c                  {$path}shBrushCpp.js',
+          'c# c-sharp csharp      {$path}shBrushCSharp.js',
+          'css                    {$path}shBrushCss.js',
+          'delphi pascal          {$path}shBrushDelphi.js',
+          'diff patch pas         {$path}shBrushDiff.js',
+          'erl erlang             {$path}shBrushErlang.js',
+          'groovy                 {$path}shBrushGroovy.js',
+          'java                   {$path}shBrushJava.js',
+          'jfx javafx             {$path}shBrushJavaFX.js',
+          'js jscript javascript  {$path}shBrushJScript.js',
+          'perl pl                {$path}shBrushPerl.js',
+          'php                    {$path}shBrushPhp.js',
+          'text plain             {$path}shBrushPlain.js',
+          'py python              {$path}shBrushPython.js',
+          'ruby rails ror rb      {$path}shBrushRuby.js',
+          'sass scss              {$path}shBrushSass.js',
+          'scala                  {$path}shBrushScala.js',
+          'sql                    {$path}shBrushSql.js',
+          'vb vbnet               {$path}shBrushVb.js',
+          'xml xhtml xslt html    {$path}shBrushXml.js'
+        );
+EOT;
         Horde::addInlineScript(array(
+            $brushes,
             'SyntaxHighlighter.defaults[\'toolbar\'] = false',
-            'SyntaxHighlighter.all()',
+            'SyntaxHighlighter.all()'
         ), 'dom');
 
-        // TODO: Need a way to figure out what language the code block is...
-        // probably a regex to look for the <pre brush="php"> tags?
         $sh_js_fs = $GLOBALS['registry']->get('jsfs', 'horde') . '/syntaxhighlighter/styles/';
         $sh_js_uri = Horde::url($GLOBALS['registry']->get('jsuri', 'horde'), false, -1) . '/syntaxhighlighter/styles/';
         Horde_Themes::includeStylesheetFiles(array('additional' => array(
             array('f' => $sh_js_fs . 'shCoreEclipse.css', 'u' => $sh_js_uri . 'shCoreEclipse.css'),
             array('f' => $sh_js_fs . 'shThemeEclipse.css', 'u' => $sh_js_uri . 'shThemeEclipse.css'),
         )));
-        Horde::addScriptFile('syntaxhighlighter/scripts/shBrush' . 'php' . '.js', 'horde', true);
 
         $driver = $GLOBALS['injector']->getInstance('Jonah_Driver');
         try {