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