savage-beast 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (265) hide show
  1. data/.gitignore +2 -0
  2. data/README.rdoc +42 -0
  3. data/Rakefile +25 -0
  4. data/VERSION +1 -0
  5. data/app/controllers/application.rb +6 -0
  6. data/app/controllers/beast_application_controller.rb +3 -0
  7. data/app/controllers/forums_controller.rb +64 -0
  8. data/app/controllers/moderators_controller.rb +10 -0
  9. data/app/controllers/monitorships_controller.rb +22 -0
  10. data/app/controllers/posts_controller.rb +134 -0
  11. data/app/controllers/topics_controller.rb +110 -0
  12. data/app/helpers/count_helper.rb +13 -0
  13. data/app/helpers/forums_helper.rb +15 -0
  14. data/app/helpers/moderators_helper.rb +2 -0
  15. data/app/helpers/monitorships_helper.rb +2 -0
  16. data/app/helpers/posts_helper.rb +3 -0
  17. data/app/helpers/topics_helper.rb +3 -0
  18. data/app/models/forum.rb +26 -0
  19. data/app/models/moderatorship.rb +6 -0
  20. data/app/models/monitorship.rb +5 -0
  21. data/app/models/monitorships_sweeper.rb +9 -0
  22. data/app/models/post.rb +33 -0
  23. data/app/models/posts_sweeper.rb +12 -0
  24. data/app/models/topic.rb +94 -0
  25. data/app/views/forums/_form.html.erb +21 -0
  26. data/app/views/forums/edit.html.erb +12 -0
  27. data/app/views/forums/index.html.erb +77 -0
  28. data/app/views/forums/new.html.erb +10 -0
  29. data/app/views/forums/show.html.erb +94 -0
  30. data/app/views/layouts/_head.html.erb +34 -0
  31. data/app/views/layouts/_post.rss.builder +9 -0
  32. data/app/views/layouts/application.html.erb +29 -0
  33. data/app/views/layouts/beast.html.erb +29 -0
  34. data/app/views/monitorships/create.js.rjs +4 -0
  35. data/app/views/monitorships/destroy.js.rjs +4 -0
  36. data/app/views/posts/_edit.html.erb +38 -0
  37. data/app/views/posts/edit.html.erb +14 -0
  38. data/app/views/posts/edit.js.rjs +6 -0
  39. data/app/views/posts/index.html.erb +53 -0
  40. data/app/views/posts/index.rss.builder +20 -0
  41. data/app/views/posts/monitored.html.erb +55 -0
  42. data/app/views/posts/monitored.rss.builder +15 -0
  43. data/app/views/posts/update.js.rjs +3 -0
  44. data/app/views/topics/_form.html.erb +28 -0
  45. data/app/views/topics/edit.html.erb +10 -0
  46. data/app/views/topics/index.html.erb +2 -0
  47. data/app/views/topics/new.html.erb +18 -0
  48. data/app/views/topics/show.html.erb +183 -0
  49. data/app/views/topics/show.rss.builder +16 -0
  50. data/config/routes.rb +18 -0
  51. data/generators/beast/beast_generator.rb +88 -0
  52. data/generators/beast/templates/migrations/create_savage_tables.rb +73 -0
  53. data/generators/beast/templates/public/images/clearbits/_readme.txt +12 -0
  54. data/generators/beast/templates/public/images/clearbits/add.gif +0 -0
  55. data/generators/beast/templates/public/images/clearbits/addressbook.gif +0 -0
  56. data/generators/beast/templates/public/images/clearbits/alert.gif +0 -0
  57. data/generators/beast/templates/public/images/clearbits/apple.gif +0 -0
  58. data/generators/beast/templates/public/images/clearbits/arrow1_e.gif +0 -0
  59. data/generators/beast/templates/public/images/clearbits/arrow1_n.gif +0 -0
  60. data/generators/beast/templates/public/images/clearbits/arrow1_ne.gif +0 -0
  61. data/generators/beast/templates/public/images/clearbits/arrow1_nw.gif +0 -0
  62. data/generators/beast/templates/public/images/clearbits/arrow1_s.gif +0 -0
  63. data/generators/beast/templates/public/images/clearbits/arrow1_se.gif +0 -0
  64. data/generators/beast/templates/public/images/clearbits/arrow1_sw.gif +0 -0
  65. data/generators/beast/templates/public/images/clearbits/arrow1_w.gif +0 -0
  66. data/generators/beast/templates/public/images/clearbits/arrow2_e.gif +0 -0
  67. data/generators/beast/templates/public/images/clearbits/arrow2_n.gif +0 -0
  68. data/generators/beast/templates/public/images/clearbits/arrow2_ne.gif +0 -0
  69. data/generators/beast/templates/public/images/clearbits/arrow2_nw.gif +0 -0
  70. data/generators/beast/templates/public/images/clearbits/arrow2_s.gif +0 -0
  71. data/generators/beast/templates/public/images/clearbits/arrow2_se.gif +0 -0
  72. data/generators/beast/templates/public/images/clearbits/arrow2_sw.gif +0 -0
  73. data/generators/beast/templates/public/images/clearbits/arrow2_w.gif +0 -0
  74. data/generators/beast/templates/public/images/clearbits/arrow3_e.gif +0 -0
  75. data/generators/beast/templates/public/images/clearbits/arrow3_n.gif +0 -0
  76. data/generators/beast/templates/public/images/clearbits/arrow3_ne.gif +0 -0
  77. data/generators/beast/templates/public/images/clearbits/arrow3_nw.gif +0 -0
  78. data/generators/beast/templates/public/images/clearbits/arrow3_s.gif +0 -0
  79. data/generators/beast/templates/public/images/clearbits/arrow3_se.gif +0 -0
  80. data/generators/beast/templates/public/images/clearbits/arrow3_sw.gif +0 -0
  81. data/generators/beast/templates/public/images/clearbits/arrow3_w.gif +0 -0
  82. data/generators/beast/templates/public/images/clearbits/ascii.gif +0 -0
  83. data/generators/beast/templates/public/images/clearbits/back.gif +0 -0
  84. data/generators/beast/templates/public/images/clearbits/bg_blank.gif +0 -0
  85. data/generators/beast/templates/public/images/clearbits/bg_circle.gif +0 -0
  86. data/generators/beast/templates/public/images/clearbits/bg_rounded.gif +0 -0
  87. data/generators/beast/templates/public/images/clearbits/bg_rounded_ne.gif +0 -0
  88. data/generators/beast/templates/public/images/clearbits/bg_rounded_nw.gif +0 -0
  89. data/generators/beast/templates/public/images/clearbits/bg_rounded_se.gif +0 -0
  90. data/generators/beast/templates/public/images/clearbits/bg_rounded_sw.gif +0 -0
  91. data/generators/beast/templates/public/images/clearbits/bigsmile.gif +0 -0
  92. data/generators/beast/templates/public/images/clearbits/binary.gif +0 -0
  93. data/generators/beast/templates/public/images/clearbits/blah.gif +0 -0
  94. data/generators/beast/templates/public/images/clearbits/bstop.gif +0 -0
  95. data/generators/beast/templates/public/images/clearbits/buy.gif +0 -0
  96. data/generators/beast/templates/public/images/clearbits/calday.gif +0 -0
  97. data/generators/beast/templates/public/images/clearbits/calendar.gif +0 -0
  98. data/generators/beast/templates/public/images/clearbits/camera.gif +0 -0
  99. data/generators/beast/templates/public/images/clearbits/cart.gif +0 -0
  100. data/generators/beast/templates/public/images/clearbits/cd.gif +0 -0
  101. data/generators/beast/templates/public/images/clearbits/cellphone.gif +0 -0
  102. data/generators/beast/templates/public/images/clearbits/chat.gif +0 -0
  103. data/generators/beast/templates/public/images/clearbits/check.gif +0 -0
  104. data/generators/beast/templates/public/images/clearbits/close.gif +0 -0
  105. data/generators/beast/templates/public/images/clearbits/comment.gif +0 -0
  106. data/generators/beast/templates/public/images/clearbits/cube.gif +0 -0
  107. data/generators/beast/templates/public/images/clearbits/day.gif +0 -0
  108. data/generators/beast/templates/public/images/clearbits/denied.gif +0 -0
  109. data/generators/beast/templates/public/images/clearbits/document.gif +0 -0
  110. data/generators/beast/templates/public/images/clearbits/download.gif +0 -0
  111. data/generators/beast/templates/public/images/clearbits/edit.gif +0 -0
  112. data/generators/beast/templates/public/images/clearbits/eject.gif +0 -0
  113. data/generators/beast/templates/public/images/clearbits/equalizer.gif +0 -0
  114. data/generators/beast/templates/public/images/clearbits/first.gif +0 -0
  115. data/generators/beast/templates/public/images/clearbits/flag.gif +0 -0
  116. data/generators/beast/templates/public/images/clearbits/flash.gif +0 -0
  117. data/generators/beast/templates/public/images/clearbits/folder.gif +0 -0
  118. data/generators/beast/templates/public/images/clearbits/forward.gif +0 -0
  119. data/generators/beast/templates/public/images/clearbits/frown.gif +0 -0
  120. data/generators/beast/templates/public/images/clearbits/ftp.gif +0 -0
  121. data/generators/beast/templates/public/images/clearbits/graph.gif +0 -0
  122. data/generators/beast/templates/public/images/clearbits/heart.gif +0 -0
  123. data/generators/beast/templates/public/images/clearbits/home.gif +0 -0
  124. data/generators/beast/templates/public/images/clearbits/html.gif +0 -0
  125. data/generators/beast/templates/public/images/clearbits/ipod.gif +0 -0
  126. data/generators/beast/templates/public/images/clearbits/last.gif +0 -0
  127. data/generators/beast/templates/public/images/clearbits/lock.gif +0 -0
  128. data/generators/beast/templates/public/images/clearbits/loop.gif +0 -0
  129. data/generators/beast/templates/public/images/clearbits/mail.gif +0 -0
  130. data/generators/beast/templates/public/images/clearbits/man.gif +0 -0
  131. data/generators/beast/templates/public/images/clearbits/manman.gif +0 -0
  132. data/generators/beast/templates/public/images/clearbits/music.gif +0 -0
  133. data/generators/beast/templates/public/images/clearbits/mute.gif +0 -0
  134. data/generators/beast/templates/public/images/clearbits/mute_centered.gif +0 -0
  135. data/generators/beast/templates/public/images/clearbits/newwindow.gif +0 -0
  136. data/generators/beast/templates/public/images/clearbits/next.gif +0 -0
  137. data/generators/beast/templates/public/images/clearbits/night.gif +0 -0
  138. data/generators/beast/templates/public/images/clearbits/open.gif +0 -0
  139. data/generators/beast/templates/public/images/clearbits/pause.gif +0 -0
  140. data/generators/beast/templates/public/images/clearbits/phone.gif +0 -0
  141. data/generators/beast/templates/public/images/clearbits/play.gif +0 -0
  142. data/generators/beast/templates/public/images/clearbits/previous.gif +0 -0
  143. data/generators/beast/templates/public/images/clearbits/quicktime.gif +0 -0
  144. data/generators/beast/templates/public/images/clearbits/redo.gif +0 -0
  145. data/generators/beast/templates/public/images/clearbits/reload.gif +0 -0
  146. data/generators/beast/templates/public/images/clearbits/sad.gif +0 -0
  147. data/generators/beast/templates/public/images/clearbits/save.gif +0 -0
  148. data/generators/beast/templates/public/images/clearbits/scream.gif +0 -0
  149. data/generators/beast/templates/public/images/clearbits/search.gif +0 -0
  150. data/generators/beast/templates/public/images/clearbits/seconds.gif +0 -0
  151. data/generators/beast/templates/public/images/clearbits/smile.gif +0 -0
  152. data/generators/beast/templates/public/images/clearbits/smirk.gif +0 -0
  153. data/generators/beast/templates/public/images/clearbits/star.gif +0 -0
  154. data/generators/beast/templates/public/images/clearbits/stop.gif +0 -0
  155. data/generators/beast/templates/public/images/clearbits/subtract.gif +0 -0
  156. data/generators/beast/templates/public/images/clearbits/switch.gif +0 -0
  157. data/generators/beast/templates/public/images/clearbits/target.gif +0 -0
  158. data/generators/beast/templates/public/images/clearbits/tcp.gif +0 -0
  159. data/generators/beast/templates/public/images/clearbits/time.gif +0 -0
  160. data/generators/beast/templates/public/images/clearbits/toggle.gif +0 -0
  161. data/generators/beast/templates/public/images/clearbits/tongue.gif +0 -0
  162. data/generators/beast/templates/public/images/clearbits/tools.gif +0 -0
  163. data/generators/beast/templates/public/images/clearbits/trackback.gif +0 -0
  164. data/generators/beast/templates/public/images/clearbits/trash.gif +0 -0
  165. data/generators/beast/templates/public/images/clearbits/tv.gif +0 -0
  166. data/generators/beast/templates/public/images/clearbits/type.gif +0 -0
  167. data/generators/beast/templates/public/images/clearbits/undo.gif +0 -0
  168. data/generators/beast/templates/public/images/clearbits/unlock.gif +0 -0
  169. data/generators/beast/templates/public/images/clearbits/upload.gif +0 -0
  170. data/generators/beast/templates/public/images/clearbits/user.gif +0 -0
  171. data/generators/beast/templates/public/images/clearbits/video.gif +0 -0
  172. data/generators/beast/templates/public/images/clearbits/volume_high.gif +0 -0
  173. data/generators/beast/templates/public/images/clearbits/volume_low.gif +0 -0
  174. data/generators/beast/templates/public/images/clearbits/wifi.gif +0 -0
  175. data/generators/beast/templates/public/images/clearbits/window.gif +0 -0
  176. data/generators/beast/templates/public/images/clearbits/woman.gif +0 -0
  177. data/generators/beast/templates/public/images/clearbits/womanman.gif +0 -0
  178. data/generators/beast/templates/public/images/clearbits/work.gif +0 -0
  179. data/generators/beast/templates/public/images/clearbits/zoomin.gif +0 -0
  180. data/generators/beast/templates/public/images/clearbits/zoomout.gif +0 -0
  181. data/generators/beast/templates/public/images/feed-icon.png +0 -0
  182. data/generators/beast/templates/public/images/rails.png +0 -0
  183. data/generators/beast/templates/public/images/reply_background.png +0 -0
  184. data/generators/beast/templates/public/images/small_circle.gif +0 -0
  185. data/generators/beast/templates/public/images/spinner.gif +0 -0
  186. data/generators/beast/templates/public/images/spinner_black.gif +0 -0
  187. data/generators/beast/templates/public/images/spinner_bounce.gif +0 -0
  188. data/generators/beast/templates/public/javascripts/beast.js +80 -0
  189. data/generators/beast/templates/public/stylesheets/display.css +941 -0
  190. data/lang/en.yml +206 -0
  191. data/lib/beast.rb +79 -0
  192. data/lib/savage_beast/application_helper.rb +91 -0
  193. data/lib/savage_beast/authentication_system.rb +47 -0
  194. data/lib/savage_beast/user_init.rb +79 -0
  195. data/lib/tasks/capistrano.rake +90 -0
  196. data/lib/tasks/deploy_edge.rake +44 -0
  197. data/lib/tasks/savage_beast.rake +133 -0
  198. data/po/beast.pot +712 -0
  199. data/po/nl/beast.po +700 -0
  200. data/tested_plugins/acts_as_list/README +23 -0
  201. data/tested_plugins/acts_as_list/init.rb +3 -0
  202. data/tested_plugins/acts_as_list/lib/active_record/acts/list.rb +256 -0
  203. data/tested_plugins/acts_as_list/test/list_test.rb +332 -0
  204. data/tested_plugins/gibberish/LICENSE +18 -0
  205. data/tested_plugins/gibberish/README +118 -0
  206. data/tested_plugins/gibberish/Rakefile +14 -0
  207. data/tested_plugins/gibberish/init.rb +3 -0
  208. data/tested_plugins/gibberish/lang/es.yml +3 -0
  209. data/tested_plugins/gibberish/lang/fr.yml +3 -0
  210. data/tested_plugins/gibberish/lib/gibberish.rb +8 -0
  211. data/tested_plugins/gibberish/lib/gibberish/localize.rb +88 -0
  212. data/tested_plugins/gibberish/lib/gibberish/string_ext.rb +17 -0
  213. data/tested_plugins/gibberish/test/gibberish_test.rb +203 -0
  214. data/tested_plugins/gibberish/test/lang/es.yml +1 -0
  215. data/tested_plugins/gibberish/test/lang/fr.yml +1 -0
  216. data/tested_plugins/mislav-will_paginate/CHANGELOG.rdoc +110 -0
  217. data/tested_plugins/mislav-will_paginate/LICENSE +18 -0
  218. data/tested_plugins/mislav-will_paginate/README.rdoc +107 -0
  219. data/tested_plugins/mislav-will_paginate/Rakefile +53 -0
  220. data/tested_plugins/mislav-will_paginate/examples/apple-circle.gif +0 -0
  221. data/tested_plugins/mislav-will_paginate/examples/index.haml +69 -0
  222. data/tested_plugins/mislav-will_paginate/examples/index.html +92 -0
  223. data/tested_plugins/mislav-will_paginate/examples/pagination.css +90 -0
  224. data/tested_plugins/mislav-will_paginate/examples/pagination.sass +91 -0
  225. data/tested_plugins/mislav-will_paginate/init.rb +1 -0
  226. data/tested_plugins/mislav-will_paginate/lib/will_paginate.rb +78 -0
  227. data/tested_plugins/mislav-will_paginate/lib/will_paginate/array.rb +16 -0
  228. data/tested_plugins/mislav-will_paginate/lib/will_paginate/collection.rb +146 -0
  229. data/tested_plugins/mislav-will_paginate/lib/will_paginate/core_ext.rb +32 -0
  230. data/tested_plugins/mislav-will_paginate/lib/will_paginate/finder.rb +264 -0
  231. data/tested_plugins/mislav-will_paginate/lib/will_paginate/named_scope.rb +170 -0
  232. data/tested_plugins/mislav-will_paginate/lib/will_paginate/named_scope_patch.rb +37 -0
  233. data/tested_plugins/mislav-will_paginate/lib/will_paginate/version.rb +9 -0
  234. data/tested_plugins/mislav-will_paginate/lib/will_paginate/view_helpers.rb +402 -0
  235. data/tested_plugins/mislav-will_paginate/test/boot.rb +21 -0
  236. data/tested_plugins/mislav-will_paginate/test/collection_test.rb +143 -0
  237. data/tested_plugins/mislav-will_paginate/test/console +8 -0
  238. data/tested_plugins/mislav-will_paginate/test/database.yml +22 -0
  239. data/tested_plugins/mislav-will_paginate/test/finder_test.rb +476 -0
  240. data/tested_plugins/mislav-will_paginate/test/fixtures/admin.rb +3 -0
  241. data/tested_plugins/mislav-will_paginate/test/fixtures/developer.rb +14 -0
  242. data/tested_plugins/mislav-will_paginate/test/fixtures/developers_projects.yml +13 -0
  243. data/tested_plugins/mislav-will_paginate/test/fixtures/project.rb +15 -0
  244. data/tested_plugins/mislav-will_paginate/test/fixtures/projects.yml +6 -0
  245. data/tested_plugins/mislav-will_paginate/test/fixtures/replies.yml +29 -0
  246. data/tested_plugins/mislav-will_paginate/test/fixtures/reply.rb +7 -0
  247. data/tested_plugins/mislav-will_paginate/test/fixtures/schema.rb +38 -0
  248. data/tested_plugins/mislav-will_paginate/test/fixtures/topic.rb +10 -0
  249. data/tested_plugins/mislav-will_paginate/test/fixtures/topics.yml +30 -0
  250. data/tested_plugins/mislav-will_paginate/test/fixtures/user.rb +2 -0
  251. data/tested_plugins/mislav-will_paginate/test/fixtures/users.yml +35 -0
  252. data/tested_plugins/mislav-will_paginate/test/helper.rb +40 -0
  253. data/tested_plugins/mislav-will_paginate/test/lib/activerecord_test_case.rb +43 -0
  254. data/tested_plugins/mislav-will_paginate/test/lib/activerecord_test_connector.rb +75 -0
  255. data/tested_plugins/mislav-will_paginate/test/lib/load_fixtures.rb +11 -0
  256. data/tested_plugins/mislav-will_paginate/test/lib/view_test_process.rb +178 -0
  257. data/tested_plugins/mislav-will_paginate/test/tasks.rake +59 -0
  258. data/tested_plugins/mislav-will_paginate/test/view_test.rb +365 -0
  259. data/tested_plugins/white_list/README +29 -0
  260. data/tested_plugins/white_list/Rakefile +22 -0
  261. data/tested_plugins/white_list/init.rb +2 -0
  262. data/tested_plugins/white_list/lib/white_list_helper.rb +97 -0
  263. data/tested_plugins/white_list/test/white_list_test.rb +132 -0
  264. data/tested_plugins/white_list_formatted_content/init.rb +27 -0
  265. metadata +322 -0
@@ -0,0 +1,2 @@
1
+ *.gem
2
+ *.gemspec
@@ -0,0 +1,42 @@
1
+ = Savage Beast
2
+
3
+ Savage Beast is a Rails Message forum plugin based on the popular Beast plugin.
4
+ The Savage Beast plugin has been installed in hundreds of Rails sites, partially
5
+ because it's the only viable choice for a message forum plugin, but also because
6
+ it incorporates a lot of features that would be a time-consuming headache for you
7
+ to implement yourself.
8
+
9
+ This version of Savage Beast has been tested working in Rails 2.3.
10
+
11
+ == Installation instructions
12
+
13
+ Add in your enviroment.rb
14
+
15
+ config.gem 'savage-beast', :lib => 'beast', :source => 'http://gemcutter.org'
16
+
17
+ Run
18
+
19
+ rake gems:install
20
+
21
+ And then
22
+
23
+ script/generate beast
24
+
25
+ Install required plugins:
26
+ * white_list
27
+ * white_list_formatted_content
28
+ * acts_as_list
29
+ * gibberish
30
+ * will_paginate
31
+
32
+ You can found tested versions of these plugins in directory tested_plugins of gem installation.
33
+ Run app and visitL: http://<you app host>/forums
34
+
35
+ This page provide more info, but it's bit outdated: http://www.williambharding.com/blog/rails/savage-beast-23-a-rails-22-23-message-forum-plugin/
36
+
37
+
38
+
39
+
40
+
41
+
42
+
@@ -0,0 +1,25 @@
1
+ # Add your own tasks in files placed in lib/tasks ending in .rake,
2
+ # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3
+
4
+ require 'rake'
5
+ require 'rake/testtask'
6
+ require 'rake/rdoctask'
7
+
8
+ #require 'tasks/rails'
9
+
10
+ begin
11
+ require 'jeweler'
12
+
13
+ Jeweler::Tasks.new do |gemspec|
14
+ gemspec.name = "savage-beast"
15
+ gemspec.summary = "Rails forum plugin"
16
+ gemspec.description = "Rails 2.3 compatible version Savage Beast with i18n support"
17
+ gemspec.email = "pavel@valodzka.name"
18
+ gemspec.homepage = "http://github.com/valodzka/savage-beast"
19
+ gemspec.authors = ["Rick Olson", "Josh Goebel", "Bill Harding", "Pavel Valodzka"]
20
+ end
21
+
22
+ rescue LoadError
23
+ puts "Jeweler not available. Install it with: sudo gem install jeweler"
24
+ end
25
+
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.0
@@ -0,0 +1,6 @@
1
+ class BeastApplicationController < ApplicationController
2
+ layout 'beast'
3
+ # Commented by WBH for Savage Beast... unnecessary? This looks like what was needed prior to Gibberish
4
+ # init_gettext "beast" if Object.const_defined?(:GetText)
5
+
6
+ end
@@ -0,0 +1,3 @@
1
+ class BeastApplicationController < ApplicationController
2
+ layout 'beast'
3
+ end
@@ -0,0 +1,64 @@
1
+ class ForumsController < BeastApplicationController
2
+ before_filter :login_required, :except => [:index, :show]
3
+ before_filter :find_or_initialize_forum, :except => :index
4
+ before_filter :admin?, :except => [:show, :index]
5
+
6
+ cache_sweeper :posts_sweeper, :only => [:create, :update, :destroy]
7
+
8
+ def index
9
+ @forums = Forum.find_ordered
10
+ # reset the page of each forum we have visited when we go back to index
11
+ session[:forum_page] = nil
12
+ respond_to do |format|
13
+ format.html
14
+ format.xml { render :xml => @forums }
15
+ end
16
+ end
17
+
18
+ def show
19
+ respond_to do |format|
20
+ format.html do
21
+ # keep track of when we last viewed this forum for activity indicators
22
+ (session[:forums] ||= {})[@forum.id] = Time.now.utc if logged_in?
23
+ (session[:forum_page] ||= Hash.new(1))[@forum.id] = params[:page].to_i if params[:page]
24
+
25
+ @topics = @forum.topics.paginate :page => params[:page]
26
+ User.find(:all, :conditions => ['id IN (?)', @topics.collect { |t| t.replied_by }.uniq]) unless @topics.blank?
27
+ end
28
+ format.xml { render :xml => @forum }
29
+ end
30
+ end
31
+
32
+ # new renders new.html.erb
33
+ def create
34
+ @forum.attributes = params[:forum]
35
+ @forum.save!
36
+ respond_to do |format|
37
+ format.html { redirect_to @forum }
38
+ format.xml { head :created, :location => forum_url(@forum, :format => :xml) }
39
+ end
40
+ end
41
+
42
+ def update
43
+ @forum.update_attributes!(params[:forum])
44
+ respond_to do |format|
45
+ format.html { redirect_to @forum }
46
+ format.xml { head 200 }
47
+ end
48
+ end
49
+
50
+ def destroy
51
+ @forum.destroy
52
+ respond_to do |format|
53
+ format.html { redirect_to forums_path }
54
+ format.xml { head 200 }
55
+ end
56
+ end
57
+
58
+ protected
59
+ def find_or_initialize_forum
60
+ @forum = params[:id] ? Forum.find(params[:id]) : Forum.new
61
+ end
62
+
63
+ alias authorized? admin?
64
+ end
@@ -0,0 +1,10 @@
1
+ class ModeratorsController < BeastApplicationController
2
+ before_filter :login_required
3
+
4
+ def destroy
5
+ Moderatorship.delete_all ['id = ?', params[:id]]
6
+ redirect_to user_path(params[:user_id])
7
+ end
8
+
9
+ alias authorized? admin?
10
+ end
@@ -0,0 +1,22 @@
1
+ class MonitorshipsController < BeastApplicationController
2
+ before_filter :login_required
3
+
4
+ cache_sweeper :monitorships_sweeper, :only => [:create, :destroy]
5
+
6
+ def create
7
+ @monitorship = Monitorship.find_or_initialize_by_user_id_and_topic_id(current_user.id, params[:topic_id])
8
+ @monitorship.update_attribute :active, true
9
+ respond_to do |format|
10
+ format.html { redirect_to forum_topic_path(params[:forum_id], params[:topic_id]) }
11
+ format.js
12
+ end
13
+ end
14
+
15
+ def destroy
16
+ Monitorship.update_all ['active = ?', false], ['user_id = ? and topic_id = ?', current_user.id, params[:topic_id]]
17
+ respond_to do |format|
18
+ format.html { redirect_to forum_topic_path(params[:forum_id], params[:topic_id]) }
19
+ format.js
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,134 @@
1
+ class PostsController < BeastApplicationController
2
+ before_filter :find_post, :except => [:index, :create, :monitored, :search]
3
+ before_filter :login_required, :except => [:index, :monitored, :search, :show]
4
+ @@query_options = { :select => "#{Post.table_name}.*, #{Topic.table_name}.title as topic_title, #{Forum.table_name}.name as forum_name", :joins => "inner join #{Topic.table_name} on #{Post.table_name}.topic_id = #{Topic.table_name}.id inner join #{Forum.table_name} on #{Topic.table_name}.forum_id = #{Forum.table_name}.id" }
5
+
6
+ # @WBH@ TODO: This uses the caches_formatted_page method. In the main Beast project, this is implemented via a Config/Initializer file. Not
7
+ # sure what analogous place to put it in this plugin. It don't work in the init.rb
8
+ #caches_formatted_page :rss, :index, :monitored
9
+ cache_sweeper :posts_sweeper, :only => [:create, :update, :destroy]
10
+
11
+ def index
12
+ conditions = []
13
+ [:user_id, :forum_id, :topic_id].each { |attr| conditions << Post.send(:sanitize_sql, ["#{Post.table_name}.#{attr} = ?", params[attr]]) if params[attr] }
14
+ conditions = conditions.empty? ? nil : conditions.collect { |c| "(#{c})" }.join(' AND ')
15
+ @posts = Post.paginate @@query_options.merge(:conditions => conditions, :page => params[:page], :count => {:select => "#{Post.table_name}.id"}, :order => post_order)
16
+ @users = User.find(:all, :select => 'distinct *', :conditions => ['id in (?)', @posts.collect(&:user_id).uniq]).index_by(&:id)
17
+ render_posts_or_xml
18
+ end
19
+
20
+ def search
21
+ conditions = params[:q].blank? ? nil : Post.send(:sanitize_sql, ["LOWER(#{Post.table_name}.body) LIKE ?", "%#{params[:q]}%"])
22
+ @posts = Post.paginate @@query_options.merge(:conditions => conditions, :page => params[:page], :count => {:select => "#{Post.table_name}.id"}, :order => post_order)
23
+ @users = User.find(:all, :select => 'distinct *', :conditions => ['id in (?)', @posts.collect(&:user_id).uniq]).index_by(&:id)
24
+ render_posts_or_xml :index
25
+ end
26
+
27
+ def monitored
28
+ @user = User.find params[:user_id]
29
+ options = @@query_options.merge(:conditions => ["#{Monitorship.table_name}.user_id = ? and #{Post.table_name}.user_id != ? and #{Monitorship.table_name}.active = ?", params[:user_id], @user.id, true])
30
+ options[:order] = post_order
31
+ options[:joins] += " inner join #{Monitorship.table_name} on #{Monitorship.table_name}.topic_id = #{Topic.table_name}.id"
32
+ options[:page] = params[:page]
33
+ options[:count] = {:select => "#{Post.table_name}.id"}
34
+ @posts = Post.paginate options
35
+ render_posts_or_xml
36
+ end
37
+
38
+ def show
39
+ respond_to do |format|
40
+ format.html { redirect_to forum_topic_path(@post.forum_id, @post.topic_id) }
41
+ format.xml { render :xml => @post.to_xml }
42
+ end
43
+ end
44
+
45
+ def create
46
+ @topic = Topic.find_by_id_and_forum_id(params[:topic_id],params[:forum_id])
47
+ if @topic.locked?
48
+ respond_to do |format|
49
+ format.html do
50
+ flash[:notice] = 'This topic is locked.'[:locked_topic]
51
+ redirect_to(forum_topic_path(:forum_id => params[:forum_id], :id => params[:topic_id]))
52
+ end
53
+ format.xml do
54
+ render :text => 'This topic is locked.'[:locked_topic], :status => 400
55
+ end
56
+ end
57
+ return
58
+ end
59
+ @forum = @topic.forum
60
+ @post = @topic.posts.build(params[:post])
61
+ @post.user = current_user
62
+ @post.save!
63
+ respond_to do |format|
64
+ format.html do
65
+ redirect_to forum_topic_path(:forum_id => params[:forum_id], :id => params[:topic_id], :anchor => @post.dom_id, :page => params[:page] || '1')
66
+ end
67
+ format.xml { head :created, :location => post_url(:forum_id => params[:forum_id], :topic_id => params[:topic_id], :id => @post, :format => :xml) }
68
+ end
69
+ rescue ActiveRecord::RecordInvalid
70
+ flash[:bad_reply] = 'Please post something at least...'[:post_something_message]
71
+ respond_to do |format|
72
+ format.html do
73
+ redirect_to forum_topic_path(:forum_id => params[:forum_id], :id => params[:topic_id], :anchor => 'reply-form', :page => params[:page] || '1')
74
+ end
75
+ format.xml { render :xml => @post.errors.to_xml, :status => 400 }
76
+ end
77
+ end
78
+
79
+ def edit
80
+ respond_to do |format|
81
+ format.html
82
+ format.js
83
+ end
84
+ end
85
+
86
+ def update
87
+ @post.attributes = params[:post]
88
+ @post.save!
89
+ rescue ActiveRecord::RecordInvalid
90
+ flash[:bad_reply] = 'An error occurred'[:error_occured_message]
91
+ ensure
92
+ respond_to do |format|
93
+ format.html do
94
+ redirect_to forum_topic_path(:forum_id => params[:forum_id], :id => params[:topic_id], :anchor => @post.dom_id, :page => params[:page] || '1')
95
+ end
96
+ format.js
97
+ format.xml { head 200 }
98
+ end
99
+ end
100
+
101
+ def destroy
102
+ @post.destroy
103
+ flash[:notice] = "Post of '{title}' was deleted."[:post_deleted_message, @post.topic.title]
104
+ respond_to do |format|
105
+ format.html do
106
+ redirect_to(@post.topic.frozen? ?
107
+ forum_path(params[:forum_id]) :
108
+ forum_topic_path(:forum_id => params[:forum_id], :id => params[:topic_id], :page => params[:page]))
109
+ end
110
+ format.xml { head 200 }
111
+ end
112
+ end
113
+
114
+ protected
115
+ def authorized?
116
+ action_name == 'create' || @post.editable_by?(current_user)
117
+ end
118
+
119
+ def post_order
120
+ "#{Post.table_name}.created_at#{params[:forum_id] && params[:topic_id] ? nil : " desc"}"
121
+ end
122
+
123
+ def find_post
124
+ @post = Post.find_by_id_and_topic_id_and_forum_id(params[:id], params[:topic_id], params[:forum_id]) || raise(ActiveRecord::RecordNotFound)
125
+ end
126
+
127
+ def render_posts_or_xml(template_name = action_name)
128
+ respond_to do |format|
129
+ format.html { render :action => template_name }
130
+ format.rss { render :action => template_name, :layout => false }
131
+ format.xml { render :xml => @posts.to_xml }
132
+ end
133
+ end
134
+ end
@@ -0,0 +1,110 @@
1
+ class TopicsController < BeastApplicationController
2
+ before_filter :find_forum_and_topic, :except => :index
3
+ before_filter :login_required, :only => [:new, :create, :edit, :update, :destroy]
4
+
5
+ # @WBH@ TODO: This uses the caches_formatted_page method. In the main Beast project, this is implemented via a Config/Initializer file. Not
6
+ # sure what analogous place to put it in this plugin. It don't work in the init.rb
7
+ #caches_formatted_page :rss, :show
8
+ cache_sweeper :posts_sweeper, :only => [:create, :update, :destroy]
9
+
10
+ def index
11
+ respond_to do |format|
12
+ format.html { redirect_to forum_path(params[:forum_id]) }
13
+ format.xml do
14
+ @topics = Topic.paginate_by_forum_id(params[:forum_id], :order => 'sticky desc, replied_at desc', :page => params[:page])
15
+ render :xml => @topics.to_xml
16
+ end
17
+ end
18
+ end
19
+
20
+ def new
21
+ @topic = Topic.new
22
+ end
23
+
24
+ def show
25
+ respond_to do |format|
26
+ format.html do
27
+ # see notes in application.rb on how this works
28
+ update_last_seen_at
29
+ # keep track of when we last viewed this topic for activity indicators
30
+ (session[:topics] ||= {})[@topic.id] = Time.now.utc if logged_in?
31
+ # authors of topics don't get counted towards total hits
32
+ @topic.hit! unless logged_in? and @topic.user == current_user
33
+ @posts = @topic.posts.paginate :page => params[:page]
34
+ User.find(:all, :conditions => ['id IN (?)', @posts.collect { |p| p.user_id }.uniq]) unless @posts.blank?
35
+ @post = Post.new
36
+ end
37
+ format.xml do
38
+ render :xml => @topic.to_xml
39
+ end
40
+ format.rss do
41
+ @posts = @topic.posts.find(:all, :order => 'created_at desc', :limit => 25)
42
+ render :action => 'show', :layout => false
43
+ end
44
+ end
45
+ end
46
+
47
+ def create
48
+ topic_saved, post_saved = false, false
49
+ # this is icky - move the topic/first post workings into the topic model?
50
+ Topic.transaction do
51
+ @topic = @forum.topics.build(params[:topic])
52
+ assign_protected
53
+ @post = @topic.posts.build(params[:topic])
54
+ @post.topic = @topic
55
+ @post.user = current_user
56
+ # only save topic if post is valid so in the view topic will be a new record if there was an error
57
+ @topic.body = @post.body # incase save fails and we go back to the form
58
+ topic_saved = @topic.save if @post.valid?
59
+ post_saved = @post.save
60
+ end
61
+
62
+ if topic_saved && post_saved
63
+ respond_to do |format|
64
+ format.html { redirect_to forum_topic_path(@forum, @topic) }
65
+ format.xml { head :created, :location => topic_url(:forum_id => @forum, :id => @topic, :format => :xml) }
66
+ end
67
+ else
68
+ render :action => "new"
69
+ end
70
+ end
71
+
72
+ def update
73
+ @topic.attributes = params[:topic]
74
+ assign_protected
75
+ @topic.save!
76
+ respond_to do |format|
77
+ format.html { redirect_to forum_topic_path(@forum, @topic) }
78
+ format.xml { head 200 }
79
+ end
80
+ end
81
+
82
+ def destroy
83
+ @topic.destroy
84
+ flash[:notice] = "Topic '{title}' was deleted."[:topic_deleted_message, @topic.title]
85
+ respond_to do |format|
86
+ format.html { redirect_to forum_path(@forum) }
87
+ format.xml { head 200 }
88
+ end
89
+ end
90
+
91
+ protected
92
+ def assign_protected
93
+ @topic.user = current_user if @topic.new_record?
94
+ # admins and moderators can sticky and lock topics
95
+ return unless admin? or current_user.moderator_of?(@topic.forum)
96
+ @topic.sticky, @topic.locked = params[:topic][:sticky], params[:topic][:locked]
97
+ # only admins can move
98
+ return unless admin?
99
+ @topic.forum_id = params[:topic][:forum_id] if params[:topic][:forum_id]
100
+ end
101
+
102
+ def find_forum_and_topic
103
+ @forum = Forum.find(params[:forum_id])
104
+ @topic = @forum.topics.find(params[:id]) if params[:id]
105
+ end
106
+
107
+ def authorized?
108
+ %w(new create).include?(action_name) || @topic.editable_by?(current_user)
109
+ end
110
+ end
@@ -0,0 +1,13 @@
1
+ module CountHelper
2
+ def posts_count(n)
3
+ t(:posts_count, :count => n, :n => number_with_delimiter(n))
4
+ end
5
+
6
+ def posts_count_found(n)
7
+ t(:posts_count_found, :count => n, :n => number_with_delimiter(n))
8
+ end
9
+
10
+ def voices_count(n)
11
+ t(:voices_count, :count => n, :n => number_with_delimiter(n))
12
+ end
13
+ end