Merge branch 'design_team' of github.com:Rulingcom/orbit into design_team

Conflicts:
	app/views/admin/pages/_edit.html.erb
	app/views/admin/pages/_form.html.erb
	lib/parsers/parser_back_end.rb
This commit is contained in:
Christophe Vilayphiou 2012-05-13 23:14:13 +08:00
commit 01d0c002f5
48 changed files with 263 additions and 286 deletions

View File

@ -6,4 +6,3 @@
// //
//= require jquery //= require jquery
//= require jquery_ujs //= require jquery_ujs
//= require news_link

View File

@ -32,3 +32,24 @@ $('.part_kind').live('click', function() {
$('.part_kind_partial').hide(); $('.part_kind_partial').hide();
$('#part_' + $(this).attr('value')).show(); $('#part_' + $(this).attr('value')).show();
}); });
$(document).ready(function(){
$('ol.sortable').nestedSortable({
disableNesting: 'no-nest',
forcePlaceholderSize: true,
handle: 'i',
helper: 'clone',
items: 'li',
maxLevels: 3,
opacity: .5,
placeholder: 'placeholder',
revert: 250,
tabSize: 25,
tolerance: 'pointer',
toleranceElement: '> div',
stop: function(event, ui) {
$.post("<%= Rails.application.routes.url_helpers.admin_update_position_path %>", { id: ui.item.attr('id'), parent_id: ui.item.parent().closest('li').attr('id'), position: ui.item.index() } );
}
});
});

View File

@ -95,9 +95,9 @@ class ApplicationController < ActionController::Base
end end
# Render the page # Render the page
def render_page(param={}) def render_page
if @item if @item
render :text => process_page(@item, param[:id], param), :layout => 'page_layout' render :text => parse_page_noko(@item), :layout => 'page_layout'
else else
render :text => '404 Not Found' render :text => '404 Not Found'
end end

View File

@ -1,7 +1,7 @@
class OrbitFrontendComponentController< ApplicationController class OrbitFrontendComponentController< ApplicationController
before_filter :setup_vars before_filter :setup_vars
before_filter {|c| c.front_end_available(@app_title)} before_filter {|c| c.front_end_available(@app_title)}
layout :false layout "module_widget"
def setup_vars def setup_vars
@app_title = request.fullpath.split('/')[2] @app_title = request.fullpath.split('/')[2]

View File

@ -19,7 +19,7 @@ class PagesController < ApplicationController
if @item && @item.is_published && (@item.enabled_for.nil? ? true : @item.enabled_for.include?(I18n.locale.to_s)) if @item && @item.is_published && (@item.enabled_for.nil? ? true : @item.enabled_for.include?(I18n.locale.to_s))
case @item._type case @item._type
when 'Page' when 'Page'
render_page(params) render_page
when 'Link' when 'Link'
redirect_to "http://#{@item[:url]}" redirect_to "http://#{@item[:url]}"
end end
@ -32,17 +32,19 @@ class PagesController < ApplicationController
end end
def index_from_link def index_from_link
if params[:page] url = "/#{@item.path}"
redirect_to "/#{@item.path}?page=#{params[:page]}&category_id=#{params[:category_id]}&tag_id=#{params[:tag_id]}" options = ''
else options << "?page_main=#{params[:page_main]}" unless params[:page_main].blank?
redirect_to "/#{@item.path}?category_id=#{params[:category_id]}&tag_id=#{params[:tag_id]}" options << "#{options.blank? ? '?' : '&'}category_id=#{params[:category_id]}" unless params[:category_id].blank?
end options << "#{options.blank? ? '?' : '&'}tag_id=#{params[:tag_id]}" unless params[:tag_id].blank?
redirect_to url + options
end end
def show_from_link def show_from_link
# debugger url = "/#{@item.path}?id=#{params[:id]}"
# a=1 options = ''
redirect_to "/#{@item.path}?id=#{params[:id]}&preview=#{params[:preview]}" options << "&preview=#{params[:preview]}" unless params[:preview].blank?
redirect_to url + options
end end
def load_orbit_bar def load_orbit_bar

View File

@ -89,11 +89,7 @@ module ApplicationHelper
def active_for_action(controller_name, action_name) def active_for_action(controller_name, action_name)
((controller.controller_name.eql?(controller_name) || request.fullpath.eql?(controller_name)) && controller.action_name.eql?(action_name)) ? 'active' : nil ((controller.controller_name.eql?(controller_name) || request.fullpath.eql?(controller_name)) && controller.action_name.eql?(action_name)) ? 'active' : nil
end end
def process_page(page, id, params)
parse_page_noko(page, id, params)
end
def page_metas(page) def page_metas(page)
tmp_meta = {} tmp_meta = {}
metas = '' metas = ''

View File

@ -11,9 +11,27 @@ class PagePart
field :public_r_tag_option, :default => nil field :public_r_tag_option, :default => nil
field :widget_path field :widget_path
has_one :i18n_variable, :as => :language_value, :autosave => true, :dependent => :destroy has_one :i18n_variable, :class_name => "I18nVariable", :as => :language_value, :autosave => true, :dependent => :destroy
has_one :title, :class_name => "I18nVariable", :as => :language_value, :autosave => true, :dependent => :destroy
belongs_to :page belongs_to :page
belongs_to :module_app belongs_to :module_app
before_save :set_key
def i18n_variable
@i18n_variable ||= I18nVariable.first(:conditions => {:key => 'i18n_variable', :language_value_id => self.id, :language_value_type => self.class}) rescue nil
end
def title
@title ||= I18nVariable.first(:conditions => {:key => 'title', :language_value_id => self.id, :language_value_type => self.class}) rescue nil
end
protected
def set_key
title.key = 'title' if title && (title.key.blank? rescue true)
i18n_variable.key = 'i18n_variable' if i18n_variable && (i18n_variable.key.blank? rescue true)
end
end end

View File

@ -1,25 +1 @@
<%= render_node_and_children(Item.first(:conditions => {:parent_id => nil})) %> <%= render_node_and_children(Item.first(:conditions => {:parent_id => nil})) %>
<script>
$(document).ready(function(){
$('ol.sortable').nestedSortable({
disableNesting: 'no-nest',
forcePlaceholderSize: true,
handle: 'i',
helper: 'clone',
items: 'li',
maxLevels: 3,
opacity: .5,
placeholder: 'placeholder',
revert: 250,
tabSize: 25,
tolerance: 'pointer',
toleranceElement: '> div',
stop: function(event, ui) {
$.post("<%= admin_update_position_path %>", { id: ui.item.attr('id'), parent_id: ui.item.parent().closest('li').attr('id'), position: ui.item.index() } );
}
});
});
</script>

View File

@ -2,7 +2,7 @@
<% LIST[:page_part_kinds].each do |kind| %> <% LIST[:page_part_kinds].each do |kind| %>
<%= f.radio_button :kind, kind, :class => 'part_kind' %> <%= f.radio_button :kind, kind, :class => 'part_kind' %>
<%= t(kind) %> <%= t(kind, :scope => 'admin.page_part_kinds') %>
<% end %> <% end %>
<% LIST[:page_part_kinds].each do |kind| %> <% LIST[:page_part_kinds].each do |kind| %>

View File

@ -1,3 +1,14 @@
<div>
<%= f.fields_for :title, @part.title do |f| %>
<% @site_valid_locales.each do |locale| %>
<p>
<%= f.label :locale, "#{t('admin.title')} #{I18nVariable.from_locale(locale)}" %>
<%= f.text_field locale %>
</p>
<% end %>
<% end %>
</div>
<span id='module_app_list'> <span id='module_app_list'>
<%= f.select :module_app, options_from_collection_for_select(@module_apps, :id, :title, :selected => @module_app.id), {}, {:rel => admin_page_parts_path} %> <%= f.select :module_app, options_from_collection_for_select(@module_apps, :id, :title, :selected => @module_app.id), {}, {:rel => admin_page_parts_path} %>
</span> </span>

View File

@ -8,5 +8,7 @@
<% end %> <% end %>
<script> <script>
load_tinymce(); $(document).ready(function() {
load_tinymce();
});
</script> </script>

View File

@ -2,10 +2,10 @@
<div id="poststuff"> <div id="poststuff">
<h1><%= t('admin.editing_page') %></h1> <h1><%= t('admin.editing_page') %></h1>
<%= form_for @item, :url => admin_page_path(@item), :html => { :class => 'form-horizontal edit_page' } do |f| %> <%= form_for @item, :url => admin_page_path(@item), :html => { :class => 'form-horizontal edit_page' } do |f| %>
<%= render :partial => "form", :locals => { :f => f } %> <%= render :partial => "form", :locals => { :f => f } %>
<div class="form-actions"> <div class="form-actions">
<%= f.submit t('update'), :class => 'btn btn-primary' %> <%= f.submit t('update'), :class => 'btn btn-primary' %>
<%= link_to t('cancel'), get_go_back, :class=>"btn" %> <%= link_to t('cancel'), get_go_back, :class=>"btn" %>
</div> </div>
<% end %>
</div> </div>
<% end %>

View File

@ -5,7 +5,7 @@
<%= f.label :name, t('admin.name'), :class => 'control-label' %> <%= f.label :name, t('admin.name'), :class => 'control-label' %>
<div class="controls"> <div class="controls">
<%= f.text_field :name, :class => 'text input-xlarge' %> <%= f.text_field :name, :class => 'text input-xlarge' %>
<p class="help-block">In addition to freeform text, any HTML5 text-based input appears like so.</p> <!-- <p class="help-block">In addition to freeform text, any HTML5 text-based input appears like so.</p> -->
</div> </div>
</div> </div>
@ -15,7 +15,7 @@
<%= f.label :locale, "#{t('admin.title')} #{I18nVariable.from_locale(locale)}", :class => 'control-label' %> <%= f.label :locale, "#{t('admin.title')} #{I18nVariable.from_locale(locale)}", :class => 'control-label' %>
<div class="controls"> <div class="controls">
<%= f.text_field locale, :class => 'text input-xlarge' %> <%= f.text_field locale, :class => 'text input-xlarge' %>
<p class="help-block">In addition to freeform text, any HTML5 text-based input appears like so.</p> <!-- <p class="help-block">In addition to freeform text, any HTML5 text-based input appears like so.</p> -->
</div> </div>
</div> </div>
<% end %> <% end %>
@ -25,14 +25,14 @@
<%= f.label :name, t('admin.design_name'), :class => 'control-label' %> <%= f.label :name, t('admin.design_name'), :class => 'control-label' %>
<div class="controls"> <div class="controls">
<%= f.collection_select :design, @designs, :id, :title, {:selected => @design.id}, {:rel => admin_pages_path} %> <%= f.collection_select :design, @designs, :id, :title, {:selected => @design.id}, {:rel => admin_pages_path} %>
<p class="help-block">In addition to freeform text, any HTML5 text-based input appears like so.</p> <!-- <p class="help-block">In addition to freeform text, any HTML5 text-based input appears like so.</p> -->
</div> </div>
</div> </div>
<div class="control-group"> <div class="control-group">
<%= f.label :name, t('admin.theme'), :class => 'control-label' %> <%= f.label :name, t('admin.theme'), :class => 'control-label' %>
<div class="controls"> <div class="controls">
<%= f.select :theme_id, @design.themes.collect { |t| [t.name.capitalize, t.id] }, :include_blank => true %> <%= f.select :theme_id, @design.themes.collect { |t| [t.name.capitalize, t.id] }, :include_blank => true %>
<p class="help-block">In addition to freeform text, any HTML5 text-based input appears like so.</p> <!-- <p class="help-block">In addition to freeform text, any HTML5 text-based input appears like so.</p> -->
</div> </div>
</div> </div>
<div class="control-group"> <div class="control-group">
@ -45,7 +45,7 @@
<span id="app_page_category"> <span id="app_page_category">
<%= select('page','category', @categories.collect{|category| [category.i18n_variable[I18n.locale], category.id]}, :selected => @item[:category], :include_blank => true ) rescue ''%> <%= select('page','category', @categories.collect{|category| [category.i18n_variable[I18n.locale], category.id]}, :selected => @item[:category], :include_blank => true ) rescue ''%>
</span> </span>
<p class="help-block">In addition to freeform text, any HTML5 text-based input appears like so.</p> <!-- <p class="help-block">In addition to freeform text, any HTML5 text-based input appears like so.</p> -->
</div> </div>
</div> </div>
<div class="control-group"> <div class="control-group">
@ -59,7 +59,7 @@
<%= f.radio_button :is_published, false %> <%= f.radio_button :is_published, false %>
No No
</label> </label>
<p class="help-block">In addition to freeform text, any HTML5 text-based input appears like so.</p> <!-- <p class="help-block">In addition to freeform text, any HTML5 text-based input appears like so.</p> -->
</div> </div>
</div> </div>
<div class="control-group"> <div class="control-group">
@ -72,7 +72,7 @@
</label> </label>
<% end %> <% end %>
<%= hidden_field_tag 'page[menu_enabled_for][]', '' %> <%= hidden_field_tag 'page[menu_enabled_for][]', '' %>
<p class="help-block">In addition to freeform text, any HTML5 text-based input appears like so.</p> <!-- <p class="help-block">In addition to freeform text, any HTML5 text-based input appears like so.</p> -->
</div> </div>
</div> </div>
@ -86,7 +86,7 @@
</label> </label>
<% end %> <% end %>
<%= hidden_field_tag 'page[enabled_for][]', '' %> <%= hidden_field_tag 'page[enabled_for][]', '' %>
<p class="help-block">In addition to freeform text, any HTML5 text-based input appears like so.</p> <!-- <p class="help-block">In addition to freeform text, any HTML5 text-based input appears like so.</p> -->
</div> </div>
</div> </div>

View File

@ -1,13 +1,11 @@
<h1><%= t('admin.new_page') %></h1>
<%= flash_messages %> <%= flash_messages %>
<div id="poststuff">
<%= form_for @item, :url => admin_pages_path, :html => { :class => 'form' } do |f| %> <h1><%= t('admin.new_page') %></h1>
<%= form_for @item, :url => admin_page_path, :html => { :class => 'form-horizontal edit_page' } do |f| %>
<%= render :partial => "form", :locals => { :f => f } %> <%= render :partial => "form", :locals => { :f => f } %>
<div class="form-actions">
<p> <%= f.submit t('update'), :class => 'btn btn-primary' %>
<%= f.submit t('create') %> <%= link_back %> <%= link_to t('cancel'), get_go_back, :class=>"btn" %>
</p> </div>
<% end %>
<% end %> </div>

View File

@ -5,7 +5,9 @@
<%= javascript_include_tag "html5" %> <%= javascript_include_tag "html5" %>
<![endif]--> <![endif]-->
<%#= stylesheet_link_tag "module_widget" %> <%#= stylesheet_link_tag "module_widget" %>
<%= javascript_include_tag "module_widget" %> <%= javascript_include_tag "module" %>
<%#= javascript_include_tag "#{@app_title}/module_widget" %>
<%= yield :page_specific_javascript %>
<%= csrf_meta_tag %> <%= csrf_meta_tag %>
</head> </head>
<body> <body>

View File

@ -200,6 +200,10 @@ en:
options: Options options: Options
orig_upload_file: Original filename orig_upload_file: Original filename
page: Page page: Page
page_part_kinds:
text: Text Area
public_r_tag: System Widget
module_widget: Plug-in Module Widget
position: Position position: Position
published?: Published? published?: Published?
purchase: Purchase purchase: Purchase

View File

@ -195,6 +195,10 @@ zh_tw:
options: 選項 options: 選項
orig_upload_file: 原上傳檔名 orig_upload_file: 原上傳檔名
page: 頁面管理 page: 頁面管理
page_part_kinds:
text: 文字區塊
public_r_tag: 系統模塊
module_widget: 外掛模塊
position: 位置 position: 位置
published?: 發布? published?: 發布?
purchase: 購買 purchase: 購買

View File

@ -23,67 +23,19 @@ module ParserBackEnd
# ret << "</a>" # ret << "</a>"
# end # end
def parse_page_edit_noko(page, id = nil) def parse_page_edit_noko(page)
body = Nokogiri::HTML(page.design.layout.body) body = Nokogiri::HTML(page.design.layout.body)
parse_menu(body, page, true) parse_menu(body, page, true)
public_r_tags = parse_content_edits(body, page, id) public_r_tags = parse_contents(body, page, true)
parse_images(body, page) parse_images(body, page)
parse_footer(body, page, true) parse_footer(body, page)
parse_sub_menu(body, page, true) parse_sub_menu(body, page)
public_r_tags.each do |tag| public_r_tags.each do |tag|
send("parse_#{tag}s", body, page, id, true) send("parse_#{tag}s", body, page, true)
end end
body.to_html body.to_html
end end
# page_contents
def parse_content_edits(body, page, id)
public_r_tags = []
body.css('.page_content').each do |content|
ret = ''
if (content["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&page_id=#{page.id}"
ret << "&category_id=#{page.category}" if page[:category]
ret << "&tag_id=#{page.tag}" if page[:tag]
ret << "'></div>"
else
part = page.page_parts.detect{ |p| p.name.to_s == content['name'].to_s } rescue nil
ret << "<div id='#{content['name']}' part_id='#{part.id}' class='editable'>" if part
ret << "<div class='edit_link' style='display:none'>"
ret << " <a href='#{edit_admin_page_part_path(part.id)}' class='nav'>#{t(:edit)}</a>" if part
ret << '</div>'
case part.kind
when 'text'
ret << part.i18n_variable[I18n.locale] rescue ''
when 'module_widget'
if !part[:category].blank?
ret << "<div class='dymanic_load' path='/panel/#{part.module_app.key}/widget/#{part.widget_path}?category_id=#{part[:category]}}'></div>"
elsif !part[:tag].blank?
ret << "<div class='dymanic_load' path='/panel/#{part.module_app.key}/widget/#{part.widget_path}?inner=true&tag_id=#{part[:tag]}'></div>"
else
ret << "<div class='dymanic_load' path='/panel/#{part.module_app.key}/widget/#{part.widget_path}'></div>"
end
when 'public_r_tag'
ret << "<r:#{part.public_r_tag} id='#{part.public_r_tag_object_id}'/>"
public_r_tags << part.public_r_tag
else
''
end if part
end
scope = "<#{content.name}"
content.attributes.each_pair do |key, value|
scope << " #{key}='#{value}'"
end
scope << ">#{ret}</#{content.name}>"
fragment = Nokogiri::HTML::DocumentFragment.new(body, scope)
content.swap(fragment)
end
public_r_tags.uniq
end
def self.included(base) def self.included(base)
base.send :helper_method, :parse_page_edit_noko if base.respond_to? :helper_method base.send :helper_method, :parse_page_edit_noko if base.respond_to? :helper_method
end end

View File

@ -36,7 +36,7 @@ module ParserCommon
end end
# ad_banners # ad_banners
def parse_ad_banners(body = nil, page = nil, id = nil, edit=nil) def parse_ad_banners(body = nil, page = nil, edit=nil)
body.css('ad_banner').each do |banner| body.css('ad_banner').each do |banner|
res = '' res = ''
ad_banner = AdBanner.find(banner["id"]) rescue nil ad_banner = AdBanner.find(banner["id"]) rescue nil
@ -82,7 +82,7 @@ module ParserCommon
end end
# page_images # page_images
def parse_images(body, page, id = nil, edit=nil) def parse_images(body, page, edit=nil)
body.css('.page_image').each do |page_image| body.css('.page_image').each do |page_image|
# image = page.custom_images.detect{|image| image.name.eql?(tag.attr['name']) } # image = page.custom_images.detect{|image| image.name.eql?(tag.attr['name']) }
# image = page.design.custom_images.detect{|image| image.name.eql?(tag.attr['name']) } unless image # image = page.design.custom_images.detect{|image| image.name.eql?(tag.attr['name']) } unless image
@ -109,7 +109,7 @@ module ParserCommon
end end
# sub_menus # sub_menus
def parse_sub_menus(body = nil, page = nil, id = nil, edit=nil) def parse_sub_menus(body = nil, page = nil, edit=nil)
body.css('sub_menu').each do |sub_menu| body.css('sub_menu').each do |sub_menu|
menu_page = Page.find(sub_menu['id']) rescue nil menu_page = Page.find(sub_menu['id']) rescue nil
res = '' res = ''
@ -132,7 +132,7 @@ module ParserCommon
end end
# page_footer # page_footer
def parse_footer(body, page, edit=nil) def parse_footer(body, page)
page_footer = body.css('.page_footer').first page_footer = body.css('.page_footer').first
if page_footer if page_footer
res = "<div id='#{page_footer['id']}', class='#{page_footer['class']}'>" res = "<div id='#{page_footer['id']}', class='#{page_footer['class']}'>"
@ -146,7 +146,7 @@ module ParserCommon
end end
# page_sub_menu # page_sub_menu
def parse_sub_menu(body, page, edit=nil) def parse_sub_menu(body, page)
page_sub_menu = body.css('.page_sub_menu').first page_sub_menu = body.css('.page_sub_menu').first
if page_sub_menu if page_sub_menu
res = "<div id='#{page_sub_menu['id']}', class='#{page_sub_menu['class']}'>" res = "<div id='#{page_sub_menu['id']}', class='#{page_sub_menu['class']}'>"
@ -159,4 +159,48 @@ module ParserCommon
end end
end end
# page_contents
def parse_contents(body, page, edit=nil)
public_r_tags = []
body.css('.page_content').each do |content|
ret = ''
if (content["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 << "/#{params[:id]}" if params[:id] && !params[:id].eql?(page.id.to_s)
ret << "?inner=true&page_id=#{page.id}&category_id=#{params[:category_id]}&tag_id=#{params[:tag_id]}&preview=#{params[:preview]}&page_main=#{params[:page_main]}"
ret << "'></div>"
else
part = page.page_parts.detect{ |p| p.name.to_s == content['name'].to_s } rescue nil
part_title = part.title[I18n.locale] rescue nil
if edit
ret << "<div id='#{content['name']}' part_id='#{part.id}' class='editable' style='border:solid 1px; margin:5px; padding:5px;'>" if part
ret << "<div class='edit_link' style='display:none'>"
ret << " <a href='#{edit_admin_page_part_path(part.id)}' class='nav'>#{t(:edit)}</a>" if part
ret << '</div>'
end
case part.kind
when 'text'
ret << part.i18n_variable[I18n.locale] rescue ''
when 'module_widget'
url = "/panel/#{part.module_app.key}/widget/#{part.widget_path}?inner=true"
options = "&category_id=#{!part[:category].blank? ? part[:category].blank? : params[:category_id]}&tag_id=#{!part[:tag].blank? ? part[:tag] : params[:tag_id]}&page=#{params[:page]}&part_title=#{Rack::Utils.escape(part_title).gsub("+", "%20") rescue nil}"
ret << "<div class='dymanic_load' path='#{url + options}'></div>"
when 'public_r_tag'
ret << "<r:#{part.public_r_tag} id='#{part.public_r_tag_object_id}'/>"
public_r_tags << part.public_r_tag
else
''
end if part
end
scope = "<#{content.name}"
content.attributes.each_pair do |key, value|
scope << " #{key}='#{value}'"
end
scope << ">#{ret}</#{content.name}>"
fragment = Nokogiri::HTML::DocumentFragment.new(body, scope)
content.swap(fragment)
end
public_r_tags.uniq
end
end end

View File

@ -21,69 +21,18 @@ module ParserFrontEnd
require 'nokogiri' require 'nokogiri'
def parse_page_noko(page, id = nil,params) def parse_page_noko(page)
body = Nokogiri::HTML(page.design.layout.body) body = Nokogiri::HTML(page.design.layout.body)
parse_menu(body, page) parse_menu(body, page)
public_r_tags = parse_contents(body, page, id,params[:preview]) public_r_tags = parse_contents(body, page)
parse_images(body, page) parse_images(body, page)
parse_footer(body, page) parse_footer(body, page)
parse_sub_menu(body, page) parse_sub_menu(body, page)
public_r_tags.each do |tag| public_r_tags.each do |tag|
send("parse_#{tag}s", body, page,id) send("parse_#{tag}s", body, page)
end end
body.to_html body.to_html
end end
# page_contents
def parse_contents(body, page, id,preview = false)
public_r_tags = []
body.css('.page_content').each do |content|
ret = ''
if (content["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&page_id=#{page.id}"
# ret << "&category_id=#{page.category}" if page[:category]
ret << "&category_id=#{params[:category_id]}" if !params[:category_id].blank?
ret << "&tag_id=#{params[:tag_id]}" if !params[:tag_id].blank?
ret << "&preview=true" if preview.eql?('true')
ret << "'></div>"
else
part = page.page_parts.detect{ |p| p.name.to_s == content['name'].to_s } rescue nil
case part.kind
when 'text'
ret << part.i18n_variable[I18n.locale] rescue ''
when 'module_widget'
# if part[:category]
# ret << "<div class='dymanic_load' path='/panel/#{part.module_app.key}/widget/#{part.widget_path}?inner=true&category_id=#{part[:category]}'></div>"
# else
# ret << "<div class='dymanic_load' path='/panel/#{part.module_app.key}/widget/#{part.widget_path}?inner=true'></div>"
# end
if !part[:category].blank?
ret << "<div class='dymanic_load' path='/panel/#{part.module_app.key}/widget/#{part.widget_path}?inner=true&category_id=#{part[:category]}'></div>"
elsif !part[:tag].blank?
ret << "<div class='dymanic_load' path='/panel/#{part.module_app.key}/widget/#{part.widget_path}?inner=true&tag_id=#{part[:tag]}'></div>"
else
ret << "<div class='dymanic_load' path='/panel/#{part.module_app.key}/widget/#{part.widget_path}?inner=true'></div>"
end
when 'public_r_tag'
ret << "<r:#{part.public_r_tag} id='#{part.public_r_tag_object_id}'/>"
public_r_tags << part.public_r_tag
else
''
end if part
end
scope = "<#{content.name}"
content.attributes.each_pair do |key, value|
scope << " #{key}='#{value}'"
end
scope << ">#{ret}</#{content.name}>"
fragment = Nokogiri::HTML::DocumentFragment.new(body, scope)
content.swap(fragment)
end
public_r_tags.uniq
end
end end

View File

@ -1,9 +0,0 @@
// This is a manifest file that'll be compiled into including all the files listed below.
// Add new JavaScript/Coffee code in separate files in this directory and they'll automatically
// be included in the compiled file accessible from http://example.com/assets/application.js
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// the compiled file.
//
//= require jquery
//= require jquery_ujs
//= require announcement_link

View File

@ -12,14 +12,14 @@ class Panel::Announcement::FrontEnd::BulletinsController < OrbitWidgetController
date_now = Time.now date_now = Time.now
if !params[:category_id].blank? if !params[:category_id].blank?
@bulletins = Bulletin.can_display.where(:bulletin_category_id => params[:category_id]).any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page]).per(10) @bulletins = Bulletin.can_display.where(:bulletin_category_id => params[:category_id]).any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page_main]).per(10)
@current_category = BulletinCategory.from_id(params[:category_id]) rescue nil @current_category = BulletinCategory.from_id(params[:category_id]) rescue nil
elsif !params[:tag_id].blank? elsif !params[:tag_id].blank?
@tag = AnnouncementTag.find(params[:tag_id]) rescue nil @tag = AnnouncementTag.find(params[:tag_id]) rescue nil
@tag = AnnouncementTag.where(key: params[:tag_id])[0] unless @tag @tag = AnnouncementTag.where(key: params[:tag_id])[0] unless @tag
@bulletins = @tag.bulletins.can_display.any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page]).per(10) @bulletins = @tag.bulletins.can_display.any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page_main]).per(10)
else else
@bulletins = Bulletin.can_display.any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page]).per(10) @bulletins = Bulletin.can_display.any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page_main]).per(10)
end end
end end

View File

@ -9,7 +9,7 @@ class Panel::Announcement::Widget::BulletinsController < OrbitWidgetController
# GET /bulletins.xml # GET /bulletins.xml
def index def index
@title = params[:part_title]
date_now = Time.now date_now = Time.now
if !params[:category_id].blank? if !params[:category_id].blank?
@bulletins = Bulletin.can_display.where(:bulletin_category_id => params[:category_id]).any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page]).per(10) @bulletins = Bulletin.can_display.where(:bulletin_category_id => params[:category_id]).any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page]).per(10)
@ -31,7 +31,6 @@ class Panel::Announcement::Widget::BulletinsController < OrbitWidgetController
@selected_tag = AnnouncementTag.find(params[:id]) rescue @tags[0] @selected_tag = AnnouncementTag.find(params[:id]) rescue @tags[0]
@bulletins = @selected_tag.get_visible_bulletins.can_display.page(params[:page]).per(5) rescue nil @bulletins = @selected_tag.get_visible_bulletins.can_display.page(params[:page]).per(5) rescue nil
@web_links = WebResourceTag.first(:conditions => {:en => @selected_tag[:en]}).get_visible_links.page(params[:page]).per(5) rescue nil @web_links = WebResourceTag.first(:conditions => {:en => @selected_tag[:en]}).get_visible_links.page(params[:page]).per(5) rescue nil
render :layout => 'module_widget'
end end
def reload_bulletins def reload_bulletins

View File

@ -3,9 +3,9 @@
<%= flash_messages %> <%= flash_messages %>
<% if @current_category %> <% if @current_category %>
<h1 class="h1"><%= @current_category.i18n_variable[I18n.locale] + t('announcement.bulletin.list_lower') %></h1> <h1 class="h1"><%= @current_category.i18n_variable[I18n.locale] %></h1>
<% else %> <% else %>
<h1 class="h1"><%= t('announcement.list_announcement') %></h1> <h1 class="h1"><%= t('announcement.announcement') %></h1>
<% end %> <% end %>
@ -29,5 +29,5 @@
</table> </table>
<%= paginate @bulletins, :params => {:inner => 'false'} %> <%= paginate @bulletins, :param_name => :page_main, :params => {:inner => 'false'} %>

View File

@ -0,0 +1,25 @@
<% if @title %>
<h1 class="h1"><%= @title %></h1>
<% end %>
<table class="table table-bordered">
<tr>
<th><%= t('announcement.bulletin.category') %></th>
<th><%= t('announcement.bulletin.title') %></th>
<th><%= t('announcement.bulletin.postdate') %></th>
</tr>
<% @bulletins.each do |post| %>
<tr>
<td><%= post.bulletin_category.i18n_variable[I18n.locale] %></td>
<td><%= link_to post.title[I18n.locale], panel_announcement_front_end_bulletin_path(post, :category_id => post.bulletin_category_id) %>
</td>
<td><%= post.postdate %></td>
</tr>
<% end %>
</table>
<%= paginate @bulletins, :params => {:inner => 'true'}, :remote => true %>

View File

@ -16,4 +16,8 @@
<ul id='bulletins_web_links_web_links' class="links_list"> <ul id='bulletins_web_links_web_links' class="links_list">
<%= render 'web_links' if @web_links %> <%= render 'web_links' if @web_links %>
</ul> </ul>
</div> </div>
<% content_for :page_specific_javascript do %>
<%= javascript_include_tag "news_link" %>
<% end %>

View File

@ -1,29 +1,3 @@
<% if @current_category %> <div id="bulletin_widget">
<h1 class="h1"><%= @current_category.i18n_variable[I18n.locale] + t('announcement.bulletin.list_lower') %></h1> <%= render 'index' %>
<% elsif @tag %> </div>
<h1 class="h1"><%= @tag[I18n.locale] + t('announcement.bulletin.list_lower') %></h1>
<% else %>
<h1 class="h1"><%= t('announcement.list_announcement') %></h1>
<% end %>
<table class="table table-bordered">
<tr>
<th><%= t('announcement.bulletin.category') %></th>
<th><%= t('announcement.bulletin.title') %></th>
<th><%= t('announcement.bulletin.postdate') %></th>
</tr>
<% @bulletins.each do |post| %>
<tr>
<td><%= post.bulletin_category.i18n_variable[I18n.locale] %></td>
<td><%= link_to post.title[I18n.locale], panel_announcement_front_end_bulletin_path(post, :category_id => post.bulletin_category_id) %>
</td>
<td><%= post.postdate %></td>
</tr>
<% end %>
</table>
<%= paginate @bulletins, :params => {:inner => 'false'} %>

View File

@ -0,0 +1 @@
$('#bulletin_widget').html("<%= j render 'index' %>")

View File

@ -58,6 +58,7 @@ en:
announcement: announcement:
all_articles: List all_articles: List
add_new: Add add_new: Add
announcement: Announcement
categories: Categories categories: Categories
error: error:
no_avilb_cate_for_posting: You need a category to submit your post,please contact admin no_avilb_cate_for_posting: You need a category to submit your post,please contact admin
@ -66,7 +67,6 @@ en:
more: more+ more: more+
bulletins: Bulletins bulletins: Bulletins
related_links: Related Links related_links: Related Links
list_announcement: List Announcement
bulletin: bulletin:
submit_user_list: Submit User submit_user_list: Submit User
category: Category category: Category

View File

@ -37,6 +37,7 @@ zh_tw:
announcement: announcement:
add_new: 新增 add_new: 新增
all_articles: 列表 all_articles: 列表
announcement: 公告
error: error:
no_avilb_cate_for_posting: 您目前沒有分類可以刊登公告,請聯絡系統管理員為您開通分類 no_avilb_cate_for_posting: 您目前沒有分類可以刊登公告,請聯絡系統管理員為您開通分類
tags: 標籤 tags: 標籤
@ -47,7 +48,6 @@ zh_tw:
more: 更多+ more: 更多+
bulletins: 公告訊息 bulletins: 公告訊息
related_links: 相關連結 related_links: 相關連結
list_announcement: 公告列表
bulletin: bulletin:
category: 分類 category: 分類
submit_user_list: 張貼人 submit_user_list: 張貼人

View File

@ -11,13 +11,13 @@ class Panel::News::FrontEnd::NewsBulletinsController < OrbitWidgetController
def index def index
date_now = Time.now date_now = Time.now
if !params[:category_id].blank? if !params[:category_id].blank?
@news_bulletins = NewsBulletin.can_display.where(:news_bulletin_category_id => params[:category_id]).any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page]).per(10) @news_bulletins = NewsBulletin.can_display.where(:news_bulletin_category_id => params[:category_id]).any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page_main]).per(10)
elsif !params[:tag_id].blank? elsif !params[:tag_id].blank?
tmp = NewsTag.find(params[:tag_id]) rescue nil tmp = NewsTag.find(params[:tag_id]) rescue nil
tmp = NewsTag.where(key: params[:tag_id])[0] unless tmp tmp = NewsTag.where(key: params[:tag_id])[0] unless tmp
@news_bulletins = tmp.news_bulletins.can_display.any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page]).per(10) rescue nil @news_bulletins = tmp.news_bulletins.can_display.any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page_main]).per(10) rescue nil
else else
@news_bulletins = NewsBulletin.can_display.any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page]).per(10) @news_bulletins = NewsBulletin.can_display.any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page_main]).per(10)
end end
get_categorys get_categorys

View File

@ -9,16 +9,17 @@ class Panel::News::Widget::NewsBulletinsController < OrbitWidgetController
# GET /news_bulletins.xml # GET /news_bulletins.xml
def index def index
@title = params[:part_title]
date_now = Time.now date_now = Time.now
if !params[:category_id].blank? if !params[:category_id].blank?
@news_bulletins = NewsBulletin.can_display.where(:news_bulletin_category_id => params[:category_id]).any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page]).per(10) @news_bulletins = NewsBulletin.can_display.where(:news_bulletin_category_id => params[:category_id]).any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page]).per(5)
@current_category = NewsBulletinCategory.from_id(params[:category_id]) rescue nil @current_category = NewsBulletinCategory.from_id(params[:category_id]) rescue nil
elsif !params[:tag_id].blank? elsif !params[:tag_id].blank?
@tag = NewsTag.find(params[:tag_id]) rescue nil @tag = NewsTag.find(params[:tag_id]) rescue nil
@tag = NewsTag.where(key: params[:tag_id])[0] unless @tag @tag = NewsTag.where(key: params[:tag_id])[0] unless @tag
@news_bulletins = @tag.news_bulletins.can_display.any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page]).per(10) rescue nil @news_bulletins = @tag.news_bulletins.can_display.any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page]).per(5) rescue nil
else else
@news_bulletins = NewsBulletin.can_display.any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page]).per(10) @news_bulletins = NewsBulletin.can_display.any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page]).per(5)
end end
end end
@ -28,7 +29,6 @@ class Panel::News::Widget::NewsBulletinsController < OrbitWidgetController
@selected_tag = NewsTag.find(params[:id]) rescue @tags[0] @selected_tag = NewsTag.find(params[:id]) rescue @tags[0]
@news_bulletins = @selected_tag.get_visible_news_bulletins.can_display.page(params[:page]).per(5) rescue nil @news_bulletins = @selected_tag.get_visible_news_bulletins.can_display.page(params[:page]).per(5) rescue nil
@web_links = WebResourceTag.first(:conditions => {:en => @selected_tag[:en]}).get_visible_links.page(params[:page]).per(5) rescue nil @web_links = WebResourceTag.first(:conditions => {:en => @selected_tag[:en]}).get_visible_links.page(params[:page]).per(5) rescue nil
render :layout => 'module_widget'
end end
def reload_news_bulletins def reload_news_bulletins

View File

@ -3,9 +3,9 @@
<%= flash_messages %> <%= flash_messages %>
<% if @current_category %> <% if @current_category %>
<h1 class="h1"><%= @current_category.i18n_variable[I18n.locale] + t('news.news_bulletin.list_lower') %></h1> <h1 class="h1"><%= @current_category.i18n_variable[I18n.locale] %></h1>
<% else %> <% else %>
<h1 class="h1"><%= t('news.list_news') %></h1> <h1 class="h1"><%= t('news.news') %></h1>
<% end %> <% end %>
<table class="table table-bordered"> <table class="table table-bordered">
@ -28,5 +28,5 @@
</tbody> </tbody>
</table> </table>
<%= paginate @news_bulletins, :params => {:inner => 'false'} %> <%= paginate @news_bulletins, :param_name => :page_main, :params => {:inner => 'false'} %>

View File

@ -0,0 +1,27 @@
<% # encoding: utf-8 %>
<% if @title %>
<h1 class="h1"><%= @title %></h1>
<% end %>
<table class="table table-bordered">
<tbody>
<tr>
<th class="span2"><%= t('news.news_bulletin.image') %></th>
<th><%= t('news.news_bulletin.title') %></th>
<th class="span2 pagination-right"><%= t('news.news_bulletin.postdate') %></th>
</tr>
<% @news_bulletins.each do |post| %>
<tr>
<td><%= image_tag post.image %></td>
<td>
<%= link_to post.title[I18n.locale], panel_news_front_end_news_bulletin_path(post), :class => 'news_title' %>
<%= post.subtitle[I18n.locale].html_safe %>
</td>
<td><%= post.postdate %></td>
</tr>
<% end %>
</tbody>
</table>
<%= paginate @news_bulletins, :params => {:inner => 'true'}, :remote => true %>

View File

@ -1,33 +1,3 @@
<% # encoding: utf-8 %> <div id='news_bulletin_widget'>
<%= render 'index' %>
<%= flash_messages %> </div>
<% if @current_category %>
<h1 class="h1"><%= @current_category.i18n_variable[I18n.locale] + t('news.news_bulletin.list_lower') %></h1>
<% elsif @tag %>
<h1 class="h1"><%= @tag[I18n.locale] + t('news.news_bulletin.list_lower') %></h1>
<% else %>
<h1 class="h1"><%= t('news.list_news') %></h1>
<% end %>
<table class="table table-bordered">
<tbody>
<tr>
<th class="span2"><%= t('news.news_bulletin.image') %></th>
<th><%= t('news.news_bulletin.title') %></th>
<th class="span2 pagination-right"><%= t('news.news_bulletin.postdate') %></th>
</tr>
<% @news_bulletins.each do |post| %>
<tr>
<td><%= image_tag post.image %></td>
<td>
<%= link_to post.title[I18n.locale], panel_news_front_end_news_bulletin_path(post), :class => 'news_title' %>
<%= post.subtitle[I18n.locale].html_safe %>
</td>
<td><%= post.postdate %></td>
</tr>
<% end %>
</tbody>
</table>
<%= paginate @news_bulletins, :params => {:inner => 'false'} %>

View File

@ -0,0 +1 @@
$('#news_bulletin_widget').html("<%= j render 'index' %>")

View File

@ -16,4 +16,8 @@
<ul id='news_bulletins_web_links_web_links' class="links_list"> <ul id='news_bulletins_web_links_web_links' class="links_list">
<%= render 'web_links' if @web_links %> <%= render 'web_links' if @web_links %>
</ul> </ul>
</div> </div>
<% content_for :page_specific_javascript do %>
<%= javascript_include_tag "announcement_link" %>
<% end %>

View File

@ -63,7 +63,7 @@ en:
more: more+ more: more+
news_bulletins: NewsBulletins news_bulletins: NewsBulletins
related_links: Related Links related_links: Related Links
list_news: List News news: News
news_bulletin: news_bulletin:
category: Category category: Category
list_lower: " list" list_lower: " list"

View File

@ -43,9 +43,9 @@ zh_tw:
sure?: 確定嗎? sure?: 確定嗎?
campus_news: 校園新聞 campus_news: 校園新聞
more: 更多+ more: 更多+
news_bulletins: 公告訊息 news_bulletins: 新聞訊息
related_links: 相關連結 related_links: 相關連結
list_news: 公告列表 news: 新聞
news_bulletin: news_bulletin:
category: 分類 category: 分類
list_lower: 列表 list_lower: 列表

View File

@ -7,6 +7,6 @@
"update_info": "Some info", "update_info": "Some info",
"create_date": "11-11-2011", "create_date": "11-11-2011",
"app_pages": ["news_bulletins"], "app_pages": ["news_bulletins"],
"widgets": ["news_bulletins", "news_bulletins_and_web_links", "home_banner"], "widgets": ["news_bulletins", "home_banner"],
"enable_frontend": true "enable_frontend": true
} }

View File

@ -12,7 +12,7 @@ class Panel::WebResource::FrontEnd::WebLinksController < OrbitWidgetController
date_now = Time.now date_now = Time.now
@web_links = WebLink.where( :is_hidden => false ).desc(:is_top, :name).page( params[:page]).per(20) @web_links = WebLink.where( :is_hidden => false ).desc(:is_top, :name).page(params[:page]).per(10)
get_categorys get_categorys
end end

View File

@ -25,6 +25,7 @@ class Panel::WebResource::Widget::WebLinksController < OrbitWidgetController
def home_list def home_list
@title = params[:part_title]
# deadline # deadline

View File

@ -2,7 +2,7 @@
<%= flash_messages %> <%= flash_messages %>
<%= paginate @web_links %> <%= paginate @web_links, :params => {:inner => false}%>
<h1><%= t('web_link.list_web_resource') %></h1> <h1><%= t('web_link.list_web_resource') %></h1>

View File

@ -1,5 +1,7 @@
<div class="quicklinks"> <div class="quicklinks">
<h3 class="link_title"><%= t("announcement.related_links") %></h3> <% if @title %>
<h3 class="link_title"><%= @title %></h3>
<% end %>
<div id='web_links_links'> <div id='web_links_links'>
<%= render 'web_links' %> <%= render 'web_links' %>

View File

@ -13,7 +13,6 @@ Rails.application.routes.draw do
resources :tags resources :tags
end end
namespace :front_end do namespace :front_end do
root :to => "web_links#index"
resources :web_links resources :web_links
end end
namespace :widget do namespace :widget do

View File

@ -7,6 +7,6 @@
"update_info": "Some info", "update_info": "Some info",
"create_date": "11-11-2011", "create_date": "11-11-2011",
"app_pages": ["web_links"], "app_pages": ["web_links"],
"widgets": ["web_links", "home_list"], "widgets": ["home_list"],
"enable_frontend": true "enable_frontend": true
} }