wip: mobile layout, remove is_deleted constraint by default

This commit is contained in:
albert
2012-01-26 14:33:46 -05:00
parent d5c98dd0c4
commit ea16f2ce37
11 changed files with 135 additions and 65 deletions

View File

@@ -53,46 +53,3 @@ $basefont: 100%;
*vertical-align: auto;
}
@mixin vertical-gradient ($startColor: #555, $endColor: #333) {
background-color: $endColor;
background-repeat: repeat-x;
background-image: -moz-linear-gradient(top, $startColor, $endColor); // FF 3.6+
background-image: -ms-linear-gradient(top, $startColor, $endColor); // IE10
background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0%, $startColor), color-stop(100%, $endColor)); // Safari 4+, Chrome 2+
background-image: -webkit-linear-gradient(top, $startColor, $endColor); // Safari 5.1+, Chrome 10+
background-image: -o-linear-gradient(top, $startColor, $endColor); // Opera 11.10
background-image: linear-gradient(top, $startColor, $endColor); // The standard
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#{$startColor}', endColorstr='#{$endColor}', GradientType=0); // IE9 and down
}
@mixin gradientBar($primaryColor, $secondaryColor) {
@include vertical-gradient($primaryColor, $secondaryColor);
text-shadow: 0 -1px 0 rgba(0,0,0,0.25);
border-color: $secondaryColor $secondaryColor darken($secondaryColor, 15%);
border-color: rgba(0,0,0,0.1) rgba(0,0,0,0.1) opacify(rgba(0,0,0,0.1), 0.15);
}
@mixin transition($transition) {
-webkit-transition: $transition;
-moz-transition: $transition;
-ms-transition: $transition;
-o-transition: $transition;
transition: $transition;
}
@mixin vertical-three-colors-gradient($startColor: #00b3ee, $midColor: #7a43b6, $colorStop: 50%, $endColor: #c3325f) {
background-color: $endColor;
background-repeat: no-repeat;
background-image: -webkit-gradient(linear, 0 0, 0 100%, from($startColor), color-stop($colorStop, $midColor), to($endColor));
background-image: -webkit-linear-gradient($startColor, $midColor $colorStop, $endColor);
background-image: -moz-linear-gradient($startColor, $midColor $colorStop, $endColor);
background-image: -ms-linear-gradient($startColor, $midColor $colorStop, $endColor);
background-image: -o-linear-gradient($startColor, $midColor $colorStop, $endColor);
background-image: linear-gradient($startColor, $midColor $colorStop, $endColor);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#{$startColor}', endColorstr='#{$endColor}', GradientType=0); // IE9 and down, gets no color-stop at all the proper fallback
}
// Reset filters for IE
@mixin reset-filter() {
filter: progid:DXImageTransform.Microsoft.gradient(enabled = false);
}

View File

@@ -0,0 +1,3 @@
body {
width: 100%;
}

View File

@@ -0,0 +1,4 @@
div#page {
overflow: visible;
margin: 0 5px;
}

View File

@@ -0,0 +1,33 @@
@import "../common/000_vars.css.scss";
header#top {
h1 {
font-size: 2.5em;
margin: 5px 5px 0 5px;
}
menu {
margin-top: -2px;
background: $menu_color;
padding: 3px 10px;
li {
margin: 0;
padding: 0;
}
li a {
padding: 6px 10px;
}
}
menu.main {
margin-top: 0px;
background: white;
li.current a {
background: $menu_color;
font-weight: bold;
}
}
}

View File

@@ -1,3 +1,2 @@
div.paginator {
font-size: 3em;
}

View File

@@ -1,15 +1,12 @@
a.search-inc-tag {
display: none;
}
@import "../common/000_vars.css.scss";
a.search-exl-tag {
display: none;
}
.post-count {
display: none;
}
section#mode-box {
display: none;
article.post-preview {
height: 150px;
width: 150px;
margin-right: 5px;
margin-bottom: 5px;
float: left;
text-align: center;
vertical-align: middle;
@include inline-block;
}

View File

@@ -0,0 +1,35 @@
module Mobile
class PostsController < ApplicationController
before_filter :member_only, :except => [:show, :index]
respond_to :html
rescue_from PostSets::SearchError, :with => :search_error
layout "mobile"
def index
@post_set = PostSets::Post.new(tag_query, params[:page])
@posts = @post_set.posts
end
def show
@post = Post.find(params[:id])
end
private
def search_error(exception)
@exception = exception
render :action => "error"
end
def tag_query
params[:tags] || (params[:post] && params[:post][:tags])
end
def save_recent_tags
if tag_query
tags = Tag.scan_tags(tag_query)
tags = TagAlias.to_aliased(tags) + Tag.scan_tags(session[:recent_tags])
session[:recent_tags] = tags.uniq.slice(0, 40).join(" ")
end
end
end
end

View File

@@ -661,8 +661,9 @@ class Post < ActiveRecord::Base
q = Tag.parse_query(q)
end
constraint = false
relation = Post.scoped
relation = add_range_relation(q[:post_id], "posts.id", relation)
relation = add_range_relation(q[:mpixels], "posts.width * posts.height / 1000000.0", relation)
relation = add_range_relation(q[:width], "posts.image_width", relation)
@@ -686,10 +687,6 @@ class Post < ActiveRecord::Base
relation = relation.where("posts.is_flagged = TRUE")
elsif q[:status] == "deleted"
relation = relation.where("posts.is_deleted = TRUE")
elsif q[:status] == "all" || q[:status] == "any"
# do nothing
else
relation = relation.where("posts.is_deleted <> TRUE")
end
if q[:source]

View File

@@ -3,12 +3,39 @@
<head>
<title><%= yield :page_title %></title>
<%= csrf_meta_tag %>
<%= stylesheet_link_tag "mobile", :media => "screen" %>
<%= javascript_include_tag "mobile" %>
<%= stylesheet_link_tag "application", :media => "screen" %>
<%= stylesheet_link_tag "mobile", :media => "only screen and (max-width: 480px), only screen and (max-device-width: 480px)" %>
<%= javascript_include_tag "application" %>
<meta name="viewport" content="width=device-width, initial-scale=1">
<%= yield :html_header %>
</head>
<body>
<div id="main">
<header id="top">
<%= render "news_updates/listing" %>
<h1><%= link_to Danbooru.config.app_name, "/" %></h1>
<nav>
<%= render "layouts/main_links" %>
<%= yield :secondary_links %>
</nav>
<%= render "layouts/more_links" %>
</header>
<div id="page">
<%- if flash[:notice] -%>
<div class="ui-corner-all ui-state-highlight" id="notice"><%= flash[:notice] %></div>
<%- else -%>
<div class="ui-corner-all ui-state-highlight" id="notice" style="display: none;"></div>
<%- end -%>
<%= yield :layout %>
</div>
<footer>
<%= yield :page_footer_content %>
</footer>
<%= render "static/footer" %>
</body>
</html>

View File

@@ -0,0 +1,14 @@
<div id="c-posts">
<div id="a-index">
<%= render "posts/partials/index/posts", :post_set => @post_set %>
<%= render "posts/partials/common/secondary_links" %>
</div>
</div>
<% content_for(:page_title) do %>
<% if @post_set.tag_string.present? %>
<%= @post_set.tag_string %> - <%= Danbooru.config.app_name %>
<% else %>
<%= Danbooru.config.app_name %>
<% end %>
<% end %>

View File

@@ -176,6 +176,10 @@ Danbooru::Application.routes.draw do
end
resources :wiki_page_versions, :only => [:index, :show]
namespace :mobile do
resources :posts
end
# aliases
resources :wpages, :controller => "wiki_pages"
resources :ftopics, :controller => "forum_topics"