public
Fork of halorgium/mephisto
Description: A refactored Mephisto that has multiple spam detection engines.
Homepage: http://mephistoblog.com/
Clone URL: git://github.com/francois/mephisto.git
add linking to article from comment

git-svn-id: http://svn.techno-weenie.net/projects/mephisto/trunk@2268 
567b1171-46fb-0310-a4c9-b4bef9110e78
technoweenie (author)
Sun Sep 24 22:21:58 -0700 2006
commit  48a8d52db2d7551ace365f251f28ec7624bc8b0e
tree    197ee6c93c230f10de429cd3321cfc104eade6eb
parent  3853a03eab6d2435e5e94e6f4370a55bb81a760b
...
1
2
 
 
 
 
 
3
4
5
...
1
2
3
4
5
6
7
8
9
10
0
@@ -1,5 +1,10 @@
0
 * SVN *
0
 
0
+* Cache article-specific fields in comments table, allow simple linking to article:
0
+
0
+ {{ comment | link_to_article }}
0
+ {{ comment.url }}
0
+
0
 * Add Liquid Filter helpers for showing comment/article feeds for a section
0
 
0
   {{ section | comments_feed }}
...
1
 
2
3
4
5
6
7
8
 
9
10
11
...
18
19
20
 
 
 
 
21
22
23
...
1
2
3
4
5
6
7
8
 
9
10
11
12
...
19
20
21
22
23
24
25
26
27
28
0
@@ -1,11 +1,12 @@
0
 class CommentDrop < BaseDrop
0
+ include Mephisto::Liquid::UrlMethods
0
   include WhiteListHelper
0
   
0
   def comment() @source end
0
 
0
   def initialize(source)
0
     @source = source
0
- @comment_liquid = %w(id author author_email author_ip created_at).inject({}) { |l, a| l.update(a => comment.send(a)) }
0
+ @comment_liquid = %w(id author author_email author_ip created_at title published_at).inject({}) { |l, a| l.update(a => comment.send(a)) }
0
     @comment_liquid.update 'is_approved' => comment.approved?, 'body' => white_list(comment.body_html)
0
   end
0
 
0
@@ -18,6 +19,10 @@ class CommentDrop < BaseDrop
0
     comment.author_url =~ /^https?:\/\// ? comment.author_url : "http://" + comment.author_url
0
   end
0
 
0
+ def url
0
+ @url ||= absolute_url(@source.site.permalink_for(@source))
0
+ end
0
+
0
   def author_link
0
     comment.author_url.blank? ? "<span>#{CGI::escapeHTML(comment.author)}</span>" : %Q{<a href="#{CGI::escapeHTML author_url}">#{CGI::escapeHTML comment.author}</a>}
0
   end
...
68
69
70
 
 
 
 
 
71
...
68
69
70
71
72
73
74
75
76
0
@@ -68,4 +68,9 @@ class ArticleDropTest < Test::Unit::TestCase
0
     assert_equal "<p>body</p>", a.send(:body_for_mode, :single)
0
     assert_equal '<p>body</p>', a.send(:body_for_mode, :list)
0
   end
0
+
0
+ def test_article_url
0
+ t = Time.now.utc - 3.days
0
+ assert_equal "/#{t.year}/#{t.month}/#{t.day}/welcome-to-mephisto", @article.url
0
+ end
0
 end
...
4
5
6
7
 
8
9
10
...
45
46
47
 
 
 
 
 
48
49
...
4
5
6
 
7
8
9
10
...
45
46
47
48
49
50
51
52
53
54
0
@@ -4,7 +4,7 @@ class CommentDropTest < Test::Unit::TestCase
0
   fixtures :contents, :sites
0
   
0
   def setup
0
- @comment = CommentDrop.new(contents(:welcome_comment))
0
+ @comment = contents(:welcome_comment).to_liquid
0
   end
0
   
0
   def test_should_convert_comment_to_drop
0
@@ -45,4 +45,9 @@ class CommentDropTest < Test::Unit::TestCase
0
     liquid = comment.to_liquid
0
     assert_equal '<p><strong>test</strong> comment</p>', liquid.before_method(:body)
0
   end
0
+
0
+ def test_comment_url
0
+ t = Time.now.utc - 3.days
0
+ assert_equal "/#{t.year}/#{t.month}/#{t.day}/welcome-to-mephisto", @comment.url
0
+ end
0
 end
0
\ No newline at end of file

Comments

    No one has commented yet.