radiant-forum-extension 1.1.2 → 1.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. data/VERSION +1 -1
  2. data/app/controllers/admin/forums_controller.rb +3 -4
  3. data/app/controllers/admin/posts_controller.rb +10 -0
  4. data/app/controllers/admin/topics_controller.rb +10 -0
  5. data/app/controllers/posts_controller.rb +3 -27
  6. data/app/controllers/topics_controller.rb +3 -17
  7. data/app/helpers/forum_helper.rb +2 -2
  8. data/app/models/forum.rb +2 -24
  9. data/app/models/post.rb +12 -9
  10. data/app/models/post_attachment.rb +13 -13
  11. data/app/models/topic.rb +28 -55
  12. data/app/views/admin/forums/edit.html.haml +2 -1
  13. data/app/views/admin/forums/index.html.haml +42 -39
  14. data/app/views/admin/posts/_form.html.haml +25 -0
  15. data/app/views/admin/posts/edit.html.haml +6 -0
  16. data/app/views/admin/posts/index.html.haml +49 -0
  17. data/app/views/admin/reader_configuration/_edit_forum.html.haml +3 -3
  18. data/app/views/admin/reader_configuration/_forum.html.haml +19 -14
  19. data/app/views/admin/topics/_form.html.haml +24 -0
  20. data/app/views/admin/topics/edit.html.haml +6 -0
  21. data/app/views/admin/topics/index.html.haml +49 -0
  22. data/app/views/forums/index.html.haml +0 -7
  23. data/app/views/forums/show.html.haml +4 -3
  24. data/app/views/posts/_attachment.html.haml +4 -0
  25. data/app/views/posts/_form.html.haml +1 -3
  26. data/app/views/posts/_post.html.haml +50 -51
  27. data/app/views/posts/_reply.html.haml +16 -17
  28. data/app/views/posts/_search.html.haml +13 -17
  29. data/app/views/posts/_upload.html.haml +2 -0
  30. data/app/views/posts/_uploader.html.haml +15 -15
  31. data/app/views/posts/edit.html.haml +5 -7
  32. data/app/views/posts/index.html.haml +1 -8
  33. data/app/views/posts/search.html.haml +54 -45
  34. data/app/views/posts/show.html.haml +14 -6
  35. data/app/views/topics/_form.html.haml +15 -11
  36. data/app/views/topics/_latest.html.haml +0 -2
  37. data/app/views/topics/_locked.html.haml +2 -2
  38. data/app/views/topics/_topic.html.haml +50 -31
  39. data/app/views/topics/comments.html.haml +2 -1
  40. data/app/views/topics/index.html.haml +1 -9
  41. data/app/views/topics/new.html.haml +29 -18
  42. data/app/views/topics/show.html.haml +14 -14
  43. data/config/initializers/radiant_config.rb +12 -0
  44. data/config/locales/en.yml +81 -12
  45. data/forum_extension.rb +11 -16
  46. data/lib/forum_admin_ui.rb +47 -5
  47. data/radiant-forum-extension.gemspec +12 -4
  48. metadata +14 -6
  49. data/app/views/readers/_extra_controls.html.haml +0 -5
  50. data/app/views/readers/show_with_posts.html.haml +0 -47
@@ -1,5 +1,4 @@
1
- - message_type = @page ? 'comment' : 'reply'
2
- - purpose = @page ? 'To add a comment' : 'To reply'
1
+ - message_type = @page ? 'comment' : 'post'
3
2
 
4
3
  - if @topic.locked?
5
4
  %p.administrative
@@ -12,25 +11,25 @@
12
11
  - @post ||= @topic.posts.build
13
12
 
14
13
  %div.reply#replyform
15
- - form_for :post, :url => formurl, :html => {:id => 'reply_form', :multipart => true, :class => 'friendly inline'} do |f|
14
+ %div.speaker
15
+ %a{:href => reader_url(current_reader), :class => 'main'}
16
+ = gravatar_for(current_reader, {:size => 40}, {:alt => current_reader.name, :class => 'gravatar', :width => '40', :height => '40'})
17
+ .post_wrapper
16
18
  .post_header
17
19
  %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
-
20
+ = t('add_post', :message_type => message_type)
23
21
  %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) + '.'
22
+ = t('logged_in_as', :name => current_reader.name)
23
+ = t('if_not_you')
24
+ = link_to(t('log_out'), reader_logout_url) + '.'
25
+
26
+ - form_for :post, :url => formurl, :html => {:id => 'reply_form', :multipart => true, :class => 'friendly inline'} do |f|
27
+ = render :partial => 'posts/form', :object => f
28
+ %p.buttons
29
+ = f.submit t('post_post', :message_type => message_type)
28
30
 
29
- = render :partial => 'posts/form', :object => f
30
- %p.buttons
31
- = f.submit "Post #{message_type}"
32
31
  - else
33
- = render :partial => 'reader_activations/activation_required', :locals => {:purpose => purpose}
32
+ = render :partial => 'reader_activations/activation_required', :locals => {:purpose => t('to_add_post', :message_type => message_type)}
34
33
 
35
34
  - else
36
- = render :partial => 'reader_sessions/login_form', :locals => {:purpose => purpose}
35
+ = render :partial => 'reader_sessions/login_form', :locals => {:purpose => t('to_add_post', :message_type => message_type)}
@@ -1,28 +1,24 @@
1
1
  %form.friendly{:action => search_posts_url}
2
- %h2
3
- Forum Search
4
-
5
2
  %p
6
3
  %label{:for => "q"}
7
- Look for this text
4
+ = t('search_form.query_label')
8
5
  = text_field_tag "q", params[:q], :class => 'standard'
9
6
 
10
7
  %p
11
8
  %label{:for => "forum_id"}
12
- In this discussion category
9
+ = t('search_form.forum_label')
10
+
13
11
  %select{:name => "forum_id"}
14
- %option{:value => ""}
15
- anywhere
12
+ %option{:value => ""}= t('anywhere')
16
13
  = options_from_collection_for_select(Forum.find(:all), "id", "name", params[:forum_id].to_i)
17
14
 
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
15
  %p
28
- = submit_tag "search"
16
+ %label{:for => "reader_id"}
17
+ = t('search_form.person_label')
18
+ %select{:name => "reader_id"}
19
+ %option{:value => ""}
20
+ =t('anyone')
21
+ = options_from_collection_for_select(Reader.find(:all), "id", "name", params[:reader_id].to_i)
22
+
23
+ %p.buttons
24
+ = submit_tag t("search")
@@ -0,0 +1,2 @@
1
+ - if uf
2
+ = uf.file_field :file, :class => 'filefield'
@@ -1,15 +1,15 @@
1
- - post ||= @post
2
-
3
- .upload_stack
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
- %ul.uploads
11
- .selector
12
- = file_field_tag "files[]", :class => "filefield"
13
- .addfile
14
- = link_to "attach a file", '#'
15
-
1
+ - if Radiant::Config['forum.allow_attachments?'] && f
2
+ - post ||= f.object
3
+
4
+ .upload_stack
5
+ %ul.attachments
6
+ - post.attachments.each do |att|
7
+ - f.fields_for :attachments, att do |af|
8
+ = render :partial => 'posts/attachment', :object => att, :locals => {:af => af}
9
+ %ul.uploads
10
+ .selector
11
+ - new_attachment = post.attachments.build
12
+ - f.fields_for :attachments, new_attachment do |uf|
13
+ = render :partial => 'posts/upload', :object => new_attachment, :locals => {:uf => uf}
14
+ .addfile
15
+ = link_to t('attach_file'), "#"
@@ -1,17 +1,15 @@
1
1
  / this form is usually brought in by a remote call to sit on the page in the place of the post itself.
2
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|
3
+ - form_for :post, @post, :url => topic_post_path(@topic, @post), :html => {:method => 'put', :multipart => true, :id => "post_form_#{@post.id}", :class => 'friendly'} do |f|
6
4
  = render :partial => 'posts/form', :object => f
7
5
  %p.buttons
8
- = f.submit "Save changes"
6
+ = f.submit t('save_changes')
9
7
  or
10
- = link_to "cancel", topic_post_path(@topic, @post), :class => 'cancel'
8
+ = link_to t('cancel'), topic_post_path(@topic, @post), :class => 'cancel'
11
9
 
12
10
  - content_for :pagetitle do
13
- Edit
14
- = message_type
11
+ = t('edit')
12
+ = @topic.page ? t('comment') : t('post')
15
13
 
16
14
  - content_for :breadhead do
17
15
  = link_to @post.topic.name, forum_topic_url(@post.topic.forum, @post.topic), {:class => 'breadhead'}
@@ -3,18 +3,13 @@
3
3
 
4
4
  - content_for :title do
5
5
  = t('latest_posts')
6
-
7
- - content_for :preamble do
8
- %p
9
- = t('posts_introduction')
10
6
 
11
7
  - content_for :messages do
12
8
  - if @posts.empty?
13
9
  %p
14
10
  = t('no_posts')
15
11
  - else
16
- %ul.main
17
- = render :partial => 'posts/post', :collection => @posts, :locals => {:with_context => true}
12
+ = render :partial => 'posts/post', :collection => @posts, :locals => {:with_context => true}
18
13
 
19
14
  - content_for :sidebar do
20
15
  = render :partial => "topics/latest"
@@ -45,8 +40,6 @@
45
40
 
46
41
 
47
42
  #forum
48
- = yield :new_topic
49
- = yield :preamble
50
43
  = yield :pagination if @posts.previous_page
51
44
  = yield :messages
52
45
  = yield :pagination if @posts.next_page
@@ -1,54 +1,63 @@
1
- = render :partial => 'readers/flasher'
1
+ - content_for :signals do
2
+ = render :partial => 'readers/flasher'
2
3
 
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}
4
+ - content_for :messages do
5
+ = render :partial => 'posts/post', :collection => @posts, :locals => {:with_context => true, :hide_author => false, :preview => true}
21
6
 
22
- = paginate_and_summarise @posts, 'posts'
23
-
24
- - else
25
- = render :partial => 'posts/search'
7
+ - content_for :pagination do
8
+ = pagination_and_summary_for @posts, t('post')
26
9
 
27
10
  - 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
11
+ = link_to t('forum').titlecase, '/forum'
12
+ = t('separator')
13
+ = link_to t('posts').titlecase, '/forum/posts'
37
14
 
38
15
  - 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'
16
+ = link_to t("Posts"), posts_url, :class => 'breadhead'
17
+
18
+ - if @searching
19
+ - content_for :title do
20
+ = t('search_results')
21
+
22
+ - content_for :thing_title do
23
+ = t('search_results')
24
+
25
+ - content_for :introduction do
26
+ - if @posts.empty?
27
+ %p
28
+ =t('no_posts_found')
29
+ - else
30
+ %p
31
+ = t('posts_found', :count => @posts.total_entries)
32
+ - unless params[:q].blank?
33
+ = t('matching')
34
+ %strong
35
+ = params[:q]
36
+ - if @reader
37
+ = t('from_reader', :name => @reader.name)
38
+ - if @topic
39
+ = t('filed_in', :name => @topic.name)
40
+ - elsif @forum
41
+ = t('filed_in', :name => @forum.name)
42
+
43
+ - content_for :feed do
44
+ = feed_link(search_posts_url(params.merge(:format => :rss)))
45
+
46
+ - else
47
+ - content_for :title do
48
+ = t('search')
49
+ - content_for :introduction do
50
+ = t('search_introduction')
51
+
52
+ - content_for :search do
53
+ = render :partial => 'search'
43
54
 
44
- - content_for :pagetitle do
45
- - if @searching
46
- = @title || 'Search results'
47
- - else
48
- Search
49
55
 
50
- - content_for :feed do
51
- = feed_link(search_posts_url(params.merge(:format => :rss))) if @searching
52
56
 
53
- - content_for :controls do
54
- = render :partial => 'readers/controls'
57
+ #forum
58
+ #search
59
+ = yield :search
60
+ - if @searching
61
+ = yield :pagination if @posts.previous_page
62
+ = yield :messages
63
+ = yield :pagination if @posts.next_page
@@ -1,10 +1,18 @@
1
- = render :partial => 'post', :object => @post
1
+ - content_for :messages do
2
+ = render :partial => 'post', :object => @post, :locals => {:with_context => true}
2
3
 
3
- - content_for :breadhead do
4
- = link_to @post.topic.name, forum_topic_url(@post.topic.forum, @post.topic), {:class => 'breadhead'}
4
+ - content_for :parent do
5
+ = link_to @post.topic.name, forum_topic_url(@post.topic, @post.topic.forum)
5
6
 
6
- - content_for :controls do
7
- = render :partial => 'readers/controls'
7
+ - content_for :breadhead do
8
+ = link_to @post.topic.name + ':', forum_topic_url(@post.topic.forum, @post.topic), {:class => 'breadhead'}
8
9
 
9
- - content_for :mugshot do
10
+ - content_for :speaker do
10
11
  = gravatar_for(@post.reader, {:size => 42}, {:alt => @post.reader.name, :class => 'gravatar'})
12
+
13
+ - content_for :thing_title do
14
+ = t('reply_to')
15
+ = @post.topic.name
16
+
17
+ #forum
18
+ = yield :messages
@@ -1,26 +1,30 @@
1
1
  %p.title
2
- = form.label :name, 'Discussion title', :class => 'required'
2
+ = form.label :name, t('label.topic_name'), :class => 'required'
3
3
  %br
4
4
  = form.text_field :name, :class => 'titular'
5
5
  - if admin?
6
6
  %br
7
7
  %span.quiet
8
8
  = form.check_box :sticky
9
- %label{:for => 'topic_sticky', :class => 'admin'} Sticky
9
+ %label{:for => 'topic_sticky', :class => 'admin'}
10
+ = t('sticky')
10
11
  = form.check_box :locked
11
- %label{:for => 'topic_locked', :class => 'admin'} Locked
12
+ %label{:for => 'topic_locked', :class => 'admin'}
13
+ = t('locked')
12
14
 
13
- %p.body
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}
15
+ - @topic.first_post ||= @topic.posts.build
16
+ - form.fields_for :first_post, @topic.first_post do |fp|
17
+ %p.body
18
+ = fp.label :body, t('label.topic_body')
19
+ %br
20
+ = fp.text_area :body, :class=> 'standard', :rows => 12
21
+
22
+ - unless @topic.page && !Radiant::Config['forum.comments_have_attachments']
23
+ = render :partial => 'posts/uploader', :locals => {:f => fp}
20
24
 
21
25
  - if @topic.new_record? || admin?
22
26
  %p.forum
23
- = form.label :forum_id, 'File in category:'
27
+ = form.label :forum_id, t('label.topic_category')
24
28
  %br
25
29
  = form.select :forum_id, Forum.visible.collect {|f| [ f.name, f.id ] }, :class=> 'standard'
26
30
 
@@ -6,8 +6,6 @@
6
6
  %li.topic
7
7
  %span.subject
8
8
  %a{:href => forum_topic_url(topic.forum, topic)}
9
- - if topic.reader
10
- = gravatar_for(topic.reader, {:size => 40}, {:alt => topic.reader.name, :class => 'gravatar'})
11
9
  = topic.name
12
10
  %span.context
13
11
  = t('posted_by')
@@ -1,2 +1,2 @@
1
- %p
2
- Sorry: this topic is locked.
1
+ %p
2
+ = t('sorry_locked')
@@ -1,34 +1,53 @@
1
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?
2
+ - post = topic.first_post
3
+ %div.post{:id => post.dom_id}
4
+ .speaker
5
+ = link_to gravatar_for(topic.reader, {:size => 40}, {:alt => topic.reader.name, :class => 'gravatar offset', :width => '40', :height => '40'}), forum_topic_url(topic.forum, topic)
6
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
- - if topic.reader
14
- = gravatar_for(topic.reader, {:size => 40}, {:alt => topic.reader.name, :class => 'gravatar'})
15
- = topic.name
16
- %span.context
17
- = t('posted_by')
18
- = link_to topic.reader.name + '.', reader_url(topic.reader)
19
- = t('post_count_from', :count => topic.posts.count - 1)
20
- - if topic.has_posts?
21
- = link_to topic.replied_by.name, reader_url(topic.replied_by)
22
- = friendly_date(topic.replied_at)
23
- - else
24
- = friendly_date(topic.created_at)
25
-
26
7
  .post_wrapper
27
- - if topic.page
28
- = truncate_words(topic.page.render_part(:body), 50)
29
- - elsif topic.first_post
30
- = truncate_and_textilize(topic.first_post.body, 50)
31
- - else
32
- %p
33
- = t('topic_empty')
34
-
8
+ .post_header
9
+ %h2.subject
10
+ %a{:href => forum_topic_url(topic.forum, topic), :class => 'main'}
11
+ = topic.name
12
+
13
+ %p.context
14
+ = t('begun_on', :date => friendly_date(topic.created_at))
15
+ = t('in')
16
+ = link_to topic.forum.name, forum_url(topic.forum)
17
+ = t('by')
18
+ = link_to post.reader.name, reader_url(topic.reader), :class => 'person'
19
+
20
+ - if post.editable_by?(current_reader)
21
+ %br
22
+ %span.still_editable
23
+ - if post.editable_interval
24
+ = t('time_remaining_to_edit', :time => distance_of_time_in_words(post.still_editable_for))
25
+ = link_to t('edit_your_post'), edit_topic_post_url(topic, post), :class => 'edit_post', :id => "revise_post_#{post.id}"
26
+ - elsif admin?
27
+ = link_to t("edit_minimal"), edit_topic_post_url(topic, post), :class => 'edit_post', :id => "revise_post_#{post.id}"
28
+ = link_to t("remove_minimal"), topic_post_url(topic, post), :method => 'delete', :class => 'delete_post', :id => "delete_post_#{post.id}", :title => "remove post", :confirm => "Are you sure you want to delete this message?"
29
+
30
+ .post_body
31
+ = truncate_and_textilize(post.body, 100)
32
+
33
+ - unless post.attachments.empty?
34
+ .post_attachments
35
+ %h4
36
+ attached:
37
+ - post.attachments.images.each do |att|
38
+ = link_to image_tag(att.thumbnail), att.file.url, :class => :thumbnail
39
+ - if post.attachments.non_images.any?
40
+ %ul.attachments
41
+ - post.attachments.non_images.each do |att|
42
+ %li
43
+ = link_to att.filename, att.file.url, :class => "attachment #{att.extension}"
44
+
45
+ - if topic.has_posts?
46
+ %p.voices
47
+ - topic.other_voices.each do |reader|
48
+ = gravatar_for(reader, {:size => 16}, {:alt => reader.name, :class => 'gravatar tiny', :width => '16', :height => '16'})
49
+ %p.replies
50
+ = t('post_count_from', :count => topic.posts.count - 1)
51
+ = link_to topic.replied_by.name, reader_url(topic.replied_by)
52
+ = friendly_date(topic.replied_at)
53
+