diff options
author | murphy <murphy@rubychan.de> | 2005-10-22 01:16:34 +0000 |
---|---|---|
committer | murphy <murphy@rubychan.de> | 2005-10-22 01:16:34 +0000 |
commit | 996de449cd5130ca3f073ad241464359c4d6d4fa (patch) | |
tree | b429e98eb5458c9ec32fded0b8ac820786ae7146 /demo/demo_server.rb | |
parent | a4052158f89068317e5a374cc553ef95de1a842a (diff) | |
download | coderay-996de449cd5130ca3f073ad241464359c4d6d4fa.tar.gz |
demo/demo_server.rb: Debug mode.
tokens.rb: orig_each alias deleted; using super now.
scanners/ruby.rb: experimental Regexp/Fancy string recognition for "method /.../" cases.
Diffstat (limited to 'demo/demo_server.rb')
-rw-r--r-- | demo/demo_server.rb | 34 |
1 files changed, 26 insertions, 8 deletions
diff --git a/demo/demo_server.rb b/demo/demo_server.rb index cc3db2b..0972de9 100644 --- a/demo/demo_server.rb +++ b/demo/demo_server.rb @@ -1,10 +1,24 @@ # CodeRay dynamic highlighter
-#
-# Usage: start this and your browser.
-#
-# Go to http://localhost:49374/?<path to the file>
-# (mnemonic: 49374 = Four-Nine-Three-Seven-Four = For No Token Shall Fall)
-# and you should get the highlighted version.
+
+unless ARGV.grep(/-[hv]|--(help|version)/).empty?
+ puts <<-USAGE
+CodeRay Server 0.5
+$Id$
+
+Usage:
+ 1) Start this and your browser.
+ 2) Go to http://localhost:2468/?<path to the file>
+ and you should get the highlighted version.
+
+Parameters:
+ -d Debug mode; reload CodeRay engine for every file.
+ (prepare for MANY "already initialized" and "method redefined"
+ messages - ingore it.)
+
+ ... More to come.
+ USAGE
+ exit
+end
require 'webrick'
require 'pathname'
@@ -29,7 +43,7 @@ require 'coderay' class CodeRayServlet < WEBrick::HTTPServlet::AbstractServlet
STYLE = 'style="font-family: sans-serif; color: navy;"'
- BANNER = '<p><img src="http://rd.cYcnus.de/coderay/coderay-banner" style="border: 0" alt="HIghlighted by CodeRay"/></p>'
+ BANNER = '<p><img src="http://rd.cYcnus.de/coderay/coderay-banner" style="border: 0" alt="Highlighted by CodeRay"/></p>'
def do_GET req, res
q = req.query_string || ''
@@ -59,6 +73,10 @@ class CodeRayServlet < WEBrick::HTTPServlet::AbstractServlet page << "#{BANNER}</body></html>"
elsif File.exist? path
+ if $DEBUG
+ $".delete_if { |f| f =~ /coderay/ }
+ require 'coderay'
+ end
div = CodeRay.scan_file(path).html :tab_width => 8, :wrap => :div
div.replace <<-DIV
<div #{STYLE}>
@@ -74,7 +92,7 @@ class CodeRayServlet < WEBrick::HTTPServlet::AbstractServlet end
end
-# this is taken by "qip_msgd" - I don't know that.
+# This port is taken by "qip_msgd" - I don't know that. Do you?
module CodeRay
PORT = 0xC0DE / 20
end
|