radiant-forum-extension 2.1.6 → 3.0.0.rc3
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +20 -16
- data/Rakefile +0 -16
- data/app/controllers/forum_base_controller.rb +32 -10
- data/app/controllers/posts_controller.rb +37 -14
- data/app/helpers/forum_helper.rb +23 -16
- data/app/models/forum.rb +11 -7
- data/app/models/post.rb +53 -14
- data/app/models/post_attachment.rb +1 -1
- data/app/models/topic.rb +21 -8
- data/app/views/admin/dashboard/_forum_dashboard.html.haml +51 -0
- data/app/views/admin/forums/_form.html.haml +12 -0
- data/app/views/admin/forums/edit.html.haml +1 -1
- data/app/views/admin/forums/index.html.haml +16 -20
- data/app/views/admin/posts/_form.html.haml +2 -2
- data/app/views/admin/posts/edit.html.haml +1 -1
- data/app/views/admin/posts/index.html.haml +5 -5
- data/app/views/admin/reader_configuration/_edit_forum.html.haml +6 -0
- data/app/views/admin/reader_configuration/_forum.html.haml +5 -1
- data/app/views/admin/topics/_form.html.haml +3 -5
- data/app/views/admin/topics/edit.html.haml +1 -1
- data/app/views/admin/topics/index.html.haml +5 -5
- data/app/views/forums/_forum.html.haml +6 -5
- data/app/views/forums/_latest.html.haml +14 -12
- data/app/views/forums/_statistics.html.haml +4 -4
- data/app/views/forums/index.html.haml +8 -10
- data/app/views/forums/index.rss.builder +2 -2
- data/app/views/forums/show.html.haml +12 -15
- data/app/views/pages/_add_comment.html.haml +9 -8
- data/app/views/pages/_comments.html.haml +3 -3
- data/app/views/posts/_attachments.html.haml +1 -1
- data/app/views/posts/_confirm_delete.html.haml +7 -2
- data/app/views/posts/_context.html.haml +5 -5
- data/app/views/posts/_edit_links.html.haml +4 -4
- data/app/views/posts/_form.html.haml +15 -12
- data/app/views/posts/_ineditable.html.haml +7 -0
- data/app/views/posts/_latest.html.haml +3 -8
- data/app/views/posts/_minimal.html.haml +7 -0
- data/app/views/posts/_post.html.haml +20 -17
- data/app/views/posts/_post.rss.builder +2 -2
- data/app/views/posts/_search_form.html.haml +13 -13
- data/app/views/posts/_search_results.html.haml +15 -0
- data/app/views/posts/_search_summary.html.haml +13 -0
- data/app/views/posts/_uploader.html.haml +1 -1
- data/app/views/posts/edit.html.haml +22 -21
- data/app/views/posts/index.html.haml +12 -19
- data/app/views/posts/index.rss.builder +6 -6
- data/app/views/posts/new.html.haml +19 -22
- data/app/views/posts/remove.html.haml +15 -15
- data/app/views/posts/show.html.haml +16 -10
- data/app/views/readers/_forum_messages.html.haml +9 -6
- data/app/views/readers/_messages_summary.html.haml +1 -1
- data/app/views/shared/_standard_forum_parts.html.haml +41 -0
- data/app/views/topics/_busiest.html.haml +9 -8
- data/app/views/topics/_context.html.haml +11 -8
- data/app/views/topics/_latest.html.haml +2 -2
- data/app/views/topics/_locked.html.haml +1 -1
- data/app/views/topics/_minimal.html.haml +2 -2
- data/app/views/topics/_replies.html.haml +4 -3
- data/app/views/topics/_reply.html.haml +13 -8
- data/app/views/topics/_topic.html.haml +5 -9
- data/app/views/topics/_topic.rss.builder +1 -1
- data/app/views/topics/index.html.haml +14 -10
- data/app/views/topics/index.rss.builder +2 -2
- data/app/views/topics/show.html.haml +20 -19
- data/app/views/topics/show.rss.builder +3 -3
- data/config/initializers/radiant_config.rb +4 -1
- data/config/locales/en.yml +202 -178
- data/db/migrate/002_pages_commentable.rb +1 -2
- data/db/migrate/004_sample_layout.rb +38 -15
- data/db/migrate/20110111080550_detach_observer.rb +4 -4
- data/db/migrate/20110613112823_search_text.rb +9 -0
- data/db/migrate/20110613130230_tidy_up.rb +27 -0
- data/db/migrate/20110630083446_page_replied_at.rb +11 -0
- data/forum_extension.rb +13 -11
- data/lib/commentable_model.rb +13 -9
- data/lib/forum_admin_ui.rb +6 -6
- data/lib/forum_page.rb +5 -3
- data/lib/forum_reader.rb +7 -1
- data/lib/forum_reader_sessions_controller.rb +2 -3
- data/lib/forum_tags.rb +126 -11
- data/lib/radiant-forum-extension.rb +8 -0
- data/public/cleditor/images/buttons.gif +0 -0
- data/public/cleditor/images/icons/1.gif +0 -0
- data/public/cleditor/images/icons/10.gif +0 -0
- data/public/cleditor/images/icons/11.gif +0 -0
- data/public/cleditor/images/icons/12.gif +0 -0
- data/public/cleditor/images/icons/2.gif +0 -0
- data/public/cleditor/images/icons/3.gif +0 -0
- data/public/cleditor/images/icons/4.gif +0 -0
- data/public/cleditor/images/icons/5.gif +0 -0
- data/public/cleditor/images/icons/6.gif +0 -0
- data/public/cleditor/images/icons/7.gif +0 -0
- data/public/cleditor/images/icons/8.gif +0 -0
- data/public/cleditor/images/icons/9.gif +0 -0
- data/public/cleditor/images/icons/icons.gif +0 -0
- data/public/cleditor/images/toolbar.gif +0 -0
- data/public/cleditor/jquery.cleditor.css +24 -0
- data/public/cleditor/jquery.cleditor.icon.js +65 -0
- data/public/cleditor/jquery.cleditor.js +1132 -0
- data/public/cleditor/jquery.cleditor.xhtml.js +230 -0
- data/public/javascripts/forum.js +146 -107
- data/public/stylesheets/sass/forum.sass +94 -58
- data/radiant-forum-extension.gemspec +25 -276
- data/spec/controllers/forums_controller_spec.rb +0 -7
- data/spec/controllers/posts_controller_spec.rb +20 -37
- data/spec/controllers/topics_controller_spec.rb +1 -7
- data/spec/datasets/forums_dataset.rb +38 -40
- data/spec/lib/commentable_model_spec.rb +26 -38
- data/spec/lib/forum_reader_spec.rb +0 -4
- data/spec/models/forum_spec.rb +46 -16
- data/spec/models/post_spec.rb +10 -6
- data/spec/models/topic_spec.rb +26 -17
- data/spec/spec_helper.rb +1 -0
- metadata +66 -99
- data/VERSION +0 -1
- data/app/views/forums/_standard_parts.html.haml +0 -59
- data/lib/sanitize/config/forum.rb +0 -49
- data/public/javascripts/gallery.js +0 -275
- data/public/punymce/blank.htm +0 -1
- data/public/punymce/css/content.css +0 -4
- data/public/punymce/css/editor.css +0 -58
- data/public/punymce/i18n/sv.js +0 -28
- data/public/punymce/img/icons.gif +0 -0
- data/public/punymce/img/icons_uncompressed.png +0 -0
- data/public/punymce/plugins/bbcode.js +0 -1
- data/public/punymce/plugins/bbcode_src.js +0 -50
- data/public/punymce/plugins/editsource/css/editor.css +0 -3
- data/public/punymce/plugins/editsource/editsource.js +0 -1
- data/public/punymce/plugins/editsource/editsource_src.js +0 -81
- data/public/punymce/plugins/editsource/img/icons.gif +0 -0
- data/public/punymce/plugins/emoticons/css/content.css +0 -13
- data/public/punymce/plugins/emoticons/css/editor.css +0 -17
- data/public/punymce/plugins/emoticons/emoticons.js +0 -1
- data/public/punymce/plugins/emoticons/emoticons_src.js +0 -303
- data/public/punymce/plugins/emoticons/img/emoticons.gif +0 -0
- data/public/punymce/plugins/emoticons/img/emoticons.png +0 -0
- data/public/punymce/plugins/emoticons/img/trans.gif +0 -0
- data/public/punymce/plugins/entities.js +0 -1
- data/public/punymce/plugins/entities_src.js +0 -37
- data/public/punymce/plugins/forceblocks.js +0 -1
- data/public/punymce/plugins/forceblocks_src.js +0 -465
- data/public/punymce/plugins/forcenl.js +0 -1
- data/public/punymce/plugins/forcenl_src.js +0 -26
- data/public/punymce/plugins/image/css/editor.css +0 -1
- data/public/punymce/plugins/image/image.js +0 -1
- data/public/punymce/plugins/image/image_src.js +0 -30
- data/public/punymce/plugins/image/img/icons.gif +0 -0
- data/public/punymce/plugins/link/css/editor.css +0 -2
- data/public/punymce/plugins/link/img/icons.gif +0 -0
- data/public/punymce/plugins/link/link.js +0 -1
- data/public/punymce/plugins/link/link_src.js +0 -36
- data/public/punymce/plugins/paste.js +0 -1
- data/public/punymce/plugins/paste_src.js +0 -169
- data/public/punymce/plugins/protect.js +0 -1
- data/public/punymce/plugins/protect_src.js +0 -30
- data/public/punymce/plugins/safari2x.js +0 -1
- data/public/punymce/plugins/safari2x_src.js +0 -284
- data/public/punymce/plugins/tabfocus.js +0 -1
- data/public/punymce/plugins/tabfocus_src.js +0 -45
- data/public/punymce/plugins/textcolor/css/editor.css +0 -7
- data/public/punymce/plugins/textcolor/img/icons.gif +0 -0
- data/public/punymce/plugins/textcolor/textcolor.js +0 -1
- data/public/punymce/plugins/textcolor/textcolor_src.js +0 -73
- data/public/punymce/puny_mce.js +0 -1
- data/public/punymce/puny_mce_full.js +0 -1
- data/public/punymce/puny_mce_src.js +0 -1460
@@ -2,34 +2,57 @@ class SampleLayout < ActiveRecord::Migration
|
|
2
2
|
def self.up
|
3
3
|
Layout.reset_column_information
|
4
4
|
Layout.create :name => 'forum_example', :content => <<-EO
|
5
|
-
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
|
6
|
-
|
5
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
|
6
|
+
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
|
7
7
|
<html>
|
8
8
|
<head>
|
9
9
|
<title>Forum : <r:content part="pagetitle" /></title>
|
10
|
-
<link rel="stylesheet" href="/stylesheets/
|
11
|
-
<
|
12
|
-
<script type="text/javascript" charset="utf-8" src="/javascripts/platform/mootools.js"></script>
|
13
|
-
<script type="text/javascript" charset="utf-8" src="/javascripts/platform/core.js"></script>
|
14
|
-
<script type="text/javascript" charset="utf-8" src="/javascripts/platform/forum.js"></script>
|
15
|
-
<script type="text/javascript" charset="utf-8" src="/javascripts/platform/remotecontent.js"></script>
|
10
|
+
<link rel="stylesheet" href="/stylesheets/forum_demo.css" type="text/css" media="all" />
|
11
|
+
<script src="http://code.jquery.com/jquery-1.5.js" type="text/javascript"></script>
|
16
12
|
</head>
|
17
13
|
<body>
|
18
14
|
<div id="container">
|
19
15
|
<div id="header">
|
20
|
-
<
|
21
|
-
<r:content part="
|
22
|
-
<
|
23
|
-
<
|
24
|
-
|
16
|
+
<div id="masthead">
|
17
|
+
<div id="search"><r:content part="search" /></div>
|
18
|
+
<p id="sitetitle"><a href="/"><span class="logo">☆</span> Radiant Forum</a></p>
|
19
|
+
<p id="navigation">
|
20
|
+
<r:navigation paths="home: / | installation: /install | documentation: /docs | demo: /forum">
|
21
|
+
<r:normal><a href="<r:path />"><r:title /></r:normal>
|
22
|
+
<r:selected><a href="<r:path />" class="here"><r:title /></r:selected>
|
23
|
+
</r:navigation>
|
24
|
+
<a href="https://github.com/spanner/radiant-forum-extension">code</a>
|
25
|
+
<a href="https://github.com/spanner/radiant-forum-extension/issues">issues</a>
|
26
|
+
</p>
|
27
|
+
</div>
|
25
28
|
</div>
|
26
29
|
<div id="page">
|
27
|
-
<
|
30
|
+
<h1 class="title">
|
31
|
+
<span class="breadhead"><r:content part="breadhead" /></span>
|
32
|
+
<r:title />
|
33
|
+
</h1>
|
34
|
+
<r:content part="signals" />
|
35
|
+
<div id="marginalia">
|
36
|
+
<r:content part="sidebar" />
|
37
|
+
</div>
|
38
|
+
<div id="main">
|
39
|
+
<r:if_content part="introduction">
|
40
|
+
<div id="introduction"><r:content part="introduction" /></div>
|
41
|
+
</r:if_content>
|
42
|
+
<r:content />
|
43
|
+
</div>
|
28
44
|
</div>
|
29
45
|
<div id="footer">
|
30
|
-
<
|
46
|
+
<div id="colophon">
|
47
|
+
<r:content part="controls" />
|
48
|
+
<r:content part="section_navigation" />
|
49
|
+
</div>
|
31
50
|
</div>
|
32
51
|
</div>
|
52
|
+
|
53
|
+
<r:content part="reader_js" />
|
54
|
+
<r:content part="forum_js" />
|
55
|
+
<r:content part="toolbar_js" />
|
33
56
|
</body>
|
34
57
|
</html>
|
35
58
|
EO
|
@@ -1,11 +1,11 @@
|
|
1
1
|
class DetachObserver < ActiveRecord::Migration
|
2
2
|
def self.up
|
3
|
-
remove_column :posts, :
|
4
|
-
remove_column :posts, :
|
3
|
+
remove_column :posts, :updated_by_id
|
4
|
+
remove_column :posts, :created_by_id
|
5
5
|
end
|
6
6
|
|
7
7
|
def self.down
|
8
|
-
add_column :posts, :
|
9
|
-
add_column :posts, :
|
8
|
+
add_column :posts, :updated_by_id, :integer
|
9
|
+
add_column :posts, :created_by_id, :integer
|
10
10
|
end
|
11
11
|
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
class TidyUp < ActiveRecord::Migration
|
2
|
+
def self.up
|
3
|
+
remove_column :forums, :topics_count
|
4
|
+
remove_column :forums, :posts_count
|
5
|
+
remove_column :forums, :group_id
|
6
|
+
remove_column :forums, :site_id
|
7
|
+
remove_column :forums, :reader_id
|
8
|
+
remove_column :topics, :site_id
|
9
|
+
remove_column :topics, :group_id
|
10
|
+
remove_column :posts, :site_id
|
11
|
+
remove_column :posts, :forum_id
|
12
|
+
remove_column :posts, :group_id
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.down
|
16
|
+
add_column :forums, :topics_count, :integer
|
17
|
+
add_column :forums, :posts_count, :integer
|
18
|
+
add_column :forums, :group_id, :integer
|
19
|
+
add_column :forums, :site_id, :integer
|
20
|
+
add_column :forums, :reader_id, :integer
|
21
|
+
add_column :topics, :site_id, :integer
|
22
|
+
add_column :topics, :group_id, :integer
|
23
|
+
add_column :posts, :site_id, :integer
|
24
|
+
add_column :posts, :forum_id, :integer
|
25
|
+
add_column :posts, :group_id, :integer
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
class PageRepliedAt < ActiveRecord::Migration
|
2
|
+
def self.up
|
3
|
+
add_column :pages, :replied_at, :datetime
|
4
|
+
add_column :pages, :replied_by_id, :integer
|
5
|
+
end
|
6
|
+
|
7
|
+
def self.down
|
8
|
+
remove_column :pages, :replied_at
|
9
|
+
remove_column :pages, :replied_by_id
|
10
|
+
end
|
11
|
+
end
|
data/forum_extension.rb
CHANGED
@@ -1,13 +1,10 @@
|
|
1
1
|
require_dependency 'application_controller'
|
2
|
+
require 'radiant-forum-extension'
|
2
3
|
|
3
4
|
class ForumExtension < Radiant::Extension
|
4
|
-
version
|
5
|
-
description
|
6
|
-
url
|
7
|
-
|
8
|
-
extension_config do |config|
|
9
|
-
config.gem "paperclip", "~> 2.3"
|
10
|
-
end
|
5
|
+
version RadiantForumExtension::VERSION
|
6
|
+
description RadiantForumExtension::DESCRIPTION
|
7
|
+
url RadiantForumExtension::URL
|
11
8
|
|
12
9
|
def activate
|
13
10
|
ActiveRecord::Base.send :include, CommentableModel # provides has_comments class method that is used here by topics and pages but can be called from any model
|
@@ -23,22 +20,27 @@ class ForumExtension < Radiant::Extension
|
|
23
20
|
Radiant::AdminUI.load_forum_extension_regions
|
24
21
|
end
|
25
22
|
|
26
|
-
admin.
|
23
|
+
admin.page.edit.add :layout, "edit_commentability"
|
27
24
|
admin.reader_configuration.show.add :settings, "forum", :after => "administration"
|
28
25
|
admin.reader_configuration.edit.add :form, "edit_forum", :after => "administration"
|
29
|
-
|
26
|
+
|
30
27
|
if defined? RedCloth::DEFAULT_RULES
|
31
28
|
RedCloth.send :include, ForumRedCloth3
|
32
29
|
RedCloth::DEFAULT_RULES.push(:smilies)
|
33
30
|
else
|
34
31
|
RedCloth::TextileDoc.send :include, ForumRedCloth4
|
35
32
|
end
|
33
|
+
|
34
|
+
if admin.respond_to?(:dashboard)
|
35
|
+
Admin::DashboardController.send :helper, ForumHelper
|
36
|
+
admin.dashboard.index.add :main, 'forum_dashboard', :after => 'draft_pages'
|
37
|
+
end
|
36
38
|
|
37
39
|
tab("Forum") do
|
38
|
-
add_item 'Categories', '/admin/forum/forums'
|
39
40
|
add_item 'Topics', '/admin/forum/topics'
|
41
|
+
add_item 'Forums', '/admin/forum/forums'
|
40
42
|
add_item 'Posts', '/admin/forum/posts'
|
41
|
-
add_item 'Settings', '/admin/reader_configuration'
|
43
|
+
add_item 'Settings', '/admin/readers/reader_configuration'
|
42
44
|
end
|
43
45
|
end
|
44
46
|
|
data/lib/commentable_model.rb
CHANGED
@@ -2,15 +2,18 @@ module CommentableModel # for inclusion into ActiveRecord::Base
|
|
2
2
|
def self.included(base)
|
3
3
|
base.extend ClassMethods
|
4
4
|
base.class_eval do
|
5
|
-
named_scope :
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
5
|
+
named_scope :last_commented, lambda { |count| {
|
6
|
+
:conditions => "replied_at IS NOT NULL",
|
7
|
+
:order => "replied_at DESC",
|
8
|
+
:limit => count
|
9
|
+
}}
|
10
|
+
named_scope :most_commented, lambda { |count| {
|
11
|
+
:select => "topics.*, count(posts.id) AS post_count",
|
12
|
+
:joins => "INNER JOIN posts ON posts.topic_id = topics.id",
|
13
|
+
:group => "topics.id",
|
14
|
+
:order => "post_count DESC",
|
15
|
+
:limit => count
|
16
|
+
}}
|
14
17
|
end
|
15
18
|
end
|
16
19
|
|
@@ -22,6 +25,7 @@ module CommentableModel # for inclusion into ActiveRecord::Base
|
|
22
25
|
def has_comments
|
23
26
|
return if has_comments?
|
24
27
|
has_many :posts, :order => 'posts.created_at ASC', :dependent => :destroy
|
28
|
+
belongs_to :replied_by, :class_name => 'Reader' if column_names.include? 'replied_by_id'
|
25
29
|
class_eval {
|
26
30
|
extend CommentableModel::CommentableClassMethods
|
27
31
|
include CommentableModel::CommentableInstanceMethods
|
data/lib/forum_admin_ui.rb
CHANGED
@@ -23,10 +23,10 @@ module ForumAdminUI
|
|
23
23
|
protected
|
24
24
|
|
25
25
|
def load_default_forum_regions
|
26
|
-
|
26
|
+
OpenStruct.new.tap do |forum|
|
27
27
|
forum.edit = Radiant::AdminUI::RegionSet.new do |edit|
|
28
28
|
edit.main.concat %w{edit_header edit_form}
|
29
|
-
edit.form.concat %w{edit_name edit_description}
|
29
|
+
edit.form.concat %w{edit_name edit_description edit_group}
|
30
30
|
edit.form_bottom.concat %w{edit_buttons}
|
31
31
|
end
|
32
32
|
forum.index = Radiant::AdminUI::RegionSet.new do |index|
|
@@ -40,11 +40,11 @@ module ForumAdminUI
|
|
40
40
|
end
|
41
41
|
|
42
42
|
def load_default_topic_regions
|
43
|
-
|
43
|
+
OpenStruct.new.tap do |topic|
|
44
44
|
topic.edit = Radiant::AdminUI::RegionSet.new do |edit|
|
45
45
|
edit.main.concat %w{edit_header edit_form}
|
46
46
|
edit.form.concat %w{edit_name edit_body}
|
47
|
-
edit.form_bottom.concat %w{
|
47
|
+
edit.form_bottom.concat %w{edit_buttons}
|
48
48
|
end
|
49
49
|
topic.index = Radiant::AdminUI::RegionSet.new do |index|
|
50
50
|
index.thead.concat %w{title_header date_header author_header body_header modify_header}
|
@@ -57,11 +57,11 @@ module ForumAdminUI
|
|
57
57
|
end
|
58
58
|
|
59
59
|
def load_default_post_regions
|
60
|
-
|
60
|
+
OpenStruct.new.tap do |post|
|
61
61
|
post.edit = Radiant::AdminUI::RegionSet.new do |edit|
|
62
62
|
edit.main.concat %w{edit_header edit_form}
|
63
63
|
edit.form.concat %w{show_name edit_body}
|
64
|
-
edit.form_bottom.concat %w{
|
64
|
+
edit.form_bottom.concat %w{edit_buttons}
|
65
65
|
end
|
66
66
|
post.index = Radiant::AdminUI::RegionSet.new do |index|
|
67
67
|
index.thead.concat %w{body_header author_header topic_header modify_header}
|
data/lib/forum_page.rb
CHANGED
@@ -10,14 +10,16 @@ module ForumPage
|
|
10
10
|
module InstanceMethods
|
11
11
|
|
12
12
|
def show_comments?
|
13
|
-
commentable?
|
13
|
+
!virtual? && !self.is_a?(RailsPage) && commentable?
|
14
14
|
end
|
15
15
|
|
16
|
+
# commentable? is a boolean model column
|
16
17
|
def still_commentable?
|
18
|
+
return false if virtual? or self.is_a? RailsPage
|
17
19
|
return false unless Radiant::Config['forum.allow_page_comments?'] && commentable?
|
18
20
|
return false if comments_closed?
|
19
21
|
return true unless commentable_period && commentable_period > 0
|
20
|
-
return Time.now - self.
|
22
|
+
return Time.now - self.published_at < commentable_period
|
21
23
|
end
|
22
24
|
|
23
25
|
def locked?
|
@@ -29,6 +31,6 @@ module ForumPage
|
|
29
31
|
def commentable_period
|
30
32
|
Radiant::Config['forum.commentable_period'].to_i.days if Radiant::Config['forum.commentable_period']
|
31
33
|
end
|
32
|
-
|
34
|
+
|
33
35
|
end
|
34
36
|
end
|
data/lib/forum_reader.rb
CHANGED
@@ -2,7 +2,6 @@ module ForumReader
|
|
2
2
|
|
3
3
|
def self.included(base)
|
4
4
|
base.class_eval {
|
5
|
-
has_many :topics, :dependent => :nullify
|
6
5
|
has_many :posts, :order => 'posts.created_at desc', :dependent => :nullify
|
7
6
|
|
8
7
|
named_scope :most_commenting, lambda { |count|
|
@@ -16,4 +15,11 @@ module ForumReader
|
|
16
15
|
}
|
17
16
|
}
|
18
17
|
end
|
18
|
+
|
19
|
+
# This will get more useful soon. For now I'm just establishing an interface.
|
20
|
+
# Moderation will be a global flag but can also come from group-leadership or forum-ownership
|
21
|
+
|
22
|
+
def is_moderator?(thing=nil)
|
23
|
+
true if is_admin?
|
24
|
+
end
|
19
25
|
end
|
@@ -2,11 +2,10 @@ module ForumReaderSessionsController
|
|
2
2
|
|
3
3
|
def self.included(base)
|
4
4
|
base.class_eval do
|
5
|
-
def
|
6
|
-
Rails.logger.warn ">>> default_loggedin_url is going to be #{topics_url}"
|
5
|
+
def default_welcome_url_with_forum
|
7
6
|
topics_url
|
8
7
|
end
|
9
|
-
alias_method_chain :
|
8
|
+
alias_method_chain :default_welcome_url, :forum
|
10
9
|
end
|
11
10
|
|
12
11
|
end
|
data/lib/forum_tags.rb
CHANGED
@@ -6,6 +6,23 @@ module ForumTags
|
|
6
6
|
|
7
7
|
class TagError < StandardError; end
|
8
8
|
|
9
|
+
tag 'forum_css' do |tag|
|
10
|
+
styles = []
|
11
|
+
styles << %{<link rel="stylesheet" href="/cleditor/jquery.cleditor.css" media="all" />} if Radiant.config['forum.toolbar?']
|
12
|
+
styles << %{<link rel="stylesheet" href="/stylesheets/forum.css" media="all" />}
|
13
|
+
end
|
14
|
+
|
15
|
+
tag 'forum_js' do |tag|
|
16
|
+
scripts = []
|
17
|
+
scripts << %{
|
18
|
+
<script type="text/javascript" src="/cleditor/jquery.cleditor.js"></script>
|
19
|
+
<script type="text/javascript" src="/cleditor/jquery.cleditor.icon.js"></script>
|
20
|
+
<script type="text/javascript" src="/cleditor/jquery.cleditor.xhtml.js"></script>
|
21
|
+
} if Radiant.config['forum.toolbar?']
|
22
|
+
scripts << %{<script type="text/javascript" src="/javascripts/forum.js"></script>}
|
23
|
+
scripts.join
|
24
|
+
end
|
25
|
+
|
9
26
|
tag 'forum' do |tag|
|
10
27
|
tag.expand
|
11
28
|
end
|
@@ -126,10 +143,10 @@ module ForumTags
|
|
126
143
|
output = []
|
127
144
|
topic = tag.locals.topic
|
128
145
|
if tag.locals.topic.has_replies?
|
129
|
-
output << I18n.t('reply_from')
|
146
|
+
output << I18n.t('forum_extension.reply_from')
|
130
147
|
output << %{<a href="#{reader_path(tag.locals.topic.replied_by)}">#{tag.locals.topic.replied_by.name}</a>}
|
131
148
|
else
|
132
|
-
output << I18n.t('started_by')
|
149
|
+
output << I18n.t('forum_extension.started_by')
|
133
150
|
output << %{<a href="#{reader_path(tag.locals.topic.reader)}">#{tag.render('forum:topic:author')}</a>}
|
134
151
|
end
|
135
152
|
output.join(' ')
|
@@ -250,11 +267,11 @@ module ForumTags
|
|
250
267
|
output = []
|
251
268
|
post = tag.locals.post
|
252
269
|
if post.page
|
253
|
-
output << I18n.t('new_comment_from')
|
270
|
+
output << I18n.t('forum_extension.new_comment_from')
|
254
271
|
elsif post.first?
|
255
|
-
output << I18n.t('new_reply_from')
|
272
|
+
output << I18n.t('forum_extension.new_reply_from')
|
256
273
|
else
|
257
|
-
output << I18n.t('new_topic_from')
|
274
|
+
output << I18n.t('forum_extension.new_topic_from')
|
258
275
|
end
|
259
276
|
output << %{<a href="#{reader_path(tag.locals.post.reader)}">#{tag.render('forum:post:author')}</a>}
|
260
277
|
output << tag.render('forum:post:date')
|
@@ -284,10 +301,10 @@ module ForumTags
|
|
284
301
|
options = tag.attr.dup
|
285
302
|
if tag.locals.page.still_commentable?
|
286
303
|
attributes = options.inject('') { |s, (k, v)| s << %{#{k.to_s.downcase}="#{v}" } }.strip
|
287
|
-
text = tag.double? ? tag.expand : I18n.t("add_comment")
|
304
|
+
text = tag.double? ? tag.expand : I18n.t("forum_extension.add_comment")
|
288
305
|
%{<a href="#{tag.render('comment_url')}" #{attributes}>#{text}</a>}
|
289
306
|
else
|
290
|
-
I18n.t("comments_closed")
|
307
|
+
I18n.t("forum_extension.comments_closed")
|
291
308
|
end
|
292
309
|
end
|
293
310
|
|
@@ -309,7 +326,7 @@ module ForumTags
|
|
309
326
|
end
|
310
327
|
|
311
328
|
tag 'comments' do |tag|
|
312
|
-
tag.expand if tag.locals.page.
|
329
|
+
tag.expand if tag.locals.page.show_comments?
|
313
330
|
end
|
314
331
|
|
315
332
|
desc %{
|
@@ -317,9 +334,9 @@ module ForumTags
|
|
317
334
|
}
|
318
335
|
tag 'comments:summary' do |tag|
|
319
336
|
if tag.locals.posts.respond_to? :total_entries
|
320
|
-
I18n.t("comment_count", :count => tag.locals.posts.total_entries)
|
337
|
+
I18n.t("forum_extension.comment_count", :count => tag.locals.posts.total_entries)
|
321
338
|
else
|
322
|
-
I18n.t("comment_count", :count => tag.locals.posts.length)
|
339
|
+
I18n.t("forum_extension.comment_count", :count => tag.locals.posts.length)
|
323
340
|
end
|
324
341
|
end
|
325
342
|
|
@@ -364,7 +381,7 @@ module ForumTags
|
|
364
381
|
tag.locals.post = post
|
365
382
|
results << tag.render('comment')
|
366
383
|
end
|
367
|
-
results << %{<div class="new_post"><div class="wrapper"><p
|
384
|
+
results << %{<div class="new_post"><div class="wrapper"><p>#{tag.render('comment_link', 'class' => 'remote post')}</p></div></div>}
|
368
385
|
results << tag.render('pagination', tag.attr.dup)
|
369
386
|
results << "</div>"
|
370
387
|
results
|
@@ -391,4 +408,102 @@ module ForumTags
|
|
391
408
|
end
|
392
409
|
end
|
393
410
|
|
411
|
+
|
412
|
+
|
413
|
+
|
414
|
+
desc %{
|
415
|
+
Expands if this group has any forums.
|
416
|
+
|
417
|
+
<pre><code><r:group:if_forums>...</r:group:if_forums></code></pre>
|
418
|
+
}
|
419
|
+
tag "group:if_forums" do |tag|
|
420
|
+
tag.expand if tag.locals.group.forums.any?
|
421
|
+
end
|
422
|
+
|
423
|
+
desc %{
|
424
|
+
Expands if this group does not have any forums.
|
425
|
+
|
426
|
+
<pre><code><r:group:unless_forums>...</r:group:unless_forums></code></pre>
|
427
|
+
}
|
428
|
+
tag "group:unless_forums" do |tag|
|
429
|
+
tag.expand unless tag.locals.group.forums.any?
|
430
|
+
end
|
431
|
+
|
432
|
+
desc %{
|
433
|
+
Expands if this group has any topics.
|
434
|
+
|
435
|
+
<pre><code><r:group:if_topics>...</r:group:if_topics></code></pre>
|
436
|
+
}
|
437
|
+
tag "group:if_topics" do |tag|
|
438
|
+
tag.expand if tag.locals.group.topics.any?
|
439
|
+
end
|
440
|
+
|
441
|
+
desc %{
|
442
|
+
Expands if this group does not have any topics.
|
443
|
+
|
444
|
+
<pre><code><r:group:unless_topics>...</r:group:unless_topics></code></pre>
|
445
|
+
}
|
446
|
+
tag "group:unless_topics" do |tag|
|
447
|
+
tag.expand unless tag.locals.group.topics.any?
|
448
|
+
end
|
449
|
+
|
450
|
+
desc %{
|
451
|
+
Loops through the forums belonging to this group.
|
452
|
+
|
453
|
+
<pre><code><r:group:forums:each>...</r:group:forums:each /></code></pre>
|
454
|
+
}
|
455
|
+
tag "group:forums" do |tag|
|
456
|
+
tag.locals.forums = tag.locals.group.forums
|
457
|
+
tag.expand
|
458
|
+
end
|
459
|
+
tag "group:forums:each" do |tag|
|
460
|
+
result = []
|
461
|
+
tag.locals.forums.each do |forum|
|
462
|
+
tag.locals.forum = forum
|
463
|
+
result << tag.expand
|
464
|
+
end
|
465
|
+
result
|
466
|
+
end
|
467
|
+
|
468
|
+
desc %{
|
469
|
+
Loops through the latest topics in all forums belonging to this group.
|
470
|
+
|
471
|
+
<pre><code><r:group:latest_topics:each count="10">...</r:group:latest_topics:each></code></pre>
|
472
|
+
}
|
473
|
+
tag "group:latest_topics" do |tag|
|
474
|
+
count = tag.attr["count"] || 10
|
475
|
+
tag.locals.topics = tag.locals.group.topics.latest(count)
|
476
|
+
tag.expand
|
477
|
+
end
|
478
|
+
tag "group:latest_topics:each" do |tag|
|
479
|
+
result = []
|
480
|
+
tag.locals.topics.each do |topic|
|
481
|
+
tag.locals.topic = topic
|
482
|
+
result << tag.expand
|
483
|
+
end
|
484
|
+
result
|
485
|
+
end
|
486
|
+
|
487
|
+
desc %{
|
488
|
+
If the group has only one forum, this presents a simple new-topic link around the supplied text.
|
489
|
+
If it has several forums, this offers a list with the supplied text as the heading.
|
490
|
+
|
491
|
+
<pre><code><r:group:new_topic_link /></code></pre>
|
492
|
+
}
|
493
|
+
tag "group:new_topic_link" do |tag|
|
494
|
+
forums = tag.locals.group.forums
|
495
|
+
text = tag.double? ? tag.expand : "Start a new conversation"
|
496
|
+
result = ""
|
497
|
+
case forums.length
|
498
|
+
when 0
|
499
|
+
when 1
|
500
|
+
result << %{<a href="#{new_forum_topic_path(forums.first)}">#{text}</a>}
|
501
|
+
else
|
502
|
+
result << %{<h3>#{text}</h3><ul>}
|
503
|
+
result << forums.collect{|forum| %{<li><a href="#{new_forum_topic_path(forum)}">#{forum.name}</a></li>}}
|
504
|
+
result << "</ul>"
|
505
|
+
end
|
506
|
+
result
|
507
|
+
end
|
508
|
+
|
394
509
|
end
|
@@ -0,0 +1,8 @@
|
|
1
|
+
module RadiantForumExtension
|
2
|
+
VERSION = '3.0.0.rc3'
|
3
|
+
SUMMARY = %q{Forum and Comment Extension for Radiant CMS}
|
4
|
+
DESCRIPTION = %q{Nice clean forums and page comments for inclusion in your radiant site.}
|
5
|
+
URL = "http://radiant.spanner.org/forum"
|
6
|
+
AUTHORS = ["William Ross"]
|
7
|
+
EMAIL = ["radiant@spanner.org"]
|
8
|
+
end
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1,24 @@
|
|
1
|
+
.cleditorMain {border:none; padding:0 1px 1px; background-color:white}
|
2
|
+
.cleditorMain iframe {border:1px solid #999; margin:0; padding:0}
|
3
|
+
.cleditorMain textarea {border:none; margin:0; padding:0; overflow-y:scroll; font:10pt Arial,Verdana; resize:none; outline:none /* webkit grip focus */}
|
4
|
+
.cleditorToolbar {background: none}
|
5
|
+
.cleditorGroup {float:left; height:26px}
|
6
|
+
.cleditorButton {float:left; width:24px; height:24px; margin:1px 0 1px 0; background: url('images/buttons.gif')}
|
7
|
+
.cleditorDisabled {opacity:0.3; filter:alpha(opacity=30)}
|
8
|
+
.cleditorDivider {float:left; width:1px; height:23px; margin:1px 0 1px 0; background:#CCC}
|
9
|
+
.cleditorPopup {border:solid 1px #999; background-color:white; position:absolute; font:10pt Arial,Verdana; cursor:default; z-index:10000}
|
10
|
+
.cleditorList div {padding:2px 4px 2px 4px}
|
11
|
+
.cleditorList p,
|
12
|
+
.cleditorList h1,
|
13
|
+
.cleditorList h2,
|
14
|
+
.cleditorList h3,
|
15
|
+
.cleditorList h4,
|
16
|
+
.cleditorList h5,
|
17
|
+
.cleditorList h6,
|
18
|
+
.cleditorList font {padding:0; margin:0; background-color:Transparent}
|
19
|
+
.cleditorColor {width:150px; padding:1px 0 0 1px}
|
20
|
+
.cleditorColor div {float:left; width:14px; height:14px; margin:0 1px 1px 0}
|
21
|
+
.cleditorPrompt {background-color:#F6F7F9; padding:4px; font-size:8.5pt}
|
22
|
+
.cleditorPrompt input,
|
23
|
+
.cleditorPrompt textarea {font:8.5pt Arial,Verdana;}
|
24
|
+
.cleditorMsg {background-color:#FDFCEE; width:150px; padding:4px; font-size:8.5pt}
|