From 180c91e81ab9aeae0e41cb1864d6daef72ff4ecc Mon Sep 17 00:00:00 2001 From: JiangRu Date: Mon, 13 Apr 2015 14:13:41 +0800 Subject: [PATCH] add view_count --- app/controllers/page_contents_controller.rb | 2 ++ app/views/page_contents/index.html.erb | 6 ++++++ config/locales/en.yml | 1 + config/locales/zh_tw.yml | 1 + 4 files changed, 10 insertions(+) diff --git a/app/controllers/page_contents_controller.rb b/app/controllers/page_contents_controller.rb index 434a9f7..afc8a05 100644 --- a/app/controllers/page_contents_controller.rb +++ b/app/controllers/page_contents_controller.rb @@ -5,6 +5,8 @@ class PageContentsController < OrbitAdminController url_to_edit = OrbitHelper.user_can_edit?(page) ? "/admin/page_contents/new?page_id=#{page.id.to_s}" : "" { "html" => (page.page_contexts.last.content rescue ""), + "view_count" => (page.page_contexts.last.view_count rescue ""), + "view-count-head" =>t('page_content.view_count'), "url_to_edit" => url_to_edit } end diff --git a/app/views/page_contents/index.html.erb b/app/views/page_contents/index.html.erb index 1fdd26a..764ca7b 100644 --- a/app/views/page_contents/index.html.erb +++ b/app/views/page_contents/index.html.erb @@ -1,4 +1,10 @@ <% data = action_data %> + +
+ <%= data["view-count-head"] %>: + <%= data["view_count"] %> +
+ <%= data["html"].html_safe %> <% if !data["url_to_edit"].blank? %> diff --git a/config/locales/en.yml b/config/locales/en.yml index b234b55..02f3767 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -2,6 +2,7 @@ en: page_content: page: Page content + view_count: View count save: Save all: All create_page_content_success: Page content was successfully created diff --git a/config/locales/zh_tw.yml b/config/locales/zh_tw.yml index a51ee4e..7462cad 100644 --- a/config/locales/zh_tw.yml +++ b/config/locales/zh_tw.yml @@ -2,6 +2,7 @@ zh_tw: page_content: context: 內文 + view_count: 瀏覽人次 create_page_content_success: 建立頁面內容成功 editing_page_content: 編輯頁面內容 all: All