Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

We’re showing branches in this repository, but you can also compare across forks.

base fork: ruby-china/ruby-china
base: 8260f363ce
...
head fork: ruby-china/ruby-china
compare: 3968dfd2e6
  • 4 commits
  • 4 files changed
  • 0 commit comments
  • 1 contributor
4 app/controllers/application_controller.rb
View
@@ -90,12 +90,16 @@ def fresh_when(opts = {})
opts[:etag] = [opts[:etag]] if !opts[:etag].is_a?(Array)
# 加入页面上直接调用的信息用于组合 etag
opts[:etag] << current_user
+ # Config 的某些信息
opts[:etag] << Setting.app_name
opts[:etag] << SiteConfig.custom_head_html
opts[:etag] << SiteConfig.footer_html
opts[:etag] << SiteConfig.faye_server
opts[:etag] << Setting.google_analytics_key
+ # 加入通知数量
opts[:etag] << unread_notify_count
+ # 所有 etag 保持一天
+ opts[:etag] << Date.current
super(opts)
end
end
6 app/controllers/pages_controller.rb
View
@@ -9,12 +9,16 @@ class PagesController < ApplicationController
def index
set_seo_meta("Wiki")
drop_breadcrumb("索引")
+
+ fresh_when(:etag => [SiteConfig.wiki_index_html])
end
def recent
@pages = Page.recent.paginate(:page => params[:page], :per_page => 30)
set_seo_meta t("pages.wiki_index")
drop_breadcrumb t("common.index")
+
+ fresh_when(:etag => [@pages])
end
def show
@@ -29,6 +33,8 @@ def show
set_seo_meta("#{@page.title} - Wiki")
drop_breadcrumb("查看 #{@page.title}")
end
+
+ fresh_when(:etag => [@page,@page.comments_count])
end
def comments
7 app/controllers/topics_controller.rb
View
@@ -56,6 +56,7 @@ def show
@topic.hits.incr(1)
@node = @topic.node
+
@per_page = Reply.per_page
# 默认最后一页
params[:page] = @topic.last_page_with_per_page(@per_page) if params[:page].blank?
@@ -68,12 +69,16 @@ def show
@replies.each { |r| @user_liked_reply_ids << r.id if r.liked_user_ids.include?(current_user.id) }
# 通知处理
current_user.read_topic(@topic)
+ # 是否关注过
+ @has_followed = @topic.follower_ids.include?(current_user.id)
+ # 是否收藏
+ @has_favorited = current_user.favorite_topic_ids.include?(@topic.id)
end
set_seo_meta("#{@topic.title} &raquo; #{t("menu.topics")}")
drop_breadcrumb("#{@node.try(:name)}", node_topics_path(@node.try(:id)))
drop_breadcrumb t("topics.read_topic")
- fresh_when(:etag => [@topic,@replies,@node])
+ fresh_when(:etag => [@topic,@has_followed,@has_favorited,@replies,@node])
end
def new
1  app/models/ability.rb
View
@@ -105,6 +105,7 @@ def basic_read_only
can :read, Page
can :recent, Page
can :preview, Page
+ can :comments, Page
can :preview, Note

No commit comments for this range

Something went wrong with that request. Please try again.