work on controllers/views started

This commit is contained in:
albert
2010-03-11 19:42:04 -05:00
parent ac98d7db37
commit 15c134b270
34 changed files with 720 additions and 7543 deletions

View File

@@ -1,16 +1,39 @@
class PostsController < ApplicationController
before_filter :member_only, :except => [:show, :index]
after_filter :save_recent_tags, :only => [:create, :update]
after_filter :save_recent_tags, :only => [:update]
respond_to :html, :xml, :json
def index
@post_set = PostSet.new(params[:tags], params[:page], @current_user, params[:before_id])
respond_with(@post_set) do |fmt|
fmt.js
end
end
def show
@post = Post.find(params[:id])
respond_with(@post)
end
def update
@post = Post.find(params[:id])
@post.update_attributes(params[:post].merge(:updater_id => @current_user.id, :updater_ip_addr => request.remote_ip))
respond_with(@post)
end
def revert
@post = Post.find(params[:id])
@version = PostVersion.find(params[:version_id])
@post.revert_to!(@version, @current_user.id, request.remote_ip)
respond_width(@post)
end
private
def save_recent_tags
if params[:tags] || (params[:post] && params[:post][:tags])
tags = Tag.scan_tags(params[:tags] || params[:post][:tags])
tags = TagAlias.to_aliased(tags) + Tag.scan_tags(session[:recent_tags])
session[:recent_tags] = tags.uniq.slice(0, 40).join(" ")
end
end
end