Merge pull request #2879 from evazion/fix-dead-code

Eliminate dead code
This commit is contained in:
Albert Yi
2017-02-07 13:56:05 -08:00
committed by GitHub
36 changed files with 1 additions and 285 deletions
@@ -1,44 +0,0 @@
div#c-landings {
div#a-show {
padding-top: 4em;
width: 960px;
margin: auto;
h1 {
text-align: center;
font-size: 4em;
}
p.slogan {
text-align: center;
font-size: 1.5em;
font-weight: bold;
}
div.column {
width: 480px;
vertical-align: top;
float: left;
background-color: #000;
}
div.landing-post {
overflow: hidden;
}
div.landing-post:hover img {
opacity: 0.25;
}
div.landing-post:hover div.data {
opacity: 1.0;
}
div.landing-post div.data {
position: absolute;
color: white;
padding: 5px;
cursor: pointer;
}
}
}
-6
View File
@@ -1,6 +0,0 @@
class LandingsController < ApplicationController
def show
@explorer = PopularPostExplorer.new
render :layout => "blank"
end
end
@@ -15,7 +15,7 @@ module Moderator
end end
::Post.without_timeout do ::Post.without_timeout do
@posts = ::Post.order("posts.id asc").pending_or_flagged.available_for_moderation(params[:hidden]).search(:tag_match => params[:query]).paginate(params[:page], :limit => per_page) @posts = ::Post.order("posts.id asc").pending_or_flagged.available_for_moderation(params[:hidden]).tag_match(params[:query]).paginate(params[:page], :limit => per_page)
@posts.each # hack to force rails to eager load @posts.each # hack to force rails to eager load
end end
respond_with(@posts) respond_with(@posts)
-8
View File
@@ -83,14 +83,6 @@ class PostsController < ApplicationController
end end
end end
def home
if CurrentUser.user.is_anonymous?
redirect_to intro_explore_posts_path
else
redirect_to posts_path(:tags => params[:tags])
end
end
def random def random
count = Post.fast_count(params[:tags], :statement_timeout => CurrentUser.user.statement_timeout) count = Post.fast_count(params[:tags], :statement_timeout => CurrentUser.user.statement_timeout)
@post = Post.tag_match(params[:tags]).random @post = Post.tag_match(params[:tags]).random
-2
View File
@@ -1,2 +0,0 @@
module BansHelper
end
-2
View File
@@ -1,2 +0,0 @@
module CommentVotesHelper
end
-2
View File
@@ -1,2 +0,0 @@
module CommentsHelper
end
-2
View File
@@ -1,2 +0,0 @@
module FavoritesHelper
end
-2
View File
@@ -1,2 +0,0 @@
module ForumPostsHelper
end
-2
View File
@@ -1,2 +0,0 @@
module ForumTopicVisitsHelper
end
-2
View File
@@ -1,2 +0,0 @@
module JanitorTrialsHelper
end
-2
View File
@@ -1,2 +0,0 @@
module LandingsHelper
end
-2
View File
@@ -1,2 +0,0 @@
module NewsUpdatesHelper
end
-2
View File
@@ -1,2 +0,0 @@
module NotesHelper
end
-2
View File
@@ -1,2 +0,0 @@
module PostVotesHelper
end
-18
View File
@@ -40,24 +40,6 @@ module PostsHelper
render("users/common_searches", user: user, sig: sig) render("users/common_searches", user: user, sig: sig)
end end
def resize_image_links(post, user)
links = []
if post.has_large?
links << link_to("L", post.large_file_url, :id => "large-file-link")
end
if post.has_large?
links << link_to("O", post.file_url, :id => "original-file-link")
end
if links.any?
content_tag("span", raw("Resize: " + links.join(" ")))
else
nil
end
end
def post_source_tag(post) def post_source_tag(post)
if post.source =~ %r!\Ahttp://img\d+\.pixiv\.net/img/([^\/]+)/!i if post.source =~ %r!\Ahttp://img\d+\.pixiv\.net/img/([^\/]+)/!i
text = "pixiv/<wbr>#{wordbreakify($1)}".html_safe text = "pixiv/<wbr>#{wordbreakify($1)}".html_safe
-2
View File
@@ -1,2 +0,0 @@
module RelatedTagsHelper
end
-2
View File
@@ -1,2 +0,0 @@
module SessionsHelper
end
-2
View File
@@ -1,2 +0,0 @@
module TagAliasesHelper
end
-2
View File
@@ -1,2 +0,0 @@
module TagImplicationsHelper
end
-2
View File
@@ -1,2 +0,0 @@
module TagSubscriptionsHelper
end
-2
View File
@@ -1,2 +0,0 @@
module UnapprovalsHelper
end
-2
View File
@@ -1,2 +0,0 @@
module UploadsHelper
end
-2
View File
@@ -1,2 +0,0 @@
module UserFeedbackHelper
end
-14
View File
@@ -39,19 +39,5 @@ module PostSets
def presenter def presenter
raise NotImplementedError raise NotImplementedError
end end
def arbitrary_sql_order_clause(ids, table_name)
if ids.empty?
return "#{table_name}.id desc"
end
conditions = []
ids.each_with_index do |x, n|
conditions << "when #{x} then #{n}"
end
"case #{table_name}.id " + conditions.join(" ") + " end"
end
end end
end end
-4
View File
@@ -158,10 +158,6 @@ class ForumTopic < ActiveRecord::Base
(response_count / Danbooru.config.posts_per_page.to_f).ceil (response_count / Danbooru.config.posts_per_page.to_f).ceil
end end
def presenter(forum_posts)
@presenter ||= ForumTopicPresenter.new(self, forum_posts)
end
def as_json(options = {}) def as_json(options = {})
if CurrentUser.user.level < min_level if CurrentUser.user.level < min_level
options[:only] = [:id] options[:only] = [:id]
-4
View File
@@ -89,10 +89,6 @@ class Note < ActiveRecord::Base
extend SearchMethods extend SearchMethods
include ApiMethods include ApiMethods
def presenter
@presenter ||= NotePresenter.new(self)
end
def initialize_creator def initialize_creator
self.creator_id ||= CurrentUser.id self.creator_id ||= CurrentUser.id
end end
-63
View File
@@ -531,10 +531,6 @@ class Post < ActiveRecord::Base
@tag_array_was ||= Tag.scan_tags(tag_string_was) @tag_array_was ||= Tag.scan_tags(tag_string_was)
end end
def increment_tag_post_counts
Tag.where(:name => tag_array).update_all("post_count = post_count + 1") if tag_array.any?
end
def decrement_tag_post_counts def decrement_tag_post_counts
Tag.where(:name => tag_array).update_all("post_count = post_count - 1") if tag_array.any? Tag.where(:name => tag_array).update_all("post_count = post_count - 1") if tag_array.any?
end end
@@ -1476,10 +1472,6 @@ class Post < ActiveRecord::Base
end end
module NoteMethods module NoteMethods
def last_noted_at_as_integer
last_noted_at.to_i
end
def has_notes? def has_notes?
last_noted_at.present? last_noted_at.present?
end end
@@ -1616,10 +1608,6 @@ class Post < ActiveRecord::Base
where("is_deleted = ?", true) where("is_deleted = ?", true)
end end
def commented_before(date)
where("last_commented_at < ?", date).order("last_commented_at DESC")
end
def has_notes def has_notes
where("last_noted_at is not null") where("last_noted_at is not null")
end end
@@ -1636,10 +1624,6 @@ class Post < ActiveRecord::Base
end end
end end
def hidden_from_moderation
where("id IN (SELECT pd.post_id FROM post_disapprovals pd WHERE pd.user_id = ?)", CurrentUser.id)
end
def raw_tag_match(tag) def raw_tag_match(tag)
where("posts.tag_index @@ to_tsquery('danbooru', E?)", tag.to_escaped_for_tsquery) where("posts.tag_index @@ to_tsquery('danbooru', E?)", tag.to_escaped_for_tsquery)
end end
@@ -1656,53 +1640,6 @@ class Post < ActiveRecord::Base
PostQueryBuilder.new(query).build PostQueryBuilder.new(query).build
end end
end end
def positive
where("score > 1")
end
def negative
where("score < -1")
end
def updater_name_matches(name)
where("updater_id = (select _.id from users _ where lower(_.name) = ?)", name.mb_chars.downcase)
end
def after_id(num)
if num.present?
where("id > ?", num.to_i).reorder("id asc")
else
where("true")
end
end
def before_id(num)
if num.present?
where("id < ?", num.to_i).reorder("id desc")
else
where("true")
end
end
def search(params)
q = where("true")
return q if params.blank?
if params[:before_id].present?
q = q.before_id(params[:before_id].to_i)
end
if params[:after_id].present?
q = q.after_id(params[:after_id].to_i)
end
if params[:tag_match].present?
q = q.tag_match(params[:tag_match])
end
q
end
end end
module PixivMethods module PixivMethods
-4
View File
@@ -56,10 +56,6 @@ class PostVersion < ActiveRecord::Base
@tag_array ||= tags.scan(/\S+/) @tag_array ||= tags.scan(/\S+/)
end end
def presenter
PostVersionPresenter.new(self)
end
def reload def reload
@tag_array = nil @tag_array = nil
super super
-22
View File
@@ -79,12 +79,6 @@ class Tag < ActiveRecord::Base
end end
end end
module ViewCountMethods
def increment_view_count(name)
Cache.incr("tvc:#{Cache.sanitize(name)}")
end
end
module CategoryMethods module CategoryMethods
module ClassMethods module ClassMethods
def categories def categories
@@ -694,20 +688,6 @@ class Tag < ActiveRecord::Base
end end
end end
module SuggestionMethods
def find_suggestions(query)
query_tokens = query.split(/_/)
if query_tokens.size == 2
search_for = query_tokens.reverse.join("_").to_escaped_for_sql_like
else
search_for = "%" + query.to_escaped_for_sql_like + "%"
end
Tag.where(["name LIKE ? ESCAPE E'\\\\' AND post_count > 0 AND name <> ?", search_for, query]).order("post_count DESC").limit(6).select("name").map(&:name).sort
end
end
module SearchMethods module SearchMethods
def name_matches(name) def name_matches(name)
where("tags.name LIKE ? ESCAPE E'\\\\'", name.mb_chars.downcase.to_escaped_for_sql_like) where("tags.name LIKE ? ESCAPE E'\\\\'", name.mb_chars.downcase.to_escaped_for_sql_like)
@@ -789,12 +769,10 @@ class Tag < ActiveRecord::Base
include ApiMethods include ApiMethods
include CountMethods include CountMethods
extend ViewCountMethods
include CategoryMethods include CategoryMethods
extend StatisticsMethods extend StatisticsMethods
extend NameMethods extend NameMethods
extend ParseMethods extend ParseMethods
include RelationMethods include RelationMethods
extend SuggestionMethods
extend SearchMethods extend SearchMethods
end end
-8
View File
@@ -1,8 +0,0 @@
class ForumTopicPresenter < Presenter
attr_reader :forum_topic, :forum_posts
def initialize(forum_topic, forum_posts)
@forum_posts = forum_posts
@forum_topic = forum_topic
end
end
-9
View File
@@ -1,9 +0,0 @@
class NotePresenter
def initialize(note)
@note = note
end
def formatted_body
note.body.gsub(/<tn>(.+?)<\/tn>/m, '<br><p class="tn">\1</p>').gsub(/\n/, '<br>')
end
end
-20
View File
@@ -1,20 +0,0 @@
class PostVersionPresenter < Presenter
attr_reader :post_version
def initialize(post_version)
@post_version = post_version
end
def changes
html = []
html << post_version.tag_array
html << "<ins>source:#{h(post_version.source)}</ins>" if post_version.source
html << "<ins>rating:#{h(post_version.rating)}</ins>" if post_version.rating
html << "<ins>parent:#{post_version.parent_id}</ins>" if post_version.parent_id
html.join(" ").html_safe
end
def updater_name
User.id_to_name(post_version.updater_id)
end
end
@@ -33,22 +33,6 @@ module Danbooru
connection.__send__(method_name, sanitize_sql_array([sql, *params])) connection.__send__(method_name, sanitize_sql_array([sql, *params]))
end end
end end
def arbitrary_sql_order_clause(ids, table_name = nil)
table_name = self.class.table_name if table_name.nil?
if ids.empty?
return "#{table_name}.id desc"
end
conditions = []
ids.each_with_index do |x, n|
conditions << "when #{x} then #{n}"
end
"case #{table_name}.id " + conditions.join(" ") + " end"
end
end end
end end
end end
-4
View File
@@ -12,10 +12,6 @@ module Danbooru
def to_escaped_for_tsquery def to_escaped_for_tsquery
"'#{gsub(/\0/, '').gsub(/'/, '\0\0').gsub(/\\/, '\0\0\0\0')}'" "'#{gsub(/\0/, '').gsub(/'/, '\0\0').gsub(/\\/, '\0\0\0\0')}'"
end end
def to_escaped_js
return self.gsub(/\\/, '\0\0').gsub(/['"]/) {|m| "\\#{m}"}.gsub(/\r\n|\r|\n/, '\\n')
end
end end
end end
end end
-2
View File
@@ -160,7 +160,6 @@ Rails.application.routes.draw do
end end
end end
resources :jobs resources :jobs
resource :landing
resources :mod_actions resources :mod_actions
resources :news_updates resources :news_updates
resources :notes do resources :notes do
@@ -197,7 +196,6 @@ Rails.application.routes.draw do
end end
resource :votes, :controller => "post_votes", :only => [:create, :destroy] resource :votes, :controller => "post_votes", :only => [:create, :destroy]
collection do collection do
get :home
get :random get :random
end end
member do member do