Changesets can be listed by changeset number.
The Git repository is here.
- Revision:
- 193
- Log:
First stage commit of Typo 4.1, modified for the ROOL site.
Includes all local modifications but a final pass needs to be
made to delete any files left over from earlier Typo versions
that shouldn't be here anymore. See the 'tags' section of the
repository for a clean Typo 4.1 tree.Note that symlinks to shared files in the RISC OS Open theme
directory have been deliberately included this time around; I
decided that on balance it was better to leave them in as
placeholders, since unlike symlinks in app/views/shared, the
Typo theme structure is not a standard Rails concept.
- Author:
- rool
- Date:
- Wed Apr 04 18:51:02 +0100 2007
- Size:
- 3381 Bytes
1 | class TextFilterPlugin |
2 | class << self |
3 | include TypoPlugins |
4 | end |
5 | |
6 | @@filter_map = {} |
7 | def self.inherited(sub) |
8 | if sub.to_s =~ /^Plugin/ or sub.to_s =~ /^Typo::Textfilter/ |
9 | name = sub.short_name |
10 | @@filter_map[name] = sub |
11 | end |
12 | end |
13 | |
14 | def self.filter_map |
15 | @@filter_map |
16 | end |
17 | |
18 | plugin_display_name "Unknown Text Filter" |
19 | plugin_description "Unknown Text Filter Description" |
20 | |
21 | def self.reloadable? |
22 | false |
23 | end |
24 | |
25 | # The name that needs to be used when refering to the plugin's |
26 | # controller in render statements |
27 | def self.component_name |
28 | if (self.to_s =~ /::([a-zA-Z]+)$/) |
29 | "plugins/textfilters/#{$1}".downcase |
30 | else |
31 | raise "I don't know who I am: #{self.to_s}" |
32 | end |
33 | end |
34 | |
35 | # The name that's stored in the DB. This is the final chunk of the |
36 | # controller name, like 'markdown' or 'smartypants'. |
37 | def self.short_name |
38 | component_name.split(%r{/}).last |
39 | end |
40 | |
41 | def self.default_config |
42 | {} |
43 | end |
44 | |
45 | def self.help_text |
46 | "" |
47 | end |
48 | |
49 | private |
50 | |
51 | def self.default_helper_module! |
52 | end |
53 | |
54 | # Look up a config paramater, falling back to the default as needed. |
55 | def self.config_value(params,name) |
56 | params[:filterparams][name] || default_config[name][:default] |
57 | end |
58 | |
59 | def self.logger |
60 | @logger ||= RAILS_DEFAULT_LOGGER || Logger.new(STDOUT) |
61 | end |
62 | end |
63 | |
64 | class TextFilterPlugin::PostProcess < TextFilterPlugin |
65 | end |
66 | |
67 | class TextFilterPlugin::Macro < TextFilterPlugin |
68 | # Utility function -- hand it a XML string like <a href="foo" title="bar"> |
69 | # and it'll give you back { "href" => "foo", "title" => "bar" } |
70 | def self.attributes_parse(string) |
71 | attributes = Hash.new |
72 | |
73 | string.gsub(/([^ =]+="[^"]*")/) do |match| |
74 | key,value = match.split(/=/,2) |
75 | attributes[key] = value.gsub(/"/,'') |
76 | end |
77 | |
78 | attributes |
79 | end |
80 | |
81 | def self.filtertext(blog, content, text, params) |
82 | filterparams = params[:filterparams] |
83 | regex1 = /<typo:#{short_name}(?:[ \t][^>]*)?\/>/ |
84 | regex2 = /<typo:#{short_name}([ \t][^>]*)?>(.*?)<\/typo:#{short_name}>/m |
85 | |
86 | new_text = text.gsub(regex1) do |match| |
87 | macrofilter(blog,content,attributes_parse(match),params) |
88 | end |
89 | |
90 | new_text = new_text.gsub(regex2) do |match| |
91 | macrofilter(blog,content,attributes_parse($1.to_s),params,$2.to_s) |
92 | end |
93 | |
94 | new_text |
95 | end |
96 | end |
97 | |
98 | class TextFilterPlugin::MacroPre < TextFilterPlugin::Macro |
99 | end |
100 | |
101 | class TextFilterPlugin::MacroPost < TextFilterPlugin::Macro |
102 | end |
103 | |
104 | class TextFilterPlugin::Markup < TextFilterPlugin |
105 | end |
106 | |
107 | class Typo |
108 | class Textfilter |
109 | class MacroPost < TextFilterPlugin |
110 | plugin_display_name "MacroPost" |
111 | plugin_description "Macro expansion meta-filter (post-markup)" |
112 | |
113 | def self.filtertext(blog,content,text,params) |
114 | filterparams = params[:filterparams] |
115 | |
116 | macros = TextFilter.available_filter_types['macropost'] |
117 | macros.inject(text) do |text,macro| |
118 | macro.filtertext(blog,content,text,params) |
119 | end |
120 | end |
121 | end |
122 | |
123 | class MacroPre < TextFilterPlugin |
124 | plugin_display_name "MacroPre" |
125 | plugin_description "Macro expansion meta-filter (pre-markup)" |
126 | |
127 | def self.filtertext(blog,content,text,params) |
128 | filterparams = params[:filterparams] |
129 | |
130 | macros = TextFilter.available_filter_types['macropre'] |
131 | macros.inject(text) do |text,macro| |
132 | macro.filtertext(blog,content,text,params) |
133 | end |
134 | end |
135 | end |
136 | end |
137 | end |