added new landing page
This commit is contained in:
9
.gitignore
vendored
9
.gitignore
vendored
@@ -1,14 +1,9 @@
|
|||||||
.bundle
|
.bundle
|
||||||
config/database.yml
|
config/database.yml
|
||||||
config/danbooru_local_config.rb
|
config/danbooru_local_config.rb
|
||||||
lib/danbooru_image_resizer/*.so
|
|
||||||
lib/danbooru_image_resizer/*.o
|
|
||||||
lib/danbooru_image_resizer/*.bundle
|
|
||||||
lib/danbooru_image_resizer/*.log
|
|
||||||
db/*.sqlite3
|
db/*.sqlite3
|
||||||
log/*.log
|
log/*.log
|
||||||
tmp/**/*
|
tmp/*
|
||||||
tmp/upload_*
|
|
||||||
public/data
|
public/data
|
||||||
vendor/cache/*.gem
|
vendor/cache/*.gem
|
||||||
.sass-cache
|
.sass-cache
|
||||||
@@ -16,3 +11,5 @@ vendor/cache/*.gem
|
|||||||
coverage
|
coverage
|
||||||
*~
|
*~
|
||||||
*.swp
|
*.swp
|
||||||
|
tmp/*.jpg
|
||||||
|
tmp/*.png
|
||||||
|
|||||||
@@ -8,17 +8,20 @@ $(document).ready(function() {
|
|||||||
$("table.striped tbody tr:even").addClass("even");
|
$("table.striped tbody tr:even").addClass("even");
|
||||||
$("table.striped tbody tr:odd").addClass("odd");
|
$("table.striped tbody tr:odd").addClass("odd");
|
||||||
|
|
||||||
// More link
|
if ($("#site-map-link").length > 0) {
|
||||||
$("#site-map-link").click(function(e) {
|
// More link
|
||||||
$("#more-links").toggle();
|
$("#site-map-link").click(function(e) {
|
||||||
e.preventDefault();
|
$("#more-links").toggle();
|
||||||
e.stopPropagation();
|
e.preventDefault();
|
||||||
});
|
e.stopPropagation();
|
||||||
$("#more-links").hide().offset({top: $("#site-map-link").offset().top + $("#site-map-link").height() + 10, left: $("#site-map-link").offset().left});
|
});
|
||||||
|
|
||||||
$(document).click(function(e) {
|
$("#more-links").hide().offset({top: $("#site-map-link").offset().top + $("#site-map-link").height() + 10, left: $("#site-map-link").offset().left});
|
||||||
$("#more-links").hide();
|
|
||||||
});
|
$(document).click(function(e) {
|
||||||
|
$("#more-links").hide();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// Ajax links
|
// Ajax links
|
||||||
$("a[data-remote=true]").click(function(e) {
|
$("a[data-remote=true]").click(function(e) {
|
||||||
|
|||||||
8
app/assets/javascripts/landings.js
Normal file
8
app/assets/javascripts/landings.js
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
$(function() {
|
||||||
|
$("#c-landings div.data").each(function(i, div) {
|
||||||
|
var $div = $(div);
|
||||||
|
var $image = $div.prev();
|
||||||
|
|
||||||
|
$div.width($image.width() - 10).height($image.height() - 10).offset({top: $image.position().top, left: $image.position().left});
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -32,3 +32,7 @@ a.login {
|
|||||||
a.forum-updated {
|
a.forum-updated {
|
||||||
font-style: italic;
|
font-style: italic;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
a.wiki-link {
|
||||||
|
margin-right: 0.3em;
|
||||||
|
}
|
||||||
44
app/assets/stylesheets/specific/landing.css.scss
Normal file
44
app/assets/stylesheets/specific/landing.css.scss
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -26,6 +26,14 @@ article.post-preview {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
div.text-post-medium {
|
||||||
|
height: 150px;
|
||||||
|
width: 480px;
|
||||||
|
text-align: center;
|
||||||
|
line-height: 480px;
|
||||||
|
border: 1px solid #CCC;
|
||||||
|
}
|
||||||
|
|
||||||
article.post-preview.blacklisted-active {
|
article.post-preview.blacklisted-active {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|||||||
6
app/controllers/landings_controller.rb
Normal file
6
app/controllers/landings_controller.rb
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
class LandingsController < ApplicationController
|
||||||
|
def show
|
||||||
|
@explorer = PopularPostExplorer.new
|
||||||
|
render :layout => "blank"
|
||||||
|
end
|
||||||
|
end
|
||||||
2
app/helpers/landings_helper.rb
Normal file
2
app/helpers/landings_helper.rb
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
module LandingsHelper
|
||||||
|
end
|
||||||
30
app/logical/popular_post_explorer.rb
Normal file
30
app/logical/popular_post_explorer.rb
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
class PopularPostExplorer
|
||||||
|
attr_reader :col1, :col2, :posts
|
||||||
|
|
||||||
|
def initialize
|
||||||
|
load_posts
|
||||||
|
sort_posts
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def load_posts
|
||||||
|
# Post.tag_match("order:rank").where("image_width >= ?", Danbooru.config.medium_image_width).limit(5).offset(offset)
|
||||||
|
@posts = Post.where("image_width >= ?", Danbooru.config.medium_image_width).limit(50)
|
||||||
|
end
|
||||||
|
|
||||||
|
def sort_posts
|
||||||
|
height1, height2 = 0, 0
|
||||||
|
@col1, @col2 = [], []
|
||||||
|
|
||||||
|
posts.each do |post|
|
||||||
|
if height1 > height2
|
||||||
|
@col2 << post
|
||||||
|
height2 += post.medium_image_height
|
||||||
|
else
|
||||||
|
@col1 << post
|
||||||
|
height1 += post.medium_image_height
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -473,6 +473,29 @@ class Post < ActiveRecord::Base
|
|||||||
def has_tag?(tag)
|
def has_tag?(tag)
|
||||||
tag_string =~ /(?:^| )#{tag}(?:$| )/
|
tag_string =~ /(?:^| )#{tag}(?:$| )/
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def essential_tag_string
|
||||||
|
tag_categories = Tag.categories_for(tag_array)
|
||||||
|
tag_array.each do |tag|
|
||||||
|
if tag_categories[tag] == Danbooru.config.tag_category_mapping["copyright"]
|
||||||
|
return "copyright: " + tag
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
tag_array.each do |tag|
|
||||||
|
if tag_categories[tag] == Danbooru.config.tag_category_mapping["character"]
|
||||||
|
return "character: " + tag
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
tag_array.each do |tag|
|
||||||
|
if tag_categories[tag] == Danbooru.config.tag_category_mapping["artist"]
|
||||||
|
return "artist: " + tag
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return tag_array.first
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
module FavoriteMethods
|
module FavoriteMethods
|
||||||
|
|||||||
@@ -33,6 +33,13 @@ class PostPresenter < Presenter
|
|||||||
PostPresenter.preview(@post)
|
PostPresenter.preview(@post)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def medium_image_html(template, options = {})
|
||||||
|
return "" if @post.is_deleted? && !CurrentUser.user.is_janitor?
|
||||||
|
return "" if !Danbooru.config.can_user_see_post?(CurrentUser.user, @post)
|
||||||
|
|
||||||
|
template.render("posts/partials/show/medium_image", :post => @post)
|
||||||
|
end
|
||||||
|
|
||||||
def image_html(template)
|
def image_html(template)
|
||||||
return template.content_tag("p", "This image was deleted.") if @post.is_deleted? && !CurrentUser.user.is_janitor?
|
return template.content_tag("p", "This image was deleted.") if @post.is_deleted? && !CurrentUser.user.is_janitor?
|
||||||
return template.content_tag("p", "You need a privileged account to see this image.") if !Danbooru.config.can_user_see_post?(CurrentUser.user, @post)
|
return template.content_tag("p", "You need a privileged account to see this image.") if !Danbooru.config.can_user_see_post?(CurrentUser.user, @post)
|
||||||
|
|||||||
@@ -36,12 +36,13 @@ private
|
|||||||
html << %{<li class="category-#{categories[tag]}">}
|
html << %{<li class="category-#{categories[tag]}">}
|
||||||
current_query = template.params[:tags] || ""
|
current_query = template.params[:tags] || ""
|
||||||
|
|
||||||
|
if categories[tag] == 1
|
||||||
|
html << %{<a class="wiki-link" href="/artists/show_or_new?name=#{u(tag)}">?</a> }
|
||||||
|
else
|
||||||
|
html << %{<a class="wiki-link" href="/wiki_pages?title=#{u(tag)}">?</a> }
|
||||||
|
end
|
||||||
|
|
||||||
if CurrentUser.user.is_privileged?
|
if CurrentUser.user.is_privileged?
|
||||||
if categories[tag] == 1
|
|
||||||
html << %{<a href="/artists/show_or_new?name=#{u(tag)}">?</a> }
|
|
||||||
else
|
|
||||||
html << %{<a href="/wiki_pages?title=#{u(tag)}">?</a> }
|
|
||||||
end
|
|
||||||
html << %{<a href="/posts?tags=#{u(current_query)}+#{u(tag)}" class="search-inc-tag">+</a> }
|
html << %{<a href="/posts?tags=#{u(current_query)}+#{u(tag)}" class="search-inc-tag">+</a> }
|
||||||
html << %{<a href="/posts?tags=#{u(current_query)}+-#{u(tag)}" class="search-exl-tag">–</a> }
|
html << %{<a href="/posts?tags=#{u(current_query)}+-#{u(tag)}" class="search-exl-tag">–</a> }
|
||||||
end
|
end
|
||||||
|
|||||||
1
app/views/landings/_image.html.erb
Normal file
1
app/views/landings/_image.html.erb
Normal file
@@ -0,0 +1 @@
|
|||||||
|
<div class="landing-post"><a href="<%= post_path(post) %>"><img src="<%= post.medium_file_url %>" width="<%= post.medium_image_width %>" height="<%= post.medium_image_height %>"><div class="data"><p><%= post.essential_tag_string %></p></div></a></div>
|
||||||
8
app/views/landings/_tag.html.erb
Normal file
8
app/views/landings/_tag.html.erb
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
<!--
|
||||||
|
- tag
|
||||||
|
-->
|
||||||
|
<div>
|
||||||
|
<% @explorer.search(tag, 300).each do |post| %>
|
||||||
|
<%= post.presenter.medium_image_html(self, :max_height => 300) %>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
||||||
22
app/views/landings/show.html.erb
Normal file
22
app/views/landings/show.html.erb
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
<div id="c-landings">
|
||||||
|
<div id="a-show">
|
||||||
|
<h1><%= link_to Danbooru.config.app_name, posts_path %></h1>
|
||||||
|
<p class="slogan">Find good art fast</p>
|
||||||
|
|
||||||
|
<div class="column">
|
||||||
|
<% @explorer.col1.each do |post| %>
|
||||||
|
<%= render "image", :post => post %>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="column">
|
||||||
|
<% @explorer.col2.each do |post| %>
|
||||||
|
<%= render "image", :post => post %>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<% content_for(:page_title) do %>
|
||||||
|
<%= Danbooru.config.app_name %>
|
||||||
|
<% end %>
|
||||||
17
app/views/layouts/blank.html.erb
Normal file
17
app/views/layouts/blank.html.erb
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
<!doctype html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title><%= yield :page_title %></title>
|
||||||
|
<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon">
|
||||||
|
<link rel="top" title="<%= Danbooru.config.app_name %>" href="/">
|
||||||
|
<%= csrf_meta_tag %>
|
||||||
|
<%= auto_discovery_link_tag :atom, posts_path(:format => "atom", :tags => params[:tags]) %>
|
||||||
|
<%= stylesheet_link_tag "application", :media => "screen" %>
|
||||||
|
<%= javascript_include_tag "application" %>
|
||||||
|
<%= Danbooru.config.custom_html_header_content %>
|
||||||
|
<%= yield :html_header %>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<%= yield :layout %>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -27,7 +27,13 @@
|
|||||||
<% @posts.each do |post| %>
|
<% @posts.each do |post| %>
|
||||||
<article id="post-<%= post.id %>">
|
<article id="post-<%= post.id %>">
|
||||||
<aside>
|
<aside>
|
||||||
<%= link_to(image_tag(post.medium_file_url), post_path(post)) %>
|
<% if post.is_image? %>
|
||||||
|
<%= link_to(image_tag(post.medium_file_url), post_path(post)) %>
|
||||||
|
<% elsif post.is_flash? %>
|
||||||
|
<div class="text-post-medium">Flash</div>
|
||||||
|
<% else %>
|
||||||
|
<div class="text-post-medium">Download</div>
|
||||||
|
<% end %>
|
||||||
</aside>
|
</aside>
|
||||||
|
|
||||||
<section>
|
<section>
|
||||||
|
|||||||
@@ -30,11 +30,24 @@ Danbooru::Application.routes.draw do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
namespace :explore do
|
||||||
|
resources :posts, :only => [:popular, :hot] do
|
||||||
|
collection do
|
||||||
|
get :popular
|
||||||
|
get :hot
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
namespace :maintenance do
|
||||||
|
namespace :user do
|
||||||
|
resource :password_reset, :only => [:new, :create, :edit, :update]
|
||||||
|
resource :login_reminder, :only => [:new, :create]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
resources :advertisements do
|
resources :advertisements do
|
||||||
resources :hits, :controller => "advertisement_hits", :only => [:create]
|
resources :hits, :controller => "advertisement_hits", :only => [:create]
|
||||||
end
|
end
|
||||||
resource :source, :only => [:show]
|
|
||||||
resource :related_tag, :only => [:show]
|
|
||||||
resources :artists do
|
resources :artists do
|
||||||
member do
|
member do
|
||||||
put :revert
|
put :revert
|
||||||
@@ -60,12 +73,13 @@ Danbooru::Application.routes.draw do
|
|||||||
end
|
end
|
||||||
resource :dtext_preview, :only => [:create]
|
resource :dtext_preview, :only => [:create]
|
||||||
resources :favorites
|
resources :favorites
|
||||||
resources :forum_topics
|
|
||||||
resources :forum_posts do
|
resources :forum_posts do
|
||||||
collection do
|
collection do
|
||||||
get :search
|
get :search
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
resources :forum_topics
|
||||||
|
resources :ip_bans
|
||||||
resources :janitor_trials do
|
resources :janitor_trials do
|
||||||
collection do
|
collection do
|
||||||
get :test
|
get :test
|
||||||
@@ -76,13 +90,12 @@ Danbooru::Application.routes.draw do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
resources :jobs
|
resources :jobs
|
||||||
resources :ip_bans
|
resource :landing
|
||||||
resources :mod_actions
|
resources :mod_actions
|
||||||
resources :notes do
|
resources :notes do
|
||||||
collection do
|
collection do
|
||||||
get :search
|
get :search
|
||||||
end
|
end
|
||||||
|
|
||||||
member do
|
member do
|
||||||
put :revert
|
put :revert
|
||||||
end
|
end
|
||||||
@@ -105,14 +118,16 @@ Danbooru::Application.routes.draw do
|
|||||||
put :revert
|
put :revert
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
resources :post_appeals, :only => [:new, :index, :create]
|
||||||
|
resources :post_flags, :only => [:new, :index, :create]
|
||||||
resources :post_versions, :only => [:index, :search] do
|
resources :post_versions, :only => [:index, :search] do
|
||||||
collection do
|
collection do
|
||||||
get :search
|
get :search
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
resources :post_flags, :only => [:new, :index, :create]
|
resource :related_tag, :only => [:show]
|
||||||
resources :post_appeals, :only => [:new, :index, :create]
|
resource :session
|
||||||
resource :session
|
resource :source, :only => [:show]
|
||||||
resources :tags do
|
resources :tags do
|
||||||
collection do
|
collection do
|
||||||
get :search
|
get :search
|
||||||
@@ -147,22 +162,6 @@ Danbooru::Application.routes.draw do
|
|||||||
end
|
end
|
||||||
resources :wiki_page_versions, :only => [:index, :show]
|
resources :wiki_page_versions, :only => [:index, :show]
|
||||||
|
|
||||||
namespace :explore do
|
|
||||||
resources :posts, :only => [:popular, :hot] do
|
|
||||||
collection do
|
|
||||||
get :popular
|
|
||||||
get :hot
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
namespace :maintenance do
|
|
||||||
namespace :user do
|
|
||||||
resource :password_reset, :only => [:new, :create, :edit, :update]
|
|
||||||
resource :login_reminder, :only => [:new, :create]
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
# aliases
|
# aliases
|
||||||
resources :wpages, :controller => "wiki_pages"
|
resources :wpages, :controller => "wiki_pages"
|
||||||
resources :ftopics, :controller => "forum_topics"
|
resources :ftopics, :controller => "forum_topics"
|
||||||
@@ -172,5 +171,5 @@ Danbooru::Application.routes.draw do
|
|||||||
match "/static/site_map" => "static#site_map", :as => "site_map"
|
match "/static/site_map" => "static#site_map", :as => "site_map"
|
||||||
match "/static/terms_of_service" => "static#terms_of_service", :as => "terms_of_service"
|
match "/static/terms_of_service" => "static#terms_of_service", :as => "terms_of_service"
|
||||||
|
|
||||||
root :to => "posts#index"
|
root :to => "landings#show"
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user