public
Fork of halorgium/mephisto
Description: A mirror of the mephisto code-base
Homepage: http://mephistoblog.com/
Clone URL: git://github.com/technoweenie/mephisto.git
Click here to lend your support to: mephisto and make a donation at www.pledgie.com !
comment blocking stuff, (big commit from plane trip)

git-svn-id: http://svn.techno-weenie.net/projects/mephisto/trunk@1286 
567b1171-46fb-0310-a4c9-b4bef9110e78
technoweenie (author)
Fri Jun 30 13:53:14 -0700 2006
commit  23e9525bd5ec479a4f176699580769055d9b5df4
tree    d3fcb7d3a6150fde26e5f0d32e50dd804d908c38
parent  bbf8e25f5be8f021608a3e1fc3f47b7e7189150d
...
21
22
23
24
 
25
26
27
...
21
22
23
 
24
25
26
27
0
@@ -21,7 +21,7 @@ class ApplicationController < ActionController::Base
0
   protected
0
     def load_site
0
       # Redefine this method if you wish to fail on host without a site
0
- @site ||= Site.find_by_host(request.host) || Site.find(:first)
0
+ @site ||= Site.find_by_host(request.host) || Site.find(:first, :order => 'id')
0
     end
0
 
0
   # def set_cache_root
...
29
30
31
32
33
34
35
36
 
 
 
 
 
 
37
38
39
...
42
43
44
 
45
46
47
...
29
30
31
 
 
 
 
 
32
33
34
35
36
37
38
39
40
...
43
44
45
46
47
48
49
0
@@ -29,11 +29,12 @@ class CommentsController < ApplicationController
0
       logger.info "Checking Akismet (#{Akismet.api_key}) for new comment on Article #{@article.id}. #{@comment.approved ? 'Approved' : 'Blocked'}"
0
     end
0
 
0
- if @comment.save
0
- redirect_to comment_preview_url(@article.hash_for_permalink(:comment => @comment))
0
- else
0
- show_article_with 'errors' => @comment.errors.full_messages
0
- end
0
+ @comment.save!
0
+ redirect_to comment_preview_url(@article.hash_for_permalink(:comment => @comment))
0
+ rescue ActiveRecord::RecordInvalid
0
+ show_article_with 'errors' => @comment.errors.full_messages
0
+ rescue Article::CommentNotAllowed
0
+ show_article_with 'errors' => ["Commenting has been disabled on this article"]
0
   end
0
   
0
   protected
0
@@ -42,6 +43,7 @@ class CommentsController < ApplicationController
0
     end
0
 
0
     def show_article_with(assigns)
0
+ Mephisto::Liquid::CommentForm.article = @article
0
       @comments = @article.comments.reject(&:new_record?).collect(&:to_liquid)
0
       @article = @article.to_liquid(:single)
0
       render_liquid_template_for(:single, assigns.merge('articles' => [@article],
...
31
32
33
 
34
35
36
...
72
73
74
 
75
76
77
...
31
32
33
34
35
36
37
...
73
74
75
76
77
78
79
0
@@ -31,6 +31,7 @@ class MephistoController < ApplicationController
0
     @article = site.articles.find_by_permalink(params[:year], params[:month], params[:day], params[:permalink])
0
     @comments = @article.comments.collect { |c| c.to_liquid }
0
     self.cached_references << @article
0
+ Mephisto::Liquid::CommentForm.article = @article
0
     @article = @article.to_liquid(:single)
0
     render_liquid_template_for(:single, 'articles' => [@article], 'article' => @article, 'comments' => @comments)
0
   end
0
@@ -72,6 +73,7 @@ class MephistoController < ApplicationController
0
       @article = page_name.nil? ? @section.articles.find_by_position : @section.articles.find_by_permalink(page_name)
0
     
0
       self.cached_references << @section << @article
0
+ Mephisto::Liquid::CommentForm.article = @article
0
       render_liquid_template_for(template_type, 'section' => @section.name,
0
                                                 'section_title' => @section.title,
0
                                                 'pages' => @section.articles.collect(&:to_liquid),
...
1
 
2
3
4
...
16
17
18
 
 
 
 
19
20
21
...
115
116
117
118
119
 
 
120
121
122
...
1
2
3
4
5
...
17
18
19
20
21
22
23
24
25
26
...
120
121
122
 
 
123
124
125
126
127
0
@@ -1,4 +1,5 @@
0
 class Article < Content
0
+ class CommentNotAllowed < StandardError; end
0
   validates_presence_of :title, :user_id, :site_id
0
 
0
   after_validation :set_comment_expiration
0
@@ -16,6 +17,10 @@ class Article < Content
0
     def self.included(base)
0
       base.validates_presence_of :site_id
0
     end
0
+
0
+ def status() :pending ; end
0
+ def comments() [] ; end
0
+ def published?() false; end
0
   end
0
 
0
   has_many :assigned_sections
0
@@ -115,8 +120,8 @@ class Article < Content
0
       :permalink => permalink }.merge(options)
0
   end
0
 
0
- def comments_expired?
0
- expire_comments_at && expire_comments_at > Time.now.utc
0
+ def comments_allowed?
0
+ status == :published && (expire_comments_at.nil? || expire_comments_at > Time.now.utc)
0
   end
0
 
0
   protected
...
1
2
 
 
 
3
4
5
...
24
25
26
 
 
 
 
27
28
29
...
1
 
2
3
4
5
6
7
...
26
27
28
29
30
31
32
33
34
35
0
@@ -1,5 +1,7 @@
0
 class Comment < Content
0
- validates_presence_of :author, :author_ip
0
+ validates_presence_of :author, :author_ip, :article_id
0
+ before_create { |comment| comment.site_id = comment.article.site_id }
0
+ before_create :check_comment_expiration
0
   before_save :increment_counter_cache
0
   before_destroy :decrement_counter_cache
0
   belongs_to :article
0
@@ -24,6 +26,10 @@ class Comment < Content
0
   end
0
 
0
   protected
0
+ def check_comment_expiration
0
+ raise Article::CommentNotAllowed unless article.comments_allowed?
0
+ end
0
+
0
     def increment_counter_cache
0
       Article.increment_counter 'comments_count', article_id if approved? && @old_approved == :false
0
       decrement_counter_cache if !approved? && @old_approved == :true
...
14
15
16
 
 
 
 
 
 
17
18
19
...
14
15
16
17
18
19
20
21
22
23
24
25
0
@@ -14,6 +14,12 @@ class Site < ActiveRecord::Base
0
   before_validation_on_create :set_default_comment_options
0
   validates_uniqueness_of :host
0
 
0
+ with_options :order => 'created_at', :class_name => 'Comment' do |comment|
0
+ comment.has_many :comments, :conditions => ['contents.approved = ?', true]
0
+ comment.has_many :unapproved_comments, :conditions => ['contents.approved = ?', false]
0
+ comment.has_many :all_comments
0
+ end
0
+
0
   def filters=(value)
0
     write_attribute :filters, [value].flatten.collect(&:to_sym)
0
   end
...
1
 
2
3
4
...
 
1
2
3
4
0
@@ -1,4 +1,4 @@
0
-<tr class="<%= article.status %><%= " draft" if article.draft %>" id="article_<%= article.id %>">
0
+<tr class="<%= article.status %>" id="article_<%= article.id %>">
0
   <td><%= image_tag "icons/#{status_icon[article.status][1]}", :class => "#{status_icon[article.status][0]} icon", :title => "This article is #{article.status}", :alt => "#{article.status}" %></td>
0
   <td class="article_title"><%= link_to(article.title, {:action => 'edit', :id => article}) %></td>
0
   <td>
...
28
29
30
31
 
 
 
 
 
32
33
34
...
46
47
48
49
 
50
51
52
 
53
54
55
...
59
60
61
 
 
 
 
 
62
63
64
...
28
29
30
 
31
32
33
34
35
36
37
38
...
50
51
52
 
53
54
55
 
56
57
58
59
...
63
64
65
66
67
68
69
70
71
72
73
0
@@ -28,7 +28,11 @@
0
 <!-- begin optional fields -->
0
 <dl class="optional">
0
   <dt><%= label_tag 'article_created_at', 'Publish on this date:' %></dt>
0
- <dd><%= datetime_select 'article', 'published_at', :discard_year => true %></dd>
0
+ <dd><%= form.datetime_select :published_at, :discard_year => true %></dd>
0
+<% if @article.expire_comments_at && site.accept_comments? && site.comment_age.to_i > 0 %>
0
+ <dt><%= label_tag 'article_expire_comments_at', 'Expire Comments on this date:' %></dt>
0
+ <dd><%= form.datetime_select :expire_comments_at %></dd>
0
+<% end -%>
0
   <dt><label for="article_permalink">Permanent link</label></dt>
0
   <dd><%= form.text_field :permalink %></dd>
0
 
0
@@ -46,10 +50,10 @@
0
 </dl>
0
 <!-- /end optional fields -->
0
 
0
-<% content_for :sidebar do %>
0
+<% if false %>
0
 <!--
0
   <div class="sgroup">
0
- <h3>Publish in these sections (FIXME)</h3>
0
+ <h3>Publish in these sections</h3>
0
     <ul class="slist">
0
       <% @sections.each do |section| %>
0
         <li>
0
@@ -59,6 +63,11 @@
0
         </li>
0
       <% end %>
0
     </ul>
0
+
0
+ <% unless @article.new_record? -%>
0
+ <h3>Expire Comments At</h3>
0
+ <%= form.date_select :expire_comments_at %>
0
+ <% end -%>
0
   </div>
0
   
0
   <div class="sgroup">
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
 
40
 
41
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
42
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
0
@@ -1,41 +1,27 @@
0
-<% content_for :action_nav do %>
0
-<!-- begin action nav -->
0
-<!-- FIXME: Remove view-style links and replace with select box. Action links should be write only -->
0
-<div id="page-nav">
0
- <ul id="act-nav" class="clear">
0
- <li><%= link_to 'All', :filter => nil %></li>
0
- <li><%= link_to 'Unapproved', :filter => :unapproved %></li>
0
- <li><%= link_to 'Approved', :filter => :approved %></li>
0
-
0
- </ul>
0
-</div>
0
-<!-- /end action nav -->
0
-<% end %>
0
-
0
- <h3 class="withcontrol">
0
- Show comments:
0
- <select id="comments-view">
0
- <%= options_for_select ['All', 'Unapproved', 'Approved'] %>
0
- </select>
0
- </h3>
0
- <ul class="pagelist">
0
- <% @comments.each_with_index do |comment, i| -%>
0
- <li class="event-comment<%= " shade" if (i % 2 > 0) %>" id="comment-<%= comment.id %>">
0
- <blockquote><p>"<%= truncate strip_tags(comment.body), 255 %>"</p></blockquote>
0
- <span class="meta">
0
- <cite>&mdash; <%= author_link_for comment %><%= %( (#{comment.author_email})) unless comment.author_email.blank? %></cite>
0
-
0
- <% if comment.approved? -%>
0
- <%= link_to_remote 'Unapprove', :url => { :action => 'unapprove', :id => @article, :comment => comment } %> |
0
- <% else -%>
0
- <%= link_to_remote 'Approve', :url => { :action => 'approve', :id => @article, :comment => comment } %> |
0
- <% end -%>
0
- <%= link_to_remote 'Delete', :url => { :action => 'destroy_comment', :id => @article, :comment => comment } %>
0
- </span>
0
- </li>
0
- <% end -%>
0
- </ul>
0
-
0
-
0
+<%= render :partial => "page_nav" %>
0
 
0
+<h2><%= link_to_article @article %><%= %( <small>(#{(params[:filter] || :all).to_s.humanize})</small>) %></h2>
0
 
0
+<h3 class="withcontrol">
0
+ Show comments:
0
+ <select id="comments-view">
0
+ <%= options_for_select ['All', 'Unapproved', 'Approved'], params[:filter].to_s.humanize %>
0
+ </select>
0
+</h3>
0
+<ul class="pagelist">
0
+ <% @comments.each_with_index do |comment, i| -%>
0
+ <li class="event-comment<%= " shade" if (i % 2 > 0) %>" id="comment-<%= comment.id %>">
0
+ <blockquote><p>"<%= truncate strip_tags(comment.body), 255 %>"</p></blockquote>
0
+ <span class="meta">
0
+ <cite>&mdash; <%= author_link_for comment %><%= %( (#{comment.author_email})) unless comment.author_email.blank? %></cite>
0
+
0
+ <% if comment.approved? -%>
0
+ <%= link_to_remote 'Unapprove', :url => { :action => 'unapprove', :id => @article, :comment => comment } %> |
0
+ <% else -%>
0
+ <%= link_to_remote 'Approve', :url => { :action => 'approve', :id => @article, :comment => comment } %> |
0
+ <% end -%>
0
+ <%= link_to_remote 'Delete', :url => { :action => 'destroy_comment', :id => @article, :comment => comment } %>
0
+ </span>
0
+ </li>
0
+ <% end -%>
0
+</ul>
0
\ No newline at end of file
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
 
23
24
25
...
41
42
43
44
45
46
47
48
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
...
20
21
22
 
 
23
24
25
0
@@ -1,25 +1,4 @@
0
-<% content_for :action_nav do %>
0
-<!-- begin action nav -->
0
-<div id="page-nav">
0
- <ul id="act-nav" class="clear">
0
- <li id="select">
0
- <a class="trigger" id="cog" href="#">&nbsp;</a>
0
- <div id="optgroup" style="display: none">
0
- <ul id="options">
0
- <% if @article.draft -%>
0
- <li><%= link_to 'View draft', :action => :draft, :id => @article.draft %></li>
0
- <% end -%>
0
- <% if @article.comments.any? -%>
0
- <li><%= link_to "View comments", :controller => 'articles', :action => 'comments', :id => @article %></li>
0
- <% end %>
0
- </ul>
0
- </div>
0
- </li>
0
- </ul>
0
-</div>
0
-<!-- /end action nav -->
0
-<% end %>
0
-
0
+<%= render :partial => "page_nav" %>
0
 
0
 <% content_for :sidebar do %>
0
   <% if @article.versions.any? -%>
0
@@ -41,8 +20,6 @@
0
 
0
 <%= error_messages_for :article %>
0
 
0
-
0
-
0
 <% form_for :article, @version, :url => { :action => 'update', :id => @article } do |f| -%>
0
 <%= render :partial => 'form', :object => f %>
0
 <p class="btns">
...
8
9
10
11
12
13
14
15
16
17
18
19
20
21
...
27
28
29
30
 
31
32
33
...
8
9
10
 
 
 
 
 
 
 
 
11
12
13
...
19
20
21
 
22
23
24
25
0
@@ -8,14 +8,6 @@
0
 <!-- /end action nav -->
0
 <% end %>
0
 
0
-<% if @drafts.any? -%>
0
-<ul id="drafts">
0
-<% @drafts.each do |draft| -%>
0
- <li><%= link_to draft.title, :action => :draft, :id => draft %></li>
0
-<% end -%>
0
-</ul>
0
-<% end -%>
0
-
0
 <!-- begin article list -->
0
 <table id="article-list" cellspacing="0" cellpadding="0">
0
   <thead>
0
@@ -27,7 +19,7 @@
0
     </tr>
0
   </thead>
0
   <tbody id="articles">
0
-<%= render :partial => 'article', :collection => @articles %>
0
+<%= render :partial => 'article', :collection => @drafts + @articles %>
0
   </tbody>
0
 </table>
0
 <!-- /end article list -->
...
50
51
52
53
 
54
55
56
...
50
51
52
 
53
54
55
56
0
@@ -50,7 +50,7 @@
0
   <% end -%>
0
 
0
   <div class="sgroup">
0
- <h3>Who done it</h3>
0
+ <h3>Authors</h3>
0
     <ul class="slist" id="activity">
0
       <% for user in @users %>
0
         <li><%= link_to who(user.login), :controller => 'users', :action => 'show', :id => user.login %> showed up <%= distance_of_time_in_words_to_now(user.updated_at) %> ago</li>
...
3
4
5
6
7
8
9
10
11
12
13
14
15
16
 
 
 
17
18
19
20
21
22
23
 
24
25
26
27
28
 
29
30
 
31
32
33
34
35
 
36
37
38
 
39
40
41
...
58
59
60
 
61
62
63
64
65
66
67
 
68
69
70
71
72
73
74
 
 
 
 
 
 
75
76
77
78
 
 
 
 
 
 
 
 
79
80
81
82
83
84
85
 
86
...
3
4
5
 
 
 
 
 
 
 
 
 
 
 
6
7
8
9
10
11
12
13
14
 
15
16
17
18
19
 
20
21
 
22
23
24
25
26
 
27
28
29
30
31
32
33
34
...
51
52
53
54
55
56
57
58
59
60
 
61
62
 
 
 
 
 
 
63
64
65
66
67
68
69
 
 
 
70
71
72
73
74
75
76
77
78
79
80
81
82
83
 
84
85
0
@@ -3,39 +3,32 @@
0
 <!-- begin action nav -->
0
 <div id="page-nav">
0
   <ul id="act-nav" class="clear">
0
- <li><%= link_to "General", :controller => 'settings' %></li>
0
- <li><%= link_to "Publishing", :controller => 'settings' %></li>
0
- <li><%= link_to "Comments", :controller => 'settings' %></li>
0
- <li><%= link_to "Feeds", :controller => 'settings' %></li>
0
- <li id="select">
0
- <a class="trigger" id="cog" href="#">&nbsp;</a>
0
- <div id="optgroup" style="display: none">
0
- <ul id="options">
0
- </ul>
0
- </div>
0
- </li>
0
+ <li><%= link_to "General", '#general' %></li>
0
+ <li><%= link_to "Publishing", '#publish' %></li>
0
+ <li><%= link_to "Comments", '#spam' %></li>
0
   </ul>
0
 </div>
0
 <!-- /end action nav -->
0
 <% end %>
0
 
0
 
0
-<%= form_tag :action => "update" %>
0
+<% form_for :site, :url => { :action => "update" } do |f| %>
0
 <div id="general" class="setgroup">
0
   <h3>General site settings</h3>
0
   <dl class="setform">
0
     <dt><label for="site_title">Website title</label></dt>
0
- <dd><%= text_field 'site', 'title' %></dd>
0
+ <dd><%= f.text_field :title %></dd>
0
     <dt><label for="site_subtitle">Website subtitle</label></dt>
0
- <dd><%= text_field 'site', 'subtitle' %></dd>
0
+ <dd><%= f.text_field :subtitle %></dd>
0
     <dt>
0
       <label for="site_email">Administrator email</label>
0
       <span class="hint">Shown in emails sent from your site</span>
0
     </dt>
0
- <dd><%= text_field 'site', 'email' %></dd>
0
+ <dd><%= f.text_field :email %></dd>
0
   </dl>
0
 </div>
0
 
0
+<% if false -%>
0
 <div id="publish" class="setgroup">
0
   <h3>Publishing and reading</h3>
0
   <dl class="setform">
0
@@ -58,29 +51,35 @@
0
     
0
   </dl>
0
 </div>
0
+<% end -%>
0
 
0
 <div id="spam" class="setgroup">
0
   <h3>Spam prevention</h3>
0
   <p>At the moment Mephisto uses <%= link_to 'Akismet', 'http://akismet.com' %> to automatically handle spam.</p>
0
   <dl class="setform">
0
     <dt><label>Akismet API Key</label></dt>
0
- <dd><%= text_field_tag :api_key, Akismet.api_key %></dd>
0
+ <dd><%= f.text_field :akismet_key %></dd>
0
     <dt><label>Blog url</label></dt>
0
- <dd><%= text_field_tag :blog, Akismet.blog %></dd>
0
- <dt><label>Allow comments?</label></dt>
0
- <dd><%= check_box_tag 'allow_comments' %> Yes, I would like to accept comments.</dd>
0
- <dt><label for="moderate_comments">Will you approve comments?</label></dt>
0
- <dd><%= check_box_tag 'moderate_comments' %> Yes, All comments require approval before being published.</dd>
0
- <dt><label for="comment_lifetime">Close comments</label></dt>
0
+ <dd><%= f.text_field :akismet_url %></dd>
0
+ <dt><label for="site_accept_comments">Allow comments?</label></dt>
0
+ <dd><%= f.check_box 'accept_comments' %> Yes, I would like to accept comments.</dd>
0
+ <dt><label for="site_approve_comments">Will you approve comments?</label></dt>
0
+ <dd><%= f.check_box 'approve_comments' %> Yes, All comments require approval before being published.</dd>
0
+ <dt><label for="site_comment_age">Close comments</label></dt>
0
     <dd>
0
- <select name="comment_lifetime">
0
- <%= options_for_select ['Never', '24 hours after publishing', '1 week after publishing', '2 weeks after publishing', '1 month after publishing', '3 months after publishing', '6 months after publishing', '1 year after publishing'] %>
0
- </select>
0
+ <%= f.select :comment_age, [['Never', 0],
0
+ ['24 hours after publishing', 1],
0
+ ['1 week after publishing', 7],
0
+ ['2 weeks after publishing', 14],
0
+ ['1 month after publishing', 30],
0
+ ['3 months after publishing', 90],
0
+ ['6 months after publishing', 180],
0
+ ['1 year after publishing', 365]] %>
0
     </dd>
0
   </dl>
0
 </div>
0
 
0
 
0
 <p class="btns"><%= submit_tag 'Save and apply settings' %></p>
0
-<%= end_form_tag %>
0
+<% end %>
0
     
...
6
7
8
9
10
11
12
13
14
15
16
17
 
 
 
 
 
 
 
 
 
 
18
19
20
...
6
7
8
 
 
 
 
 
 
 
 
 
9
10
11
12
13
14
15
16
17
18
19
20
21
0
@@ -6,15 +6,16 @@ module Mephisto
0
       def initialize(article, mode)
0
         @article = article
0
         @article_liquid = {
0
- 'id' => article.id,
0
- 'title' => article.title,
0
- 'permalink' => article.permalink,
0
- 'url' => article.full_permalink,
0
- 'body' => article.send(:body_for_mode, mode),
0
- 'published_at' => article.published_at,
0
- 'updated_at' => article.updated_at,
0
- 'comments_count' => article.comments_count,
0
- 'author' => article.user.to_liquid
0
+ 'id' => article.id,
0
+ 'title' => article.title,
0
+ 'permalink' => article.permalink,
0
+ 'url' => article.full_permalink,
0
+ 'body' => article.send(:body_for_mode, mode),
0
+ 'published_at' => article.published_at,
0
+ 'updated_at' => article.updated_at,
0
+ 'comments_count' => article.comments_count,
0
+ 'author' => article.user.to_liquid,
0
+ 'comments_allowed' => article.comments_allowed?
0
         }
0
       end
0
 
...
1
2
3
 
4
5
6
 
7
8
9
...
1
2
3
4
5
6
7
8
9
10
11
0
@@ -1,9 +1,11 @@
0
 module Mephisto
0
   module Liquid
0
     class CommentForm < ::Liquid::Block
0
+ cattr_accessor :article
0
       include Reloadable
0
     
0
       def render(context)
0
+ return '' unless article.comments_allowed?
0
         result = []
0
         context.stack do
0
           if context['message'].blank?
...
130
131
132
 
 
 
 
133
134
135
...
161
162
163
 
 
 
 
 
 
164
...
130
131
132
133
134
135
136
137
138
139
...
165
166
167
168
169
170
171
172
173
174
0
@@ -130,6 +130,10 @@ var ArticleForm = {
0
 
0
   getAvailableComments: function() {
0
     return $$('#main div').reject(function(div) { return !(div.visible() && div.id.match(/^comment-/)); }).collect(function(div) { return div.id.match(/comment-(\d+)/)[1] });
0
+ },
0
+
0
+ viewComments: function() {
0
+ location.href = "?filter=" + $F(this).toLowerCase();
0
   }
0
 }
0
 
0
@@ -161,3 +165,9 @@ var SectionForm = {
0
     new Ajax.Request('/admin/sections/order/' + Navigate.currentId(), {asynchronous:true, evalScripts:true, parameters:query});
0
   }
0
 }
0
+
0
+Event.observe(window, 'load', function() {
0
+ new DropMenu('select');
0
+ var commentsView = $('comments-view');
0
+ if(commentsView) Event.observe(commentsView, 'change', ArticleForm.viewComments.bind(commentsView));
0
+});
0
\ No newline at end of file
...
3
4
5
 
6
7
8
...
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
...
137
138
139
140
141
142
143
...
172
173
174
175
176
177
178
...
3
4
5
6
7
8
9
...
117
118
119
 
 
 
 
 
 
 
 
 
 
 
 
120
121
122
...
126
127
128
 
129
130
131
...
160
161
162
 
 
 
 
0
@@ -3,6 +3,7 @@ var DropMenu = Class.create();
0
 DropMenu.prototype = {
0
   initialize: function(element) {
0
     this.menu = $(element);
0
+ if(!this.menu) return;
0
     this.trigger = document.getElementsByClassName('trigger', this.menu)[0];
0
     this.options = $('optgroup');
0
     this.focused = false;
0
@@ -116,18 +117,6 @@ var Fat = {
0
   }
0
 }
0
 
0
-function highlight_comment() {
0
- var h = location.hash;
0
- var c = h ? h.substr(1) : '';
0
- if(document.getElementById(c)) Fat.fade_element(c, 20, 1500);
0
-}
0
-
0
-window.onload = function() {
0
- highlight_comment();
0
-}
0
-
0
-
0
-
0
 Asset = {
0
   upload: function(form) {
0
     form = $(form);
0
@@ -137,7 +126,6 @@ Asset = {
0
 }
0
 
0
 
0
-
0
 /*-------------------- Flash ------------------------------*/
0
 // Flash is used to manage error messages and notices from
0
 // Ajax calls.
0
@@ -172,7 +160,3 @@ var Flash = {
0
   }
0
 }
0
 
0
-Event.observe(window, 'load', function() {
0
- new DropMenu('select');
0
-});
0
-
...
72
73
74
 
75
76
77
...
72
73
74
75
76
77
78
0
@@ -72,6 +72,7 @@ about:
0
   published_at: <%= (4.days - 13.minutes).ago.to_s(:db) %>
0
   user_id: 1
0
   type: Article
0
+ expire_comments_at: <%= 3.days.ago.utc.to_s :db %>
0
 site_map:
0
   id: 7
0
   site_id: 1
...
85
86
87
88
89
90
91
 
 
 
 
 
 
92
93
...
85
86
87
 
 
 
 
88
89
90
91
92
93
94
95
0
@@ -85,9 +85,11 @@ class ArticleTest < Test::Unit::TestCase
0
   end
0
   
0
   def test_comment_expiry
0
- a = Article.new :expire_comments_at => 5.minutes.ago.utc
0
- assert !a.comments_expired?
0
- a.expire_comments_at = 5.minutes.from_now.utc
0
- assert a.comments_expired?
0
+ a = Article.new :expire_comments_at => 5.minutes.from_now.utc, :published_at => 5.minutes.from_now.utc
0
+ assert !a.comments_allowed?
0
+ a.published_at = 5.minutes.ago.utc
0
+ assert a.comments_allowed?
0
+ a.expire_comments_at = 5.minutes.ago.utc
0
+ assert !a.comments_allowed?
0
   end
0
 end
...
22
23
24
 
 
 
 
 
 
 
 
 
 
 
 
25
26
27
...
22
23
24
25