From 0e3d2b6c376e5ccd26f2f8bc535682376dac7498 Mon Sep 17 00:00:00 2001 From: Josh Adams Date: Mon, 22 Dec 2008 22:14:10 -0600 Subject: [PATCH] updated engines (this broke stuff), fixed a few things with the forums --- app/controllers/forums_controller.rb | 61 ++++++++++++++++++- app/models/page.rb | 8 ++- .../app/views/forums/index.html.erb | 1 - .../app/models/ansuz/j_adams/twitterati.rb | 9 +++ vendor/plugins/ansuz_twitterati/init.rb | 1 + .../admin/twitterati/_twitterati.html.erb | 1 + .../views/plugin_mail/mail_from_plugin.erb | 1 + 7 files changed, 78 insertions(+), 4 deletions(-) create mode 100644 vendor/plugins/ansuz_twitterati/app/models/ansuz/j_adams/twitterati.rb create mode 100644 vendor/plugins/ansuz_twitterati/init.rb create mode 100644 vendor/plugins/ansuz_twitterati/views/admin/twitterati/_twitterati.html.erb create mode 100644 vendor/plugins/engines/test/plugins/test_plugin_mailing/app/views/plugin_mail/mail_from_plugin.erb diff --git a/app/controllers/forums_controller.rb b/app/controllers/forums_controller.rb index 7297355..9997e1d 100644 --- a/app/controllers/forums_controller.rb +++ b/app/controllers/forums_controller.rb @@ -1,7 +1,66 @@ class ForumsController < ApplicationController before_filter :set_page_title + before_filter :login_required, :except => [:index, :show] + before_filter :find_or_initialize_forum, :except => :index + before_filter :admin?, :except => [:show, :index] + + cache_sweeper :posts_sweeper, :only => [:create, :update, :destroy] + + def index + @forums = Forum.find_ordered + # reset the page of each forum we have visited when we go back to index + session[:forum_page] = nil + respond_to do |format| + format.html + format.xml { render :xml => @forums } + end + end + + def show + respond_to do |format| + format.html do + # keep track of when we last viewed this forum for activity indicators + (session[:forums] ||= {})[@forum.id] = Time.now.utc if logged_in? + (session[:forum_page] ||= Hash.new(1))[@forum.id] = params[:page].to_i if params[:page] + + @topics = @forum.topics.paginate :page => params[:page] + User.find(:all, :conditions => ['id IN (?)', @topics.collect { |t| t.replied_by }.uniq]) unless @topics.blank? + end + format.xml { render :xml => @forum } + end + end + + # new renders new.html.erb + def create + @forum.attributes = params[:forum] + @forum.save! + respond_to do |format| + format.html { redirect_to @forum } + format.xml { head :created, :location => formatted_forum_url(@forum, :xml) } + end + end + + def update + @forum.update_attributes!(params[:forum]) + respond_to do |format| + format.html { redirect_to @forum } + format.xml { head 200 } + end + end + + def destroy + @forum.destroy + respond_to do |format| + format.html { redirect_to forums_path } + format.xml { head 200 } + end + end + + protected + def find_or_initialize_forum + @forum = params[:id] ? Forum.find(params[:id]) : Forum.new + end -protected def set_page_title @page_title = "Ansuz - Forum" end diff --git a/app/models/page.rb b/app/models/page.rb index 9a68005..f5108c2 100644 --- a/app/models/page.rb +++ b/app/models/page.rb @@ -50,11 +50,15 @@ class Page < ActiveRecord::Base protected def inform_reviewers - AnsuzMailer.deliver_page_review_notifications(self) + if User.content_approvers.any? + AnsuzMailer.deliver_page_review_notifications(self) + end end def inform_authors - AnsuzMailer.deliver_page_publication_notifications(self) + if User.authors.any? + AnsuzMailer.deliver_page_publication_notifications(self) + end end public diff --git a/vendor/plugins/ansuz_savage_beast/app/views/forums/index.html.erb b/vendor/plugins/ansuz_savage_beast/app/views/forums/index.html.erb index cf133db..f2db442 100644 --- a/vendor/plugins/ansuz_savage_beast/app/views/forums/index.html.erb +++ b/vendor/plugins/ansuz_savage_beast/app/views/forums/index.html.erb @@ -7,7 +7,6 @@

<%= 'Forums'[:forums_title] %>

- <%= feed_icon_tag "Recent Posts"[:recent_posts], formatted_posts_path(:format => 'rss') %> <%# '{count} topic(s)'[(count=Topic.count)==1 ? :topic_count : :topics_count, number_with_delimiter(count)] %>, <%# '{count} post(s)'[(count=Post.count)==1 ? :post_count : :posts_count, number_with_delimiter(count)] %>, <%# '{count} voice(s)'[(count=User.count(:conditions => "posts_count > 0"))==1 ? :voice_count : :voices_count, number_with_delimiter(count)] %>

diff --git a/vendor/plugins/ansuz_twitterati/app/models/ansuz/j_adams/twitterati.rb b/vendor/plugins/ansuz_twitterati/app/models/ansuz/j_adams/twitterati.rb new file mode 100644 index 0000000..9205dbe --- /dev/null +++ b/vendor/plugins/ansuz_twitterati/app/models/ansuz/j_adams/twitterati.rb @@ -0,0 +1,9 @@ +module Ansuz + module JAdams + class Twitterati < ProtoPagePlugin + def view_partial + '/admin/twitterati/twitterati' + end + end + end +end diff --git a/vendor/plugins/ansuz_twitterati/init.rb b/vendor/plugins/ansuz_twitterati/init.rb new file mode 100644 index 0000000..f32d9e8 --- /dev/null +++ b/vendor/plugins/ansuz_twitterati/init.rb @@ -0,0 +1 @@ +Ansuz::PluginManagerInstance.register_plugin(Ansuz::JAdams::Twitterati) diff --git a/vendor/plugins/ansuz_twitterati/views/admin/twitterati/_twitterati.html.erb b/vendor/plugins/ansuz_twitterati/views/admin/twitterati/_twitterati.html.erb new file mode 100644 index 0000000..257cc56 --- /dev/null +++ b/vendor/plugins/ansuz_twitterati/views/admin/twitterati/_twitterati.html.erb @@ -0,0 +1 @@ +foo diff --git a/vendor/plugins/engines/test/plugins/test_plugin_mailing/app/views/plugin_mail/mail_from_plugin.erb b/vendor/plugins/engines/test/plugins/test_plugin_mailing/app/views/plugin_mail/mail_from_plugin.erb new file mode 100644 index 0000000..2b49606 --- /dev/null +++ b/vendor/plugins/engines/test/plugins/test_plugin_mailing/app/views/plugin_mail/mail_from_plugin.erb @@ -0,0 +1 @@ +<%= @note %> \ No newline at end of file