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:
- 4879 Bytes
1 | $: << File.dirname(__FILE__) + "../../lib" |
2 | |
3 | require_dependency 'chunks/chunk' |
4 | require 'instiki_stringsupport' |
5 | require 'maruku' |
6 | require 'maruku/ext/math' |
7 | require_dependency 'rdocsupport' |
8 | require 'redcloth' |
9 | |
10 | # The markup engines are Chunks that call the one of RedCloth |
11 | # or RDoc to convert text. This markup occurs when the chunk is required |
12 | # to mask itself. |
13 | module Engines |
14 | class AbstractEngine < Chunk::Abstract |
15 | |
16 | # Create a new chunk for the whole content and replace it with its mask. |
17 | def self.apply_to(content) |
18 | new_chunk = self.new(content) |
19 | content.replace(new_chunk.mask) |
20 | end |
21 | |
22 | private |
23 | |
24 | # Never create engines by constructor - use apply_to instead |
25 | def initialize(content) |
26 | @content = content |
27 | end |
28 | |
29 | end |
30 | |
31 | class Textile < AbstractEngine |
32 | def mask |
33 | @content.as_utf8 |
34 | redcloth = RedCloth.new(@content, [:hard_breaks] + @content.options[:engine_opts]) |
35 | redcloth.filter_html = false |
36 | redcloth.no_span_caps = false |
37 | html = redcloth.to_html(:textile) |
38 | end |
39 | end |
40 | |
41 | class Markdown < AbstractEngine |
42 | def mask |
43 | @content.as_utf8 |
44 | # If the request is for S5, call Maruku accordingly (without math) |
45 | if @content.options[:mode] == :s5 |
46 | my_content = Maruku.new(@content.delete("\r").to_utf8, |
47 | {:math_enabled => false, :content_only => true, |
48 | :author => @content.options[:engine_opts][:author], |
49 | :title => @content.options[:engine_opts][:title]}) |
50 | @content.options[:renderer].s5_theme = my_content.s5_theme |
51 | else |
52 | html = Maruku.new(@content.delete("\r").to_utf8, {:math_enabled => false}).to_html |
53 | html.gsub(/\A<div class="maruku_wrapper_div">\n?(.*?)\n?<\/div>\Z/m, '\1') |
54 | end |
55 | |
56 | end |
57 | end |
58 | |
59 | class MarkdownMML < AbstractEngine |
60 | def mask |
61 | @content.as_utf8 |
62 | # If the request is for S5, call Maruku accordingly |
63 | if @content.options[:mode] == :s5 |
64 | my_content = Maruku.new(@content.delete("\r").to_utf8, |
65 | {:math_enabled => true, |
66 | :math_numbered => ['\\[','\\begin{equation}'], |
67 | :content_only => true, |
68 | :author => @content.options[:engine_opts][:author], |
69 | :title => @content.options[:engine_opts][:title]}) |
70 | @content.options[:renderer].s5_theme = my_content.s5_theme |
71 | my_content.to_s5 |
72 | else |
73 | html = Maruku.new(@content.delete("\r").to_utf8, |
74 | {:math_enabled => true, |
75 | :math_numbered => ['\\[','\\begin{equation}']}).to_html |
76 | html.gsub(/\A<div class="maruku_wrapper_div">\n?(.*?)\n?<\/div>\Z/m, '\1') |
77 | end |
78 | end |
79 | end |
80 | |
81 | class MarkdownPNG < AbstractEngine |
82 | def mask |
83 | @content.as_utf8 |
84 | # If the request is for S5, call Maruku accordingly |
85 | if @content.options[:mode] == :s5 |
86 | my_content = Maruku.new(@content.delete("\r").to_utf8, |
87 | {:math_enabled => true, |
88 | :math_numbered => ['\\[','\\begin{equation}'], |
89 | :html_math_output_mathml => false, |
90 | :html_math_output_png => true, |
91 | :html_png_engine => 'blahtex', |
92 | :html_png_dir => @content.web.files_path.join('pngs').to_s, |
93 | :html_png_url => @content.options[:png_url], |
94 | :content_only => true, |
95 | :author => @content.options[:engine_opts][:author], |
96 | :title => @content.options[:engine_opts][:title]}) |
97 | @content.options[:renderer].s5_theme = my_content.s5_theme |
98 | my_content.to_s5 |
99 | else |
100 | html = Maruku.new(@content.delete("\r").to_utf8, |
101 | {:math_enabled => true, |
102 | :math_numbered => ['\\[','\\begin{equation}'], |
103 | :html_math_output_mathml => false, |
104 | :html_math_output_png => true, |
105 | :html_png_engine => 'blahtex', |
106 | :html_png_dir => @content.web.files_path.join('pngs').to_s, |
107 | :html_png_url => @content.options[:png_url]}).to_html |
108 | html.gsub(/\A<div class="maruku_wrapper_div">\n?(.*?)\n?<\/div>\Z/m, '\1') |
109 | end |
110 | end |
111 | end |
112 | |
113 | class Mixed < AbstractEngine |
114 | def mask |
115 | @content.as_utf8 |
116 | redcloth = RedCloth.new(@content, @content.options[:engine_opts]) |
117 | redcloth.filter_html = false |
118 | redcloth.no_span_caps = false |
119 | html = redcloth.to_html |
120 | end |
121 | end |
122 | |
123 | class RDoc < AbstractEngine |
124 | def mask |
125 | @content.as_utf8 |
126 | html = RDocSupport::RDocFormatter.new(@content).to_html |
127 | end |
128 | end |
129 | |
130 | MAP = { :textile => Textile, :markdown => Markdown, :markdownMML => MarkdownMML, :markdownPNG => MarkdownPNG, :mixed => Mixed, :rdoc => RDoc } |
131 | MAP.default = MarkdownMML |
132 | end |