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:
- 3972 Bytes
1 | # The methods added to this helper will be available to all templates in the application. |
2 | require 'digest/sha1' |
3 | |
4 | module ApplicationHelper |
5 | # Override the default ActionController#url_for. |
6 | def url_for(options = { }) |
7 | # this_blog.url_for doesn't do relative URLs. |
8 | # if options.kind_of? Hash |
9 | # unless options[:controller] |
10 | # options[:controller] = params[:controller] |
11 | # end |
12 | # end |
13 | |
14 | # this_blog.url_for(options) |
15 | super(options) |
16 | end |
17 | |
18 | # Basic english pluralizer. |
19 | # Axe? |
20 | def pluralize(size, word) |
21 | case size |
22 | when 0 then "no #{word.pluralize}" |
23 | when 1 then "1 #{word}" |
24 | else "#{size} #{word.pluralize}" |
25 | end |
26 | end |
27 | |
28 | # Produce a link to the permalink_url of 'item'. |
29 | def link_to_permalink(item, title, anchor=nil) |
30 | anchor = "##{anchor}" if anchor |
31 | "<a href=\"#{item.permalink_url}#{anchor}\">#{title}</a>" |
32 | end |
33 | |
34 | # The '5 comments' link from the bottom of articles |
35 | def comments_link(article) |
36 | link_to_permalink(article,pluralize(article.published_comments.size, 'comment'),'comments') |
37 | end |
38 | |
39 | def trackbacks_link(article) |
40 | link_to_permalink(article,pluralize(article.published_trackbacks.size, 'trackback'),'trackbacks') |
41 | end |
42 | |
43 | def check_cache(aggregator, *args) |
44 | hash = "#{aggregator.to_s}_#{args.collect { |arg| Digest::SHA1.hexdigest(arg) }.join('_') }".to_sym |
45 | controller.cache[hash] ||= aggregator.new(*args) |
46 | end |
47 | |
48 | def js_distance_of_time_in_words_to_now(date) |
49 | if date |
50 | time = date.utc.strftime("%a, %d %b %Y %H:%M:%S GMT") |
51 | else |
52 | time = Time.now |
53 | end |
54 | "<span class=\"typo_date\" title=\"#{time}\">#{time}</span>" |
55 | end |
56 | |
57 | def meta_tag(name, value) |
58 | tag :meta, :name => name, :content => value unless value.blank? |
59 | end |
60 | |
61 | def date(date) |
62 | "<span class=\"typo_date\">#{date.utc.strftime("%d. %b")}</span>" |
63 | end |
64 | |
65 | def render_theme(options) |
66 | options[:controller]=Themes::ThemeController.active_theme_name |
67 | render_component(options) |
68 | end |
69 | |
70 | def toggle_effect(domid, true_effect, true_opts, false_effect, false_opts) |
71 | "$('#{domid}').style.display == 'none' ? new #{false_effect}('#{domid}', {#{false_opts}}) : new #{true_effect}('#{domid}', {#{true_opts}}); return false;" |
72 | end |
73 | |
74 | def markup_help_popup(markup, text) |
75 | if markup and markup.commenthelp.size > 1 |
76 | "<a href=\"#{url_for :controller => '/articles', :action => 'markup_help', :id => markup.id}\" onclick=\"return popup(this, 'Typo Markup Help')\">#{text}</a>" |
77 | else |
78 | '' |
79 | end |
80 | end |
81 | |
82 | # Deprecated helpers |
83 | def server_url_for(options={}) |
84 | typo_deprecated "Use url_for instead" |
85 | url_for(options) |
86 | end |
87 | |
88 | def config_value(name) |
89 | typo_deprecated "Use this_blog.#{name} instead." |
90 | this_blog.send(name) |
91 | end |
92 | |
93 | def config |
94 | typo_deprecated "Use this_blog.configname instead of config[:configname]" |
95 | raise "Unimplemented" |
96 | end |
97 | |
98 | def item_link(title, item, anchor=nil) |
99 | typo_deprecated "Use link_to_permalink instead of item_link" |
100 | link_to_permalink(item, title, anchor) |
101 | end |
102 | |
103 | alias_method :article_link, :item_link |
104 | alias_method :page_link, :item_link |
105 | alias_method :comment_url_link, :item_link |
106 | |
107 | def url_of(item, only_path=true, anchor=nil) |
108 | typo_deprecated "Use item.permalink_url instead" |
109 | item.permalink_url |
110 | end |
111 | |
112 | alias_method :trackback_url, :url_of |
113 | alias_method :comment_url, :url_of |
114 | alias_method :article_url, :url_of |
115 | alias_method :page_url, :url_of |
116 | |
117 | def html(content, what = :all, deprecated = false) |
118 | if deprecated |
119 | msg = "use html(#{content.class.to_s.underscore}" + ((what == :all) ? "" : ", #{what.inspect}") + ")" |
120 | typo_deprecated(msg) |
121 | end |
122 | |
123 | content.html(what) |
124 | end |
125 | |
126 | def article_html(article, what = :all) |
127 | html(article, what, true) |
128 | end |
129 | |
130 | def comment_html(comment) |
131 | html(comment, :body, true) |
132 | end |
133 | |
134 | def page_html(page) |
135 | html(page, :body, true) |
136 | end |
137 | |
138 | def strip_html(text) |
139 | typo_deprecated "use text.strip_html" |
140 | text.strip_html |
141 | end |
142 | end |