edit page_content
This commit is contained in:
parent
9b001aa6c3
commit
20c320961f
|
@ -98,7 +98,8 @@ module ParserBackEnd
|
|||
c.define_tag 'content' do |tag|
|
||||
ret = ''
|
||||
if (tag.attributes["main"] == "true" && !page.module_app.nil?)
|
||||
ret << "<div id='appfrontend' class='dymanic_load' path='/panel/#{page.module_app.key}/front_end/#{page.app_frontend_url}?inner=true'></div>"
|
||||
# ret << "<div id='appfrontend' class='dymanic_load' path='/panel/#{page.module_app.key}/front_end/#{page.app_frontend_url}?inner=true'></div>"
|
||||
ret << "<div id='appfrontend' class='dymanic_load' path='/panel/#{page.module_app.key}/front_end/#{page.app_frontend_url}?inner=true&page_id=#{page.id}'></div>"
|
||||
else
|
||||
part = page.page_parts.detect{ |p| p.name.to_s == tag.attr['name'].to_s }
|
||||
ret << "<div id='#{tag.attr['name']}' part_id='#{part.id}' class='editable' style='border:solid 1px; margin:5px; padding:5px;'>"
|
||||
|
|
|
@ -124,7 +124,8 @@ module ParserFrontEnd
|
|||
if (tag.attributes["main"] == "true" && !page.module_app.nil?)
|
||||
ret << "<div id='appfrontend' class='dymanic_load' path='/panel/#{page.module_app.key}/front_end/#{page.app_frontend_url}"
|
||||
ret << "/#{id}" if id
|
||||
ret << "?inner=true'></div>"
|
||||
# ret << "?inner=true'></div>"
|
||||
ret << "?inner=true&page_id=#{page.id}'></div>"
|
||||
else
|
||||
part = page.page_parts.detect{ |p| p.name.to_s == tag.attr['name'].to_s } rescue nil
|
||||
case part.kind
|
||||
|
|
|
@ -1,14 +1,24 @@
|
|||
class Panel::PageContent::BackEnd::PageContextsController < ApplicationController
|
||||
|
||||
|
||||
layout 'admin'
|
||||
layout 'new_admin'
|
||||
|
||||
before_filter :authenticate_user!
|
||||
before_filter :is_admin?
|
||||
|
||||
def index
|
||||
|
||||
@page_contexts = PageContext.all
|
||||
@page_contexts = PageContext.where(:archived => false).desc(:updated_at)
|
||||
|
||||
respond_to do |format|
|
||||
format.html # index.html.erb
|
||||
format.xml { render :xml => @page_contexts }
|
||||
end
|
||||
end
|
||||
|
||||
def view
|
||||
|
||||
@page_contexts = PageContext.where("page_id" => params[:page_id]).desc(:updated_at)
|
||||
|
||||
respond_to do |format|
|
||||
format.html # index.html.erb
|
||||
|
@ -68,10 +78,23 @@ class Panel::PageContent::BackEnd::PageContextsController < ApplicationControlle
|
|||
def update
|
||||
@page_context = PageContext.find(params[:id])
|
||||
|
||||
if ( @page_context.version > 0 )
|
||||
@create_page_context = PageContext.new(:version => @page_context.version)
|
||||
@create_page_context = @page_context.clone
|
||||
@create_page_context.context = @page_context.context.clone
|
||||
@create_page_context.archived = true
|
||||
end
|
||||
|
||||
@page_context.update_user_id = current_user.id
|
||||
@page_context.version = @page_context.version + 1
|
||||
|
||||
respond_to do |format|
|
||||
if @page_context.update_attributes(params[:page_context])
|
||||
|
||||
if ( @page_context.version > 1 )
|
||||
@create_page_context.save
|
||||
end
|
||||
|
||||
format.html { redirect_to(panel_page_content_back_end_page_contexts_url, :notice => t('page_content.update_page_content_success')) }
|
||||
format.js { render 'toggle_enable' }
|
||||
format.xml { head :ok }
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
class Panel::PageContent::FrontEnd::PageContextsController < ObitWidgetController
|
||||
|
||||
def initialize
|
||||
super
|
||||
@app_title = NewBlog::MOUDLEAPP_TITLE
|
||||
end
|
||||
|
||||
def index
|
||||
|
||||
# @page_context = PageContext.where("page_id" => params[:page_id], :archived => false)
|
||||
@page_context = PageContext.first(conditions: { page_id: params[:page_id], :archived => false })
|
||||
|
||||
respond_to do |format|
|
||||
format.html # index.html.erb
|
||||
format.xml { render :xml => @page_contexts }
|
||||
end
|
||||
end
|
||||
|
||||
end
|
|
@ -10,11 +10,10 @@ class PageContext
|
|||
|
||||
field :create_user_id
|
||||
field :update_user_id
|
||||
field :version, :type => Integer , :default => 1
|
||||
field :version, :type => Integer , :default => 0
|
||||
|
||||
field :is_top, :type => Boolean, :default => false
|
||||
field :is_hot, :type => Boolean, :default => false
|
||||
field :is_hidden, :type => Boolean, :default => false
|
||||
field :archived, :type => Boolean, :default => false
|
||||
# field :current, :type => Boolean, :default => false
|
||||
|
||||
belongs_to :page
|
||||
|
||||
|
@ -22,8 +21,4 @@ class PageContext
|
|||
self.is_top
|
||||
end
|
||||
|
||||
def context
|
||||
@context ||= I18nVariable.first(:conditions => {:key => 'context', :language_value_id => self.id, :language_value_type => self.class}) rescue nil
|
||||
end
|
||||
|
||||
end
|
|
@ -20,17 +20,20 @@
|
|||
<% end %>
|
||||
</div>
|
||||
|
||||
<div class="field">
|
||||
<%= f.label :status %><br />
|
||||
<%= f.check_box :is_top %><%= t('top') %>
|
||||
<%= f.check_box :is_hot %><%= t('hot') %>
|
||||
<%= f.check_box :is_hidden %><%= t('hidden') %>
|
||||
</div>
|
||||
|
||||
<br />
|
||||
<br />
|
||||
|
||||
<div class="actions">
|
||||
<%= f.submit %>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<% content_for :page_specific_javascript do %>
|
||||
<script type="text/javascript">
|
||||
$(function() {
|
||||
$('textarea').tinymce({
|
||||
theme: 'advanced'
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<% end %>
|
|
@ -1,18 +1,7 @@
|
|||
|
||||
<tr id="<%= dom_id page_context %>">
|
||||
<td>
|
||||
<% if page_context.is_top? %>
|
||||
<span class="label label-success"><%= t(:top) %></span>
|
||||
<% end %>
|
||||
<% if page_context.is_hot? %>
|
||||
<span class="label label-important"><%= t(:hot) %></span>
|
||||
<% end %>
|
||||
<% if page_context.is_hidden? %>
|
||||
<span class="label"><%= t(:hidden) %></span>
|
||||
<% end %>
|
||||
</td>
|
||||
<td><%= page_context.page.i18n_variable[I18n.locale] %></td>
|
||||
<td><%= page_context.version %></td>
|
||||
<td><%= link_to page_context.version, panel_page_content_back_end_view_path(page_context.page_id) %></td>
|
||||
<td><%= page_context.updated_at.strftime("%Y-%m-%d %H:%I:%S") %></td>
|
||||
<td><%= User.find(page_context.create_user_id).name %></td>
|
||||
<td>
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
|
||||
<tr id="<%= dom_id view_page_context %>">
|
||||
<td><%= view_page_context.page.i18n_variable[I18n.locale] %></td>
|
||||
<td><%= view_page_context.version %></td>
|
||||
<td><%= view_page_context.updated_at.strftime("%Y-%m-%d %H:%I:%S") %></td>
|
||||
<td><%= User.find(view_page_context.create_user_id).name %></td>
|
||||
<td>
|
||||
<%= link_to t('view_page_context.show'), panel_page_content_back_end_page_context_path(view_page_context) %>
|
||||
</td>
|
||||
</tr>
|
|
@ -21,7 +21,6 @@
|
|||
|
||||
<table>
|
||||
<tr>
|
||||
<th><%= t('page_context.status') %></th>
|
||||
<th><%= t('page_context.name') %></th>
|
||||
<th><%= t('page_context.version') %></th>
|
||||
<th><%= t('page_context.update_time') %></th>
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
<% # encoding: utf-8 %>
|
||||
|
||||
<br />
|
||||
<br />
|
||||
<br />
|
||||
|
||||
<p id="notice"><%= flash_messages %></p>
|
||||
|
||||
<ul>
|
||||
<li>
|
||||
<b><%= t('page_content.name') %></b>
|
||||
<%= @page_context.page.i18n_variable[I18n.locale] %>
|
||||
</li>
|
||||
<li>
|
||||
<b><%= t('page_content.context') %></b>
|
||||
<%= @page_context.context[I18n.locale].html_safe %>
|
||||
</li>
|
||||
<li>
|
||||
<b><%= t('page_content.張貼者') %></b>
|
||||
<%= User.find(@page_context.create_user_id).name %>
|
||||
</li>
|
||||
<li>
|
||||
<b><%= t('page_content.最後修改時間') %></b>
|
||||
<%= @page_context.updated_at.strftime("%Y-%m-%d %H:%I:%S") %>
|
||||
</li>
|
||||
|
||||
|
||||
<%= link_back %>
|
|
@ -0,0 +1,36 @@
|
|||
<% content_for :secondary do %>
|
||||
<br />
|
||||
<br />
|
||||
<br />
|
||||
<br />
|
||||
<br />
|
||||
<ul class="list">
|
||||
<li><%= link_to t('page_context.page_content_list'), panel_page_content_back_end_page_contexts_path %></li>
|
||||
</ul>
|
||||
<% end -%>
|
||||
|
||||
<%= flash_messages %>
|
||||
|
||||
<br />
|
||||
<br />
|
||||
<br />
|
||||
<br />
|
||||
<br />
|
||||
|
||||
<h1><%= t('page_context.list_page_content') %></h1>
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<th><%= t('page_context.name') %></th>
|
||||
<th><%= t('page_context.version') %></th>
|
||||
<th><%= t('page_context.update_time') %></th>
|
||||
<th><%= t('page_context.last_modified') %></th>
|
||||
<th><%= t('page_context.action') %></th>
|
||||
</tr>
|
||||
|
||||
<%= render :partial => 'view_page_context', :collection => @page_contexts %>
|
||||
|
||||
</table>
|
||||
|
||||
<br />
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
<% # encoding: utf-8 %>
|
||||
|
||||
|
||||
<p id="notice"><%= flash_messages %></p>
|
||||
|
||||
<h2><%= @page_context.page.i18n_variable[I18n.locale] %></h2>
|
||||
|
||||
<div class="page_content"><%= @page_context.context[I18n.locale].html_safe %></div>
|
|
@ -5,6 +5,12 @@ Rails.application.routes.draw do
|
|||
namespace :back_end do
|
||||
root :to => "page_contexts#index"
|
||||
resources :page_contexts
|
||||
match "view/:page_id" => "page_contexts#view" ,:as => :view
|
||||
end
|
||||
namespace :front_end do
|
||||
root :to => "page_contexts#index"
|
||||
resources :page_contexts
|
||||
match "page_contexts/:page_id" => "page_contexts#index"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue