moved some donmai-specific stuff out of default config
This commit is contained in:
@@ -2,8 +2,8 @@ class ArtistVersionsController < ApplicationController
|
|||||||
respond_to :html, :xml, :json
|
respond_to :html, :xml, :json
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@artist = Artist.find(params[:artist_id])
|
@search = Artist.search(params[:search])
|
||||||
@artist_versions = ArtistVersion.paginate :order => "version desc", :per_page => 25, :page => params[:page], :conditions => ["artist_id = ?", @artist.id]
|
@artist_versions = @search.paginate :order => "version desc", :per_page => 25, :page => params[:page]
|
||||||
respond_with(@artist_versions)
|
respond_with(@artist_versions)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,19 +1,36 @@
|
|||||||
class BansController < ApplicationController
|
class BansController < ApplicationController
|
||||||
def new
|
def new
|
||||||
|
@ban = Ban.new
|
||||||
end
|
end
|
||||||
|
|
||||||
def edit
|
def edit
|
||||||
|
@ban = Ban.find(params[:id])
|
||||||
end
|
end
|
||||||
|
|
||||||
def index
|
def index
|
||||||
|
@search = Ban.search(params[:search])
|
||||||
|
@bans = @search.paginate(:page => params[:page])
|
||||||
end
|
end
|
||||||
|
|
||||||
def show
|
def show
|
||||||
|
@ban = Ban.find(params[:id])
|
||||||
end
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
|
@ban = Ban.new(params[:ban])
|
||||||
|
if @ban.save
|
||||||
|
redirect_to ban_path(@ban)
|
||||||
|
else
|
||||||
|
render :action => "new"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def update
|
def update
|
||||||
|
@ban = Ban.find(params[:id])
|
||||||
|
if @ban.update_attributes(params[:ban])
|
||||||
|
redirect_to ban_path(@ban)
|
||||||
|
else
|
||||||
|
render :action => "edit"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,19 +1,37 @@
|
|||||||
class ForumPostsController < ApplicationController
|
class ForumPostsController < ApplicationController
|
||||||
def new
|
def new
|
||||||
|
@forum_post = ForumPost.new(:topic_id => params[:topic_id])
|
||||||
end
|
end
|
||||||
|
|
||||||
def edit
|
def edit
|
||||||
|
@forum_post = ForumPost.find(params[:id])
|
||||||
end
|
end
|
||||||
|
|
||||||
def show
|
def show
|
||||||
|
@forum_post = ForumPost.find(params[:id])
|
||||||
end
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
|
@forum_post = ForumPost.new(params[:forum_post])
|
||||||
|
if @forum_post.save
|
||||||
|
redirect_to forum_post_path(@forum_post)
|
||||||
|
else
|
||||||
|
render :action => "new"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def update
|
def update
|
||||||
|
@forum_post = ForumPost.find(params[:id])
|
||||||
|
if @forum_post.update_attributes(params[:forum_post])
|
||||||
|
redirect_to forum_post_path(@forum_post)
|
||||||
|
else
|
||||||
|
render :action => "edit"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
|
@forum_post = ForumPost.find(params[:id])
|
||||||
|
@forum_post.destroy
|
||||||
|
redirect_to forum_topic_path(@forum_post.topic_id)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,22 +1,42 @@
|
|||||||
class ForumTopicsController < ApplicationController
|
class ForumTopicsController < ApplicationController
|
||||||
def new
|
def new
|
||||||
|
@forum_topic = ForumTopic.new
|
||||||
end
|
end
|
||||||
|
|
||||||
def edit
|
def edit
|
||||||
|
@forum_topic = ForumTopic.find(params[:id])
|
||||||
end
|
end
|
||||||
|
|
||||||
def index
|
def index
|
||||||
|
@search = ForumTopic.search(params[:search])
|
||||||
|
@forum_topics = @search.paginate(:page => params[:page], :order => "updated_at DESC")
|
||||||
end
|
end
|
||||||
|
|
||||||
def show
|
def show
|
||||||
|
@forum_topic = ForumTopic.find(params[:id])
|
||||||
end
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
|
@forum_topic = ForumTopic.new(params[:forum_topic])
|
||||||
|
if @forum_topic.save
|
||||||
|
redirect_to forum_topic_path(@forum_topic)
|
||||||
|
else
|
||||||
|
render :action => "new"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def update
|
def update
|
||||||
|
@forum_topic = ForumTopic.find(params[:id])
|
||||||
|
if @forum_topic.update_attributes(params[:forum_topic])
|
||||||
|
redirect_to forum_topic_path(@forum_topic)
|
||||||
|
else
|
||||||
|
render :action => "edit"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
|
@forum_topic = ForumTopic.find(params[:id])
|
||||||
|
@forum_topic.destroy
|
||||||
|
redirect_to forum_topics_path
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -4,4 +4,5 @@ class ForumTopic < ActiveRecord::Base
|
|||||||
has_many :posts, :class_name => "ForumPost", :order => "forum_posts.id asc"
|
has_many :posts, :class_name => "ForumPost", :order => "forum_posts.id asc"
|
||||||
validates_presence_of :title, :creator_id
|
validates_presence_of :title, :creator_id
|
||||||
scope :search_title, lambda {|title| where(["text_index @@ plainto_tsquery(?)", title])}
|
scope :search_title, lambda {|title| where(["text_index @@ plainto_tsquery(?)", title])}
|
||||||
|
accepts_nested_attributes_for :forum_posts
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
<h4>History for <%= @artist.name %></h4>
|
<h4>Artist History</h4>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<table width="100%" class="highlightable">
|
<table width="100%" class="highlightable">
|
||||||
@@ -16,7 +16,7 @@
|
|||||||
<tbody>
|
<tbody>
|
||||||
<% @artist_versions.each do |artist_version| %>
|
<% @artist_versions.each do |artist_version| %>
|
||||||
<tr class="<%= cycle 'even', 'odd' %>">
|
<tr class="<%= cycle 'even', 'odd' %>">
|
||||||
<td><%= link_to h(artist_version.name), artist_versions_path(:artist_id => @artist.id) %></td>
|
<td><%= link_to h(artist_version.name), artist_versions_path(:artist_id => artist_version.artist_id) %></td>
|
||||||
<td><%= h artist_version.other_names %></td>
|
<td><%= h artist_version.other_names %></td>
|
||||||
<td><%= h artist_version.group_name %></td>
|
<td><%= h artist_version.group_name %></td>
|
||||||
<td><%= time_ago_in_words artist_version.created_at %> ago</td>
|
<td><%= time_ago_in_words artist_version.created_at %> ago</td>
|
||||||
@@ -33,14 +33,5 @@
|
|||||||
<%= will_paginate(@artist_versions) %>
|
<%= will_paginate(@artist_versions) %>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<% content_for("footer") do %>
|
|
||||||
<li>|</li>
|
|
||||||
<li><%= link_to "Show", artist_path(@artist) %>
|
|
||||||
<li><%= link_to "Edit", edit_artist_path(@artist) %></li>
|
|
||||||
<li><%= link_to "Delete", artist_path(@artist, :method => :delete) %></li>
|
|
||||||
<li><%= link_to "History", artist_versions_path(:artist_id => @artist) %></li>
|
|
||||||
<li><%= link_to "Posts", posts_path(:tags => @artist.name) %></li>
|
|
||||||
<% end %>
|
|
||||||
|
|
||||||
<%= render :partial => "footer" %>
|
<%= render :partial => "footer" %>
|
||||||
|
|
||||||
|
|||||||
@@ -182,18 +182,7 @@ module Danbooru
|
|||||||
# Any custom code you want to insert into the default layout without
|
# Any custom code you want to insert into the default layout without
|
||||||
# having to modify the templates.
|
# having to modify the templates.
|
||||||
def custom_html_header_content
|
def custom_html_header_content
|
||||||
%{
|
nil
|
||||||
<script type="text/javascript">
|
|
||||||
//var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
|
|
||||||
//document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
|
|
||||||
</script>
|
|
||||||
<script type="text/javascript">
|
|
||||||
try {
|
|
||||||
//var pageTracker = _gat._getTracker("UA-86094-4");
|
|
||||||
//pageTracker._trackPageview();
|
|
||||||
} catch(err) {}
|
|
||||||
</script>
|
|
||||||
}.html_safe
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# The number of posts displayed per page.
|
# The number of posts displayed per page.
|
||||||
@@ -202,11 +191,11 @@ module Danbooru
|
|||||||
end
|
end
|
||||||
|
|
||||||
def is_post_restricted?(post)
|
def is_post_restricted?(post)
|
||||||
post.has_tag?("loli") || post.has_tag?("shota")
|
false
|
||||||
end
|
end
|
||||||
|
|
||||||
def is_user_restricted?(user)
|
def is_user_restricted?(user)
|
||||||
!user.is_privileged? || user.name == "ppayne"
|
!user.is_privileged?
|
||||||
end
|
end
|
||||||
|
|
||||||
def can_user_see_post?(user, post)
|
def can_user_see_post?(user, post)
|
||||||
@@ -218,7 +207,7 @@ module Danbooru
|
|||||||
end
|
end
|
||||||
|
|
||||||
def select_posts_visible_to_user(user, posts)
|
def select_posts_visible_to_user(user, posts)
|
||||||
posts.select {|x| !is_user_restricted?(user) || !is_post_restricted?(x)}
|
posts.select {|x| can_user_see_post?(x)}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -8,5 +8,28 @@ module Danbooru
|
|||||||
def posts_per_page
|
def posts_per_page
|
||||||
1
|
1
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def is_user_restricted?(user)
|
||||||
|
!user.is_privileged? || user.name == "ppayne"
|
||||||
|
end
|
||||||
|
|
||||||
|
def is_post_restricted?(post)
|
||||||
|
post.has_tag?("loli") || post.has_tag?("shota")
|
||||||
|
end
|
||||||
|
|
||||||
|
def custom_html_header_content
|
||||||
|
%{
|
||||||
|
<script type="text/javascript">
|
||||||
|
//var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
|
||||||
|
//document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
|
||||||
|
</script>
|
||||||
|
<script type="text/javascript">
|
||||||
|
try {
|
||||||
|
//var pageTracker = _gat._getTracker("UA-86094-4");
|
||||||
|
//pageTracker._trackPageview();
|
||||||
|
} catch(err) {}
|
||||||
|
</script>
|
||||||
|
}.html_safe
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,7 +1,3 @@
|
|||||||
# Be sure to restart your server when you modify this file.
|
|
||||||
|
|
||||||
# Add new inflection rules using the following format
|
|
||||||
# (all these examples are active by default):
|
|
||||||
# ActiveSupport::Inflector.inflections do |inflect|
|
# ActiveSupport::Inflector.inflections do |inflect|
|
||||||
# inflect.plural /^(ox)$/i, '\1en'
|
# inflect.plural /^(ox)$/i, '\1en'
|
||||||
# inflect.singular /^(ox)en/i, '\1'
|
# inflect.singular /^(ox)en/i, '\1'
|
||||||
|
|||||||
@@ -1,12 +1,7 @@
|
|||||||
Danbooru::Application.routes.draw do
|
Danbooru::Application.routes.draw do
|
||||||
namespace :admin do
|
namespace :admin do
|
||||||
resources :users
|
match 'users/edit' => 'users#edit', :via => :get
|
||||||
resources :posts do
|
match 'users' => 'users#update', :via => :put
|
||||||
collection do
|
|
||||||
get :mass_edit
|
|
||||||
put :mass_update
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
resources :advertisements
|
resources :advertisements
|
||||||
resources :advertisement_hits
|
resources :advertisement_hits
|
||||||
|
|||||||
@@ -1,8 +1,4 @@
|
|||||||
require 'test_helper'
|
require 'test_helper'
|
||||||
|
|
||||||
class AdvertisementsControllerTest < ActionController::TestCase
|
class AdvertisementsControllerTest < ActionController::TestCase
|
||||||
# Replace this with your real tests.
|
|
||||||
test "the truth" do
|
|
||||||
assert true
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user