diff -N -r -u5 instiki-0.6.0.orig/app/models/revision.rb instiki-0.6.0/app/models/revision.rb --- instiki-0.6.0.orig/app/models/revision.rb 2004-04-15 23:20:25.000000000 +0200 +++ instiki-0.6.0/app/models/revision.rb 2004-04-16 12:18:07.000000000 +0200 @@ -1,8 +1,9 @@ $: << File.dirname(__FILE__) + "../../libraries" require "redcloth" +require "rdocsupport" require "date" require "author" require "page" require "wiki_words" @@ -64,18 +65,22 @@ end private def textilize(content) - safe_mode_options = [:filter_html, :filter_styles] if Object.const_defined?("OPTIONS") && OPTIONS[:safe_mode] - RedCloth.new(create_auto_links(content.to_s.dup), safe_mode_options || []).to_html + if Object.const_defined?("OPTIONS") && OPTIONS[:markup] == :rdoc + RDocSupport::RDocFormatter.new(content.to_s).to_html + else + safe_mode_options = [:filter_html, :filter_styles] if Object.const_defined?("OPTIONS") && OPTIONS[:safe_mode] + RedCloth.new(create_auto_links(content.to_s.dup), safe_mode_options || []).to_html + end end def create_auto_links(text) urls_linked = text.gsub( /([^=>\3\4\5\6\7' ) # " ruby-mode urls_and_mails_linked = urls_linked.gsub(/([\w\.!#\$%\-+.]+@[A-Za-z0-9\-]+(\.[A-Za-z0-9\-]+)+)/, '\1') end -end \ No newline at end of file +end diff -N -r -u5 instiki-0.6.0.orig/app/views/rdoc_help.rhtml instiki-0.6.0/app/views/rdoc_help.rhtml --- instiki-0.6.0.orig/app/views/rdoc_help.rhtml 1970-01-01 01:00:00.000000000 +0100 +++ instiki-0.6.0/app/views/rdoc_help.rhtml 2004-04-16 12:49:28.000000000 +0200 @@ -0,0 +1,81 @@ + + +
+

Basic formatting tips

+ + + + + + + + + + + + +
_your text_your text
*your text*your text
* Bulleted list
* Second item
• Bulleted list
• Second item
1. Numbered list
2. Second item
1. Numbered list
2. Second item
[[URL linkname]]linkname
http://url
mailto:email@address.com
Auto-linked
imageURLImage
anchor:anchornameAnchor #anchorname
link:#anchornameLink to #anchorname
[[rubytalk:12345 link to some posting in + ruby-talk]] + link to + some posting in ruby-talk
[[isbn:0201710897 link to a book by ISBN]] + + link to a book by ISBN +
+

Wiki words

+

+ Two or more uppercase words stuck together is a wiki word that links to the page of that name. + If the page doesn't already exist, the question mark trailing the name will link to a blank slate that becomes the page when saved. + A wiki word can be escaped by putting \ in front of it. +

+

+ Wiki words: HomePage, ThreeWordsTogether
+ Not wiki words: IBM, School +

+
diff -N -r -u5 instiki-0.6.0.orig/app/views/wiki/edit.rhtml instiki-0.6.0/app/views/wiki/edit.rhtml --- instiki-0.6.0.orig/app/views/wiki/edit.rhtml 2004-04-15 23:20:26.000000000 +0200 +++ instiki-0.6.0/app/views/wiki/edit.rhtml 2004-04-16 12:41:44.000000000 +0200 @@ -2,11 +2,17 @@ <% @content_width = 720 %> <%= sub_template "top" %>

Editing <%= @page.plain_name %>

-<%= sub_template "textile_help" %> +<%= + if Object.const_defined?("OPTIONS") && OPTIONS[:markup] == :rdoc + sub_template "rdoc_help" + else + sub_template "textile_help" + end +%>

@@ -27,6 +33,6 @@ return false; } } -<%= sub_template "bottom" %> \ No newline at end of file +<%= sub_template "bottom" %> diff -N -r -u5 instiki-0.6.0.orig/app/views/wiki/write.rhtml instiki-0.6.0/app/views/wiki/write.rhtml --- instiki-0.6.0.orig/app/views/wiki/write.rhtml 2004-04-15 23:20:26.000000000 +0200 +++ instiki-0.6.0/app/views/wiki/write.rhtml 2004-04-16 12:41:55.000000000 +0200 @@ -2,11 +2,17 @@ <% @content_width = 720 %> <%= sub_template "top" %>

Creating <%= WikiWords.separate(@page_name) %>

-<%= sub_template "textile_help" %> +<%= + if Object.const_defined?("OPTIONS") && OPTIONS[:markup] == :rdoc + sub_template "rdoc_help" + else + sub_template "textile_help" + end +%>

@@ -25,6 +31,6 @@ return false; } } -<%= sub_template "bottom" %> \ No newline at end of file +<%= sub_template "bottom" %> diff -N -r -u5 instiki-0.6.0.orig/instiki.rb instiki-0.6.0/instiki.rb --- instiki-0.6.0.orig/instiki.rb 2004-04-15 23:20:27.000000000 +0200 +++ instiki-0.6.0/instiki.rb 2004-04-16 12:18:42.000000000 +0200 @@ -14,11 +14,12 @@ end OPTIONS = { :multi_web => false, :server_type => fork_available ? Daemon : SimpleServer, - :port => 2500 + :port => 2500, + :markup => :redcloth } ARGV.options do |opts| script_name = File.basename($0) opts.banner = "Usage: ruby #{script_name} [options]" @@ -36,10 +37,14 @@ ) { OPTIONS[:server_type] = SimpleServer } opts.on("-S", "--safe", "--safe-mode", "Enables safe mode.", "This will filter out user-supplied HTML and CSS." ) { OPTIONS[:safe_mode] = true } + opts.on("-r", "--rdoc", + "Use RDoc markup.", + "The contents are interpreted as RDoc markup." + ) { OPTIONS[:markup] = :rdoc } opts.separator "" opts.on("-h", "--help", "Show this help message.") { puts opts; exit } @@ -51,6 +56,6 @@ Socket.do_not_reverse_lookup = true WikiService.storage_path = "#{cdir}/storage/#{OPTIONS[:port]}" WikiService.run_as_single_web if !OPTIONS[:multi_web] WikiController.template_root = "#{cdir}/app/views/" -WebControllerServer.new(OPTIONS[:port], OPTIONS[:server_type], "#{cdir}/app/controllers/") \ No newline at end of file +WebControllerServer.new(OPTIONS[:port], OPTIONS[:server_type], "#{cdir}/app/controllers/") diff -N -r -u5 instiki-0.6.0.orig/libraries/rdocsupport.rb instiki-0.6.0/libraries/rdocsupport.rb --- instiki-0.6.0.orig/libraries/rdocsupport.rb 1970-01-01 01:00:00.000000000 +0100 +++ instiki-0.6.0/libraries/rdocsupport.rb 2004-04-16 12:35:55.000000000 +0200 @@ -0,0 +1,165 @@ + +case RUBY_VERSION +when /(^1\.8\.[1-9])|(^1\.9)/ + require "rdoc/markup/simple_markup" + require 'rdoc/markup/simple_markup/to_html' +else + begin + require 'markup/simple_markup' + require 'markup/simple_markup/to_html' + rescue LoadError + puts < description with spaces]] + add_special(/((\\)?\[\[\S+?\s+.+?\]\])/,:TIDYLINK) + + # and external references + add_special(/((\\)?(link:|anchor:|http:|mailto:|ftp:|img:|www\.)\S+\w\/?)/, + :HYPERLINK) + + #
+ add_special(%r{(#{pre}
)}, :BR) + + # and
...
+ add_html("center", :CENTER) + end + + def convert(text, handler) + #$stderr.puts text.inspect + res = super + res.sub!(/^

\n/, '') + res.sub!(/<\/p>$/, '') + res + end +end + +# Handle special hyperlinking requirments for RDoc formatted +# entries. Requires RDoc + +class HyperLinkHtml < SM::ToHtml + + # Initialize the HyperLinkHtml object. + # [path] location of the node + # [site] object representing the whole site (typically of class + # +Site+) + def initialize + super() + add_tag(:CENTER, "

", "
") + end + + # handle
+ def handle_special_BR(special) + return "<br/>" if special.text[0,1] == '\\' + special.text + end + + # We're invoked with a potential external hyperlink. + # [mailto:] just gets inserted. + # [http:] links are checked to see if they + # reference an image. If so, that image gets inserted + # using an tag. Otherwise a conventional + # is used. + # [img:] insert a tag + # [link:] used to insert arbitrary references + # [anchor:] used to create an anchor + def handle_special_HYPERLINK(special) + text = special.text.strip + return text[1..-1] if text[0,1] == '\\' + url = special.text.strip + if url =~ /([A-Za-z]+):(.*)/ + type = $1 + path = $2 + else + type = "http" + path = url + url = "http://#{url}" + end + + case type + when "http" + if url =~ /\.(gif|png|jpg|jpeg|bmp)$/ + "" + else + "#{url.sub(%r{^\w+:/*}, '')}" + end + when "img" + "" + when "link" + "#{path}" + when "anchor" + "" + else + "#{url.sub(%r{^\w+:/*}, '')}" + end + end + + # Here's a hyperlink where the label is different to the URL + # [[url label that may contain spaces]] + # + + def handle_special_TIDYLINK(special) + text = special.text.strip + return text[1..-1] if text[0,1] == '\\' + unless text =~ /\[\[(\S+?)\s+(.+?)\]\]/ + return text + end + url = $1 + label = $2 + label = RDocFormatter.new(label).to_html + label = label.split.select{|x| x =~ /\S/}. + map{|x| x.chomp}.join(' ') + + case url + when /link:(\S+)/ + return %{#{label}} + when /img:(\S+)/ + return %{#{label}} + when /rubytalk:(\S+)/ + return %{#{label}} + when /rubygarden:(\S+)/ + return %{#{label}} + when /c2:(\S+)/ + return %{#{label}} + when /isbn:(\S+)/ + return %{#{label}} + end + + unless url =~ /\w+?:/ + url = "http://#{url}" + end + + "#{label}" + end +end + +class RDocFormatter + def initialize(text) + @text = text + end + + def to_html + markup = RDocMarkup.new + h = HyperLinkHtml.new + markup.convert(@text, h) + end +end + +end