This commit is contained in:
albert
2010-10-08 18:42:26 -04:00
parent 6bc469b05d
commit f051e04550
88 changed files with 2865 additions and 699 deletions

View File

@@ -0,0 +1,6 @@
module Admin
class PostsController
def edit
end
end
end

View File

@@ -0,0 +1,12 @@
class AdvertisementHitsController < ApplicationController
def create
advertisement = Advertisement.find(params[:id])
advertisement.hits.create(:ip_addr => request.remote_ip)
redirect_to advertisement.referral_url
end
protected
def set_title
@page_title = Danbooru.config.app_name + "/advertisements"
end
end

View File

@@ -1,22 +1,60 @@
class AdvertisementsController < ApplicationController
def new
@advertisement = Advertisement.new(
:ad_type => "vertical",
:status => "active"
)
end
def edit
@advertisement = Advertisement.find(params[:id])
end
def index
@advertisements = Advertisement.all
if params[:start_date]
@start_date = Date.parse(params[:start_date])
else
@start_date = 1.month.ago.to_date
end
if params[:end_date]
@end_date = Date.parse(params[:end_date])
else
@end_date = Date.today
end
end
def show
@advertisement = Advertisement.find(params[:id])
end
def create
@advertisement = Advertisement.new(params[:advertisement])
if @advertisement.save
flash[:notice] = "Advertisement created"
redirect_to advertisement_path(@advertisement)
else
flash[:notice] = "There were errors"
render :action => "new"
end
end
def update
@advertisement = Advertisement.find(params[:id])
if @advertisement.update_attributes(params[:advertisement])
flash[:notice] = "Advertisement updated"
redirect_to advertisement_path(@advertisement)
else
flash[:notice] = "There were errors"
render :action => "edit"
end
end
def destroy
@advertisement = Advertisement.find(params[:id])
@advertisement.destroy
redirect_to advertisements_path
end
end

View File

@@ -3,6 +3,7 @@ class ApplicationController < ActionController::Base
before_filter :set_current_user
after_filter :reset_current_user
before_filter :initialize_cookies
before_filter :set_title
layout "default"
protected
@@ -65,4 +66,8 @@ protected
cookies["blacklisted_tags"] = CurrentUser.user.blacklisted_tags
end
end
def set_title
@page_title = Danbooru.config.app_name + "/#{params[:controller]}"
end
end

View File

@@ -1,7 +1,9 @@
class ArtistVersionsController < ApplicationController
def index
end
respond_to :html, :xml, :json
def show
end
def index
@artist = Artist.find(params[:artist_id])
@artist_versions = ArtistVersion.paginate :order => "version desc", :per_page => 25, :page => params[:page], :conditions => ["artist_id = ?", @artist.id]
respond_with(@artist_versions)
end
end

View File

@@ -1,4 +1,6 @@
class ArtistsController < ApplicationController
before_filter :member_only
def new
@artist = Artist.new_with_defaults(params)
end
@@ -8,23 +10,45 @@ class ArtistsController < ApplicationController
end
def index
order = params[:order] == "date" ? "updated_at DESC" : "name"
limit = params[:limit] || 50
@artists = Artist.paginate(Artist.build_relation())
@artists = Artist.build_relation(params).paginate(:per_page => 25, :page => params[:page])
end
def show
@artist = Artist.find(params[:id])
if @artist
@posts = Danbooru.config.select_posts_visible_to_user(CurrentUser.user, Post.find_by_tags(@artist.name, :limit => 6))
else
redirect_to new_artist_path(params[:name])
end
end
def create
@artist = Artist.create(params[:artist])
if @artist.errors.empty?
redirect_to artist_path(@artist)
else
flash[:notice] = "There were errors"
render :action => "new"
end
end
def update
@artist = Artist.find(params[:id])
@artist.update_attributes(params[:artist])
if @artist.errors.empty?
redirect_to artist_path(@artist)
else
flash[:notice] = "There were errors"
render :action => "edit"
end
end
def destroy
end
def revert
@artist = Artist.find(params[:id])
@artist.revert_to!(params[:version])
redirect_to artist_path(@artist)
end
end

View File

@@ -14,7 +14,7 @@ class CommentsController < ApplicationController
def create
@comment = Comment.new(params[:comment])
@comment.post_id = params[:comment][:post_id]
@comment.creator_id = @current_user.id
@comment.creator_id = CurrentUser.user.id
@comment.ip_addr = request.remote_ip
@comment.score = 0
@comment.save

View File

@@ -1,14 +1,14 @@
class FavoritesController < ApplicationController
def create
@favorite = Favorite.create(
:user_id => @current_user.id,
:user_id => CurrentUser.user.id,
:post_id => params[:favorite][:post_id]
)
end
def destroy
Favorite.destroy(
:user_id => @current_user.id,
:user_id => CurrentUser.user.id,
:post_id => params[:favorite][:post_id]
)
end

View File

@@ -4,10 +4,8 @@ class PostsController < ApplicationController
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
@post_set = PostSet.new(params[:tags], params[:page], params[:before_id])
respond_with(@post_set)
end
def show

View File

@@ -16,4 +16,7 @@ class TagAliasesController < ApplicationController
def destroy
end
def destroy_cache
end
end

View File

@@ -10,7 +10,7 @@ class UploadsController < ApplicationController
end
def index
@uploads = Upload.where("uploader_id = ?", @current_user.id).includes(:uploader).order("uploads.id desc").limit(10)
@uploads = Upload.where("uploader_id = ?", CurrentUser.user.id).includes(:uploader).order("uploads.id desc").limit(10)
respond_with(@uploads)
end
@@ -19,7 +19,15 @@ class UploadsController < ApplicationController
end
def create
@upload = Upload.create(params[:upload].merge(:uploader_id => @current_user.id, :uploader_ip_addr => request.remote_ip))
@upload = Upload.create(params[:upload])
respond_with(@upload)
end
def update
@upload = Upload.find(params[:id])
@upload.process!
render :update do |page|
page.reload
end
end
end

View File

@@ -1,6 +1,6 @@
class UsersController < ApplicationController
respond_to :html, :xml, :json
before_filter :member_only, :only => [:edit, :show, :update, :destroy, :create]
before_filter :member_only, :only => [:edit, :show, :update, :destroy]
def new
@user = User.new
@@ -8,8 +8,8 @@ class UsersController < ApplicationController
def edit
@user = User.find(params[:id])
unless @current_user.is_admin?
@user = @current_user
unless CurrentUser.user.is_admin?
@user = CurrentUser.user
end
end
@@ -23,10 +23,13 @@ class UsersController < ApplicationController
def create
@user = User.new(params[:user].merge(:ip_addr => request.remote_ip))
if @user.save
flash[:notice] = "You have succesfully created a new account."
flash[:notice] = "You have succesfully created a new account"
session[:user_id] = @user.id
redirect_to user_path(@user)
else
flash[:notice] = "There were errors"
render :action => "new"
end
respond_with(@user)
end
def update