From 803253ebcf8d2f89c00da0c241affbd199fbd679 Mon Sep 17 00:00:00 2001 From: Christophe Vilayphiou Date: Sat, 12 May 2012 22:12:17 +0800 Subject: [PATCH 1/6] Put nestedSortable in page_edit.js.erb --- .../{page_edit.js => page_edit.js.erb} | 21 ++++++++++++++++ .../admin/items/_site_map_left_bar.html.erb | 24 ------------------- 2 files changed, 21 insertions(+), 24 deletions(-) rename app/assets/javascripts/{page_edit.js => page_edit.js.erb} (63%) diff --git a/app/assets/javascripts/page_edit.js b/app/assets/javascripts/page_edit.js.erb similarity index 63% rename from app/assets/javascripts/page_edit.js rename to app/assets/javascripts/page_edit.js.erb index a889f5b2..7c0f6923 100644 --- a/app/assets/javascripts/page_edit.js +++ b/app/assets/javascripts/page_edit.js.erb @@ -32,3 +32,24 @@ $('.part_kind').live('click', function() { $('.part_kind_partial').hide(); $('#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() } ); + } + }); +}); \ No newline at end of file diff --git a/app/views/admin/items/_site_map_left_bar.html.erb b/app/views/admin/items/_site_map_left_bar.html.erb index b33023b4..8d32365f 100644 --- a/app/views/admin/items/_site_map_left_bar.html.erb +++ b/app/views/admin/items/_site_map_left_bar.html.erb @@ -1,25 +1 @@ <%= render_node_and_children(Item.first(:conditions => {:parent_id => nil})) %> - - - \ No newline at end of file From 82fa85def8838382c1ba8d89818c06835c6291cd Mon Sep 17 00:00:00 2001 From: Christophe Vilayphiou Date: Sun, 13 May 2012 19:32:05 +0800 Subject: [PATCH 2/6] Clean the parsers code --- app/controllers/application_controller.rb | 4 +- app/controllers/pages_controller.rb | 20 ++++---- app/helpers/application_helper.rb | 6 +-- lib/parsers/parser_back_end.rb | 58 ++--------------------- lib/parsers/parser_common.rb | 53 +++++++++++++++++++-- lib/parsers/parser_front_end.rb | 57 ++-------------------- 6 files changed, 70 insertions(+), 128 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 494b497e..4d8d6d48 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -95,9 +95,9 @@ class ApplicationController < ActionController::Base end # Render the page - def render_page(param={}) + def render_page if @item - render :text => process_page(@item, param[:id], param), :layout => 'page_layout' + render :text => parse_page_noko(@item), :layout => 'page_layout' else render :text => '404 Not Found' end diff --git a/app/controllers/pages_controller.rb b/app/controllers/pages_controller.rb index b781f202..c4a571dd 100644 --- a/app/controllers/pages_controller.rb +++ b/app/controllers/pages_controller.rb @@ -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)) case @item._type when 'Page' - render_page(params) + render_page when 'Link' redirect_to "http://#{@item[:url]}" end @@ -32,17 +32,19 @@ class PagesController < ApplicationController end def index_from_link - if params[:page] - redirect_to "/#{@item.path}?page=#{params[:page]}&category_id=#{params[:category_id]}&tag_id=#{params[:tag_id]}" - else - redirect_to "/#{@item.path}?category_id=#{params[:category_id]}&tag_id=#{params[:tag_id]}" - end + url = "/#{@item.path}" + options = '' + options << "?page=#{params[:page]}" unless params[:page].blank? + options << "#{options.blank? ? '?' : '&'}category_id=#{params[:category_id]}" unless params[:category_id].blank? + options << "#{options.blank? ? '?' : '&'}tag_id=#{params[:tag_id]}" unless params[:tag_id].blank? + redirect_to url + options end def show_from_link - # debugger - # a=1 - redirect_to "/#{@item.path}?id=#{params[:id]}&preview=#{params[:preview]}" + url = "/#{@item.path}?id=#{params[:id]}" + options = '' + options << "&preview=#{params[:preview]}" unless params[:preview].blank? + redirect_to url + options end def load_orbit_bar diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 37c2d0d2..32800d80 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -89,11 +89,7 @@ module ApplicationHelper 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 end - - def process_page(page, id, params) - parse_page_noko(page, id, params) - end - + def page_metas(page) tmp_meta = {} metas = '' diff --git a/lib/parsers/parser_back_end.rb b/lib/parsers/parser_back_end.rb index e9c08a01..aed8f36b 100644 --- a/lib/parsers/parser_back_end.rb +++ b/lib/parsers/parser_back_end.rb @@ -23,67 +23,19 @@ module ParserBackEnd # ret << "" # end - def parse_page_edit_noko(page, id = nil) + def parse_page_edit_noko(page) body = Nokogiri::HTML(page.design.layout.body) 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_footer(body, page, true) - parse_sub_menu(body, page, true) - + parse_footer(body, page) + parse_sub_menu(body, page) public_r_tags.each do |tag| - send("parse_#{tag}s", body, page, id, true) + send("parse_#{tag}s", body, page, true) end - body.to_html 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 << "
" - else - part = page.page_parts.detect{ |p| p.name.to_s == content['name'].to_s } rescue nil - ret << "
" if part - ret << "' - case part.kind - when 'text' - ret << part.i18n_variable[I18n.locale] rescue '' - when 'module_widget' - if !part[:category].blank? - ret << "
" - elsif !part[:tag].blank? - ret << "
" - else - ret << "
" - end - when 'public_r_tag' - ret << "" - 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}" - fragment = Nokogiri::HTML::DocumentFragment.new(body, scope) - content.swap(fragment) - end - public_r_tags.uniq - end - - def self.included(base) base.send :helper_method, :parse_page_edit_noko if base.respond_to? :helper_method end diff --git a/lib/parsers/parser_common.rb b/lib/parsers/parser_common.rb index 59bd85b3..180914b3 100644 --- a/lib/parsers/parser_common.rb +++ b/lib/parsers/parser_common.rb @@ -36,7 +36,7 @@ module ParserCommon end # 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| res = '' ad_banner = AdBanner.find(banner["id"]) rescue nil @@ -82,7 +82,7 @@ module ParserCommon end # 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| # 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 @@ -109,7 +109,7 @@ module ParserCommon end # 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| menu_page = Page.find(sub_menu['id']) rescue nil res = '' @@ -132,7 +132,7 @@ module ParserCommon end # page_footer - def parse_footer(body, page, edit=nil) + def parse_footer(body, page) page_footer = body.css('.page_footer').first if page_footer res = "
" @@ -146,7 +146,7 @@ module ParserCommon end # 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 if page_sub_menu res = "
" @@ -159,4 +159,47 @@ module ParserCommon 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 << "
" + else + part = page.page_parts.detect{ |p| p.name.to_s == content['name'].to_s } rescue nil + if edit + ret << "
" if part + ret << "' if edit + end + scope = "<#{content.name}" + content.attributes.each_pair do |key, value| + scope << " #{key}='#{value}'" + end + scope << ">#{ret}" + fragment = Nokogiri::HTML::DocumentFragment.new(body, scope) + content.swap(fragment) + end + public_r_tags.uniq + end + end diff --git a/lib/parsers/parser_front_end.rb b/lib/parsers/parser_front_end.rb index 6320f808..3d39bd5f 100644 --- a/lib/parsers/parser_front_end.rb +++ b/lib/parsers/parser_front_end.rb @@ -21,69 +21,18 @@ module ParserFrontEnd require 'nokogiri' - def parse_page_noko(page, id = nil,params) + def parse_page_noko(page) body = Nokogiri::HTML(page.design.layout.body) 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_footer(body, page) parse_sub_menu(body, page) - public_r_tags.each do |tag| - send("parse_#{tag}s", body, page,id) + send("parse_#{tag}s", body, page) end body.to_html 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 << "
" - 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 << "
" - # else - # ret << "
" - # end - if !part[:category].blank? - ret << "
" - elsif !part[:tag].blank? - ret << "
" - else - ret << "
" - end - when 'public_r_tag' - ret << "" - 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}" - fragment = Nokogiri::HTML::DocumentFragment.new(body, scope) - content.swap(fragment) - end - public_r_tags.uniq - end end From 4685952bd687609ccaaa5b9610b52ecd9cca2df2 Mon Sep 17 00:00:00 2001 From: Christophe Vilayphiou Date: Sun, 13 May 2012 20:13:26 +0800 Subject: [PATCH 3/6] Changes in page_edit --- app/assets/images/editicon.png | Bin 0 -> 2935 bytes app/assets/stylesheets/sidebar.css.erb | 1 + app/assets/stylesheets/style.css.erb | 28 +++++- app/views/admin/pages/_edit.html.erb | 19 ++-- app/views/admin/pages/_form.html.erb | 128 ++++++++++++++++--------- app/views/admin/pages/_new.html.erb | 22 ++--- lib/parsers/parser_common.rb | 2 +- 7 files changed, 132 insertions(+), 68 deletions(-) create mode 100644 app/assets/images/editicon.png diff --git a/app/assets/images/editicon.png b/app/assets/images/editicon.png new file mode 100644 index 0000000000000000000000000000000000000000..cef3e600041b8e110bc9050067807b87953ad38d GIT binary patch literal 2935 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 d{Bti2ZBWFK~`XBEIp0WS{ literal 0 HcmV?d00001 diff --git a/app/assets/stylesheets/sidebar.css.erb b/app/assets/stylesheets/sidebar.css.erb index 15922cc0..1e4b4010 100644 --- a/app/assets/stylesheets/sidebar.css.erb +++ b/app/assets/stylesheets/sidebar.css.erb @@ -11,6 +11,7 @@ } .nav-list ol li { padding: 5px 0; + list-style: none; } .nav-list ol li a { font-size: 13px; diff --git a/app/assets/stylesheets/style.css.erb b/app/assets/stylesheets/style.css.erb index c4b2e93c..ba1c3066 100644 --- a/app/assets/stylesheets/style.css.erb +++ b/app/assets/stylesheets/style.css.erb @@ -110,10 +110,8 @@ padding:6px; } #orbit-bar .nav > li.search { - background-image: none; overflow: hidden; width: 28px; - margin-bottom: 0; position: relative; } #orbit-bar .nav > li > a.orbit-bar-home { @@ -686,6 +684,32 @@ z-index: 2 !important; } +#back_main .editable { + position: relative; +} +#back_main .editable:after { + content: ''; + clear: both; + display: block; + visibility: hidden; + height: 0; +} + +#back_main .edit_link a { + position: absolute; + z-index: 10; + width: 100%; + height: 100%; + top: 0; + left: 0; + text-indent: -9999px; + background: url(<%= asset_path 'editicon.png' %>) no-repeat center center rgba(255,255,255,.8); + -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 8px rgba(82, 168, 236, 1); + -moz-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 8px rgba(82, 168, 236, 1); + box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 8px rgba(82, 168, 236, 1); +} + + [class^="icons-"] { display: inline-block; width: 16px; diff --git a/app/views/admin/pages/_edit.html.erb b/app/views/admin/pages/_edit.html.erb index 61ff8046..d81a533d 100644 --- a/app/views/admin/pages/_edit.html.erb +++ b/app/views/admin/pages/_edit.html.erb @@ -1,10 +1,11 @@ <%= flash_messages %> - -

<%= t('admin.editing_page') %>

- -<%= form_for @item, :url => admin_page_path(@item) do |f| %> - <%= render :partial => "form", :locals => { :f => f } %> -

- <%= f.submit t('update') %> <%= link_back %> -

-<% end %> \ No newline at end of file +
+

<%= t('admin.editing_page') %>

+ <%= form_for @item, :url => admin_page_path(@item), :html => { :class => 'form-horizontal edit_page' } do |f| %> + <%= render :partial => "form", :locals => { :f => f } %> +
+ <%= f.submit t('update'), :class => 'btn btn-primary' %> + <%= link_to t('cancel'), get_go_back, :class=>"btn" %> +
+ <% end %> +
\ No newline at end of file diff --git a/app/views/admin/pages/_form.html.erb b/app/views/admin/pages/_form.html.erb index 7aae7c00..36e6e008 100644 --- a/app/views/admin/pages/_form.html.erb +++ b/app/views/admin/pages/_form.html.erb @@ -1,52 +1,92 @@ <%= f.error_messages %> <%= f.hidden_field :parent, :value => (@item.parent.id rescue nil) %> -

-<%= f.label :name, t('admin.name') %> -<%= f.text_field :name, :class => 'text' %> -

+
+ <%= f.label :name, t('admin.name'), :class => 'control-label' %> +
+ <%= f.text_field :name, :class => 'text input-xlarge' %> + +
+
<%= f.fields_for :i18n_variable, (@item.new_record? ? @item.build_i18n_variable : @item.i18n_variable) do |f| %> - <% @site_valid_locales.each do |locale| %> -

- <%= f.label :locale, "#{t('admin.title')} #{I18nVariable.from_locale(locale)}" %> - <%= f.text_field locale %> -

- <% end %> + <% @site_valid_locales.each do |locale| %> +
+ <%= f.label :locale, "#{t('admin.title')} #{I18nVariable.from_locale(locale)}", :class => 'control-label' %> +
+ <%= f.text_field locale, :class => 'text input-xlarge' %> + +
+
+ <% end %> <% end %> -

- <%= t('admin.design_name') %> - <%= f.collection_select :design, @designs, :id, :title, {:selected => @design.id}, {:rel => admin_pages_path} %> -

-

- <%= t('admin.theme') %> - <%= f.select :theme_id, @design.themes.collect { |t| [t.name.capitalize, t.id] }, :include_blank => true %> -

-

- <%= t('admin.module_app') %> - <%= render :partial => "app_selector", :locals => { :f => f } %> - <%= select('page','app_frontend_url', @app_frontend_urls, :selected => @item.app_frontend_url ) rescue ''%> - <%= select('page','category', @categories.collect{|category| [category.i18n_variable[I18n.locale], category.id]}, :selected => @item[:category], :include_blank => true ) rescue ''%> -

-

- <%= f.label :is_published, "#{t('admin.is_published')} ?" %> - <%= f.radio_button :is_published, true %>Yes <%= f.radio_button :is_published, false %> No -

-

- <%= f.label :menu_enabled_for, "#{t('admin.menu_enabled_for')}:" %> - <% @site_valid_locales.each do |valid_locale| %> - <%= check_box_tag 'page[menu_enabled_for][]', valid_locale, (@item.menu_enabled_for.nil? ? true : @item.menu_enabled_for.include?(valid_locale)) %> - <%= I18nVariable.from_locale(valid_locale) %> - <% end %> - <%= hidden_field_tag 'page[menu_enabled_for][]', '' %> -

-

- <%= f.label :enabled_for, "#{t('admin.enabled_for')}:" %> - <% @site_valid_locales.each do |valid_locale| %> - <%= check_box_tag 'page[enabled_for][]', valid_locale, (@item.enabled_for.nil? ? true : @item.enabled_for.include?(valid_locale)) %> - <%= I18nVariable.from_locale(valid_locale) %> - <% end %> - <%= hidden_field_tag 'page[enabled_for][]', '' %> -

+
+ <%= f.label :name, t('admin.design_name'), :class => 'control-label' %> +
+ <%= f.collection_select :design, @designs, :id, :title, {:selected => @design.id}, {:rel => admin_pages_path} %> + +
+
+
+ <%= f.label :name, t('admin.theme'), :class => 'control-label' %> +
+ <%= f.select :theme_id, @design.themes.collect { |t| [t.name.capitalize, t.id] }, :include_blank => true %> + +
+
+
+ <%= f.label :name, t('admin.module_app'), :class => 'control-label' %> +
+ <%= render :partial => "app_selector", :locals => { :f => f } %> + + <%= select('page','app_frontend_url', @app_frontend_urls, :selected => @item.app_frontend_url ) rescue ''%> + + + <%= select('page','category', @categories.collect{|category| [category.i18n_variable[I18n.locale], category.id]}, :selected => @item[:category], :include_blank => true ) rescue ''%> + + +
+
+
+ <%= f.label :is_published, "#{t('admin.is_published')} ?", :class => 'control-label' %> +
+ + + +
+
+
+ <%= f.label :menu_enabled_for, "#{t('admin.menu_enabled_for')}:", :class => 'control-label' %> +
+ <% @site_valid_locales.each do |valid_locale| %> + + <% end %> + <%= hidden_field_tag 'page[menu_enabled_for][]', '' %> + +
+
+ +
+ <%= f.label :enabled_for, "#{t('admin.enabled_for')}:", :class => 'control-label' %> +
+ <% @site_valid_locales.each do |valid_locale| %> + + <% end %> + <%= hidden_field_tag 'page[enabled_for][]', '' %> + +
+
diff --git a/app/views/admin/pages/_new.html.erb b/app/views/admin/pages/_new.html.erb index a2991bec..d3190e0e 100644 --- a/app/views/admin/pages/_new.html.erb +++ b/app/views/admin/pages/_new.html.erb @@ -1,13 +1,11 @@ -

<%= t('admin.new_page') %>

- <%= flash_messages %> - -<%= form_for @item, :url => admin_pages_path, :html => { :class => 'form' } do |f| %> - - <%= render :partial => "form", :locals => { :f => f } %> - -

- <%= f.submit t('create') %> <%= link_back %> -

- -<% end %> \ No newline at end of file +
+

<%= t('admin.new_page') %>

+ <%= form_for @item, :url => admin_page_path, :html => { :class => 'form-horizontal edit_page' } do |f| %> + <%= render :partial => "form", :locals => { :f => f } %> +
+ <%= f.submit t('update'), :class => 'btn btn-primary' %> + <%= link_to t('cancel'), get_go_back, :class=>"btn" %> +
+ <% end %> +
\ No newline at end of file diff --git a/lib/parsers/parser_common.rb b/lib/parsers/parser_common.rb index 180914b3..f9dd868a 100644 --- a/lib/parsers/parser_common.rb +++ b/lib/parsers/parser_common.rb @@ -175,6 +175,7 @@ module ParserCommon ret << "
" if part ret << "' end case part.kind when 'text' @@ -189,7 +190,6 @@ module ParserCommon else '' end if part - ret << '
' if edit end scope = "<#{content.name}" content.attributes.each_pair do |key, value| From 281cfa6518651438809001dfae3e15d51bbca13a Mon Sep 17 00:00:00 2001 From: Christophe Vilayphiou Date: Sun, 13 May 2012 21:55:39 +0800 Subject: [PATCH 4/6] Changes for widgets --- .../assets/javascripts/module.js.erb | 1 - .../orbit_frontend_component_controller.rb | 2 +- app/views/admin/page_parts/_text.html.erb | 4 ++- app/views/layouts/module_widget.html.erb | 4 ++- .../app/assets/javascripts/module_widget.js | 9 ----- .../widget/bulletins_controller.rb | 1 - .../widget/bulletins/_index.html.erb | 29 +++++++++++++++ .../bulletins_and_web_links.html.erb | 6 +++- .../widget/bulletins/index.html.erb | 32 ++--------------- .../widget/bulletins/index.js.erb | 1 + .../news/widget/news_bulletins_controller.rb | 7 ++-- .../widget/news_bulletins/_index.html.erb | 33 +++++++++++++++++ .../news/widget/news_bulletins/index.html.erb | 36 ++----------------- .../news/widget/news_bulletins/index.js.erb | 1 + .../news_bulletins_and_web_links.html.erb | 6 +++- vendor/built_in_modules/news/news.json | 2 +- .../assets/javascripts/web_resource/.gitkeep | 0 .../front_end/web_links_controller.rb | 2 +- .../front_end/web_links/index.html.erb | 2 +- .../front_end/web_links/index.js.erb | 1 + .../web_resource/config/routes.rb | 1 - .../web_resource/web_resource.json | 2 +- 22 files changed, 95 insertions(+), 87 deletions(-) rename vendor/built_in_modules/news/app/assets/javascripts/module_widget.js => app/assets/javascripts/module.js.erb (95%) delete mode 100644 vendor/built_in_modules/announcement/app/assets/javascripts/module_widget.js create mode 100644 vendor/built_in_modules/announcement/app/views/panel/announcement/widget/bulletins/_index.html.erb create mode 100644 vendor/built_in_modules/announcement/app/views/panel/announcement/widget/bulletins/index.js.erb create mode 100644 vendor/built_in_modules/news/app/views/panel/news/widget/news_bulletins/_index.html.erb create mode 100644 vendor/built_in_modules/news/app/views/panel/news/widget/news_bulletins/index.js.erb delete mode 100644 vendor/built_in_modules/web_resource/app/assets/javascripts/web_resource/.gitkeep create mode 100644 vendor/built_in_modules/web_resource/app/views/panel/web_resource/front_end/web_links/index.js.erb diff --git a/vendor/built_in_modules/news/app/assets/javascripts/module_widget.js b/app/assets/javascripts/module.js.erb similarity index 95% rename from vendor/built_in_modules/news/app/assets/javascripts/module_widget.js rename to app/assets/javascripts/module.js.erb index aea46d72..fc19b8e6 100644 --- a/vendor/built_in_modules/news/app/assets/javascripts/module_widget.js +++ b/app/assets/javascripts/module.js.erb @@ -6,4 +6,3 @@ // //= require jquery //= require jquery_ujs -//= require news_link \ No newline at end of file diff --git a/app/controllers/orbit_frontend_component_controller.rb b/app/controllers/orbit_frontend_component_controller.rb index 185dbce6..09621e5f 100644 --- a/app/controllers/orbit_frontend_component_controller.rb +++ b/app/controllers/orbit_frontend_component_controller.rb @@ -1,7 +1,7 @@ class OrbitFrontendComponentController< ApplicationController before_filter :setup_vars before_filter {|c| c.front_end_available(@app_title)} - layout :false + layout "module_widget" def setup_vars @app_title = request.fullpath.split('/')[2] diff --git a/app/views/admin/page_parts/_text.html.erb b/app/views/admin/page_parts/_text.html.erb index 4193cf50..529773e3 100644 --- a/app/views/admin/page_parts/_text.html.erb +++ b/app/views/admin/page_parts/_text.html.erb @@ -8,5 +8,7 @@ <% end %> diff --git a/app/views/layouts/module_widget.html.erb b/app/views/layouts/module_widget.html.erb index 44a2be85..793f7370 100644 --- a/app/views/layouts/module_widget.html.erb +++ b/app/views/layouts/module_widget.html.erb @@ -5,7 +5,9 @@ <%= javascript_include_tag "html5" %> <%#= 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 %> diff --git a/vendor/built_in_modules/announcement/app/assets/javascripts/module_widget.js b/vendor/built_in_modules/announcement/app/assets/javascripts/module_widget.js deleted file mode 100644 index 9c429aac..00000000 --- a/vendor/built_in_modules/announcement/app/assets/javascripts/module_widget.js +++ /dev/null @@ -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 \ No newline at end of file diff --git a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/widget/bulletins_controller.rb b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/widget/bulletins_controller.rb index 57295cc7..ad3eec72 100644 --- a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/widget/bulletins_controller.rb +++ b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/widget/bulletins_controller.rb @@ -31,7 +31,6 @@ class Panel::Announcement::Widget::BulletinsController < OrbitWidgetController @selected_tag = AnnouncementTag.find(params[:id]) rescue @tags[0] @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 - render :layout => 'module_widget' end def reload_bulletins diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/widget/bulletins/_index.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/widget/bulletins/_index.html.erb new file mode 100644 index 00000000..4213ed29 --- /dev/null +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/widget/bulletins/_index.html.erb @@ -0,0 +1,29 @@ +<% if @current_category %> +

<%= @current_category.i18n_variable[I18n.locale] + t('announcement.bulletin.list_lower') %>

+<% elsif @tag %> +

<%= @tag[I18n.locale] + t('announcement.bulletin.list_lower') %>

+<% else %> +

<%= t('announcement.list_announcement') %>

+<% end %> + + + + + + + + + +<% @bulletins.each do |post| %> + + + + + + +<% end %> + +
<%= t('announcement.bulletin.category') %><%= t('announcement.bulletin.title') %><%= t('announcement.bulletin.postdate') %>
<%= post.bulletin_category.i18n_variable[I18n.locale] %><%= link_to post.title[I18n.locale], panel_announcement_front_end_bulletin_path(post, :category_id => post.bulletin_category_id) %> + <%= post.postdate %>
+ +<%= paginate @bulletins, :params => {:inner => 'true'}, :remote => true %> \ No newline at end of file diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/widget/bulletins/bulletins_and_web_links.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/widget/bulletins/bulletins_and_web_links.html.erb index 3e628120..50ae0674 100644 --- a/vendor/built_in_modules/announcement/app/views/panel/announcement/widget/bulletins/bulletins_and_web_links.html.erb +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/widget/bulletins/bulletins_and_web_links.html.erb @@ -16,4 +16,8 @@ -
\ No newline at end of file +
+ +<% content_for :page_specific_javascript do %> + <%= javascript_include_tag "news_link" %> +<% end %> \ No newline at end of file diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/widget/bulletins/index.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/widget/bulletins/index.html.erb index c885488f..dacb9eaf 100644 --- a/vendor/built_in_modules/announcement/app/views/panel/announcement/widget/bulletins/index.html.erb +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/widget/bulletins/index.html.erb @@ -1,29 +1,3 @@ -<% if @current_category %> -

<%= @current_category.i18n_variable[I18n.locale] + t('announcement.bulletin.list_lower') %>

-<% elsif @tag %> -

<%= @tag[I18n.locale] + t('announcement.bulletin.list_lower') %>

-<% else %> -

<%= t('announcement.list_announcement') %>

-<% end %> - - - - - - - - - -<% @bulletins.each do |post| %> - - - - - - -<% end %> - -
<%= t('announcement.bulletin.category') %><%= t('announcement.bulletin.title') %><%= t('announcement.bulletin.postdate') %>
<%= post.bulletin_category.i18n_variable[I18n.locale] %><%= link_to post.title[I18n.locale], panel_announcement_front_end_bulletin_path(post, :category_id => post.bulletin_category_id) %> - <%= post.postdate %>
- -<%= paginate @bulletins, :params => {:inner => 'false'} %> \ No newline at end of file +
+ <%= render 'index' %> +
\ No newline at end of file diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/widget/bulletins/index.js.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/widget/bulletins/index.js.erb new file mode 100644 index 00000000..e1be79eb --- /dev/null +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/widget/bulletins/index.js.erb @@ -0,0 +1 @@ +$('#bulletin_widget').html("<%= j render 'index' %>") \ No newline at end of file diff --git a/vendor/built_in_modules/news/app/controllers/panel/news/widget/news_bulletins_controller.rb b/vendor/built_in_modules/news/app/controllers/panel/news/widget/news_bulletins_controller.rb index a6d20ca7..27e83c00 100644 --- a/vendor/built_in_modules/news/app/controllers/panel/news/widget/news_bulletins_controller.rb +++ b/vendor/built_in_modules/news/app/controllers/panel/news/widget/news_bulletins_controller.rb @@ -11,14 +11,14 @@ class Panel::News::Widget::NewsBulletinsController < OrbitWidgetController def index date_now = Time.now 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 elsif !params[:tag_id].blank? @tag = NewsTag.find(params[:tag_id]) rescue nil @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 - @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 @@ -28,7 +28,6 @@ class Panel::News::Widget::NewsBulletinsController < OrbitWidgetController @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 @web_links = WebResourceTag.first(:conditions => {:en => @selected_tag[:en]}).get_visible_links.page(params[:page]).per(5) rescue nil - render :layout => 'module_widget' end def reload_news_bulletins diff --git a/vendor/built_in_modules/news/app/views/panel/news/widget/news_bulletins/_index.html.erb b/vendor/built_in_modules/news/app/views/panel/news/widget/news_bulletins/_index.html.erb new file mode 100644 index 00000000..fd3d477a --- /dev/null +++ b/vendor/built_in_modules/news/app/views/panel/news/widget/news_bulletins/_index.html.erb @@ -0,0 +1,33 @@ +<% # encoding: utf-8 %> + +<%= flash_messages %> + +<% if @current_category %> +

<%= @current_category.i18n_variable[I18n.locale] + t('news.news_bulletin.list_lower') %>

+<% elsif @tag %> +

<%= @tag[I18n.locale] + t('news.news_bulletin.list_lower') %>

+<% else %> +

<%= t('news.list_news') %>

+<% end %> + + + + + + + + + <% @news_bulletins.each do |post| %> + + + + + + <% end %> + +
<%= t('news.news_bulletin.image') %><%= t('news.news_bulletin.title') %><%= t('news.news_bulletin.postdate') %>
<%= image_tag post.image %> + <%= link_to post.title[I18n.locale], panel_news_front_end_news_bulletin_path(post), :class => 'news_title' %> + <%= post.subtitle[I18n.locale].html_safe %> + <%= post.postdate %>
+ +<%= paginate @news_bulletins, :params => {:inner => 'true'}, :remote => true %> diff --git a/vendor/built_in_modules/news/app/views/panel/news/widget/news_bulletins/index.html.erb b/vendor/built_in_modules/news/app/views/panel/news/widget/news_bulletins/index.html.erb index bb2ff639..1b59c3f9 100644 --- a/vendor/built_in_modules/news/app/views/panel/news/widget/news_bulletins/index.html.erb +++ b/vendor/built_in_modules/news/app/views/panel/news/widget/news_bulletins/index.html.erb @@ -1,33 +1,3 @@ -<% # encoding: utf-8 %> - -<%= flash_messages %> - -<% if @current_category %> -

<%= @current_category.i18n_variable[I18n.locale] + t('news.news_bulletin.list_lower') %>

-<% elsif @tag %> -

<%= @tag[I18n.locale] + t('news.news_bulletin.list_lower') %>

-<% else %> -

<%= t('news.list_news') %>

-<% end %> - - - - - - - - - <% @news_bulletins.each do |post| %> - - - - - - <% end %> - -
<%= t('news.news_bulletin.image') %><%= t('news.news_bulletin.title') %><%= t('news.news_bulletin.postdate') %>
<%= image_tag post.image %> - <%= link_to post.title[I18n.locale], panel_news_front_end_news_bulletin_path(post), :class => 'news_title' %> - <%= post.subtitle[I18n.locale].html_safe %> - <%= post.postdate %>
- -<%= paginate @news_bulletins, :params => {:inner => 'false'} %> +
+ <%= render 'index' %> +
\ No newline at end of file diff --git a/vendor/built_in_modules/news/app/views/panel/news/widget/news_bulletins/index.js.erb b/vendor/built_in_modules/news/app/views/panel/news/widget/news_bulletins/index.js.erb new file mode 100644 index 00000000..d4862b87 --- /dev/null +++ b/vendor/built_in_modules/news/app/views/panel/news/widget/news_bulletins/index.js.erb @@ -0,0 +1 @@ +$('#news_bulletin_widget').html("<%= j render 'index' %>") \ No newline at end of file diff --git a/vendor/built_in_modules/news/app/views/panel/news/widget/news_bulletins/news_bulletins_and_web_links.html.erb b/vendor/built_in_modules/news/app/views/panel/news/widget/news_bulletins/news_bulletins_and_web_links.html.erb index 9e8ae742..b71f26f9 100644 --- a/vendor/built_in_modules/news/app/views/panel/news/widget/news_bulletins/news_bulletins_and_web_links.html.erb +++ b/vendor/built_in_modules/news/app/views/panel/news/widget/news_bulletins/news_bulletins_and_web_links.html.erb @@ -16,4 +16,8 @@ -
\ No newline at end of file +
+ +<% content_for :page_specific_javascript do %> + <%= javascript_include_tag "announcement_link" %> +<% end %> \ No newline at end of file diff --git a/vendor/built_in_modules/news/news.json b/vendor/built_in_modules/news/news.json index 74b2bfcc..e1b5c95e 100644 --- a/vendor/built_in_modules/news/news.json +++ b/vendor/built_in_modules/news/news.json @@ -7,6 +7,6 @@ "update_info": "Some info", "create_date": "11-11-2011", "app_pages": ["news_bulletins"], - "widgets": ["news_bulletins", "news_bulletins_and_web_links", "home_banner"], + "widgets": ["news_bulletins", "home_banner"], "enable_frontend": true } diff --git a/vendor/built_in_modules/web_resource/app/assets/javascripts/web_resource/.gitkeep b/vendor/built_in_modules/web_resource/app/assets/javascripts/web_resource/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/vendor/built_in_modules/web_resource/app/controllers/panel/web_resource/front_end/web_links_controller.rb b/vendor/built_in_modules/web_resource/app/controllers/panel/web_resource/front_end/web_links_controller.rb index 82804979..e605c768 100644 --- a/vendor/built_in_modules/web_resource/app/controllers/panel/web_resource/front_end/web_links_controller.rb +++ b/vendor/built_in_modules/web_resource/app/controllers/panel/web_resource/front_end/web_links_controller.rb @@ -12,7 +12,7 @@ class Panel::WebResource::FrontEnd::WebLinksController < OrbitWidgetController 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 end diff --git a/vendor/built_in_modules/web_resource/app/views/panel/web_resource/front_end/web_links/index.html.erb b/vendor/built_in_modules/web_resource/app/views/panel/web_resource/front_end/web_links/index.html.erb index 2c30da53..2c32f800 100644 --- a/vendor/built_in_modules/web_resource/app/views/panel/web_resource/front_end/web_links/index.html.erb +++ b/vendor/built_in_modules/web_resource/app/views/panel/web_resource/front_end/web_links/index.html.erb @@ -2,7 +2,7 @@ <%= flash_messages %> -<%= paginate @web_links %> +<%= paginate @web_links, :params => {:inner => false}%>

<%= t('web_link.list_web_resource') %>

diff --git a/vendor/built_in_modules/web_resource/app/views/panel/web_resource/front_end/web_links/index.js.erb b/vendor/built_in_modules/web_resource/app/views/panel/web_resource/front_end/web_links/index.js.erb new file mode 100644 index 00000000..c5efda63 --- /dev/null +++ b/vendor/built_in_modules/web_resource/app/views/panel/web_resource/front_end/web_links/index.js.erb @@ -0,0 +1 @@ +alert('bob'); \ No newline at end of file diff --git a/vendor/built_in_modules/web_resource/config/routes.rb b/vendor/built_in_modules/web_resource/config/routes.rb index fed85983..02c81a82 100644 --- a/vendor/built_in_modules/web_resource/config/routes.rb +++ b/vendor/built_in_modules/web_resource/config/routes.rb @@ -13,7 +13,6 @@ Rails.application.routes.draw do resources :tags end namespace :front_end do - root :to => "web_links#index" resources :web_links end namespace :widget do diff --git a/vendor/built_in_modules/web_resource/web_resource.json b/vendor/built_in_modules/web_resource/web_resource.json index c27bf731..f87f06a2 100644 --- a/vendor/built_in_modules/web_resource/web_resource.json +++ b/vendor/built_in_modules/web_resource/web_resource.json @@ -7,6 +7,6 @@ "update_info": "Some info", "create_date": "11-11-2011", "app_pages": ["web_links"], - "widgets": ["web_links", "home_list"], + "widgets": ["home_list"], "enable_frontend": true } From 4ae829994936941ac80cca3edc02f19c77de7ae5 Mon Sep 17 00:00:00 2001 From: Christophe Vilayphiou Date: Sun, 13 May 2012 22:35:00 +0800 Subject: [PATCH 5/6] Add custom title to widgets Fix pagination conflict with main_content and widgets --- app/controllers/pages_controller.rb | 2 +- app/models/page_part.rb | 20 ++++++++++++++++++- .../admin/page_parts/_module_widget.html.erb | 11 ++++++++++ lib/parsers/parser_common.rb | 5 +++-- .../front_end/bulletins_controller.rb | 6 +++--- .../widget/bulletins_controller.rb | 2 +- .../front_end/bulletins/index.html.erb | 2 +- .../widget/bulletins/_index.html.erb | 8 ++------ .../front_end/news_bulletins_controller.rb | 6 +++--- .../news/widget/news_bulletins_controller.rb | 1 + .../front_end/news_bulletins/index.html.erb | 2 +- .../widget/news_bulletins/_index.html.erb | 10 ++-------- .../widget/web_links_controller.rb | 1 + .../widget/web_links/home_list.html.erb | 4 +++- 14 files changed, 52 insertions(+), 28 deletions(-) diff --git a/app/controllers/pages_controller.rb b/app/controllers/pages_controller.rb index c4a571dd..45299450 100644 --- a/app/controllers/pages_controller.rb +++ b/app/controllers/pages_controller.rb @@ -34,7 +34,7 @@ class PagesController < ApplicationController def index_from_link url = "/#{@item.path}" options = '' - options << "?page=#{params[:page]}" unless params[:page].blank? + options << "?page_main=#{params[:page_main]}" unless params[:page_main].blank? options << "#{options.blank? ? '?' : '&'}category_id=#{params[:category_id]}" unless params[:category_id].blank? options << "#{options.blank? ? '?' : '&'}tag_id=#{params[:tag_id]}" unless params[:tag_id].blank? redirect_to url + options diff --git a/app/models/page_part.rb b/app/models/page_part.rb index 8bb1bc72..52eafdf3 100644 --- a/app/models/page_part.rb +++ b/app/models/page_part.rb @@ -11,9 +11,27 @@ class PagePart field :public_r_tag_option, :default => nil 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 :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 \ No newline at end of file diff --git a/app/views/admin/page_parts/_module_widget.html.erb b/app/views/admin/page_parts/_module_widget.html.erb index 3f81a5ae..1a1dd63c 100644 --- a/app/views/admin/page_parts/_module_widget.html.erb +++ b/app/views/admin/page_parts/_module_widget.html.erb @@ -1,3 +1,14 @@ +
+ <%= f.fields_for :title, @part.title do |f| %> + <% @site_valid_locales.each do |locale| %> +

+ <%= f.label :locale, "#{t('admin.title')} #{I18nVariable.from_locale(locale)}" %> + <%= f.text_field locale %> +

+ <% end %> +<% end %> +
+ <%= f.select :module_app, options_from_collection_for_select(@module_apps, :id, :title, :selected => @module_app.id), {}, {:rel => admin_page_parts_path} %> diff --git a/lib/parsers/parser_common.rb b/lib/parsers/parser_common.rb index f9dd868a..b9c56642 100644 --- a/lib/parsers/parser_common.rb +++ b/lib/parsers/parser_common.rb @@ -167,10 +167,11 @@ module ParserCommon if (content["main"] == "true" && !page.module_app.nil?) ret << "
" 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 << "
" if part ret << "