sync
This commit is contained in:
6
app/controllers/admin/posts_controller.rb
Normal file
6
app/controllers/admin/posts_controller.rb
Normal file
@@ -0,0 +1,6 @@
|
||||
module Admin
|
||||
class PostsController
|
||||
def edit
|
||||
end
|
||||
end
|
||||
end
|
||||
12
app/controllers/advertisement_hits_controller.rb
Normal file
12
app/controllers/advertisement_hits_controller.rb
Normal 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
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -16,4 +16,7 @@ class TagAliasesController < ApplicationController
|
||||
|
||||
def destroy
|
||||
end
|
||||
|
||||
def destroy_cache
|
||||
end
|
||||
end
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user