Changesets can be listed by changeset number.
The Git repository is here.
- Revision:
- 111
- Log:
Renamed cookies with "typoapp_" prefix and corrected their paths.
Integrated with Hub, which includes removing support for the comment
author cookie; added a comment e-mail address cookie instead, to go
with the URL cookie that Typo already supports. Updated styles to
improve comment display and included e-mail address, where supplied,
in hex-encoded form after the author name.
- Author:
- adh
- Date:
- Mon Oct 23 21:30:52 +0100 2006
- Size:
- 5525 Bytes
1 | module ArticlesHelper |
2 | def admin_tools_for(model) |
3 | type = model.class.to_s.downcase |
4 | tag = [] |
5 | tag << content_tag("div", |
6 | link_to_remote('nuke', { |
7 | :url => { :action => "nuke_#{type}", :id => model }, |
8 | :complete => visual_effect(:puff, "#{type}-#{model.id}", :duration => 0.6), |
9 | :confirm => "Are you sure you want to delete this #{type}?" |
10 | }, :class => "admintools") << |
11 | link_to('edit', { |
12 | :controller => "admin/#{type.pluralize}/article/#{model.article.id}", |
13 | :action => "edit", :id => model |
14 | }, :class => "admintools"), |
15 | :id => "admin_#{type}_#{model.id}", :style => "display: none") |
16 | tag.join(" | ") |
17 | end |
18 | |
19 | def onhover_show_admin_tools(type, id = nil) |
20 | tag = [] |
21 | tag << %{ onmouseover="if (getCookie('typoapp_is_admin') == 'yes') { Element.show('admin_#{[type, id].compact.join('_')}'); }" } |
22 | tag << %{ onmouseout="Element.hide('admin_#{[type, id].compact.join('_')}');" } |
23 | tag |
24 | end |
25 | |
26 | def render_errors(obj) |
27 | return "" unless obj |
28 | tag = String.new |
29 | |
30 | unless obj.errors.empty? |
31 | tag << %{<ul class="objerrors">} |
32 | |
33 | obj.errors.each_full do |message| |
34 | tag << "<li>#{message}</li>" |
35 | end |
36 | |
37 | tag << "</ul>" |
38 | end |
39 | |
40 | tag |
41 | end |
42 | |
43 | def page_title |
44 | if @page_title |
45 | @page_title |
46 | else |
47 | this_blog.blog_name || "Typo" |
48 | end |
49 | end |
50 | |
51 | def page_header |
52 | page_header_includes = contents.collect { |c| c.whiteboard }.collect { |w| w.select {|k,v| k =~ /^page_header_/}.collect {|(k,v)| v} }.flatten.uniq |
53 | ( |
54 | <<-HTML |
55 | <meta http-equiv="content-type" content="text/html; charset=utf-8" /> |
56 | #{ meta_tag 'ICBM', this_blog.geourl_location unless this_blog.geourl_location.empty? } |
57 | <link rel="EditURI" type="application/rsd+xml" title="RSD" href="#{ server_url_for :controller => 'xml', :action => 'rsd' }" /> |
58 | <link rel="alternate" type="application/atom+xml" title="Atom" href="#{ @auto_discovery_url_atom }" /> |
59 | <link rel="alternate" type="application/rss+xml" title="RSS" href="#{ @auto_discovery_url_rss }" /> |
60 | #{ javascript_include_tag "cookies" } |
61 | #{ javascript_include_tag "prototype" } |
62 | #{ javascript_include_tag "effects" } |
63 | #{ javascript_include_tag "typo" } |
64 | #{ page_header_includes.join("\n") } |
65 | <script type="text/javascript">#{ @content_for_script }</script> |
66 | HTML |
67 | ).chomp |
68 | end |
69 | |
70 | def article_links(article) |
71 | returning code = [] do |
72 | code << category_links(article) unless article.categories.empty? |
73 | code << tag_links(article) unless article.tags.empty? |
74 | code << comments_link(article) if article.allow_comments? |
75 | code << trackbacks_link(article) if article.allow_pings? |
76 | end.join(" <strong>|</strong> ") |
77 | end |
78 | |
79 | def category_links(article) |
80 | "Posted in " + article.categories.collect { |c| link_to h(c.name), |
81 | { :controller => "articles", :action => "category", :id => c.permalink }, |
82 | :rel => "tag" |
83 | }.join(", ") |
84 | end |
85 | |
86 | def tag_links(article) |
87 | "Tags " + article.tags.collect { |tag| link_to tag.display_name, |
88 | { :controller => "articles", :action => "tag", :id => tag.name }, |
89 | :rel => "tag" |
90 | }.sort.join(", ") |
91 | end |
92 | |
93 | def author_link(article) |
94 | if this_blog.link_to_author and article.user and article.user.email.to_s.size>0 |
95 | "<a href=\"mailto:#{h article.user.email}\">#{h article.user.name}</a>" |
96 | elsif article.user and article.user.name.to_s.size>0 |
97 | h article.user.name |
98 | else |
99 | h article.author |
100 | end |
101 | end |
102 | |
103 | def next_link(article) |
104 | n = article.next |
105 | return n ? article_link("#{n.title} »", n) : '' |
106 | end |
107 | |
108 | def prev_link(article) |
109 | p = article.previous |
110 | return p ? article_link("« #{p.title}", p) : '' |
111 | end |
112 | |
113 | def render_sidebars |
114 | # ugly ugly hack to fix the extremely verbose sidebar logging |
115 | options = { :controller => SidebarController, |
116 | :action => 'display_plugins', |
117 | :params => {:contents => contents, |
118 | :request_params => params} } |
119 | render_component(options) |
120 | end |
121 | |
122 | # Generate the image tag for a commenters gravatar based on their email address |
123 | # Valid options are described at http://www.gravatar.com/implement.php |
124 | def gravatar_tag(email, options={}) |
125 | options.update(:gravatar_id => Digest::MD5.hexdigest(email.strip)) |
126 | options[:default] = CGI::escape(options[:default]) if options.include?(:default) |
127 | options[:size] ||= 60 |
128 | |
129 | image_tag("http://www.gravatar.com/avatar.php?" << |
130 | options.map { |key,value| "#{key}=#{value}" }.sort.join("&"), :class => "gravatar") |
131 | end |
132 | |
133 | def calc_distributed_class(articles, max_articles, grp_class, min_class, max_class) |
134 | (grp_class.to_prefix rescue grp_class.to_s) + |
135 | ((max_articles == 0) ? |
136 | min_class.to_s : |
137 | (min_class + ((max_class-min_class) * articles.to_f / max_articles).to_i).to_s) |
138 | end |
139 | |
140 | def link_to_grouping(grp) |
141 | link_to( grp.display_name, urlspec_for_grouping(grp), |
142 | :rel => "tag", :title => title_for_grouping(grp) ) |
143 | end |
144 | |
145 | def urlspec_for_grouping(grouping) |
146 | { :controller => "articles", :action => grouping.class.to_prefix, :id => grouping.permalink } |
147 | end |
148 | |
149 | def title_for_grouping(grouping) |
150 | "#{pluralize(grouping.article_counter, 'post')} with #{grouping.class.to_s.underscore} '#{grouping.display_name}'" |
151 | end |
152 | |
153 | def ul_tag_for(grouping_class) |
154 | case grouping_class |
155 | when Tag |
156 | %{<ul id="taglist" class="tags">} |
157 | when Category |
158 | %{<ul class="categorylist">} |
159 | else |
160 | '<ul>' |
161 | end |
162 | end |
163 | end |