diff --git a/app/controllers/public/content_viewer_controller.rb b/app/controllers/public/content_viewer_controller.rb index 0260d8a..b0708f9 100644 --- a/app/controllers/public/content_viewer_controller.rb +++ b/app/controllers/public/content_viewer_controller.rb @@ -8,6 +8,7 @@ class ContentViewerController < ApplicationController helper TagsHelper def view_page + path = get_path(params[:page], params[:format]) @version = params[:version].to_i @@ -38,7 +39,7 @@ class ContentViewerController < ApplicationController end # At this point the page will be showed - @page.hit unless user_is_a_bot? + @page.hit unless user_is_a_bot? || already_visited? @page = FilePresenter.for @page @@ -272,4 +273,17 @@ class ContentViewerController < ApplicationController @comment_order = params[:comment_order].nil? ? 'oldest' : params[:comment_order] end + private + + def already_visited? + return true if current_user.nil? + + if cookies[:visited].to_i == current_user.id + return true + else + cookies[:visited] = { value: current_user.id, expires: 7.days.from_now } + return false; + end + end + end -- libgit2 0.21.2