From 0e203c5cda3c3fa3ac6fdb56089a69473888eb72 Mon Sep 17 00:00:00 2001 From: r888888888 Date: Fri, 5 Sep 2014 16:46:22 -0700 Subject: [PATCH] add favorite/unfavorite links to mobile page --- app/assets/stylesheets/mobile.css.scss | 8 +++++++- app/controllers/favorites_controller.rb | 12 ++++++++++++ app/views/layouts/mobile.html.erb | 2 ++ app/views/mobile/posts/show.html.erb | 9 +++++++++ 4 files changed, 30 insertions(+), 1 deletion(-) diff --git a/app/assets/stylesheets/mobile.css.scss b/app/assets/stylesheets/mobile.css.scss index 2f4220889..7d5091d30 100644 --- a/app/assets/stylesheets/mobile.css.scss +++ b/app/assets/stylesheets/mobile.css.scss @@ -51,8 +51,14 @@ img#image { margin-top: 5px; } -div#tags { +div#options { margin-top: 10px; + font-size: 24pt; + font-weight: bold; +} + +div#tags { + margin-top: 30px; li { margin: 10px 0; diff --git a/app/controllers/favorites_controller.rb b/app/controllers/favorites_controller.rb index bc360952e..e794c0094 100644 --- a/app/controllers/favorites_controller.rb +++ b/app/controllers/favorites_controller.rb @@ -24,10 +24,22 @@ class FavoritesController < ApplicationController else @error_msg = "You can only keep up to #{CurrentUser.favorite_limit} favorites. Upgrade your account to save more." end + + respond_with(@post) do |format| + format.html do + redirect_to(mobile_post_path(@post)) + end + end end def destroy @post = Post.find(params[:id]) @post.remove_favorite!(CurrentUser.user) + + respond_with(@post) do |format| + format.html do + redirect_to(mobile_post_path(@post)) + end + end end end diff --git a/app/views/layouts/mobile.html.erb b/app/views/layouts/mobile.html.erb index bf1349edb..09c50688e 100644 --- a/app/views/layouts/mobile.html.erb +++ b/app/views/layouts/mobile.html.erb @@ -5,6 +5,8 @@ <%= csrf_meta_tag %> <%= stylesheet_link_tag "mobile", :media => "screen" %> + <%= javascript_include_tag "jquery-1.10.1.min.js" %> + <%= javascript_include_tag "rails.js" %> <%= Danbooru.config.custom_html_header_content %> <%= yield :html_header %> diff --git a/app/views/mobile/posts/show.html.erb b/app/views/mobile/posts/show.html.erb index 0775568c8..e498ce6e4 100644 --- a/app/views/mobile/posts/show.html.erb +++ b/app/views/mobile/posts/show.html.erb @@ -5,6 +5,15 @@ <%= @post.presenter.image_html(self) %> +
+ <% if @post.favorited_by?(CurrentUser.user.id) %> + <%= link_to "Unfavorite", favorite_path(@post), :method => :delete %> | + <% else %> + <%= link_to "Favorite", favorites_path(:post_id => @post.id), :method => :post %> | + <% end %> + <%= link_to "Non-mobile Version", post_path(@post.id) %> +
+
<%= @post.presenter.tag_list_html(self, :name_only => true, :path_prefix => "/m/posts") %>