Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

merge latest master into gallery

  • Loading branch information...
commit 68c5e378e492551f3c828900ffd8170e27f20e85 2 parents d3483a2 + 91fbb0d
Jeff Reifman authored
Showing with 6,998 additions and 2,766 deletions.
  1. +3 −0  .gitignore
  2. +2 −0  Rakefile
  3. +2 −1  app/controllers/admin/comments_controller.rb
  4. +2 −0  app/controllers/admin/contents_controller.rb
  5. +5 −2 app/controllers/admin/dashboard_messages_controller.rb
  6. +16 −4 app/controllers/admin/events_controller.rb
  7. +11 −9 app/controllers/admin/featured_items_controller.rb
  8. +2 −2 app/controllers/admin/feeds_controller.rb
  9. +92 −0 app/controllers/admin/images_controller.rb
  10. +85 −0 app/controllers/admin/metadata/ad_layouts_controller.rb
  11. +17 −2 app/controllers/admin/metadata/settings_controller.rb
  12. +1 −1  app/controllers/admin/metadata/skip_images_controller.rb
  13. +94 −0 app/controllers/admin/metadata/sponsor_zones_controller.rb
  14. +1 −1  app/controllers/admin/newswires_controller.rb
  15. +88 −0 app/controllers/admin/prediction_groups_controller.rb
  16. +87 −0 app/controllers/admin/prediction_guesses_controller.rb
  17. +93 −0 app/controllers/admin/prediction_questions_controller.rb
  18. +2 −0  app/controllers/admin/resources_controller.rb
  19. +3 −2 app/controllers/admin/translations_controller.rb
  20. +25 −5 app/controllers/admin/widgets_controller.rb
  21. +8 −0 app/controllers/admin_controller.rb
  22. +123 −36 app/controllers/application_controller.rb
  23. +73 −21 app/controllers/articles_controller.rb
  24. +10 −1 app/controllers/comments_controller.rb
  25. +14 −8 app/controllers/events_controller.rb
  26. +4 −1 app/controllers/forums_controller.rb
  27. +20 −7 app/controllers/home_controller.rb
  28. +3 −1 app/controllers/idea_boards_controller.rb
  29. +9 −4 app/controllers/ideas_controller.rb
  30. +2 −7 app/controllers/newswires_controller.rb
  31. +35 −0 app/controllers/oauth_controller.rb
  32. +33 −0 app/controllers/prediction_groups_controller.rb
  33. +27 −0 app/controllers/prediction_guesses_controller.rb
  34. +3 −0  app/controllers/prediction_questions_controller.rb
  35. +2 −0  app/controllers/prediction_scores_controller.rb
  36. +52 −0 app/controllers/predictions_controller.rb
  37. +9 −7 app/controllers/questions_controller.rb
  38. +3 −1 app/controllers/resource_sections_controller.rb
  39. +9 −4 app/controllers/resources_controller.rb
  40. +7 −3 app/controllers/sessions_controller.rb
  41. +34 −15 app/controllers/stories_controller.rb
  42. +3 −0  app/controllers/topics_controller.rb
  43. +26 −3 app/controllers/users_controller.rb
  44. +7 −6 app/controllers/votes_controller.rb
  45. +105 −0 app/controllers/widgets_controller.rb
  46. +9 −2 app/helpers/admin_helper.rb
  47. +88 −19 app/helpers/application_helper.rb
  48. +5 −6 app/helpers/facebook_helper.rb
  49. +2 −0  app/helpers/prediction_groups_helper.rb
  50. +2 −0  app/helpers/prediction_guesses_helper.rb
  51. +2 −0  app/helpers/prediction_questions_helper.rb
  52. +2 −0  app/helpers/prediction_scores_helper.rb
  53. +2 −0  app/helpers/widgets_helper.rb
  54. +29 −8 app/models/article.rb
  55. +5 −0 app/models/audio.rb
  56. +1 −1  app/models/chirp.rb
  57. +4 −0 app/models/comment.rb
  58. +22 −7 app/models/content.rb
  59. +26 −2 app/models/event.rb
  60. +1 −0  app/models/feed.rb
  61. +5 −0 app/models/flag_observer.rb
  62. +2 −0  app/models/forum.rb
  63. +1 −0  app/models/idea_board.rb
  64. +6 −5 app/models/image.rb
  65. +34 −0 app/models/metadata/ad_layout.rb
  66. +4 −0 app/models/metadata/setting.rb
  67. +14 −3 app/models/metadata/skip_image.rb
  68. +29 −0 app/models/metadata/sponsor_zone.rb
  69. +9 −2 app/models/newswire.rb
  70. +53 −9 app/models/notifier.rb
  71. +3 −1 app/models/pfeeds/user_triggered_answer.rb
  72. +2 −0  app/models/pfeeds/user_triggered_article.rb
  73. +3 −1 app/models/pfeeds/user_triggered_chirp.rb
  74. +1 −0  app/models/pfeeds/user_triggered_comment.rb
  75. +2 −0  app/models/pfeeds/user_triggered_dashboard_message.rb
  76. +2 −0  app/models/pfeeds/user_triggered_event.rb
  77. +2 −0  app/models/pfeeds/user_triggered_idea.rb
  78. +2 −0  app/models/pfeeds/user_triggered_question.rb
  79. +2 −0  app/models/pfeeds/user_triggered_resource.rb
  80. +2 −0  app/models/pfeeds/user_triggered_story.rb
  81. +2 −0  app/models/pfeeds/user_triggered_topic.rb
  82. +44 −0 app/models/prediction_group.rb
  83. +7 −0 app/models/prediction_guess.rb
  84. +23 −0 app/models/prediction_question.rb
  85. +5 −0 app/models/prediction_score.rb
  86. +4 −0 app/models/question.rb
  87. +3 −0  app/models/resource_section.rb
  88. +2 −2 app/models/score.rb
  89. +3 −0  app/models/source.rb
  90. +40 −10 app/models/user.rb
  91. +1 −0  app/models/video.rb
  92. +4 −0 app/models/vote.rb
  93. +4 −0 app/models/widget.rb
  94. +42 −0 app/stylesheets/addthis.sass
  95. +127 −0 app/stylesheets/admin.sass
  96. +0 −43 app/stylesheets/application.sass
  97. +623 −411 app/stylesheets/default.sass
  98. +266 −67 app/stylesheets/fb_grid.sass
  99. +115 −0 app/stylesheets/flowplayer_tabs.sass
  100. +99 −167 app/stylesheets/formtastic.sass
  101. +239 −0 app/stylesheets/formtastic_changes.sass
  102. +253 −53 app/stylesheets/grid.sass
  103. +69 −0 app/stylesheets/scrollable.sass
  104. +60 −0 app/stylesheets/scrollable_fb.sass
  105. +22 −8 app/stylesheets/skin.sass
  106. +0 −3  app/sweepers/announcement_sweeper.rb
  107. +0 −2  app/sweepers/card_sweeper.rb
  108. +1 −3 app/sweepers/event_sweeper.rb
  109. +6 −6 app/sweepers/forum_sweeper.rb
  110. +1 −3 app/sweepers/idea_sweeper.rb
  111. +1 −3 app/sweepers/newswire_sweeper.rb
  112. +71 −0 app/sweepers/prediction_sweeper.rb
  113. +4 −49 app/sweepers/qanda_sweeper.rb
  114. +1 −5 app/sweepers/resource_sweeper.rb
  115. +6 −9 app/sweepers/story_sweeper.rb
  116. +0 −1  app/sweepers/user_sweeper.rb
  117. +6 −0 app/sweepers/vote_sweeper.rb
  118. +9 −2 app/sweepers/widget_sweeper.rb
  119. +26 −0 app/sweepers/wrapper_sweeper.rb
  120. +10 −4 app/views/admin/events/import_zvents.html.haml
  121. +50 −114 app/views/admin/featured_items/index.html.haml
  122. +120 −0 app/views/admin/featured_items/load_template.html.haml
  123. +56 −0 app/views/admin/images/index.html.haml
  124. +2 −3 app/views/admin/index.html.haml
  125. +8 −0 app/views/admin/translations/index.html.erb
  126. +15 −17 app/views/admin/widgets/index.js.erb
  127. +254 −0 app/views/admin/widgets/new_widgets.html.haml
  128. +10 −1 app/views/articles/_article_form.html.haml
  129. +29 −0 app/views/articles/drafts.html.haml
  130. +166 −0 app/views/articles/edit.html.haml
  131. +6 −1 app/views/articles/index.html.haml
  132. +99 −14 app/views/articles/new.html.haml
  133. +77 −0 app/views/articles/old_edit.html.haml
  134. +77 −0 app/views/articles/old_new.html.haml
  135. +0 −8 app/views/articles/tags.html.haml
  136. +4 −1 app/views/articles/user_index.html.haml
  137. +9 −9 app/views/cards/my_received.html.haml
  138. +11 −11 app/views/cards/my_sent.html.haml
  139. +11 −5 app/views/events/import_facebook.html.haml
  140. +7 −1 app/views/events/index.html.haml
  141. +8 −8 app/views/events/new.html.haml
  142. +33 −19 app/views/events/show.html.haml
  143. +7 −0 app/views/forums/index.html.haml
  144. +12 −1 app/views/forums/show.html.haml
  145. +4 −0 app/views/home/external_page_header.html.haml
  146. +21 −18 app/views/home/index.html.haml
  147. +21 −0 app/views/home/preview_widgets.html.haml
  148. +15 −16 app/views/home/test_design.html.haml
  149. +5 −5 app/views/home/test_widgets.html.haml
  150. +6 −2 app/views/idea_boards/index.html.haml
  151. +14 −10 app/views/idea_boards/show.html.haml
  152. +8 −2 app/views/ideas/index.html.haml
  153. +4 −1 app/views/ideas/my_ideas.html.haml
  154. +74 −20 app/views/ideas/new.html.haml
  155. +21 −12 app/views/ideas/show.html.haml
  156. +53 −9 app/views/layouts/application.html.haml
  157. +66 −0 app/views/layouts/external_page.html.haml
  158. +25 −22 app/views/layouts/new_admin.html.haml
  159. +2 −2 app/views/layouts/overlay.html.haml
  160. +38 −0 app/views/layouts/widgets.html.haml
  161. +2 −2 app/views/mobile/stories/new.html.haml
  162. +6 −2 app/views/newswires/feed_index.html.haml
  163. +6 −2 app/views/newswires/index.html.haml
  164. +0 −7 app/views/notifier/activity_message.haml
  165. +7 −0 app/views/notifier/chirp_message.html.haml
  166. +8 −0 app/views/notifier/comment_message.html.haml
  167. +9 −0 app/views/notifier/dashboard_message_message.haml
  168. +3 −0  app/views/notifier/flag_message.haml
  169. +2 −1  app/views/pfeeds/_pfeed.html.haml
  170. +1 −1  app/views/pfeeds/_pfeed_item.html.erb
  171. +3 −3 app/views/pfeeds/_pfeed_list.html.haml
  172. +2 −2 app/views/pfeeds/_user_triggered_answer.html.haml
  173. +2 −2 app/views/pfeeds/_user_triggered_article.html.haml
  174. +3 −3 app/views/pfeeds/_user_triggered_chirp.html.haml
  175. +3 −3 app/views/pfeeds/_user_triggered_comment.html.haml
  176. +2 −2 app/views/pfeeds/_user_triggered_dashboard_message.html.haml
  177. +2 −2 app/views/pfeeds/_user_triggered_event.html.haml
  178. +2 −2 app/views/pfeeds/_user_triggered_idea.html.haml
  179. +2 −2 app/views/pfeeds/_user_triggered_question.html.haml
  180. +2 −2 app/views/pfeeds/_user_triggered_resource.html.haml
  181. +2 −2 app/views/pfeeds/_user_triggered_story.html.haml
  182. +2 −2 app/views/pfeeds/_user_triggered_topic.html.haml
  183. +17 −0 app/views/prediction_groups/_prediction_group_list.html.haml
  184. +22 −0 app/views/prediction_groups/index.html.haml
  185. +66 −0 app/views/prediction_groups/show.html.haml
  186. +18 −0 app/views/predictions/_top_scores_list.html.haml
  187. +23 −0 app/views/predictions/index.html.haml
  188. +26 −0 app/views/predictions/my_predictions.html.haml
  189. +13 −0 app/views/predictions/scores.html.haml
  190. +38 −0 app/views/predictions/show_question.html.haml
  191. +8 −8 app/views/questions/index.fbjs.haml
  192. +26 −19 app/views/questions/index.html.haml
  193. +8 −8 app/views/questions/index.json.haml
  194. +16 −13 app/views/questions/my_questions.html.haml
  195. +3 −3 app/views/questions/new.html.haml
  196. +25 −17 app/views/questions/show.html.haml
  197. +3 −2 app/views/related_items/new.html.haml
  198. +5 −0 app/views/reminders/_invite_friends.html.haml
  199. +13 −11 app/views/resource_sections/show.html.haml
  200. +7 −1 app/views/resources/index.html.haml
  201. +90 −24 app/views/resources/new.html.haml
  202. +21 −12 app/views/resources/show.html.haml
  203. +12 −8 app/views/sessions/new.html.erb
  204. +38 −0 app/views/shared/_add_this.html.haml
  205. +8 −6 app/views/shared/_ads_banner.html.haml
  206. +16 −15 app/views/shared/_announcements.html.haml
  207. +1 −15 app/views/shared/_answer.html.haml
  208. +6 −19 app/views/shared/_articles.html.haml
  209. +14 −13 app/views/shared/_articles.json.haml
  210. +50 −0 app/views/shared/_auto_feature.html.haml
  211. +0 −14 app/views/shared/_bookmarklet_panel.fbml.haml
  212. +5 −5 app/views/shared/_comment.html.haml
  213. +3 −2 app/views/shared/_comment_form.html.haml
  214. +2 −2 app/views/shared/_comments.html.haml
  215. +15 −0 app/views/shared/_comments.json.haml
  216. +1 −1  app/views/shared/_custom_widget.html.haml
  217. +21 −8 app/views/shared/_events.html.haml
  218. +3 −3 app/views/shared/_events.json.haml
  219. +77 −173 app/views/shared/_featured_items.html.haml
  220. +1 −1  app/views/shared/_flag_form.html.haml
  221. +52 −54 app/views/shared/_footer.html.haml
  222. +35 −36 app/views/shared/_forums.html.haml
  223. +2 −4 app/views/shared/_header.html.haml
  224. +0 −13 app/views/shared/_hot_topics.html.haml
  225. +6 −6 app/views/shared/_idea_boards.html.haml
  226. +17 −16 app/views/shared/_ideas.html.haml
  227. +8 −8 app/views/shared/_ideas.json.haml
  228. +1 −1  app/views/shared/_index_footer.html.haml
  229. +2 −2 app/views/shared/_item_footer.html.haml
  230. +5 −4 app/views/shared/_moderate_form.html.haml
  231. +11 −11 app/views/shared/_my_ideas.html.haml
  232. +5 −14 app/views/shared/_newswires.html.haml
  233. +11 −2 app/views/shared/_page_tabs.html.haml
  234. +23 −0 app/views/shared/_prediction_question.html.haml
  235. +6 −6 app/views/shared/_resource_sections.html.haml
  236. +18 −17 app/views/shared/_resources.html.haml
  237. +8 −8 app/views/shared/_resources.json.haml
  238. +25 −21 app/views/shared/_stories.html.haml
  239. +17 −14 app/views/shared/_stories.json.haml
  240. +41 −0 app/views/shared/_stories_short.html.haml
  241. +0 −354 app/views/shared/_test_layout_a.html.haml
  242. +0 −103 app/views/shared/_test_panels.html.haml
  243. +0 −34 app/views/shared/_test_users.html.haml
  244. +6 −4 app/views/shared/_topics.html.haml
  245. +4 −14 app/views/shared/_users.html.haml
  246. +3 −3 app/views/shared/_users.json.haml
  247. +18 −4 app/views/shared/ads/_helios_alt4_ads.html.haml
  248. +40 −0 app/views/shared/ads/_openx_ads.html.haml
  249. +7 −0 app/views/shared/ads/_sponsor_zone_wrapper.html.haml
  250. +34 −0 app/views/shared/external/_outbrain_widget.html.erb
  251. +5 −0 app/views/shared/external/_outbrain_wrapper.html.haml
  252. +6 −0 app/views/shared/external/_traffic_spaces_widget.html.haml
  253. +12 −0 app/views/shared/featured_items/_panel3.html.haml
  254. +21 −0 app/views/shared/featured_items/_panel3_subheads.html.haml
  255. +16 −0 app/views/shared/featured_items/_panel4.html.haml
  256. +11 −0 app/views/shared/featured_items/_panel4b.html.haml
  257. +12 −0 app/views/shared/featured_items/_panel4c.html.haml
  258. +11 −0 app/views/shared/featured_items/_panel5.html.haml
  259. +14 −0 app/views/shared/featured_items/_panel_af_sidebar.html.haml
  260. +10 −0 app/views/shared/featured_items/_panel_wide.html.haml
  261. +2 −0  app/views/shared/featured_items/_panelbar.html.haml
  262. +16 −0 app/views/shared/featured_items/_video.html.haml
  263. +7 −7 app/views/shared/feed_items/_article.html.haml
  264. +3 −3 app/views/shared/feed_items/_comment.html.haml
  265. +7 −7 app/views/shared/feed_items/_story.html.haml
  266. +2 −2 app/views/shared/feed_items/_vote.html.haml
  267. +1 −1  app/views/shared/forms/_flag_dropdown.html.haml
  268. +7 −0 app/views/shared/forms/_image_simple.html.haml
  269. +13 −0 app/views/shared/forms/_images_simple.html.haml
  270. +37 −28 app/views/shared/forms/_media_items.html.haml
  271. +34 −0 app/views/shared/forms/_media_items_simple.html.haml
  272. +1 −1  app/views/shared/forms/_related_item_form.html.haml
  273. +1 −1  app/views/shared/forms/_wall_postable.html.haml
  274. +10 −4 app/views/shared/items/_answer.html.haml
  275. +23 −14 app/views/shared/items/_article.html.haml
  276. +5 −5 app/views/shared/items/_comment.html.haml
  277. +7 −7 app/views/shared/items/_content.html.haml
  278. +6 −6 app/views/shared/items/_event.html.haml
  279. +19 −0 app/views/shared/items/_featured_comment.html.haml
  280. +31 −0 app/views/shared/items/_featured_event.html.haml
  281. +28 −0 app/views/shared/items/_featured_generic.html.haml
  282. +19 −0 app/views/shared/items/_featured_topic.html.haml
  283. +7 −7 app/views/shared/items/_idea.html.haml
  284. +4 −0 app/views/shared/items/_micro_generic.html.haml
  285. +8 −10 app/views/shared/items/_newswire.html.haml
  286. +14 −0 app/views/shared/items/_prediction_group.html.haml
  287. +11 −0 app/views/shared/items/_prediction_question.html.haml
  288. +9 −0 app/views/shared/items/_prediction_user_score.html.haml
  289. +8 −8 app/views/shared/items/_question.html.haml
  290. +8 −8 app/views/shared/items/_resource.html.haml
  291. +7 −6 app/views/shared/items/_small_answer.html.haml
  292. +7 −6 app/views/shared/items/_small_article.html.haml
  293. +5 −5 app/views/shared/items/_small_comment.html.haml
  294. +5 −5 app/views/shared/items/_small_content.html.haml
  295. +4 −4 app/views/shared/items/_small_event.html.haml
  296. +8 −0 app/views/shared/items/_small_generic.html.haml
  297. +5 −5 app/views/shared/items/_small_idea.html.haml
  298. +7 −7 app/views/shared/items/_small_newswire.html.haml
  299. +7 −6 app/views/shared/items/_small_question.html.haml
  300. +3 −2 app/views/shared/items/_small_resource.html.haml
Sorry, we could not display the entire diff because too many files (781) changed.
View
3  .gitignore
@@ -1,5 +1,6 @@
!*.gitignore
public/maintenance.*
+public/sitemap*
public/uploads
public/cache/*
!public/cache/.gitignore
@@ -21,7 +22,9 @@ config/application.god
config/compass.config
config/compass.rb
!config/widgets.yml
+!config/resque_schedule.yml
!config/cucumber.yml
+!config/asset_packages.yml
config/deploy/*.rb
!config/deploy/sample.rb
*.pid
View
2  Rakefile
@@ -9,6 +9,8 @@ require 'rake/rdoctask'
require 'tasks/rails'
+require 'resque_scheduler/tasks'
+
begin
require 'sitemap_generator/tasks'
rescue Exception => e
View
3  app/controllers/admin/comments_controller.rb
@@ -4,7 +4,8 @@ def index
render :partial => 'shared/admin/index_page', :layout => 'new_admin', :locals => {
:items => Comment.paginate(:page => params[:page], :per_page => 20, :order => "created_at desc"),
:model => Comment,
- :fields => [:comments, :postedByName, :created_at],
+ :fields => [:comments, :user_id, :created_at],
+ :associations => { :belongs_to => { :user => :user_id } },
:paginate => true
}
end
View
2  app/controllers/admin/contents_controller.rb
@@ -1,5 +1,7 @@
class Admin::ContentsController < AdminController
+ cache_sweeper :story_sweeper, :only => [:create, :update, :destroy]
+
def index
render :partial => 'shared/admin/index_page', :layout => 'new_admin', :locals => {
:items => Content.paginate(:page => params[:page], :per_page => 20, :order => "created_at desc"),
View
7 app/controllers/admin/dashboard_messages_controller.rb
@@ -1,7 +1,6 @@
class Admin::DashboardMessagesController < AdminController
def index
- current_facebook_user.dashboard_increment_count
render :partial => 'shared/admin/index_page', :layout => 'new_admin', :locals => {
:items => DashboardMessage.paginate(:page => params[:page], :per_page => 20, :order => "created_at desc"),
:model => DashboardMessage,
@@ -90,9 +89,13 @@ def clear_global
@dashboardMessage.each do |dashboardMessage|
dashboardMessage.set_draft! dashboardMessage.news_id
end
+ end
+ User.find_in_batches(:batch_size => 100) do |users|
+ Facebooker::User.multi_clear_news users.inject({}) {|arr,u| arr[u.fb_user_id.to_s] = []; arr}
+ Facebooker::User.dashboard_multi_set_count users.inject({}) {|arr,u| arr[u.fb_user_id.to_s] = 0; arr}
end
-
+
# if result =~ /^[0-9]+$/
flash[:success] = "Successfully cleared the message(s)"
redirect_to admin_dashboard_messages_path
View
20 app/controllers/admin/events_controller.rb
@@ -42,15 +42,27 @@ def create
def import_zvents
if request.post?
- zvent =Zvent::Session.new(APP_CONFIG['zvent_api_key'])
- zevents = zvent.find_events_by_date('next 30 days', :where=>APP_CONFIG['zvent_location'])
+ zvent = Zvent::Session.new(APP_CONFIG['zvent_api_key'])
+ zevents = zvent.find_events_by_date('next 30 days', :where => APP_CONFIG['zvent_location'], :limit => 50)
+ count = 0
zevents[:events].each do |event|
+ if params[:commit] == "Import Selected Events"
+ next unless params[:events].present? and params[:events].any?
+ next unless params[:events].include? event.id.to_s
+ end
Event.create_from_zvent_event(event,current_user)
+ count += 1
+ end
+ if count > 0
+ flash[:success] = "Successfully added #{count} events!"
+ else
+ flash[:error] = "Could not add any events, please try again"
end
- redirect_to [:admin]
+ EventSweeper.expire_event_all Event.last
+ redirect_to admin_events_path
else
zvent =Zvent::Session.new(APP_CONFIG['zvent_api_key'])
- zevents = zvent.find_events_by_date('next 30 days',:where=>APP_CONFIG['zvent_location'])
+ zevents = zvent.find_events_by_date('next 30 days', :where => APP_CONFIG['zvent_location'], :limit => 50)
@events = zevents[:events]
end
end
View
20 app/controllers/admin/featured_items_controller.rb
@@ -15,15 +15,15 @@ def load_template
def load_items
case params[:id]
when Content.name.tableize
- @items = Content.paginate :page => params[:page], :per_page => 12, :order => "created_at desc"
+ @items = Content.active.paginate :page => params[:page], :per_page => 12, :order => "created_at desc"
when Idea.name.tableize
- @items = Idea.paginate :page => params[:page], :per_page => 12, :order => "created_at desc"
+ @items = Idea.active.paginate :page => params[:page], :per_page => 12, :order => "created_at desc"
when Event.name.tableize
- @items = Event.paginate :page => params[:page], :per_page => 12, :order => "created_at desc"
+ @items = Event.active.paginate :page => params[:page], :per_page => 12, :order => "created_at desc"
when Resource.name.tableize
- @items = Resource.paginate :page => params[:page], :per_page => 12, :order => "created_at desc"
+ @items = Resource.active.paginate :page => params[:page], :per_page => 12, :order => "created_at desc"
when Question.name.tableize
- @items = Question.paginate :page => params[:page], :per_page => 12, :order => "created_at desc"
+ @items = Question.active.paginate :page => params[:page], :per_page => 12, :order => "created_at desc"
else
return false
end
@@ -38,15 +38,17 @@ def save
@section2 = @template_name.children.create({:name => "section2", :featured_type => "section2"})
@section3 = @template_name.children.create({:name => "section3", :featured_type => "section3"})
@section4 = @template_name.children.create({:name => "section4", :featured_type => "section4"})
- ['section1', 'section2','section3','section4'].each do |section|
+ @section5 = @template_name.children.create({:name => "section5", :featured_type => "section5"})
+ @section6 = @template_name.children.create({:name => "section6", :featured_type => "section6"})
+ ['section1', 'section2','section3','section4','section5','section6'].each do |section|
section_data = instance_variable_get("@#{section}")
['primary', 'secondary1', 'secondary2'].each do |box|
item_id = data[section][box]
next unless item = get_item(item_id)
item = get_item item_id
section_data.children.create({:name => "item_#{item_id}", :featured_type => "featured_item", :featurable => item})
- #tweet item
- tweet(item) if Metadata::Setting.find_setting('tweet_featured_items').value == 'true'
+ #@tweet_features = Metadata::Setting.find_setting('tweet_featured_items')
+ #tweet(item) if (@tweet_features.present? and @tweet_features.value)
end
end
@@ -82,7 +84,7 @@ def set_current_tab
@current_tab = 'featured-items';
end
- def tweet
+ def tweet item
return if item.tweeted_item.present?
if Metadata::Setting.find_setting('bitly_username').value
View
4 app/controllers/admin/feeds_controller.rb
@@ -2,7 +2,7 @@ class Admin::FeedsController < AdminController
def index
render :partial => 'shared/admin/index_page', :layout => 'new_admin', :locals => {
- :items => Feed.paginate(:page => params[:page], :per_page => 20, :order => "created_at desc"),
+ :items => Feed.active.paginate(:page => params[:page], :per_page => 20, :order => "created_at desc"),
:model => Feed,
:fields => [:title, :url, :rss, :created_at, :user_id],
:associations => { :belongs_to => { :user => :user_id } },
@@ -52,7 +52,7 @@ def create
def destroy
@feed = Feed.find(params[:id])
- @feed.destroy
+ @feed.update_attribute(:deleted_at, Time.now)
redirect_to admin_feeds_path
end
View
92 app/controllers/admin/images_controller.rb
@@ -0,0 +1,92 @@
+class Admin::ImagesController < AdminController
+
+ def index
+ @images = Image.paginate(:page => params[:page], :per_page => 20, :order => "created_at desc")
+ end
+
+ def new
+ render_new
+ end
+
+ def edit
+ @image = Image.find(params[:id])
+
+ render_edit @image
+ end
+
+ def update
+ @image = Image.find(params[:id])
+ if @image.update_attributes(params[:image])
+ flash[:success] = "Successfully updated your Image."
+ redirect_to [:admin, @image]
+ else
+ flash[:error] = "Could not update your Image as requested. Please try again."
+ render_edit @image
+ end
+ end
+
+ def show
+ render :partial => 'shared/admin/show_page', :layout => 'new_admin', :locals => {
+ :item => Image.find(params[:id]),
+ :model => Image,
+ :fields => [:title, :url, :rss, :created_at],
+ }
+ end
+
+ def create
+ @image = Image.new(params[:image])
+ if @image.save
+ flash[:success] = "Successfully created your new Image!"
+ redirect_to [:admin, @image]
+ else
+ flash[:error] = "Could not create your Image, please try again"
+ render_new @image
+ end
+ end
+
+ def destroy
+ @ignore = params[:ignore].present? and params[:ignore]
+ @image = Image.find(params[:id])
+ @imageable = @image.imageable
+ if @ignore and @image.remote_image_url
+ Metadata::SkipImage.create({:image_url => @image.remote_image_url})
+ end
+ if @image.destroy
+ expire_cache @imageable
+ WidgetSweeper.expire_features
+ end
+
+ respond_to do |format|
+ format.html { redirect_to admin_images_path }
+ format.json { render :json => {}, :status => 200 }
+ end
+ end
+
+ private
+
+ def render_new image = nil
+ image ||= Image.new
+
+ render :partial => 'shared/admin/new_page', :layout => 'new_admin', :locals => {
+ :item => image,
+ :model => Image,
+ :fields => [:title, :url, :rss, :user_id],
+ :associations => { :belongs_to => { :user => :user_id } }
+ }
+ end
+
+ def render_edit image
+ render :partial => 'shared/admin/edit_page', :layout => 'new_admin', :locals => {
+ :item => image,
+ :model => Image,
+ :fields => [:title, :url, :rss, :user_id],
+ :associations => { :belongs_to => { :user => :user_id } }
+ }
+ end
+
+
+ def set_current_tab
+ @current_tab = 'images';
+ end
+
+end
View
85 app/controllers/admin/metadata/ad_layouts_controller.rb
@@ -0,0 +1,85 @@
+class Admin::Metadata::AdLayoutsController < Admin::MetadataController
+
+ def index
+ render :partial => 'shared/admin/index_page', :layout => 'new_admin', :locals => {
+ :items => Metadata::AdLayout.paginate(:page => params[:page], :per_page => 25, :order => "created_at desc"),
+ :model => Metadata::AdLayout,
+ :fields => [:ad_layout_name, :ad_layout_layout],
+ :paginate => true
+ }
+ end
+
+ def new
+ render_new
+ end
+
+ def edit
+ @ad_layout = Metadata::AdLayout.find(params[:id])
+
+ render_edit @ad_layout
+ end
+
+ def update
+ @ad_layout = Metadata::AdLayout.find(params[:id])
+ if @ad_layout.update_attributes(params[:metadata_ad_layout])
+ flash[:success] = "Successfully updated your ad layout."
+ redirect_to admin_metadata_ad_layout_path(@ad_layout)
+ else
+ flash[:error] = "Could not update your ad layout as requested. Please try again."
+ render_edit @ad_layout
+ end
+ end
+
+ def show
+ render :partial => 'shared/admin/show_page', :layout => 'new_admin', :locals => {
+ :item => Metadata::AdLayout.find(params[:id]),
+ :model => Metadata::AdLayout,
+ :fields => [:ad_layout_name, :ad_layout_layout, :created_at],
+ }
+ end
+
+ def create
+ @ad_layout = Metadata::AdLayout.new(params[:metadata_ad_layout])
+ if @ad_layout.save
+ flash[:success] = "Successfully created your ad layout."
+ redirect_to admin_metadata_ad_layout_path(@ad_layout)
+ else
+ flash[:error] = "Could not create your ad layout as requested. Please try again."
+ render_new @ad_layout
+ end
+ end
+
+ def destroy
+ @ad_layout = Metadata::AdLayout.find(params[:id])
+ @ad_layout.destroy
+
+ redirect_to admin_metadata_ad_layouts_path
+ end
+
+ private
+
+ def render_new ad_layout = nil
+ ad_layout ||= Metadata::AdLayout.new
+
+ render :partial => 'shared/admin/new_page', :layout => 'new_admin', :locals => {
+ :item => ad_layout,
+ :model => Metadata::AdLayout,
+ :fields => [:ad_layout_name, :ad_layout_layout]
+ }
+ end
+
+ def render_edit ad_layout
+ ad_layout ||= Metadata::AdLayout.new
+
+ render :partial => 'shared/admin/edit_page', :layout => 'new_admin', :locals => {
+ :item => ad_layout,
+ :model => Metadata::AdLayout,
+ :fields => [:ad_layout_name, :ad_layout_layout]
+ }
+ end
+
+ def set_current_tab
+ @current_tab = 'ad_layouts';
+ end
+
+end
View
19 app/controllers/admin/metadata/settings_controller.rb
@@ -2,7 +2,7 @@ class Admin::Metadata::SettingsController < Admin::MetadataController
def index
render :partial => 'shared/admin/index_page', :layout => 'new_admin', :locals => {
- :items => Metadata::Setting.paginate(:page => params[:page], :per_page => 30, :order => "created_at desc"),
+ :items => Metadata::Setting.paginate(:page => params[:page], :per_page => 30, :order => "key_sub_type asc, key_name asc"),
:model => Metadata::Setting,
:fields => [:setting_name, :setting_sub_type_name, :setting_value],
:paginate => true
@@ -27,6 +27,12 @@ def update
if @setting.key_name.include? "welcome_"
WidgetSweeper.expire_item "welcome_panel"
end
+ if @setting.key_name.include? "google_search_engine_id"
+ WidgetSweeper.expire_item "google_search"
+ end
+ if @setting.key_name.include? "widget_stories_short_max"
+ WidgetSweeper.expire_item "stories_short"
+ end
flash[:success] = "Successfully updated your setting."
redirect_to admin_metadata_setting_path(@setting)
else
@@ -75,7 +81,16 @@ def render_new setting = nil
def render_edit setting
setting ||= Metadata::Setting.new
-
+=begin
+ if setting.name == 'site_notification_user'
+ render :partial => 'shared/admin/edit_page', :layout => 'new_admin', :locals => {
+ :item => setting,
+ :model => Metadata::Setting,
+ :fields => [:setting_name, :setting_hint, lambda {|f| f.input :setting_sub_type_name, :required => false }, lambda {|f| f.input :setting_value, :as => :select, :collection => User.admins, :hint => :setting_hint } ]
+ }
+ else
+ end
+=end
render :partial => 'shared/admin/edit_page', :layout => 'new_admin', :locals => {
:item => setting,
:model => Metadata::Setting,
View
2  app/controllers/admin/metadata/skip_images_controller.rb
@@ -48,7 +48,7 @@ def create
render_new @skip_image
end
end
-
+
def destroy
@skip_image = Metadata::SkipImage.find(params[:id])
@skip_image.destroy
View
94 app/controllers/admin/metadata/sponsor_zones_controller.rb
@@ -0,0 +1,94 @@
+class Admin::Metadata::SponsorZonesController < Admin::MetadataController
+
+ def index
+ render :partial => 'shared/admin/index_page', :layout => 'new_admin', :locals => {
+ :items => Metadata::SponsorZone.paginate(:page => params[:page], :per_page => 30, :order => "key_sub_type asc"),
+ :model => Metadata::SponsorZone,
+ :fields => [:sponsor_zone_name, :sponsor_zone_topic, :sponsor_zone_code],
+ :paginate => true
+ }
+ end
+
+ def new
+ render_new
+ end
+
+ def edit
+ @sponsor_zone = Metadata::SponsorZone.find(params[:id])
+
+ render_edit @sponsor_zone
+ end
+
+ def update
+ @sponsor_zone = Metadata::SponsorZone.find(params[:id])
+ if @sponsor_zone.update_attributes(params[:metadata_sponsor_zone])
+ flash[:success] = "Successfully updated your sponsor_zone."
+ redirect_to admin_metadata_sponsor_zone_path(@sponsor_zone)
+ else
+ flash[:error] = "Could not update your sponsor_zone as requested. Please try again."
+ render_edit @sponsor_zone
+ end
+ end
+
+ def show
+ render :partial => 'shared/admin/show_page', :layout => 'new_admin', :locals => {
+ :item => Metadata::SponsorZone.find(params[:id]),
+ :model => Metadata::SponsorZone,
+ :fields => [:sponsor_zone_name, :sponsor_zone_topic, :sponsor_zone_code]
+ }
+ end
+
+ def create
+ @sponsor_zone = Metadata::SponsorZone.new(params[:metadata_sponsor_zone])
+ if @sponsor_zone.save
+ flash[:success] = "Successfully created your sponsor_zone."
+ redirect_to admin_metadata_sponsor_zone_path(@sponsor_zone)
+ else
+ flash[:error] = "Could not create your sponsor_zone as requested. Please try again."
+ render_new @sponsor_zone
+ end
+ end
+
+ def destroy
+ @sponsor_zone = Metadata::SponsorZone.find(params[:id])
+ @sponsor_zone.destroy
+
+ redirect_to admin_metadata_sponsor_zones_path
+ end
+
+ private
+
+ def render_new sponsor_zone = nil
+ sponsor_zone ||= Metadata::SponsorZone.new
+
+ render :partial => 'shared/admin/new_page', :layout => 'new_admin', :locals => {
+ :item => sponsor_zone,
+ :model => Metadata::SponsorZone,
+ :fields => [:sponsor_zone_name, :sponsor_zone_topic, :sponsor_zone_code]
+ }
+ end
+
+ def render_edit sponsor_zone
+ sponsor_zone ||= Metadata::SponsorZone.new
+=begin
+ if sponsor_zone.name == 'site_notification_user'
+ render :partial => 'shared/admin/edit_page', :layout => 'new_admin', :locals => {
+ :item => sponsor_zone,
+ :model => Metadata::SponsorZone,
+ :fields => [:sponsor_zone_name, :sponsor_zone_topic, :sponsor_zone_code]
+ }
+ else
+ end
+=end
+ render :partial => 'shared/admin/edit_page', :layout => 'new_admin', :locals => {
+ :item => sponsor_zone,
+ :model => Metadata::SponsorZone,
+ :fields => [:sponsor_zone_name, :sponsor_zone_topic, :sponsor_zone_code]
+ }
+ end
+
+ def set_current_tab
+ @current_tab = 'sponsor_zones';
+ end
+
+end
View
2  app/controllers/admin/newswires_controller.rb
@@ -2,7 +2,7 @@ class Admin::NewswiresController < AdminController
def index
render :partial => 'shared/admin/index_page', :layout => 'new_admin', :locals => {
- :items => Newswire.paginate(:page => params[:page], :per_page => 20, :order => "created_at desc"),
+ :items => Newswire.newest.paginate(:page => params[:page], :per_page => 20, :order => "created_at desc"),
:model => Newswire,
:fields => [:title, :feed_id, :created_at],
:associations => { :belongs_to => { :feed => :feed_id } },
View
88 app/controllers/admin/prediction_groups_controller.rb
@@ -0,0 +1,88 @@
+class Admin::PredictionGroupsController < AdminController
+
+ def index
+ render :partial => 'shared/admin/index_page', :layout => 'new_admin', :locals => {
+ :items => PredictionGroup.paginate(:page => params[:page], :per_page => 20, :order => "created_at desc"),
+ :model => PredictionGroup,
+ :fields => [:title, :created_at],
+ :associations => { :belongs_to => { :user => :user_id } },
+ :paginate => true
+ }
+ end
+
+ def new
+ render_new
+ end
+
+ def edit
+ @prediction_group = PredictionGroup.find(params[:id])
+
+ render_edit @prediction_group
+ end
+
+ def update
+ @prediction_group = PredictionGroup.find(params[:id])
+ if @prediction_group.update_attributes(params[:prediction_group])
+ flash[:success] = "Successfully updated your PredictionGroup."
+ redirect_to [:admin, @prediction_group]
+ else
+ flash[:error] = "Could not update your PredictionGroup as requested. Please try again."
+ render_edit @prediction_group
+ end
+ end
+
+ def show
+ render :partial => 'shared/admin/show_page', :layout => 'new_admin', :locals => {
+ :item => PredictionGroup.find(params[:id]),
+ :model => PredictionGroup,
+ :fields => [:title, :section, :description, :status, :is_approved, :is_blocked, :user_id, :created_at],
+ :associations => { :belongs_to => { :user => :user_id } }
+ }
+ end
+
+ def create
+ @prediction_group = PredictionGroup.new(params[:prediction_group])
+ @prediction_group.section = @prediction_group.title
+ if @prediction_group.save
+ flash[:success] = "Successfully created your new PredictionGroup!"
+ redirect_to [:admin, @prediction_group]
+ else
+ flash[:error] = "Could not create your PredictionGroup, please try again"
+ render_new @prediction_group
+ end
+ end
+
+ def destroy
+ @prediction_group = PredictionGroup.find(params[:id])
+ @prediction_group.destroy
+
+ redirect_to admin_prediction_groups_path
+ end
+
+ private
+
+ def render_new prediction_group = nil
+ prediction_group ||= PredictionGroup.new
+
+ render :partial => 'shared/admin/new_page', :layout => 'new_admin', :locals => {
+ :item => @prediction_group,
+ :model => PredictionGroup,
+ :fields => [:title, lambda {|f| f.input :description, :required => false }, :status, :is_approved, :is_blocked, :user_id],
+ :associations => { :belongs_to => { :user => :user_id } }
+ }
+ end
+
+ def render_edit prediction_group
+ render :partial => 'shared/admin/edit_page', :layout => 'new_admin', :locals => {
+ :item => prediction_group,
+ :model => PredictionGroup,
+ :fields => [:title, :section, lambda {|f| f.input :description, :required => false }, :status, :is_approved, :is_blocked, :user_id],
+ :associations => { :belongs_to => { :user => :user_id } }
+ }
+ end
+
+ def set_current_tab
+ @current_tab = 'prediction_groups';
+ end
+
+end
View
87 app/controllers/admin/prediction_guesses_controller.rb
@@ -0,0 +1,87 @@
+class Admin::PredictionGuessesController < AdminController
+
+ def index
+ render :partial => 'shared/admin/index_page', :layout => 'new_admin', :locals => {
+ :items => PredictionGuess.paginate(:page => params[:page], :per_page => 20, :order => "created_at desc"),
+ :model => PredictionGuess,
+ :fields => [:prediction_question, :user, :guess, :guess_numeric, :guess_date, :created_at],
+ :associations => { :belongs_to => { :user => :user_id , :prediction_question => :prediction_question_id } },
+ :paginate => true
+ }
+ end
+
+ def new
+ render_new
+ end
+
+ def edit
+ @prediction_guess = PredictionGuess.find(params[:id])
+
+ render_edit @prediction_guess
+ end
+
+ def update
+ @prediction_guess = PredictionGuess.find(params[:id])
+ if @prediction_guess.update_attributes(params[:prediction_guess])
+ flash[:success] = "Successfully updated your PredictionGuess."
+ redirect_to [:admin, @prediction_guess]
+ else
+ flash[:error] = "Could not update your PredictionGuess as requested. Please try again."
+ render_edit @prediction_guess
+ end
+ end
+
+ def show
+ render :partial => 'shared/admin/show_page', :layout => 'new_admin', :locals => {
+ :item => PredictionGuess.find(params[:id]),
+ :model => PredictionGuess,
+ :fields => [:prediction_question, :user, :guess, :guess_numeric, :guess_date],
+ :associations => { :belongs_to => { :user => :user_id , :prediction_question => :prediction_question_id } }
+ }
+ end
+
+ def create
+ @prediction_guess = PredictionGuess.new(params[:prediction_guess])
+ if @prediction_guess.save
+ flash[:success] = "Successfully created your new PredictionGuess!"
+ redirect_to [:admin, @prediction_guess]
+ else
+ flash[:error] = "Could not create your PredictionGuess, please try again"
+ render_new @prediction_guess
+ end
+ end
+
+ def destroy
+ @prediction_guess = PredictionGuess.find(params[:id])
+ @prediction_guess.destroy
+
+ redirect_to admin_prediction_guesses_path
+ end
+
+ private
+
+ def render_new prediction_guess = nil
+ prediction_guess ||= PredictionGuess.new
+
+ render :partial => 'shared/admin/new_page', :layout => 'new_admin', :locals => {
+ :item => @prediction_guess,
+ :model => PredictionGuess,
+ :fields => [:prediction_question, :user, :guess, :guess_numeric, :guess_date],
+ :associations => { :belongs_to => { :user => :user_id , :prediction_question => :prediction_question_id } }
+ }
+ end
+
+ def render_edit prediction_guess
+ render :partial => 'shared/admin/edit_page', :layout => 'new_admin', :locals => {
+ :item => prediction_guess,
+ :model => PredictionGuess,
+ :fields => [:prediction_question, :user, :guess, :guess_numeric, :guess_date],
+ :associations => { :belongs_to => { :user => :user_id , :prediction_question => :prediction_question_id } }
+ }
+ end
+
+ def set_current_tab
+ @current_tab = 'prediction_guesses';
+ end
+
+end
View
93 app/controllers/admin/prediction_questions_controller.rb
@@ -0,0 +1,93 @@
+class Admin::PredictionQuestionsController < AdminController
+
+ before_filter :set_prediction_types
+
+ def index
+ render :partial => 'shared/admin/index_page', :layout => 'new_admin', :locals => {
+ :items => PredictionQuestion.paginate(:page => params[:page], :per_page => 20, :order => "created_at desc"),
+ :model => PredictionQuestion,
+ :fields => [:title, :prediction_type, :status, :created_at],
+ :associations => { :belongs_to => { :user => :user_id } },
+ :paginate => true
+ }
+ end
+
+ def new
+ render_new
+ end
+
+ def edit
+ @prediction_question = PredictionQuestion.find(params[:id])
+
+ render_edit @prediction_question
+ end
+
+ def update
+ @prediction_question = PredictionQuestion.find(params[:id])
+ if @prediction_question.update_attributes(params[:prediction_question])
+ flash[:success] = "Successfully updated your PredictionQuestion."
+ redirect_to [:admin, @prediction_question]
+ else
+ flash[:error] = "Could not update your PredictionQuestion as requested. Please try again."
+ render_edit @prediction_question
+ end
+ end
+
+ def show
+ render :partial => 'shared/admin/show_page', :layout => 'new_admin', :locals => {
+ :item => PredictionQuestion.find(params[:id]),
+ :model => PredictionQuestion,
+ :fields => [:title, :prediction_type, :status, :is_approved, :is_blocked, :user_id, :prediction_group_id],
+ :associations => { :belongs_to => { :user => :user_id , :prediction_group => :prediction_group_id } }
+ }
+ end
+
+ def create
+ @prediction_question = PredictionQuestion.new(params[:prediction_question])
+ if @prediction_question.save
+ flash[:success] = "Successfully created your new PredictionQuestion!"
+ redirect_to [:admin, @prediction_question]
+ else
+ flash[:error] = "Could not create your PredictionQuestion, please try again"
+ render_new @prediction_question
+ end
+ end
+
+ def destroy
+ @prediction_question = PredictionQuestion.find(params[:id])
+ @prediction_question.destroy
+
+ redirect_to admin_prediction_questions_path
+ end
+
+ private
+
+ def render_new prediction_question = nil
+ prediction_question ||= PredictionQuestion.new
+
+ render :partial => 'shared/admin/new_page', :layout => 'new_admin', :locals => {
+ :item => @prediction_question,
+ :model => PredictionQuestion,
+ :fields => [:title, lambda {|f| f.input :prediction_type, :as => :select, :collection => @type_list}, lambda {|f| f.input :choices, :required => false }, :status, :is_approved, :is_blocked, :user_id, :prediction_group_id],
+ :associations => { :belongs_to => { :user => :user_id , :prediction_group => :prediction_group_id } }
+ }
+ end
+
+ def render_edit prediction_question
+ render :partial => 'shared/admin/edit_page', :layout => 'new_admin', :locals => {
+ :item => prediction_question,
+ :model => PredictionQuestion,
+ :fields => [:title, lambda {|f| f.input :prediction_type, :as => :select, :collection => @type_list}, lambda {|f| f.input :choices, :required => false } , :status, :is_approved, :is_blocked, :user_id, :prediction_group_id, :created_at],
+ :associations => { :belongs_to => { :user => :user_id , :prediction_group => :prediction_group_id } }
+ }
+ end
+
+ def set_prediction_types
+ @type_list = { t('predictions.types.yes_no') => 'yesno', t('predictions.types.multi') => 'multi', t('predictions.types.numeric') => 'numeric', t('predictions.types.text') => 'text', t('predictions.types.year') => 'year' }
+ end
+
+ def set_current_tab
+ @current_tab = 'prediction_questions';
+ end
+
+end
View
2  app/controllers/admin/resources_controller.rb
@@ -1,5 +1,7 @@
class Admin::ResourcesController < AdminController
+ cache_sweeper :resource_sweeper, :only => [:create, :update, :destroy]
+
def index
@resources = Resource.paginate :page => params[:page], :per_page => 20, :order => "created_at desc"
end
View
5 app/controllers/admin/translations_controller.rb
@@ -7,10 +7,11 @@ class Admin::TranslationsController < AdminController
# GET /translations
# GET /translations.xml
def index
+ @paginate = true
if params[:type].nil?
- @translations = @locale.translations.find(:all, :order => "raw_key, pluralization_index")
+ @translations = @locale.translations.paginate :page => params[:page], :per_page => 100, :order => "value"
else
- @translations = @locale.translations.with_type params[:type]
+ @translations = @locale.translations.with_type(params[:type]).paginate :page => params[:page], :per_page => 100, :order => "value"
end
respond_to do |format|
View
30 app/controllers/admin/widgets_controller.rb
@@ -14,9 +14,31 @@ def index
end
end
+ def new_widgets
+ @filters = [
+ { :name => 'stories', :regex => /(stor(y|ies))|article|featured_content/i },
+ { :name => 'content', :regex => /idea|question|answer|event|resource|forum|topic/i },
+ { :name => 'media', :regex => /image|video/i },
+ { :name => 'users', :regex => /user?/i },
+ { :name => 'ads', :regex => /\bad[s_\.]/i },
+ { :name => 'misc', :regex => /.+/i }
+ ]
+ @controller = self
+ @main = Widget.main
+ @sidebar = Widget.sidebar
+ @page = WidgetPage.find_root_by_page_name('home')
+ if @page.present? and @page.children.present?
+ @main_widgets = @page.children.first.children
+ @sidebar_widgets = @page.children.second.children
+ else
+ @main_widgets = []
+ @sidebar_widgets = []
+ end
+ end
+
def save
# TODO:: Switch to updating instead of deleting
- WidgetPage.all.each {|w| w.destroy}
+ WidgetPage.destroy_all
@main = params[:main].split /,/
@sidebar = params[:sidebar].split /,/
@@ -24,13 +46,11 @@ def save
@main_content = @home_page.children.create({:name => "home_main_content", :widget_type => "main_content"})
@sidebar_content = @home_page.children.create({:name => "home_sidebar_content", :widget_type => "sidebar_content"})
@main.each do |widget_id|
- widget_position = nil
- if widget_id =~ /^([0-9]+)(?:-(left|right|))?$/
+ if widget_id =~ /^([0-9]+)$/
widget_id = $1
- widget_position = $2
end
widget = Widget.find_by_id(widget_id)
- @main_content.children.create({:name => "home_#{widget.name}_widget", :widget => widget, :widget_type => "widget", :position => widget_position})
+ @main_content.children.create({:name => "home_#{widget.name}_widget", :widget => widget, :widget_type => "widget"})
end
@sidebar.each do |widget_id|
widget_position = nil
View
8 app/controllers/admin_controller.rb
@@ -3,6 +3,7 @@ class AdminController < ApplicationController
before_filter :check_admin_or_default_status
before_filter :set_current_tab
+ before_filter :check_iframe
def index
# Loads dashboard
@@ -40,4 +41,11 @@ def find_moderatable_item
nil
end
+ def check_iframe
+ if @iframe_status
+ @iframe_status = false
+ redirect_to admin_path and return false
+ end
+ end
+
end
View
159 app/controllers/application_controller.rb
@@ -16,24 +16,30 @@ def rescue_action(exception)
end
def facebook_session_expired
- canvas = iframe_facebook_request? ? true : false
clear_fb_cookies!
clear_facebook_session_information
reset_session # remove your cookies!
- flash[:error] = "Your facebook session has expired."
- redirect_to root_url(:canvas => false)
+ #flash[:error] = "Your facebook session has expired."
+ if canvas?
+ redirect_top link_user_accounts_users_path(:only_path => false, :canvas => true)
+ else
+ redirect_to link_user_accounts_users_path(:only_path => false, :canvas => false)
+ end
end
include AuthenticatedSystem
helper :all # include all helpers, all the time
+ before_filter :set_iframe_status
#protect_from_forgery # See ActionController::RequestForgeryProtection for details
before_filter :set_p3p_header
before_filter :set_facebook_session_wrapper
- before_filter :set_slot_data
before_filter :set_current_tab
before_filter :set_current_sub_tab
+ before_filter :set_ad_layout
before_filter :set_locale
+ before_filter :set_outbrain_item
+ before_filter :set_auto_discovery_rss
before_filter :update_last_active
before_filter :check_post_wall
before_filter :verify_request_format
@@ -46,6 +52,16 @@ def facebook_session_expired
helper_method :facebook_session
helper_method :current_facebook_user
helper_method :get_setting
+ helper_method :get_ad_layout
+ helper_method :iframe_facebook_request?
+
+ def newscloud_redirect_to(options = {}, response_status = {})
+ @enable_iframe_hack = !! @iframe_status
+ headers["Newscloud-Redirect"] = @enable_iframe_hack ? 'redirect' : 'static'
+ rails_redirect_to options, response_status
+ end
+ alias_method :rails_redirect_to, :redirect_to
+ alias_method :redirect_to, :newscloud_redirect_to
def logged_in_to_facebook_and_app_authorized
if ensure_application_is_installed_by_facebook_user
@@ -65,7 +81,7 @@ def set_p3p_header
def set_facebook_session_wrapper
begin
set_facebook_session
- session[:facebook_request] = true if request_comes_from_facebook? or params[:iframe_req].present?
+ #session[:facebook_request] = true if request_comes_from_facebook? or params[:iframe_req].present?
rescue
return facebook_session_expired
end
@@ -75,6 +91,28 @@ def set_current_tab
@current_tab = false
end
+ def set_auto_discovery_rss url = nil
+ @auto_discovery_rss ||= url || stories_path(:format => :atom)
+ end
+
+ def set_sponsor_zone name = nil, topic = 'default'
+ if get_setting('sponsor_zones_enabled').try('enabled?')
+ @sponsor_zone_code ||= Metadata::SponsorZone.get(name, 'default').try(:sponsor_zone_code)
+ @sponsor_zone_topic ||= topic
+ else
+ @sponsor_zone_code = nil
+ @sponsor_zone_topic = nil
+ end
+ end
+
+ def set_outbrain_item item = nil
+ if get_setting('outbrain_enabled').try('enabled?')
+ @outbrain_item ||= item
+ else
+ @outbrain_item = nil
+ end
+ end
+
def set_current_sub_tab
@current_sub_tab = false
end
@@ -88,7 +126,7 @@ def load_top_stories
end
def load_top_users
- @top_users ||= User.top
+ @top_users ||= User.top.members
end
def load_contents
@@ -102,6 +140,7 @@ def load_newest_users
def load_top_discussed_stories
@most_discussed_stories ||= Content.find( :all,
:limit => 5,
+ :conditions => ["created_at > ?", 1.week.ago],
:order => "comments_count desc"
)
end
@@ -123,7 +162,7 @@ def load_featured_comments
end
def load_newest_articles
- @newest_articles ||= Article.active.newest 5
+ @newest_articles ||= Article.published.active.newest 5
end
def load_newest_images
@@ -156,11 +195,11 @@ def load_featured_items
end
def load_newest_idea_boards
- @newest_idea_boards ||= IdeaBoard.newest 5
+ @newest_idea_boards ||= IdeaBoard.active.newest 5
end
def load_newest_resource_sections
- @newest_resource_sections ||= ResourceSection.newest 5
+ @newest_resource_sections ||= ResourceSection.active.newest 5
end
def load_top_resources
@@ -225,6 +264,18 @@ def set_locale
cookies[:locale] = locale unless (cookies[:locale] && cookies[:locale] == locale)
end
+ def set_iframe_status
+ @enable_iframe_hack = false
+ @force_enable_iframe = false
+ @iframe_status = params[:iframe] || false
+ headers["Newscloud-Origin"] = @iframe_status ? 'iframe' : 'web'
+ end
+
+ def enable_iframe_urls
+ @force_enable_iframe = true
+ headers["Newscloud-Origin"] = 'static'
+ end
+
def default_url_options(options={})
format = options[:format] || request.format.to_sym
unless ['html', 'fbml', 'json', 'js', 'fbjs', 'xml', 'atom', 'rss'].include? format.to_s
@@ -245,22 +296,22 @@ def default_url_options(options={})
end
end
end
- {
+ opts = {
:locale => I18n.locale,
:format => format
}
+ # Disabled this and moved to IframeRewriter middleware due to fragment caching
+ #opts[:iframe] = @iframe_status if @iframe_status and not options[:canvas] == true
+ # TODO:: FIX:: Reenabled as a hack to update ajax json urls that aren't cached
+ opts[:iframe] = @iframe_status if @iframe_status and (not options[:canvas] == true) and request.xhr?
+ opts[:iframe] = @iframe_status if @iframe_status and @force_enable_iframe
+ opts
end
def tag_cloud(item)
@tags = item.tag_counts_on(:tags)
end
- def set_slot_data
- @ad_banner = Metadata.get_ad_slot('banner', 'default')
- @ad_leaderboard = Metadata.get_ad_slot('leaderboard', 'default')
- @ad_skyscraper = Metadata.get_ad_slot('skyscraper', 'default')
- end
-
def current_user_profile
return nil unless current_user.present?
current_user.profile
@@ -289,35 +340,19 @@ def find_polymorphic_item
end
def expire_cache item
- case item.class.name
- when "Content"
- StorySweeper.expire_story_all item
- when "Article"
- StorySweeper.expire_article_all item
- when "Idea"
- IdeaSweeper.expire_idea_all item
- when "Question"
- QandaSweeper.expire_question_all item
- when "Answer"
- QandaSweeper.expire_answer_all item
- when "Resource"
- ResourceSweeper.expire_resource_all item
- when "Event"
- EventSweeper.expire_event_all item
- else
- nil
- end
+ WrapperSweeper.expire_item item
end
def canvas?
- iframe_facebook_request? ? true : false
+ iframe_facebook_request?
end
def iframe_facebook_request?
- (session and session[:facebook_request]) or request_comes_from_facebook?
+ !! @iframe_status
end
def after_facebook_login_url
+ headers["Newscloud-Origin"] = 'no-rewrite'
if canvas?
link_user_accounts_users_path(:only_path => false, :canvas => true)
else
@@ -330,6 +365,10 @@ def get_setting name, sub_type = nil
Metadata::Setting.get name, sub_type
end
+ def get_ad_layout name, sub_type = nil
+ Metadata::AdLayout.get name, sub_type
+ end
+
def set_custom_sidebar_widget
cswidget = Metadata::CustomWidget.find_slot('sidebar', "#{self.controller_name}")
@custom_sidebar_widget = (cswidget and cswidget.has_widget? ? cswidget.metadatable : nil)
@@ -346,4 +385,52 @@ def verify_request_format
end
end
+ def set_ad_layout
+ action = ( params['action'] == 'index' ? 'index' : 'item' )
+ @ad_layout_info = get_ad_layout("#{params['controller']}_#{action}")
+ if @ad_layout_info.present?
+ @ad_layout = @ad_layout_info.layout
+ elsif get_ad_layout("default").present?
+ @ad_layout = get_ad_layout("default").layout
+ else
+ @ad_layout = nil
+ end
+ unless @ad_layout.nil?
+ # load ad banners
+ if @ad_layout.include? "Leader"
+ @ad_leaderboard = Metadata.get_ad_slot('leaderboard', params['controller'])
+ end
+ if @ad_layout.include? "Banner"
+ @ad_banner = Metadata.get_ad_slot('banner', params['controller'])
+ end
+ if ( @ad_layout.include? "Leader_B" or @ad_layout.include? "Banner_B" or @ad_layout.include? "Sky_A" )
+ @ad_skyscraper = Metadata.get_ad_slot('skyscraper', params['controller'])
+ end
+ if ( @ad_layout.include? "Leader_C" or @ad_layout.include? "Banner_C" or @ad_layout.include? "Square_A" )
+ @ad_small_square = Metadata.get_ad_slot('small_square', params['controller'])
+ end
+ end
+ end
+
+ # NOTE:: THIS SUCKS!!! DON'T USE THIS!!!
+ # This is an annoying hack to redirect the top page url of a facebook canvas iframe app
+ # Updated from: http://groups.google.com/group/facebooker/msg/f5790d4d45c80685
+ def redirect_top location
+ headers["Newscloud-Origin"] = 'no-rewrite'
+ @redirect_url = location
+ text = %{
+ <html><head>
+ <script type="text/javascript">
+ window.top.location.href = <%= @redirect_url.to_json %>;
+ </script>
+ <noscript>
+ <meta http-equiv="refresh" content="0;url=<%=h @redirect_url %>" />
+ <meta http-equiv="window-target" content="_top" />
+ </noscript>
+ </head></html>
+ }
+ render :layout => false, :inline => text
+
+ end
+
end
View
94 app/controllers/articles_controller.rb
@@ -1,8 +1,10 @@
class ArticlesController < ApplicationController
- before_filter :logged_in_to_facebook_and_app_authorized, :only => [:new, :create, :update, :like], :if => :request_comes_from_facebook?
- cache_sweeper :story_sweeper, :only => [:create]
+ before_filter :logged_in_to_facebook_and_app_authorized, :only => [:new, :drafts, :create, :edit, :update, :like], :if => :request_comes_from_facebook?
+ before_filter :check_valid_user, :only => [:edit, :update ]
+ cache_sweeper :story_sweeper, :only => [:create, :update, :destroy, :like]
before_filter :set_current_tab
+ before_filter :set_ad_layout, :only => [:index, :drafts, :user_index]
before_filter :login_required, :only => [:new, :create]
before_filter :load_top_stories, :only => [:index]
before_filter :load_top_discussed_stories, :only => [:index]
@@ -11,26 +13,66 @@ class ArticlesController < ApplicationController
def index
@page = params[:page].present? ? (params[:page].to_i < 3 ? "page_#{params[:page]}_" : "") : "page_1_"
@current_sub_tab = 'Browse Articles'
- @articles = Content.articles.paginate :page => params[:page], :per_page => Content.per_page, :order => "created_at desc"
- #@article_images = Image.find(:all, :conditions => ["imageable_type = ?", "Article"], :order => "created_at desc")
+ @articles = Content.articles.active.paginate :page => params[:page], :per_page => Content.per_page, :order => "created_at desc"
+ set_sponsor_zone('articles')
respond_to do |format|
format.html { @paginate = true }
- format.json { @articles = Content.refine(params) }
+ format.json { @articles = Content.articles.active.refine(params) }
end
end
+ def drafts
+ @current_sub_tab = 'Draft Articles'
+ @drafts = current_user.contents.draft_articles
+ end
+
def user_index
@user = User.find(params[:user_id])
@page = false
@current_sub_tab = 'Browse Articles'
- @articles = @user.articles.paginate :page => params[:page], :per_page => Content.per_page, :order => "created_at desc"
+ @articles = @user.articles.active.paginate :page => params[:page], :per_page => Content.per_page, :order => "created_at desc"
respond_to do |format|
format.html { @refine = false, @paginate = false }
#format.json { @articles = Content.articles.refine(params) }
end
end
+
+ def edit
+ @current_sub_tab = 'New Article'
+ @article = Article.find(params[:id])
+ end
+
+ def update
+ @article = Article.find(params[:id])
+ @article.content.caption = @article.body = params[:article][:body]
+ @article.create_preamble
+ @article.tag_list = params[:article][:content_attributes][:tags_string]
+ @article.post_wall = params[:article][:content_attributes][:post_wall]
+ @article.is_draft = params[:is_draft]
+ @article.content.user = @article.author
+ @article.author = @article.author
+ if @article.valid? and @article.update_attributes(params[:article]) and @article.update_attribute(:is_draft, params[:is_draft])
+ unless @article.is_draft
+ if @article.post_wall?
+ session[:post_wall] = @article.content
+ end
+ flash[:success] = "Successfully posted your article!"
+ redirect_to story_path(@article.content)
+ else
+ flash[:success] = "Successfully saved your draft article!"
+ redirect_to drafts_articles_path()
+ end
+ else
+ flash[:error] = "Could not create your article. Please fix the errors and try again."
+ render :new
+ end
+ end
def new
+ if get_setting('limit_daily_member_posts').present? and get_setting('limit_daily_member_posts').value.to_i <= current_user.count_daily_posts
+ flash[:error] = t('error_daily_post_limit')
+ redirect_to home_index_path
+ end
@current_sub_tab = 'New Article'
@article = Article.new
@article.build_content
@@ -40,19 +82,31 @@ def create
@article = Article.new(params[:article])
@article.content = Content.new(params[:article][:content_attributes].merge(:article => @article))
@article.content.caption = @article.body
+ @article.create_preamble
@article.tag_list = params[:article][:content_attributes][:tags_string]
@article.post_wall = params[:article][:content_attributes][:post_wall]
+ @article.is_draft = params[:is_draft]
@article.content.user = current_user
@article.author = current_user
- if @article.valid? and current_user.articles.push @article
- if @article.post_wall?
- session[:post_wall] = @article.content
- end
- flash[:success] = "Successfully posted your article!"
- redirect_to story_path(@article.content)
+ unless @article.is_draft
+ if @article.valid? and current_user.articles.push @article
+ if @article.post_wall?
+ session[:post_wall] = @article.content
+ end
+ flash[:success] = "Successfully posted your article!"
+ redirect_to story_path(@article.content)
+ else
+ flash[:error] = "Could not create your article. Please fix the errors and try again."
+ render :new
+ end
else
- flash[:error] = "Could not create your article. Please fix the errors and try again."
- render :new
+ if @article.valid? and @article.save
+ flash[:success] = "Successfully saved your draft article!"
+ redirect_to drafts_articles_path()
+ else
+ flash[:error] = "Could not create your article. Please fix the errors and try again."
+ render :new
+ end
end
end
@@ -60,16 +114,14 @@ def tags
tag_name = CGI.unescape(params[:tag])
@paginate = true
@articles = Article.tagged_with(tag_name, :on => 'tags').active.paginate :page => params[:page], :per_page => 20, :order => "created_at desc"
-
- end
-
- def set_slot_data
- @ad_banner = Metadata.get_ad_slot('banner', 'articles')
- @ad_leaderboard = Metadata.get_ad_slot('leaderboard', 'articles')
- @ad_skyscraper = Metadata.get_ad_slot('skyscraper', 'articles')
+ render :template => 'articles/index'
end
private
+
+ def check_valid_user
+ redirect_to home_index_path and return false unless current_user and ((current_user == Article.find(params[:id]).author or current_user.is_moderator?))
+ end
def set_current_tab
if MENU.key? 'articles'
View
11 app/controllers/comments_controller.rb
@@ -12,9 +12,18 @@ def create
if @comment.post_wall?
session[:post_wall] = @comment
end
+ if @comment.user.post_comments?
+ image_url = (@comment.commentable.respond_to?(:images) and @comment.commentable.images.any?) ? @template.base_url(@comment.commentable.images.first.url(:thumb)) : nil
+ app_caption = t('app.facebook.comment_caption', :title => APP_CONFIG['site_title'])
+ @comment.async_comment_messenger polymorphic_path(@commentable.item_link, :only_path => false, :canvas => iframe_facebook_request?, :format => 'html'), app_caption, image_url
+ end
# TODO:: change this to work with polymorphic associations, switch to using touch
#expire_page :controller => 'stories', :action => 'show', :id => @story
- redirect_to @commentable
+ respond_to do |format|
+ format.html { redirect_to @commentable }
+ format.json { render(:partial => 'shared/comments.html', :locals => { :comments => @commentable.comments }) and return }
+ #format.json { @comments = @commentable.comments }
+ end
else
redirect_to @commentable
end
View
22 app/controllers/events_controller.rb
@@ -4,6 +4,7 @@ class EventsController < ApplicationController
cache_sweeper :event_sweeper, :only => [:create, :update, :destroy, :import_facebook]
before_filter :set_current_tab
+ before_filter :set_ad_layout, :only => [:index, :show, :my_events, :import_facebook]
before_filter :login_required, :only => [:like, :new, :create, :update]
before_filter :load_top_events
before_filter :load_newest_events
@@ -13,8 +14,9 @@ class EventsController < ApplicationController
def index
@page = params[:page].present? ? (params[:page].to_i < 3 ? "page_#{params[:page]}_" : "") : "page_1_"
@current_sub_tab = 'Browse Events'
- @events = Event.upcoming.active.paginate :page => params[:page], :per_page => Event.per_page, :order => "created_at desc"
- respond_to do |format|
+ @events = Event.upcoming.active.paginate :page => params[:page], :per_page => Event.per_page
+ set_sponsor_zone('events')
+ respond_to do |format|
format.html { @paginate = true }
format.fbml { @paginate = true }
format.atom
@@ -49,6 +51,8 @@ def create
def show
@event = Event.find(params[:id])
tag_cloud @event
+ set_sponsor_zone('events', @event.item_title.underscore)
+ set_outbrain_item @event
end
def my_events
@@ -58,12 +62,6 @@ def my_events
@events = @user.events.active.paginate :page => params[:page], :per_page => Event.per_page, :order => "created_at desc"
end
- def set_slot_data
- @ad_banner = Metadata.get_ad_slot('banner', 'events')
- @ad_leaderboard = Metadata.get_ad_slot('leaderboard', 'events')
- @ad_skyscraper = Metadata.get_ad_slot('skyscraper', 'events')
- end
-
def import_facebook
if request.post?
@events = current_facebook_user.events(:eids=>params[:fb_events].join(','))
@@ -74,6 +72,7 @@ def import_facebook
redirect_to events_path
else
if current_facebook_user
+ @events_allowed = current_facebook_user.has_permission?('user_events')
@event = Event.new
@fb_events = current_facebook_user.events(:start_time => Time.now, :end_time => 1.month.from_now)
current_events = Event.find(:all, :conditions=>["eid IN (?)", @fb_events.collect { |e| e.eid }]).collect { |e| e.eid }
@@ -84,6 +83,13 @@ def import_facebook
end
end
end
+
+ def tags
+ tag_name = CGI.unescape(params[:tag])
+ @paginate = true
+ @events = Event.tagged_with(tag_name, :on => 'tags').active.paginate :page => params[:page], :per_page => 20, :order => "created_at desc"
+ render :template => 'events/index'
+ end
private
View
5 app/controllers/forums_controller.rb
@@ -1,8 +1,10 @@
class ForumsController < ApplicationController
before_filter :set_current_tab
+ before_filter :set_ad_layout, :only => [:index, :show]
def index
- @forums = Forum.positioned
+ @forums = Forum.alpha
+ set_sponsor_zone('forums')
end
def show
@@ -10,6 +12,7 @@ def show
@forum = Forum.find(params[:id])
@topics = @forum.topics.active.paginate :page => params[:page], :per_page => Topic.per_page, :order => "created_at desc"
@paginate = true
+ set_sponsor_zone('forums', @forum.item_title.underscore)
end
private
View
27 app/controllers/home_controller.rb
@@ -1,5 +1,5 @@
class HomeController < ApplicationController
- #caches_page :index, :google_ads, :helios_ads, :bookmarklet_panel
+ #caches_page :index, :google_ads, :helios_ads
layout proc { |controller| controller.action_name == 'app_tab' ? 'app_tab' : 'application' }
cache_sweeper :story_sweeper, :only => [:create, :update, :destroy, :like]
@@ -11,6 +11,16 @@ class HomeController < ApplicationController
def test_design
end
+ def preview_widgets
+ @page = true
+ @page = WidgetPage.find_root_by_page_name('home')
+ if false and @page.present? and @page.children.present?
+ @main = @page.children.first.children
+ end
+ @main = params[:widget_ids].split(',').map {|wid| Widget.find(wid) }
+ @sidebar = []
+ end
+
def index
@page = "page_1_"
if request.post?
@@ -31,8 +41,6 @@ def index
@main.each {|w| controller.send(w.widget.load_functions) if w.widget.load_functions.present? }
@sidebar.each {|w| controller.send(w.widget.load_functions) if w.widget.load_functions.present? }
end
- render :template => 'home/test_widgets'
- return
end
#expires_in 1.minutes, :private => false, :public => true
@no_paginate = true
@@ -56,6 +64,11 @@ def google_ads
render :partial => 'shared/google_ads', :locals => { :slot_name => slot_name },:layout => false
end
+ def openx_ads
+ slot_name = params[:slot_name] || get_setting('openx_slot_name').try(:value)
+ render :partial => 'shared/ads/openx_ads', :locals => { :slot_name => slot_name },:layout => false
+ end
+
def helios_ads
slot_name = params[:slot_name] || APP_CONFIG['helios_slot_name']
render :partial => 'shared/ads/helios_ads', :locals => { :slot_name => slot_name },:layout => false
@@ -76,10 +89,6 @@ def helios_alt4_ads
render :partial => 'shared/ads/helios_alt4_ads', :locals => { :slot_name => slot_name },:layout => false
end
- def bookmarklet_panel
- render :partial => 'shared/bookmarklet_panel.fbml.haml', :layout => false
- end
-
def about
end
@@ -89,6 +98,10 @@ def faq
def terms
end
+ def external_page
+ render(:layout => 'external_page', :template => 'home/external_page_header')
+ end
+
def contact_us
if request.post?
@message = Message.new(params[:message])
View
4 app/controllers/idea_boards_controller.rb
@@ -1,12 +1,13 @@
class IdeaBoardsController < ApplicationController
before_filter :set_current_tab
+ before_filter :set_ad_layout, :only => [:index, :show]
before_filter :login_required, :only => [:new, :create, :update]
before_filter :load_top_ideas, :only => :index
before_filter :load_newest_ideas, :only => :index
def index
@current_sub_tab = 'Browse Idea Topics'
- @idea_boards = IdeaBoard.paginate :page => params[:page], :per_page => 10, :order => "created_at desc"
+ @idea_boards = IdeaBoard.active.paginate :page => params[:page], :per_page => 10, :order => "created_at desc"
end
def show
@@ -18,6 +19,7 @@ def show
:order => "votes.count desc"
})
@newest_ideas = @idea_board.ideas.newest 5
+ set_sponsor_zone('ideas', @idea_board.item_title.underscore)
end
private
View
13 app/controllers/ideas_controller.rb
@@ -4,6 +4,7 @@ class IdeasController < ApplicationController
cache_sweeper :idea_sweeper, :only => [:create, :update, :destroy]
before_filter :set_current_tab
+ before_filter :set_ad_layout, :only => [:index, :show, :my_ideas]
before_filter :login_required, :only => [:new, :create, :update, :my_ideas]
before_filter :load_top_ideas
before_filter :load_newest_ideas
@@ -15,6 +16,7 @@ def index
@page = params[:page].present? ? (params[:page].to_i < 3 ? "page_#{params[:page]}_" : "") : "page_1_"
@current_sub_tab = 'Browse Ideas'
@ideas = Idea.active.paginate :page => params[:page], :per_page => Idea.per_page, :order => "created_at desc"
+ set_sponsor_zone('ideas')
respond_to do |format|
format.html { @paginate = true }
format.fbml { @paginate = true }
@@ -55,6 +57,8 @@ def create
def show
@idea = Idea.find(params[:id])
tag_cloud @idea
+ set_outbrain_item @idea
+ set_sponsor_zone('ideas', @idea.item_title.underscore)
end
def my_ideas
@@ -64,10 +68,11 @@ def my_ideas
@ideas = @user.ideas.active.paginate :page => params[:page], :per_page => Idea.per_page, :order => "created_at desc"
end
- def set_slot_data
- @ad_banner = Metadata.get_ad_slot('banner', 'ideas')
- @ad_leaderboard = Metadata.get_ad_slot('leaderboard', 'ideas')
- @ad_skyscraper = Metadata.get_ad_slot('skyscraper', 'ideas')
+ def tags
+ tag_name = CGI.unescape(params[:tag])
+ @paginate = true
+ @ideas = Idea.tagged_with(tag_name, :on => 'tags').active.paginate :page => params[:page], :per_page => 20, :order => "created_at desc"
+ render :template => 'ideas/index'
end
private
View
9 app/controllers/newswires_controller.rb
@@ -1,12 +1,13 @@
class NewswiresController < ApplicationController
before_filter :set_current_tab
+ before_filter :set_ad_layout, :only => [:index]
before_filter :login_required, :only => [:quick_post]
before_filter :load_top_stories, :only => [:index]
def index
@current_sub_tab = 'Browse Wires'
@page = params[:page].present? ? (params[:page].to_i < 3 ? "page_#{params[:page]}_" : "") : "page_1_"
- @newswires = Newswire.unpublished.paginate :page => params[:page], :per_page => 20, :order => "created_at desc"
+ @newswires = Newswire.unpublished.newest.paginate :page => params[:page], :per_page => 20, :order => "created_at desc"
@paginate = true
end
@@ -34,12 +35,6 @@ def quick_post
end
end
- def set_slot_data
- @ad_banner = Metadata.get_ad_slot('banner', 'newswires')
- @ad_leaderboard = Metadata.get_ad_slot('leaderboard', 'newswires')
- @ad_skyscraper = Metadata.get_ad_slot('skyscraper', 'newswires')
- end
-
private
def set_current_tab
View
35 app/controllers/oauth_controller.rb
@@ -0,0 +1,35 @@
+class OauthController < ApplicationController
+ before_filter :login_required
+
+ def new
+ session[:at]=nil
+ if iframe_facebook_request?
+ redirect_top authenticator.authorize_url(:scope => 'publish_stream,offline_access', :display => 'page')
+ else
+ redirect_to authenticator.authorize_url(:scope => 'publish_stream,offline_access', :display => 'page')
+ end
+ end
+
+ def create
+ if params[:error].present?
+ if params[:error][:type] == "OAuthAccessDeniedException"
+ current_user.update_attribute(:fb_oauth_denied_at, Time.now)
+ else
+ Rails.logger.error "***FB OAUTH ERROR*** #{params.inspect}"
+ end
+ else
+ mogli_client = Mogli::Client.create_from_code_and_authenticator(params[:code],authenticator)
+ session[:at]=mogli_client.access_token
+ current_user.update_attribute(:fb_oauth_key, mogli_client.access_token)
+ end
+ if iframe_facebook_request?
+ redirect_top home_index_path(:only_path => false, :canvas => true)
+ else
+ redirect_to home_index_path
+ end
+ end
+
+ def authenticator
+ @authenticator ||= Mogli::Authenticator.new(APP_CONFIG['facebook_application_id'], Facebooker.secret_key, oauth_callback_path(:only_path => false, :canvas => iframe_facebook_request?))
+ end
+end
View
33 app/controllers/prediction_groups_controller.rb
@@ -0,0 +1,33 @@
+class PredictionGroupsController < ApplicationController
+ before_filter :login_required, :only => [:like, :new, :create]
+ before_filter :set_ad_layout, :only => [:index, :show]
+
+# cache_sweeper :qanda_sweeper, :only => [:create, :update, :destroy, :create_answer]
+
+ def index
+ @page