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:
- 1926 Bytes
1 | # Allow the metal piece to run in isolation |
2 | require(File.dirname(__FILE__) + "/../../config/environment") unless defined?(Rails) |
3 | |
4 | require 'instiki_stringsupport' |
5 | |
6 | class Itex |
7 | def self.call(env) |
8 | if env["PATH_INFO"] =~ /^\/itex/ |
9 | [200, {"Content-Type" => "application/xml"}, [response(env)]] |
10 | else |
11 | [404, {"Content-Type" => "text/html"}, ["Not Found"]] |
12 | end |
13 | end |
14 | |
15 | private |
16 | |
17 | # plugable XML parser; falls back to REXML |
18 | begin |
19 | require 'nokogiri' |
20 | def self.xmlparse(text) |
21 | Nokogiri::XML(text) { |config| config.options = Nokogiri::XML::ParseOptions::STRICT } |
22 | end |
23 | rescue LoadError |
24 | require 'rexml/document' |
25 | def self.xmlparse(text) |
26 | REXML::Document.new(text) |
27 | end |
28 | end |
29 | |
30 | #error message to return |
31 | def self.error(str) |
32 | "<math xmlns='http://www.w3.org/1998/Math/MathML' display='inline'><merror><mtext>" + |
33 | str + "</mtext></merror></math>" |
34 | end |
35 | |
36 | # itex2MML parser |
37 | begin |
38 | require 'itextomml' |
39 | def self.parse_itex(tex, filter) |
40 | Itex2MML::Parser.new.send(filter, tex).to_utf8 |
41 | end |
42 | rescue LoadError |
43 | def self.parse_itex(tex, filter) |
44 | error("Please install the itex2MML Ruby bindings.") |
45 | end |
46 | end |
47 | |
48 | # the actual response |
49 | def self.response(env) |
50 | params = Rack::Request.new(env).params |
51 | tex = (params['tex'] || '').purify.strip |
52 | case params['display'] |
53 | when 'block' |
54 | filter = :block_filter |
55 | else |
56 | filter = :inline_filter |
57 | end |
58 | return "<math xmlns='http://www.w3.org/1998/Math/MathML' display='" + |
59 | filter.to_s[/(.*?)_filter/] + "'/>" if tex == '' |
60 | begin |
61 | doc = parse_itex(tex, filter) |
62 | # make sure the result is well-formed, before sending it off |
63 | begin |
64 | xmlparse(doc) |
65 | rescue |
66 | return error("Ill-formed XML.") |
67 | end |
68 | return doc |
69 | rescue Itex2MML::Error => e |
70 | error(e.to_s) |
71 | rescue |
72 | error("Unknown Error") |
73 | end |
74 | end |
75 | end |