Skip to content
This repository has been archived by the owner on Aug 15, 2018. It is now read-only.

Commit

Permalink
updated engines (this broke stuff), fixed a few things with the forums
Browse files Browse the repository at this point in the history
  • Loading branch information
Josh Adams committed Dec 23, 2008
1 parent 1ec530e commit 0e3d2b6
Show file tree
Hide file tree
Showing 7 changed files with 78 additions and 4 deletions.
61 changes: 60 additions & 1 deletion 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
Expand Down
8 changes: 6 additions & 2 deletions app/models/page.rb
Expand Up @@ -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
Expand Down
Expand Up @@ -7,7 +7,6 @@

<h1><%= 'Forums'[:forums_title] %></h1>
<p class="subtitle">
<%= 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)] %>
</p>
Expand Down
@@ -0,0 +1,9 @@
module Ansuz
module JAdams
class Twitterati < ProtoPagePlugin
def view_partial
'/admin/twitterati/twitterati'
end
end
end
end
1 change: 1 addition & 0 deletions vendor/plugins/ansuz_twitterati/init.rb
@@ -0,0 +1 @@
Ansuz::PluginManagerInstance.register_plugin(Ansuz::JAdams::Twitterati)
@@ -0,0 +1 @@
foo
@@ -0,0 +1 @@
<%= @note %>

0 comments on commit 0e3d2b6

Please sign in to comment.