I thought that an Apache module for Colorer could be useful for highlighting sources/diff etc. on server side?
Source highlightning is very conveniently implemented in PHP apache handler, but it could be possible to add this to other languages as well.
To use something like the snippet below httpd.conf to get all .pys and .lua files highlighted:
...
LoadFile "C:/colorer/mod_colorer.dll"
LoadModule colorer_module "C:/colorer/mod_colorer.dll"
<IfModule colorer_module>
<Location />
AddType text/html .pys, .lua
AddHandler application/x-httpd-colorer .php
AddHandler application/x-httpd-php-source .phps
</Location>
</IfModule>
...
Logged In: YES
user_id=669020
Originator: YES
Oops. Wrong paste. Should be something like that..
...
LoadFile "C:/colorer/mod_colorer.dll"
LoadModule colorer_module "C:/colorer/mod_colorer.dll"
<IfModule colorer_module>
<Location />
AddType text/html .pys, .lua
AddHandler application/x-httpd-colorer .pys, .lua
</Location>
</IfModule>
...
Logged In: YES
user_id=669020
Originator: YES
And another mistake.
...
AddType text/html .pys .lua
AddHandler application/x-httpd-colorer .pys .lua
...
Logged In: YES
user_id=313042
Originator: NO
colorer_cgi.sh/pl/bat:
#!/bin/sh
echo Content-type: text/html
echo
colorer -h "$PATH_TRANSLATED"
httpd.conf.diff:
AddType text/x-lang .cpp .c .h .hpp .pas .asm .java .pl .pm .cgi
AddIconByType (CODE,/icons/c.gif) text/x-lang
Action text/x-lang /cgi-bin/colorer_cgi.bat
# Action text/x-lang /cgi-bin/colorer_cgi.pl
# Action text/x-lang /cgi-bin/colorer_cgi.sh
# need .bat as cgi handler! check it!
AddHandler cgi-script .cgi .bat
This is already in colorer/bin/apache/
Isn't it enough?
Logged In: YES
user_id=669020
Originator: YES
No. Not really. CGI is not effective, because it loads colorer (which in turn parses all config files) every time you need to color some text. Considering amount of resources used - no hosting provider will allow that. But if there would be a separate module, which can load once and run continuosly without significant impact on server performance - that would be an option at least.
Logged In: YES
user_id=313042
Originator: NO
Ok, yes, that can be an issue. However the actual load time can be not very big (note that colorer loads only the schemes it requires to parse the source file).
The solution with the separate apache module is ok, however the drawback is that ultimately this colorer's module will loadup all HRC descriptions. For now the memory consumption on this is 20-30Mb. That's also is not very good for Apache I believe.
Colorer has a number of HRC serialization schemes - this approach can fit better into webserver's requirements. One is implemented in Perl module Syntax-Highlighting-Universal - it gives good startup boost, however it still consumes time.
Another is experimental feature for 'romizing' I've implemented (but not integrated into the trunk) (IRUSSKIH-MEMORY-ROMIZER branch). Theoretically the load time for this scheme is equal to the file read from the storage device. However this is not thoroughly tested.
And the third approach, which can solve this issue, is the parser's redesign I'm working on now. It'll allow parser to use arbitrary HRC description provider and (in particular) different forms of serialized HRC. Hope it'll give good startup improvement.
Igor