radiant-forum-extension 2.0.4 → 2.0.5

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.0.4
1
+ 2.0.5
@@ -7,11 +7,11 @@ class PostsController < ForumBaseController
7
7
  before_filter :require_authority, :only => [:edit, :update, :destroy]
8
8
 
9
9
  def index
10
- posts = Post.scoped
11
- posts = posts.from(@reader) if @reader
10
+ @term = params[:q]
11
+ posts = @forum ? Post.in_forum(@forum) : Post.scoped
12
+ posts = posts.containing(@term) unless @term.blank?
13
+ posts = posts.from_reader(@reader) if @reader
12
14
  posts = posts.in_topic(@topic) if @topic
13
- posts = posts.in_forum(@forum) if @forum
14
- posts = posts.containing(@term) if @term = params[:q]
15
15
  @posts = posts.paginate(pagination_parameters)
16
16
  render_page_or_feed
17
17
  end
@@ -29,8 +29,12 @@ class PostsController < ForumBaseController
29
29
  @post.topic = @forum.topics.new
30
30
  end
31
31
  respond_to do |format|
32
- format.html { }
33
- format.js { render :partial => 'posts/form', :layout => false }
32
+ format.html {
33
+ expires_now
34
+ }
35
+ format.js {
36
+ render :partial => 'posts/form', :layout => false
37
+ }
34
38
  end
35
39
  end
36
40
 
@@ -51,7 +55,9 @@ class PostsController < ForumBaseController
51
55
 
52
56
  def edit
53
57
  respond_to do |format|
54
- format.html { }
58
+ format.html {
59
+ expires_now
60
+ }
55
61
  format.js { render :partial => 'posts/form' }
56
62
  end
57
63
  end
data/app/models/post.rb CHANGED
@@ -20,9 +20,11 @@ class Post < ActiveRecord::Base
20
20
  named_scope :non_comments, :conditions => "page_id IS NULL"
21
21
  named_scope :imported, :conditions => "old_id IS NOT NULL"
22
22
  named_scope :in_topic, lambda { |topic| { :conditions => ["topic_id = ?", topic.id] }}
23
- named_scope :in_topics, lambda { |topics| { :conditions => ["topic_id IN (#{topics.map("?").join(',')})", topics.map(&:id)] }}
24
- named_scope :in_forum, lambda { |forum| in_topics(forum.topics) }
25
- named_scope :from, lambda { |reader| { :conditions => ["reader_id = ?", reader.id] }}
23
+ named_scope :in_topics, lambda { |topics|
24
+ ids = topics.map(&:id)
25
+ { :conditions => ["topic_id IN (#{ids.map{"?"}.join(',')})", *ids] }
26
+ }
27
+ named_scope :from_reader, lambda { |reader| { :conditions => ["reader_id = ?", reader.id] }}
26
28
  named_scope :latest, lambda { |count| { :order => 'created_at DESC', :limit => count }}
27
29
  named_scope :except, lambda { |post| { :conditions => ["NOT posts.id = ?", post.id] }}
28
30
  named_scope :distinct_readers, :select => "DISTINCT posts.reader_id" do
@@ -32,11 +34,15 @@ class Post < ActiveRecord::Base
32
34
  end
33
35
  named_scope :containing, lambda { |term|
34
36
  {
35
- :conditions => "posts.body LIKE :term OR topics.name LIKE :term", :term => "%#{term}%",
37
+ :conditions => ["posts.body LIKE :term OR topics.name LIKE :term", {:term => "%#{term}%"}],
36
38
  :joins => "LEFT OUTER JOIN topics on posts.topic_id = topics.id"
37
39
  }
38
40
  }
39
41
 
42
+ def self.in_forum(forum)
43
+ in_topics(forum.topics)
44
+ end
45
+
40
46
  def holder
41
47
  page || topic
42
48
  end
@@ -24,9 +24,6 @@
24
24
  - tbody.title_cell do
25
25
  %td.name
26
26
  = link_to forum.name, edit_admin_forum_url(:id => forum)
27
- -if forum.for_comments
28
- %p.context
29
- = t('for_comments')
30
27
 
31
28
  - tbody.description_cell do
32
29
  %td.forum_description
@@ -57,17 +54,12 @@
57
54
 
58
55
  - tbody.modify_cell do
59
56
  %td.actions
60
- -if forum.for_comments
57
+ - if admin?
58
+ = link_to image('minus') + ' ' + t('remove'), remove_admin_forum_url(:id => forum) , :class => 'action'
59
+ - else
61
60
  %span.action.disabled
62
61
  = image('minus_disabled')
63
62
  = " " + t('remove')
64
- -else
65
- - if admin?
66
- = link_to image('minus') + ' ' + t('remove'), remove_admin_forum_url(:id => forum) , :class => 'action'
67
- - else
68
- %span.action.disabled
69
- = image('minus_disabled')
70
- = " " + t('remove')
71
63
 
72
64
  - render_region :bottom do |bottom|
73
65
  - bottom.buttons do
@@ -16,11 +16,8 @@
16
16
  = link_to t('navigation.forums'), forums_url
17
17
  = link_to t('navigation.readers'), readers_url
18
18
  = link_to t('navigation.new_topic'), new_post_url
19
- - if current_reader
20
- = link_to t('navigation.your_account'), reader_account_url
21
- = link_to t('log_out'), reader_logout_url
22
- - else
23
- = link_to t('log_in'), reader_login_url
19
+ = link_to t('navigation.your_account'), reader_account_url
20
+ = link_to t('navigation.search'), posts_url
24
21
  - if Radiant::Config['forum.help_url']
25
22
  = link_to t('navigation.forum_help'), Radiant::Config['forum.help_url']
26
23
 
@@ -7,6 +7,11 @@
7
7
  %p
8
8
  = t('forums_introduction')
9
9
 
10
+ - content_for :sidebar do
11
+ = render :partial => 'posts/search_form'
12
+ = render :partial => 'topics/latest'
13
+ = render :partial => 'topics/busiest'
14
+
10
15
  - content_for :messages do
11
16
  - if @forums.empty?
12
17
  %p
@@ -1,7 +1,7 @@
1
1
  - post ||= @post
2
2
  - first ||= post.first?
3
- - headless ||= first
4
3
  - with_context ||= false
4
+ - headless ||= first unless defined? headless
5
5
 
6
6
  - cssclasses = []
7
7
  - cssclasses << 'first' if post.first?
@@ -1,8 +1,10 @@
1
- %form.friendly{:action => posts_url}
1
+ %form.friendly{:action => posts_url, :method => :get}
2
+ %h2
3
+ =t('search_header')
2
4
  %p
3
5
  %label{:for => "q"}
4
6
  = t('search_form.query_label')
5
- = text_field_tag "q", params[:q], :class => 'standard'
7
+ = text_field_tag "q", params[:q], :class => 'titular'
6
8
 
7
9
  %p
8
10
  %label{:for => "forum_id"}
@@ -12,13 +14,14 @@
12
14
  %option{:value => ""}= t('anywhere')
13
15
  = options_from_collection_for_select(Forum.find(:all), "id", "name", params[:forum_id].to_i)
14
16
 
15
- %p
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)
17
+ - if Radiant::Config['forum.allow_search_by_reader?']
18
+ %p
19
+ %label{:for => "reader_id"}
20
+ = t('search_form.person_label')
21
+ %select{:name => "reader_id"}
22
+ %option{:value => ""}
23
+ =t('anyone')
24
+ = options_from_collection_for_select(Reader.find(:all), "id", "name", params[:reader_id].to_i)
22
25
 
23
26
  %p.buttons
24
- = submit_tag t("search")
27
+ %input{:type => 'submit', :value => "Search"}
@@ -1,18 +1,27 @@
1
+ - if !@term.blank? || @reader || @forum || @topic
2
+ - @searching = true
3
+ - summary = [t('showing_posts')]
4
+ - summary << t('in') + ' ' + link_to(@forum.name, forum_url(@forum)) if @forum
5
+ - summary << t('containing') + " <strong>#{@term}</strong>" unless @term.blank?
6
+ - summary << t('posted_by') + ' ' + link_to(@reader.name, reader_url(@reader)) if @reader
7
+ - summary << t('in_topic') + ' ' + link_to(@topic.name, forum_topic_url(@topic.forum, @topic)) if @topic
8
+
1
9
  = render :partial => 'forums/standard_parts'
2
10
 
3
11
  - content_for :title do
4
12
  = t('posts_heading')
5
13
 
6
14
  - content_for :introduction do
7
- = t('posts_introduction')
15
+ - if @searching
16
+ = summary.join(' ') + ":"
17
+ - else
18
+ = t('posts_introduction')
8
19
 
9
20
  - content_for :sidebar do
21
+ - unless @searching && @posts.empty?
22
+ = render :partial => 'posts/search_form'
10
23
  = render :partial => "topics/latest"
11
24
 
12
- - content_for :newtopic do
13
- .newmessage
14
- = link_to t('new_topic'), new_post_url
15
-
16
25
  - content_for :pagination do
17
26
  = pagination_and_summary_for(@posts, t('post'))
18
27
 
@@ -26,11 +35,16 @@
26
35
 
27
36
  - content_for :messages do
28
37
  - if @posts.empty?
29
- %p
30
- = t('no_posts')
38
+ - if @searching
39
+ %p.has_error
40
+ = t('no_search_results')
41
+ = render :partial => 'posts/search_form'
42
+ - else
43
+ %p
44
+ = t('no_posts')
31
45
  - else
32
46
  = yield :pagination if @posts.previous_page
33
- = render :partial => 'posts/post', :collection => @posts, :locals => {:with_context => true}
47
+ = render :partial => 'posts/post', :collection => @posts, :locals => {:with_context => true, :headless => false}
34
48
  = yield :pagination if @posts.next_page
35
49
 
36
50
  #forum
@@ -1,7 +1,7 @@
1
1
  %h2
2
2
  = t('recent_topics')
3
3
  %ul
4
- - Topic.latest(10).each do |topic|
4
+ - Topic.latest(5).each do |topic|
5
5
  %li.topic
6
6
  = link_to_post(topic.posts.last, :class => 'title')
7
7
  %br
@@ -8,6 +8,7 @@
8
8
  = render :partial => 'topics/topic', :collection => @topics
9
9
 
10
10
  - content_for :sidebar do
11
+ = render :partial => 'posts/search_form'
11
12
  = render :partial => 'forums/latest'
12
13
  = render :partial => 'topics/busiest'
13
14
 
@@ -12,5 +12,6 @@ Radiant.config do |config|
12
12
  forum.define 'paginate_posts?', :default => true
13
13
  forum.define 'posts_per_page', :type => :integer, :default => 20
14
14
  forum.define 'commentable_period', :type => :integer, :default => 7, :units => "days"
15
+ forum.define 'allow_search_by_reader?', :default => true
15
16
  end
16
17
  end
@@ -32,13 +32,7 @@ en:
32
32
  confirm_remove_forum: "Delete forum?"
33
33
  confirm_remove_post: "Delete post?"
34
34
  confirm_remove_topic: "Delete topic?"
35
- time:
36
- formats:
37
- recently: "%A at %l:%M%p"
38
- standard: "on %B %e, %Y at %l:%M%p"
39
- this_year: "%B %e at %l:%M%p"
40
- today: "today at %l:%M%p"
41
- yesterday: "yesterday at %l:%M%p"
35
+ containing: "containing the phrase"
42
36
  definitely_remove_post: "Yes: delete it"
43
37
  edit_forum: "Edit forum"
44
38
  edit_minimal: "e"
@@ -85,6 +79,7 @@ en:
85
79
  forums: "Categories"
86
80
  readers: "People"
87
81
  new_topic: "New topic"
82
+ search: "Search"
88
83
  topics: "Latest"
89
84
  your_account: "Your account"
90
85
  new_forum: "New forum"
@@ -101,6 +96,7 @@ en:
101
96
  no_messages_yet: "No messages yet"
102
97
  no_posts: "The forum is empty."
103
98
  no_posts_found: "No messages found."
99
+ no_search_results: "Sorry: no messages match your criteria. Please use the form below to broaden your search."
104
100
  no_topics: "No talk here yet."
105
101
  notice:
106
102
  topic_deleted: "Topic '%{name}' was deleted."
@@ -126,8 +122,8 @@ en:
126
122
  zero: "Nothing found"
127
123
  one: "One message found"
128
124
  other: "%{count} messages found"
129
- posts_heading: "Latest messages"
130
- posts_introduction: 'This is a list of all forum posts by date, with the most recent first. You can get a similar list of recent messages <a href="/forum/topics">organised by topic</a>.'
125
+ posts_heading: "Search the forum"
126
+ posts_introduction: 'This begins as a full list of all the posts in the forum. Add criteria below to cut down the list to specific subjects and speakers.'
131
127
  really_remove_post: "Are you sure you want to delete this comment?"
132
128
  recent_topics: "Recent topics"
133
129
  remove_minimal: "x"
@@ -147,10 +143,12 @@ en:
147
143
  person_label: "From this person"
148
144
  query_label: "Look for this text"
149
145
  search_whole_forum: "search the whole forum"
146
+ search_header: "Forum Search"
150
147
  search_introduction: "Please choose a search phrase and/or a person or discussion category."
151
148
  search_results: "Search Results"
152
149
  separator: ':'
153
150
  showing: "showing"
151
+ showing_posts: "Showing topics and messages"
154
152
  sorry_locked: "Sorry: this topic is locked."
155
153
  start_topic: "Start a new conversation"
156
154
  started: "started"
@@ -158,6 +156,13 @@ en:
158
156
  started_topic_in: "started a new topic under"
159
157
  started_topic_on: "started a new topic on %{date}"
160
158
  sticky: "sticky"
159
+ time:
160
+ formats:
161
+ recently: "%A at %l:%M%p"
162
+ standard: "on %B %e, %Y at %l:%M%p"
163
+ this_year: "%B %e at %l:%M%p"
164
+ today: "today at %l:%M%p"
165
+ yesterday: "yesterday at %l:%M%p"
161
166
  time_remaining_to_edit: "You have %{time} left to "
162
167
  topic_count:
163
168
  zero: "No discussion."
@@ -165,7 +170,6 @@ en:
165
170
  other: "%{count} topics, most recently "
166
171
  topic_show_introduction: ""
167
172
  topic_removed: "Topic removed"
168
- post_removed: "Post removed"
169
173
  to: "to"
170
174
  to_add_post: "To add a %{message_type}"
171
175
  topic: "topic"
@@ -174,6 +178,6 @@ en:
174
178
  topic_name: "Topic name"
175
179
  topics: "Topics"
176
180
  topics_heading: "Latest topics"
177
- topics_introduction: 'This is a list of all the discussions going on here, with the most recently updated first. You can also see a more organised list of <a href="/forum/forums">discussion categories</a> or a purely chronological list of <a href="/forum/posts">recent posts.</a>'
181
+ topics_introduction: 'This is a list of all the discussions going on here, with the most recently updated first. You can also see a more organised list of <a href="/forum/forums">discussion categories</a> or <a href="/forum/posts">search</a> for particular posts and people.'
178
182
  under: "under"
179
183
  unknown_date: "unknown date"
data/forum_extension.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  require_dependency 'application_controller'
2
2
 
3
3
  class ForumExtension < Radiant::Extension
4
- version "2.0.4"
4
+ version "2.0.5"
5
5
  description "Nice clean forums and page comments for inclusion in your radiant site. Requires the reader extension and share_layouts."
6
6
  url "http://spanner.org/radiant/forum"
7
7
 
data/lib/forum_tags.rb CHANGED
@@ -145,7 +145,7 @@ module ForumTags
145
145
  desc %{
146
146
  Renders the reply date of the current topic in a colloquial form.
147
147
  }
148
- tag 'forum:topic:date' do |tag|
148
+ tag 'forum:topic:replydate' do |tag|
149
149
  I18n.l tag.locals.topic.replied_at, :format => :standard
150
150
  end
151
151
 
@@ -38,6 +38,7 @@
38
38
  mimic: function () {
39
39
  self.zoomer.setImage(self.item.src);
40
40
  self.image.attr('src', self.item.src);
41
+ self.controls.find('a.download').attr('href', self.item.download_url());
41
42
  if (self.item.caption.html()) self.caption.html(self.item.caption.html()).show();
42
43
  else self.caption.hide();
43
44
  },
@@ -96,7 +97,6 @@
96
97
  showControls: function (e) {
97
98
  self.controls.fadeIn("fast");
98
99
  self.closer.fadeIn("fast");
99
- self.controls.find('a.download').attr('href', self.item.download_url());
100
100
  },
101
101
  hideControls: function (e) {
102
102
  self.controls.fadeOut("fast");
@@ -108,11 +108,13 @@
108
108
  var w = $(window);
109
109
  var d = item.imageSize();
110
110
  var p = self.container.offset();
111
- self.image.animate(d, 'fast');
112
- self.container.animate({
111
+ var r = {
113
112
  left: p.left + (self.image.innerWidth() - d.width)/2,
114
113
  top: p.top + (self.image.innerHeight() - d.height)/2
115
- }, 'fast');
114
+ };
115
+ if (resized.top <= 10) resized.top = 10;
116
+ self.image.animate(d, 'fast');
117
+ self.container.animate(r, 'fast');
116
118
  self.controls.css({left: (d.width - 96)/2});
117
119
  },
118
120
  reposition: function (item) {
@@ -123,6 +125,7 @@
123
125
  top: w.scrollTop() + (w.height() - d.height)/2,
124
126
  left: w.scrollLeft() + (w.width() - d.width)/2
125
127
  };
128
+ if (p.top <= 10) p.top = 10;
126
129
  if (self.visible) {
127
130
  self.image.animate(d, 'fast');
128
131
  self.container.animate(p, 'fast');
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{radiant-forum-extension}
8
- s.version = "2.0.4"
8
+ s.version = "2.0.5"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["spanner"]
12
- s.date = %q{2011-02-01}
12
+ s.date = %q{2011-02-07}
13
13
  s.description = %q{Nice clean forums and page comments for inclusion in your radiant site. Derived long ago from beast. Requires the reader extension and share_layouts.}
14
14
  s.email = %q{will@spanner.org}
15
15
  s.extra_rdoc_files = [
@@ -17,11 +17,11 @@ describe "Forum Tags" do
17
17
  it { should render(%{<r:forum:topic id="#{topic.id}"><r:forum:topic:author /></r:forum:topic>}).as("Normal") }
18
18
  it { should render(%{<r:forum:topic id="#{topic.id}"><r:forum:topic:date /></r:forum:topic>}).as(on_date) }
19
19
  it { should render(%{<r:forum:topic id="#{topic.id}"><r:forum:topic:url /></r:forum:topic>}).as("/forum/forums/#{topic.forum.id}/topics/#{topic.id}") }
20
- it { should render(%{<r:forum:topic id="#{topic.id}"><r:forum:topic:context /></r:forum:topic>}).as(%{Started by <a href="/readers/#{reader_id(:normal)}">Normal</a> #{on_date}}) }
20
+ it { should render(%{<r:forum:topic id="#{topic.id}"><r:forum:topic:context /></r:forum:topic>}).as(%{reply from <a href="/readers/#{reader_id(:normal)}">Normal</a>}) }
21
21
  it { should render(%{<r:forum:topic id="#{topic.id}"><r:forum:topic:body /></r:forum:topic>}).as("<p>original topic message</p>") }
22
22
  it { should render(%{<r:forum:topic id="#{topic.id}"><r:forum:topic:link /></r:forum:topic>}).as(%{<a href="/forum/forums/#{topic.forum.id}/topics/#{topic.id}">#{topic.name}</a>}) }
23
- it { should render(%{<r:forum:topic id="#{topic.id}"><r:forum:topic:summary /></r:forum:topic>}).as(%{<li><a href="/forum/forums/#{topic.forum.id}/topics/#{topic.id}">#{topic.name}</a><br />Started by <a href="/readers/#{reader_id(:normal)}">Normal</a> #{on_date}</li>}) }
24
- it { should render(%{<r:forum:topic id="#{sticky.id}"><r:forum:topic:summary /></r:forum:topic>}).as(%{<li><a href="/forum/forums/#{sticky.forum.id}/topics/#{sticky.id}">#{sticky.name}</a><br />Started by <a href="/readers/#{reader_id(:normal)}">Normal</a> #{sticky_date}</li>}) }
23
+ it { should render(%{<r:forum:topic id="#{topic.id}"><r:forum:topic:summary /></r:forum:topic>}).as(%{<li><a href="/forum/forums/#{topic.forum.id}/topics/#{topic.id}">#{topic.name}</a><br />reply from <a href="/readers/#{reader_id(:normal)}">Normal</a></li>}) }
24
+ it { should render(%{<r:forum:topic id="#{sticky.id}"><r:forum:topic:summary /></r:forum:topic>}).as(%{<li><a href="/forum/forums/#{sticky.forum.id}/topics/#{sticky.id}">#{sticky.name}</a><br />Started by <a href="/readers/#{reader_id(:normal)}">Normal</a></li>}) }
25
25
  end
26
26
 
27
27
  describe "r:forum:post tags" do
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: radiant-forum-extension
3
3
  version: !ruby/object:Gem::Version
4
- hash: 7
4
+ hash: 5
5
5
  prerelease: false
6
6
  segments:
7
7
  - 2
8
8
  - 0
9
- - 4
10
- version: 2.0.4
9
+ - 5
10
+ version: 2.0.5
11
11
  platform: ruby
12
12
  authors:
13
13
  - spanner
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-02-01 00:00:00 +00:00
18
+ date: 2011-02-07 00:00:00 +00:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency