radiant-forum-extension 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (146) hide show
  1. data/README.md +155 -0
  2. data/Rakefile +139 -0
  3. data/VERSION +1 -0
  4. data/app/controllers/admin/forums_controller.rb +11 -0
  5. data/app/controllers/forums_controller.rb +34 -0
  6. data/app/controllers/posts_controller.rb +238 -0
  7. data/app/controllers/topics_controller.rb +78 -0
  8. data/app/models/forum.rb +52 -0
  9. data/app/models/moderatorship.rb +5 -0
  10. data/app/models/post.rb +122 -0
  11. data/app/models/post_attachment.rb +73 -0
  12. data/app/models/topic.rb +162 -0
  13. data/app/views/admin/forums/_form.html.haml +25 -0
  14. data/app/views/admin/forums/edit.html.haml +5 -0
  15. data/app/views/admin/forums/index.html.haml +76 -0
  16. data/app/views/admin/forums/moderate.html.haml +2 -0
  17. data/app/views/admin/forums/new.html.haml +5 -0
  18. data/app/views/admin/forums/remove.html.haml +22 -0
  19. data/app/views/admin/pages/_edit_commentability.html.haml +9 -0
  20. data/app/views/admin/reader_settings/_forum.html.haml +4 -0
  21. data/app/views/admin/sites/_choose_forum_layout.html.haml +7 -0
  22. data/app/views/forums/_forum.html.haml +22 -0
  23. data/app/views/forums/index.html.haml +44 -0
  24. data/app/views/forums/show.html.haml +38 -0
  25. data/app/views/forums/show.rss.builder +13 -0
  26. data/app/views/layouts/feed.rss.builder +5 -0
  27. data/app/views/monitorships/create.rjs.erb +1 -0
  28. data/app/views/monitorships/destroy.rjs.erb +1 -0
  29. data/app/views/monitorships/index.html.erb +35 -0
  30. data/app/views/pages/_comment.html.haml +10 -0
  31. data/app/views/pages/_comments.html.haml +15 -0
  32. data/app/views/posts/_attachment.html.haml +2 -0
  33. data/app/views/posts/_form.html.haml +6 -0
  34. data/app/views/posts/_latest.html.haml +17 -0
  35. data/app/views/posts/_post.html.haml +67 -0
  36. data/app/views/posts/_post.rss.builder +13 -0
  37. data/app/views/posts/_reply.html.haml +36 -0
  38. data/app/views/posts/_search.html.haml +28 -0
  39. data/app/views/posts/_uploader.html.haml +16 -0
  40. data/app/views/posts/edit.html.haml +20 -0
  41. data/app/views/posts/index.html.haml +33 -0
  42. data/app/views/posts/index.rss.builder +14 -0
  43. data/app/views/posts/new.html.haml +14 -0
  44. data/app/views/posts/preview.html.haml +32 -0
  45. data/app/views/posts/search.html.haml +54 -0
  46. data/app/views/posts/search.rss.builder +14 -0
  47. data/app/views/posts/show.html.haml +10 -0
  48. data/app/views/reader_notifier/post.rhtml +14 -0
  49. data/app/views/readers/_extra_controls.html.haml +5 -0
  50. data/app/views/readers/show_with_posts.html.haml +47 -0
  51. data/app/views/topics/_form.html.haml +26 -0
  52. data/app/views/topics/_help.html.haml +8 -0
  53. data/app/views/topics/_locked.html.haml +2 -0
  54. data/app/views/topics/_topic.html.haml +35 -0
  55. data/app/views/topics/_topic.rss.builder +9 -0
  56. data/app/views/topics/comments.html.haml +5 -0
  57. data/app/views/topics/edit.html.haml +26 -0
  58. data/app/views/topics/index.html.haml +41 -0
  59. data/app/views/topics/index.rss.builder +14 -0
  60. data/app/views/topics/new.html.haml +40 -0
  61. data/app/views/topics/show.html.haml +45 -0
  62. data/app/views/topics/show.rss.builder +14 -0
  63. data/config/routes.rb +16 -0
  64. data/db/migrate/001_create_forum_tables.rb +64 -0
  65. data/db/migrate/002_pages_commentable.rb +16 -0
  66. data/db/migrate/003_extend_sites.rb +13 -0
  67. data/db/migrate/004_sample_layout.rb +41 -0
  68. data/db/migrate/005_post_attachments.rb +19 -0
  69. data/db/migrate/006_user_relations.rb +20 -0
  70. data/db/migrate/007_reader_ownership.rb +35 -0
  71. data/db/migrate/008_first_posts.rb +13 -0
  72. data/db/migrate/20090824111005_import_helpers.rb +15 -0
  73. data/forum_extension.rb +44 -0
  74. data/lib/forum_admin_ui.rb +37 -0
  75. data/lib/forum_helper.rb +109 -0
  76. data/lib/forum_page.rb +45 -0
  77. data/lib/forum_reader.rb +9 -0
  78. data/lib/forum_reader_notifier.rb +9 -0
  79. data/lib/forum_readers_controller.rb +15 -0
  80. data/lib/forum_red_cloth3.rb +10 -0
  81. data/lib/forum_red_cloth4.rb +21 -0
  82. data/lib/forum_site.rb +12 -0
  83. data/lib/forum_tags.rb +285 -0
  84. data/lib/tasks/radiant_forum_extension_tasks.rake +137 -0
  85. data/pkg/radiant-forum-extension-0.5.0.gem +0 -0
  86. data/public/images/admin/forum.png +0 -0
  87. data/public/images/admin/new-forum.png +0 -0
  88. data/public/images/admin/nominus.png +0 -0
  89. data/public/images/admin/noremove.png +0 -0
  90. data/public/images/emoticons/angry.gif +0 -0
  91. data/public/images/emoticons/bigsmile.gif +0 -0
  92. data/public/images/emoticons/confused.gif +0 -0
  93. data/public/images/emoticons/cool.gif +0 -0
  94. data/public/images/emoticons/cry.gif +0 -0
  95. data/public/images/emoticons/devil.gif +0 -0
  96. data/public/images/emoticons/neutral.gif +0 -0
  97. data/public/images/emoticons/sad.gif +0 -0
  98. data/public/images/emoticons/shamed.gif +0 -0
  99. data/public/images/emoticons/shocked.gif +0 -0
  100. data/public/images/emoticons/smile.gif +0 -0
  101. data/public/images/emoticons/surprised.gif +0 -0
  102. data/public/images/emoticons/tongue.gif +0 -0
  103. data/public/images/emoticons/wink.gif +0 -0
  104. data/public/images/forum/attachment.png +0 -0
  105. data/public/images/forum/attachment_link.png +0 -0
  106. data/public/images/forum/attachment_over.png +0 -0
  107. data/public/images/forum/chk_off.png +0 -0
  108. data/public/images/forum/chk_on.png +0 -0
  109. data/public/images/forum/feed_14.png +0 -0
  110. data/public/images/forum/feed_28.png +0 -0
  111. data/public/images/forum/post_14.png +0 -0
  112. data/public/images/forum/post_14_over.png +0 -0
  113. data/public/images/forum/rdo_off.png +0 -0
  114. data/public/images/forum/rdo_on.png +0 -0
  115. data/public/images/forum/wait_16_grey.gif +0 -0
  116. data/public/javascripts/platform/forum.js +175 -0
  117. data/public/javascripts/platform/remotecontent.js +89 -0
  118. data/public/stylesheets/admin/forum.css +87 -0
  119. data/public/stylesheets/platform/forum.css +70 -0
  120. data/radiant-forum-extension.gemspec +215 -0
  121. data/spec/controllers/admin/forums_controller_spec.rb +54 -0
  122. data/spec/controllers/forums_controller_spec.rb +42 -0
  123. data/spec/controllers/posts_controller_spec.rb +310 -0
  124. data/spec/controllers/topics_controller_spec.rb +133 -0
  125. data/spec/datasets/forum_layouts_dataset.rb +15 -0
  126. data/spec/datasets/forum_pages_dataset.rb +11 -0
  127. data/spec/datasets/forum_readers_dataset.rb +55 -0
  128. data/spec/datasets/forum_sites_dataset.rb +10 -0
  129. data/spec/datasets/forums_dataset.rb +28 -0
  130. data/spec/datasets/posts_dataset.rb +31 -0
  131. data/spec/datasets/topics_dataset.rb +37 -0
  132. data/spec/lib/forum_admin_ui_spec.rb +35 -0
  133. data/spec/lib/forum_page_spec.rb +63 -0
  134. data/spec/lib/forum_reader_notification_spec.rb +9 -0
  135. data/spec/lib/forum_reader_spec.rb +13 -0
  136. data/spec/lib/forum_site_spec.rb +39 -0
  137. data/spec/models/forum_spec.rb +48 -0
  138. data/spec/models/post_spec.rb +91 -0
  139. data/spec/models/topic_spec.rb +105 -0
  140. data/spec/spec.opts +6 -0
  141. data/spec/spec_helper.rb +44 -0
  142. data/vendor/plugins/acts_as_list/README +23 -0
  143. data/vendor/plugins/acts_as_list/init.rb +3 -0
  144. data/vendor/plugins/acts_as_list/lib/active_record/acts/list.rb +256 -0
  145. data/vendor/plugins/acts_as_list/test/list_test.rb +332 -0
  146. metadata +287 -0
@@ -0,0 +1,13 @@
1
+ xm.item do
2
+ if post.first?
3
+ xm.title "New topic: #{h(post.topic.name)} (from #{h post.reader.name})"
4
+ elsif (@topic && @topic == post.topic)
5
+ xm.title "Reply from #{h post.reader.name}"
6
+ else
7
+ xm.title "Reply to '#{h(post.topic.name)}' (from #{h post.reader.name})"
8
+ end
9
+ xm.description clean_textilize(truncate_words(post.body, 64))
10
+ xm.pubDate post.created_at.to_s(:rfc822)
11
+ xm.guid [ActionController::Base.session_options[:session_key], post.forum_id.to_s, post.topic_id.to_s, post.id.to_s].join(":"), "isPermaLink" => "false"
12
+ xm.link paged_post_url(post)
13
+ end
@@ -0,0 +1,36 @@
1
+ - message_type = @page ? 'comment' : 'reply'
2
+ - purpose = @page ? 'To add a comment' : 'To reply'
3
+
4
+ - if @topic.locked?
5
+ %p.administrative
6
+ This topic is closed.
7
+
8
+ - else
9
+ - if current_reader
10
+ - if current_reader.activated?
11
+ - formurl = @page ? page_posts_url(@page) : topic_posts_url(@topic)
12
+ - @post ||= @topic.posts.build
13
+
14
+ %div.reply#replyform
15
+ - form_for :post, :url => formurl, :html => {:id => 'reply_form', :multipart => true, :class => 'friendly inline'} do |f|
16
+ .post_header
17
+ %h2
18
+ %a{:href => reader_url(current_reader), :class => 'main'}
19
+ = gravatar_for(current_reader, {:size => 40}, {:alt => current_reader.name, :class => 'gravatar', :width => '40', :height => '40'})
20
+ Add a
21
+ = message_type
22
+
23
+ %p.context
24
+ You are currently logged in as
25
+ = link_to(current_reader.name, reader_url(current_reader)) + '.'
26
+ If that's not you, please
27
+ = link_to("log out", reader_logout_url) + '.'
28
+
29
+ = render :partial => 'posts/form', :object => f
30
+ %p.buttons
31
+ = f.submit "Post #{message_type}"
32
+ - else
33
+ = render :partial => 'reader_activations/activation_required', :locals => {:purpose => purpose}
34
+
35
+ - else
36
+ = render :partial => 'reader_sessions/login_form', :locals => {:purpose => purpose}
@@ -0,0 +1,28 @@
1
+ %form.friendly{:action => search_posts_url}
2
+ %h2
3
+ Forum Search
4
+
5
+ %p
6
+ %label{:for => "q"}
7
+ Look for this text
8
+ = text_field_tag "q", params[:q], :class => 'standard'
9
+
10
+ %p
11
+ %label{:for => "forum_id"}
12
+ In this discussion category
13
+ %select{:name => "forum_id"}
14
+ %option{:value => ""}
15
+ anywhere
16
+ = options_from_collection_for_select(Forum.find(:all), "id", "name", params[:forum_id].to_i)
17
+
18
+ -if Radiant::Config['forum.search_by_reader']
19
+ %p
20
+ %label{:for => "reader_id"}
21
+ From this person
22
+ %select{:name => "reader_id"}
23
+ %option{:value => ""}
24
+ anyone
25
+ = options_from_collection_for_select(Reader.find(:all), "id", "name", params[:reader_id].to_i)
26
+
27
+ %p
28
+ = submit_tag "search"
@@ -0,0 +1,16 @@
1
+ - post ||= @post
2
+
3
+ .upload_handler
4
+ %ul.attachments
5
+ = hidden_field_tag "post[attachment_ids][]", ""
6
+ - post.attachments.each do |attachment|
7
+ %li.attachment
8
+ = check_box_tag "post[attachment_ids][]", attachment.id, true, {:id => "post_attachment_#{attachment.id}", :class => 'choose_attachment'}
9
+ = link_to attachment.filename, attachment.file.url, :class => "attachment #{attachment.extension}"
10
+ = link_to 'remove', '#', :class => 'remove', :id => "remove_attachment_#{attachment.id}"
11
+ .uploads
12
+ .selector
13
+ = file_field_tag "files[]", :class => "filefield"
14
+ .addfile
15
+ = link_to "attach a file", '#'
16
+
@@ -0,0 +1,20 @@
1
+ / this form is usually brought in by a remote call to sit on the page in the place of the post itself.
2
+
3
+ - message_type = @topic.page ? 'comment' : 'message'
4
+
5
+ - form_for :post, :url => topic_post_path(@topic, @post), :html => {:method => 'put', :multipart => true, :id => "post_form_#{@post.id}", :class => 'friendly'} do |f|
6
+ = render :partial => 'posts/form', :object => f
7
+ %p.buttons
8
+ = f.submit "Save changes"
9
+ or
10
+ = link_to "cancel", topic_post_path(@topic, @post), :class => 'cancel'
11
+
12
+ - content_for :pagetitle do
13
+ Edit
14
+ = message_type
15
+
16
+ - content_for :breadhead do
17
+ = link_to @post.topic.name, forum_topic_url(@post.topic.forum, @post.topic), {:class => 'breadhead'}
18
+
19
+ - content_for :controls do
20
+ = render :partial => 'readers/controls'
@@ -0,0 +1,33 @@
1
+ = render :partial => 'readers/flasher'
2
+
3
+ #forum
4
+ - if @posts.empty?
5
+ %p No talk here yet.
6
+ - else
7
+ - if @posts.previous_page
8
+ = paginate_and_summarise @posts, 'posts'
9
+
10
+ %ul.main
11
+ = render :partial => 'posts/post', :collection => @posts, :locals => {:with_context => true}
12
+
13
+ = paginate_and_summarise @posts, 'posts'
14
+
15
+ - content_for :breadcrumbs do
16
+ = link_to 'Forum', topics_url
17
+ \>
18
+ = @title
19
+
20
+ - content_for :pagetitle do
21
+ Posts
22
+
23
+ - content_for :breadhead do
24
+ = link_to "Forum", topics_url, :class => 'breadhead'
25
+
26
+ - content_for :feed do
27
+ = feed_link(posts_path(:format => :rss))
28
+
29
+ - content_for :controls do
30
+ = render :partial => 'readers/controls'
31
+
32
+ - content_for :help do
33
+ = render :partial => 'topics/help'
@@ -0,0 +1,14 @@
1
+ xml.channel do
2
+ xml.atom :link, nil, {
3
+ :href => formatted_posts_url(:rss),
4
+ :rel => 'self', :type => 'application/rss+xml'
5
+ }
6
+
7
+ xml.title "#{@site_title} : Latest posts"
8
+ xml.description "Latest posts in any topic or forum"
9
+ xml.link posts_url
10
+ xml.language "en-us"
11
+ xml.ttl "60"
12
+
13
+ render :partial => "post", :collection => @posts, :locals => {:xm => xml}
14
+ end
@@ -0,0 +1,14 @@
1
+ - message_type = @page ? 'comment' : 'reply'
2
+
3
+ #forum
4
+ = render :partial => 'posts/reply'
5
+
6
+ - content_for :breadhead do
7
+ - if @page
8
+ = link_to @page.title, @page.url, :class => 'breadhead'
9
+ - else
10
+ = link_to @topic.name, forum_topic_url(@topic.forum, @topic), :class => 'breadhead'
11
+
12
+ - content_for :pagetitle do
13
+ Add a
14
+ = message_type
@@ -0,0 +1,32 @@
1
+ / this template is generally only where you don't want a reply form on the page by default,
2
+ / and instead bring it in with a remote call. most often this is for page comments, where
3
+ / it has the advantage that the page can still be cached. that's why a login form might be returned.
4
+
5
+ - message_type = @page ? 'comment' : 'message'
6
+ - formurl = @page ? page_posts_url(@page) : posts_url(@forum, @topic)
7
+
8
+ #forum
9
+ - if response.layout
10
+ %p
11
+ Please check your message below. If it's ok, press 'post message' to add it to the site.
12
+ %div.post
13
+ %div{:class => 'reply'}
14
+ %div.post_header
15
+ %h2
16
+ %a{:href => reader_url(@post.reader), :class => 'main'}
17
+ = gravatar_for(@post.reader, {:size => 40}, {:alt => @post.reader.name, :class => 'gravatar', :width => '40', :height => '40'})
18
+ = @post.reader.name
19
+ %p.context
20
+ replied
21
+ = time_ago_in_words(@post.created_at)
22
+ ago
23
+ %div.post_body
24
+ = clean_textilize(@post.body)
25
+ %div.post_confirmation
26
+ - form_for :post, :url => formurl, :html => {:id => 'reply_form', :class => 'friendly'} do |f|
27
+ = f.hidden_field :body
28
+ = submit_tag 'confirm', :class => 'confirm', :id => 'confirm'
29
+ or
30
+ = submit_tag 'revise', :class => 'revise', :id => 'revise'
31
+ or
32
+ = link_to 'cancel', @page ? @page.url : forum_topic_url(@topic.forum, @topic), :class => 'cancelform'
@@ -0,0 +1,54 @@
1
+ = render :partial => 'readers/flasher'
2
+
3
+ #forum
4
+ #search
5
+
6
+ - if @searching
7
+ - if @posts.empty?
8
+ %p No messages found.
9
+
10
+ - else
11
+ %p
12
+ We found
13
+ = @posts.total_entries
14
+ = @description + ':'
15
+
16
+ - if @posts.previous_page
17
+ = paginate_and_summarise @posts, 'posts'
18
+
19
+ %ul.main
20
+ = render :partial => 'posts/post', :collection => @posts, :locals => {:with_context => true, :hide_author => false, :preview => true}
21
+
22
+ = paginate_and_summarise @posts, 'posts'
23
+
24
+ - else
25
+ = render :partial => 'posts/search'
26
+
27
+ - content_for :breadcrumbs do
28
+ = link_to 'Forum', topics_url
29
+ - if @searching
30
+ \>
31
+ = link_to "Posts", posts_url
32
+ \>
33
+ = @title
34
+ - else
35
+ \>
36
+ Search
37
+
38
+ - content_for :breadhead do
39
+ - if @searching
40
+ = link_to "Posts", posts_url, :class => 'breadhead'
41
+ - else
42
+ = link_to "Posts", topics_url, :class => 'breadhead'
43
+
44
+ - content_for :pagetitle do
45
+ - if @searching
46
+ = @title || 'Search results'
47
+ - else
48
+ Search
49
+
50
+ - content_for :feed do
51
+ = feed_link(search_posts_url(params.merge(:format => :rss))) if @searching
52
+
53
+ - content_for :controls do
54
+ = render :partial => 'readers/controls'
@@ -0,0 +1,14 @@
1
+ xml.channel do
2
+ xml.atom :link, nil, {
3
+ :href => search_posts_url(:rss),
4
+ :rel => 'self', :type => 'application/rss+xml'
5
+ }
6
+
7
+ xml.title "#{@site_title} : forum search"
8
+ xml.description @title
9
+ xml.link search_posts_url(params)
10
+ xml.language "en-us"
11
+ xml.ttl "60"
12
+
13
+ render :partial => "post", :collection => @posts, :locals => {:xm => xml}
14
+ end
@@ -0,0 +1,10 @@
1
+ = render :partial => 'post', :object => @post
2
+
3
+ - content_for :breadhead do
4
+ = link_to @post.topic.name, forum_topic_url(@post.topic.forum, @post.topic), {:class => 'breadhead'}
5
+
6
+ - content_for :controls do
7
+ = render :partial => 'readers/controls'
8
+
9
+ - content_for :mugshot do
10
+ = gravatar_for(@post.reader, {:size => 42}, {:alt => @post.reader.name, :class => 'gravatar'})
@@ -0,0 +1,14 @@
1
+ Hello <%= @reader.name %>.
2
+
3
+ A new comment has been added to the conversation '<%= @post.topic.name %>' by <%= @post.reader.name %>:
4
+
5
+ _______________________________________________________________________
6
+
7
+ <%= @post.body %>
8
+
9
+ _______________________________________________________________________
10
+
11
+
12
+ To see the comment in context and to reply, please visit the topic page at <%= @url %>
13
+
14
+ On that page you will also find the link to switch off this email notification service.
@@ -0,0 +1,5 @@
1
+ %br
2
+ start a new discussion
3
+ | discussions
4
+ | categories
5
+ | search
@@ -0,0 +1,47 @@
1
+ = render :partial => 'flasher'
2
+
3
+ #reader
4
+ - if @reader.description.blank?
5
+ - if @reader == current_reader
6
+ %p
7
+ = link_to "Edit your preferences", edit_reader_url(current_reader)
8
+ to put some text about yourself here.
9
+ - else
10
+ %p No description provided.
11
+ - else
12
+ = clean_textilize @reader.description
13
+
14
+ #forum
15
+ %h2{:style => 'clear: left;'}
16
+ Messages from
17
+ = @reader.name
18
+ = feed_link(search_posts_url(:reader_id => @reader.id, :format => :rss))
19
+
20
+ - if @posts
21
+ %ul.main
22
+ - if @posts.previous_page
23
+ = paginate_and_summarise @posts, 'comments'
24
+
25
+ = render :partial => 'posts/post', :collection => @posts, :locals => { :with_context => true, :without_author => false, :preview => true }
26
+
27
+ - if @posts.next_page
28
+ = paginate_and_summarise @posts, 'comments'
29
+
30
+ - else
31
+ %p None yet
32
+
33
+ - content_for :breadcrumbs do
34
+ = link_to 'Home', '/'
35
+ &gt;
36
+ = link_to 'Readers', '/readers'
37
+ &gt;
38
+ = @reader.name
39
+
40
+ - content_for :pagetitle do
41
+ = @reader.name
42
+
43
+ - content_for :mugshot do
44
+ = gravatar_for(@reader, {:size => 42}, {:alt => @reader.name, :class => 'gravatar'})
45
+
46
+ - content_for :breadhead do
47
+ = link_to 'People', '/readers', :class => 'breadhead'
@@ -0,0 +1,26 @@
1
+ - with_error_report(@topic.errors.on(:name)) do
2
+ = form.label :name, 'Discussion title', :class => 'required'
3
+ %br
4
+ = form.text_field :name, :class => 'titular'
5
+ - if admin?
6
+ %br
7
+ %span.quiet
8
+ = form.check_box :sticky
9
+ %label{:for => 'topic_sticky', :class => 'admin'} Sticky
10
+ = form.check_box :locked
11
+ %label{:for => 'topic_locked', :class => 'admin'} Locked
12
+
13
+ - with_error_report(@topic.errors.on(:body)) do
14
+ = form.label :name, 'Opening message'
15
+ %br
16
+ = form.text_area :body, :class=> 'standard', :rows => 12
17
+
18
+ - unless @topic.page && !Radiant::Config['forum.comments_have_attachments']
19
+ = render :partial => 'posts/uploader', :locals => {:post => @topic.first_post}
20
+
21
+ - if @topic.new_record? || admin?
22
+ - with_error_report(@topic.errors.on(:forum)) do
23
+ = form.label :forum_id, 'File in category:'
24
+ %br
25
+ = form.select :forum_id, Forum.visible.collect {|f| [ f.name, f.id ] }, :class=> 'standard'
26
+
@@ -0,0 +1,8 @@
1
+ - if helpforum = Forum.find_by_name('Help')
2
+ #marginalia
3
+ %h3
4
+ Help!
5
+ %ul.helplist
6
+ - helpforum.topics.find(:all, :limit => 10).each do |topic|
7
+ %li
8
+ = link_to topic.name, forum_topic_url(topic.forum, topic)
@@ -0,0 +1,2 @@
1
+ %p
2
+ Sorry: this topic is locked.
@@ -0,0 +1,35 @@
1
+ - if topic.visible_to?(current_reader)
2
+ - with_context ||= false
3
+ - cssclass = ['topic']
4
+ - cssclass << 'sticky' if topic.sticky?
5
+ - cssclass << 'locked' if topic.locked?
6
+
7
+ %li{:id => topic.dom_id, :class => cssclass.join(' ')}
8
+ %span.context
9
+ - if with_context
10
+ = link_to(topic.forum.name, forum_url(topic.forum)) + ':'
11
+ %span.subject
12
+ %a{:href => forum_topic_url(topic.forum, topic), :class => 'main'}
13
+ = gravatar_for(topic.reader, {:size => 40}, {:alt => topic.reader.name, :class => 'gravatar'})
14
+ = topic.name
15
+ %span.context
16
+ from
17
+ - if topic.posts.count > 1
18
+ = link_to topic.reader.name + '.', reader_url(topic.reader)
19
+ = topic.posts.count
20
+ = pluralize(topic.posts.count, 'comment') + ','
21
+ most recently from
22
+ = link_to topic.replied_by.name, reader_url(topic.replied_by)
23
+ = friendly_date(topic.replied_at)
24
+ - else
25
+ = link_to topic.reader.name, reader_url(topic.reader)
26
+ = friendly_date(topic.created_at)
27
+
28
+ %div.preview
29
+ - if topic.page
30
+ = truncate_words(topic.page.render_part(:body), 50)
31
+ - elsif topic.first_post
32
+ = truncate_and_textilize(topic.first_post.body, 50)
33
+ - else
34
+ %p Topic empty!
35
+