diff --git a/app/controllers/admin/page_contents_controller.rb b/app/controllers/admin/page_contents_controller.rb
index fb87b63..3da817c 100644
--- a/app/controllers/admin/page_contents_controller.rb
+++ b/app/controllers/admin/page_contents_controller.rb
@@ -1,4 +1,34 @@
-class Admin::PageContentsController < ApplicationController
+class Admin::PageContentsController < OrbitAdminController
def index
+ @pages = Page.where(:module=>"page_content")
+ @table_fields = ["Name","Version","Updated At","Last Modified By"]
+ end
+
+ def show
+ @page_context = PageContext.find(params[:id])
+ end
+
+ def new
+ @page = Page.find(params[:page_id])
+ @page_content = PageContext.new
+ end
+
+ def create
+ @page_content = PageContext.new(update_params)
+ @page_content.update_user_id = current_user.id
+ @page_content.save
+ redirect_to admin_page_contents_path
+ end
+
+ def view
+ @table_fields = ["Name","Version","Updated At","Last Modified By"]
+ @page = Page.find(params[:id])
+ @page_contexts = @page.page_contexts.desc(:version)
+ end
+
+ private
+
+ def update_params
+ params.require(:page_context).permit!
end
end
diff --git a/app/controllers/page_contents_controller.rb b/app/controllers/page_contents_controller.rb
new file mode 100644
index 0000000..17e4730
--- /dev/null
+++ b/app/controllers/page_contents_controller.rb
@@ -0,0 +1,9 @@
+class PageContentsController < OrbitAdminController
+ def index
+ params = OrbitHelper.params
+ page = Page.where(:page_id => params[:page_id]).first
+ {
+ "html" => page.page_contexts.last.content
+ }
+ end
+end
\ No newline at end of file
diff --git a/app/models/page_context.rb b/app/models/page_context.rb
new file mode 100644
index 0000000..0dff3b1
--- /dev/null
+++ b/app/models/page_context.rb
@@ -0,0 +1,27 @@
+# encoding: utf-8
+
+class PageContext
+ include Mongoid::Document
+ include Mongoid::Timestamps
+ include Impressionist::Impressionable
+
+ is_impressionable :counter_cache => { :column_name => :view_count }
+
+ field :update_user_id
+ field :version, :type => Integer , :default => 0
+ field :view_count, :type => Integer, :default => 0
+ field :content, localize: true
+ field :archived, :type => Boolean, :default => false
+ # field :current, :type => Boolean, :default => false
+
+ belongs_to :page
+
+ def pp_object
+ page.title
+ end
+
+ def title
+ self.page.title
+ end
+
+end
\ No newline at end of file
diff --git a/app/views/admin/page_contents/index.html.erb b/app/views/admin/page_contents/index.html.erb
index 64cd70e..c7d3080 100644
--- a/app/views/admin/page_contents/index.html.erb
+++ b/app/views/admin/page_contents/index.html.erb
@@ -1,2 +1,27 @@
-
Admin::PageContents#index
-Find me in app/views/admin/page_contents/index.html.erb
+
+
+
+
+
+ <% @pages.each do |page| %>
+
+
+ <%= page.name %>
+
+ |
+ <%= page.page_contexts.last.version %> |
+ <%= format_value page.page_contexts.last.updated_at %> |
+ <%= User.find(page.page_contexts.last.update_user_id).user_name %> |
+
+ <% end %>
+
+
+
diff --git a/app/views/admin/page_contents/new.html.erb b/app/views/admin/page_contents/new.html.erb
new file mode 100644
index 0000000..83b8bec
--- /dev/null
+++ b/app/views/admin/page_contents/new.html.erb
@@ -0,0 +1,40 @@
+<% content_for :page_specific_css do %>
+ <%= stylesheet_link_tag "lib/main-forms" %>
+<% end %>
+<%= form_for @page_content, :url => {:action => :create}, :html => {:class => 'form-horizontal main-forms'} do |f| %>
+
+<% end %>
\ No newline at end of file
diff --git a/app/views/admin/page_contents/show.html.erb b/app/views/admin/page_contents/show.html.erb
new file mode 100644
index 0000000..c545b37
--- /dev/null
+++ b/app/views/admin/page_contents/show.html.erb
@@ -0,0 +1 @@
+<%= @page_context.content.html_safe %>
\ No newline at end of file
diff --git a/app/views/admin/page_contents/view.html.erb b/app/views/admin/page_contents/view.html.erb
new file mode 100644
index 0000000..b6c0d49
--- /dev/null
+++ b/app/views/admin/page_contents/view.html.erb
@@ -0,0 +1,28 @@
+
+
+
+
+
+ <% @page_contexts.each do |page| %>
+ <% if page.version > 0 %>
+
+
+ <%= @page.name %>
+
+ |
+ <%= page.version %> |
+ <%= format_value page.updated_at %> |
+ <%= User.find(page.update_user_id).user_name rescue nil %> |
+
+ <% end %>
+ <% end %>
+
+
diff --git a/app/views/page_contents/index.html.erb b/app/views/page_contents/index.html.erb
new file mode 100644
index 0000000..0fe3ce0
--- /dev/null
+++ b/app/views/page_contents/index.html.erb
@@ -0,0 +1,2 @@
+<% data = action_data %>
+<%= data["html"].html_safe %>
\ No newline at end of file
diff --git a/config/locales/en.yml b/config/locales/en.yml
new file mode 100644
index 0000000..34fee99
--- /dev/null
+++ b/config/locales/en.yml
@@ -0,0 +1,10 @@
+en:
+
+ page_content:
+ page: Page content
+ save: Save
+ create_page_content_success: Page content was successfully created
+ editing_page_content: Editing page content
+ frontend:
+ page: Front-end page
+ update_page_content_success: Page content was successfully updated
\ No newline at end of file
diff --git a/config/locales/zh_tw.yml b/config/locales/zh_tw.yml
new file mode 100644
index 0000000..b803089
--- /dev/null
+++ b/config/locales/zh_tw.yml
@@ -0,0 +1,9 @@
+zh_tw:
+
+ page_content:
+ context: 內文
+ create_page_content_success: 建立頁面內容成功
+ editing_page_content: 編輯頁面內容
+ frontend:
+ page: 頁面前台
+ update_page_content_success: 更新頁面內容成功
\ No newline at end of file
diff --git a/config/routes.rb b/config/routes.rb
index 54981e2..28c8a59 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -4,7 +4,11 @@ Rails.application.routes.draw do
scope "(:locale)", locale: Regexp.new(locales.join("|")) do
namespace :admin do
- resources :page_contents
+ resources :page_contents do
+ member do
+ get "view" => "page_contents#view"
+ end
+ end
end
end
diff --git a/lib/page_content/engine.rb b/lib/page_content/engine.rb
index 4be3a68..53aafa1 100644
--- a/lib/page_content/engine.rb
+++ b/lib/page_content/engine.rb
@@ -10,7 +10,7 @@ module PageContent
side_bar do
head_label_i18n 'page_content.page', icon_class: "icons-newspaper"
available_for [:admin,:manager,:sub_manager]
- active_for_controllers ({:private=>['page_content']})
+ active_for_controllers (['admin/page_contents'])
head_link_path "admin_page_contents_path"
end
end