Changesets can be listed by changeset number.
The Git repository is here.
- Revision:
- 344
- Log:
Massive changeset which brings the old, ROOL customised Instiki
version up to date, but without any ROOL customisations in this
latest checked-in version (which is 0.19.1). This is deliberate,
so that it's easy to see the changes made for the ROOL version
in a subsequent changeset. The 'app/views/shared' directory is not
part of Instiki but is kept to maintain the change history with
updated ROOL customisations, some of which involve the same files
in that same directory.
- Author:
- rool
- Date:
- Sat Mar 19 19:52:13 +0000 2011
- Size:
- 4106 Bytes
1 | begin |
2 | require "rdoc/markup/simple_markup" |
3 | require 'rdoc/markup/simple_markup/to_html' |
4 | rescue LoadError |
5 | # Ruby 1.9 |
6 | require "rdoc/markup" |
7 | require 'rdoc/markup/to_html' |
8 | module SM |
9 | class SimpleMarkup < RDoc::Markup |
10 | end |
11 | class ToHtml <RDoc::Markup::ToHtml |
12 | end |
13 | end |
14 | end |
15 | |
16 | module RDocSupport |
17 | |
18 | # A simple +rdoc+ markup class which recognizes some additional |
19 | # formatting commands suitable for Wiki use. |
20 | class RDocMarkup < SM::SimpleMarkup |
21 | def initialize |
22 | super() |
23 | |
24 | pre = '(?:\\s|^|\\\\)' |
25 | |
26 | # links of the form |
27 | # [[<url> description with spaces]] |
28 | add_special(/((\\)?\[\[\S+?\s+.+?\]\])/,:TIDYLINK) |
29 | |
30 | # and external references |
31 | add_special(/((\\)?(link:|anchor:|http:|mailto:|ftp:|img:|www\.)\S+\w\/?)/, |
32 | :HYPERLINK) |
33 | |
34 | # <br/> |
35 | add_special(%r{(#{pre}<br/>)}, :BR) |
36 | |
37 | # and <center> ... </center> |
38 | add_html("center", :CENTER) |
39 | end |
40 | |
41 | def convert(text, handler) |
42 | super.sub(/^<p>\n/, '').sub(/<\/p>$/, '') |
43 | end |
44 | end |
45 | |
46 | # Handle special hyperlinking requirments for RDoc formatted |
47 | # entries. Requires RDoc |
48 | |
49 | class HyperLinkHtml < SM::ToHtml |
50 | |
51 | # Initialize the HyperLinkHtml object. |
52 | # [path] location of the node |
53 | # [site] object representing the whole site (typically of class |
54 | # +Site+) |
55 | def initialize |
56 | super() |
57 | add_tag(:CENTER, "<center>", "</center>") |
58 | end |
59 | |
60 | # handle <br/> |
61 | def handle_special_BR(special) |
62 | return "<br/>" if special.text[0,1] == '\\' |
63 | special.text |
64 | end |
65 | |
66 | # We're invoked with a potential external hyperlink. |
67 | # [mailto:] just gets inserted. |
68 | # [http:] links are checked to see if they |
69 | # reference an image. If so, that image gets inserted |
70 | # using an <img> tag. Otherwise a conventional <a href> |
71 | # is used. |
72 | # [img:] insert a <tt><img></tt> tag |
73 | # [link:] used to insert arbitrary <tt><a></tt> references |
74 | # [anchor:] used to create an anchor |
75 | def handle_special_HYPERLINK(special) |
76 | text = special.text.strip |
77 | return text[1..-1] if text[0,1] == '\\' |
78 | url = special.text.strip |
79 | if url =~ /([A-Za-z]+):(.*)/ |
80 | type = $1 |
81 | path = $2 |
82 | else |
83 | type = "http" |
84 | path = url |
85 | url = "http://#{url}" |
86 | end |
87 | |
88 | case type |
89 | when "http" |
90 | if url =~ /\.(gif|png|jpg|jpeg|bmp)$/ |
91 | "<img src=\"#{url}\"/>" |
92 | else |
93 | "<a href=\"#{url}\">#{url.sub(%r{^\w+:/*}, '')}</a>" |
94 | end |
95 | when "img" |
96 | "<img src=\"#{path}\"/>" |
97 | when "link" |
98 | "<a href=\"#{path}\">#{path}</a>" |
99 | when "anchor" |
100 | "<a name=\"#{path}\"></a>" |
101 | else |
102 | "<a href=\"#{url}\">#{url.sub(%r{^\w+:/*}, '')}</a>" |
103 | end |
104 | end |
105 | |
106 | # Here's a hyperlink where the label is different to the URL |
107 | # [[url label that may contain spaces]] |
108 | # |
109 | |
110 | def handle_special_TIDYLINK(special) |
111 | text = special.text.strip |
112 | return text[1..-1] if text[0,1] == '\\' |
113 | unless text =~ /\[\[(\S+?)\s+(.+?)\]\]/ |
114 | return text |
115 | end |
116 | url = $1 |
117 | label = $2 |
118 | label = RDocFormatter.new(label).to_html |
119 | label = label.split.select{|x| x =~ /\S/}. |
120 | map{|x| x.chomp}.join(' ') |
121 | |
122 | case url |
123 | when /link:(\S+)/ |
124 | return %{<a href="#{$1}">#{label}</a>} |
125 | when /img:(\S+)/ |
126 | return %{<img src="http://#{$1}" alt="#{label}" />} |
127 | when /rubytalk:(\S+)/ |
128 | return %{<a href="http://ruby-talk.org/blade/#{$1}">#{label}</a>} |
129 | when /rubygarden:(\S+)/ |
130 | return %{<a href="http://www.rubygarden.org/ruby?#{$1}">#{label}</a>} |
131 | when /c2:(\S+)/ |
132 | return %{<a href="http://c2.com/cgi/wiki?#{$1}">#{label}</a>} |
133 | when /isbn:(\S+)/ |
134 | return %{<a href="http://search.barnesandnoble.com/bookSearch/} + |
135 | %{isbnInquiry.asp?isbn=#{$1}">#{label}</a>} |
136 | end |
137 | |
138 | unless url =~ /\w+?:/ |
139 | url = "http://#{url}" |
140 | end |
141 | |
142 | "<a href=\"#{url}\">#{label}</a>" |
143 | end |
144 | end |
145 | |
146 | class RDocFormatter |
147 | def initialize(text) |
148 | @text = text |
149 | end |
150 | |
151 | def to_html |
152 | markup = RDocMarkup.new |
153 | h = HyperLinkHtml.new |
154 | markup.convert(@text, h) |
155 | end |
156 | end |
157 | |
158 | end |