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:
- 5784 Bytes
1 | module ArticlesHelper |
2 | include SidebarHelper |
3 | |
4 | def admin_tools_for(model) |
5 | type = model.class.to_s.downcase |
6 | tag = [] |
7 | tag << content_tag("div", |
8 | link_to_remote('nuke', { |
9 | :url => { :action => "nuke_#{type}", :id => model }, |
10 | :complete => visual_effect(:puff, "#{type}-I#{model.id}", :duration => 0.6), |
11 | :confirm => "Are you sure you want to delete this #{type}?" |
12 | }, :class => "admintools") << |
13 | link_to('edit', { |
14 | :controller => "admin/#{type.pluralize}", |
15 | :article_id => model.article.id, |
16 | :action => "edit", :id => model |
17 | }, :class => "admintools"), |
18 | :id => "admin_#{type}_#{model.id}", :style => "display: none") |
19 | tag.join(" | ") |
20 | end |
21 | |
22 | def onhover_show_admin_tools(type, id = nil) |
23 | tag = [] |
24 | tag << %{ onmouseover="if (getCookie('typoapp_is_admin') == 'yes') { Element.show('admin_#{[type, id].compact.join('_')}'); }" } |
25 | tag << %{ onmouseout="Element.hide('admin_#{[type, id].compact.join('_')}');" } |
26 | tag |
27 | end |
28 | |
29 | def render_errors(obj) |
30 | return "" unless obj |
31 | tag = String.new |
32 | |
33 | unless obj.errors.empty? |
34 | tag << %{<ul class="objerrors">} |
35 | |
36 | obj.errors.each_full do |message| |
37 | tag << "<li>#{message}</li>" |
38 | end |
39 | |
40 | tag << "</ul>" |
41 | end |
42 | |
43 | tag |
44 | end |
45 | |
46 | def page_title |
47 | blog_name = this_blog.blog_name || "Typo" |
48 | if @page_title |
49 | # this is where the page title prefix (string) should go |
50 | (this_blog.title_prefix == 1 ? blog_name + " : " : '') + @page_title + (this_blog.title_prefix == 2 ? " : " + blog_name : '') |
51 | else |
52 | blog_name |
53 | end |
54 | end |
55 | |
56 | def page_header |
57 | page_header_includes = contents.collect { |c| c.whiteboard }.collect do |w| |
58 | w.select {|k,v| k =~ /^page_header_/}.collect do |(k,v)| |
59 | v = v.chomp |
60 | # trim the same number of spaces from the beginning of each line |
61 | # this way plugins can indent nicely without making ugly source output |
62 | spaces = /\A[ \t]*/.match(v)[0].gsub(/\t/, " ") |
63 | v.gsub!(/^#{spaces}/, ' ') # add 2 spaces to line up with the assumed position of the surrounding tags |
64 | end |
65 | end.flatten.uniq |
66 | ( |
67 | <<-HTML |
68 | <meta http-equiv="content-type" content="text/html; charset=utf-8" /> |
69 | #{ meta_tag 'ICBM', this_blog.geourl_location unless this_blog.geourl_location.empty? } |
70 | <link rel="EditURI" type="application/rsd+xml" title="RSD" href="#{ url_for :controller => 'xml', :action => 'rsd' }" /> |
71 | <link rel="alternate" type="application/atom+xml" title="Atom" href="#{ @auto_discovery_url_atom }" /> |
72 | <link rel="alternate" type="application/rss+xml" title="RSS" href="#{ @auto_discovery_url_rss }" /> |
73 | #{ javascript_include_tag "cookies" } |
74 | #{ javascript_include_tag "prototype" } |
75 | #{ javascript_include_tag "effects" } |
76 | #{ javascript_include_tag "typo" } |
77 | #{ page_header_includes.join("\n") } |
78 | <script type="text/javascript">#{ @content_for_script }</script> |
79 | HTML |
80 | ).chomp |
81 | end |
82 | |
83 | def article_links(article) |
84 | returning code = [] do |
85 | code << category_links(article) unless article.categories.empty? |
86 | code << tag_links(article) unless article.tags.empty? |
87 | code << comments_link(article) if article.allow_comments? |
88 | code << trackbacks_link(article) if article.allow_pings? |
89 | end.join(" <strong>|</strong> ") |
90 | end |
91 | |
92 | def category_links(article) |
93 | "Posted in " + article.categories.map { |c| link_to h(c.name), c.permalink_url, :rel => 'tag'}.join(", ") |
94 | end |
95 | |
96 | def tag_links(article) |
97 | "Tags " + article.tags.map { |tag| link_to tag.display_name, tag.permalink_url, :rel => "tag"}.sort.join(", ") |
98 | end |
99 | |
100 | def author_link(article) |
101 | if this_blog.link_to_author and article.user and article.user.email.to_s.size>0 |
102 | "<a href=\"mailto:#{h article.user.email}\">#{h article.user.name}</a>" |
103 | elsif article.user and article.user.name.to_s.size>0 |
104 | h article.user.name |
105 | else |
106 | h article.author |
107 | end |
108 | end |
109 | |
110 | def next_link(article) |
111 | n = article.next |
112 | return n ? n.link_to_permalink("#{n.title} »") : '' |
113 | end |
114 | |
115 | def prev_link(article) |
116 | p = article.previous |
117 | return p ? n.link_to_permalink("« #{p.title}") : '' |
118 | end |
119 | |
120 | def render_to_string(*args, &block) |
121 | controller.send(:render_to_string, *args, &block) |
122 | end |
123 | |
124 | # Generate the image tag for a commenters gravatar based on their email address |
125 | # Valid options are described at http://www.gravatar.com/implement.php |
126 | def gravatar_tag(email, options={}) |
127 | options.update(:gravatar_id => Digest::MD5.hexdigest(email.strip)) |
128 | options[:default] = CGI::escape(options[:default]) if options.include?(:default) |
129 | options[:size] ||= 60 |
130 | |
131 | image_tag("http://www.gravatar.com/avatar.php?" << |
132 | options.map { |key,value| "#{key}=#{value}" }.sort.join("&"), :class => "gravatar") |
133 | end |
134 | |
135 | def calc_distributed_class(articles, max_articles, grp_class, min_class, max_class) |
136 | (grp_class.to_prefix rescue grp_class.to_s) + |
137 | ((max_articles == 0) ? |
138 | min_class.to_s : |
139 | (min_class + ((max_class-min_class) * articles.to_f / max_articles).to_i).to_s) |
140 | end |
141 | |
142 | def link_to_grouping(grp) |
143 | link_to( grp.display_name, urlspec_for_grouping(grp), |
144 | :rel => "tag", :title => title_for_grouping(grp) ) |
145 | end |
146 | |
147 | def urlspec_for_grouping(grouping) |
148 | { :controller => "/articles", :action => grouping.class.to_prefix, :id => grouping.permalink } |
149 | end |
150 | |
151 | def title_for_grouping(grouping) |
152 | "#{pluralize(grouping.article_counter, 'post')} with #{grouping.class.to_s.underscore} '#{grouping.display_name}'" |
153 | end |
154 | |
155 | def ul_tag_for(grouping_class) |
156 | case |
157 | when grouping_class == Tag |
158 | %{<ul id="taglist" class="tags">} |
159 | when grouping_class == Category |
160 | %{<ul class="categorylist">} |
161 | else |
162 | '<ul>' |
163 | end |
164 | end |
165 | end |