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:
- 2761 Bytes
1 | require 'net/http' |
2 | |
3 | class TextFilter < CachedModel |
4 | serialize :filters |
5 | serialize :params |
6 | |
7 | def self.available_filters |
8 | TextFilterPlugin.filter_map.values |
9 | end |
10 | |
11 | TYPEMAP={TextFilterPlugin::Markup => "markup", |
12 | TextFilterPlugin::MacroPre => "macropre", |
13 | TextFilterPlugin::MacroPost => "macropost", |
14 | TextFilterPlugin::PostProcess => "postprocess", |
15 | TextFilterPlugin => "other"} |
16 | |
17 | def self.available_filter_types |
18 | filters=available_filters |
19 | @cached_filter_types ||= {} |
20 | |
21 | unless @cached_filter_types[filters] |
22 | types={"macropre" => [], |
23 | "macropost" => [], |
24 | "markup" => [], |
25 | "postprocess" => [], |
26 | "other" => []} |
27 | |
28 | filters.each { |filter| types[TYPEMAP[filter.superclass]].push(filter) } |
29 | |
30 | @cached_filter_types[filters] = types |
31 | end |
32 | |
33 | @cached_filter_types[filters] |
34 | end |
35 | |
36 | def self.filters_map |
37 | TextFilterPlugin.filter_map |
38 | end |
39 | |
40 | def self.filter_text(blog, text, content, filters, filterparams={}) |
41 | map=TextFilter.filters_map |
42 | |
43 | filters.each do |filter| |
44 | next if filter == nil |
45 | begin |
46 | filter_class = map[filter.to_s] |
47 | next unless filter_class |
48 | text = filter_class.filtertext(blog, content, text, :filterparams => filterparams) |
49 | rescue => err |
50 | logger.error "Filter #{filter} failed: #{err}" |
51 | end |
52 | end |
53 | |
54 | text |
55 | end |
56 | |
57 | def self.filter_text_by_name(blog, text, filtername) |
58 | f = TextFilter.find_by_name(filtername) |
59 | f.filter_text_for_content blog, text, nil |
60 | end |
61 | |
62 | def filter_text_for_content(blog, text, content) |
63 | self.class.filter_text(blog, text, content, |
64 | [:macropre, markup, :macropost, filters].flatten, params) |
65 | end |
66 | |
67 | def filter(text) |
68 | typo_deprecated "What does this do?" |
69 | self.class.filter(text,self.filters,self.params) |
70 | end |
71 | |
72 | def help |
73 | filter_map = TextFilter.filters_map |
74 | filter_types = TextFilter.available_filter_types |
75 | |
76 | help = [] |
77 | help.push(filter_map[markup]) |
78 | filter_types['macropre'].sort_by {|f| f.short_name}.each { |f| help.push f } |
79 | filter_types['macropost'].sort_by {|f| f.short_name}.each { |f| help.push f } |
80 | filters.each { |f| help.push(filter_map[f.to_s]) } |
81 | |
82 | help_text = help.collect do |f| |
83 | f.help_text.blank? ? '' : "<h3>#{f.display_name}</h3>\n#{BlueCloth.new(f.help_text).to_html}\n" |
84 | end |
85 | |
86 | help_text.join("\n") |
87 | end |
88 | |
89 | def commenthelp |
90 | filter_map = TextFilter.filters_map |
91 | |
92 | help = [filter_map[markup]] |
93 | filters.each { |f| help.push(filter_map[f.to_s]) } |
94 | |
95 | help_text = help.collect do |f| |
96 | f.help_text.blank? ? '' : "#{BlueCloth.new(f.help_text).to_html}\n" |
97 | end.join("\n") |
98 | |
99 | return help_text |
100 | end |
101 | |
102 | def to_s; self.name; end |
103 | |
104 | def to_text_filter; self; end |
105 | end |