added new landing page

This commit is contained in:
albert 2011-10-28 19:21:44 -04:00
parent 47abe4eacd
commit 40745a2e6e
18 changed files with 234 additions and 48 deletions

9
.gitignore vendored
View File

@ -1,14 +1,9 @@
.bundle
config/database.yml
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
log/*.log
tmp/**/*
tmp/upload_*
tmp/*
public/data
vendor/cache/*.gem
.sass-cache
@ -16,3 +11,5 @@ vendor/cache/*.gem
coverage
*~
*.swp
tmp/*.jpg
tmp/*.png

View File

@ -8,17 +8,20 @@ $(document).ready(function() {
$("table.striped tbody tr:even").addClass("even");
$("table.striped tbody tr:odd").addClass("odd");
// More link
$("#site-map-link").click(function(e) {
$("#more-links").toggle();
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();
});
if ($("#site-map-link").length > 0) {
// More link
$("#site-map-link").click(function(e) {
$("#more-links").toggle();
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();
});
}
// Ajax links
$("a[data-remote=true]").click(function(e) {

View 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});
});
});

View File

@ -31,4 +31,8 @@ a.login {
a.forum-updated {
font-style: italic;
}
a.wiki-link {
margin-right: 0.3em;
}

View 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;
}
}
}

View File

@ -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 {
display: none;
}

View File

@ -0,0 +1,6 @@
class LandingsController < ApplicationController
def show
@explorer = PopularPostExplorer.new
render :layout => "blank"
end
end

View File

@ -0,0 +1,2 @@
module LandingsHelper
end

View 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

View File

@ -473,6 +473,29 @@ class Post < ActiveRecord::Base
def has_tag?(tag)
tag_string =~ /(?:^| )#{tag}(?:$| )/
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
module FavoriteMethods

View File

@ -32,6 +32,13 @@ class PostPresenter < Presenter
def preview_html
PostPresenter.preview(@post)
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)
return template.content_tag("p", "This image was deleted.") if @post.is_deleted? && !CurrentUser.user.is_janitor?

View File

@ -36,12 +36,13 @@ private
html << %{<li class="category-#{categories[tag]}">}
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 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-exl-tag">&ndash;</a> }
end

View 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>

View 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>

View 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 %>

View 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>

View File

@ -27,7 +27,13 @@
<% @posts.each do |post| %>
<article id="post-<%= post.id %>">
<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>
<section>

View File

@ -30,11 +30,24 @@ Danbooru::Application.routes.draw do
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 :hits, :controller => "advertisement_hits", :only => [:create]
end
resource :source, :only => [:show]
resource :related_tag, :only => [:show]
resources :artists do
member do
put :revert
@ -60,12 +73,13 @@ Danbooru::Application.routes.draw do
end
resource :dtext_preview, :only => [:create]
resources :favorites
resources :forum_topics
resources :forum_posts do
collection do
get :search
end
end
resources :forum_topics
resources :ip_bans
resources :janitor_trials do
collection do
get :test
@ -76,13 +90,12 @@ Danbooru::Application.routes.draw do
end
end
resources :jobs
resources :ip_bans
resource :landing
resources :mod_actions
resources :notes do
collection do
get :search
end
member do
put :revert
end
@ -105,14 +118,16 @@ Danbooru::Application.routes.draw do
put :revert
end
end
resources :post_appeals, :only => [:new, :index, :create]
resources :post_flags, :only => [:new, :index, :create]
resources :post_versions, :only => [:index, :search] do
collection do
get :search
end
end
resources :post_flags, :only => [:new, :index, :create]
resources :post_appeals, :only => [:new, :index, :create]
resource :session
resource :related_tag, :only => [:show]
resource :session
resource :source, :only => [:show]
resources :tags do
collection do
get :search
@ -147,22 +162,6 @@ Danbooru::Application.routes.draw do
end
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
resources :wpages, :controller => "wiki_pages"
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/terms_of_service" => "static#terms_of_service", :as => "terms_of_service"
root :to => "posts#index"
root :to => "landings#show"
end