add favorite/unfavorite links to mobile page

This commit is contained in:
r888888888
2014-09-05 16:46:22 -07:00
parent 719343cea5
commit 0e203c5cda
4 changed files with 30 additions and 1 deletions

View File

@@ -51,8 +51,14 @@ img#image {
margin-top: 5px; margin-top: 5px;
} }
div#tags { div#options {
margin-top: 10px; margin-top: 10px;
font-size: 24pt;
font-weight: bold;
}
div#tags {
margin-top: 30px;
li { li {
margin: 10px 0; margin: 10px 0;

View File

@@ -24,10 +24,22 @@ class FavoritesController < ApplicationController
else else
@error_msg = "You can only keep up to #{CurrentUser.favorite_limit} favorites. Upgrade your account to save more." @error_msg = "You can only keep up to #{CurrentUser.favorite_limit} favorites. Upgrade your account to save more."
end end
respond_with(@post) do |format|
format.html do
redirect_to(mobile_post_path(@post))
end
end
end end
def destroy def destroy
@post = Post.find(params[:id]) @post = Post.find(params[:id])
@post.remove_favorite!(CurrentUser.user) @post.remove_favorite!(CurrentUser.user)
respond_with(@post) do |format|
format.html do
redirect_to(mobile_post_path(@post))
end
end
end end
end end

View File

@@ -5,6 +5,8 @@
<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon"> <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon">
<%= csrf_meta_tag %> <%= csrf_meta_tag %>
<%= stylesheet_link_tag "mobile", :media => "screen" %> <%= 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 %> <%= Danbooru.config.custom_html_header_content %>
<%= yield :html_header %> <%= yield :html_header %>
</head> </head>

View File

@@ -5,6 +5,15 @@
<%= @post.presenter.image_html(self) %> <%= @post.presenter.image_html(self) %>
<div id="options">
<% 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) %>
</div>
<div id="tags"> <div id="tags">
<%= @post.presenter.tag_list_html(self, :name_only => true, :path_prefix => "/m/posts") %> <%= @post.presenter.tag_list_html(self, :name_only => true, :path_prefix => "/m/posts") %>
</div> </div>