Changesets can be listed by changeset number.
The Git repository is here.
Changeset 111
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.
- Comitted by: adh
- Date: Monday October 23 21:30:52 2006 (over 18 years ago)
Affected files:
- rool/rails/typo/trunk/app/controllers/accounts_controller.rb (diff)
- rool/rails/typo/trunk/app/controllers/application.rb (diff)
- rool/rails/typo/trunk/app/controllers/articles_controller.rb (diff)
- rool/rails/typo/trunk/app/helpers/articles_helper.rb (diff)
- rool/rails/typo/trunk/app/views/articles/_comment.rhtml (diff)
- rool/rails/typo/trunk/app/views/articles/_comment_box.rhtml (diff)
- rool/rails/typo/trunk/app/views/articles/comment_preview.rhtml (diff)
- rool/rails/typo/trunk/app/views/articles/read.rhtml (diff)
- rool/rails/typo/trunk/public/javascripts/typo.js (diff)
- rool/rails/typo/trunk/themes/risc_os_open/layouts/default.rhtml (diff)
- rool/rails/typo/trunk/themes/risc_os_open/stylesheets/risc_os_open.css (diff)
rool/rails/typo/trunk/app/controllers/accounts_controller.rb:
prev. | current | |
if session[:user] = User.authenticate(params[:user_login], params[:user_password]) | ||
flash[:notice] = "Login successful" | ||
11 | | |
11 | cookies[:typoapp_is_admin] = "yes" | |
redirect_back_or_default :controller => "admin/content", :action => "index" | ||
else | ||
flash.now[:notice] = "Login unsuccessful" | ||
... | ... | |
def logout | ||
session[:user] = nil | ||
36 | | |
36 | cookies.delete :typoapp_is_admin | |
end | ||
def welcome | ||
end | ||
41 | | |
41 | ||
private | ||
43 | | |
43 | ||
def verify_users | ||
if User.count == 0 | ||
redirect_to :controller => "accounts", :action => "signup" |
rool/rails/typo/trunk/app/controllers/application.rb:
prev. | current | |
# The filters added to this controller will be run for all controllers in the application. | ||
# Likewise will all the methods added be available for all controllers. | ||
class ApplicationController < ActionController::Base | ||
4 | ||
5 | # Hub single sign-on support. | |
6 | ||
7 | require 'hub_sso_lib' | |
8 | include HubSsoLib::Core | |
9 | before_filter :hubssolib_update_state | |
10 | ||
11 | # Standard Typo gubbins follows, including its own admin login system. | |
12 | ||
include LoginSystem | ||
before_filter :get_the_blog_object |
rool/rails/typo/trunk/app/controllers/articles_controller.rb:
prev. | current | |
class ArticlesController < ContentController | ||
2 | ||
3 | # We might expect to have to do the stuff below, but because the only | |
4 | # method protected presently is 'comment' and that works by AJAX it has | |
5 | # to take a different approach. The commented out code is left here in | |
6 | # case other methods become protected in future - saves having to dig | |
7 | # out reference code from some other controller to use as a template. | |
8 | # | |
9 | # # Action permissions for this class as a class variable, exposed | |
10 | # # to the public through a class method. | |
11 | # | |
12 | # @@hubssolib_permissions = HubSsoLib::Permissions.new({ | |
13 | # :comment => [ :admin, :webmaster, :privileged, :normal ] | |
14 | # }) | |
15 | # | |
16 | # def ArticlesController.hubssolib_permissions | |
17 | # @@hubssolib_permissions | |
18 | # end | |
19 | ||
before_filter :verify_config | ||
layout :theme_layout, :except => [:comment_preview, :trackback] | ||
... | ... | |
@articles = Article.find( :all, | ||
:offset => @pages.current.offset, | ||
:limit => @pages.items_per_page, | ||
30 | | |
48 | :order => "contents.published_at DESC", | |
:include => [:categories, :tags, :user, :blog], | ||
:conditions => | ||
['published = ? AND contents.published_at < ? AND blog_id = ?', | ||
true, Time.now, this_blog.id] | ||
35 | | |
53 | ) | |
end | ||
def search | ||
... | ... | |
return | ||
end | ||
113 | # The Hub filter would catch this action if we let it, but because | |
114 | # it is fetched by an AJAX mechanism we end up with the login page | |
115 | # embedded inside the parent :-) - so take steps to prevent this. | |
116 | ||
117 | unless hubssolib_logged_in? | |
118 | render_error("You are not logged in; you cannot comment on articles") | |
119 | return | |
120 | end | |
121 | ||
if request.post? | ||
begin | ||
params[:comment].merge!({:ip => request.remote_ip, | ||
... | ... | |
@article = this_blog.published_articles.find(params[:id]) | ||
@comment = @article.comments.build(params[:comment]) | ||
@comment.user = session[:user] | ||
102 | | |
129 | ||
spam_options = { | ||
104 | | |
105 | | |
131 | :user_agent => request.env['HTTP_USER_AGENT'], | |
132 | :referrer => request.env['HTTP_REFERER'], | |
:permalink => this_blog.article_url(@article, false)} | ||
107 | | |
134 | ||
if @comment.is_spam? spam_options | ||
STDERR.puts "Moderating comment as spam!" | ||
@comment.withdraw | ||
end | ||
112 | | |
139 | ||
@comment.save! | ||
114 | | |
115 | | |
142 | add_to_cookies(:typoapp_url, @comment.url) | |
143 | add_to_cookies(:typoapp_email, @comment.email) | |
144 | ||
set_headers | ||
render :partial => "comment", :object => @comment | ||
rescue ActiveRecord::RecordInvalid | ||
... | ... | |
render :nothing => true, :status => 404 | ||
end | ||
end | ||
168 | | |
196 | ||
def markup_help | ||
render :text => TextFilter.find(params[:id]).commenthelp | ||
end | ||
... | ... | |
private | ||
def add_to_cookies(name, value, path=nil, expires=nil) | ||
176 | | |
204 | cookies[name] = { :value => value, :path => path ? PATH_PREFIX + '/' + path : "#{PATH_PREFIX}/#{controller_name}", | |
:expires => 6.weeks.from_now } | ||
end | ||
rool/rails/typo/trunk/app/helpers/articles_helper.rb:
prev. | current | |
def onhover_show_admin_tools(type, id = nil) | ||
tag = [] | ||
21 | | |
21 | tag << %{ onmouseover="if (getCookie('typoapp_is_admin') == 'yes') { Element.show('admin_#{[type, id].compact.join('_')}'); }" } | |
tag << %{ onmouseout="Element.hide('admin_#{[type, id].compact.join('_')}');" } | ||
tag | ||
end |
rool/rails/typo/trunk/app/views/articles/_comment.rhtml:
prev. | current | |
<li id="comment-<%= comment.id %>" <%= 'class="author_comment"' if comment.user %> <%= 'style="display:none"' if controller.request.xhr? %><%= onhover_show_admin_tools(:comment, comment.id) %>> | ||
<%= admin_tools_for comment %> | ||
<a name="comment-<%= comment.id %>"></a> | ||
4 | | |
5 | | |
4 | <%= gravatar_tag(comment.email) if this_blog.use_gravatar and comment.email and !comment.email.empty? %> | |
5 | <div class="citation"> | |
6 | <cite> | |
7 | <strong> | |
8 | <%= link_to_unless(comment.url.blank?, h(comment.author), comment.url) %> | |
9 | </strong> | |
10 | </cite> | |
11 | <%= comment.email && !comment.email.empty? ? mail_to(comment.email, '(e-mail)', :encode => 'hex') : '' %> | |
12 | said <%= distance_of_time_in_words comment.article.published_at, comment.created_at %> later: | |
13 | </div> | |
<%= comment.full_html %> | ||
<% unless comment.published -%> | ||
8 | | |
16 | <div class="spamwarning"> | |
17 | This comment has been flagged for moderator approval. It won't | |
18 | appear below the live article until the author approves it. | |
19 | </div> | |
<% end -%> | ||
10 | ||
21 | </li> | |
rool/rails/typo/trunk/app/views/articles/_comment_box.rhtml:
prev. | current | |
1 | ||
2 | | |
1 | <%= form_remote_tag :url => {:action => "comment", :id => @article}, | |
2 | :position=> :bottom, | |
:update => {:success => 'commentList'}, | ||
4 | | |
4 | :loading => "loading()", | |
:complete => "complete(request)", | ||
:failure => "failure(request)", | ||
:html => {:id=>"commentform",:class=>"commentform"} %> | ||
... | ... | |
<table cellpadding="4" cellspacing="0" class="frm-tbl"> | ||
<tr> | ||
<td><p><label for="comment_author">Your name</label></p></td> | ||
18 | | |
18 | <td> | |
19 | <% if hubssolib_current_user.roles.to_authenticated_roles.includes? [:admin, :webmaster, :privileged] -%> | |
20 | <input id="comment_author" name="comment[author]" size="20" type="text" value="<%= hubssolib_unique_name %>" /> | |
21 | <% else -%> | |
22 | <input id="comment_author" name="comment[author]" size="20" type="hidden" value="<%= hubssolib_unique_name %>" /> | |
23 | <b><%= hubssolib_unique_name %></b> | |
24 | <% end -%> | |
25 | <small><%= link_to_function("(leave url/email »)", "Element.toggle('guest_url'); Element.toggle('guest_email')") %></small> | |
26 | </td> | |
</tr> | ||
<tr id="guest_url" style="display:none;"> | ||
<td><p><label for="comment_url">Your blog</label></p></td> | ||
... | ... | |
<td colspan="2" id="frm-btns"> | ||
<span id="comment_loading" style="display:none;"><%= image_tag "spinner.gif" %></span> | ||
<%= markup_help_popup TextFilter.find_by_name(config[:comment_text_filter]), "Comment Markup Help" %> | ||
38 | | |
46 | <a href="#" onclick="new Ajax.Updater('preview', '<%= url_for :action => 'comment_preview' %>', {asynchronous:true, evalScripts:true, parameters:Form.serialize('commentform'), onComplete:function(request){Element.show('preview')}}); return false;">Preview comment</a> | |
<input type="submit" name="submit" id="form-submit-button" value="submit" class="button" /> | ||
</td> | ||
</tr> |
rool/rails/typo/trunk/app/views/articles/comment_preview.rhtml:
prev. | current | |
1 | ||
2 | ||
1 | <%= gravatar_tag(@comment.email) if this_blog.use_gravatar and @comment.email and !@comment.email.empty? %> | |
2 | <div class="citation"> | |
3 | <cite> | |
4 | <strong> | |
5 | <%= link_to_unless(@comment.url.blank?, h(@comment.author), @comment.url) %> | |
6 | </strong> | |
7 | <%= @comment.email && !@comment.email.empty? ? mail_to(@comment.email, '(e-mail)', :encode => 'hex') : '' %> | |
8 | </cite> | |
9 | is about to say: | |
10 | </div> | |
<%= @comment.full_html %> |
rool/rails/typo/trunk/app/views/articles/read.rhtml:
prev. | current | |
<a name="comments"></a><h4 class="blueblk">Comments</h4> | ||
<% unless @article.comments_closed? -%> | ||
<p class="postmetadata alt"> | ||
34 | | |
34 | <% if hubssolib_logged_in? -%> | |
35 | <small><a href="#respond">Add a comment about this article</a></small> | |
36 | <% else -%> | |
37 | <b>To add a comment</b> about this article, <a href="/rails/hub/account/login">please log in</a>. | |
38 | <% end -%> | |
</p> | ||
<% end -%> | ||
<ol class="comment-list" id="commentList"> | ||
... | ... | |
</p> | ||
<% unless @article.comments_closed? -%> | ||
67 | | |
71 | <%= render(:partial => 'comment_box') if hubssolib_logged_in? %> | |
<% else -%> | ||
69 | | |
73 | <p>Comments are closed for this article.</p> | |
<% end -%> |
rool/rails/typo/trunk/public/javascripts/typo.js:
prev. | current | |
register_onload(function() { | ||
if ($('commentform')) { | ||
91 | | |
92 | | |
91 | var _url = getCookie('typoapp_url'); | |
92 | var _email = getCookie('typoapp_email'); | |
94 | | |
if(_url != null) { $('commentform').elements['comment[url]'].value = _url } | ||
95 | if(_email != null) { $('commentform').elements['comment[email]'].value = _email } | |
if ($('commentform').elements['comment[url]'].value != '' | ||
|| $('commentform').elements['comment[email]'].value != '') { |
rool/rails/typo/trunk/themes/risc_os_open/layouts/default.rhtml:
prev. | current | |
<table width="85%" cellspacing="0" cellpadding="0" align="center"> | ||
<tr valign="top" align="left"> | ||
<td width="75%"> | ||
19 | <%= hubssolib_flash_tags -%> | |
<h2><%= link_to this_blog.blog_name, { :controller => '/' } %></h2> | ||
<br /> |
rool/rails/typo/trunk/themes/risc_os_open/stylesheets/risc_os_open.css:
prev. | current | |
clear: right; | ||
} | ||
97 | ||
97 | DIV.citation | |
{ | ||
99 | font-size: small; | |
100 | margin-bottom: 6px; | |
101 | } | |
102 | ||
103 | DIV.citation CITE | |
104 | { | |
color: #8CB877; | ||
106 | font-style: normal; | |
} | ||
.gravatar |