Skip to content

Commit

Permalink
Unmark a content as read
Browse files Browse the repository at this point in the history
  • Loading branch information
nono committed Apr 23, 2011
1 parent 2325107 commit 364c888
Show file tree
Hide file tree
Showing 13 changed files with 130 additions and 9 deletions.
25 changes: 25 additions & 0 deletions app/controllers/readings_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Encoding: utf-8
#
class ReadingsController < ApplicationController
before_filter :authenticate_account!
before_filter :find_node, :only => [:destroy]

def index
end

def destroy
@node.unread_by(current_account.id)
respond_to do |wants|
wants.js { render :nothing => true }
wants.html { redirect_to_content @node.content }
end
end

protected

def find_node
@node = Node.find(params[:id])
enforce_tag_permission(@node.content)
end

end
13 changes: 9 additions & 4 deletions app/helpers/node_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -104,20 +104,25 @@ def posted_by(content, user_link=nil)
end

def read_it(content)
node = content.node
link = link_to_unless_current("Lire la suite", path_for_content(content)) { "" }
nb_comments = content_tag(:span, pluralize(content.node.try(:comments_count), "commentaire"), :class => "nb_comments")
nb_comments = content_tag(:span, pluralize(node.try(:comments_count), "commentaire"), :class => "nb_comments")
if current_account
status = content.node.read_status(current_account)
status = node.read_status(current_account)
visit = case status
when :not_read then ", non visité"
when :new_comments then ", Nouveaux !"
else ", déjà visité"
end
visit = content_tag(:span, visit, :class => "visit")
else
status = "anonymous_reader"
status = :anonymous_reader
end
content_tag(:span, "#{link} (#{nb_comments}#{visit}).".html_safe, :class => status)
ret = content_tag(:span, "#{link} (#{nb_comments}#{visit}).".html_safe, :class => status)
if [:no_comments, :new_comments, :read].include?(status)
ret += button_to("Oublier", reading_path(:id => node.id), :method => :delete, :class => "unread")
end
ret
end

def translate_content_type(content_type)
Expand Down
4 changes: 4 additions & 0 deletions app/models/node.rb
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,10 @@ def read_by(account_id)
$redis.expire("readings/#{self.id}/#{account_id}", 7776000) # 3 months
end

def unread_by(account_id)
$redis.del("readings/#{self.id}/#{account_id}")
end

def self.last_reading(node_id, account_id)
time = $redis.get("readings/#{node_id}/#{account_id}")
time && Time.at(time.to_i)
Expand Down
20 changes: 18 additions & 2 deletions app/stylesheets/RonRonnement.scss
Original file line number Diff line number Diff line change
Expand Up @@ -671,8 +671,24 @@ article {
color: $C_INTER;
}

footer.actions .action {
color: $C_INTER;
footer.actions {
.action {
color: $C_INTER;
}
form, form div {
display: inline;
}
.button_to {
input {
padding: 0px;
display: inline;
color: $C_INTER;
font-size: inherit;
font-weight: bold;
border-style: none;
background-color: transparent;
}
}
}

/* parti de la base de yggdras pour la partie sur les tags */
Expand Down
2 changes: 1 addition & 1 deletion app/views/polls/_poll.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
- if current_account && current_account.can_update?(poll)
= link_to("Modifier", edit_moderation_poll_path(poll), :class => 'action')
- if poll.answerable_by?(request.remote_ip)
= link_to("Afficher les résultats", :controller => "polls", :action => "show", :id => poll.to_param, :results => 1)
= link_to("Afficher les résultats", { :controller => "polls", :action => "show", :id => poll.to_param, :results => 1 }, { :class => "action" })
5 changes: 3 additions & 2 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,12 @@
resources :nodes, :only => [] do
resources :comments do
get :answer, :on => :member
post "/relevance/:action" => "relevances#index", :as => :relevance, :on => :member
post "/relevance/:action", :controller => "relevances", :as => :relevance, :on => :member
end
resources :tags, :only => [:new, :create, :update, :destroy]
post "/vote/:action" => "votes#index", :as => :vote, :on => :member
post "/vote/:action", :controller => "votes", :as => :vote, :on => :member
end
resources :readings, :only => [:index, :destroy]
resources :tags, :only => [:index, :show] do
get :autocomplete, :on => :collection
get :public, :on => :member
Expand Down
10 changes: 10 additions & 0 deletions public/stylesheets/RonRonnement.css
Original file line number Diff line number Diff line change
Expand Up @@ -642,6 +642,16 @@ article {

footer.actions .action {
color: #a99c90; }
footer.actions form, footer.actions form div {
display: inline; }
footer.actions .button_to input {
padding: 0px;
display: inline;
color: #a99c90;
font-size: inherit;
font-weight: bold;
border-style: none;
background-color: transparent; }

/* parti de la base de yggdras pour la partie sur les tags */
.tag_in_place {
Expand Down
10 changes: 10 additions & 0 deletions public/stylesheets/contrib/RonRonnement-Bordeau.css
Original file line number Diff line number Diff line change
Expand Up @@ -642,6 +642,16 @@ article {

footer.actions .action {
color: #a99c90; }
footer.actions form, footer.actions form div {
display: inline; }
footer.actions .button_to input {
padding: 0px;
display: inline;
color: #a99c90;
font-size: inherit;
font-weight: bold;
border-style: none;
background-color: transparent; }

/* parti de la base de yggdras pour la partie sur les tags */
.tag_in_place {
Expand Down
10 changes: 10 additions & 0 deletions public/stylesheets/contrib/RonRonnement-Mauve.css
Original file line number Diff line number Diff line change
Expand Up @@ -642,6 +642,16 @@ article {

footer.actions .action {
color: #a99c90; }
footer.actions form, footer.actions form div {
display: inline; }
footer.actions .button_to input {
padding: 0px;
display: inline;
color: #a99c90;
font-size: inherit;
font-weight: bold;
border-style: none;
background-color: transparent; }

/* parti de la base de yggdras pour la partie sur les tags */
.tag_in_place {
Expand Down
10 changes: 10 additions & 0 deletions public/stylesheets/contrib/RonRonnement-Orange.css
Original file line number Diff line number Diff line change
Expand Up @@ -642,6 +642,16 @@ article {

footer.actions .action {
color: #a99c90; }
footer.actions form, footer.actions form div {
display: inline; }
footer.actions .button_to input {
padding: 0px;
display: inline;
color: #a99c90;
font-size: inherit;
font-weight: bold;
border-style: none;
background-color: transparent; }

/* parti de la base de yggdras pour la partie sur les tags */
.tag_in_place {
Expand Down
10 changes: 10 additions & 0 deletions public/stylesheets/contrib/RonRonnement-Turquoise.css
Original file line number Diff line number Diff line change
Expand Up @@ -642,6 +642,16 @@ article {

footer.actions .action {
color: #a99c90; }
footer.actions form, footer.actions form div {
display: inline; }
footer.actions .button_to input {
padding: 0px;
display: inline;
color: #a99c90;
font-size: inherit;
font-weight: bold;
border-style: none;
background-color: transparent; }

/* parti de la base de yggdras pour la partie sur les tags */
.tag_in_place {
Expand Down
10 changes: 10 additions & 0 deletions public/stylesheets/contrib/RonRonnement-Vert.css
Original file line number Diff line number Diff line change
Expand Up @@ -642,6 +642,16 @@ article {

footer.actions .action {
color: #a99c90; }
footer.actions form, footer.actions form div {
display: inline; }
footer.actions .button_to input {
padding: 0px;
display: inline;
color: #a99c90;
font-size: inherit;
font-weight: bold;
border-style: none;
background-color: transparent; }

/* parti de la base de yggdras pour la partie sur les tags */
.tag_in_place {
Expand Down
10 changes: 10 additions & 0 deletions public/stylesheets/contrib/RonRonnement.css
Original file line number Diff line number Diff line change
Expand Up @@ -642,6 +642,16 @@ article {

footer.actions .action {
color: #a99c90; }
footer.actions form, footer.actions form div {
display: inline; }
footer.actions .button_to input {
padding: 0px;
display: inline;
color: #a99c90;
font-size: inherit;
font-weight: bold;
border-style: none;
background-color: transparent; }

/* parti de la base de yggdras pour la partie sur les tags */
.tag_in_place {
Expand Down

0 comments on commit 364c888

Please sign in to comment.