From ebf3a2eae451ec7e38fcfd1e21533322f90999f3 Mon Sep 17 00:00:00 2001 From: Christophe Vilayphiou Date: Thu, 1 Mar 2012 10:57:13 +0800 Subject: [PATCH 001/125] Fix extra loaded js: the widgets only need to render layout when they need js. --- app/controllers/obit_frontend_component_controller.rb | 2 +- .../panel/announcement/widget/bulletins_controller.rb | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/app/controllers/obit_frontend_component_controller.rb b/app/controllers/obit_frontend_component_controller.rb index d0be3a25..2c44b60c 100644 --- a/app/controllers/obit_frontend_component_controller.rb +++ b/app/controllers/obit_frontend_component_controller.rb @@ -1,7 +1,7 @@ class ObitFrontendComponentController< ApplicationController before_filter :setup_vars before_filter {|c| c.front_end_available(@app_title)} - layout 'module_widget' + layout :false def setup_vars @app_title = request.fullpath.split('/')[2] 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 6695156a..333f88e7 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 @@ -28,6 +28,7 @@ class Panel::Announcement::Widget::BulletinsController < ObitWidgetController @selected_tag = AnnouncementTag.find(params[:id]) rescue @tags[0] @bulletins = @selected_tag.get_visible_bulletins.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 From 9ae140204f62bae987fddd1fb3eb393e1880bd89 Mon Sep 17 00:00:00 2001 From: Christophe Vilayphiou Date: Thu, 1 Mar 2012 10:58:31 +0800 Subject: [PATCH 002/125] Fix announcement pagination in front-end --- app/controllers/pages_controller.rb | 6 +++++- lib/parsers/parser_back_end.rb | 2 +- lib/parsers/parser_front_end.rb | 2 +- .../panel/announcement/front_end/bulletins_controller.rb | 6 +++--- .../panel/announcement/front_end/bulletins/index.html.erb | 4 ++-- vendor/built_in_modules/announcement/config/routes.rb | 1 - 6 files changed, 12 insertions(+), 9 deletions(-) diff --git a/app/controllers/pages_controller.rb b/app/controllers/pages_controller.rb index aa66238d..8ea35391 100644 --- a/app/controllers/pages_controller.rb +++ b/app/controllers/pages_controller.rb @@ -30,7 +30,11 @@ class PagesController < ApplicationController end def index_from_link - redirect_to "/#{@item.full_name}" + if params[:page] + redirect_to "/#{@item.full_name}?page=#{params[:page]}" + else + redirect_to "/#{@item.full_name}" + end end def show_from_link diff --git a/lib/parsers/parser_back_end.rb b/lib/parsers/parser_back_end.rb index dea65b6a..37c22ed1 100644 --- a/lib/parsers/parser_back_end.rb +++ b/lib/parsers/parser_back_end.rb @@ -100,7 +100,7 @@ module ParserBackEnd ret = '' if (tag.attributes["main"] == "true" && !page.module_app.nil?) ret << "
" else part = page.page_parts.detect{ |p| p.name.to_s == tag.attr['name'].to_s } diff --git a/lib/parsers/parser_front_end.rb b/lib/parsers/parser_front_end.rb index 305596ed..17468e54 100644 --- a/lib/parsers/parser_front_end.rb +++ b/lib/parsers/parser_front_end.rb @@ -127,7 +127,7 @@ module ParserFrontEnd ret << "
" else part = page.page_parts.detect{ |p| p.name.to_s == tag.attr['name'].to_s } rescue nil diff --git a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/front_end/bulletins_controller.rb b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/front_end/bulletins_controller.rb index b71a4609..e840d65f 100644 --- a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/front_end/bulletins_controller.rb +++ b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/front_end/bulletins_controller.rb @@ -11,15 +11,15 @@ class Panel::Announcement::FrontEnd::BulletinsController < ObitWidgetController def index date_now = Time.now - if params[:bulletin_category_id] - @bulletins = Bulletin.where(:bulletin_category_id => params[:bulletin_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) + if params[:category_id] + @bulletins = Bulletin.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) else @bulletins = Bulletin.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) end get_categorys - @current_category = BulletinCategory.from_id(params[:bulletin_category_id]) rescue nil + @current_category = BulletinCategory.from_id(params[:category_id]) rescue nil end def show diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/front_end/bulletins/index.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/front_end/bulletins/index.html.erb index d4335e9a..086794b9 100644 --- a/vendor/built_in_modules/announcement/app/views/panel/announcement/front_end/bulletins/index.html.erb +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/front_end/bulletins/index.html.erb @@ -28,6 +28,6 @@ <% end %> - -<%= paginate @bulletins %> + +<%= paginate @bulletins, :params => {:inner => 'false'} %> diff --git a/vendor/built_in_modules/announcement/config/routes.rb b/vendor/built_in_modules/announcement/config/routes.rb index c3a60f74..a604da85 100644 --- a/vendor/built_in_modules/announcement/config/routes.rb +++ b/vendor/built_in_modules/announcement/config/routes.rb @@ -10,7 +10,6 @@ Rails.application.routes.draw do resources :tags end namespace :front_end do - root :to => "bulletins#index" resources :bulletins end namespace :widget do From 826a5a5f20f158237dc49b36e3692183111f31d5 Mon Sep 17 00:00:00 2001 From: Christophe Vilayphiou Date: Thu, 1 Mar 2012 14:12:47 +0800 Subject: [PATCH 003/125] Fix link in widget --- .../panel/announcement/widget/bulletins/_web_links.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/widget/bulletins/_web_links.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/widget/bulletins/_web_links.html.erb index 3a6982dc..2b65417d 100644 --- a/vendor/built_in_modules/announcement/app/views/panel/announcement/widget/bulletins/_web_links.html.erb +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/widget/bulletins/_web_links.html.erb @@ -1,6 +1,6 @@ <% @web_links.each do |web_link| %>
  • - <%= web_link.name[I18n.locale] %> + <%= link_to web_link.name[I18n.locale], web_link.url %>
  • <% end %> From 900855724c4e06984b3291fe4bdae46399f94b24 Mon Sep 17 00:00:00 2001 From: Christophe Vilayphiou Date: Wed, 7 Mar 2012 11:37:00 +0800 Subject: [PATCH 004/125] Add bootstrap-orbit.css in front-end --- lib/parsers/parser_front_end.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/parsers/parser_front_end.rb b/lib/parsers/parser_front_end.rb index 17468e54..99353cc1 100644 --- a/lib/parsers/parser_front_end.rb +++ b/lib/parsers/parser_front_end.rb @@ -62,6 +62,7 @@ module ParserFrontEnd c.define_tag 'stylesheets' do |tag| res = '' res << "" + res << "" res << "" res << "" if page.design.reset_css res << " " if page.design.default_css From 0b1f83c042edae823005eb22f0cf9e677d78d01a Mon Sep 17 00:00:00 2001 From: Christophe Vilayphiou Date: Thu, 1 Mar 2012 10:57:13 +0800 Subject: [PATCH 005/125] Fix extra loaded js: the widgets only need to render layout when they need js. --- app/controllers/orbit_frontend_component_controller.rb | 2 +- .../panel/announcement/widget/bulletins_controller.rb | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/app/controllers/orbit_frontend_component_controller.rb b/app/controllers/orbit_frontend_component_controller.rb index 12695040..185dbce6 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 'module_widget' + layout :false def setup_vars @app_title = request.fullpath.split('/')[2] 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 6695156a..333f88e7 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 @@ -28,6 +28,7 @@ class Panel::Announcement::Widget::BulletinsController < ObitWidgetController @selected_tag = AnnouncementTag.find(params[:id]) rescue @tags[0] @bulletins = @selected_tag.get_visible_bulletins.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 From 4dd9b7ffa43b873db2cdba66163dceb0b24f14f4 Mon Sep 17 00:00:00 2001 From: Christophe Vilayphiou Date: Thu, 1 Mar 2012 10:58:31 +0800 Subject: [PATCH 006/125] Fix announcement pagination in front-end --- app/controllers/pages_controller.rb | 6 +++++- lib/parsers/parser_back_end.rb | 2 +- lib/parsers/parser_front_end.rb | 2 +- .../panel/announcement/front_end/bulletins_controller.rb | 6 +++--- .../panel/announcement/front_end/bulletins/index.html.erb | 4 ++-- vendor/built_in_modules/announcement/config/routes.rb | 1 - 6 files changed, 12 insertions(+), 9 deletions(-) diff --git a/app/controllers/pages_controller.rb b/app/controllers/pages_controller.rb index aa66238d..8ea35391 100644 --- a/app/controllers/pages_controller.rb +++ b/app/controllers/pages_controller.rb @@ -30,7 +30,11 @@ class PagesController < ApplicationController end def index_from_link - redirect_to "/#{@item.full_name}" + if params[:page] + redirect_to "/#{@item.full_name}?page=#{params[:page]}" + else + redirect_to "/#{@item.full_name}" + end end def show_from_link diff --git a/lib/parsers/parser_back_end.rb b/lib/parsers/parser_back_end.rb index dea65b6a..37c22ed1 100644 --- a/lib/parsers/parser_back_end.rb +++ b/lib/parsers/parser_back_end.rb @@ -100,7 +100,7 @@ module ParserBackEnd ret = '' if (tag.attributes["main"] == "true" && !page.module_app.nil?) ret << "
    " else part = page.page_parts.detect{ |p| p.name.to_s == tag.attr['name'].to_s } diff --git a/lib/parsers/parser_front_end.rb b/lib/parsers/parser_front_end.rb index 305596ed..17468e54 100644 --- a/lib/parsers/parser_front_end.rb +++ b/lib/parsers/parser_front_end.rb @@ -127,7 +127,7 @@ module ParserFrontEnd ret << "
    " else part = page.page_parts.detect{ |p| p.name.to_s == tag.attr['name'].to_s } rescue nil diff --git a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/front_end/bulletins_controller.rb b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/front_end/bulletins_controller.rb index b71a4609..e840d65f 100644 --- a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/front_end/bulletins_controller.rb +++ b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/front_end/bulletins_controller.rb @@ -11,15 +11,15 @@ class Panel::Announcement::FrontEnd::BulletinsController < ObitWidgetController def index date_now = Time.now - if params[:bulletin_category_id] - @bulletins = Bulletin.where(:bulletin_category_id => params[:bulletin_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) + if params[:category_id] + @bulletins = Bulletin.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) else @bulletins = Bulletin.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) end get_categorys - @current_category = BulletinCategory.from_id(params[:bulletin_category_id]) rescue nil + @current_category = BulletinCategory.from_id(params[:category_id]) rescue nil end def show diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/front_end/bulletins/index.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/front_end/bulletins/index.html.erb index d4335e9a..086794b9 100644 --- a/vendor/built_in_modules/announcement/app/views/panel/announcement/front_end/bulletins/index.html.erb +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/front_end/bulletins/index.html.erb @@ -28,6 +28,6 @@ <% end %> - -<%= paginate @bulletins %> + +<%= paginate @bulletins, :params => {:inner => 'false'} %> diff --git a/vendor/built_in_modules/announcement/config/routes.rb b/vendor/built_in_modules/announcement/config/routes.rb index 78425f33..cb39d253 100644 --- a/vendor/built_in_modules/announcement/config/routes.rb +++ b/vendor/built_in_modules/announcement/config/routes.rb @@ -13,7 +13,6 @@ Rails.application.routes.draw do resources :tags end namespace :front_end do - root :to => "bulletins#index" resources :bulletins end namespace :widget do From 79c8b3861b3e92aef8493da22858aa7b340429e9 Mon Sep 17 00:00:00 2001 From: Christophe Vilayphiou Date: Thu, 1 Mar 2012 14:12:47 +0800 Subject: [PATCH 007/125] Fix link in widget --- .../panel/announcement/widget/bulletins/_web_links.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/widget/bulletins/_web_links.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/widget/bulletins/_web_links.html.erb index 3a6982dc..2b65417d 100644 --- a/vendor/built_in_modules/announcement/app/views/panel/announcement/widget/bulletins/_web_links.html.erb +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/widget/bulletins/_web_links.html.erb @@ -1,6 +1,6 @@ <% @web_links.each do |web_link| %>
  • - <%= web_link.name[I18n.locale] %> + <%= link_to web_link.name[I18n.locale], web_link.url %>
  • <% end %> From 3e22c6e61b79bf379deca7fff08190ee083cdf54 Mon Sep 17 00:00:00 2001 From: Christophe Vilayphiou Date: Wed, 7 Mar 2012 11:37:00 +0800 Subject: [PATCH 008/125] Add bootstrap-orbit.css in front-end --- lib/parsers/parser_front_end.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/parsers/parser_front_end.rb b/lib/parsers/parser_front_end.rb index 17468e54..99353cc1 100644 --- a/lib/parsers/parser_front_end.rb +++ b/lib/parsers/parser_front_end.rb @@ -62,6 +62,7 @@ module ParserFrontEnd c.define_tag 'stylesheets' do |tag| res = '' res << "" + res << "" res << "" res << "" if page.design.reset_css res << " " if page.design.default_css From 00ab7739426678983bc6cc529e7cf12cbc18a0f1 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 14 Mar 2012 20:05:03 +0800 Subject: [PATCH 009/125] fix dashboard & announcement --- app/assets/javascripts/bulletin_form.js.erb | 3 +- app/views/layouts/_side_bar.html.erb | 15 +- .../back_end/bulletins_controller.rb | 51 +- .../announcement/app/models/bulletin.rb | 26 +- .../announcement/app/models/bulletin_file.rb | 22 +- .../announcement/app/models/bulletin_link.rb | 8 +- .../_bulletin_category.html.erb | 28 +- .../bulletin_categorys/_form.html.erb | 54 +- .../bulletin_categorys/_quick_edit.html.erb | 13 + .../_quick_edit_qe.html.erb | 28 + .../bulletin_categorys/index.html.erb | 46 +- .../bulletins/_bulletin_file.html.erb | 16 +- .../bulletins/_bulletin_link.html - 複製.erb | 27 + .../bulletins/_bulletin_link.html.erb | 10 +- .../bulletins/_bulletin_link2.html - 複製.erb | 16 + .../bulletins/_bulletin_link2.html.erb | 17 + .../bulletins/_bulletin_link_qe.html.erb | 41 + .../back_end/bulletins/_form.html.erb | 720 ++++++------------ .../bulletins/_quick_edit_links.html.erb | 34 +- .../bulletins/_quick_edit_picture.html.erb | 13 +- .../back_end/bulletins/index.html - 複製.erb | 9 + .../back_end/bulletins/link_quick_edit.js.erb | 2 + .../back_end/bulletins/show.html.erb | 10 +- .../widget/bulletins/index.html.erb | 2 +- .../announcement/config/routes.rb | 5 +- .../back_end/page_contexts/_form.html.erb | 51 +- .../page_contexts/_page_context.html.erb | 22 +- .../page_contexts/_view_page_context.html.erb | 23 +- .../back_end/page_contexts/edit.html.erb | 10 +- .../back_end/page_contexts/index.html.erb | 42 +- .../back_end/page_contexts/view.html.erb | 41 +- .../back_end/web_link_categorys_controller.rb | 2 +- .../back_end/web_links_controller.rb | 2 +- .../web_link_categorys/_form.html.erb | 38 +- .../_web_link_category.html.erb | 26 +- .../web_link_categorys/index.html.erb | 46 +- .../back_end/web_links/_form.html.erb | 145 ++-- .../back_end/web_links/_web_links.html.erb | 17 +- .../back_end/web_links/index.html.erb | 59 +- 39 files changed, 845 insertions(+), 895 deletions(-) create mode 100644 vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletin_categorys/_quick_edit.html.erb create mode 100644 vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletin_categorys/_quick_edit_qe.html.erb create mode 100644 vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletin_link.html - 複製.erb create mode 100644 vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletin_link2.html - 複製.erb create mode 100644 vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletin_link2.html.erb create mode 100644 vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletin_link_qe.html.erb create mode 100644 vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/index.html - 複製.erb create mode 100644 vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/link_quick_edit.js.erb diff --git a/app/assets/javascripts/bulletin_form.js.erb b/app/assets/javascripts/bulletin_form.js.erb index 5002cfae..17f86060 100644 --- a/app/assets/javascripts/bulletin_form.js.erb +++ b/app/assets/javascripts/bulletin_form.js.erb @@ -1,4 +1,4 @@ -$('.bulletin_urls_block a.delete').live('click', function(){ +$('.bulletin_links_block a.delete').live('click', function(){ $(this).parents('.list_item').remove(); }); @@ -9,4 +9,5 @@ $('.bulletin_files_block a.delete').live('click', function(){ $('.action a.remove_existing_record').live('click', function(){ $(this).next('.should_destroy').attr('value', 1); $("#bulletin_" + $(this).prev().attr('value')).hide(); + $("tr#bulletin_" + $(this).prev().attr('value')).hide(); }); \ No newline at end of file diff --git a/app/views/layouts/_side_bar.html.erb b/app/views/layouts/_side_bar.html.erb index 15948578..61e2c4d8 100644 --- a/app/views/layouts/_side_bar.html.erb +++ b/app/views/layouts/_side_bar.html.erb @@ -16,16 +16,25 @@ <%= link_to content_tag(:i, nil, :class => 'icons-member') + t('admin.member'), panel_web_resource_back_end_web_links_path %> <% end -%> -<%= content_tag :li, :class => active_for_controllers(nil) do -%> +<%= content_tag :li, :class => active_for_controllers('page_contexts') do -%> <%= link_to content_tag(:i, nil, :class => 'icons-page') + t('admin.page'), panel_page_content_back_end_page_contexts_path %> + <%= content_tag :ul, :class => ("nav nav-list " + visible_for_controllers('page_contexts')) do -%> + <%= content_tag :li, link_to(t('admin.all_articles'), panel_page_content_back_end_page_contexts_path), :class => active_for_action('page_context', 'index') %> + <% end -%> <% end -%> <%= content_tag :li, :class => active_for_controllers('designs') do -%> <%= link_to content_tag(:i, nil, :class => 'icons-window-block') + t('admin.design'), admin_designs_path %> <% end -%> -<%= content_tag :li, :class => active_for_controllers(nil) do -%> - <%= link_to content_tag(:i, nil, :class => 'icons-link') + t('admin.link'), nil %> +<%= content_tag :li, :class => active_for_controllers('web_links', 'tags', 'web_link_categorys') do -%> + <%= link_to content_tag(:i, nil, :class => 'icons-link') + t('admin.link'), panel_web_resource_back_end_web_links_path %> + <%= content_tag :ul, :class => ("nav nav-list " + visible_for_controllers('web_links', 'tags', 'web_link_categorys')) do -%> + <%= content_tag :li, link_to(t('admin.all_articles'), panel_web_resource_back_end_web_links_path), :class => active_for_action('web_link', 'index') %> + <%= content_tag :li, link_to(t('admin.add_new'), new_panel_web_resource_back_end_web_link_path), :class => active_for_action('web_link', 'new') %> + <%= content_tag :li, link_to(t('admin.categories'), panel_web_resource_back_end_web_link_categorys_path), :class => active_for_action('web_link_categorys', 'index') %> + <%= content_tag :li, link_to(t('admin.tags'), panel_web_resource_back_end_tags_path), :class => active_for_action('tags', 'index') %> + <% end -%> <% end -%> <%= content_tag :li, :class => active_for_controllers(nil) do -%> diff --git a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletins_controller.rb b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletins_controller.rb index 48b9ac88..09e94c2d 100644 --- a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletins_controller.rb +++ b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletins_controller.rb @@ -9,6 +9,7 @@ class Panel::Announcement::BackEnd::BulletinsController < ApplicationController # @bulletins = Bulletin.all # @bulletins = Bulletin.desc("postdate desc") get_categorys(params[:bulletin_category_id]) + get_tags # @bulletins = Bulletin.where("bulletin_category_id" => params[:bulletin_category_id]).desc("postdate") if params[:bulletin_category_id] @@ -16,9 +17,6 @@ class Panel::Announcement::BackEnd::BulletinsController < ApplicationController # @bulletins = Bulletin.all.order_by([params[:sort], params[:direction]]) @bulletins = params[:sort] ? get_sorted_bulletins : Bulletin.all @bulletin_categories = BulletinCategory.all - - module_app = ModuleApp.first(:conditions => {:key => 'announcement'}) - @tags = Tag.all(:conditions => {:module_app_id => module_app.id}).order_by(I18n.locale, :asc) respond_to do |format| format.html # index.html.erb @@ -31,6 +29,7 @@ class Panel::Announcement::BackEnd::BulletinsController < ApplicationController # GET /bulletins/1.xml def show @bulletin = Bulletin.find(params[:id]) + get_tags # get_categorys # @bulletin_categorys = BulletinCategory.where("_id" => params[:id]) @@ -51,11 +50,14 @@ class Panel::Announcement::BackEnd::BulletinsController < ApplicationController # GET /bulletins/new.xml def new @bulletin = Bulletin.new + + @link_url = panel_announcement_back_end_bulletins_path # @bulletin.bulletin_files.build # @bulletin.bulletin_files.new get_categorys + get_tags respond_to do |format| format.html # new.html.erb @@ -67,7 +69,11 @@ class Panel::Announcement::BackEnd::BulletinsController < ApplicationController def edit @bulletin = Bulletin.find(params[:id]) # @summary_variable = @bulletin.summary_variable + + @link_url = panel_announcement_back_end_bulletin_path(@bulletin) + get_categorys + get_tags end # POST /bulletins @@ -90,6 +96,32 @@ class Panel::Announcement::BackEnd::BulletinsController < ApplicationController end end + def link_quick_add + # debugger + + @bulletin = Bulletin.find(params[:bulletin_id]) + + @link_url = panel_announcement_back_end_bulletins_path + + respond_to do |format| + format.js + end + + end + + def link_quick_edit + # debugger + + @bulletin = Bulletin.find(params[:bulletin_id]) + + @link_url = panel_announcement_back_end_bulletin_path(@bulletin) + + respond_to do |format| + format.js + end + + end + # PUT /bulletins/1 # PUT /bulletins/1.xml def update @@ -98,11 +130,11 @@ class Panel::Announcement::BackEnd::BulletinsController < ApplicationController @bulletin.update_user_id = current_user.id # @bulletin.image.clear if params[:bulletin][:image_del] == '1' - if params[:bulletin][:image_del] == '1' - @bulletin.remove_image! + # if params[:bulletin][:image_del] == '1' + # @bulletin.remove_image! # @bulletin.image_del = nil - params[:bulletin][:image_del] = nil - end + # params[:bulletin][:image_del] = nil + # end respond_to do |format| if @bulletin.update_attributes(params[:bulletin]) @@ -147,6 +179,11 @@ class Panel::Announcement::BackEnd::BulletinsController < ApplicationController def get_categorys(id = nil) @bulletin_categorys = (id ? BulletinCategory.find(id).to_a : BulletinCategory.excludes('disabled' => true)) end + + def get_tags + module_app = ModuleApp.first(:conditions => {:key => 'announcement'}) + @tags = Tag.all(:conditions => {:module_app_id => module_app.id}).order_by(I18n.locale, :asc) + end def get_sorted_bulletins bulletins = Bulletin.all diff --git a/vendor/built_in_modules/announcement/app/models/bulletin.rb b/vendor/built_in_modules/announcement/app/models/bulletin.rb index 7c258f23..a1141b41 100644 --- a/vendor/built_in_modules/announcement/app/models/bulletin.rb +++ b/vendor/built_in_modules/announcement/app/models/bulletin.rb @@ -26,10 +26,11 @@ class Bulletin belongs_to :bulletin_category - embeds_many :bulletin_links, :cascade_callbacks => true - embeds_many :bulletin_files, :cascade_callbacks => true + # embeds_many :bulletin_links, :cascade_callbacks => true + # embeds_many :bulletin_files, :cascade_callbacks => true - # has_many :bulletin_files, :autosave => true, :dependent => :destroy + has_many :bulletin_links, :autosave => true, :dependent => :destroy + has_many :bulletin_files, :autosave => true, :dependent => :destroy accepts_nested_attributes_for :bulletin_files, :allow_destroy => true accepts_nested_attributes_for :bulletin_links, :allow_destroy => true @@ -38,6 +39,9 @@ class Bulletin before_save :set_key + after_save :save_bulletin_links + after_save :save_bulletin_files + def self.search( search = nil, category_id = nil ) @@ -94,6 +98,22 @@ class Bulletin self.is_hidden end + def save_bulletin_links + self.bulletin_links.each do |t| + if t.should_destroy + t.destroy + end + end + end + + def save_bulletin_files + self.bulletin_files.each do |t| + if t.should_destroy + t.destroy + end + end + end + def title @title ||= I18nVariable.first(:conditions => {:key => 'title', :language_value_id => self.id, :language_value_type => self.class}) rescue nil diff --git a/vendor/built_in_modules/announcement/app/models/bulletin_file.rb b/vendor/built_in_modules/announcement/app/models/bulletin_file.rb index 28062d40..05894515 100644 --- a/vendor/built_in_modules/announcement/app/models/bulletin_file.rb +++ b/vendor/built_in_modules/announcement/app/models/bulletin_file.rb @@ -5,13 +5,27 @@ class BulletinFile mount_uploader :file, AssetUploader - field :filetitle - field :description + # field :filetitle + # field :description + has_one :filetitle, :class_name => "I18nVariable", :as => :language_value, :autosave => true, :dependent => :destroy + has_one :description, :class_name => "I18nVariable", :as => :language_value, :autosave => true, :dependent => :destroy # field :to_save, :type => Boolean field :should_destroy, :type => Boolean - # belongs_to :bulletin - embedded_in :bulletin + belongs_to :bulletin + # embedded_in :bulletin + + + protected + + def set_key + if filetitle.new_record? + filetitle.key = 'filetitle' + end + if description.new_record? + description.key = 'description' + end + end end diff --git a/vendor/built_in_modules/announcement/app/models/bulletin_link.rb b/vendor/built_in_modules/announcement/app/models/bulletin_link.rb index a999d45d..30363182 100644 --- a/vendor/built_in_modules/announcement/app/models/bulletin_link.rb +++ b/vendor/built_in_modules/announcement/app/models/bulletin_link.rb @@ -4,10 +4,12 @@ class BulletinLink include Mongoid::Timestamps field :url - field :name + # field :name + + has_one :i18n_variable, :as => :language_value, :autosave => true, :dependent => :destroy field :should_destroy, :type => Boolean - embedded_in :bulletin - + # embedded_in :bulletin + belongs_to :bulletin end diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletin_categorys/_bulletin_category.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletin_categorys/_bulletin_category.html.erb index 57998770..546356fe 100644 --- a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletin_categorys/_bulletin_category.html.erb +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletin_categorys/_bulletin_category.html.erb @@ -1,13 +1,17 @@ - - <%= bulletin_category.key %> - <% @site_valid_locales.each do |locale| %> - <%= bulletin_category.i18n_variable[locale] rescue nil %> - <% end %> - <%= bulletin_category.display %> - - <%= link_to t('bulletin_category.edit'), edit_panel_announcement_back_end_bulletin_category_path(bulletin_category), :remote => true %> | - <%= link_to t('bulletin_category.quick_edit'), panel_announcement_back_end_bulletin_category_quick_edit_path(bulletin_category), :remote => true %> | - <%= link_to t('bulletin_category.delete'), panel_announcement_back_end_bulletin_category_path(bulletin_category), :confirm => t('announcement.sure?'), :method => :delete, :remote => true %> - - \ No newline at end of file + + + <%= bulletin_category.key %> +
    + +
    + + <% @site_valid_locales.each do |locale| %> + <%= bulletin_category.i18n_variable[locale] rescue nil %> + <% end %> + <%= bulletin_category.display %> + \ No newline at end of file diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletin_categorys/_form.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletin_categorys/_form.html.erb index d7bfac7b..1ce7f629 100644 --- a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletin_categorys/_form.html.erb +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletin_categorys/_form.html.erb @@ -1,36 +1,36 @@ <% # encoding: utf-8 %> <%= form_for(@bulletin_category, :remote => true, :url => @url) do |f| %> -<%#= form_for(@bulletin_category, :remote => true, :url => panel_announcement_back_end_bulletin_category_path(@bulletin_category)) do |f| %> -
    - <%= f.label :key %>
    - <%= f.text_field :key %> -
    - -
    - <%= f.label :name %>
    - <%= f.fields_for :i18n_variable, (@bulletin_category.new_record? ? @bulletin_category.build_i18n_variable : @bulletin_category.i18n_variable) do |f| %> - <% @site_valid_locales.each do |locale| %> - <%= I18nVariable.first(:conditions => {:key => locale})[I18n.locale] %> - <%= f.text_field locale, :style => "width:130px" %> - <% end %> - <% end %> -
    - -
    - <%= f.label :display %>
    - <%#= f.select :display, BulletinCategory::PAYMENT_TYPES, :prompt => 'Select a display method' %> +

    <%= (@bulletin_category.new_record? ? 'Add' : 'Edit') %>

    - <%= f.radio_button :display, "List" %>List - <%#= f.label :display, 'list', :value => '1', :checked => @a %> - <%= f.radio_button :display, "Picture" %>Picture - <%#= f.label :display, 'picture', :value => '2', :checked => @b %> -
    憿舐內孵航身摰典圈X嚗鞈閮曄璅撘 -
    +
    + <%= f.label :key %> + <%= f.text_field :key %> +
    + +
    + <%= f.fields_for :i18n_variable, (@bulletin_category.new_record? ? @bulletin_category.build_i18n_variable : @bulletin_category.i18n_variable) do |f| %> + <% @site_valid_locales.each do |locale| %> +
    + <%= label_tag "name-#{locale}", "Name-#{I18nVariable.from_locale(locale)}", :class => 'control-label' %> +
    + <%= f.text_field locale, :class => 'input-xxlarge' %> +
    +
    + <% end %> + <% end %> +
    + +
    + <%= f.label :display %> + <%= f.radio_button :display, "List" %>List + <%= f.radio_button :display, "Picture" %>Picture +
    憿舐內孵航身摰典圈X嚗鞈閮曄璅撘 +
    -
    - <%= f.submit %> +
    + <%= f.submit 'Submit/', :class=>'btn btn-primary' %>
    <% end %> diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletin_categorys/_quick_edit.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletin_categorys/_quick_edit.html.erb new file mode 100644 index 00000000..14a72951 --- /dev/null +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletin_categorys/_quick_edit.html.erb @@ -0,0 +1,13 @@ + + + + <%= t(:quick_edit) %> + <%= form_for bulletin_category, :url => panel_announcement_back_end_bulletin_category_path(bulletin_category), :html => {:class => 'form-horizontal'} do |f| %> + <%= render :partial => "quick_edit_qe", :locals => { :f => f, :bulletin_category => bulletin_category } %> +
    + <%= f.submit t(:submit), :class => 'btn btn-primary' %> + <%= f.submit t(:cancel), :class => 'btn', :type => 'reset' %> +
    + <% end %> + + diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletin_categorys/_quick_edit_qe.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletin_categorys/_quick_edit_qe.html.erb new file mode 100644 index 00000000..cb32d861 --- /dev/null +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletin_categorys/_quick_edit_qe.html.erb @@ -0,0 +1,28 @@ +<% # encoding: utf-8 %> + +
    + +
    + <%= f.label :key %> + <%= f.text_field :key %> +
    +
    + <%= f.fields_for :i18n_variable, bulletin_category.i18n_variable do |f| %> + <% @site_valid_locales.each do |locale| %> +
    + <%= label_tag "title-#{locale}", "Title-#{I18nVariable.from_locale(locale)}", :class => 'control-label' %> +
    + <%= f.text_field locale, :class => 'input-xxlarge' %> +
    +
    + <% end %> + <% end %> +
    + +
    + <%= f.label :display %> + <%= f.radio_button :display, "List" %>List + <%= f.radio_button :display, "Picture" %>Picture +
    憿舐內孵航身摰典圈X嚗鞈閮曄璅撘 +
    +
    diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletin_categorys/index.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletin_categorys/index.html.erb index 87a2993c..0a6e7f83 100644 --- a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletin_categorys/index.html.erb +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletin_categorys/index.html.erb @@ -1,43 +1,23 @@ -<% content_for :secondary do %> -
    -
    -
    -
    -
    -
      -
    • <%#= link_to t('bulletin_category.new_announcement_class'), new_panel_announcement_back_end_bulletin_category_path, :class => 'seclink1' %>
    • -
    -<% end -%> <%= flash_messages %> -

    <%= t('bulletin_category.list_announcement_class') %>

    -
    -
    -
    -
    -
    - - - - <% @site_valid_locales.each do |locale| %> - - <% end %> - - - +
    <%= t('bulletin_category.key') %><%= I18nVariable.first(:conditions => {:key => locale})[I18n.locale] %><%= t('bulletin_category.display') %><%= t('bulletin.action') %>
    + + + + <% @site_valid_locales.each do |locale| %> + + <% end %> + + + + -<%# @bulletin_categorys.each do |post| %> <%= render :partial => 'bulletin_category', :collection => @bulletin_categorys %> -<%# end %> + +
    <%= t('bulletin_category.key') %><%= I18nVariable.first(:conditions => {:key => locale})[I18n.locale] %><%= t('bulletin_category.display') %>
    -
    -
    -
    -
    - -

    Add New

    <%= render :partial => "form" %>
    diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletin_file.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletin_file.html.erb index 86785ee0..6da49ceb 100644 --- a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletin_file.html.erb +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletin_file.html.erb @@ -6,10 +6,22 @@ <%= f.file_field :file %> <%= f.label :file_title %> - <%= f.text_field :filetitle %> + <%#= f.text_field :filetitle %> + <%= f.fields_for :filetitle, (bulletin_file.new_record? ? bulletin_file.build_filetitle : bulletin_file.filetitle ) do |f| %> + <% @site_valid_locales.each do |locale| %> + <%= I18nVariable.from_locale(locale) %> + <%= f.text_field locale %> + <% end %> + <% end %> <%= f.label :file_description %> - <%= f.text_field :description %> + <%#= f.text_field :description %> + <%= f.fields_for :description, (bulletin_file.new_record? ? bulletin_file.build_description : bulletin_file.description ) do |f| %> + <% @site_valid_locales.each do |locale| %> + <%= I18nVariable.from_locale(locale) %> + <%= f.text_field locale %> + <% end %> + <% end %> <% if bulletin_file.new_record? %> diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletin_link.html - 複製.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletin_link.html - 複製.erb new file mode 100644 index 00000000..33d1ba1e --- /dev/null +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletin_link.html - 複製.erb @@ -0,0 +1,27 @@ + +
    " class='list_item'> +
    + + <%= f.label :link_url %> + <%= f.text_field :url %> + + <%= f.label :link_name %> + <%#= f.text_field :name %> + <%= f.fields_for :i18n_variable, (bulletin_link.new_record? ? bulletin_link.build_i18n_variable : bulletin_link.i18n_variable) do |f| %> + <% @site_valid_locales.each do |locale| %> + <%= I18nVariable.first(:conditions => {:key => locale})[I18n.locale] %> + <%= f.text_field locale, :style => "width:130px" %> + <% end %> + <% end %> + + + <% if bulletin_link.new_record? %> + <%= t(:delete) %> + <% else %> + <%= f.hidden_field :id %> + <%= t(:delete) %> + <%= f.hidden_field :should_destroy, :value => nil, :class => 'should_destroy' %> + <% end %> + +
    +
    diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletin_link.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletin_link.html.erb index 44c7ab75..e0077384 100644 --- a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletin_link.html.erb +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletin_link.html.erb @@ -1,12 +1,18 @@ -
    " class='list_item'> +
    " class='list_item'>
    <%= f.label :link_url %> <%= f.text_field :url %> <%= f.label :link_name %> - <%= f.text_field :name %> + <%#= f.text_field :name %> + <%= f.fields_for :i18n_variable, (bulletin_link.new_record? ? bulletin_link.build_i18n_variable : bulletin_link.i18n_variable) do |f| %> + <% @site_valid_locales.each do |locale| %> + <%= I18nVariable.first(:conditions => {:key => locale})[I18n.locale] %> + <%= f.text_field locale, :style => "width:130px" %> + <% end %> + <% end %> <% if bulletin_link.new_record? %> diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletin_link2.html - 複製.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletin_link2.html - 複製.erb new file mode 100644 index 00000000..c44b5c92 --- /dev/null +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletin_link2.html - 複製.erb @@ -0,0 +1,16 @@ + + "> + <%= link_to bulletin_link2.i18n_variable.zh_tw, bulletin_link2.url, :target => '_blank' %> + <%= link_to bulletin_link2.i18n_variable.en, bulletin_link2.url, :target => '_blank' %> + + + <%= f.hidden_field :id %> + + <%= f.hidden_field :should_destroy, :value => nil, :class => 'should_destroy' %> + + + + + + + \ No newline at end of file diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletin_link2.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletin_link2.html.erb new file mode 100644 index 00000000..a3bc5243 --- /dev/null +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletin_link2.html.erb @@ -0,0 +1,17 @@ + + "> + <%= link_to bulletin_link2.i18n_variable.zh_tw, bulletin_link2.url, :target => '_blank' %> + <%= link_to bulletin_link2.i18n_variable.en, bulletin_link2.url, :target => '_blank' %> + + + + <%= f.hidden_field :id %> + + <%= f.hidden_field :should_destroy, :value => nil, :class => 'should_destroy' %> + + + + + + + \ No newline at end of file diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletin_link_qe.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletin_link_qe.html.erb new file mode 100644 index 00000000..7208f73c --- /dev/null +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletin_link_qe.html.erb @@ -0,0 +1,41 @@ +<% # encoding: utf-8 %> + + <%= form_for(@bulletin.bulletin_links, :remote => true, :url => @link_url) do |f| %> + + + + <% end %> + + + \ No newline at end of file diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_form.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_form.html.erb index 751a5f12..2e41f302 100644 --- a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_form.html.erb +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_form.html.erb @@ -1,118 +1,246 @@ <% # encoding: utf-8 %> <%= f.error_messages %> - <%= f.select :bulletin_category_id, @bulletin_categorys.collect{|t| [ t.i18n_variable[I18n.locale], t.id ]}, {}, :class => "input-medium" %> + + + +
    + +
    +
    + +
    +

    Picture

    +
    +
    + +
    + + +
    + +
    + <% if @bulletin.image.file %> + <%= f.check_box :remove_image %> + <%= t('announcement.芷文歇銝單獢') %> + <% end %> +
    +
    +
    +
    -
    - <%= f.label :image, t('announcement.image') %>
    - <%= f.file_field :image %> - <% if @bulletin.image.file %> - <%= check_box_tag 'bulletin[image_del]' %> - <%= t('announcement.芷文歇銝單獢') %> - <% end %> -
    +
    +
    + +
    +

    Date

    +
    +
    + +
    + <%= f.date_select :postdate, {:use_month_numbers => true, :prompt => { :month => 'Month', :day => 'Day', :year => 'Year'}, :order => [:day, :month, :year] }, {:class => 'input-small'} %> +
    +
    +
    + +
    + <%= f.date_select :deadline, {:use_month_numbers => true, :prompt => { :month => 'Month', :day => 'Day', :year => 'Year'}, :order => [:day, :month, :year] }, {:class => 'input-small'} %> +
    +
    +
    +
    + +
    +
    + +
    +

    Status

    +
    +
    + <%= f.check_box :is_top %><%= t('top') %> + <%= f.check_box :is_hot %><%= t('hot') %> + <%= f.check_box :is_hidden %><%= t('hide') %> +
    +
    +
    -
    - <%= f.label :title %> - <%= f.fields_for :title, (@bulletin.new_record? ? @bulletin.build_title : @bulletin.title ) do |f| %> - <% @site_valid_locales.each do |locale| %> - - <%= I18nVariable.from_locale(locale) %> - <%= f.text_field locale %> - - <% end %> - <% end %> +
    +
    + +
    +

    Tags

    +
    + <% @tags.each do |tag| %> + <%= check_box_tag 'bulletin[tag_ids][]', tag.id, @bulletin.tag_ids.include?(tag.id)%> + <%= tag[I18n.locale] %> + <% end %> +
    +
    +
    -
    - <%= f.label :subtitle %> - <%= f.fields_for :subtitle, (@bulletin.new_record? ? @bulletin.build_subtitle : @bulletin.subtitle ) do |f| %> - <% @site_valid_locales.each do |locale| %> - - <%= I18nVariable.from_locale(locale) %> - <%= f.text_area locale, :rows => 10, :cols => 40 %> - - <% end %> - <% end %> -
    + + + -
    - <%= f.label :text %> - <%= f.fields_for :text, (@bulletin.new_record? ? @bulletin.build_text : @bulletin.text ) do |f| %> - <% @site_valid_locales.each do |locale| %> - - <%= I18nVariable.from_locale(locale) %> - <%= f.text_area locale, :rows => 10, :cols => 40 %> - - <% end %> - <% end %> -
    - -
    - <%= f.label :postdate %>
    - <%= f.date_select :postdate, :order => [:year, :month, :day], :use_month_numbers => true %> - <%#= date_select("bulletin", "postdate", :use_month_numbers => true) %> -
    - -
    - <%= f.label :deadline %>
    - <%= f.date_select :deadline, :use_month_numbers => true, :prompt => { :day => 'Select day', :month => 'Select month', :year => 'Select year'} %> - <%#= f.date_select :deadline, :order => [:year, :month, :day],:default => 1.years.from_now, :use_month_numbers => true %> -
    - -
    - <%#= f.label :url %>
    - <%#= f.text_field :url, :size => 60 %> -
    - - - -
    --> - - - - - - diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_quick_edit_links.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_quick_edit_links.html.erb index adfe015c..1d9004c8 100644 --- a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_quick_edit_links.html.erb +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_quick_edit_links.html.erb @@ -17,11 +17,13 @@ + <% bulletin.bulletin_links.each_with_index do |blink, i| %> - - + <%= link_to blink.i18n_variable.zh_tw, blink.url, :target => '_blank' %> + <%= link_to blink.i18n_variable.en, blink.url, :target => '_blank' %> + <% end %>
    @@ -32,27 +34,25 @@
    + diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/index.html - 複製.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/index.html - 複製.erb new file mode 100644 index 00000000..d37d2134 --- /dev/null +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/index.html - 複製.erb @@ -0,0 +1,9 @@ +<%= render 'filter' %> + + <%= render 'bulletins' %> +
    + +
    + <%= link_to content_tag(:i, nil, :class => 'icon-plus icon-white') + t('admin.add'), new_panel_announcement_back_end_bulletin_path, :class => 'btn btn-primary' %> +
    + diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/link_quick_edit.js.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/link_quick_edit.js.erb new file mode 100644 index 00000000..cbe5e3c7 --- /dev/null +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/link_quick_edit.js.erb @@ -0,0 +1,2 @@ +//$.each($(".quick_edit"),function(obj){ $(this).remove(); }); +$("#<%= "bulletin_#{bulletin_link2.id}" %>").append("<%= j render "bulletin_link_qe" %>"); diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/show.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/show.html.erb index f02d9156..ace4ec12 100644 --- a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/show.html.erb +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/show.html.erb @@ -17,7 +17,7 @@
  • <%= t('announcement.title') %> - <%= @bulletin.title %> + <%= @bulletin.title[I18n.locale] %>
  • <%#= image_tag(@bulletin.image.url, :size => "320x240") if @bulletin.image.file %> @@ -25,23 +25,23 @@
  • <%= t('announcement.subtitle') %> - <%= @bulletin.subtitle %> + <%= @bulletin.subtitle[I18n.locale].html_safe %>
  • <%= t('announcement.text') %> - <%= @bulletin.text %> + <%= @bulletin.text[I18n.locale].html_safe %>
  • <%= t('announcement.link') %> <% @bulletin.bulletin_links.each do | blink | %> - <%= link_to blink.name, blink.url, :target => '_blank' %> + <%= link_to blink.i18n_variable[I18n.locale], blink.url, :target => '_blank' %> <% end %>
  • <%= t('announcement.file') %> <% @bulletin.bulletin_files.each do | bfile | %> - <%= link_to bfile.filetitle, bfile.file.url, {:target => '_blank', :title => bfile.description} if bfile.file.file %> + <%= link_to bfile.filetitle[I18n.locale], bfile.file.url, {:target => '_blank', :title => bfile.description[I18n.locale]} if bfile.file.file %> <% end %>
  • 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 e3ba9d48..33166165 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 @@ -11,7 +11,7 @@
  • <%= image_tag(post.image.url, :size => "290x130") if post.image.file %>

    <%= link_to post.title[I18n.locale], panel_announcement_front_end_bulletin_path(post, :category_id => post.bulletin_category_id) %>

    -

    <%= post.subtitle[I18n.locale] %>

    +

    <%= post.subtitle[I18n.locale].html_safe %>

  • <% end %> diff --git a/vendor/built_in_modules/announcement/config/routes.rb b/vendor/built_in_modules/announcement/config/routes.rb index c3a60f74..9a405ecc 100644 --- a/vendor/built_in_modules/announcement/config/routes.rb +++ b/vendor/built_in_modules/announcement/config/routes.rb @@ -3,7 +3,10 @@ Rails.application.routes.draw do namespace :announcement do namespace :back_end do root :to => "bulletins#index" - resources :bulletins + resources :bulletins do + match "link_quick_add/:bulletin_id" => "bulletins#link_quick_add" ,:as => :link_quick_add + match "link_quick_edit/:bulletin_id" => "bulletins#link_quick_edit" ,:as => :link_quick_edit + end resources :bulletin_categorys, :controller => 'bulletin_categorys' do match "quick_edit/:bulletin_category_id" => "bulletin_categorys#quick_edit" ,:as => :quick_edit end diff --git a/vendor/built_in_modules/page_content/app/views/panel/page_content/back_end/page_contexts/_form.html.erb b/vendor/built_in_modules/page_content/app/views/panel/page_content/back_end/page_contexts/_form.html.erb index e5c7fc45..4ca568a9 100644 --- a/vendor/built_in_modules/page_content/app/views/panel/page_content/back_end/page_contexts/_form.html.erb +++ b/vendor/built_in_modules/page_content/app/views/panel/page_content/back_end/page_contexts/_form.html.erb @@ -1,31 +1,32 @@ <% # encoding: utf-8 %> - <%= f.error_messages %> - <%#= debugger %> - -
    - <%= f.label :name %> - <%= @page_context.page.i18n_variable[I18n.locale] %> -
    +<%= f.error_messages %> -
    - <%= f.label :context %> - <%= f.fields_for :context, (@page_context.new_record? ? @page_context.build_context : @page_context.context ) do |f| %> - <% @site_valid_locales.each do |locale| %> - - <%= I18nVariable.from_locale(locale) %> - <%= f.text_area locale, :rows => 10, :cols => 40 %> - - <% end %> - <% end %> -
    - -
    -
    - -
    - <%= f.submit %> -
    +
    + +
    + <%= f.label :name %> + <%= @page_context.page.i18n_variable[I18n.locale] %> +
    + +
    + <%= f.label :context %> + <%= f.fields_for :context, (@page_context.new_record? ? @page_context.build_context : @page_context.context ) do |f| %> + <% @site_valid_locales.each do |locale| %> + + <%= I18nVariable.from_locale(locale) %> + <%= f.text_area locale, :style=>"width:100%" %> + + <% end %> + <% end %> +
    + + +
    + <%= f.submit 'Submit/', :class=>'btn btn-primary' %> +
    + +
    <% content_for :page_specific_javascript do %> diff --git a/vendor/built_in_modules/page_content/app/views/panel/page_content/back_end/page_contexts/_page_context.html.erb b/vendor/built_in_modules/page_content/app/views/panel/page_content/back_end/page_contexts/_page_context.html.erb index c1d86fe1..08db9b2d 100644 --- a/vendor/built_in_modules/page_content/app/views/panel/page_content/back_end/page_contexts/_page_context.html.erb +++ b/vendor/built_in_modules/page_content/app/views/panel/page_content/back_end/page_contexts/_page_context.html.erb @@ -1,10 +1,14 @@ - - <%= page_context.page.i18n_variable[I18n.locale] %> - <%= link_to page_context.version, panel_page_content_back_end_view_path(page_context.page_id) %> - <%= page_context.updated_at.strftime("%Y-%m-%d %H:%I:%S") %> - <%= User.find(page_context.create_user_id).name %> - - <%= link_to t('page_context.edit'), edit_panel_page_content_back_end_page_context_path(page_context) %> - - + + + <%= page_context.page.i18n_variable[I18n.locale] %> +
    + +
    + + <%= link_to page_context.version, panel_page_content_back_end_view_path(page_context.page_id) %> + <%= page_context.updated_at.strftime("%Y-%m-%d %H:%I:%S") %> + <%= User.find(page_context.create_user_id).name %> + \ No newline at end of file diff --git a/vendor/built_in_modules/page_content/app/views/panel/page_content/back_end/page_contexts/_view_page_context.html.erb b/vendor/built_in_modules/page_content/app/views/panel/page_content/back_end/page_contexts/_view_page_context.html.erb index db23a280..7035a700 100644 --- a/vendor/built_in_modules/page_content/app/views/panel/page_content/back_end/page_contexts/_view_page_context.html.erb +++ b/vendor/built_in_modules/page_content/app/views/panel/page_content/back_end/page_contexts/_view_page_context.html.erb @@ -1,10 +1,15 @@ - - <%= view_page_context.page.i18n_variable[I18n.locale] %> - <%= view_page_context.version %> - <%= view_page_context.updated_at.strftime("%Y-%m-%d %H:%I:%S") %> - <%= User.find(view_page_context.create_user_id).name %> - - <%= link_to t('view_page_context.show'), panel_page_content_back_end_page_context_path(view_page_context) %> - - + + + + <%= view_page_context.page.i18n_variable[I18n.locale] %> +
    + +
    + + <%= view_page_context.version %> + <%= view_page_context.updated_at.strftime("%Y-%m-%d %H:%I:%S") %> + <%= User.find(view_page_context.create_user_id).name %> + \ No newline at end of file diff --git a/vendor/built_in_modules/page_content/app/views/panel/page_content/back_end/page_contexts/edit.html.erb b/vendor/built_in_modules/page_content/app/views/panel/page_content/back_end/page_contexts/edit.html.erb index 18bb0ce5..86f2398c 100644 --- a/vendor/built_in_modules/page_content/app/views/panel/page_content/back_end/page_contexts/edit.html.erb +++ b/vendor/built_in_modules/page_content/app/views/panel/page_content/back_end/page_contexts/edit.html.erb @@ -1,7 +1,3 @@ -
    -
    -
    -

    <%= t('page_content.editing_page_content') %>

    @@ -9,8 +5,4 @@ <%= render :partial => 'form', :locals => {:f => f} %> <% end %> -<%= link_back %> -
    -
    -
    -
    \ No newline at end of file +<%#= link_back %> \ No newline at end of file diff --git a/vendor/built_in_modules/page_content/app/views/panel/page_content/back_end/page_contexts/index.html.erb b/vendor/built_in_modules/page_content/app/views/panel/page_content/back_end/page_contexts/index.html.erb index a1566881..3227dcd4 100644 --- a/vendor/built_in_modules/page_content/app/views/panel/page_content/back_end/page_contexts/index.html.erb +++ b/vendor/built_in_modules/page_content/app/views/panel/page_content/back_end/page_contexts/index.html.erb @@ -1,36 +1,20 @@ -<% content_for :secondary do %> -
    -
    -
    -
    -
    -
      -
    • <%= link_to t('page_context.page_content_list'), panel_page_content_back_end_page_contexts_path %>
    • -
    -<% end -%> <%= flash_messages %> -
    -
    -
    -
    -
    - -

    <%= t('page_context.list_page_content') %>

    - - - - - - - - - +
    <%= t('page_context.name') %><%= t('page_context.version') %><%= t('page_context.update_time') %><%= t('page_context.last_modified') %><%= t('page_context.action') %>
    + + + + + + + + + - <%= render :partial => 'page_context', :collection => @page_contexts %> + <%= render :partial => 'page_context', :collection => @page_contexts %> -
    <%= t('page_context.name') %><%= t('page_context.version') %><%= t('page_context.update_time') %><%= t('page_context.last_modified') %>
    + + -
    diff --git a/vendor/built_in_modules/page_content/app/views/panel/page_content/back_end/page_contexts/view.html.erb b/vendor/built_in_modules/page_content/app/views/panel/page_content/back_end/page_contexts/view.html.erb index c5a9871a..d88df80e 100644 --- a/vendor/built_in_modules/page_content/app/views/panel/page_content/back_end/page_contexts/view.html.erb +++ b/vendor/built_in_modules/page_content/app/views/panel/page_content/back_end/page_contexts/view.html.erb @@ -1,36 +1,19 @@ -<% content_for :secondary do %> -
    -
    -
    -
    -
    -
      -
    • <%= link_to t('page_context.page_content_list'), panel_page_content_back_end_page_contexts_path %>
    • -
    -<% end -%> <%= flash_messages %> -
    -
    -
    -
    -
    - -

    <%= t('page_context.list_page_content') %>

    - - - - - - - - - +
    <%= t('page_context.name') %><%= t('page_context.version') %><%= t('page_context.update_time') %><%= t('page_context.last_modified') %><%= t('page_context.action') %>
    + + + + + + + + + <%= render :partial => 'view_page_context', :collection => @page_contexts %> -
    <%= t('page_context.name') %><%= t('page_context.version') %><%= t('page_context.update_time') %><%= t('page_context.last_modified') %>
    - -
    + + diff --git a/vendor/built_in_modules/web_resource/app/controllers/panel/web_resource/back_end/web_link_categorys_controller.rb b/vendor/built_in_modules/web_resource/app/controllers/panel/web_resource/back_end/web_link_categorys_controller.rb index 3db38add..0ba3236a 100644 --- a/vendor/built_in_modules/web_resource/app/controllers/panel/web_resource/back_end/web_link_categorys_controller.rb +++ b/vendor/built_in_modules/web_resource/app/controllers/panel/web_resource/back_end/web_link_categorys_controller.rb @@ -1,6 +1,6 @@ class Panel::WebResource::BackEnd::WebLinkCategorysController < ApplicationController - layout 'admin' + layout 'new_admin' def index @web_link_categorys = WebLinkCategory.all diff --git a/vendor/built_in_modules/web_resource/app/controllers/panel/web_resource/back_end/web_links_controller.rb b/vendor/built_in_modules/web_resource/app/controllers/panel/web_resource/back_end/web_links_controller.rb index f1ec7485..dfe09ce5 100644 --- a/vendor/built_in_modules/web_resource/app/controllers/panel/web_resource/back_end/web_links_controller.rb +++ b/vendor/built_in_modules/web_resource/app/controllers/panel/web_resource/back_end/web_links_controller.rb @@ -1,7 +1,7 @@ class Panel::WebResource::BackEnd::WebLinksController < ApplicationController - layout 'admin' + layout 'new_admin' before_filter :authenticate_user! before_filter :is_admin? diff --git a/vendor/built_in_modules/web_resource/app/views/panel/web_resource/back_end/web_link_categorys/_form.html.erb b/vendor/built_in_modules/web_resource/app/views/panel/web_resource/back_end/web_link_categorys/_form.html.erb index 7eb698ea..2e0f61ff 100644 --- a/vendor/built_in_modules/web_resource/app/views/panel/web_resource/back_end/web_link_categorys/_form.html.erb +++ b/vendor/built_in_modules/web_resource/app/views/panel/web_resource/back_end/web_link_categorys/_form.html.erb @@ -1,25 +1,29 @@ <% # encoding: utf-8 %> <%= form_for(@web_link_category, :remote => true, :url => @url) do |f| %> -<%#= form_for(@web_link_category, :remote => true, :url => panel_web_resource_back_end_web_link_category_path(@web_link_category)) do |f| %> -
    - <%= f.label :key %>
    - <%= f.text_field :key %> -
    +

    <%= (@web_link_category.new_record? ? 'Add' : 'Edit') %>

    + +
    + <%= f.label :key %> + <%= f.text_field :key %> +
    + +
    + <%= f.fields_for :i18n_variable, (@web_link_category.new_record? ? @web_link_category.build_i18n_variable : @web_link_category.i18n_variable) do |f| %> + <% @site_valid_locales.each do |locale| %> +
    + <%= label_tag "name-#{locale}", "Name-#{I18nVariable.from_locale(locale)}", :class => 'control-label' %> +
    + <%= f.text_field locale, :class => 'input-xxlarge' %> +
    +
    + <% end %> + <% end %> +
    -
    - <%= f.label :name %>
    - <%= f.fields_for :i18n_variable, (@web_link_category.new_record? ? @web_link_category.build_i18n_variable : @web_link_category.i18n_variable) do |f| %> - <% @site_valid_locales.each do |locale| %> - <%= I18nVariable.first(:conditions => {:key => locale})[I18n.locale] %> - <%= f.text_field locale, :style => "width:130px" %> - <% end %> - <% end %> -
    - -
    - <%= f.submit %> +
    + <%= f.submit 'Submit/', :class=>'btn btn-primary' %>
    <% end %> diff --git a/vendor/built_in_modules/web_resource/app/views/panel/web_resource/back_end/web_link_categorys/_web_link_category.html.erb b/vendor/built_in_modules/web_resource/app/views/panel/web_resource/back_end/web_link_categorys/_web_link_category.html.erb index d6e27e8d..3f6a1a71 100644 --- a/vendor/built_in_modules/web_resource/app/views/panel/web_resource/back_end/web_link_categorys/_web_link_category.html.erb +++ b/vendor/built_in_modules/web_resource/app/views/panel/web_resource/back_end/web_link_categorys/_web_link_category.html.erb @@ -1,12 +1,16 @@ - - <%= web_link_category.key %> - <% @site_valid_locales.each do |locale| %> - <%= web_link_category.i18n_variable[locale] rescue nil %> - <% end %> - - <%= link_to t('web_link_category.edit'), edit_panel_web_resource_back_end_web_link_category_path(web_link_category), :remote => true %> | - <%= link_to t('web_link_category.quick_edit'), panel_web_resource_back_end_web_link_category_quick_edit_path(web_link_category), :remote => true %> | - <%= link_to t('web_link_category.delete'), panel_web_resource_back_end_web_link_category_path(web_link_category), :confirm => t('sure?'), :method => :delete, :remote => true %> - - \ No newline at end of file + + + + <%= web_link_category.key %> +
    + +
    + + <% @site_valid_locales.each do |locale| %> + <%= web_link_category.i18n_variable[locale] rescue nil %> + <% end %> + \ No newline at end of file diff --git a/vendor/built_in_modules/web_resource/app/views/panel/web_resource/back_end/web_link_categorys/index.html.erb b/vendor/built_in_modules/web_resource/app/views/panel/web_resource/back_end/web_link_categorys/index.html.erb index 45842451..762da9e7 100644 --- a/vendor/built_in_modules/web_resource/app/views/panel/web_resource/back_end/web_link_categorys/index.html.erb +++ b/vendor/built_in_modules/web_resource/app/views/panel/web_resource/back_end/web_link_categorys/index.html.erb @@ -1,43 +1,23 @@ -<% content_for :secondary do %> -
    -
    -
    -
    -
    -
      -
    • <%#= link_to t('web_link_category.new_web_resource_class'), new_panel_web_resource_back_end_web_link_category_path, :class => 'seclink1' %>
    • -
    -<% end -%> + <%= flash_messages %> -

    <%= t('web_link_category.list_web_resource_class') %>

    -
    -
    -
    -
    -
    - - - - <% @site_valid_locales.each do |locale| %> - - <% end %> - - + + + + + <% @site_valid_locales.each do |locale| %> + + <% end %> + + + -<%# @web_link_categorys.each do |post| %> <%= render :partial => 'web_link_category', :collection => @web_link_categorys %> -<%# end %> + + -
    -
    -
    -
    - -

    Add New

    <%= render :partial => "form" %>
    - diff --git a/vendor/built_in_modules/web_resource/app/views/panel/web_resource/back_end/web_links/_form.html.erb b/vendor/built_in_modules/web_resource/app/views/panel/web_resource/back_end/web_links/_form.html.erb index ce17555a..2abdf4a0 100644 --- a/vendor/built_in_modules/web_resource/app/views/panel/web_resource/back_end/web_links/_form.html.erb +++ b/vendor/built_in_modules/web_resource/app/views/panel/web_resource/back_end/web_links/_form.html.erb @@ -1,62 +1,101 @@ <% # encoding: utf-8 %> <%= f.error_messages %> - <%#= debugger %> - -
    - <%= f.label :category %>
    - <%= f.select :web_link_category_id, @web_link_categorys.collect {|t| [ t.i18n_variable[I18n.locale], t.id ]} %> -
    - -
    - <%= f.label :name %> - <%= f.fields_for :name, (@web_link.new_record? ? @web_link.build_name : @web_link.name ) do |f| %> - <% @site_valid_locales.each do |locale| %> - - <%= I18nVariable.from_locale(locale) %> - <%= f.text_field locale %> - - <% end %> - <% end %> -
    - -
    - <%= f.label :url %>
    - <%= f.text_field :url, :size => 60 %> -
    -
    - <%= f.label :describe %> - <%= f.fields_for :context, (@web_link.new_record? ? @web_link.build_context : @web_link.context ) do |f| %> - <% @site_valid_locales.each do |locale| %> - - <%= I18nVariable.from_locale(locale) %> - <%= f.text_area locale, :rows => 10, :cols => 40 %> - - <% end %> - <% end %> -
    + + +
    + +
    +
    + +
    +

    Status

    +
    +
    + <%= f.check_box :is_top %><%= t('top') %> + <%= f.check_box :is_hot %><%= t('hot') %> + <%= f.check_box :is_hidden %><%= t('hide') %> +
    +
    +
    + +
    +
    + +
    +

    Tags

    +
    + <% @tags.each do |tag| %> + <%= check_box_tag 'web_link[tag_ids][]', tag.id, @web_link.tag_ids.include?(tag.id)%> + <%= tag[I18n.locale] %> + <% end %> +
    +
    -
    - <%= f.label :status %>
    - <%= f.check_box :is_top %><%= t('top') %> - <%= f.check_box :is_hot %><%= t('hot') %> - <%= f.check_box :is_hidden %><%= t('hidden') %> -
    - -
    - <%= f.label :tags %>
    - <% @tags.each do |tag| %> - <%= check_box_tag 'web_link[tag_ids][]', tag.id, @web_link.tag_ids.include?(tag.id)%> - <%= tag[I18n.locale] %> - <% end %> -
    - -
    -
    +
    -
    - <%= f.submit %> + + + +
    +
    + + <%= f.label :category %> + <%= f.select :web_link_category_id, @web_link_categorys.collect {|t| [ t.i18n_variable[I18n.locale], t.id ]} %> + + + +
    + <%= f.label :name %> + <%= f.fields_for :name, (@web_link.new_record? ? @web_link.build_name : @web_link.name ) do |f| %> + <% @site_valid_locales.each do |locale| %> + + <%= I18nVariable.from_locale(locale) %> + <%= f.text_field locale, :class=>'post-title' %> + + <% end %> + <% end %> +
    + +
    + <%= f.label :url %> + <%= f.text_field :url %> +
    + +
    + <%= f.label :describe %> + <%= f.fields_for :context, (@web_link.new_record? ? @web_link.build_context : @web_link.context ) do |f| %> + <% @site_valid_locales.each do |locale| %> + + <%= I18nVariable.from_locale(locale) %> + <%= f.text_area locale, :style=>"width:100%" %> + + <% end %> + <% end %> +
    + +
    + + + + +
    + <%= f.submit 'Submit/', :class=>'btn btn-primary' %>
    \ No newline at end of file diff --git a/vendor/built_in_modules/web_resource/app/views/panel/web_resource/back_end/web_links/_web_links.html.erb b/vendor/built_in_modules/web_resource/app/views/panel/web_resource/back_end/web_links/_web_links.html.erb index d87b59d8..c58f15e4 100644 --- a/vendor/built_in_modules/web_resource/app/views/panel/web_resource/back_end/web_links/_web_links.html.erb +++ b/vendor/built_in_modules/web_resource/app/views/panel/web_resource/back_end/web_links/_web_links.html.erb @@ -1,5 +1,5 @@ - + <% if post.is_top? %> <%= t(:top) %> @@ -10,6 +10,12 @@ <% if post.is_hidden? %> <%= t(:hidden) %> <% end %> +
    + +
    <%= post.web_link_category.i18n_variable[I18n.locale] %> @@ -20,12 +26,5 @@ <%= tag[I18n.locale] %> <% end %> - - <%= link_to t('web_link.edit'), edit_panel_web_resource_back_end_web_link_path(post) %> | - - <%= link_to t(:set_top), eval("panel_web_resource_back_end_web_link_path(post, :authenticity_token => form_authenticity_token, :web_link => {:is_top => true})"), :remote => true, :method => :put, :id => "disable_#{post.id}", :style => "display:#{post.is_top? ? 'none' : ''}", :class => 'switch' %> - <%= link_to t(:cancel_top), eval("panel_web_resource_back_end_web_link_path(post, :authenticity_token => form_authenticity_token, :web_link => {:is_top => false})"), :remote => true, :method => :put, :id => "enable_#{post.id}", :style => "display:#{post.is_top? ? '' : 'none'}", :class => 'switch' %> - - | <%= link_to t('web_link.delete'), panel_web_resource_back_end_web_link_path(post), :confirm => t('sure?'), :method => :delete, :remote => true %> - + diff --git a/vendor/built_in_modules/web_resource/app/views/panel/web_resource/back_end/web_links/index.html.erb b/vendor/built_in_modules/web_resource/app/views/panel/web_resource/back_end/web_links/index.html.erb index 82afe4ea..301c1bbe 100644 --- a/vendor/built_in_modules/web_resource/app/views/panel/web_resource/back_end/web_links/index.html.erb +++ b/vendor/built_in_modules/web_resource/app/views/panel/web_resource/back_end/web_links/index.html.erb @@ -1,52 +1,21 @@ -<% content_for :secondary do %> -
    -
    -
    -
    -
    -
      -
    • <%= link_to t('web_link.new_link'), new_panel_web_resource_back_end_web_link_path %>
    • -
    • <%= link_to t('web_link.link_list'), panel_web_resource_back_end_web_links_path %>
    • -
    • <%= link_to t('web_link.new_link_class'), panel_web_resource_back_end_web_link_categorys_path %>
    • -
    -<% end -%> <%= flash_messages %> -
    -
    -
    -
    -
    - - <%= form_for :web_link, :action => 'search', :method => 'get', :url => panel_web_resource_back_end_web_links_path do |f| %> - - <%#= f.select :web_link_category_id, @web_link_categorys.collect {|t| [ t.i18n_variable[I18n.locale], t.id ] },{ :include_blank => t('web_link.select') }%> - - Category <%= select_tag "category_id", options_for_select(@web_link_categorys.collect{|t| [t.i18n_variable[I18n.locale], t.id]}), :prompt => t('web_link.select') %> - - <%= submit_tag "OK", :name => nil %> - - <% end %> - -
    -
    - -

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

    - - - - - - - - - +
    <%= t('web_link.status') %><%= t('web_link.category') %><%= t('web_link.name') %><%= t('web_link.tags') %><%= t('web_link.action') %>
    + + + + + + + + + <% @web_links.each do |post| %> <%= render :partial => 'web_links', :locals => {:post => post} %> - <% end %> -
    <%= t('web_link.status') %><%= t('web_link.category') %><%= t('web_link.name') %><%= t('web_link.tags') %>
    - -
    + <% end %> + + + From 13b6892f873e625aeff2ce7b640b2a2d9ee4d586 Mon Sep 17 00:00:00 2001 From: Matt Fu Date: Fri, 16 Mar 2012 11:09:44 +0800 Subject: [PATCH 010/125] code for new fact check --- app/controllers/orbit_backend_controller.rb | 1 + app/views/layouts/_side_bar.html.erb | 1 + lib/tasks/anc_tasks.rake | 12 +-- .../back_end/bulletins_controller.rb | 7 +- .../back_end/fact_checks_controller.rb | 92 +++++++++++++------ .../announcement/app/models/bulletin.rb | 3 + .../back_end/bulletins/_bulletin.html.erb | 5 +- .../back_end/bulletins/_form.html.erb | 13 ++- .../back_end/bulletins/_quick_edit.html.erb | 10 +- .../back_end/bulletins/index.html.erb | 1 - .../back_end/fact_checks/_list_table.html.erb | 15 --- .../back_end/fact_checks/index.html.erb | 40 -------- .../announcement/config/locales/en.yml | 6 ++ .../announcement/config/locales/zh_tw.yml | 7 ++ .../announcement/config/routes.rb | 5 +- 15 files changed, 114 insertions(+), 104 deletions(-) delete mode 100644 vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/fact_checks/_list_table.html.erb delete mode 100644 vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/fact_checks/index.html.erb diff --git a/app/controllers/orbit_backend_controller.rb b/app/controllers/orbit_backend_controller.rb index d3639ebe..b52384c6 100644 --- a/app/controllers/orbit_backend_controller.rb +++ b/app/controllers/orbit_backend_controller.rb @@ -4,6 +4,7 @@ class OrbitBackendController< ApplicationController # before_filter {|c| c.front_end_available(@app_title)} before_filter :check_user_can_use,:except => [:public] include OrbitCoreLib::PermissionUnility + include AdminHelper layout 'admin' diff --git a/app/views/layouts/_side_bar.html.erb b/app/views/layouts/_side_bar.html.erb index 33e41597..d287e46c 100644 --- a/app/views/layouts/_side_bar.html.erb +++ b/app/views/layouts/_side_bar.html.erb @@ -9,6 +9,7 @@ <%= content_tag :li, link_to(t('admin.add_new'), new_panel_announcement_back_end_bulletin_path), :class => active_for_action('bulletins', 'new') %> <%= content_tag :li, link_to(t('admin.categories'), panel_announcement_back_end_bulletin_categorys_path), :class => active_for_action('bulletin_categorys', 'index') %> <%= content_tag :li, link_to(t('admin.tags'), panel_announcement_back_end_tags_path), :class => active_for_action('tags', 'index') %> + <%= content_tag :li, link_to(t('announcement.bulletin.fact_check_setting'), panel_announcement_back_end_fact_checks_setting_path), :class => active_for_action('tags', 'index') %> <% end -%> <% end -%> diff --git a/lib/tasks/anc_tasks.rake b/lib/tasks/anc_tasks.rake index 3145d119..cd534b93 100644 --- a/lib/tasks/anc_tasks.rake +++ b/lib/tasks/anc_tasks.rake @@ -11,12 +11,12 @@ namespace :anc do bulletin_category_3.create_i18n_variable(:en => "MattCheckChrisPreview", :zh_tw => 'MattCheckChrisPreview') - bulletin_1 = Bulletin.create(:title => "C1P1",:status => nil,:subtitle => "",:text => "value",:postadate => Time.now,:deadline => nil,:bulletin_category => bulletin_category_1 ) - bulletin_2 = Bulletin.create(:title => "C1P2",:status => nil,:subtitle => "",:text => "value",:postadate => Time.now,:deadline => nil,:bulletin_category => bulletin_category_1 ) - bulletin_3 = Bulletin.create(:title => "C2P1",:status => nil,:subtitle => "",:text => "value",:postadate => Time.now,:deadline => nil,:bulletin_category => bulletin_category_2 ) - bulletin_4 = Bulletin.create(:title => "C2P2",:status => nil,:subtitle => "",:text => "value",:postadate => Time.now,:deadline => nil,:bulletin_category => bulletin_category_2 ) - bulletin_5 = Bulletin.create(:title => "C3P1",:status => nil,:subtitle => "",:text => "value",:postadate => Time.now,:deadline => nil,:bulletin_category => bulletin_category_3 ) - bulletin_6 = Bulletin.create(:title => "C3P2",:status => nil,:subtitle => "",:text => "value",:postadate => Time.now,:deadline => nil,:bulletin_category => bulletin_category_3 ) + bulletin_1 = Bulletin.create(:title => "C1P1",:status => nil,:subtitle => "",:text => "value",:post_date => Time.now,:deadline => nil,:bulletin_category => bulletin_category_1 ) + bulletin_2 = Bulletin.create(:title => "C1P2",:status => nil,:subtitle => "",:text => "value",:post_date => Time.now,:deadline => nil,:bulletin_category => bulletin_category_1 ) + bulletin_3 = Bulletin.create(:title => "C2P1",:status => nil,:subtitle => "",:text => "value",:post_date => Time.now,:deadline => nil,:bulletin_category => bulletin_category_2 ) + bulletin_4 = Bulletin.create(:title => "C2P2",:status => nil,:subtitle => "",:text => "value",:post_date => Time.now,:deadline => nil,:bulletin_category => bulletin_category_2 ) + bulletin_5 = Bulletin.create(:title => "C3P1",:status => nil,:subtitle => "",:text => "value",:post_date => Time.now,:deadline => nil,:bulletin_category => bulletin_category_3 ) + bulletin_6 = Bulletin.create(:title => "C3P2",:status => nil,:subtitle => "",:text => "value",:post_date => Time.now,:deadline => nil,:bulletin_category => bulletin_category_3 ) end end \ No newline at end of file diff --git a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletins_controller.rb b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletins_controller.rb index dcd3de04..e8eb6149 100644 --- a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletins_controller.rb +++ b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletins_controller.rb @@ -1,5 +1,4 @@ -class Panel::Announcement::BackEnd::BulletinsController < ApplicationController - +class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController layout 'new_admin' before_filter :authenticate_user! @@ -151,7 +150,6 @@ class Panel::Announcement::BackEnd::BulletinsController < ApplicationController elsif is_sub_manager? @bulletin_categorys = BulletinCategory.authed_for_user(current_user,'submit_new') end -<<<<<<< HEAD end def get_sorted_bulletins @@ -196,8 +194,7 @@ class Panel::Announcement::BackEnd::BulletinsController < ApplicationController a.flatten! a.uniq end -======= ->>>>>>> 26cd6951dba43b1f6eaf5056160309c5c77a8716 + end diff --git a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/fact_checks_controller.rb b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/fact_checks_controller.rb index dd471958..c47e91fb 100644 --- a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/fact_checks_controller.rb +++ b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/fact_checks_controller.rb @@ -1,38 +1,76 @@ class Panel::Announcement::BackEnd::FactChecksController < OrbitBackendController before_filter :authenticate_user! include AdminHelper - layout 'admin' + # layout 'admin' + layout 'new_admin' - def index - @bulletin_categorys_submit_new = [] - @bulletin_categorys_check =[] - if is_admin? || is_manager? - #@bulletin_categorys_submit_new = BulletinCategory.all - @bulletin_categorys_check = BulletinCategory.all - # elsif is_sub_manager? - # @bulletin_categorys_submit_new = BulletinCategory.authed_for_user(current_user,'submit_new') - # @bulletin_categorys_check = BulletinCategory.authed_for_user(current_user,'fact_check') + def setting + @bulletin_categorys = BulletinCategory.all + if params.has_key?(:category_id) + first_category = BulletinCategory.find params[:category_id] + if params[:commit] == 'Update' + privilege_users = params[:users].collect{|key,value| User.find key } rescue [] + preload_object_auth_ary = first_category.object_auths.where(title: 'fact_check') || (first_category.object_auths.create :title=> 'fact_check') + preload_object_auth = preload_object_auth_ary.first + preload_object_auth.privilege_users = privilege_users + preload_object_auth.save! + end + else + first_category = @bulletin_categorys.first + end + preload_object_auth = first_category.object_auths.where(title: 'fact_check') || (first_category.object_auths.create :title=> 'fact_check') + @users_array = preload_object_auth.first.privilege_users rescue [] + respond_to do |format| + format.html + format.js end end - def new + def update_setting end - - def create - + # def index + # get_categorys(params[:bulletin_category_id]) + # + # @bulletins = params[:sort] ? get_sorted_bulletins : Bulletin.all + # @bulletin_categories = BulletinCategory.all + # + # module_app = ModuleApp.first(:conditions => {:key => 'announcement'}) + # @tags = Tag.all(:conditions => {:module_app_id => module_app.id}).order_by(I18n.locale, :asc) + # + # respond_to do |format| + # format.html # index.html.erb + # format.js + # format.xml { render :xml => @bulletins } + # end + # end + # + # def new + # + # end + # + # def create + # + # end + # + # def update + # + # end + # + # def edit + # + # end + # + # def destroy + # + # end + protected + def get_categorys(id = nil) + @bulletin_categorys = [] + if(is_manager? || is_admin?) + @bulletin_categorys = (id ? BulletinCategory.find(id).to_a : BulletinCategory.excludes('disabled' => true)) + elsif is_sub_manager? + @bulletin_categorys = BulletinCategory.authed_for_user(current_user,'submit_new') + end end - - def update - - end - - def edit - - end - - def destroy - - end - end diff --git a/vendor/built_in_modules/announcement/app/models/bulletin.rb b/vendor/built_in_modules/announcement/app/models/bulletin.rb index 188142ea..e68e2c97 100644 --- a/vendor/built_in_modules/announcement/app/models/bulletin.rb +++ b/vendor/built_in_modules/announcement/app/models/bulletin.rb @@ -19,6 +19,9 @@ class Bulletin field :is_top, :type => Boolean, :default => false field :is_hot, :type => Boolean, :default => false field :is_hidden, :type => Boolean, :default => false + field :is_checked, :type => Boolean, :default => false + + field :not_checked_reason field :public, :type => Boolean, :default => true diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletin.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletin.html.erb index 3f6f50e1..e12af233 100644 --- a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletin.html.erb +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletin.html.erb @@ -24,11 +24,12 @@ +
  • <%= link_to t('bulletin.fact_check'), edit_panel_announcement_back_end_bulletin_path(bulletin) %>
  • <%#= #TODO add ancher so user can quick access into that part %>
    <%= bulletin.bulletin_category.i18n_variable[I18n.locale] %> - <%= link_to bulletin.title[I18n.locale], panel_announcement_back_end_bulletin_path(bulletin) %> + <%= link_to bulletin.title[I18n.locale], panel_announcement_back_end_bulletin_path(bulletin) rescue ''%> <%= bulletin.postdate %> <%= (bulletin.deadline) ? bulletin.deadline : t('bulletin.no_deadline') %> @@ -36,7 +37,7 @@ <%= tag[I18n.locale] %> <% end %> - <%= User.from_id(bulletin.update_user_id).name %> + <%= User.from_id(bulletin.update_user_id).name rescue ''%> <%= render :partial => 'quick_edit', :locals => {:bulletin => bulletin} %> diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_form.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_form.html.erb index 751a5f12..2236b5ed 100644 --- a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_form.html.erb +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_form.html.erb @@ -2,7 +2,16 @@ <%= f.error_messages %> <%= f.select :bulletin_category_id, @bulletin_categorys.collect{|t| [ t.i18n_variable[I18n.locale], t.id ]}, {}, :class => "input-medium" %> - +
    + <%= label :fact_check_stat, t('announcement.bulletin.fact_check_stat') %> + <%= f.radio_button :is_checked, true%> + <%= label :is_checked_true, t('announcement.bulletin.fact_check_pass') %> + <%= f.radio_button :is_checked, false, (@bulletin.is_checked.nil?? {:checked => true} : {}) %> + <%= label :is_checked_false, t('announcement.bulletin.fact_check_not_pass') %> + + <%= label :is_checked_false, t('announcement.bulletin.fact_check_not_pass_reason') %> + <%= f.text_field :not_checked_reason %> +
    <%= f.label :image, t('announcement.image') %>
    <%= f.file_field :image %> @@ -523,6 +532,8 @@
    --> + + diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_quick_edit.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_quick_edit.html.erb index 91726d88..96e8237c 100644 --- a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_quick_edit.html.erb +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_quick_edit.html.erb @@ -3,11 +3,11 @@ <%= t(:quick_edit) %> - Basic / Picture / Tags / Link / File <%= form_for bulletin, :url => panel_announcement_back_end_bulletin_path(bulletin), :html => {:class => 'form-horizontal'} do |f| %> - <%= render :partial => "quick_edit_basic", :locals => { :f => f, :bulletin => bulletin } %> - <%= render :partial => "quick_edit_picture", :locals => { :f => f, :bulletin => bulletin } %> - <%= render :partial => "quick_edit_tags", :locals => { :f => f, :bulletin => bulletin } %> - <%= render :partial => "quick_edit_links", :locals => { :f => f, :bulletin => bulletin } %> - <%= render :partial => "quick_edit_files", :locals => { :f => f, :bulletin => bulletin } %> + <%= render :partial => "panel/announcement/back_end/bulletins/quick_edit_basic", :locals => { :f => f, :bulletin => bulletin } %> + <%= render :partial => "panel/announcement/back_end/bulletins/quick_edit_picture", :locals => { :f => f, :bulletin => bulletin } %> + <%= render :partial => "panel/announcement/back_end/bulletins/quick_edit_tags", :locals => { :f => f, :bulletin => bulletin } %> + <%= render :partial => "panel/announcement/back_end/bulletins/quick_edit_links", :locals => { :f => f, :bulletin => bulletin } %> + <%= render :partial => "panel/announcement/back_end/bulletins/quick_edit_files", :locals => { :f => f, :bulletin => bulletin } %>
    <%= f.submit t(:submit), :class => 'btn btn-primary' %> <%= f.submit t(:cancel), :class => 'btn', :type => 'reset' %> diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/index.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/index.html.erb index fd2b29b5..c833297a 100644 --- a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/index.html.erb +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/index.html.erb @@ -2,7 +2,6 @@ <%= render 'bulletins' %>
    -
    <%= link_to content_tag(:i, nil, :class => 'icon-plus icon-white') + t('admin.add'), new_panel_announcement_back_end_bulletin_path, :class => 'btn btn-primary' %>
    diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/fact_checks/_list_table.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/fact_checks/_list_table.html.erb deleted file mode 100644 index 59bac03a..00000000 --- a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/fact_checks/_list_table.html.erb +++ /dev/null @@ -1,15 +0,0 @@ -

    <%= bulletin_category.key %>

    - - - - - - - - - - -<% bulletin_category.bulletins.each do |post| %> - <%= render :partial => 'panel/announcement/back_end/bulletins/bulletins', :locals => {:post => post,:fact_check_allow=>true} %> -<% end %> -
    <%= t('bulletin.status') %><%= t('bulletin.category') %><%= t('bulletin.title') %><%= t('bulletin.postdate') %><%= t('bulletin.deadline') %><%= t('bulletin.action') %>
    \ No newline at end of file diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/fact_checks/index.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/fact_checks/index.html.erb deleted file mode 100644 index 6f878b06..00000000 --- a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/fact_checks/index.html.erb +++ /dev/null @@ -1,40 +0,0 @@ -<% content_for :secondary do %> -<%= render :partial => '/panel/announcement/back_end/announcement_secondary' %> -<% end -%> - -<%= flash_messages %> - -
    -
    -
    -
    -
    - -
    <%= t('bulletin.search') %> - - <%= form_for :bulletin, :action => 'search', :method => 'get', :url => panel_announcement_back_end_bulletins_path do |f| %> - - <%#= f.select :bulletin_category_id, @bulletin_categorys.collect {|t| [ t.i18n_variable[I18n.locale], t.id ] },{ :include_blank => t('bulletin.select') }%> - - Category <%#= select_tag "category_id", options_for_select(@bulletin_categorys.collect{|t| [t.i18n_variable[I18n.locale], t.id]}), :prompt => t('bulletin.select') %> - - KeyWord <%#= text_field_tag :search, params[:search], :id => 'search_field' %> - - <%= submit_tag "Search", :name => nil %> - - <% end %> - - -
    - -
    -
    - -

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

    - -
    -

    Check Please

    - <%= render :partial => "list_table", :collection => @bulletin_categorys_check,:as => :bulletin_category%> -
    -
    - diff --git a/vendor/built_in_modules/announcement/config/locales/en.yml b/vendor/built_in_modules/announcement/config/locales/en.yml index 1f544b28..6143b177 100644 --- a/vendor/built_in_modules/announcement/config/locales/en.yml +++ b/vendor/built_in_modules/announcement/config/locales/en.yml @@ -35,6 +35,12 @@ en: list_lower: " list" title: Title postdate: Postdate + fact_check: Fact Check + fact_check_setting: Fact Check Setting + fact_check_stat: Fact Check Status + fact_check_not_pass: 'Not Pass' + fact_check_not_pass_reason: 'Reason' + fact_check_pass: 'Pass' # admin: # action: Action # add_language: Add language diff --git a/vendor/built_in_modules/announcement/config/locales/zh_tw.yml b/vendor/built_in_modules/announcement/config/locales/zh_tw.yml index a9da545b..e2dfd957 100644 --- a/vendor/built_in_modules/announcement/config/locales/zh_tw.yml +++ b/vendor/built_in_modules/announcement/config/locales/zh_tw.yml @@ -30,6 +30,13 @@ zh_tw: list_lower: 銵 title: 璅憿 postdate: 撘菔票交 + fact_check: 砍撖拇 + fact_check_setting: 撖拇貉身摰 + fact_check_stat: 撖拇貊瘜 + fact_check_not_pass: '銝' + fact_check_pass: '' + fact_check_not_pass_reason: '銝' + # admin: # action: 銵 # add_language: 啣隤閮 diff --git a/vendor/built_in_modules/announcement/config/routes.rb b/vendor/built_in_modules/announcement/config/routes.rb index cb39d253..f6f30b31 100644 --- a/vendor/built_in_modules/announcement/config/routes.rb +++ b/vendor/built_in_modules/announcement/config/routes.rb @@ -3,8 +3,9 @@ Rails.application.routes.draw do namespace :announcement do namespace :back_end do match 'public' => "announcements#public",:as => :public - resources :fact_checks - match 'list_mine' => "announcements#list_mine" + match 'fact_check_setting' => "fact_checks#setting" ,:as => :fact_checks_setting + match 'update_setting' => "fact_checks#update_setting" ,:as => :fact_checks_update_setting + root :to => "bulletins#index" resources :bulletins resources :bulletin_categorys, :controller => 'bulletin_categorys' do From b6d49df1453c8c3c0f6b0a080c2b0f3805030bac Mon Sep 17 00:00:00 2001 From: Christophe Vilayphiou Date: Fri, 16 Mar 2012 11:20:16 +0800 Subject: [PATCH 011/125] Change Obit to Orbit --- app/controllers/orbit_widget_controller.rb | 2 +- .../panel/announcement/back_end/bulletins_controller.rb | 1 - .../panel/announcement/front_end/bulletins_controller.rb | 2 +- .../panel/announcement/widget/bulletins_controller.rb | 2 +- .../app/controllers/panel/new_blog/widget/posts_controller.rb | 2 +- .../panel/page_content/front_end/page_contexts_controller.rb | 2 +- .../panel/web_resource/front_end/web_links_controller.rb | 2 +- .../panel/web_resource/widget/web_links_controller.rb | 2 +- 8 files changed, 7 insertions(+), 8 deletions(-) diff --git a/app/controllers/orbit_widget_controller.rb b/app/controllers/orbit_widget_controller.rb index c2be4691..47e24fe0 100644 --- a/app/controllers/orbit_widget_controller.rb +++ b/app/controllers/orbit_widget_controller.rb @@ -1,3 +1,3 @@ -class ObitWidgetController< OrbitFrontendComponentController +class OrbitWidgetController< OrbitFrontendComponentController end \ No newline at end of file diff --git a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletins_controller.rb b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletins_controller.rb index e8eb6149..c6eb0180 100644 --- a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletins_controller.rb +++ b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletins_controller.rb @@ -194,7 +194,6 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController a.flatten! a.uniq end - end diff --git a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/front_end/bulletins_controller.rb b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/front_end/bulletins_controller.rb index e840d65f..ff3cbdc9 100644 --- a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/front_end/bulletins_controller.rb +++ b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/front_end/bulletins_controller.rb @@ -1,4 +1,4 @@ -class Panel::Announcement::FrontEnd::BulletinsController < ObitWidgetController +class Panel::Announcement::FrontEnd::BulletinsController < OrbitWidgetController def initialize super 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 333f88e7..60aad3d9 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 @@ -1,4 +1,4 @@ -class Panel::Announcement::Widget::BulletinsController < ObitWidgetController +class Panel::Announcement::Widget::BulletinsController < OrbitWidgetController def initialize super diff --git a/vendor/built_in_modules/new_blog/app/controllers/panel/new_blog/widget/posts_controller.rb b/vendor/built_in_modules/new_blog/app/controllers/panel/new_blog/widget/posts_controller.rb index dab532ee..73098dda 100644 --- a/vendor/built_in_modules/new_blog/app/controllers/panel/new_blog/widget/posts_controller.rb +++ b/vendor/built_in_modules/new_blog/app/controllers/panel/new_blog/widget/posts_controller.rb @@ -1,4 +1,4 @@ -class Panel::NewBlog::Widget::PostsController < ObitWidgetController +class Panel::NewBlog::Widget::PostsController < OrbitWidgetController # GET /posts # GET /posts.xml def index diff --git a/vendor/built_in_modules/page_content/app/controllers/panel/page_content/front_end/page_contexts_controller.rb b/vendor/built_in_modules/page_content/app/controllers/panel/page_content/front_end/page_contexts_controller.rb index 8b750dcc..5b46866b 100644 --- a/vendor/built_in_modules/page_content/app/controllers/panel/page_content/front_end/page_contexts_controller.rb +++ b/vendor/built_in_modules/page_content/app/controllers/panel/page_content/front_end/page_contexts_controller.rb @@ -1,4 +1,4 @@ -class Panel::PageContent::FrontEnd::PageContextsController < ObitWidgetController +class Panel::PageContent::FrontEnd::PageContextsController < OrbitWidgetController def initialize super 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 c230140d..54374ed3 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 @@ -1,4 +1,4 @@ -class Panel::WebResource::FrontEnd::WebLinksController < ObitWidgetController +class Panel::WebResource::FrontEnd::WebLinksController < OrbitWidgetController def initialize super diff --git a/vendor/built_in_modules/web_resource/app/controllers/panel/web_resource/widget/web_links_controller.rb b/vendor/built_in_modules/web_resource/app/controllers/panel/web_resource/widget/web_links_controller.rb index bbe4a8d9..750897ae 100644 --- a/vendor/built_in_modules/web_resource/app/controllers/panel/web_resource/widget/web_links_controller.rb +++ b/vendor/built_in_modules/web_resource/app/controllers/panel/web_resource/widget/web_links_controller.rb @@ -1,4 +1,4 @@ -class Panel::WebResource::Widget::WebLinksController < ObitWidgetController +class Panel::WebResource::Widget::WebLinksController < OrbitWidgetController def initialize super From 6f6e84b0157e301f117bcd28aa867b1ef4eec96a Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 14 Mar 2012 20:05:03 +0800 Subject: [PATCH 012/125] fix dashboard & announcement --- app/assets/javascripts/bulletin_form.js.erb | 3 +- app/views/layouts/_side_bar.html.erb | 14 +- .../back_end/bulletins_controller.rb | 51 ++- .../announcement/app/models/bulletin.rb | 26 +- .../announcement/app/models/bulletin_file.rb | 22 +- .../announcement/app/models/bulletin_link.rb | 8 +- .../_bulletin_category.html.erb | 40 ++- .../bulletin_categorys/_form.html.erb | 54 +-- .../bulletin_categorys/_quick_edit.html.erb | 13 + .../_quick_edit_qe.html.erb | 28 ++ .../bulletin_categorys/index.html.erb | 41 +-- .../bulletins/_bulletin_file.html.erb | 16 +- .../bulletins/_bulletin_link.html - 複製.erb | 27 ++ .../bulletins/_bulletin_link.html.erb | 10 +- .../bulletins/_bulletin_link2.html - 複製.erb | 16 + .../bulletins/_bulletin_link2.html.erb | 17 + .../bulletins/_bulletin_link_qe.html.erb | 41 +++ .../back_end/bulletins/_form.html.erb | 322 +++++++++++++----- .../bulletins/_quick_edit_links.html.erb | 34 +- .../bulletins/_quick_edit_picture.html.erb | 13 +- .../back_end/bulletins/index.html - 複製.erb | 9 + .../back_end/bulletins/link_quick_edit.js.erb | 2 + .../back_end/bulletins/show.html.erb | 10 +- .../announcement/config/routes.rb | 5 +- .../back_end/page_contexts/_form.html.erb | 51 +-- .../page_contexts/_page_context.html.erb | 22 +- .../page_contexts/_view_page_context.html.erb | 23 +- .../back_end/page_contexts/edit.html.erb | 10 +- .../back_end/page_contexts/index.html.erb | 42 +-- .../back_end/page_contexts/view.html.erb | 41 +-- .../back_end/web_link_categorys_controller.rb | 2 +- .../back_end/web_links_controller.rb | 2 +- .../web_link_categorys/_form.html.erb | 38 ++- .../_web_link_category.html.erb | 26 +- .../web_link_categorys/index.html.erb | 46 +-- .../back_end/web_links/_form.html.erb | 145 +++++--- .../back_end/web_links/_web_links.html.erb | 17 +- .../back_end/web_links/index.html.erb | 59 +--- 38 files changed, 849 insertions(+), 497 deletions(-) create mode 100644 vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletin_categorys/_quick_edit.html.erb create mode 100644 vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletin_categorys/_quick_edit_qe.html.erb create mode 100644 vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletin_link.html - 複製.erb create mode 100644 vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletin_link2.html - 複製.erb create mode 100644 vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletin_link2.html.erb create mode 100644 vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletin_link_qe.html.erb create mode 100644 vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/index.html - 複製.erb create mode 100644 vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/link_quick_edit.js.erb diff --git a/app/assets/javascripts/bulletin_form.js.erb b/app/assets/javascripts/bulletin_form.js.erb index 5002cfae..17f86060 100644 --- a/app/assets/javascripts/bulletin_form.js.erb +++ b/app/assets/javascripts/bulletin_form.js.erb @@ -1,4 +1,4 @@ -$('.bulletin_urls_block a.delete').live('click', function(){ +$('.bulletin_links_block a.delete').live('click', function(){ $(this).parents('.list_item').remove(); }); @@ -9,4 +9,5 @@ $('.bulletin_files_block a.delete').live('click', function(){ $('.action a.remove_existing_record').live('click', function(){ $(this).next('.should_destroy').attr('value', 1); $("#bulletin_" + $(this).prev().attr('value')).hide(); + $("tr#bulletin_" + $(this).prev().attr('value')).hide(); }); \ No newline at end of file diff --git a/app/views/layouts/_side_bar.html.erb b/app/views/layouts/_side_bar.html.erb index d287e46c..44f448fd 100644 --- a/app/views/layouts/_side_bar.html.erb +++ b/app/views/layouts/_side_bar.html.erb @@ -17,17 +17,25 @@ <%= link_to content_tag(:i, nil, :class => 'icons-member') + t('admin.member'), admin_users_path %> <% end -%> -<%= content_tag :li, :class => active_for_controllers(nil) do -%> +<%= content_tag :li, :class => active_for_controllers('page_contexts') do -%> <%= link_to content_tag(:i, nil, :class => 'icons-page') + t('admin.page'), panel_page_content_back_end_page_contexts_path %> + <%= content_tag :ul, :class => ("nav nav-list " + visible_for_controllers('page_contexts')) do -%> + <%= content_tag :li, link_to(t('admin.all_articles'), panel_page_content_back_end_page_contexts_path), :class => active_for_action('page_context', 'index') %> + <% end -%> <% end -%> <%= content_tag :li, :class => active_for_controllers('designs') do -%> <%= link_to content_tag(:i, nil, :class => 'icons-window-block') + t('admin.design'), admin_designs_path %> <% end -%> -<%= content_tag :li, :class => active_for_controllers(nil) do -%> +<%= content_tag :li, :class => active_for_controllers('web_links', 'tags', 'web_link_categorys') do -%> <%= link_to content_tag(:i, nil, :class => 'icons-link') + t('admin.link'), panel_web_resource_back_end_web_links_path %> -<% end -%> + <%= content_tag :ul, :class => ("nav nav-list " + visible_for_controllers('web_links', 'tags', 'web_link_categorys')) do -%> + <%= content_tag :li, link_to(t('admin.all_articles'), panel_web_resource_back_end_web_links_path), :class => active_for_action('web_link', 'index') %> + <%= content_tag :li, link_to(t('admin.add_new'), new_panel_web_resource_back_end_web_link_path), :class => active_for_action('web_link', 'new') %> + <%= content_tag :li, link_to(t('admin.categories'), panel_web_resource_back_end_web_link_categorys_path), :class => active_for_action('web_link_categorys', 'index') %> + <%= content_tag :li, link_to(t('admin.tags'), panel_web_resource_back_end_tags_path), :class => active_for_action('tags', 'index') %> + <% end -%> <%= content_tag :li, :class => active_for_controllers(nil) do -%> <%= link_to content_tag(:i, nil, :class => 'icons-cog') + t('admin.site_settings'), nil %> diff --git a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletins_controller.rb b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletins_controller.rb index c6eb0180..8b86a7a4 100644 --- a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletins_controller.rb +++ b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletins_controller.rb @@ -8,6 +8,7 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController # @bulletins = Bulletin.all # @bulletins = Bulletin.desc("postdate desc") get_categorys(params[:bulletin_category_id]) + get_tags # @bulletins = Bulletin.where("bulletin_category_id" => params[:bulletin_category_id]).desc("postdate") if params[:bulletin_category_id] @@ -15,9 +16,6 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController # @bulletins = Bulletin.all.order_by([params[:sort], params[:direction]]) @bulletins = params[:sort] ? get_sorted_bulletins : Bulletin.all @bulletin_categories = BulletinCategory.all - - module_app = ModuleApp.first(:conditions => {:key => 'announcement'}) - @tags = Tag.all(:conditions => {:module_app_id => module_app.id}).order_by(I18n.locale, :asc) respond_to do |format| format.html # index.html.erb @@ -30,6 +28,7 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController # GET /bulletins/1.xml def show @bulletin = Bulletin.find(params[:id]) + get_tags # get_categorys # @bulletin_categorys = BulletinCategory.where("_id" => params[:id]) @@ -50,11 +49,14 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController # GET /bulletins/new.xml def new @bulletin = Bulletin.new + + @link_url = panel_announcement_back_end_bulletins_path # @bulletin.bulletin_files.build # @bulletin.bulletin_files.new get_categorys + get_tags respond_to do |format| format.html # new.html.erb @@ -66,7 +68,11 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController def edit @bulletin = Bulletin.find(params[:id]) # @summary_variable = @bulletin.summary_variable + + @link_url = panel_announcement_back_end_bulletin_path(@bulletin) + get_categorys + get_tags end # POST /bulletins @@ -89,6 +95,32 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController end end + def link_quick_add + # debugger + + @bulletin = Bulletin.find(params[:bulletin_id]) + + @link_url = panel_announcement_back_end_bulletins_path + + respond_to do |format| + format.js + end + + end + + def link_quick_edit + # debugger + + @bulletin = Bulletin.find(params[:bulletin_id]) + + @link_url = panel_announcement_back_end_bulletin_path(@bulletin) + + respond_to do |format| + format.js + end + + end + # PUT /bulletins/1 # PUT /bulletins/1.xml def update @@ -97,11 +129,11 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController @bulletin.update_user_id = current_user.id # @bulletin.image.clear if params[:bulletin][:image_del] == '1' - if params[:bulletin][:image_del] == '1' - @bulletin.remove_image! + # if params[:bulletin][:image_del] == '1' + # @bulletin.remove_image! # @bulletin.image_del = nil - params[:bulletin][:image_del] = nil - end + # params[:bulletin][:image_del] = nil + # end respond_to do |format| if @bulletin.update_attributes(params[:bulletin]) && @bulletin.save @@ -151,6 +183,11 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController @bulletin_categorys = BulletinCategory.authed_for_user(current_user,'submit_new') end end + + def get_tags + module_app = ModuleApp.first(:conditions => {:key => 'announcement'}) + @tags = Tag.all(:conditions => {:module_app_id => module_app.id}).order_by(I18n.locale, :asc) + end def get_sorted_bulletins bulletins = Bulletin.all diff --git a/vendor/built_in_modules/announcement/app/models/bulletin.rb b/vendor/built_in_modules/announcement/app/models/bulletin.rb index e68e2c97..d1b7f3c5 100644 --- a/vendor/built_in_modules/announcement/app/models/bulletin.rb +++ b/vendor/built_in_modules/announcement/app/models/bulletin.rb @@ -29,10 +29,11 @@ class Bulletin belongs_to :bulletin_category - embeds_many :bulletin_links, :cascade_callbacks => true - embeds_many :bulletin_files, :cascade_callbacks => true + # embeds_many :bulletin_links, :cascade_callbacks => true + # embeds_many :bulletin_files, :cascade_callbacks => true - # has_many :bulletin_files, :autosave => true, :dependent => :destroy + has_many :bulletin_links, :autosave => true, :dependent => :destroy + has_many :bulletin_files, :autosave => true, :dependent => :destroy accepts_nested_attributes_for :bulletin_files, :allow_destroy => true accepts_nested_attributes_for :bulletin_links, :allow_destroy => true @@ -41,6 +42,9 @@ class Bulletin before_save :set_key + after_save :save_bulletin_links + after_save :save_bulletin_files + def self.search( search = nil, category_id = nil ) @@ -97,6 +101,22 @@ class Bulletin self.is_hidden end + def save_bulletin_links + self.bulletin_links.each do |t| + if t.should_destroy + t.destroy + end + end + end + + def save_bulletin_files + self.bulletin_files.each do |t| + if t.should_destroy + t.destroy + end + end + end + def title @title ||= I18nVariable.first(:conditions => {:key => 'title', :language_value_id => self.id, :language_value_type => self.class}) rescue nil diff --git a/vendor/built_in_modules/announcement/app/models/bulletin_file.rb b/vendor/built_in_modules/announcement/app/models/bulletin_file.rb index 28062d40..05894515 100644 --- a/vendor/built_in_modules/announcement/app/models/bulletin_file.rb +++ b/vendor/built_in_modules/announcement/app/models/bulletin_file.rb @@ -5,13 +5,27 @@ class BulletinFile mount_uploader :file, AssetUploader - field :filetitle - field :description + # field :filetitle + # field :description + has_one :filetitle, :class_name => "I18nVariable", :as => :language_value, :autosave => true, :dependent => :destroy + has_one :description, :class_name => "I18nVariable", :as => :language_value, :autosave => true, :dependent => :destroy # field :to_save, :type => Boolean field :should_destroy, :type => Boolean - # belongs_to :bulletin - embedded_in :bulletin + belongs_to :bulletin + # embedded_in :bulletin + + + protected + + def set_key + if filetitle.new_record? + filetitle.key = 'filetitle' + end + if description.new_record? + description.key = 'description' + end + end end diff --git a/vendor/built_in_modules/announcement/app/models/bulletin_link.rb b/vendor/built_in_modules/announcement/app/models/bulletin_link.rb index a999d45d..30363182 100644 --- a/vendor/built_in_modules/announcement/app/models/bulletin_link.rb +++ b/vendor/built_in_modules/announcement/app/models/bulletin_link.rb @@ -4,10 +4,12 @@ class BulletinLink include Mongoid::Timestamps field :url - field :name + # field :name + + has_one :i18n_variable, :as => :language_value, :autosave => true, :dependent => :destroy field :should_destroy, :type => Boolean - embedded_in :bulletin - + # embedded_in :bulletin + belongs_to :bulletin end diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletin_categorys/_bulletin_category.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletin_categorys/_bulletin_category.html.erb index e834ec60..9c95881a 100644 --- a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletin_categorys/_bulletin_category.html.erb +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletin_categorys/_bulletin_category.html.erb @@ -1,21 +1,25 @@ - - <%= bulletin_category.key %> - <% @site_valid_locales.each do |locale| %> - <%= bulletin_category.i18n_variable[locale] rescue nil %> - <% end %> - <%= bulletin_category.display %> - <% if is_manager? %> + - <%= link_to t('blog.new_auth'), init_admin_object_auths_path("BulletinCategory",bulletin_category,:token => @module_app.token) %>
    - <% bulletin_category.object_auths.each do |obj_auth| %> - <%= link_to obj_auth.title,edit_admin_object_auth_url(obj_auth,:token => @module_app.token) %>
    - <% end %> + <%= bulletin_category.key %> +
    + +
    - - <% end %> - <%= link_to t('bulletin_category.edit'), edit_panel_announcement_back_end_bulletin_category_path(bulletin_category), :remote => true %> | - <%= link_to t('bulletin_category.quick_edit'), panel_announcement_back_end_bulletin_category_quick_edit_path(bulletin_category), :remote => true %> | - <%= link_to t('bulletin_category.delete'), panel_announcement_back_end_bulletin_category_path(bulletin_category), :confirm => t('announcement.sure?'), :method => :delete, :remote => true %> - - \ No newline at end of file + <% @site_valid_locales.each do |locale| %> + <%= bulletin_category.i18n_variable[locale] rescue nil %> + <% end %> + <%= bulletin_category.display %> + diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletin_categorys/_form.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletin_categorys/_form.html.erb index d7bfac7b..1ce7f629 100644 --- a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletin_categorys/_form.html.erb +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletin_categorys/_form.html.erb @@ -1,36 +1,36 @@ <% # encoding: utf-8 %> <%= form_for(@bulletin_category, :remote => true, :url => @url) do |f| %> -<%#= form_for(@bulletin_category, :remote => true, :url => panel_announcement_back_end_bulletin_category_path(@bulletin_category)) do |f| %> -
    - <%= f.label :key %>
    - <%= f.text_field :key %> -
    - -
    - <%= f.label :name %>
    - <%= f.fields_for :i18n_variable, (@bulletin_category.new_record? ? @bulletin_category.build_i18n_variable : @bulletin_category.i18n_variable) do |f| %> - <% @site_valid_locales.each do |locale| %> - <%= I18nVariable.first(:conditions => {:key => locale})[I18n.locale] %> - <%= f.text_field locale, :style => "width:130px" %> - <% end %> - <% end %> -
    - -
    - <%= f.label :display %>
    - <%#= f.select :display, BulletinCategory::PAYMENT_TYPES, :prompt => 'Select a display method' %> +

    <%= (@bulletin_category.new_record? ? 'Add' : 'Edit') %>

    - <%= f.radio_button :display, "List" %>List - <%#= f.label :display, 'list', :value => '1', :checked => @a %> - <%= f.radio_button :display, "Picture" %>Picture - <%#= f.label :display, 'picture', :value => '2', :checked => @b %> -
    憿舐內孵航身摰典圈X嚗鞈閮曄璅撘 -
    +
    + <%= f.label :key %> + <%= f.text_field :key %> +
    + +
    + <%= f.fields_for :i18n_variable, (@bulletin_category.new_record? ? @bulletin_category.build_i18n_variable : @bulletin_category.i18n_variable) do |f| %> + <% @site_valid_locales.each do |locale| %> +
    + <%= label_tag "name-#{locale}", "Name-#{I18nVariable.from_locale(locale)}", :class => 'control-label' %> +
    + <%= f.text_field locale, :class => 'input-xxlarge' %> +
    +
    + <% end %> + <% end %> +
    + +
    + <%= f.label :display %> + <%= f.radio_button :display, "List" %>List + <%= f.radio_button :display, "Picture" %>Picture +
    憿舐內孵航身摰典圈X嚗鞈閮曄璅撘 +
    -
    - <%= f.submit %> +
    + <%= f.submit 'Submit/', :class=>'btn btn-primary' %>
    <% end %> diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletin_categorys/_quick_edit.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletin_categorys/_quick_edit.html.erb new file mode 100644 index 00000000..14a72951 --- /dev/null +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletin_categorys/_quick_edit.html.erb @@ -0,0 +1,13 @@ + + + + <%= t(:quick_edit) %> + <%= form_for bulletin_category, :url => panel_announcement_back_end_bulletin_category_path(bulletin_category), :html => {:class => 'form-horizontal'} do |f| %> + <%= render :partial => "quick_edit_qe", :locals => { :f => f, :bulletin_category => bulletin_category } %> +
    + <%= f.submit t(:submit), :class => 'btn btn-primary' %> + <%= f.submit t(:cancel), :class => 'btn', :type => 'reset' %> +
    + <% end %> + + diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletin_categorys/_quick_edit_qe.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletin_categorys/_quick_edit_qe.html.erb new file mode 100644 index 00000000..cb32d861 --- /dev/null +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletin_categorys/_quick_edit_qe.html.erb @@ -0,0 +1,28 @@ +<% # encoding: utf-8 %> + +
    + +
    + <%= f.label :key %> + <%= f.text_field :key %> +
    +
    + <%= f.fields_for :i18n_variable, bulletin_category.i18n_variable do |f| %> + <% @site_valid_locales.each do |locale| %> +
    + <%= label_tag "title-#{locale}", "Title-#{I18nVariable.from_locale(locale)}", :class => 'control-label' %> +
    + <%= f.text_field locale, :class => 'input-xxlarge' %> +
    +
    + <% end %> + <% end %> +
    + +
    + <%= f.label :display %> + <%= f.radio_button :display, "List" %>List + <%= f.radio_button :display, "Picture" %>Picture +
    憿舐內孵航身摰典圈X嚗鞈閮曄璅撘 +
    +
    diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletin_categorys/index.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletin_categorys/index.html.erb index 87b30a04..0a6e7f83 100644 --- a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletin_categorys/index.html.erb +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletin_categorys/index.html.erb @@ -1,38 +1,23 @@ -<% content_for :secondary do %> -<%= render :partial => '/panel/announcement/back_end/announcement_secondary' %> -<% end -%> <%= flash_messages %> -
    -
    -
    -
    -
    + + + + + <% @site_valid_locales.each do |locale| %> + + <% end %> + + + + -

    <%= t('bulletin_category.list_announcement_class') %>

    - -
    <%= t('bulletin_category.key') %><%= I18nVariable.first(:conditions => {:key => locale})[I18n.locale] %><%= t('bulletin_category.display') %>
    - - - <% @site_valid_locales.each do |locale| %> - - <% end %> - - - - -<%# @bulletin_categorys.each do |post| %> <%= render :partial => 'bulletin_category', :collection => @bulletin_categorys %> -<%# end %> + +
    <%= t('bulletin_category.key') %><%= I18nVariable.first(:conditions => {:key => locale})[I18n.locale] %><%= t('bulletin_category.display') %><%= t('bulletin.action') %>
    -
    -
    -
    -
    - -

    Add New

    <%= render :partial => "form" %>
    diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletin_file.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletin_file.html.erb index 86785ee0..6da49ceb 100644 --- a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletin_file.html.erb +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletin_file.html.erb @@ -6,10 +6,22 @@ <%= f.file_field :file %> <%= f.label :file_title %> - <%= f.text_field :filetitle %> + <%#= f.text_field :filetitle %> + <%= f.fields_for :filetitle, (bulletin_file.new_record? ? bulletin_file.build_filetitle : bulletin_file.filetitle ) do |f| %> + <% @site_valid_locales.each do |locale| %> + <%= I18nVariable.from_locale(locale) %> + <%= f.text_field locale %> + <% end %> + <% end %> <%= f.label :file_description %> - <%= f.text_field :description %> + <%#= f.text_field :description %> + <%= f.fields_for :description, (bulletin_file.new_record? ? bulletin_file.build_description : bulletin_file.description ) do |f| %> + <% @site_valid_locales.each do |locale| %> + <%= I18nVariable.from_locale(locale) %> + <%= f.text_field locale %> + <% end %> + <% end %> <% if bulletin_file.new_record? %> diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletin_link.html - 複製.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletin_link.html - 複製.erb new file mode 100644 index 00000000..33d1ba1e --- /dev/null +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletin_link.html - 複製.erb @@ -0,0 +1,27 @@ + +
    " class='list_item'> +
    + + <%= f.label :link_url %> + <%= f.text_field :url %> + + <%= f.label :link_name %> + <%#= f.text_field :name %> + <%= f.fields_for :i18n_variable, (bulletin_link.new_record? ? bulletin_link.build_i18n_variable : bulletin_link.i18n_variable) do |f| %> + <% @site_valid_locales.each do |locale| %> + <%= I18nVariable.first(:conditions => {:key => locale})[I18n.locale] %> + <%= f.text_field locale, :style => "width:130px" %> + <% end %> + <% end %> + + + <% if bulletin_link.new_record? %> + <%= t(:delete) %> + <% else %> + <%= f.hidden_field :id %> + <%= t(:delete) %> + <%= f.hidden_field :should_destroy, :value => nil, :class => 'should_destroy' %> + <% end %> + +
    +
    diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletin_link.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletin_link.html.erb index 44c7ab75..e0077384 100644 --- a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletin_link.html.erb +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletin_link.html.erb @@ -1,12 +1,18 @@ -
    " class='list_item'> +
    " class='list_item'>
    <%= f.label :link_url %> <%= f.text_field :url %> <%= f.label :link_name %> - <%= f.text_field :name %> + <%#= f.text_field :name %> + <%= f.fields_for :i18n_variable, (bulletin_link.new_record? ? bulletin_link.build_i18n_variable : bulletin_link.i18n_variable) do |f| %> + <% @site_valid_locales.each do |locale| %> + <%= I18nVariable.first(:conditions => {:key => locale})[I18n.locale] %> + <%= f.text_field locale, :style => "width:130px" %> + <% end %> + <% end %> <% if bulletin_link.new_record? %> diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletin_link2.html - 複製.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletin_link2.html - 複製.erb new file mode 100644 index 00000000..c44b5c92 --- /dev/null +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletin_link2.html - 複製.erb @@ -0,0 +1,16 @@ + + "> + <%= link_to bulletin_link2.i18n_variable.zh_tw, bulletin_link2.url, :target => '_blank' %> + <%= link_to bulletin_link2.i18n_variable.en, bulletin_link2.url, :target => '_blank' %> + + + <%= f.hidden_field :id %> + + <%= f.hidden_field :should_destroy, :value => nil, :class => 'should_destroy' %> + + + + + + + \ No newline at end of file diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletin_link2.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletin_link2.html.erb new file mode 100644 index 00000000..a3bc5243 --- /dev/null +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletin_link2.html.erb @@ -0,0 +1,17 @@ + + "> + <%= link_to bulletin_link2.i18n_variable.zh_tw, bulletin_link2.url, :target => '_blank' %> + <%= link_to bulletin_link2.i18n_variable.en, bulletin_link2.url, :target => '_blank' %> + + + + <%= f.hidden_field :id %> + + <%= f.hidden_field :should_destroy, :value => nil, :class => 'should_destroy' %> + + + + + + + \ No newline at end of file diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletin_link_qe.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletin_link_qe.html.erb new file mode 100644 index 00000000..7208f73c --- /dev/null +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletin_link_qe.html.erb @@ -0,0 +1,41 @@ +<% # encoding: utf-8 %> + + <%= form_for(@bulletin.bulletin_links, :remote => true, :url => @link_url) do |f| %> + + + + <% end %> + + + \ No newline at end of file diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_form.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_form.html.erb index 2236b5ed..35137b4f 100644 --- a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_form.html.erb +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_form.html.erb @@ -20,108 +20,246 @@ <%= t('announcement.芷文歇銝單獢') %> <% end %>
    + + + +
    + +
    +
    + +
    +

    Picture

    +
    +
    + +
    + + +
    + +
    + <% if @bulletin.image.file %> + <%= f.check_box :remove_image %> + <%= t('announcement.芷文歇銝單獢') %> + <% end %> +
    +
    +
    +
    -
    - <%= f.label :title %> - <%= f.fields_for :title, (@bulletin.new_record? ? @bulletin.build_title : @bulletin.title ) do |f| %> - <% @site_valid_locales.each do |locale| %> - - <%= I18nVariable.from_locale(locale) %> - <%= f.text_field locale %> - - <% end %> - <% end %> -
    - -
    - <%= f.label :subtitle %> - <%= f.fields_for :subtitle, (@bulletin.new_record? ? @bulletin.build_subtitle : @bulletin.subtitle ) do |f| %> - <% @site_valid_locales.each do |locale| %> - - <%= I18nVariable.from_locale(locale) %> - <%= f.text_area locale, :rows => 10, :cols => 40 %> - - <% end %> - <% end %> -
    +
    +
    + +
    +

    Date

    +
    +
    + +
    + <%= f.date_select :postdate, {:use_month_numbers => true, :prompt => { :month => 'Month', :day => 'Day', :year => 'Year'}, :order => [:day, :month, :year] }, {:class => 'input-small'} %> +
    +
    +
    + +
    + <%= f.date_select :deadline, {:use_month_numbers => true, :prompt => { :month => 'Month', :day => 'Day', :year => 'Year'}, :order => [:day, :month, :year] }, {:class => 'input-small'} %> +
    +
    +
    +
    + +
    +
    + +
    +

    Status

    +
    +
    + <%= f.check_box :is_top %><%= t('top') %> + <%= f.check_box :is_hot %><%= t('hot') %> + <%= f.check_box :is_hidden %><%= t('hide') %> +
    +
    +
    -
    - <%= f.label :text %> - <%= f.fields_for :text, (@bulletin.new_record? ? @bulletin.build_text : @bulletin.text ) do |f| %> - <% @site_valid_locales.each do |locale| %> - - <%= I18nVariable.from_locale(locale) %> - <%= f.text_area locale, :rows => 10, :cols => 40 %> - - <% end %> - <% end %> +
    +
    + +
    +

    Tags

    +
    + <% @tags.each do |tag| %> + <%= check_box_tag 'bulletin[tag_ids][]', tag.id, @bulletin.tag_ids.include?(tag.id)%> + <%= tag[I18n.locale] %> + <% end %> +
    +
    +
    -
    - <%= f.label :postdate %>
    - <%= f.date_select :postdate, :order => [:year, :month, :day], :use_month_numbers => true %> - <%#= date_select("bulletin", "postdate", :use_month_numbers => true) %> -
    -
    - <%= f.label :deadline %>
    - <%= f.date_select :deadline, :use_month_numbers => true, :prompt => { :day => 'Select day', :month => 'Select month', :year => 'Select year'} %> - <%#= f.date_select :deadline, :order => [:year, :month, :day],:default => 1.years.from_now, :use_month_numbers => true %> -
    - -
    - <%#= f.label :url %>
    - <%#= f.text_field :url, :size => 60 %> -
    - - - + diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/index.html - 複製.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/index.html - 複製.erb new file mode 100644 index 00000000..d37d2134 --- /dev/null +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/index.html - 複製.erb @@ -0,0 +1,9 @@ +<%= render 'filter' %> + + <%= render 'bulletins' %> +
    + +
    + <%= link_to content_tag(:i, nil, :class => 'icon-plus icon-white') + t('admin.add'), new_panel_announcement_back_end_bulletin_path, :class => 'btn btn-primary' %> +
    + diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/link_quick_edit.js.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/link_quick_edit.js.erb new file mode 100644 index 00000000..cbe5e3c7 --- /dev/null +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/link_quick_edit.js.erb @@ -0,0 +1,2 @@ +//$.each($(".quick_edit"),function(obj){ $(this).remove(); }); +$("#<%= "bulletin_#{bulletin_link2.id}" %>").append("<%= j render "bulletin_link_qe" %>"); diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/show.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/show.html.erb index 7b886e77..5a33b86a 100644 --- a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/show.html.erb +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/show.html.erb @@ -21,7 +21,7 @@
  • <%= t('announcement.title') %> - <%= @bulletin.title %> + <%= @bulletin.title[I18n.locale] %>
  • <%#= image_tag(@bulletin.image.url, :size => "320x240") if @bulletin.image.file %> @@ -29,23 +29,23 @@
  • <%= t('announcement.subtitle') %> - <%= @bulletin.subtitle %> + <%= @bulletin.subtitle[I18n.locale].html_safe %>
  • <%= t('announcement.text') %> - <%= @bulletin.text %> + <%= @bulletin.text[I18n.locale].html_safe %>
  • <%= t('announcement.link') %> <% @bulletin.bulletin_links.each do | blink | %> - <%= link_to blink.name, blink.url, :target => '_blank' %> + <%= link_to blink.i18n_variable[I18n.locale], blink.url, :target => '_blank' %> <% end %>
  • <%= t('announcement.file') %> <% @bulletin.bulletin_files.each do | bfile | %> - <%= link_to bfile.filetitle, bfile.file.url, {:target => '_blank', :title => bfile.description} if bfile.file.file %> + <%= link_to bfile.filetitle[I18n.locale], bfile.file.url, {:target => '_blank', :title => bfile.description[I18n.locale]} if bfile.file.file %> <% end %>
  • diff --git a/vendor/built_in_modules/announcement/config/routes.rb b/vendor/built_in_modules/announcement/config/routes.rb index f6f30b31..61056e49 100644 --- a/vendor/built_in_modules/announcement/config/routes.rb +++ b/vendor/built_in_modules/announcement/config/routes.rb @@ -7,7 +7,10 @@ Rails.application.routes.draw do match 'update_setting' => "fact_checks#update_setting" ,:as => :fact_checks_update_setting root :to => "bulletins#index" - resources :bulletins + resources :bulletins do + match "link_quick_add/:bulletin_id" => "bulletins#link_quick_add" ,:as => :link_quick_add + match "link_quick_edit/:bulletin_id" => "bulletins#link_quick_edit" ,:as => :link_quick_edit + end resources :bulletin_categorys, :controller => 'bulletin_categorys' do match "quick_edit/:bulletin_category_id" => "bulletin_categorys#quick_edit" ,:as => :quick_edit end diff --git a/vendor/built_in_modules/page_content/app/views/panel/page_content/back_end/page_contexts/_form.html.erb b/vendor/built_in_modules/page_content/app/views/panel/page_content/back_end/page_contexts/_form.html.erb index e5c7fc45..4ca568a9 100644 --- a/vendor/built_in_modules/page_content/app/views/panel/page_content/back_end/page_contexts/_form.html.erb +++ b/vendor/built_in_modules/page_content/app/views/panel/page_content/back_end/page_contexts/_form.html.erb @@ -1,31 +1,32 @@ <% # encoding: utf-8 %> - <%= f.error_messages %> - <%#= debugger %> - -
    - <%= f.label :name %> - <%= @page_context.page.i18n_variable[I18n.locale] %> -
    +<%= f.error_messages %> -
    - <%= f.label :context %> - <%= f.fields_for :context, (@page_context.new_record? ? @page_context.build_context : @page_context.context ) do |f| %> - <% @site_valid_locales.each do |locale| %> - - <%= I18nVariable.from_locale(locale) %> - <%= f.text_area locale, :rows => 10, :cols => 40 %> - - <% end %> - <% end %> -
    - -
    -
    - -
    - <%= f.submit %> -
    +
    + +
    + <%= f.label :name %> + <%= @page_context.page.i18n_variable[I18n.locale] %> +
    + +
    + <%= f.label :context %> + <%= f.fields_for :context, (@page_context.new_record? ? @page_context.build_context : @page_context.context ) do |f| %> + <% @site_valid_locales.each do |locale| %> + + <%= I18nVariable.from_locale(locale) %> + <%= f.text_area locale, :style=>"width:100%" %> + + <% end %> + <% end %> +
    + + +
    + <%= f.submit 'Submit/', :class=>'btn btn-primary' %> +
    + +
    <% content_for :page_specific_javascript do %> diff --git a/vendor/built_in_modules/page_content/app/views/panel/page_content/back_end/page_contexts/_page_context.html.erb b/vendor/built_in_modules/page_content/app/views/panel/page_content/back_end/page_contexts/_page_context.html.erb index c1d86fe1..08db9b2d 100644 --- a/vendor/built_in_modules/page_content/app/views/panel/page_content/back_end/page_contexts/_page_context.html.erb +++ b/vendor/built_in_modules/page_content/app/views/panel/page_content/back_end/page_contexts/_page_context.html.erb @@ -1,10 +1,14 @@ - - <%= page_context.page.i18n_variable[I18n.locale] %> - <%= link_to page_context.version, panel_page_content_back_end_view_path(page_context.page_id) %> - <%= page_context.updated_at.strftime("%Y-%m-%d %H:%I:%S") %> - <%= User.find(page_context.create_user_id).name %> - - <%= link_to t('page_context.edit'), edit_panel_page_content_back_end_page_context_path(page_context) %> - - + + + <%= page_context.page.i18n_variable[I18n.locale] %> +
    + +
    + + <%= link_to page_context.version, panel_page_content_back_end_view_path(page_context.page_id) %> + <%= page_context.updated_at.strftime("%Y-%m-%d %H:%I:%S") %> + <%= User.find(page_context.create_user_id).name %> + \ No newline at end of file diff --git a/vendor/built_in_modules/page_content/app/views/panel/page_content/back_end/page_contexts/_view_page_context.html.erb b/vendor/built_in_modules/page_content/app/views/panel/page_content/back_end/page_contexts/_view_page_context.html.erb index db23a280..7035a700 100644 --- a/vendor/built_in_modules/page_content/app/views/panel/page_content/back_end/page_contexts/_view_page_context.html.erb +++ b/vendor/built_in_modules/page_content/app/views/panel/page_content/back_end/page_contexts/_view_page_context.html.erb @@ -1,10 +1,15 @@ - - <%= view_page_context.page.i18n_variable[I18n.locale] %> - <%= view_page_context.version %> - <%= view_page_context.updated_at.strftime("%Y-%m-%d %H:%I:%S") %> - <%= User.find(view_page_context.create_user_id).name %> - - <%= link_to t('view_page_context.show'), panel_page_content_back_end_page_context_path(view_page_context) %> - - + + + + <%= view_page_context.page.i18n_variable[I18n.locale] %> +
    + +
    + + <%= view_page_context.version %> + <%= view_page_context.updated_at.strftime("%Y-%m-%d %H:%I:%S") %> + <%= User.find(view_page_context.create_user_id).name %> + \ No newline at end of file diff --git a/vendor/built_in_modules/page_content/app/views/panel/page_content/back_end/page_contexts/edit.html.erb b/vendor/built_in_modules/page_content/app/views/panel/page_content/back_end/page_contexts/edit.html.erb index 18bb0ce5..86f2398c 100644 --- a/vendor/built_in_modules/page_content/app/views/panel/page_content/back_end/page_contexts/edit.html.erb +++ b/vendor/built_in_modules/page_content/app/views/panel/page_content/back_end/page_contexts/edit.html.erb @@ -1,7 +1,3 @@ -
    -
    -
    -

    <%= t('page_content.editing_page_content') %>

    @@ -9,8 +5,4 @@ <%= render :partial => 'form', :locals => {:f => f} %> <% end %> -<%= link_back %> -
    -
    -
    -
    \ No newline at end of file +<%#= link_back %> \ No newline at end of file diff --git a/vendor/built_in_modules/page_content/app/views/panel/page_content/back_end/page_contexts/index.html.erb b/vendor/built_in_modules/page_content/app/views/panel/page_content/back_end/page_contexts/index.html.erb index a1566881..3227dcd4 100644 --- a/vendor/built_in_modules/page_content/app/views/panel/page_content/back_end/page_contexts/index.html.erb +++ b/vendor/built_in_modules/page_content/app/views/panel/page_content/back_end/page_contexts/index.html.erb @@ -1,36 +1,20 @@ -<% content_for :secondary do %> -
    -
    -
    -
    -
    -
      -
    • <%= link_to t('page_context.page_content_list'), panel_page_content_back_end_page_contexts_path %>
    • -
    -<% end -%> <%= flash_messages %> -
    -
    -
    -
    -
    - -

    <%= t('page_context.list_page_content') %>

    - - - - - - - - - +
    <%= t('page_context.name') %><%= t('page_context.version') %><%= t('page_context.update_time') %><%= t('page_context.last_modified') %><%= t('page_context.action') %>
    + + + + + + + + + - <%= render :partial => 'page_context', :collection => @page_contexts %> + <%= render :partial => 'page_context', :collection => @page_contexts %> -
    <%= t('page_context.name') %><%= t('page_context.version') %><%= t('page_context.update_time') %><%= t('page_context.last_modified') %>
    + + -
    diff --git a/vendor/built_in_modules/page_content/app/views/panel/page_content/back_end/page_contexts/view.html.erb b/vendor/built_in_modules/page_content/app/views/panel/page_content/back_end/page_contexts/view.html.erb index c5a9871a..d88df80e 100644 --- a/vendor/built_in_modules/page_content/app/views/panel/page_content/back_end/page_contexts/view.html.erb +++ b/vendor/built_in_modules/page_content/app/views/panel/page_content/back_end/page_contexts/view.html.erb @@ -1,36 +1,19 @@ -<% content_for :secondary do %> -
    -
    -
    -
    -
    -
      -
    • <%= link_to t('page_context.page_content_list'), panel_page_content_back_end_page_contexts_path %>
    • -
    -<% end -%> <%= flash_messages %> -
    -
    -
    -
    -
    - -

    <%= t('page_context.list_page_content') %>

    - - - - - - - - - +
    <%= t('page_context.name') %><%= t('page_context.version') %><%= t('page_context.update_time') %><%= t('page_context.last_modified') %><%= t('page_context.action') %>
    + + + + + + + + + <%= render :partial => 'view_page_context', :collection => @page_contexts %> -
    <%= t('page_context.name') %><%= t('page_context.version') %><%= t('page_context.update_time') %><%= t('page_context.last_modified') %>
    - -
    + + diff --git a/vendor/built_in_modules/web_resource/app/controllers/panel/web_resource/back_end/web_link_categorys_controller.rb b/vendor/built_in_modules/web_resource/app/controllers/panel/web_resource/back_end/web_link_categorys_controller.rb index 3db38add..0ba3236a 100644 --- a/vendor/built_in_modules/web_resource/app/controllers/panel/web_resource/back_end/web_link_categorys_controller.rb +++ b/vendor/built_in_modules/web_resource/app/controllers/panel/web_resource/back_end/web_link_categorys_controller.rb @@ -1,6 +1,6 @@ class Panel::WebResource::BackEnd::WebLinkCategorysController < ApplicationController - layout 'admin' + layout 'new_admin' def index @web_link_categorys = WebLinkCategory.all diff --git a/vendor/built_in_modules/web_resource/app/controllers/panel/web_resource/back_end/web_links_controller.rb b/vendor/built_in_modules/web_resource/app/controllers/panel/web_resource/back_end/web_links_controller.rb index f1ec7485..dfe09ce5 100644 --- a/vendor/built_in_modules/web_resource/app/controllers/panel/web_resource/back_end/web_links_controller.rb +++ b/vendor/built_in_modules/web_resource/app/controllers/panel/web_resource/back_end/web_links_controller.rb @@ -1,7 +1,7 @@ class Panel::WebResource::BackEnd::WebLinksController < ApplicationController - layout 'admin' + layout 'new_admin' before_filter :authenticate_user! before_filter :is_admin? diff --git a/vendor/built_in_modules/web_resource/app/views/panel/web_resource/back_end/web_link_categorys/_form.html.erb b/vendor/built_in_modules/web_resource/app/views/panel/web_resource/back_end/web_link_categorys/_form.html.erb index 7eb698ea..2e0f61ff 100644 --- a/vendor/built_in_modules/web_resource/app/views/panel/web_resource/back_end/web_link_categorys/_form.html.erb +++ b/vendor/built_in_modules/web_resource/app/views/panel/web_resource/back_end/web_link_categorys/_form.html.erb @@ -1,25 +1,29 @@ <% # encoding: utf-8 %> <%= form_for(@web_link_category, :remote => true, :url => @url) do |f| %> -<%#= form_for(@web_link_category, :remote => true, :url => panel_web_resource_back_end_web_link_category_path(@web_link_category)) do |f| %> -
    - <%= f.label :key %>
    - <%= f.text_field :key %> -
    +

    <%= (@web_link_category.new_record? ? 'Add' : 'Edit') %>

    + +
    + <%= f.label :key %> + <%= f.text_field :key %> +
    + +
    + <%= f.fields_for :i18n_variable, (@web_link_category.new_record? ? @web_link_category.build_i18n_variable : @web_link_category.i18n_variable) do |f| %> + <% @site_valid_locales.each do |locale| %> +
    + <%= label_tag "name-#{locale}", "Name-#{I18nVariable.from_locale(locale)}", :class => 'control-label' %> +
    + <%= f.text_field locale, :class => 'input-xxlarge' %> +
    +
    + <% end %> + <% end %> +
    -
    - <%= f.label :name %>
    - <%= f.fields_for :i18n_variable, (@web_link_category.new_record? ? @web_link_category.build_i18n_variable : @web_link_category.i18n_variable) do |f| %> - <% @site_valid_locales.each do |locale| %> - <%= I18nVariable.first(:conditions => {:key => locale})[I18n.locale] %> - <%= f.text_field locale, :style => "width:130px" %> - <% end %> - <% end %> -
    - -
    - <%= f.submit %> +
    + <%= f.submit 'Submit/', :class=>'btn btn-primary' %>
    <% end %> diff --git a/vendor/built_in_modules/web_resource/app/views/panel/web_resource/back_end/web_link_categorys/_web_link_category.html.erb b/vendor/built_in_modules/web_resource/app/views/panel/web_resource/back_end/web_link_categorys/_web_link_category.html.erb index d6e27e8d..3f6a1a71 100644 --- a/vendor/built_in_modules/web_resource/app/views/panel/web_resource/back_end/web_link_categorys/_web_link_category.html.erb +++ b/vendor/built_in_modules/web_resource/app/views/panel/web_resource/back_end/web_link_categorys/_web_link_category.html.erb @@ -1,12 +1,16 @@ - - <%= web_link_category.key %> - <% @site_valid_locales.each do |locale| %> - <%= web_link_category.i18n_variable[locale] rescue nil %> - <% end %> - - <%= link_to t('web_link_category.edit'), edit_panel_web_resource_back_end_web_link_category_path(web_link_category), :remote => true %> | - <%= link_to t('web_link_category.quick_edit'), panel_web_resource_back_end_web_link_category_quick_edit_path(web_link_category), :remote => true %> | - <%= link_to t('web_link_category.delete'), panel_web_resource_back_end_web_link_category_path(web_link_category), :confirm => t('sure?'), :method => :delete, :remote => true %> - - \ No newline at end of file + + + + <%= web_link_category.key %> +
    + +
    + + <% @site_valid_locales.each do |locale| %> + <%= web_link_category.i18n_variable[locale] rescue nil %> + <% end %> + \ No newline at end of file diff --git a/vendor/built_in_modules/web_resource/app/views/panel/web_resource/back_end/web_link_categorys/index.html.erb b/vendor/built_in_modules/web_resource/app/views/panel/web_resource/back_end/web_link_categorys/index.html.erb index 45842451..762da9e7 100644 --- a/vendor/built_in_modules/web_resource/app/views/panel/web_resource/back_end/web_link_categorys/index.html.erb +++ b/vendor/built_in_modules/web_resource/app/views/panel/web_resource/back_end/web_link_categorys/index.html.erb @@ -1,43 +1,23 @@ -<% content_for :secondary do %> -
    -
    -
    -
    -
    -
      -
    • <%#= link_to t('web_link_category.new_web_resource_class'), new_panel_web_resource_back_end_web_link_category_path, :class => 'seclink1' %>
    • -
    -<% end -%> + <%= flash_messages %> -

    <%= t('web_link_category.list_web_resource_class') %>

    -
    -
    -
    -
    -
    - - - - <% @site_valid_locales.each do |locale| %> - - <% end %> - - + + + + + <% @site_valid_locales.each do |locale| %> + + <% end %> + + + -<%# @web_link_categorys.each do |post| %> <%= render :partial => 'web_link_category', :collection => @web_link_categorys %> -<%# end %> + + -
    -
    -
    -
    - -

    Add New

    <%= render :partial => "form" %>
    - diff --git a/vendor/built_in_modules/web_resource/app/views/panel/web_resource/back_end/web_links/_form.html.erb b/vendor/built_in_modules/web_resource/app/views/panel/web_resource/back_end/web_links/_form.html.erb index ce17555a..2abdf4a0 100644 --- a/vendor/built_in_modules/web_resource/app/views/panel/web_resource/back_end/web_links/_form.html.erb +++ b/vendor/built_in_modules/web_resource/app/views/panel/web_resource/back_end/web_links/_form.html.erb @@ -1,62 +1,101 @@ <% # encoding: utf-8 %> <%= f.error_messages %> - <%#= debugger %> - -
    - <%= f.label :category %>
    - <%= f.select :web_link_category_id, @web_link_categorys.collect {|t| [ t.i18n_variable[I18n.locale], t.id ]} %> -
    - -
    - <%= f.label :name %> - <%= f.fields_for :name, (@web_link.new_record? ? @web_link.build_name : @web_link.name ) do |f| %> - <% @site_valid_locales.each do |locale| %> - - <%= I18nVariable.from_locale(locale) %> - <%= f.text_field locale %> - - <% end %> - <% end %> -
    - -
    - <%= f.label :url %>
    - <%= f.text_field :url, :size => 60 %> -
    -
    - <%= f.label :describe %> - <%= f.fields_for :context, (@web_link.new_record? ? @web_link.build_context : @web_link.context ) do |f| %> - <% @site_valid_locales.each do |locale| %> - - <%= I18nVariable.from_locale(locale) %> - <%= f.text_area locale, :rows => 10, :cols => 40 %> - - <% end %> - <% end %> -
    + + +
    + +
    +
    + +
    +

    Status

    +
    +
    + <%= f.check_box :is_top %><%= t('top') %> + <%= f.check_box :is_hot %><%= t('hot') %> + <%= f.check_box :is_hidden %><%= t('hide') %> +
    +
    +
    + +
    +
    + +
    +

    Tags

    +
    + <% @tags.each do |tag| %> + <%= check_box_tag 'web_link[tag_ids][]', tag.id, @web_link.tag_ids.include?(tag.id)%> + <%= tag[I18n.locale] %> + <% end %> +
    +
    -
    - <%= f.label :status %>
    - <%= f.check_box :is_top %><%= t('top') %> - <%= f.check_box :is_hot %><%= t('hot') %> - <%= f.check_box :is_hidden %><%= t('hidden') %> -
    - -
    - <%= f.label :tags %>
    - <% @tags.each do |tag| %> - <%= check_box_tag 'web_link[tag_ids][]', tag.id, @web_link.tag_ids.include?(tag.id)%> - <%= tag[I18n.locale] %> - <% end %> -
    - -
    -
    +
    -
    - <%= f.submit %> + + + +
    +
    + + <%= f.label :category %> + <%= f.select :web_link_category_id, @web_link_categorys.collect {|t| [ t.i18n_variable[I18n.locale], t.id ]} %> + + + +
    + <%= f.label :name %> + <%= f.fields_for :name, (@web_link.new_record? ? @web_link.build_name : @web_link.name ) do |f| %> + <% @site_valid_locales.each do |locale| %> + + <%= I18nVariable.from_locale(locale) %> + <%= f.text_field locale, :class=>'post-title' %> + + <% end %> + <% end %> +
    + +
    + <%= f.label :url %> + <%= f.text_field :url %> +
    + +
    + <%= f.label :describe %> + <%= f.fields_for :context, (@web_link.new_record? ? @web_link.build_context : @web_link.context ) do |f| %> + <% @site_valid_locales.each do |locale| %> + + <%= I18nVariable.from_locale(locale) %> + <%= f.text_area locale, :style=>"width:100%" %> + + <% end %> + <% end %> +
    + +
    + + + + +
    + <%= f.submit 'Submit/', :class=>'btn btn-primary' %>
    \ No newline at end of file diff --git a/vendor/built_in_modules/web_resource/app/views/panel/web_resource/back_end/web_links/_web_links.html.erb b/vendor/built_in_modules/web_resource/app/views/panel/web_resource/back_end/web_links/_web_links.html.erb index d87b59d8..c58f15e4 100644 --- a/vendor/built_in_modules/web_resource/app/views/panel/web_resource/back_end/web_links/_web_links.html.erb +++ b/vendor/built_in_modules/web_resource/app/views/panel/web_resource/back_end/web_links/_web_links.html.erb @@ -1,5 +1,5 @@ - + <% if post.is_top? %> <%= t(:top) %> @@ -10,6 +10,12 @@ <% if post.is_hidden? %> <%= t(:hidden) %> <% end %> +
    + +
    <%= post.web_link_category.i18n_variable[I18n.locale] %> @@ -20,12 +26,5 @@ <%= tag[I18n.locale] %> <% end %> - - <%= link_to t('web_link.edit'), edit_panel_web_resource_back_end_web_link_path(post) %> | - - <%= link_to t(:set_top), eval("panel_web_resource_back_end_web_link_path(post, :authenticity_token => form_authenticity_token, :web_link => {:is_top => true})"), :remote => true, :method => :put, :id => "disable_#{post.id}", :style => "display:#{post.is_top? ? 'none' : ''}", :class => 'switch' %> - <%= link_to t(:cancel_top), eval("panel_web_resource_back_end_web_link_path(post, :authenticity_token => form_authenticity_token, :web_link => {:is_top => false})"), :remote => true, :method => :put, :id => "enable_#{post.id}", :style => "display:#{post.is_top? ? '' : 'none'}", :class => 'switch' %> - - | <%= link_to t('web_link.delete'), panel_web_resource_back_end_web_link_path(post), :confirm => t('sure?'), :method => :delete, :remote => true %> - + diff --git a/vendor/built_in_modules/web_resource/app/views/panel/web_resource/back_end/web_links/index.html.erb b/vendor/built_in_modules/web_resource/app/views/panel/web_resource/back_end/web_links/index.html.erb index 82afe4ea..301c1bbe 100644 --- a/vendor/built_in_modules/web_resource/app/views/panel/web_resource/back_end/web_links/index.html.erb +++ b/vendor/built_in_modules/web_resource/app/views/panel/web_resource/back_end/web_links/index.html.erb @@ -1,52 +1,21 @@ -<% content_for :secondary do %> -
    -
    -
    -
    -
    -
      -
    • <%= link_to t('web_link.new_link'), new_panel_web_resource_back_end_web_link_path %>
    • -
    • <%= link_to t('web_link.link_list'), panel_web_resource_back_end_web_links_path %>
    • -
    • <%= link_to t('web_link.new_link_class'), panel_web_resource_back_end_web_link_categorys_path %>
    • -
    -<% end -%> <%= flash_messages %> -
    -
    -
    -
    -
    - - <%= form_for :web_link, :action => 'search', :method => 'get', :url => panel_web_resource_back_end_web_links_path do |f| %> - - <%#= f.select :web_link_category_id, @web_link_categorys.collect {|t| [ t.i18n_variable[I18n.locale], t.id ] },{ :include_blank => t('web_link.select') }%> - - Category <%= select_tag "category_id", options_for_select(@web_link_categorys.collect{|t| [t.i18n_variable[I18n.locale], t.id]}), :prompt => t('web_link.select') %> - - <%= submit_tag "OK", :name => nil %> - - <% end %> - -
    -
    - -

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

    - - - - - - - - - +
    <%= t('web_link.status') %><%= t('web_link.category') %><%= t('web_link.name') %><%= t('web_link.tags') %><%= t('web_link.action') %>
    + + + + + + + + + <% @web_links.each do |post| %> <%= render :partial => 'web_links', :locals => {:post => post} %> - <% end %> -
    <%= t('web_link.status') %><%= t('web_link.category') %><%= t('web_link.name') %><%= t('web_link.tags') %>
    - -
    + <% end %> + + + From f4fda08e865b1672d5bb4284e32cafdce527f014 Mon Sep 17 00:00:00 2001 From: Christophe Vilayphiou Date: Mon, 5 Mar 2012 16:19:08 +0800 Subject: [PATCH 013/125] Replace PrototypeR4 by Orbit. Move session into mongoid_store. Reset session when sing_in. --- Gemfile | 3 ++ Gemfile.lock | 32 +++++++++++++++++++ Rakefile | 2 +- app/controllers/admin/sessions_controller.rb | 8 +++++ app/models/session.rb | 12 +++++++ config.ru | 2 +- config/application.rb | 3 +- config/environment.rb | 2 +- config/environments/development.rb | 2 +- config/environments/production.rb | 2 +- config/environments/test.rb | 2 +- .../cookie_verification_secret.rb | 2 +- config/initializers/secret_token.rb | 2 +- config/initializers/session_store.rb | 7 +--- config/routes.rb | 2 +- .../config/initializers/app_config.rb | 4 +-- 16 files changed, 69 insertions(+), 18 deletions(-) create mode 100644 app/controllers/admin/sessions_controller.rb create mode 100644 app/models/session.rb diff --git a/Gemfile b/Gemfile index eb1f5434..cd8c36f9 100644 --- a/Gemfile +++ b/Gemfile @@ -1,6 +1,8 @@ source 'http://rubygems.org' gem 'rails', '>=3.1.0', '<3.2.0' +gem "brakeman" + gem 'bson_ext' gem 'carrierwave' gem 'carrierwave-mongoid', :require => 'carrierwave/mongoid' @@ -13,6 +15,7 @@ gem 'kaminari', :git => 'git://github.com/amatsuda/kaminari.git' gem 'mini_magick' gem 'mongoid' +gem "mongo_session_store-rails3" gem 'radius' gem 'rake' gem 'ruby-debug19' diff --git a/Gemfile.lock b/Gemfile.lock index 8889b1d5..b1ab1679 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -42,6 +42,14 @@ GEM arel (2.2.1) bcrypt-ruby (3.0.1) bcrypt-ruby (3.0.1-x86-mingw32) + brakeman (1.5.0) + activesupport + erubis (~> 2.6) + haml (~> 3.0) + i18n + ruby2ruby (~> 1.2) + ruport (~> 1.6) + sass (~> 3.0) bson (1.5.2) bson_ext (1.5.2) bson (= 1.5.2) @@ -59,6 +67,7 @@ GEM coffee-script-source execjs coffee-script-source (1.2.0) + color (1.4.1) columnize (0.3.6) database_cleaner (0.7.1) delorean (1.2.0) @@ -78,7 +87,11 @@ GEM factory_girl_rails (1.6.0) factory_girl (~> 2.5.0) railties (>= 3.0.0) + fastercsv (1.5.4) + haml (3.1.4) hike (1.2.1) + hoe (2.15.0) + rake (~> 0.8) i18n (0.6.0) jquery-rails (1.0.19) railties (~> 3.0) @@ -96,12 +109,18 @@ GEM subexec (~> 0.2.1) mongo (1.5.2) bson (= 1.5.2) + mongo_session_store-rails3 (3.0.5) + actionpack (>= 3.0) + mongo mongoid (2.4.2) activemodel (~> 3.1) mongo (~> 1.3) tzinfo (~> 0.3.22) multi_json (1.0.4) orm_adapter (0.0.6) + pdf-writer (1.1.8) + color (>= 1.4.0) + transaction-simple (~> 1.3) polyglot (0.3.3) rack (1.3.6) rack-cache (1.1) @@ -154,15 +173,24 @@ GEM columnize (>= 0.3.1) linecache19 (>= 0.5.11) ruby-debug-base19 (>= 0.11.19) + ruby2ruby (1.3.1) + ruby_parser (~> 2.0) + sexp_processor (~> 3.0) ruby_core_source (0.1.5) archive-tar-minitar (>= 0.5.2) + ruby_parser (2.3.1) + sexp_processor (~> 3.0) rubyzip (0.9.5) + ruport (1.6.3) + fastercsv + pdf-writer (= 1.1.8) sass (3.1.12) sass-rails (3.1.5) actionpack (~> 3.1.0) railties (~> 3.1.0) sass (~> 3.1.10) tilt (~> 1.3.2) + sexp_processor (3.1.0) shoulda-matchers (1.0.0) simplecov (0.5.4) multi_json (~> 1.0.3) @@ -186,6 +214,8 @@ GEM tilt (1.3.3) tinymce-rails (3.4.8) railties (>= 3.1) + transaction-simple (1.4.0) + hoe (>= 1.1.7) treetop (1.4.10) polyglot polyglot (>= 0.3.1) @@ -210,6 +240,7 @@ PLATFORMS x86-mingw32 DEPENDENCIES + brakeman bson_ext carrierwave carrierwave-mongoid @@ -223,6 +254,7 @@ DEPENDENCIES jquery-rails kaminari! mini_magick + mongo_session_store-rails3 mongoid radius rails (>= 3.1.0, < 3.2.0) diff --git a/Rakefile b/Rakefile index 2036d04c..9a495de7 100644 --- a/Rakefile +++ b/Rakefile @@ -5,4 +5,4 @@ require File.expand_path('../config/application', __FILE__) require 'rake/dsl_definition' require 'rake' -PrototypeR4::Application.load_tasks +Orbit::Application.load_tasks diff --git a/app/controllers/admin/sessions_controller.rb b/app/controllers/admin/sessions_controller.rb new file mode 100644 index 00000000..00649580 --- /dev/null +++ b/app/controllers/admin/sessions_controller.rb @@ -0,0 +1,8 @@ +class SessionsController < Devise::SessionsController + + def create + super + reset_session + end + +end \ No newline at end of file diff --git a/app/models/session.rb b/app/models/session.rb new file mode 100644 index 00000000..3c6deb54 --- /dev/null +++ b/app/models/session.rb @@ -0,0 +1,12 @@ +class Session + include Mongoid::Document + include Mongoid::Timestamps + + def self.sweep(time = 1.hour) + if time.is_a?(String) + time = time.split.inject { |count, unit| count.to_i.send(unit) } + end + + delete_all "updated_at < '#{time.ago.to_s(:db)}' OR created_at < '#{2.days.ago.to_s(:db)}'" + end +end \ No newline at end of file diff --git a/config.ru b/config.ru index 20d6bd1f..6a593e4a 100644 --- a/config.ru +++ b/config.ru @@ -1,4 +1,4 @@ # This file is used by Rack-based servers to start the application. require ::File.expand_path('../config/environment', __FILE__) -run PrototypeR4::Application +run Orbit::Application diff --git a/config/application.rb b/config/application.rb index 50b9f4a7..d1243133 100644 --- a/config/application.rb +++ b/config/application.rb @@ -13,12 +13,13 @@ require 'sprockets/railtie' # or test environments. Bundler.require *Rails.groups(:assets) if defined?(Bundler) -module PrototypeR4 +module Orbit class Application < Rails::Application # Add directories for plugins config.paths["vendor/plugins"] += %W(#{config.root}/vendor/built_in_modules) config.paths["vendor/plugins"] += %W(#{config.root}/vendor/downloaded_modules) + config.paths.app.views << "app/views/devise" # Settings in config/environments/* take precedence over those specified here. diff --git a/config/environment.rb b/config/environment.rb index efd38a40..3538bc87 100644 --- a/config/environment.rb +++ b/config/environment.rb @@ -4,4 +4,4 @@ require 'yaml' YAML::ENGINE.yamler = 'syck' # Initialize the rails application -PrototypeR4::Application.initialize! +Orbit::Application.initialize! diff --git a/config/environments/development.rb b/config/environments/development.rb index c2b4c930..1dbff032 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -1,4 +1,4 @@ -PrototypeR4::Application.configure do +Orbit::Application.configure do # Settings specified here will take precedence over those in config/application.rb # In the development environment your application's code is reloaded on diff --git a/config/environments/production.rb b/config/environments/production.rb index f52ead13..001ff2c6 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -1,4 +1,4 @@ -PrototypeR4::Application.configure do +Orbit::Application.configure do # Settings specified here will take precedence over those in config/application.rb # The production environment is meant for finished, "live" apps. diff --git a/config/environments/test.rb b/config/environments/test.rb index 6d22bb12..e55cc24b 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -1,4 +1,4 @@ -PrototypeR4::Application.configure do +Orbit::Application.configure do # Settings specified here will take precedence over those in config/application.rb # The test environment is used exclusively to run your application's diff --git a/config/initializers/cookie_verification_secret.rb b/config/initializers/cookie_verification_secret.rb index 5a8601a7..694e666d 100644 --- a/config/initializers/cookie_verification_secret.rb +++ b/config/initializers/cookie_verification_secret.rb @@ -4,4 +4,4 @@ # If you change this key, all old signed cookies will become invalid! # Make sure the secret is at least 30 characters and all random, # no regular words or you'll be exposed to dictionary attacks. -PrototypeR4::Application.config.secret_token = 'cbf6409102b30cb9f4da455ee08c3a7e9d8b2a3d32a0e5b59a354dad03f469d363a8127ef4b7bc3b1afa632d7cf947a1e59e09022d2d4cd8df1f4fa521d7ec07' +Orbit::Application.config.secret_token = 'cbf6409102b30cb9f4da455ee08c3a7e9d8b2a3d32a0e5b59a354dad03f469d363a8127ef4b7bc3b1afa632d7cf947a1e59e09022d2d4cd8df1f4fa521d7ec07' diff --git a/config/initializers/secret_token.rb b/config/initializers/secret_token.rb index 67abf723..ae9a444a 100644 --- a/config/initializers/secret_token.rb +++ b/config/initializers/secret_token.rb @@ -4,4 +4,4 @@ # If you change this key, all old signed cookies will become invalid! # Make sure the secret is at least 30 characters and all random, # no regular words or you'll be exposed to dictionary attacks. -PrototypeR4::Application.config.secret_token = 'b8d78ecaf3086ebfc1ba42e912acba60d85cf3d789d933e117770e1a045a12911f121ff012a234982abb446c8b8c768052eea4bf8b2d5d336be821e2c25d8cdb' +Orbit::Application.config.secret_token = 'b8d78ecaf3086ebfc1ba42e912acba60d85cf3d789d933e117770e1a045a12911f121ff012a234982abb446c8b8c768052eea4bf8b2d5d336be821e2c25d8cdb' diff --git a/config/initializers/session_store.rb b/config/initializers/session_store.rb index e6387adb..b1a4a2c1 100644 --- a/config/initializers/session_store.rb +++ b/config/initializers/session_store.rb @@ -1,8 +1,3 @@ # Be sure to restart your server when you modify this file. -PrototypeR4::Application.config.session_store :cookie_store, :key => '_prototype_R4_session' - -# Use the database for sessions instead of the cookie-based default, -# which shouldn't be used to store highly confidential information -# (create the session table with "rails generate session_migration") -# PrototypeR4::Application.config.session_store :active_record_store +Orbit::Application.config.session_store :mongoid_store diff --git a/config/routes.rb b/config/routes.rb index cd3921f0..112d96e1 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,4 +1,4 @@ -PrototypeR4::Application.routes.draw do +Orbit::Application.routes.draw do devise_for :users diff --git a/vendor/built_in_modules/new_blog/config/initializers/app_config.rb b/vendor/built_in_modules/new_blog/config/initializers/app_config.rb index c098b837..0e9f56e7 100644 --- a/vendor/built_in_modules/new_blog/config/initializers/app_config.rb +++ b/vendor/built_in_modules/new_blog/config/initializers/app_config.rb @@ -3,7 +3,7 @@ # # Add a load path for this specific Engine # # config.autoload_paths << File.expand_path("../lib/some/path", __FILE__) # put "ABC" -# PrototypeR4::Application::Orbit_Apps << "NewBlog" +# Orbit::Application::Orbit_Apps << "NewBlog" # # # initializer "my_engine.add_middleware" do |app| # # app.middleware.use MyEngine::Middleware @@ -15,4 +15,4 @@ module NewBlog VERSION = "0.0.1" MOUDLEAPP_TITLE = "NewBlog" end -# PrototypeR4::Application::Orbit_Apps << "NewBlog" \ No newline at end of file +# Orbit::Application::Orbit_Apps << "NewBlog" \ No newline at end of file From 29ec36130e660318f8fbc86208e5952011413aac Mon Sep 17 00:00:00 2001 From: Christophe Vilayphiou Date: Fri, 16 Mar 2012 15:06:45 +0800 Subject: [PATCH 014/125] css and js changes --- app/assets/javascripts/orbit-1.0.js | 9 +- app/assets/stylesheets/site_items.css.erb | 963 +++++++++++----------- 2 files changed, 488 insertions(+), 484 deletions(-) diff --git a/app/assets/javascripts/orbit-1.0.js b/app/assets/javascripts/orbit-1.0.js index efb7042e..f8daaecd 100644 --- a/app/assets/javascripts/orbit-1.0.js +++ b/app/assets/javascripts/orbit-1.0.js @@ -52,12 +52,15 @@ $(document).ready(function(){ /*tinyscrollbar&windows-Size*/ resize(); - $('#main-sidebar').css("height", viewportheight-40); - $('#main-sidebar .viewport').css("height", viewportheight-40); + var $mainWrapMarginLeft = parseInt($('#main-wrap').css("margin-left"))-2; + $('#main-sidebar').css("height", viewportheight-30); + $('#main-sidebar .viewport').css("height", viewportheight-30); $('.post-title').css("width", viewportwidth-495); + $('#main-wrap > .subnav').css("width", viewportwidth-$mainWrapMarginLeft) $('#main-sidebar').tinyscrollbar(); $('.detal-list').tinyscrollbar(); - $('#main-sidebar').tinyscrollbar({size:(viewportheight-44)}); + $('#main-sidebar').tinyscrollbar({size:(viewportheight-34)}); + mainTablePosition() /*isotope*/ var $container = $('#isotope'); diff --git a/app/assets/stylesheets/site_items.css.erb b/app/assets/stylesheets/site_items.css.erb index 38b0a185..4e23bd4c 100644 --- a/app/assets/stylesheets/site_items.css.erb +++ b/app/assets/stylesheets/site_items.css.erb @@ -1,482 +1,483 @@ -html, body{ - height: 100%; - margin: 0; - padding: 0; -} -html{ - background: url(<%= asset_path "body.jpg" %>) no-repeat fixed 0 0 transparent; - background-size: cover; -} - -body{ - color: #000000; - font-family: Helvetica, '敺株甇暺擃'; -} -#back_banner_link{ - background:-webkit-gradient( linear, left top, left bottom, color-stop(0, #787e82), color-stop(0.05, #61676c), color-stop(1, #292c2d) ); - background:-moz-linear-gradient( center top -90deg, #787e82 0%, #61676c 5%, #292c2d 100% ); - filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#61676c', endColorstr='#292c2d'); - -moz-box-shadow: 0px 1px 5px 0px rgba(0,0,0,.7); - -webkit-box-shadow: 0px 1px 5px 0px rgba(0,0,0,.7); - box-shadow: 0px 1px 5px 0px rgba(0,0,0,.7); - border-top: 1px solid #474a4c; - border-bottom: 1px solid #1d2020; - height: 41px; - width: 100%; - behavior: url(<%= asset_path "PIE.htc" %>); -} -.hmenu{ - float: right; - height: 41px; -} -#back_orbit{ - background:-webkit-gradient( linear, left top, left bottom, color-stop(0, #70787d), color-stop(1, #3b4043) ); - background:-moz-linear-gradient( center top -90deg, #70787d 0%, #3b4043 100% ); - filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#70787d', endColorstr='#3b4043'); - -webkit-border-radius: 0px 0px 5px 5px; - -moz-border-radius: 0px 0px 5px 5px; - border-radius: 0px 0px 5px 5px; - -moz-box-shadow: 0px 1px 1px 0px rgba(0,0,0,.7); - -webkit-box-shadow: 0px 1px 1px 0px rgba(0,0,0,.7); - box-shadow: 0px 1px 1px 0px rgba(0,0,0,.7); - cursor: pointer; - float: left; - height: 43px; - margin-left: 10px; - width: 41px; - behavior: url(<%= asset_path "PIE.htc" %>); -} -#back_orbit span{ - text-indent: -9999px; - background: url(<%= asset_path "bar_orbit.png" %>) no-repeat scroll 0 0 transparent; - display: block; - height: 43px; - width: 100%; -} -#back_orbit:hover{ - background:-webkit-gradient( linear, left top, left bottom, color-stop(0, #fefefe), color-stop(1, #e4e4e4) ); - background:-moz-linear-gradient( center top -90deg, #fefefe 0%, #e4e4e4 100% ); - filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#fefefe', endColorstr='#e4e4e4'); - -webkit-border-radius: 0px; - -moz-border-radius: 0px; - border-radius: 0px; -} -#back_orbit:hover span{ - background-position: 0 -44px; -} -#back_orbit:hover #orblist{ - display:block; -} -#orblist{ - background:-webkit-gradient( linear, left top, left bottom, color-stop(0, #e4e4e4), color-stop(1, #FFFFFF) ); - background:-moz-linear-gradient( center top -90deg, #e4e4e4 0%, #FFFFFF 100% ); - filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#e4e4e4', endColorstr='#FFFFFF'); - -webkit-border-radius: 0px 3px 3px 3px; - -moz-border-radius: 0px 3px 3px 3px; - border-radius: 0px 3px 3px 3px; - -webkit-box-shadow: 0 3px 3px #000000; - -moz-box-shadow: 0 3px 3px #000000; - box-shadow: 0 3px 3px #000000; - display: none; - margin: 0; - padding: 10px; - position: absolute; - top: 43px; - width: 130px; -} -#orblist li{ - border-bottom:1px solid #aaa; - list-style:none; -} -.orblink{ - color: #333333; - display: block; - font: 12px/100% arial,sans-serif; - padding: 5px; - text-decoration: none; -} -.orblink:hover{ - background:#eee; - color:#333; -} -#log_out{ - -moz-box-shadow:inset 1px 0px 0px 0px #73777b; - -webkit-box-shadow:inset 1px 0px 0px 0px #73777b; - box-shadow:inset 1px 0px 0px 0px #73777b; - border-right:1px solid #41474c; - border-left:1px solid #41474c; - float:right; - width:41px; - height:41px; -} -#log_out:hover{ - background:-webkit-gradient( linear, left top, left bottom, color-stop(0, #01afde), color-stop(1, #007ec6) ); - background:-moz-linear-gradient( center top -90deg, #01afde 0%, #007ec6 100% ); - filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#01afde', endColorstr='#007ec6'); -} -#log_out a{ - background: url(<%= asset_path "service_btn.png" %>) no-repeat scroll right 0 transparent; - display: block; - height: 41px; - text-indent: -9999px; - width: 41px; -} -#log_out a:hover{ - background: url(<%= asset_path "service_btn.png" %>) no-repeat scroll right bottom transparent !important; -} -.lang{ - color: #FFFFFF; - float: right; - font-size: 15px; - line-height: 40px; - margin-right: 10px; -} -.lang a{ - color:#fff; - text-decoration:none; -} -.lang a:hover{ - text-decoration:underline; -} -#back_content{ - height: 100%; -} -#back_footer{ - background-color: #101010; - bottom: 0; - color: #FFFFFF; - font-size: 11px; - padding: 10px; - position: fixed; - width: 100%; - left: 0; - box-shadow: 0 -3px 4px #000; -} -.items_setup{ - padding:42px 0 0 0; -} -#back_sidebar .items_setup .list li{ - padding: 6px 0 7px 5px; -} -#back_sidebar .items_setup .list li a{ - display: inline; - font-size: 0.9em; - padding: 0; -} -#back_sidebar .items_setup .list li a span{ - background:none; - padding:0; - text-shadow:none; -} -.main { - background: none repeat scroll 0 0 #FFFFFF; - height: 100%; - margin-left: 220px; - padding: 0 40px; - position: relative; -} -.main_list { - padding-top: 70px; -} -.main_list ul { - clear:both; -} -#porfile { - padding-top: 100px; -} -/*add_buttom*/ -.button_bar { - float: right; - -moz-box-shadow:inset 0px 1px 0px 0px #666, 0px 0px 3px black; - -webkit-box-shadow:inset 0px 1px 0px 0px #666, 0px 0px 3px black; - box-shadow:inset 0px 1px 0px 0px #666, 0px 0px 3px black; - background:-webkit-gradient( linear, left top, left bottom, color-stop(0.05, #4f4f4f), color-stop(1, #000000) ); - background:-moz-linear-gradient( center top, #4f4f4f 5%, #000000 100% ); - filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#4f4f4f', endColorstr='#000000'); - background-color:#4f4f4f; - -moz-border-radius:5px; - -webkit-border-radius:5px; - border-radius:5px; - display:inline-block; - padding:0; - margin:10px 0 60px; -} -.button_bar a { - text-decoration:none; - text-shadow:0px -1px 0px #000000; - font-size:12px; - color:#EDEDED; - border-right:1px solid #555; - -moz-box-shadow:1px 0px 0px black; - -webkit-box-shadow:1px 0px 0px black; - box-shadow:1px 0px 0px black; - padding: 6px 10px 4px; - display: inline-block; - float: left; -} -.button_bar a:active { - padding: 7px 10px 3px !important; - text-shadow:0px 1px 0px #000000; - background:-webkit-gradient( linear, left top, left bottom, color-stop(0.05, #000000), color-stop(1, #4f4f4f) ); - background:-moz-linear-gradient( center top, #000000 5%, #4f4f4f 100% ); - filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#000000', endColorstr='#4f4f4f'); -} -.button_bar a:last-child { - border-right:none; - -moz-box-shadow:none; - -webkit-box-shadow:none; - box-shadow:none; - -moz-border-radius:0px 5px 5px 0px; - -webkit-border-radius:0px 5px 5px 0px; - border-radius:0px 5px 5px 0px; -} -.button_bar a:first-child { - -moz-border-radius:5px 0px 0px 5px; - -webkit-border-radius:5px 0px 0px 5px; - border-radius:5px 0px 0px 5px; -} -.button_bar a.new { - padding: 5px 10px; - -moz-border-radius:5px; - -webkit-border-radius:5px; - border-radius:5px; -} -.button_bar a:hover { - color:#FFFFFF; -} -.up { - margin:10px 0; -} -#person { - left: 245px; - position: fixed; - text-align: center; - top: 75px; - width: 140px; - background-color:#FFF; - padding:15px; - border-radius: 5px; - -moz-border-radius: 5px; - -webkit-border-radius: 5px; - -moz-box-shadow: 0px 0px 4px #180902; /* Firefox */ - -webkit-box-shadow: 0px 0px 4px #180902;/* Safari Chrome */ - box-shadow: 0px 0px 4px #180902; /* Opera 10.5 + */ -} -#file { - display:none; -} -#person img { -} -.user_mail { - border: medium none; - border:1px solid #DDDDDD; - color: #666666; - font-size: 12px; - width: 140px; -} -#person label { - display: block; - margin: 15px 0 0; -} -#person label input { -} -#person label #user_admin { - float:right; - margin: 0; -} -#person label span { - text-align:left; - font-size:11px; - color:#888; - display:block; -} -#person select { - border: 1px solid #DDDDDD; - padding: 0; - width: 140px; -} -#porfile .users{ - margin-left: 180px; -} -.roles_block { - background: url(<%= asset_path "75.png" %>) repeat left top; - min-width:710px; - margin-bottom:50px; - position:relative; - padding-bottom: 20px; - border-radius: 5px; - -moz-border-radius: 5px; - -webkit-border-radius: 5px; - -moz-box-shadow: 0px 0px 4px #180902; /* Firefox */ - -webkit-box-shadow: 0px 0px 4px #180902;/* Safari Chrome */ - box-shadow: 0px 0px 4px #180902; /* Opera 10.5 + */ -} -.roles_block h2 { - color: #FFFFFF; - font-weight: normal; - margin: 0; - padding: 0; - position: absolute; - text-shadow: 0 3px 2px #000000; - top: -30px; -} -.main hr { - height:8px; - border:none; - margin:0; - border-radius: 5px 5px 0px 0px; - -moz-border-radius: 5px 5px 0px 0px; - -webkit-border-radius: 5px 5px 0px 0px; - border-bottom:1px solid #000; -} -.main2{ - padding:70px 0 0; -} -#basic_block hr { - background-color: #666666; -} -#teacher_block hr { - background-color: #0071A9; -} -#student_block hr { - background-color: #AF0045; -} -.info_input { - padding:10px 20px; -} -.info_input table { - color:#fff; - width:100%; - font-size:14px; -} -.info_input table td { - padding:5px 10px 5px 0; - width: 10%; -} -.info_input .list_head { - background:url(<%= asset_path "line.png" %>) left bottom repeat-x; -} -.info_input .list_head td { -} -.info_input .list_item { - color:#AEAEAE; -} -.info_input .add { - display:block; - padding-left:22px; - font-size:12px; - line-height:21px; - height:19px; - background:url(<%= asset_path "icon.png" %>) no-repeat -59px 0; - margin-top: 10px; - color: #DDDDDD; -} - -.main table { - width:100%; -} -.main td { - padding-left:20px; - color:#fff; - font-size:14px; - line-height:40px; -} -.main tr.have td{ - background: url(<%= asset_path "75.png" %>) repeat left top; -} -.main tr.have td:first-child{ - border-radius: 5px 0 0 5px; - -moz-border-radius: 5px 0 0 5px; - -webkit-border-radius: 5px 0 0 5px; -} -.main tr.have td:last-child{ - border-radius: 0 5px 5px 0; - -moz-border-radius: 0 5px 5px 0; - -webkit-border-radius: 0 5px 5px 0; -} -.main thead td { - line-height:40px; - font-size:16px; - text-shadow: 0px 1px 1px #3e2914; -} -.main thead td.action { - width:140px; -} -.main tbody td.roles { - background-image: url(<%= asset_path "roles_type.jpg" %>); - background-repeat: repeat-x; -} -.main tbody td.teacher { - background-position: 0 -54px; -} -.main tbody td.student { - background-position: 0 -5px; -} -.main tbody td.action a { - background-image: url(<%= asset_path "icon.png" %>); - display: inline-block; - height: 19px; - margin-right: 10px; - top: 8px; - text-indent: -9999px; - width: 19px; - position: relative; -} -.main tbody td.action a.show { - background-position: left top; -} -.main tbody td.action a.show:hover { - background-position: left -19px; -} -.main tbody td.action a.edit { - background-position: -19px top; -} -.main tbody td.action a.edit:hover { - background-position: -19px -19px; -} -.main tbody td.action a.delete { - background-position: -38px top; -} -.main tbody td.action a.delete:hover { - background-position: -38px -19px; -} -.main tbody td.action a.switch { - background: url(<%= asset_path "switch.png" %>) no-repeat left 3px; - width: 40px; -} -.main tbody tr.disable td.action a.switch { - background-position:left bottom; -} -.main tbody td.action a.delete:hover { - background-position: -38px -19px; -} -.main tbody tr.have { -} -.main tbody tr.disable { - opacity: 0.7; -} -.main tbody tr { - background:none; - height:15px; -} -h1{ - margin:0 0 20px; -} -p{ - margin:0 0 10px; -} - -#back_sidebar .items_setup .list li{ - background:url(<%= asset_path "sidebar_li2.jpg" %>) repeat left top; - border:none; - padding: 0 0 0 5px; -} -#back_sidebar .items_setup .list li a{ - line-height:31px; -} -#back_sidebar .items_setup .list li:hover{ - background:url(<%= asset_path "sidebar_li2.jpg" %>) repeat left top; - border:none; -} -#back_sidebar .items_setup ul .list { +html, body{ + height: 100%; + margin: 0; + padding: 0; +} +html{ + background: url(<%= asset_path "body.jpg" %>) no-repeat fixed 0 0 transparent; + background-size: cover; +} + +body{ + color: #000000; + font-family: Helvetica, '敺株甇暺擃'; +} +#back_banner_link{ + background:-webkit-gradient( linear, left top, left bottom, color-stop(0, #787e82), color-stop(0.05, #61676c), color-stop(1, #292c2d) ); + background:-moz-linear-gradient( center top -90deg, #787e82 0%, #61676c 5%, #292c2d 100% ); + filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#61676c', endColorstr='#292c2d'); + -moz-box-shadow: 0px 1px 5px 0px rgba(0,0,0,.7); + -webkit-box-shadow: 0px 1px 5px 0px rgba(0,0,0,.7); + box-shadow: 0px 1px 5px 0px rgba(0,0,0,.7); + border-top: 1px solid #474a4c; + border-bottom: 1px solid #1d2020; + height: 41px; + width: 100%; + behavior: url(<%= asset_path "PIE.htc" %>); +} +.hmenu{ + float: right; + height: 41px; +} +#back_orbit{ + background:-webkit-gradient( linear, left top, left bottom, color-stop(0, #70787d), color-stop(1, #3b4043) ); + background:-moz-linear-gradient( center top -90deg, #70787d 0%, #3b4043 100% ); + filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#70787d', endColorstr='#3b4043'); + -webkit-border-radius: 0px 0px 5px 5px; + -moz-border-radius: 0px 0px 5px 5px; + border-radius: 0px 0px 5px 5px; + -moz-box-shadow: 0px 1px 1px 0px rgba(0,0,0,.7); + -webkit-box-shadow: 0px 1px 1px 0px rgba(0,0,0,.7); + box-shadow: 0px 1px 1px 0px rgba(0,0,0,.7); + cursor: pointer; + float: left; + height: 43px; + margin-left: 10px; + width: 41px; + behavior: url(<%= asset_path "PIE.htc" %>); +} +#back_orbit span{ + text-indent: -9999px; + background: url(<%= asset_path "bar_orbit.png" %>) no-repeat scroll 0 0 transparent; + display: block; + height: 43px; + width: 100%; +} +#back_orbit:hover{ + background:-webkit-gradient( linear, left top, left bottom, color-stop(0, #fefefe), color-stop(1, #e4e4e4) ); + background:-moz-linear-gradient( center top -90deg, #fefefe 0%, #e4e4e4 100% ); + filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#fefefe', endColorstr='#e4e4e4'); + -webkit-border-radius: 0px; + -moz-border-radius: 0px; + border-radius: 0px; +} +#back_orbit:hover span{ + background-position: 0 -44px; +} +#back_orbit:hover #orblist{ + display:block; +} +#orblist{ + background:-webkit-gradient( linear, left top, left bottom, color-stop(0, #e4e4e4), color-stop(1, #FFFFFF) ); + background:-moz-linear-gradient( center top -90deg, #e4e4e4 0%, #FFFFFF 100% ); + filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#e4e4e4', endColorstr='#FFFFFF'); + -webkit-border-radius: 0px 3px 3px 3px; + -moz-border-radius: 0px 3px 3px 3px; + border-radius: 0px 3px 3px 3px; + -webkit-box-shadow: 0 3px 3px #000000; + -moz-box-shadow: 0 3px 3px #000000; + box-shadow: 0 3px 3px #000000; + display: none; + margin: 0; + padding: 10px; + position: absolute; + top: 43px; + width: 130px; +} +#orblist li{ + border-bottom:1px solid #aaa; + list-style:none; +} +.orblink{ + color: #333333; + display: block; + font: 12px/100% arial,sans-serif; + padding: 5px; + text-decoration: none; +} +.orblink:hover{ + background:#eee; + color:#333; +} +#log_out{ + -moz-box-shadow:inset 1px 0px 0px 0px #73777b; + -webkit-box-shadow:inset 1px 0px 0px 0px #73777b; + box-shadow:inset 1px 0px 0px 0px #73777b; + border-right:1px solid #41474c; + border-left:1px solid #41474c; + float:right; + width:41px; + height:41px; +} +#log_out:hover{ + background:-webkit-gradient( linear, left top, left bottom, color-stop(0, #01afde), color-stop(1, #007ec6) ); + background:-moz-linear-gradient( center top -90deg, #01afde 0%, #007ec6 100% ); + filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#01afde', endColorstr='#007ec6'); +} +#log_out a{ + background: url(<%= asset_path "service_btn.png" %>) no-repeat scroll right 0 transparent; + display: block; + height: 41px; + text-indent: -9999px; + width: 41px; +} +#log_out a:hover{ + background: url(<%= asset_path "service_btn.png" %>) no-repeat scroll right bottom transparent !important; +} +.lang{ + color: #FFFFFF; + float: right; + font-size: 15px; + line-height: 40px; + margin-right: 10px; +} +.lang a{ + color:#fff; + text-decoration:none; +} +.lang a:hover{ + text-decoration:underline; +} +#back_content{ + height: 100%; +} +#back_footer{ + background-color: #101010; + bottom: 0; + color: #FFFFFF; + display:none; + font-size: 11px; + padding: 10px; + position: fixed; + width: 100%; + left: 0; + box-shadow: 0 -3px 4px #000; +} +.items_setup{ + padding:42px 0 0 0; +} +#back_sidebar .items_setup .list li{ + padding: 6px 0 7px 5px; +} +#back_sidebar .items_setup .list li a{ + display: inline; + font-size: 0.9em; + padding: 0; +} +#back_sidebar .items_setup .list li a span{ + background:none; + padding:0; + text-shadow:none; +} +.main { + background: none repeat scroll 0 0 #FFFFFF; + height: 100%; + margin-left: 220px; + padding: 0 40px; + position: relative; +} +.main_list { + padding-top: 70px; +} +.main_list ul { + clear:both; +} +#porfile { + padding-top: 100px; +} +/*add_buttom*/ +.button_bar { + float: right; + -moz-box-shadow:inset 0px 1px 0px 0px #666, 0px 0px 3px black; + -webkit-box-shadow:inset 0px 1px 0px 0px #666, 0px 0px 3px black; + box-shadow:inset 0px 1px 0px 0px #666, 0px 0px 3px black; + background:-webkit-gradient( linear, left top, left bottom, color-stop(0.05, #4f4f4f), color-stop(1, #000000) ); + background:-moz-linear-gradient( center top, #4f4f4f 5%, #000000 100% ); + filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#4f4f4f', endColorstr='#000000'); + background-color:#4f4f4f; + -moz-border-radius:5px; + -webkit-border-radius:5px; + border-radius:5px; + display:inline-block; + padding:0; + margin:10px 0 60px; +} +.button_bar a { + text-decoration:none; + text-shadow:0px -1px 0px #000000; + font-size:12px; + color:#EDEDED; + border-right:1px solid #555; + -moz-box-shadow:1px 0px 0px black; + -webkit-box-shadow:1px 0px 0px black; + box-shadow:1px 0px 0px black; + padding: 6px 10px 4px; + display: inline-block; + float: left; +} +.button_bar a:active { + padding: 7px 10px 3px !important; + text-shadow:0px 1px 0px #000000; + background:-webkit-gradient( linear, left top, left bottom, color-stop(0.05, #000000), color-stop(1, #4f4f4f) ); + background:-moz-linear-gradient( center top, #000000 5%, #4f4f4f 100% ); + filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#000000', endColorstr='#4f4f4f'); +} +.button_bar a:last-child { + border-right:none; + -moz-box-shadow:none; + -webkit-box-shadow:none; + box-shadow:none; + -moz-border-radius:0px 5px 5px 0px; + -webkit-border-radius:0px 5px 5px 0px; + border-radius:0px 5px 5px 0px; +} +.button_bar a:first-child { + -moz-border-radius:5px 0px 0px 5px; + -webkit-border-radius:5px 0px 0px 5px; + border-radius:5px 0px 0px 5px; +} +.button_bar a.new { + padding: 5px 10px; + -moz-border-radius:5px; + -webkit-border-radius:5px; + border-radius:5px; +} +.button_bar a:hover { + color:#FFFFFF; +} +.up { + margin:10px 0; +} +#person { + left: 245px; + position: fixed; + text-align: center; + top: 75px; + width: 140px; + background-color:#FFF; + padding:15px; + border-radius: 5px; + -moz-border-radius: 5px; + -webkit-border-radius: 5px; + -moz-box-shadow: 0px 0px 4px #180902; /* Firefox */ + -webkit-box-shadow: 0px 0px 4px #180902;/* Safari Chrome */ + box-shadow: 0px 0px 4px #180902; /* Opera 10.5 + */ +} +#file { + display:none; +} +#person img { +} +.user_mail { + border: medium none; + border:1px solid #DDDDDD; + color: #666666; + font-size: 12px; + width: 140px; +} +#person label { + display: block; + margin: 15px 0 0; +} +#person label input { +} +#person label #user_admin { + float:right; + margin: 0; +} +#person label span { + text-align:left; + font-size:11px; + color:#888; + display:block; +} +#person select { + border: 1px solid #DDDDDD; + padding: 0; + width: 140px; +} +#porfile .users{ + margin-left: 180px; +} +.roles_block { + background: url(<%= asset_path "75.png" %>) repeat left top; + min-width:710px; + margin-bottom:50px; + position:relative; + padding-bottom: 20px; + border-radius: 5px; + -moz-border-radius: 5px; + -webkit-border-radius: 5px; + -moz-box-shadow: 0px 0px 4px #180902; /* Firefox */ + -webkit-box-shadow: 0px 0px 4px #180902;/* Safari Chrome */ + box-shadow: 0px 0px 4px #180902; /* Opera 10.5 + */ +} +.roles_block h2 { + color: #FFFFFF; + font-weight: normal; + margin: 0; + padding: 0; + position: absolute; + text-shadow: 0 3px 2px #000000; + top: -30px; +} +.main hr { + height:8px; + border:none; + margin:0; + border-radius: 5px 5px 0px 0px; + -moz-border-radius: 5px 5px 0px 0px; + -webkit-border-radius: 5px 5px 0px 0px; + border-bottom:1px solid #000; +} +.main2{ + padding:70px 0 0; +} +#basic_block hr { + background-color: #666666; +} +#teacher_block hr { + background-color: #0071A9; +} +#student_block hr { + background-color: #AF0045; +} +.info_input { + padding:10px 20px; +} +.info_input table { + color:#fff; + width:100%; + font-size:14px; +} +.info_input table td { + padding:5px 10px 5px 0; + width: 10%; +} +.info_input .list_head { + background:url(<%= asset_path "line.png" %>) left bottom repeat-x; +} +.info_input .list_head td { +} +.info_input .list_item { + color:#AEAEAE; +} +.info_input .add { + display:block; + padding-left:22px; + font-size:12px; + line-height:21px; + height:19px; + background:url(<%= asset_path "icon.png" %>) no-repeat -59px 0; + margin-top: 10px; + color: #DDDDDD; +} + +.main table { + width:100%; +} +.main td { + padding-left:20px; + color:#fff; + font-size:14px; + line-height:40px; +} +.main tr.have td{ + background: url(<%= asset_path "75.png" %>) repeat left top; +} +.main tr.have td:first-child{ + border-radius: 5px 0 0 5px; + -moz-border-radius: 5px 0 0 5px; + -webkit-border-radius: 5px 0 0 5px; +} +.main tr.have td:last-child{ + border-radius: 0 5px 5px 0; + -moz-border-radius: 0 5px 5px 0; + -webkit-border-radius: 0 5px 5px 0; +} +.main thead td { + line-height:40px; + font-size:16px; + text-shadow: 0px 1px 1px #3e2914; +} +.main thead td.action { + width:140px; +} +.main tbody td.roles { + background-image: url(<%= asset_path "roles_type.jpg" %>); + background-repeat: repeat-x; +} +.main tbody td.teacher { + background-position: 0 -54px; +} +.main tbody td.student { + background-position: 0 -5px; +} +.main tbody td.action a { + background-image: url(<%= asset_path "icon.png" %>); + display: inline-block; + height: 19px; + margin-right: 10px; + top: 8px; + text-indent: -9999px; + width: 19px; + position: relative; +} +.main tbody td.action a.show { + background-position: left top; +} +.main tbody td.action a.show:hover { + background-position: left -19px; +} +.main tbody td.action a.edit { + background-position: -19px top; +} +.main tbody td.action a.edit:hover { + background-position: -19px -19px; +} +.main tbody td.action a.delete { + background-position: -38px top; +} +.main tbody td.action a.delete:hover { + background-position: -38px -19px; +} +.main tbody td.action a.switch { + background: url(<%= asset_path "switch.png" %>) no-repeat left 3px; + width: 40px; +} +.main tbody tr.disable td.action a.switch { + background-position:left bottom; +} +.main tbody td.action a.delete:hover { + background-position: -38px -19px; +} +.main tbody tr.have { +} +.main tbody tr.disable { + opacity: 0.7; +} +.main tbody tr { + background:none; + height:15px; +} +h1{ + margin:0 0 20px; +} +p{ + margin:0 0 10px; +} + +#back_sidebar .items_setup .list li{ + background:url(<%= asset_path "sidebar_li2.jpg" %>) repeat left top; + border:none; + padding: 0 0 0 5px; +} +#back_sidebar .items_setup .list li a{ + line-height:31px; +} +#back_sidebar .items_setup .list li:hover{ + background:url(<%= asset_path "sidebar_li2.jpg" %>) repeat left top; + border:none; +} +#back_sidebar .items_setup ul .list { } \ No newline at end of file From eb2b4b80b7b136baf526a8a81a108f090c052963 Mon Sep 17 00:00:00 2001 From: Matt Fu Date: Fri, 16 Mar 2012 15:48:13 +0800 Subject: [PATCH 015/125] add new files --- .../app/models/bulletin - %BDしs.rb | 101 ++++++++++++++++++ .../fact_checks/_list_table.html.erb.can_del | 15 +++ .../fact_checks/_privilege_user.html.erb | 7 ++ .../fact_checks/index.html.erb.can_del | 50 +++++++++ .../back_end/fact_checks/setting.html.erb | 20 ++++ .../back_end/fact_checks/setting.js.erb | 1 + .../widget/bulletins/index.html - %BDしs.erb | 42 ++++++++ 7 files changed, 236 insertions(+) create mode 100644 vendor/built_in_modules/announcement/app/models/bulletin - %BDしs.rb create mode 100644 vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/fact_checks/_list_table.html.erb.can_del create mode 100644 vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/fact_checks/_privilege_user.html.erb create mode 100644 vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/fact_checks/index.html.erb.can_del create mode 100644 vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/fact_checks/setting.html.erb create mode 100644 vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/fact_checks/setting.js.erb create mode 100644 vendor/built_in_modules/announcement/app/views/panel/announcement/widget/bulletins/index.html - %BDしs.erb diff --git a/vendor/built_in_modules/announcement/app/models/bulletin - %BDしs.rb b/vendor/built_in_modules/announcement/app/models/bulletin - %BDしs.rb new file mode 100644 index 00000000..c65e65f7 --- /dev/null +++ b/vendor/built_in_modules/announcement/app/models/bulletin - %BDしs.rb @@ -0,0 +1,101 @@ +# encoding: utf-8 + +class Bulletin + include Mongoid::Document + include Mongoid::Timestamps + include Mongoid::MultiParameterAttributes + + # field :category_id, :type => Integer + field :title + # has_one :title_variable, :class_name => "I18nVariable", :as => :language_value, :autosave => true, :dependent => :destroy + # has_one :subtitle_variable, :class_name => "I18nVariable", :as => :language_value, :autosave => true, :dependent => :destroy + # has_one :text_variable, :class_name => "I18nVariable", :as => :language_value, :autosave => true, :dependent => :destroy + field :subtitle + field :text + field :postdate , :type => Date + field :deadline , :type => Date + # field :url + field :create_user_id + field :update_user_id + + field :is_top, :type => Boolean, :default => false + + mount_uploader :image, ImageUploader + + belongs_to :bulletin_category + + embeds_many :bulletin_links, :cascade_callbacks => true + embeds_many :bulletin_files, :cascade_callbacks => true + + # has_many :bulletin_files, :autosave => true, :dependent => :destroy + + accepts_nested_attributes_for :bulletin_files, :allow_destroy => true + accepts_nested_attributes_for :bulletin_links, :allow_destroy => true + + # validates_presence_of :title_variable + validates_presence_of :title + + after_save :save_bulletin_links + after_save :save_bulletin_files + + + def self.search( search = nil, category_id = nil ) + + if category_id.to_s.size > 0 and search.to_s.size > 0 + + key = /#{search}/ + + find(:all, :conditions => {title: key, bulletin_category_id: category_id}).desc( :is_top, :postdate ) + + elsif category_id.to_s.size > 0 and search.to_s.size < 1 + + find(:all, :conditions => {bulletin_category_id: category_id}).desc( :is_top, :postdate ) + + elsif search.to_s.size > 0 and category_id.to_s.size < 1 + + key = /#{search}/ + + find(:all, :conditions => {title: key}).desc( :is_top, :postdate ) + else + + find(:all).desc( :is_top, :postdate) + + end + + end + + + def self.widget_datas + + date_now = Time.now + + # find(:all, :conditions => {:postdate => {"$lte" => Date.today}, deadline: nil} ).desc( :is_top, :postdate) + # where( :postdate.lte => date_now ).where( :deadline => nil ).desc(:is_top, :postdate) + # any_of({ :title => "test" },{:deadline => nil, :title => "123"}) + any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).limit(5) + + + end + + + def is_top? + self.is_top + end + + def save_bulletin_links + self.bulletin_links.each do |t| + if t.should_destroy + t.destroy + end + end + end + + def save_bulletin_files + self.bulletin_files.each do |t| + if t.should_destroy + t.destroy + end + end + end + +end \ No newline at end of file diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/fact_checks/_list_table.html.erb.can_del b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/fact_checks/_list_table.html.erb.can_del new file mode 100644 index 00000000..59bac03a --- /dev/null +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/fact_checks/_list_table.html.erb.can_del @@ -0,0 +1,15 @@ +

    <%= bulletin_category.key %>

    + + + + + + + + + + +<% bulletin_category.bulletins.each do |post| %> + <%= render :partial => 'panel/announcement/back_end/bulletins/bulletins', :locals => {:post => post,:fact_check_allow=>true} %> +<% end %> +
    <%= t('bulletin.status') %><%= t('bulletin.category') %><%= t('bulletin.title') %><%= t('bulletin.postdate') %><%= t('bulletin.deadline') %><%= t('bulletin.action') %>
    \ No newline at end of file diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/fact_checks/_privilege_user.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/fact_checks/_privilege_user.html.erb new file mode 100644 index 00000000..347b15b2 --- /dev/null +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/fact_checks/_privilege_user.html.erb @@ -0,0 +1,7 @@ +<%= content_tag :div ,:id => "users_checkbox_ary", do -%> +<% sys_users = User.all -%> + <% sys_users.each do |user| -%> + <%= label_tag "lab-user-#{user.id}", user.name rescue '' -%> + <%= check_box_tag "[users][#{user.id}]", 'true',users.include?(user) -%> + <% end -%> +<% end -%> \ No newline at end of file diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/fact_checks/index.html.erb.can_del b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/fact_checks/index.html.erb.can_del new file mode 100644 index 00000000..32f3d820 --- /dev/null +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/fact_checks/index.html.erb.can_del @@ -0,0 +1,50 @@ +<%= render 'panel/announcement/back_end/bulletins/filter' %> + + <%= render 'panel/announcement/back_end/bulletins/bulletins' %> +
    +
    + <%= link_to content_tag(:i, nil, :class => 'icon-plus icon-white') + t('admin.add'), new_panel_announcement_back_end_bulletin_path, :class => 'btn btn-primary' %> +
    + + \ No newline at end of file diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/fact_checks/setting.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/fact_checks/setting.html.erb new file mode 100644 index 00000000..d5d589cf --- /dev/null +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/fact_checks/setting.html.erb @@ -0,0 +1,20 @@ +<%= label_tag :fact_check_setting, t("announcement.bulletin.fact_check_setting") %> +
    +<%= form_tag('', :remote => true) %> +<%= label_tag :category, t("announcement.bulletin.category") %> +<%= select_tag "category_id", options_from_collection_for_select(@bulletin_categorys, "id", "key") %> + +
    +<%= label_tag :role, t("admin.roles") %> +<%= content_tag :div do -%> + <% form_tag :action => "update_setting" do %> + <%= render :partial => "privilege_user", :locals => {:users => @users_array} %> + <%= submit_tag "Update" %> + <% end -%> +<% end -%> + + \ No newline at end of file diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/fact_checks/setting.js.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/fact_checks/setting.js.erb new file mode 100644 index 00000000..a01c9d6a --- /dev/null +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/fact_checks/setting.js.erb @@ -0,0 +1 @@ +$("#users_checkbox_ary").replaceWith('<%= (render :partial => 'privilege_user', :locals => {:users => @users_array}).html_safe%>'); \ No newline at end of file diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/widget/bulletins/index.html - %BDしs.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/widget/bulletins/index.html - %BDしs.erb new file mode 100644 index 00000000..2c4cd153 --- /dev/null +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/widget/bulletins/index.html - %BDしs.erb @@ -0,0 +1,42 @@ + + +<% if @bulletin and !@bulletin.nil? %> + +
    +

    <%= @bulletin.title %>

    +

    <%= @bulletin.subtitle %>

    + <%= link_to "read more >",panel_announcement_front_end_bulletin_path(@bulletin.id) %> + read more > +
    + +<% end %> + +<% if @bulletins and !@bulletins.nil? %> + +
    +

    news

    +
      + <% @bulletins.each do |post| %> +
    • <%= post.postdate.to_s.gsub("-", "") %><%= link_to post.title,panel_announcement_front_end_bulletin_path(post) %>
    • + <% end %> +
    +<%= link_to "read more >",panel_announcement_front_end_bulletins_path(), :class => "btn" %> +read more > +
    + +
    +

    news

    +
      + <% @bulletins.each do |post| %> +
    • + <%= image_tag(post.image.url, :size => "160x140") if post.image.file %> +

      <%= post.title %>

      + <%= post.subtitle %> +
    • + <% end %> +
    +<%= link_to "read more >",panel_announcement_front_end_bulletins_path(), :class => "btn" %> +read more > +
    + +<% end %> From c7a333f99034ff0095d8f6d655834b251ee454a3 Mon Sep 17 00:00:00 2001 From: Matt Fu Date: Fri, 16 Mar 2012 15:51:59 +0800 Subject: [PATCH 016/125] after merge --- .../bulletins/_bulletin_link.html - %BDしs.erb | 27 +++++++++++++++++++ .../_bulletin_link2.html - %BDしs.erb | 16 +++++++++++ .../back_end/bulletins/index.html - %BDしs.erb | 9 +++++++ 3 files changed, 52 insertions(+) create mode 100644 vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletin_link.html - %BDしs.erb create mode 100644 vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletin_link2.html - %BDしs.erb create mode 100644 vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/index.html - %BDしs.erb diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletin_link.html - %BDしs.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletin_link.html - %BDしs.erb new file mode 100644 index 00000000..33d1ba1e --- /dev/null +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletin_link.html - %BDしs.erb @@ -0,0 +1,27 @@ + +
    " class='list_item'> +
    + + <%= f.label :link_url %> + <%= f.text_field :url %> + + <%= f.label :link_name %> + <%#= f.text_field :name %> + <%= f.fields_for :i18n_variable, (bulletin_link.new_record? ? bulletin_link.build_i18n_variable : bulletin_link.i18n_variable) do |f| %> + <% @site_valid_locales.each do |locale| %> + <%= I18nVariable.first(:conditions => {:key => locale})[I18n.locale] %> + <%= f.text_field locale, :style => "width:130px" %> + <% end %> + <% end %> + + + <% if bulletin_link.new_record? %> + <%= t(:delete) %> + <% else %> + <%= f.hidden_field :id %> + <%= t(:delete) %> + <%= f.hidden_field :should_destroy, :value => nil, :class => 'should_destroy' %> + <% end %> + +
    +
    diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletin_link2.html - %BDしs.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletin_link2.html - %BDしs.erb new file mode 100644 index 00000000..c44b5c92 --- /dev/null +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletin_link2.html - %BDしs.erb @@ -0,0 +1,16 @@ + + "> + <%= link_to bulletin_link2.i18n_variable.zh_tw, bulletin_link2.url, :target => '_blank' %> + <%= link_to bulletin_link2.i18n_variable.en, bulletin_link2.url, :target => '_blank' %> + + + <%= f.hidden_field :id %> + + <%= f.hidden_field :should_destroy, :value => nil, :class => 'should_destroy' %> + + + + + + + \ No newline at end of file diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/index.html - %BDしs.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/index.html - %BDしs.erb new file mode 100644 index 00000000..d37d2134 --- /dev/null +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/index.html - %BDしs.erb @@ -0,0 +1,9 @@ +<%= render 'filter' %> + + <%= render 'bulletins' %> +
    + +
    + <%= link_to content_tag(:i, nil, :class => 'icon-plus icon-white') + t('admin.add'), new_panel_announcement_back_end_bulletin_path, :class => 'btn btn-primary' %> +
    + From 7d553acaec68331b34e3bc261fd9ac114478a929 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 16 Mar 2012 15:53:57 +0800 Subject: [PATCH 017/125] fix announcement link & files --- app/assets/javascripts/bulletin_form.js.erb | 12 +- app/views/layouts/_side_bar.html.erb | 2 +- .../back_end/bulletin_links_controller.rb | 14 ++ .../back_end/bulletins_controller.rb | 2 +- .../bulletins/_bulletin_file.html.erb | 63 ++++--- .../bulletins/_bulletin_link.html.erb | 48 +++--- .../back_end/bulletins/_form.html.erb | 155 ++++++++++++------ .../bulletins/_quick_edit_links.html.erb | 12 +- .../back_end/bulletins/index.html.erb | 3 + .../announcement/config/routes.rb | 1 + 10 files changed, 200 insertions(+), 112 deletions(-) create mode 100644 vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletin_links_controller.rb diff --git a/app/assets/javascripts/bulletin_form.js.erb b/app/assets/javascripts/bulletin_form.js.erb index 17f86060..a427667d 100644 --- a/app/assets/javascripts/bulletin_form.js.erb +++ b/app/assets/javascripts/bulletin_form.js.erb @@ -1,13 +1,15 @@ -$('.bulletin_links_block a.delete').live('click', function(){ - $(this).parents('.list_item').remove(); +$('.bulletin_links_block a.remove_existing_record').live('click', function(){ + //$(this).parents('.list_item').remove(); + $(this).parents('tr.list_item').remove(); }); -$('.bulletin_files_block a.delete').live('click', function(){ - $(this).parents('.list_item').remove(); +$('.bulletin_files_block a.remove_existing_record').live('click', function(){ + //$(this).parents('.list_item').remove(); + $(this).parents('tr.list_item').remove(); }); $('.action a.remove_existing_record').live('click', function(){ $(this).next('.should_destroy').attr('value', 1); - $("#bulletin_" + $(this).prev().attr('value')).hide(); + //$("#bulletin_" + $(this).prev().attr('value')).hide(); $("tr#bulletin_" + $(this).prev().attr('value')).hide(); }); \ No newline at end of file diff --git a/app/views/layouts/_side_bar.html.erb b/app/views/layouts/_side_bar.html.erb index 61e2c4d8..220781a7 100644 --- a/app/views/layouts/_side_bar.html.erb +++ b/app/views/layouts/_side_bar.html.erb @@ -13,7 +13,7 @@ <% end -%> <%= content_tag :li, :class => active_for_controllers('users') do -%> - <%= link_to content_tag(:i, nil, :class => 'icons-member') + t('admin.member'), panel_web_resource_back_end_web_links_path %> + <%= link_to content_tag(:i, nil, :class => 'icons-member') + t('admin.member'), admin_users_path %> <% end -%> <%= content_tag :li, :class => active_for_controllers('page_contexts') do -%> diff --git a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletin_links_controller.rb b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletin_links_controller.rb new file mode 100644 index 00000000..04a75fa6 --- /dev/null +++ b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletin_links_controller.rb @@ -0,0 +1,14 @@ +class Panel::Announcement::BackEnd::BulletinLinksController < ApplicationController + + layout 'new_admin' + + def index + @bulletin_links = BulletinLink.all + + respond_to do |format| + format.html # index.html.erb + # format.xml { render :xml => @bulletins } + format.js + end + +end diff --git a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletins_controller.rb b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletins_controller.rb index 09e94c2d..77454b85 100644 --- a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletins_controller.rb +++ b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletins_controller.rb @@ -15,7 +15,7 @@ class Panel::Announcement::BackEnd::BulletinsController < ApplicationController # @bulletins = Bulletin.search(params[:search], params[:category_id]) # @bulletins = Bulletin.all.order_by([params[:sort], params[:direction]]) - @bulletins = params[:sort] ? get_sorted_bulletins : Bulletin.all + @bulletins = params[:sort] ? get_sorted_bulletins : Bulletin.limit(1).desc("postdate") @bulletin_categories = BulletinCategory.all respond_to do |format| diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletin_file.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletin_file.html.erb index 6da49ceb..ef2d4bc7 100644 --- a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletin_file.html.erb +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletin_file.html.erb @@ -1,36 +1,47 @@ -
    " class='list_item'> -
    - <%= f.label :file %> - <%#= file_field_tag 'bulletin[file]' %> - <%= f.file_field :file %> - - <%= f.label :file_title %> - <%#= f.text_field :filetitle %> - <%= f.fields_for :filetitle, (bulletin_file.new_record? ? bulletin_file.build_filetitle : bulletin_file.filetitle ) do |f| %> - <% @site_valid_locales.each do |locale| %> - <%= I18nVariable.from_locale(locale) %> - <%= f.text_field locale %> + " class='list_item'> + +
    +
    + <%= f.file_field :file %> +
    +
    + + + <%= f.fields_for :filetitle, (bulletin_file.new_record? ? bulletin_file.build_filetitle : bulletin_file.filetitle ) do |f| %> + <% @site_valid_locales.each do |locale| %> +
    + +
    + <%= f.text_field locale, :id => "link-#{locale}", :class => "input-xlarge" %> +
    +
    + <% end %> <% end %> - <% end %> - - <%= f.label :file_description %> - <%#= f.text_field :description %> - <%= f.fields_for :description, (bulletin_file.new_record? ? bulletin_file.build_description : bulletin_file.description ) do |f| %> - <% @site_valid_locales.each do |locale| %> - <%= I18nVariable.from_locale(locale) %> - <%= f.text_field locale %> + + + <%= f.fields_for :description, (bulletin_file.new_record? ? bulletin_file.build_description : bulletin_file.description ) do |f| %> + <% @site_valid_locales.each do |locale| %> +
    + +
    + <%= f.text_field locale, :id => "link-#{locale}", :class => "input-xlarge" %> +
    +
    + <% end %> <% end %> - <% end %> - + + <% if bulletin_file.new_record? %> - <%= t(:delete) %> + <% else %> <%= f.hidden_field :id %> - <%= t(:delete) %> + <%= f.hidden_field :should_destroy, :value => nil, :class => 'should_destroy' %> <% end %> -
    -
    + + + + diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletin_link.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletin_link.html.erb index e0077384..c8503083 100644 --- a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletin_link.html.erb +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletin_link.html.erb @@ -1,27 +1,37 @@ -
    " class='list_item'> -
    - - <%= f.label :link_url %> - <%= f.text_field :url %> - - <%= f.label :link_name %> - <%#= f.text_field :name %> - <%= f.fields_for :i18n_variable, (bulletin_link.new_record? ? bulletin_link.build_i18n_variable : bulletin_link.i18n_variable) do |f| %> - <% @site_valid_locales.each do |locale| %> - <%= I18nVariable.first(:conditions => {:key => locale})[I18n.locale] %> - <%= f.text_field locale, :style => "width:130px" %> - <% end %> - <% end %> - + " class='list_item'> + + +
    +
    + <%= f.text_field :url %> +
    +
    + + + <%= f.fields_for :i18n_variable, (bulletin_link.new_record? ? bulletin_link.build_i18n_variable : bulletin_link.i18n_variable) do |f| %> + <% @site_valid_locales.each do |locale| %> +
    +
    + <%= f.text_field locale, :id => "link-#{locale}", :class => "input-xlarge" %> +
    +
    + + + + <% end %> + <% end %> + + + <% if bulletin_link.new_record? %> - <%= t(:delete) %> + <% else %> <%= f.hidden_field :id %> - <%= t(:delete) %> + <%= f.hidden_field :should_destroy, :value => nil, :class => 'should_destroy' %> <% end %> -
    -
    + + diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_form.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_form.html.erb index 2e41f302..3cefe360 100644 --- a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_form.html.erb +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_form.html.erb @@ -13,7 +13,8 @@

    Picture

    - + +
    - - - + +
    + +
    @@ -202,38 +229,60 @@
    - +
    -
    - - - - -
    - -
    -

    Bulletin files

    - <%= hidden_field_tag 'bulletin_file_field_count', @bulletin.bulletin_files.count %> - <%= t(:add) %> -
    - - <%#= render :partial => 'file', :locals => { :bulletin_files => @bulletin.bulletin_files , :f => f} %> - - - <% @bulletin.bulletin_files.each_with_index do |bulletin_file, i| %> - <%#= fields_for "bulletin[bulletin_files][]", bulletin_file do |f| %> - <%= f.fields_for :bulletin_files, bulletin_file do |f| %> - <%= render :partial => 'bulletin_file', :object => bulletin_file, :locals => {:f => f, :i => i} %> - <% end %> - <% end %> - -
    - -
    -
    +
    + + + + +
    +
    +
    + +
    +

    File

    +
    + + + + + + + + + + + + + + + + +
    + + <% @bulletin.bulletin_files.each_with_index do |bulletin_file, i| %> + <%#= fields_for "bulletin[bulletin_files][]", bulletin_file do |f| %> + <%= f.fields_for :bulletin_files, bulletin_file do |f| %> + <%= render :partial => 'bulletin_file', :object => bulletin_file, :locals => {:f => f, :i => i} %> + <% end %> + <% end %> + +
    + + +
    FileName<%= t('description') %>
    +
    + <%= hidden_field_tag 'bulletin_file_field_count', @bulletin.bulletin_files.count %> + ADD/啣 +
    +
    +
    +
    +
    -
    +
    @@ -252,13 +301,13 @@ var new_id = $(this).prev().attr('value'); var old_id = new RegExp("new_bulletin_links", "g"); $(this).prev().attr('value', parseInt(new_id) + 1); - $('#bulletin_links').append(("<%= escape_javascript(add_attribute 'bulletin_link', f, :bulletin_links) %>").replace(old_id, new_id)); + $(this).parents('table').append(("<%= escape_javascript(add_attribute 'bulletin_link', f, :bulletin_links) %>").replace(old_id, new_id)); }); $('#add_bulletin_file a.add').live('click', function(){ var new_id = $(this).prev().attr('value'); var old_id = new RegExp("new_bulletin_files", "g"); $(this).prev().attr('value', parseInt(new_id) + 1); - $('#bulletin_files').append(("<%= escape_javascript(add_attribute 'bulletin_file', f, :bulletin_files) %>").replace(old_id, new_id)); + $(this).parents('table').append(("<%= escape_javascript(add_attribute 'bulletin_file', f, :bulletin_files) %>").replace(old_id, new_id)); }); \ No newline at end of file diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/fact_checks/setting.js.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/fact_checks/setting.js.erb new file mode 100644 index 00000000..a01c9d6a --- /dev/null +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/fact_checks/setting.js.erb @@ -0,0 +1 @@ +$("#users_checkbox_ary").replaceWith('<%= (render :partial => 'privilege_user', :locals => {:users => @users_array}).html_safe%>'); \ No newline at end of file diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/widget/bulletins/index.html - %BDしs.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/widget/bulletins/index.html - %BDしs.erb new file mode 100644 index 00000000..2c4cd153 --- /dev/null +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/widget/bulletins/index.html - %BDしs.erb @@ -0,0 +1,42 @@ + + +<% if @bulletin and !@bulletin.nil? %> + +
    +

    <%= @bulletin.title %>

    +

    <%= @bulletin.subtitle %>

    + <%= link_to "read more >",panel_announcement_front_end_bulletin_path(@bulletin.id) %> + read more > +
    + +<% end %> + +<% if @bulletins and !@bulletins.nil? %> + +
    +

    news

    +
      + <% @bulletins.each do |post| %> +
    • <%= post.postdate.to_s.gsub("-", "") %><%= link_to post.title,panel_announcement_front_end_bulletin_path(post) %>
    • + <% end %> +
    +<%= link_to "read more >",panel_announcement_front_end_bulletins_path(), :class => "btn" %> +read more > +
    + +
    +

    news

    +
      + <% @bulletins.each do |post| %> +
    • + <%= image_tag(post.image.url, :size => "160x140") if post.image.file %> +

      <%= post.title %>

      + <%= post.subtitle %> +
    • + <% end %> +
    +<%= link_to "read more >",panel_announcement_front_end_bulletins_path(), :class => "btn" %> +read more > +
    + +<% end %> From 670011495560a810823b00b43aec20ad226e20a6 Mon Sep 17 00:00:00 2001 From: Matt Fu Date: Fri, 16 Mar 2012 15:51:59 +0800 Subject: [PATCH 019/125] after merge --- .../bulletins/_bulletin_link.html - %BDしs.erb | 27 +++++++++++++++++++ .../_bulletin_link2.html - %BDしs.erb | 16 +++++++++++ .../back_end/bulletins/index.html - %BDしs.erb | 9 +++++++ 3 files changed, 52 insertions(+) create mode 100644 vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletin_link.html - %BDしs.erb create mode 100644 vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletin_link2.html - %BDしs.erb create mode 100644 vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/index.html - %BDしs.erb diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletin_link.html - %BDしs.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletin_link.html - %BDしs.erb new file mode 100644 index 00000000..33d1ba1e --- /dev/null +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletin_link.html - %BDしs.erb @@ -0,0 +1,27 @@ + +
    " class='list_item'> +
    + + <%= f.label :link_url %> + <%= f.text_field :url %> + + <%= f.label :link_name %> + <%#= f.text_field :name %> + <%= f.fields_for :i18n_variable, (bulletin_link.new_record? ? bulletin_link.build_i18n_variable : bulletin_link.i18n_variable) do |f| %> + <% @site_valid_locales.each do |locale| %> + <%= I18nVariable.first(:conditions => {:key => locale})[I18n.locale] %> + <%= f.text_field locale, :style => "width:130px" %> + <% end %> + <% end %> + + + <% if bulletin_link.new_record? %> + <%= t(:delete) %> + <% else %> + <%= f.hidden_field :id %> + <%= t(:delete) %> + <%= f.hidden_field :should_destroy, :value => nil, :class => 'should_destroy' %> + <% end %> + +
    +
    diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletin_link2.html - %BDしs.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletin_link2.html - %BDしs.erb new file mode 100644 index 00000000..c44b5c92 --- /dev/null +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletin_link2.html - %BDしs.erb @@ -0,0 +1,16 @@ + + "> + <%= link_to bulletin_link2.i18n_variable.zh_tw, bulletin_link2.url, :target => '_blank' %> + <%= link_to bulletin_link2.i18n_variable.en, bulletin_link2.url, :target => '_blank' %> + + + <%= f.hidden_field :id %> + + <%= f.hidden_field :should_destroy, :value => nil, :class => 'should_destroy' %> + + + + + + + \ No newline at end of file diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/index.html - %BDしs.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/index.html - %BDしs.erb new file mode 100644 index 00000000..d37d2134 --- /dev/null +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/index.html - %BDしs.erb @@ -0,0 +1,9 @@ +<%= render 'filter' %> + + <%= render 'bulletins' %> +
    + +
    + <%= link_to content_tag(:i, nil, :class => 'icon-plus icon-white') + t('admin.add'), new_panel_announcement_back_end_bulletin_path, :class => 'btn btn-primary' %> +
    + From b58db48d26e32dea6594e035bc7707248cda9143 Mon Sep 17 00:00:00 2001 From: Christophe Vilayphiou Date: Mon, 19 Mar 2012 14:04:28 +0800 Subject: [PATCH 020/125] Changes in Gemfile --- Gemfile | 4 ++-- Gemfile.lock | 11 ++++++----- config/application.rb | 2 +- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/Gemfile b/Gemfile index fabc1833..024f3449 100644 --- a/Gemfile +++ b/Gemfile @@ -6,7 +6,7 @@ gem "brakeman" gem 'bson_ext' gem 'carrierwave' gem 'carrierwave-mongoid', :require => 'carrierwave/mongoid' -gem 'devise' +gem 'devise', '1.5.3' gem 'exception_notification' # Send error trace gem 'execjs' gem 'jquery-rails' @@ -23,7 +23,7 @@ gem 'rubyzip' gem 'sinatra' gem 'sprockets' gem 'tinymce-rails' -#gem 'therubyracer' +gem 'therubyracer' if RUBY_PLATFORM.downcase.include?("linux") # Gems used only for assets and not required # in production environments by default. diff --git a/Gemfile.lock b/Gemfile.lock index dd1a1d59..1df648c4 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -40,7 +40,7 @@ GEM multi_json (~> 1.0) archive-tar-minitar (0.5.2) arel (2.2.3) - bcrypt-ruby (3.0.1-x86-mingw32) + bcrypt-ruby (3.0.1) brakeman (1.5.1) activesupport erubis (~> 2.6) @@ -71,11 +71,10 @@ GEM database_cleaner (0.7.1) delorean (1.2.0) chronic - devise (2.0.4) + devise (1.5.3) bcrypt-ruby (~> 3.0) orm_adapter (~> 0.0.3) - railties (~> 3.1) - warden (~> 1.1.1) + warden (~> 1.1) diff-lcs (1.1.3) erubis (2.7.0) exception_notification (2.5.2) @@ -199,6 +198,7 @@ GEM rack (~> 1.3, >= 1.3.6) rack-protection (~> 1.2) tilt (~> 1.3, >= 1.3.3) + spork (0.9.0) spork (0.9.0-x86-mingw32) win32-process sprockets (2.0.3) @@ -232,6 +232,7 @@ GEM windows-api (>= 0.3.0) PLATFORMS + ruby x86-mingw32 DEPENDENCIES @@ -242,7 +243,7 @@ DEPENDENCIES coffee-rails database_cleaner delorean - devise + devise (= 1.5.3) exception_notification execjs factory_girl_rails diff --git a/config/application.rb b/config/application.rb index d1243133..381d1c64 100644 --- a/config/application.rb +++ b/config/application.rb @@ -19,7 +19,7 @@ module Orbit # Add directories for plugins config.paths["vendor/plugins"] += %W(#{config.root}/vendor/built_in_modules) config.paths["vendor/plugins"] += %W(#{config.root}/vendor/downloaded_modules) - config.paths.app.views << "app/views/devise" + config.paths["app/views"] += %W(#{config.root}/app/views/devise) # Settings in config/environments/* take precedence over those specified here. From 7cc075e12406fa1c5468bae073adde3c13dc38d2 Mon Sep 17 00:00:00 2001 From: Christophe Vilayphiou Date: Mon, 19 Mar 2012 15:49:40 +0800 Subject: [PATCH 021/125] Change the monkey picture --- app/views/layouts/_orbit_bar.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/layouts/_orbit_bar.html.erb b/app/views/layouts/_orbit_bar.html.erb index e9a91f48..31fa6806 100644 --- a/app/views/layouts/_orbit_bar.html.erb +++ b/app/views/layouts/_orbit_bar.html.erb @@ -28,7 +28,7 @@ <% if user_signed_in? %>
  • <%= bulletin.bulletin_category.i18n_variable[I18n.locale] %> - <%= link_to bulletin.title[I18n.locale], panel_announcement_back_end_bulletin_path(bulletin) rescue ''%> + <%= link_to bulletin.title[I18n.locale], panel_announcement_front_end_bulletin_path(bulletin) rescue ''%> <%= bulletin.postdate %> <%= (bulletin.deadline) ? bulletin.deadline : t('bulletin.no_deadline') %> From 3aa7c5120deadba8de4252753a125533555fb551 Mon Sep 17 00:00:00 2001 From: Christophe Vilayphiou Date: Wed, 21 Mar 2012 12:41:32 +0800 Subject: [PATCH 025/125] Put tinymce in its own js file. To use on a text area just add the class "tinymce_textarea". --- app/assets/javascripts/new_admin.js | 3 ++- app/assets/javascripts/tinymce_orbit.js | 26 +++++++++++++++++++ .../back_end/bulletins/_form.html.erb | 11 ++------ .../back_end/page_contexts/_form.html.erb | 13 +--------- 4 files changed, 31 insertions(+), 22 deletions(-) create mode 100644 app/assets/javascripts/tinymce_orbit.js diff --git a/app/assets/javascripts/new_admin.js b/app/assets/javascripts/new_admin.js index cd15fc39..3ec6f22f 100644 --- a/app/assets/javascripts/new_admin.js +++ b/app/assets/javascripts/new_admin.js @@ -10,4 +10,5 @@ //= require jquery.isotope.min //= require jquery.tinyscrollbar.min //= require orbit-1.0 -//= require tinymce-jquery \ No newline at end of file +//= require tinymce-jquery +//= require tinymce_orbit \ No newline at end of file diff --git a/app/assets/javascripts/tinymce_orbit.js b/app/assets/javascripts/tinymce_orbit.js new file mode 100644 index 00000000..89fb9390 --- /dev/null +++ b/app/assets/javascripts/tinymce_orbit.js @@ -0,0 +1,26 @@ +$(function() { + $('.tinymce_textarea').tinymce({ + theme: 'advanced', + plugins : "autolink,lists,spellchecker,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template", + + // Theme options + theme_advanced_buttons1 : "save,newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,styleselect,formatselect,fontselect,fontsizeselect", + theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,|,insertdate,inserttime,preview,|,forecolor,backcolor", + theme_advanced_buttons3 : "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,emotions,iespell,media,advhr,|,print,|,ltr,rtl,|,fullscreen", + theme_advanced_buttons4 : "insertlayer,moveforward,movebackward,absolute,|,styleprops,spellchecker,|,cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,template,blockquote,pagebreak,|,insertfile,insertimage", + theme_advanced_toolbar_location : "top", + theme_advanced_toolbar_align : "left", + theme_advanced_statusbar_location : "bottom", + theme_advanced_resizing : false, + + // Skin options + skin : "o2k7", + skin_variant : "silver", + + // Drop lists for link/image/media/template dialogs + template_external_list_url : "js/template_list.js", + external_link_list_url : "js/link_list.js", + external_image_list_url : "js/image_list.js", + media_external_list_url : "js/media_list.js" + }); +}); \ No newline at end of file diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_form.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_form.html.erb index d3e9f3a1..97f822d0 100644 --- a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_form.html.erb +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_form.html.erb @@ -146,7 +146,7 @@ <% @site_valid_locales.each do |locale| %> <%= I18nVariable.from_locale(locale) %> - <%= f.text_area locale, :style=>"width:100%" %> + <%= f.text_area locale, :style=>"width:100%", :class => 'tinymce_textarea' %> <% end %> <% end %> @@ -158,7 +158,7 @@ <% @site_valid_locales.each do |locale| %> <%= I18nVariable.from_locale(locale) %> - <%= f.text_area locale, :style=>"width:100%" %> + <%= f.text_area locale, :style=>"width:100%", :class => 'tinymce_textarea' %> <% end %> <% end %> @@ -286,11 +286,4 @@ $(this).parents('table').append(("<%= escape_javascript(add_attribute 'bulletin_file', f, :bulletin_files) %>").replace(old_id, new_id)); }); - <% end %> diff --git a/vendor/built_in_modules/page_content/app/views/panel/page_content/back_end/page_contexts/_form.html.erb b/vendor/built_in_modules/page_content/app/views/panel/page_content/back_end/page_contexts/_form.html.erb index 4ca568a9..258aa55c 100644 --- a/vendor/built_in_modules/page_content/app/views/panel/page_content/back_end/page_contexts/_form.html.erb +++ b/vendor/built_in_modules/page_content/app/views/panel/page_content/back_end/page_contexts/_form.html.erb @@ -15,7 +15,7 @@ <% @site_valid_locales.each do |locale| %> <%= I18nVariable.from_locale(locale) %> - <%= f.text_area locale, :style=>"width:100%" %> + <%= f.text_area locale, :style=>"width:100%", :class => 'tinymce_textarea' %> <% end %> <% end %> @@ -27,14 +27,3 @@
    - - -<% content_for :page_specific_javascript do %> - -<% end %> \ No newline at end of file From 0e8f8b34246beb6247ef9a277dad03dba9789f6f Mon Sep 17 00:00:00 2001 From: Christophe Vilayphiou Date: Wed, 21 Mar 2012 12:58:13 +0800 Subject: [PATCH 026/125] Add missing category when redirect to front-end for bulletin back-end index --- .../panel/announcement/back_end/bulletins/_bulletin.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletin.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletin.html.erb index da802446..ebd8f098 100644 --- a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletin.html.erb +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletin.html.erb @@ -29,7 +29,7 @@
    <%= bulletin.bulletin_category.i18n_variable[I18n.locale] %> - <%= link_to bulletin.title[I18n.locale], panel_announcement_front_end_bulletin_path(bulletin) rescue ''%> + <%= link_to bulletin.title[I18n.locale], panel_announcement_front_end_bulletin_path(bulletin, :category_id => bulletin.bulletin_category.id) rescue ''%> <%= bulletin.postdate %> <%= (bulletin.deadline) ? bulletin.deadline : t('bulletin.no_deadline') %> From 472744fc875cf4ca5787d36facf97b6c232ad3fe Mon Sep 17 00:00:00 2001 From: Christophe Vilayphiou Date: Wed, 21 Mar 2012 15:51:55 +0800 Subject: [PATCH 027/125] Changes for IE9 with html5 --- app/assets/javascripts/html5.js | 3 +++ app/views/layouts/admin.html.erb | 2 +- app/views/layouts/devise.html.erb | 2 +- app/views/layouts/module_widget.html.erb | 2 +- app/views/layouts/new_admin.html.erb | 2 +- app/views/layouts/site_editor.html.erb | 2 +- 6 files changed, 8 insertions(+), 5 deletions(-) create mode 100644 app/assets/javascripts/html5.js diff --git a/app/assets/javascripts/html5.js b/app/assets/javascripts/html5.js new file mode 100644 index 00000000..5c92911e --- /dev/null +++ b/app/assets/javascripts/html5.js @@ -0,0 +1,3 @@ +/*! HTML5 Shiv pre3.5 | @afarkas @jdalton @jon_neal @rem | MIT/GPL2 Licensed + Uncompressed source: https://github.com/aFarkas/html5shiv */ +(function(a,b){function h(a,b){var c=a.createElement("p"),d=a.getElementsByTagName("head")[0]||a.documentElement;return c.innerHTML="x",d.insertBefore(c.lastChild,d.firstChild)}function i(){var a=l.elements;return typeof a=="string"?a.split(" "):a}function j(a){var b={},c=a.createElement,f=a.createDocumentFragment,g=f();a.createElement=function(a){l.shivMethods||c(a);var f;return b[a]?f=b[a].cloneNode():e.test(a)?f=(b[a]=c(a)).cloneNode():f=c(a),f.canHaveChildren&&!d.test(a)?g.appendChild(f):f},a.createDocumentFragment=Function("h,f","return function(){var n=f.cloneNode(),c=n.createElement;h.shivMethods&&("+i().join().replace(/\w+/g,function(a){return b[a]=c(a),g.createElement(a),'c("'+a+'")'})+");return n}")(l,g)}function k(a){var b;return a.documentShived?a:(l.shivCSS&&!f&&(b=!!h(a,"article,aside,details,figcaption,figure,footer,header,hgroup,nav,section{display:block}audio{display:none}canvas,video{display:inline-block;*display:inline;*zoom:1}[hidden]{display:none}audio[controls]{display:inline-block;*display:inline;*zoom:1}mark{background:#FF0;color:#000}")),g||(b=!j(a)),b&&(a.documentShived=b),a)}function p(a){var b,c=a.getElementsByTagName("*"),d=c.length,e=RegExp("^(?:"+i().join("|")+")$","i"),f=[];while(d--)b=c[d],e.test(b.nodeName)&&f.push(b.applyElement(q(b)));return f}function q(a){var b,c=a.attributes,d=c.length,e=a.ownerDocument.createElement(n+":"+a.nodeName);while(d--)b=c[d],b.specified&&e.setAttribute(b.nodeName,b.nodeValue);return e.style.cssText=a.style.cssText,e}function r(a){var b,c=a.split("{"),d=c.length,e=RegExp("(^|[\\s,>+~])("+i().join("|")+")(?=[[\\s,>+~#.:]|$)","gi"),f="$1"+n+"\\:$2";while(d--)b=c[d]=c[d].split("}"),b[b.length-1]=b[b.length-1].replace(e,f),c[d]=b.join("}");return c.join("{")}function s(a){var b=a.length;while(b--)a[b].removeNode()}function t(a){var b,c,d=a.namespaces,e=a.parentWindow;return!o||a.printShived?a:(typeof d[n]=="undefined"&&d.add(n),e.attachEvent("onbeforeprint",function(){var d,e,f,g=a.styleSheets,i=[],j=g.length,k=Array(j);while(j--)k[j]=g[j];while(f=k.pop())if(!f.disabled&&m.test(f.media)){for(d=f.imports,j=0,e=d.length;j",f="hidden"in c,f&&typeof injectElementWithStyles=="function"&&injectElementWithStyles("#modernizr{}",function(b){b.hidden=!0,f=(a.getComputedStyle?getComputedStyle(b,null):b.currentStyle).display=="none"}),g=c.childNodes.length==1||function(){try{b.createElement("a")}catch(a){return!0}var c=b.createDocumentFragment();return typeof c.cloneNode=="undefined"||typeof c.createDocumentFragment=="undefined"||typeof c.createElement=="undefined"}()})();var l={elements:c.elements||"abbr article aside audio bdi canvas data datalist details figcaption figure footer header hgroup mark meter nav output progress section summary time video",shivCSS:c.shivCSS!==!1,shivMethods:c.shivMethods!==!1,type:"default",shivDocument:k};a.html5=l,k(b);var m=/^$|\b(?:all|print)\b/,n="html5shiv",o=!g&&function(){var c=b.documentElement;return typeof b.namespaces!="undefined"&&typeof b.parentWindow!="undefined"&&typeof c.applyElement!="undefined"&&typeof c.removeNode!="undefined"&&typeof a.attachEvent!="undefined"}();l.type+=" print",l.shivPrint=t,t(b)})(this,document) \ No newline at end of file diff --git a/app/views/layouts/admin.html.erb b/app/views/layouts/admin.html.erb index d800ab5d..4adce7a5 100644 --- a/app/views/layouts/admin.html.erb +++ b/app/views/layouts/admin.html.erb @@ -5,7 +5,7 @@ <%= @title || APP_CONFIG['orbit'] %> <%= stylesheet_link_tag "admin" %> <%= javascript_include_tag "admin" %> diff --git a/app/views/layouts/devise.html.erb b/app/views/layouts/devise.html.erb index 976b5422..d1a3512c 100644 --- a/app/views/layouts/devise.html.erb +++ b/app/views/layouts/devise.html.erb @@ -4,7 +4,7 @@ <%= @title || APP_CONFIG['orbit'] %> <%= stylesheet_link_tag "devise" %> <%= javascript_include_tag "devise" %> diff --git a/app/views/layouts/module_widget.html.erb b/app/views/layouts/module_widget.html.erb index 254ac4e9..44a2be85 100644 --- a/app/views/layouts/module_widget.html.erb +++ b/app/views/layouts/module_widget.html.erb @@ -2,7 +2,7 @@ <%#= stylesheet_link_tag "module_widget" %> <%= javascript_include_tag "module_widget" %> diff --git a/app/views/layouts/new_admin.html.erb b/app/views/layouts/new_admin.html.erb index 3ae7a2a2..b6156c5d 100644 --- a/app/views/layouts/new_admin.html.erb +++ b/app/views/layouts/new_admin.html.erb @@ -4,7 +4,7 @@ <%= @title || APP_CONFIG['orbit'] %> <%= stylesheet_link_tag "new_admin" %> <%= javascript_include_tag "new_admin" %> diff --git a/app/views/layouts/site_editor.html.erb b/app/views/layouts/site_editor.html.erb index f4df75c4..efcc54ca 100644 --- a/app/views/layouts/site_editor.html.erb +++ b/app/views/layouts/site_editor.html.erb @@ -5,7 +5,7 @@ <%= @title || APP_CONFIG['orbit'] %> <%= stylesheet_link_tag "site_editor" %> <%= javascript_include_tag "site_editor" %> From a126935d2c66d8cd57f63f754b04ee549d852b4c Mon Sep 17 00:00:00 2001 From: Christophe Vilayphiou Date: Wed, 21 Mar 2012 18:30:12 +0800 Subject: [PATCH 028/125] Clean the parsers and introduce the metas --- app/models/meta.rb | 11 +++ app/models/meta/meta.rb | 11 +++ app/models/meta/page_meta.rb | 5 ++ app/models/meta/site_meta.rb | 5 ++ app/models/page.rb | 14 ++- app/models/site.rb | 2 + lib/parsers/parser_back_end.rb | 111 ++++++++++------------- lib/parsers/parser_front_end.rb | 154 ++++++++++++-------------------- lib/parsers/parser_layout.rb | 25 +++--- 9 files changed, 165 insertions(+), 173 deletions(-) create mode 100644 app/models/meta.rb create mode 100644 app/models/meta/meta.rb create mode 100644 app/models/meta/page_meta.rb create mode 100644 app/models/meta/site_meta.rb diff --git a/app/models/meta.rb b/app/models/meta.rb new file mode 100644 index 00000000..411a4f0c --- /dev/null +++ b/app/models/meta.rb @@ -0,0 +1,11 @@ +class Meta + + include Mongoid::Document + include Mongoid::Timestamps + + field :key + field :value, :default => nil + + has_one :i18n_variable, :as => :language_value, :autosave => true, :dependent => :destroy + +end diff --git a/app/models/meta/meta.rb b/app/models/meta/meta.rb new file mode 100644 index 00000000..411a4f0c --- /dev/null +++ b/app/models/meta/meta.rb @@ -0,0 +1,11 @@ +class Meta + + include Mongoid::Document + include Mongoid::Timestamps + + field :key + field :value, :default => nil + + has_one :i18n_variable, :as => :language_value, :autosave => true, :dependent => :destroy + +end diff --git a/app/models/meta/page_meta.rb b/app/models/meta/page_meta.rb new file mode 100644 index 00000000..9b3ded99 --- /dev/null +++ b/app/models/meta/page_meta.rb @@ -0,0 +1,5 @@ +class PageMeta < Meta + + belongs_to :page + +end diff --git a/app/models/meta/site_meta.rb b/app/models/meta/site_meta.rb new file mode 100644 index 00000000..9a17c4fa --- /dev/null +++ b/app/models/meta/site_meta.rb @@ -0,0 +1,5 @@ +class SiteMeta < Meta + + belongs_to :site + +end diff --git a/app/models/page.rb b/app/models/page.rb index ceead525..b9e06143 100644 --- a/app/models/page.rb +++ b/app/models/page.rb @@ -6,17 +6,23 @@ class Page < Item belongs_to :design belongs_to :module_app + has_one :title, :class_name => "I18nVariable", :as => :language_value, :autosave => true, :dependent => :destroy has_many :page_parts, :autosave => true, :dependent => :destroy has_many :page_contexts, :autosave => true, :dependent => :destroy + has_many :page_metas, :autosave => true, :dependent => :destroy accepts_nested_attributes_for :page_parts, :allow_destroy => true - before_save :create_parts + before_save :create_parts, :set_key # embeds_many :custom_images, :class_name => 'Image', as: :design_image def is_home? self.parent ? false : true end + + def title + @title ||= I18nVariable.first(:conditions => {:key => 'title', :language_value_id => self.id, :language_value_type => self.class}) rescue nil + end protected @@ -27,4 +33,10 @@ class Page < Item end end + def set_key + if title.new_record? + title.key = 'title' + end + end + end diff --git a/app/models/site.rb b/app/models/site.rb index 065a6f79..8f367c0a 100644 --- a/app/models/site.rb +++ b/app/models/site.rb @@ -12,6 +12,8 @@ class Site field :school field :department + + has_many :site_metas, :autosave => true, :dependent => :destroy def generate_keys private_key = OpenSSL::PKey::RSA.generate(2048) diff --git a/lib/parsers/parser_back_end.rb b/lib/parsers/parser_back_end.rb index 37c22ed1..787f579b 100644 --- a/lib/parsers/parser_back_end.rb +++ b/lib/parsers/parser_back_end.rb @@ -13,63 +13,6 @@ module ParserBackEnd def parser_context_edit(page, attributes = {}) Radius::Context.new do |c| - c.define_tag 'snippet' do |tag| - snippet = Snippet.first(:conditions => {:name => tag.attr['name']}) - if snippet - snippet.content - else - t('nothing') - end - end - c.define_tag 'language_bar' do - @site.in_use_locales.map{ |locale| - lang = I18nVariable.first(:conditions => {:key => locale})[locale] - if I18n.locale.to_s.eql?(locale) - lang - else - "#{lang}" - end - }.join(' | ') - end - c.define_tag 'css' do |tag| - assets = Asset.any_in(:filename => tag.attr['name'].split(',').map(&:strip)) - res = '' - assets.each do |asset| - res << " " if asset.data.file.content_type.eql?('text/css') - end - res - end - c.define_tag 'image' do |tag| - # 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.images.detect{|image| image.name.eql?(tag.attr['name']) } unless image - if image - res = "' - end - end - c.define_tag 'stylesheets' do |tag| - res = '' - res << "" if page.design.reset_css - res << "" if page.design.default_css - theme = page.design.themes.detect{ |d| d.id == page.theme_id } - res << "" if theme - res - end - c.define_tag 'javascripts' do |tag| - res = '' - res << "" - res << "" - res << "" - res << "" - page.design.javascripts.each do |js| - res << "" - end - res - end c.define_tag 'ad_banner' do |tag| res = '' ad_banner = AdBanner.find(tag.attr["id"]) rescue nil @@ -89,13 +32,6 @@ module ParserBackEnd res << "
    " end end - c.define_tag 'layout_part' do |tag| - part = page.page_parts.detect{ |p| p.name.to_s == tag.attr['name'].to_s } - ret = '' - ret << "
    " - ret << tag.expand - ret << '
    ' - end c.define_tag 'content' do |tag| ret = '' if (tag.attributes["main"] == "true" && !page.module_app.nil?) @@ -124,6 +60,39 @@ module ParserBackEnd end ret << '
    ' end + end + c.define_tag 'image' do |tag| + # 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.images.detect{|image| image.name.eql?(tag.attr['name']) } unless image + if image + res = "' + end + end + c.define_tag 'javascripts' do |tag| + res = '' + res << "" + res << "" + res << "" + res << "" + page.design.javascripts.each do |js| + res << "" + end + res + end + c.define_tag 'language_bar' do + @site.in_use_locales.map{ |locale| + lang = I18nVariable.first(:conditions => {:key => locale})[locale] + if I18n.locale.to_s.eql?(locale) + lang + else + "#{lang}" + end + }.join(' | ') end c.define_tag 'link' do |tag| item = Item.first(:conditions => { :full_name => tag.attr['name'] }) @@ -139,6 +108,20 @@ module ParserBackEnd menu = page.design.layout.menu menu_level(home, 0, menu, true) end + c.define_tag 'meta' do |tag| + "" + end + c.define_tag 'stylesheets' do |tag| + res = '' + res << "" if page.design.reset_css + res << "" if page.design.default_css + theme = page.design.themes.detect{ |d| d.id == page.theme_id } + res << "" if theme + res + end + c.define_tag 'title' do |tag| + "#{page.title ? page.title : page.i18n_variable[I18n.locale]}" + end end end diff --git a/lib/parsers/parser_front_end.rb b/lib/parsers/parser_front_end.rb index 99353cc1..4b5a523f 100644 --- a/lib/parsers/parser_front_end.rb +++ b/lib/parsers/parser_front_end.rb @@ -4,88 +4,6 @@ module ParserFrontEnd def parser_context(page, attributes = {}, id = nil) Radius::Context.new do |c| - c.define_tag 'snippet' do |tag| - snippet = Snippet.first(:conditions => {:name => tag.attr['name']}) - if snippet - snippet.content - else - t('nothing') - end - end - c.define_tag 'language_bar' do - @site.in_use_locales.map{ |locale| - lang = I18nVariable.first(:conditions => {:key => locale})[locale] - if I18n.locale.to_s.eql?(locale) - lang - else - "#{lang}" - end - }.join(' | ') - end - c.define_tag 'locale' do |tag| - case attributes[:locale] - when 'create' - var = I18nVariable.new(:key => (tag.attr['name'] rescue nil), :document_class => 'Text') - @site.valid_locales.each do |locale| - var[locale] = tag.attr[locale] rescue nil - end - var.save! - res = '' - res << "' - when 'show' - var = I18nVariable.find(tag.attr['id']) - res = '' - res << "' - when 'destroy' - var = I18nVariable.find(tag.attr['id']) - var.destroy - end - end - c.define_tag 'css' do |tag| - assets = Asset.any_in(:filename => tag.attr['name'].split(',').map(&:strip)) - res = '' - assets.each do |asset| - res << " " if asset.data.file.content_type.eql?('text/css') - end - res - end - c.define_tag 'stylesheets' do |tag| - res = '' - res << "" - res << "" - res << "" - res << "" if page.design.reset_css - res << " " if page.design.default_css - theme = page.design.themes.detect{ |d| d.id == page.theme_id } - res << "" if theme - res - end - c.define_tag 'javascripts' do |tag| - res = '' - res << "" - res << "" - res << "" - res << "" - res << "" - res << "" - res << "" - res << "" - res << "" - page.design.javascripts.each do |js| - # res << "" - end - res - end c.define_tag 'ad_banner' do |tag| res = '' ad_banner = AdBanner.find(tag.attr["id"]) rescue nil @@ -106,22 +24,6 @@ module ParserFrontEnd end res end - c.define_tag 'image' do |tag| - # 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.images.detect{|image| image.name.eql?(tag.attr['name']) } unless image - if image - res = "' - end - end - c.define_tag 'layout_part' do |tag| - part = page.page_parts.detect{ |p| p.name.to_s == tag.attr['name'].to_s } rescue nil - part.content - end c.define_tag 'content' do |tag| ret = '' if (tag.attributes["main"] == "true" && !page.module_app.nil?) @@ -149,6 +51,44 @@ module ParserFrontEnd end ret end + c.define_tag 'image' do |tag| + # 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.images.detect{|image| image.name.eql?(tag.attr['name']) } unless image + if image + res = "' + end + end + c.define_tag 'javascripts' do |tag| + res = '' + res << "" + res << "" + res << "" + res << "" + res << "" + res << "" + res << "" + res << "" + res << "" + page.design.javascripts.each do |js| + # res << "" + end + res + end + c.define_tag 'language_bar' do + @site.in_use_locales.map{ |locale| + lang = I18nVariable.first(:conditions => {:key => locale})[locale] + if I18n.locale.to_s.eql?(locale) + lang + else + "#{lang}" + end + }.join(' | ') + end c.define_tag 'link' do |tag| item = Item.first(:conditions => { :full_name => tag.attr['name'] }) ret = '' @@ -161,6 +101,24 @@ module ParserFrontEnd menu = page.design.layout.menu menu_level(home, 0, menu) end + c.define_tag 'meta' do |tag| + res = '' + #res << "" + end + c.define_tag 'stylesheets' do |tag| + res = '' + res << "" + res << "" + res << "" + res << "" if page.design.reset_css + res << " " if page.design.default_css + theme = page.design.themes.detect{ |d| d.id == page.theme_id } + res << "" if theme + res + end + c.define_tag 'title' do |tag| + "#{page.title ? page.title[I18n.locale] : page.i18n_variable[I18n.locale]}" + end end end diff --git a/lib/parsers/parser_layout.rb b/lib/parsers/parser_layout.rb index 4a0232c6..063078df 100644 --- a/lib/parsers/parser_layout.rb +++ b/lib/parsers/parser_layout.rb @@ -10,12 +10,17 @@ module ParserLayout end def parser_layout_contents(layout) - Radius::Context.new do |c| - c.define_tag 'javascripts' do |tag| - end - c.define_tag 'stylesheets' do |tag| - end + Radius::Context.new do |c| c.define_tag 'ad_banner' do |tag| + end + c.define_tag 'content' do |tag| + layout.layout_parts.new(:name => tag.attr['name']) + end + c.define_tag 'image' do |tag| + image = layout.design.images.detect{ |i| i.file_identifier.eql?(parse_html_image(tag.expand)) } + image.update_attributes(:name => tag.attr['name'], :html_id => tag.attr['id'], :html_class => tag.attr['class']) if image + end + c.define_tag 'javascripts' do |tag| end c.define_tag 'menu' do |tag| layout.build_menu(:levels => 0, :values => {}) unless layout.menu @@ -24,13 +29,13 @@ module ParserLayout layout.menu.values.merge!({"id_#{i}" => tag.attr['id'], "class_#{i}" => tag.attr['class'], "li_class_#{i}" => tag.attr['li_class'], "li_incremental_#{i}" => tag.attr['li_incremental']}) tag.expand end - c.define_tag 'content' do |tag| - layout.layout_parts.new(:name => tag.attr['name']) + c.define_tag 'meta' do |tag| end - c.define_tag 'image' do |tag| - image = layout.design.images.detect{ |i| i.file_identifier.eql?(parse_html_image(tag.expand)) } - image.update_attributes(:name => tag.attr['name'], :html_id => tag.attr['id'], :html_class => tag.attr['class']) if image + c.define_tag 'stylesheets' do |tag| end + c.define_tag 'title' do |tag| + end + end end From 4f741418a09516082210ea1138ee62495e9bda81 Mon Sep 17 00:00:00 2001 From: Christophe Vilayphiou Date: Thu, 22 Mar 2012 01:51:16 +0800 Subject: [PATCH 029/125] Trying nokogiri --- Gemfile | 1 + Gemfile.lock | 4 + app/controllers/application_controller.rb | 2 +- app/controllers/pages_controller.rb | 2 + app/helpers/application_helper.rb | 47 ++++++++++ app/models/design/layout.rb | 8 +- app/models/meta.rb | 4 + app/views/layouts/page_layout.html.erb | 17 ++++ lib/parsers/parser_front_end.rb | 105 ++++++++++++++-------- lib/parsers/parser_layout.rb | 57 +++++------- 10 files changed, 172 insertions(+), 75 deletions(-) create mode 100644 app/views/layouts/page_layout.html.erb diff --git a/Gemfile b/Gemfile index 024f3449..d1afdb8c 100644 --- a/Gemfile +++ b/Gemfile @@ -16,6 +16,7 @@ gem 'kaminari', :git => 'git://github.com/amatsuda/kaminari.git' gem 'mini_magick' gem 'mongoid' gem "mongo_session_store-rails3" +gem 'nokogiri' gem 'radius' gem 'rake' gem 'ruby-debug19' diff --git a/Gemfile.lock b/Gemfile.lock index 1df648c4..71742974 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -41,6 +41,7 @@ GEM archive-tar-minitar (0.5.2) arel (2.2.3) bcrypt-ruby (3.0.1) + bcrypt-ruby (3.0.1-x86-mingw32) brakeman (1.5.1) activesupport erubis (~> 2.6) @@ -115,6 +116,8 @@ GEM mongo (~> 1.3) tzinfo (~> 0.3.22) multi_json (1.1.0) + nokogiri (1.5.2) + nokogiri (1.5.2-x86-mingw32) orm_adapter (0.0.6) pdf-writer (1.1.8) color (>= 1.4.0) @@ -252,6 +255,7 @@ DEPENDENCIES mini_magick mongo_session_store-rails3 mongoid + nokogiri radius rails (>= 3.1.0, < 3.2.0) rake diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 4b433777..fb82774e 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -47,7 +47,7 @@ class ApplicationController < ActionController::Base # Render the page def render_page(id = nil) if @item - render :text => parse_page(@item, id) + render :text => process_page(@item, id), :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 8ea35391..4860ea2e 100644 --- a/app/controllers/pages_controller.rb +++ b/app/controllers/pages_controller.rb @@ -1,5 +1,7 @@ class PagesController < ApplicationController + include ApplicationHelper + before_filter :get_item, :only => [:index_from_link, :show_from_link] def index diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 50510e3c..9c03de3d 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -107,4 +107,51 @@ module ApplicationHelper end end + + def process_page(page, id) + parse_page_noko(page, id) + end + + def page_metas(page) + metas = '' + @site.page_metas.each do |meta| + name, content = meta.get_name_content + metas << "\n" + end rescue nil + return metas + end + + def page_title(page) + "#{page.title ? page.title[I18n.locale] : page.i18n_variable[I18n.locale]}\n" + end + + def page_stylesheets(page) + stylesheets = '' + stylesheets << "\n" + stylesheets << "\n" + stylesheets << "\n" + stylesheets << "\n" if page.design.reset_css + stylesheets << "\n" if page.design.default_css + theme = page.design.themes.detect{ |d| d.id == page.theme_id } + stylesheets << "\n" if theme + stylesheets + end + + def page_javascripts(page) + javascripts = '' + javascripts << "\n" + javascripts << "\n" + javascripts << "\n" + javascripts << "\n" + javascripts << "\n" + javascripts << "\n" + javascripts << "\n" + javascripts << "\n" + javascripts << "\n" + page.design.javascripts.each do |js| + # javascripts << "" + end + javascripts + end + end diff --git a/app/models/design/layout.rb b/app/models/design/layout.rb index e13498f3..bf48415c 100644 --- a/app/models/design/layout.rb +++ b/app/models/design/layout.rb @@ -2,6 +2,8 @@ class Layout < DesignFile include ParserLayout attr_reader :content + + field :body embeds_one :menu embedded_in :design @@ -17,8 +19,10 @@ class Layout < DesignFile Layout.count > 0 end - def parse_layout - parse_layout_contents(self) + def parse_layout + html = Nokogiri::HTML(self.file.read) + self.body = html.at_css("body").inner_html + parse_body(self) end end diff --git a/app/models/meta.rb b/app/models/meta.rb index 411a4f0c..dbeac167 100644 --- a/app/models/meta.rb +++ b/app/models/meta.rb @@ -7,5 +7,9 @@ class Meta field :value, :default => nil has_one :i18n_variable, :as => :language_value, :autosave => true, :dependent => :destroy + + def get_name_content + [self.key, self.value ? self.value : self.i18n_variable[I18n.locale]] + end end diff --git a/app/views/layouts/page_layout.html.erb b/app/views/layouts/page_layout.html.erb new file mode 100644 index 00000000..8fb884b0 --- /dev/null +++ b/app/views/layouts/page_layout.html.erb @@ -0,0 +1,17 @@ + + + + + <%= page_title(@item).html_safe %> + <%= page_metas(@item).html_safe %> + <%= @metas %> + + <%= page_stylesheets(@item).html_safe %> + <%= page_javascripts(@item).html_safe %> + + + <%= yield %> + + diff --git a/lib/parsers/parser_front_end.rb b/lib/parsers/parser_front_end.rb index 4b5a523f..8ea3840a 100644 --- a/lib/parsers/parser_front_end.rb +++ b/lib/parsers/parser_front_end.rb @@ -63,22 +63,6 @@ module ParserFrontEnd res << '>' end end - c.define_tag 'javascripts' do |tag| - res = '' - res << "" - res << "" - res << "" - res << "" - res << "" - res << "" - res << "" - res << "" - res << "" - page.design.javascripts.each do |js| - # res << "" - end - res - end c.define_tag 'language_bar' do @site.in_use_locales.map{ |locale| lang = I18nVariable.first(:conditions => {:key => locale})[locale] @@ -101,38 +85,87 @@ module ParserFrontEnd menu = page.design.layout.menu menu_level(home, 0, menu) end - c.define_tag 'meta' do |tag| - res = '' - #res << "" - end - c.define_tag 'stylesheets' do |tag| - res = '' - res << "" - res << "" - res << "" - res << "" if page.design.reset_css - res << " " if page.design.default_css - theme = page.design.themes.detect{ |d| d.id == page.theme_id } - res << "" if theme - res - end - c.define_tag 'title' do |tag| - "#{page.title ? page.title[I18n.locale] : page.i18n_variable[I18n.locale]}" - end end end def parse_page(page, id = nil) if page._type == 'Page' - layout_content = page.design.layout.content.force_encoding('UTF-8') rescue '' context = parser_context(page, {}, id) parser = Radius::Parser.new(context, :tag_prefix => 'r') - parser.parse(parser.parse(layout_content)) + parser.parse(parser.parse(page.design.layout.body)) end end def self.included(base) base.send :helper_method, :parse_page if base.respond_to? :helper_method end + + + + require 'nokogiri' + + def parse_page_noko(page, id = nil) + body = Nokogiri::HTML(page.design.layout.body, nil, 'UTF-8') + + # page_contents + 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 + when 'public_r_tag' + ret << "" + else + '' + end + 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 + + # page_menu + page_menu = body.css('.page_menu').first + home = get_homepage + menu = page.design.layout.menu + fragment = Nokogiri::HTML::DocumentFragment.new(body, menu_level(home, 0, menu)) + page_menu.swap(fragment) + + # page_image + 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 + image = page.design.images.detect{|image| image.name.eql?(page_image['name']) } unless image + if image + res = "' + end + fragment = Nokogiri::HTML::DocumentFragment.new(body, res) + page_image.swap(fragment) + end + + body.to_html + end end diff --git a/lib/parsers/parser_layout.rb b/lib/parsers/parser_layout.rb index 063078df..01d681ef 100644 --- a/lib/parsers/parser_layout.rb +++ b/lib/parsers/parser_layout.rb @@ -1,44 +1,27 @@ module ParserLayout - require 'radius' - include ParserCommon + require 'nokogiri' - def parse_layout_contents(layout) - content = layout.content.force_encoding('UTF-8') - context = parser_layout_contents(layout) - parser = Radius::Parser.new(context, :tag_prefix => 'r') - parser.parse(content) - end - - def parser_layout_contents(layout) - Radius::Context.new do |c| - c.define_tag 'ad_banner' do |tag| - end - c.define_tag 'content' do |tag| - layout.layout_parts.new(:name => tag.attr['name']) - end - c.define_tag 'image' do |tag| - image = layout.design.images.detect{ |i| i.file_identifier.eql?(parse_html_image(tag.expand)) } - image.update_attributes(:name => tag.attr['name'], :html_id => tag.attr['id'], :html_class => tag.attr['class']) if image - end - c.define_tag 'javascripts' do |tag| - end - c.define_tag 'menu' do |tag| - layout.build_menu(:levels => 0, :values => {}) unless layout.menu - layout.menu.levels = i = tag.attr['level'].to_i - layout.menu.values.merge!({'home' => tag.attr['home']}) if i == 1 - layout.menu.values.merge!({"id_#{i}" => tag.attr['id'], "class_#{i}" => tag.attr['class'], "li_class_#{i}" => tag.attr['li_class'], "li_incremental_#{i}" => tag.attr['li_incremental']}) - tag.expand - end - c.define_tag 'meta' do |tag| - end - c.define_tag 'stylesheets' do |tag| - end - c.define_tag 'title' do |tag| - end + def parse_body(layout) + body = Nokogiri::HTML(layout.body) + body.css('.page_content').each do |content| + layout.layout_parts.build(:name => content['name']) end + + body.css('.page_image').each do |image| + image = layout.design.images.detect{ |i| i.file_identifier.eql?(parse_html_image(image.to_html)) } + image.update_attributes(:name => image['name'], :html_id => image['id'], :html_class => image['class']) if image + end + + body.css('.page_menu').each do |menu| + layout.build_menu(:levels => 0, :values => {}) unless layout.menu + layout.menu.levels = i = menu['level'].to_i + layout.menu.values.merge!({'home' => menu['home']}) if i == 1 + layout.menu.values.merge!({"id_#{i}" => menu['id'], "class_#{i}" => menu['class'], "li_class_#{i}" => menu['li_class'], "li_incremental_#{i}" => menu['li_incremental']}) + end + end - + def parse_html_image(html) html.scan(/(?<=\)/){ $1.gsub(' ','').scan(/(?<=src=\")(.*?)(?=\")/){ @@ -46,4 +29,6 @@ module ParserLayout } } end + + end From b109410a7aeb456f01bbd529e5eb1c6a2f2ef63f Mon Sep 17 00:00:00 2001 From: Christophe Vilayphiou Date: Thu, 22 Mar 2012 10:11:02 +0800 Subject: [PATCH 030/125] Add ad_banner to nokogiri --- lib/parsers/parser_front_end.rb | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/lib/parsers/parser_front_end.rb b/lib/parsers/parser_front_end.rb index 8ea3840a..529802ff 100644 --- a/lib/parsers/parser_front_end.rb +++ b/lib/parsers/parser_front_end.rb @@ -105,7 +105,7 @@ module ParserFrontEnd require 'nokogiri' def parse_page_noko(page, id = nil) - body = Nokogiri::HTML(page.design.layout.body, nil, 'UTF-8') + body = Nokogiri::HTML(page.design.layout.body) # page_contents body.css('.page_content').each do |content| @@ -165,6 +165,29 @@ module ParserFrontEnd page_image.swap(fragment) end + # ad_banner + body.css('ad_banner').each do |banner| + res = '' + ad_banner = AdBanner.find(banner["id"]) rescue nil + if ad_banner && ad_banner.display? + res << "" + res << "
    " + ad_banner.ad_images.each do |ad_image| + res << "" + end + res << "
    " + end + fragment = Nokogiri::HTML::DocumentFragment.new(body, res) + banner.swap(fragment) + end + body.to_html end From 34a4e47057730bb59f62b0d3570af5e84e04330e Mon Sep 17 00:00:00 2001 From: Matt Fu Date: Thu, 22 Mar 2012 14:33:59 +0800 Subject: [PATCH 031/125] Fact check program completed,Lin checked --- Gemfile.lock | 1 + app/models/object_auth.rb | 2 +- app/views/layouts/_side_bar.html.erb | 3 +- lib/orbit_core_lib.rb | 16 ++++-- .../back_end/bulletin_categorys_controller.rb | 2 +- .../back_end/bulletins_controller.rb | 51 +++++++++---------- .../back_end/fact_checks_controller.rb | 2 +- .../front_end/bulletins_controller.rb | 6 +-- .../widget/bulletins_controller.rb | 8 +-- .../announcement/app/models/bulletin.rb | 48 +++++++++-------- .../back_end/bulletins/_bulletin.html.erb | 10 +++- .../bulletins/_bulletin_link_qe.html.erb | 3 +- .../back_end/bulletins/_form.html.erb | 4 ++ .../widget/bulletins/index.html.erb | 1 - 14 files changed, 91 insertions(+), 66 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 1df648c4..ef54f585 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -41,6 +41,7 @@ GEM archive-tar-minitar (0.5.2) arel (2.2.3) bcrypt-ruby (3.0.1) + bcrypt-ruby (3.0.1-x86-mingw32) brakeman (1.5.1) activesupport erubis (~> 2.6) diff --git a/app/models/object_auth.rb b/app/models/object_auth.rb index 8932bb76..ae3fd701 100644 --- a/app/models/object_auth.rb +++ b/app/models/object_auth.rb @@ -1,6 +1,6 @@ class ObjectAuth < PrototypeAuth include OrbitCoreLib::ObjectTokenUnility - validates_uniqueness_of :obj_authable_type,:scope => :title #{ |c| } + validates_uniqueness_of :title ,:scope => [:obj_authable_type,:obj_authable_id] #{ |c| } belongs_to :obj_authable, polymorphic: true # > - Something.find_with_auth(query) # > - or Something.find(query).auth diff --git a/app/views/layouts/_side_bar.html.erb b/app/views/layouts/_side_bar.html.erb index 71e8106d..baeef6c4 100644 --- a/app/views/layouts/_side_bar.html.erb +++ b/app/views/layouts/_side_bar.html.erb @@ -9,8 +9,9 @@ <%= content_tag :li, link_to(t('admin.add_new'), new_panel_announcement_back_end_bulletin_path), :class => active_for_action('bulletins', 'new') %> <%= content_tag :li, link_to(t('admin.categories'), panel_announcement_back_end_bulletin_categorys_path), :class => active_for_action('bulletin_categorys', 'index') %> <%= content_tag :li, link_to(t('admin.tags'), panel_announcement_back_end_tags_path), :class => active_for_action('tags', 'index') %> - <%= content_tag :li, link_to(t('announcement.bulletin.fact_check_setting'), panel_announcement_back_end_fact_checks_setting_path), :class => active_for_action('tags', 'index') %> + <%= content_tag :li, link_to(t('announcement.bulletin.fact_check_setting'), panel_announcement_back_end_fact_checks_setting_path), :class => active_for_action('tags', 'index') if is_manager? %> <% end -%> + <% end -%> <%= content_tag :li, :class => active_for_controllers('users') do -%> diff --git a/lib/orbit_core_lib.rb b/lib/orbit_core_lib.rb index 561fceba..bcde17e0 100644 --- a/lib/orbit_core_lib.rb +++ b/lib/orbit_core_lib.rb @@ -21,11 +21,19 @@ module OrbitCoreLib def authed_users(title=nil) users = [] - unless title.nil? - users = self.object_auths.where(title: title )[0].auth_users_after_block_list rescue [] + users = case title + when :all + ary = self.object_auths.collect{|t| t.auth_users} + ary.flatten! + when nil + if self.object_auths.count ==1 + self.object_auths.first.auth_users_after_block_list rescue [] + else + logger.info "Warning calling a auth commend without specificed value( has multi-auths ), return empty" + [] + end else - users = self.object_auths.collect{|t| t.auth_users_after_block_list} rescue [] - users.flatten!.uniq! + self.object_auths.where(title: title).first.auth_users rescue [] end users end diff --git a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletin_categorys_controller.rb b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletin_categorys_controller.rb index 92bf922f..cb70aaf7 100644 --- a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletin_categorys_controller.rb +++ b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletin_categorys_controller.rb @@ -1,4 +1,4 @@ -class Panel::Announcement::BackEnd::BulletinCategorysController < ApplicationController +class Panel::Announcement::BackEnd::BulletinCategorysController < OrbitBackendController layout 'new_admin' diff --git a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletins_controller.rb b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletins_controller.rb index 0eda0723..2e6f90b0 100644 --- a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletins_controller.rb +++ b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletins_controller.rb @@ -110,40 +110,39 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController def link_quick_edit # debugger - - @bulletin = Bulletin.find(params[:bulletin_id]) - - @link_url = panel_announcement_back_end_bulletin_path(@bulletin) - - respond_to do |format| - format.js - end - + @bulletin = Bulletin.find(params[:bulletin_id]) + unless @bulletin.is_expired? + @link_url = panel_announcement_back_end_bulletin_path(@bulletin) + respond_to do |format| + format.js + end + end end # PUT /bulletins/1 # PUT /bulletins/1.xml def update @bulletin = Bulletin.find(params[:id]) + unless @bulletin.is_expired? + @bulletin.update_user_id = current_user.id - @bulletin.update_user_id = current_user.id - - # @bulletin.image.clear if params[:bulletin][:image_del] == '1' - # if params[:bulletin][:image_del] == '1' - # @bulletin.remove_image! - # @bulletin.image_del = nil - # params[:bulletin][:image_del] = nil - # end + # @bulletin.image.clear if params[:bulletin][:image_del] == '1' + # if params[:bulletin][:image_del] == '1' + # @bulletin.remove_image! + # @bulletin.image_del = nil + # params[:bulletin][:image_del] = nil + # end - respond_to do |format| - if @bulletin.update_attributes(params[:bulletin]) && @bulletin.save - # format.html { redirect_to(panel_announcement_back_end_bulletin_url(@bulletin), :notice => t('bulletin.update_bulletin_success')) } - format.html { redirect_to(panel_announcement_back_end_bulletins_url, :notice => t('bulletin.update_bulletin_success')) } - format.js { render 'toggle_enable' } - format.xml { head :ok } - else - format.html { render :action => "edit" } - format.xml { render :xml => @bulletin.errors, :status => :unprocessable_entity } + respond_to do |format| + if @bulletin.update_attributes(params[:bulletin]) && @bulletin.save + # format.html { redirect_to(panel_announcement_back_end_bulletin_url(@bulletin), :notice => t('bulletin.update_bulletin_success')) } + format.html { redirect_to(panel_announcement_back_end_bulletins_url, :notice => t('bulletin.update_bulletin_success')) } + format.js { render 'toggle_enable' } + format.xml { head :ok } + else + format.html { render :action => "edit" } + format.xml { render :xml => @bulletin.errors, :status => :unprocessable_entity } + end end end end diff --git a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/fact_checks_controller.rb b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/fact_checks_controller.rb index c47e91fb..9095a4d3 100644 --- a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/fact_checks_controller.rb +++ b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/fact_checks_controller.rb @@ -18,7 +18,7 @@ class Panel::Announcement::BackEnd::FactChecksController < OrbitBackendControll else first_category = @bulletin_categorys.first end - preload_object_auth = first_category.object_auths.where(title: 'fact_check') || (first_category.object_auths.create :title=> 'fact_check') + preload_object_auth = first_category.object_auths.where(title: 'fact_check').empty?? (first_category.object_auths.create! :title=> 'fact_check') : first_category.object_auths.where(title: 'fact_check') @users_array = preload_object_auth.first.privilege_users rescue [] respond_to do |format| format.html diff --git a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/front_end/bulletins_controller.rb b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/front_end/bulletins_controller.rb index ff3cbdc9..fe0b2aa5 100644 --- a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/front_end/bulletins_controller.rb +++ b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/front_end/bulletins_controller.rb @@ -12,9 +12,9 @@ class Panel::Announcement::FrontEnd::BulletinsController < OrbitWidgetController date_now = Time.now if params[:category_id] - @bulletins = Bulletin.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) else - @bulletins = Bulletin.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]).per(10) end get_categorys @@ -23,7 +23,7 @@ class Panel::Announcement::FrontEnd::BulletinsController < OrbitWidgetController end def show - @bulletin = Bulletin.find(params[:id]) + @bulletin = Bulletin.can_display.where.where(_id: params[:id]) get_categorys end 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 60aad3d9..783ee9ef 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 @@ -14,9 +14,9 @@ class Panel::Announcement::Widget::BulletinsController < OrbitWidgetController # @bulletin_categorys = BulletinCategory.first; # @bulletins = Bulletin.widget_datas(@bulletin_categorys.id).limit(9) if params[:category_id] - @bulletins = Bulletin.where(:bulletin_category_id => params[:category_id]).widget_datas.limit(9) + @bulletins = Bulletin.can_display.where(:bulletin_category_id => params[:category_id]).widget_datas.limit(9) else - @bulletins = Bulletin.widget_datas.limit(9) + @bulletins = Bulletin.can_display.widget_datas.limit(9) end get_categorys @@ -26,14 +26,14 @@ class Panel::Announcement::Widget::BulletinsController < OrbitWidgetController def bulletins_and_web_links @tags = AnnouncementTag.all @selected_tag = AnnouncementTag.find(params[:id]) rescue @tags[0] - @bulletins = @selected_tag.get_visible_bulletins.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 render :layout => 'module_widget' end def reload_bulletins @selected_tag = AnnouncementTag.find(params[:tag_id]) - @bulletins = @selected_tag.get_visible_bulletins.page(params[:page]).per(5) rescue nil + @bulletins = @selected_tag.get_visible_bulletins.can_display.page(params[:page]).per(5) rescue nil end def reload_web_links diff --git a/vendor/built_in_modules/announcement/app/models/bulletin.rb b/vendor/built_in_modules/announcement/app/models/bulletin.rb index d1b7f3c5..e24f7f21 100644 --- a/vendor/built_in_modules/announcement/app/models/bulletin.rb +++ b/vendor/built_in_modules/announcement/app/models/bulletin.rb @@ -19,12 +19,14 @@ class Bulletin field :is_top, :type => Boolean, :default => false field :is_hot, :type => Boolean, :default => false field :is_hidden, :type => Boolean, :default => false - field :is_checked, :type => Boolean, :default => false + field :is_checked, :type => Boolean, :default => nil field :not_checked_reason field :public, :type => Boolean, :default => true + scope :can_display,where(is_checked: true) + mount_uploader :image, ImageUploader belongs_to :bulletin_category @@ -47,28 +49,17 @@ class Bulletin def self.search( search = nil, category_id = nil ) - - if category_id.to_s.size > 0 and search.to_s.size > 0 - + if category_id.to_s.size > 0 and search.to_s.size > 0 key = /#{search}/ - - find(:all, :conditions => {title: key, bulletin_category_id: category_id}).desc( :is_top, :postdate ) - - elsif category_id.to_s.size > 0 and search.to_s.size < 1 - - find(:all, :conditions => {bulletin_category_id: category_id}).desc( :is_top, :postdate ) - - elsif search.to_s.size > 0 and category_id.to_s.size < 1 - + find(:all, :conditions => {title: key, bulletin_category_id: category_id}).desc( :is_top, :postdate ) + elsif category_id.to_s.size > 0 and search.to_s.size < 1 + find(:all, :conditions => {bulletin_category_id: category_id}).desc( :is_top, :postdate ) + elsif search.to_s.size > 0 and category_id.to_s.size < 1 key = /#{search}/ - - find(:all, :conditions => {title: key}).desc( :is_top, :postdate ) - else - - find(:all).desc( :is_top, :postdate) - - end - + find(:all, :conditions => {title: key}).desc( :is_top, :postdate ) + else + find(:all).desc( :is_top, :postdate) + end end @@ -87,7 +78,11 @@ class Bulletin end end - + + def is_expired? + Date.today > self.deadline ? true : false rescue false + #some dates might sat as nil so rescue false + end def is_top? self.is_top @@ -101,6 +96,15 @@ class Bulletin self.is_hidden end + def is_checked? + self.is_checked + end + + def is_check_rejected? + self.is_checked == false + end + + def save_bulletin_links self.bulletin_links.each do |t| if t.should_destroy diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletin.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletin.html.erb index e12af233..c0a9cee6 100644 --- a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletin.html.erb +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletin.html.erb @@ -10,8 +10,10 @@ <% if bulletin.is_hidden? %> <%= t(:hidden) %> <% end %> +
    - + <%#= debugger %> + <%#= a=1 %> + <% if (bulletin.bulletin_category.authed_users('fact_check').include?(current_user) or is_manager?) and !bulletin.is_expired? %>
  • <%= link_to t('bulletin.fact_check'), edit_panel_announcement_back_end_bulletin_path(bulletin) %>
  • <%#= #TODO add ancher so user can quick access into that part %> + <% end %> + <% end %> +
    + <%= bulletin.bulletin_category.i18n_variable[I18n.locale] %> <%= link_to bulletin.title[I18n.locale], panel_announcement_back_end_bulletin_path(bulletin) rescue ''%> diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletin_link_qe.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletin_link_qe.html.erb index 7208f73c..55ea8e8c 100644 --- a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletin_link_qe.html.erb +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletin_link_qe.html.erb @@ -1,6 +1,7 @@ <% # encoding: utf-8 %> - <%= form_for(@bulletin.bulletin_links, :remote => true, :url => @link_url) do |f| %> + + <%= form_for(@bulletin.bulletin_links, :remote => true, :url => @link_url) do |f| %> diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/show.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/show.html.erb index 5a33b86a..30cbbb56 100644 --- a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/show.html.erb +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/show.html.erb @@ -1,7 +1,3 @@ -<% content_for :secondary do %> -<%= render :partial => '/panel/announcement/back_end/announcement_secondary' %> -<% end -%> - <%= flash_messages %>
    From 422a49f56c50533807d7208068a416f589a37b77 Mon Sep 17 00:00:00 2001 From: Christophe Vilayphiou Date: Tue, 27 Mar 2012 15:03:00 +0800 Subject: [PATCH 043/125] Ray's changes in announcenment back-end --- app/assets/fonts/widget.css | 8 ++-- app/assets/javascripts/bootstrap.js | 3 +- app/assets/javascripts/orbit-1.0.js | 21 +++++++++- app/assets/stylesheets/bootstrap-orbit.css | 2 +- app/assets/stylesheets/list.css | 31 ++++++++++---- app/assets/stylesheets/reset.css.erb | 1 - app/assets/stylesheets/style.css.erb | 2 - app/assets/stylesheets/widget.css | 4 +- .../back_end/bulletins/_bulletin.html.erb | 20 ++++++---- .../back_end/bulletins/_bulletins.html.erb | 14 ++++++- .../back_end/bulletins/_filter.html.erb | 40 +++++++++++++++++++ .../back_end/bulletins/_form.html.erb | 27 ++++++++++--- .../back_end/bulletins/edit.html.erb | 17 ++++---- .../back_end/bulletins/new.html.erb | 4 +- 14 files changed, 150 insertions(+), 44 deletions(-) diff --git a/app/assets/fonts/widget.css b/app/assets/fonts/widget.css index 0c596876..fe83b22d 100644 --- a/app/assets/fonts/widget.css +++ b/app/assets/fonts/widget.css @@ -45,10 +45,10 @@ opacity: 1; filter: alpha(opacity=100); cursor: pointer; -} -.select-role { - display:none; - overflow:hidden; +} +.select-role { + display:none; + padding: 10px 0 0; } .file-upload { position:relative; diff --git a/app/assets/javascripts/bootstrap.js b/app/assets/javascripts/bootstrap.js index b822d62b..f1b88f8d 100644 --- a/app/assets/javascripts/bootstrap.js +++ b/app/assets/javascripts/bootstrap.js @@ -1251,7 +1251,8 @@ var that = this , complete = function () { if (startEvent == 'show') that.reset() - that.$element.trigger(completeEvent) + that.$element.trigger(completeEvent) + mainTablePosition(); } this.$element diff --git a/app/assets/javascripts/orbit-1.0.js b/app/assets/javascripts/orbit-1.0.js index f8daaecd..520473f6 100644 --- a/app/assets/javascripts/orbit-1.0.js +++ b/app/assets/javascripts/orbit-1.0.js @@ -49,6 +49,25 @@ $(document).ready(function(){ $(document).on('click', '.sort-header > .sort', function() { $.getScript($(this).attr('rel')); }); + + + var $role = $('.select-role'); + var method =$('.privacy:eq(1)').attr('checked'); + if(method == 'checked'){ + $role.slideDown(0); + } + $('.privacy').each(function($i) { + $(this).click(function() { + switch ($i) { + case 0: + $role.slideUp(300); + break; + case 1: + $role.slideDown(300); + break; + } + }); + }); /*tinyscrollbar&windows-Size*/ resize(); @@ -86,7 +105,7 @@ function mainTablePosition() { var $height = $('#main-wrap > .subnav').height() var $table = $('#main-wrap > .table') //alert ($table.height()) - $table.stop().animate({marginTop:$height},500) + $table.stop().animate({marginTop:$height-17},500) //$table.css({marginTop : $height}) } $(window).scroll(function () { diff --git a/app/assets/stylesheets/bootstrap-orbit.css b/app/assets/stylesheets/bootstrap-orbit.css index 88bca1b3..eede71d4 100644 --- a/app/assets/stylesheets/bootstrap-orbit.css +++ b/app/assets/stylesheets/bootstrap-orbit.css @@ -98,7 +98,7 @@ h1, h2, h3, h4, h5, h6 { border-radius: 0 0 4px 4px; } table .span1-2 { - width: 94px; + min-width: 85px; float: none; margin-left: 0; } diff --git a/app/assets/stylesheets/list.css b/app/assets/stylesheets/list.css index ccf35f24..b4becb42 100644 --- a/app/assets/stylesheets/list.css +++ b/app/assets/stylesheets/list.css @@ -9,9 +9,9 @@ .main-list { margin-bottom: 0; } -.main-list thead th { - background-color: rgba(0,0,0,0.05); - border-right: 1px solid #ddd; +.main-wrap>.main-list thead th { + background-color: transparent; + border-right: medium none; } .main-list thead th:last-child { border-right: none; @@ -29,19 +29,22 @@ } .main-list tbody .quick-edit { position:relative; - height:40px; + height:20px; } .main-list tbody .quick-edit .nav { /*left: -55px;*/ position: absolute; /*top: -3px;*/ width: 350px; + left: -8px; } .main-list td { - /*height:80px;*/ + background-color: #FFFFFF; + border-bottom: 1px solid #DDDDDD; + border-top: medium none; } .main-list .nav { - margin-top: 15px; + margin-top: 0; margin-bottom: 3px; } .main-list tr.with_action:hover .hide { @@ -53,7 +56,7 @@ } .main-list .label-td { background-color: rgba(255, 255, 255, 1); - height: 60px; + height: 40px; overflow: hidden; position: absolute; width: 100%; @@ -74,6 +77,15 @@ -webkit-border-radius: 3px; -moz-border-radius: 3px; z-index: 5; +} +.table-label { + background-color: #F2F2F2; + position: relative; +} +.table-label .main-list thead th { + background-color: #F2F2F2; + border-right: 1px solid #DDDDDD; + border-top: 1px solid #DDDDDD !important; } .route-group .route { padding: 0; @@ -108,7 +120,10 @@ legend { -webkit-border-radius: 0; border-radius: 0; border-left: none; - border-right: none; + border-right: none; + position: fixed; + top: 30px; + z-index: 50; } .subnav .nav > li:first-child > a, .subnav .nav > li:first-child > a:hover { -moz-border-radius: 0; diff --git a/app/assets/stylesheets/reset.css.erb b/app/assets/stylesheets/reset.css.erb index 0d91f32a..5c0a9cd5 100644 --- a/app/assets/stylesheets/reset.css.erb +++ b/app/assets/stylesheets/reset.css.erb @@ -2,7 +2,6 @@ html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockq -webkit-text-size-adjust:none; } html, body{ - background: url(<%= asset_path 'background.jpg' %>) repeat left top; height: 100%; } /*芸*/ diff --git a/app/assets/stylesheets/style.css.erb b/app/assets/stylesheets/style.css.erb index beae5a8e..2e203a02 100644 --- a/app/assets/stylesheets/style.css.erb +++ b/app/assets/stylesheets/style.css.erb @@ -350,8 +350,6 @@ border-top: none; } #post-body .editor { - background-color: #333333; - height: 20px; margin: 8px 0; width: 100%; } diff --git a/app/assets/stylesheets/widget.css b/app/assets/stylesheets/widget.css index b66a6074..b0e3568d 100644 --- a/app/assets/stylesheets/widget.css +++ b/app/assets/stylesheets/widget.css @@ -58,8 +58,8 @@ cursor: pointer; } .select-role { - display:none; - overflow:hidden; + display:none; + padding: 10px 0; } .file-upload { position:relative; diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletin.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletin.html.erb index 64355320..0ae522cb 100644 --- a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletin.html.erb +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletin.html.erb @@ -10,7 +10,10 @@ <% if bulletin.is_hidden? %> <%= t(:hidden) %> <% end %> - + + <%= bulletin.bulletin_category.i18n_variable[I18n.locale] %> + + <%= link_to bulletin.title[I18n.locale], panel_announcement_front_end_bulletin_path(bulletin, :category_id => bulletin.bulletin_category.id) rescue ''%>
    - - <%= bulletin.bulletin_category.i18n_variable[I18n.locale] %> - <%= link_to bulletin.title[I18n.locale], panel_announcement_front_end_bulletin_path(bulletin, :category_id => bulletin.bulletin_category.id) rescue ''%> <%= bulletin.postdate %> <%= (bulletin.deadline) ? bulletin.deadline : t('bulletin.no_deadline') %> - <% bulletin.sorted_tags.each do |tag| %> - <%= tag[I18n.locale] %> - <% end %> +
    +
    + <% bulletin.sorted_tags.each do |tag| %> + <%= tag[I18n.locale] %> + <% end %> +
    +
    <%= User.from_id(bulletin.update_user_id).name rescue ''%> @@ -54,4 +58,4 @@ -<% end %> \ No newline at end of file +<% end %> diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletins.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletins.html.erb index bbe383bc..979f3f4a 100644 --- a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletins.html.erb +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletins.html.erb @@ -1,4 +1,4 @@ - + + + + + + + + + + + + <%= render :partial => 'bulletin', :collection => @bulletins %> diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_filter.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_filter.html.erb index 5b078391..09222a36 100644 --- a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_filter.html.erb +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_filter.html.erb @@ -53,5 +53,45 @@ Clear/蝵
    +
    + + + + + + + + + + + + + +
    + + + + <%= t('bulletin.status') %> + <%= content_tag(:b, nil, :class => is_sort?('status')) %> + + <%= t('bulletin.category') %> + <%= content_tag(:b, nil, :class => is_sort?('category')) %> + + <%= t('bulletin.title') %> + <%= content_tag(:b, nil, :class => is_sort?('title')) %> + + <%= t('bulletin.start_date') %> + <%= content_tag(:b, nil, :class => is_sort?('postdate')) %> + + <%= t('bulletin.end_date') %> + <%= content_tag(:b, nil, :class => is_sort?('deadline')) %> + + <%= t('bulletin.tags') %> + <%= content_tag(:b, nil, :class => is_sort?('tags')) %> + + <%= t('bulletin.last_modified') %> + <%= content_tag(:b, nil, :class => is_sort?('update_user_id')) %> +
    +
    \ No newline at end of file diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_form.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_form.html.erb index 27ad1df1..9b2d3557 100644 --- a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_form.html.erb +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_form.html.erb @@ -3,13 +3,16 @@ <%= f.error_messages %>
    + <% if params[:action] != 'new' %>
    +

    Audit

    - <% if is_manager? || @bulletin.bulletin_category.authed_users('fact_check').include?(current_user) || current_user.admin?%> + + <% if is_manager? || @bulletin.bulletin_category.authed_users('fact_check').include?(current_user) || current_user.admin? %>
    <%= f.label :fact_check_stat, t('announcement.bulletin.fact_check_stat') %> <%= content_tag :label,:class => "radio inline" do -%> @@ -29,6 +32,7 @@ <% end %>
    + <% end %>
    @@ -84,9 +88,18 @@

    Status

    - <%= f.check_box :is_top %><%= t('top') %> - <%= f.check_box :is_hot %><%= t('hot') %> - <%= f.check_box :is_hidden %><%= t('hide') %> + <%= content_tag :label,:class => "checkbox inline" do -%> + <%= f.check_box :is_top %> + <%= t('top') %> + <% end -%> + <%= content_tag :label,:class => "checkbox inline" do -%> + <%= f.check_box :is_hot %> + <%= t('hot') %> + <% end -%> + <%= content_tag :label,:class => "checkbox inline" do -%> + <%= f.check_box :is_hidden %> + <%= t('hide') %> + <% end -%>
    @@ -98,8 +111,10 @@

    Tags

    <% @tags.each do |tag| %> - <%= check_box_tag 'bulletin[tag_ids][]', tag.id, @bulletin.tag_ids.include?(tag.id)%> - <%= tag[I18n.locale] %> + <%= content_tag :label,:class => "checkbox inline" do -%> + <%= check_box_tag 'bulletin[tag_ids][]', tag.id, @bulletin.tag_ids.include?(tag.id)%> + <%= tag[I18n.locale] %> + <% end %> <% end %>
    diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/edit.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/edit.html.erb index 56cfd258..c448c6a1 100644 --- a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/edit.html.erb +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/edit.html.erb @@ -1,7 +1,10 @@ -

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

    - -<%= form_for @bulletin, :url => panel_announcement_back_end_bulletin_path(@bulletin), :html => {:class => 'clear'} do |f| %> - <%= render :partial => 'form', :locals => {:f => f} %> -<% end %> - -<%= link_back %> + +
    + <%= form_for @bulletin, :url => panel_announcement_back_end_bulletin_path(@bulletin), :html => {:class => 'clear'} do |f| %> + <%= render :partial => 'form', :locals => {:f => f} %> + <% end %> +
    \ No newline at end of file diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/new.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/new.html.erb index 74e1291a..33a1e609 100644 --- a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/new.html.erb +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/new.html.erb @@ -1,5 +1,5 @@ +
    <%= form_for @bulletin, :url => panel_announcement_back_end_bulletins_path do |f| %> <%= render :partial => 'form', :locals => {:f => f} %> <% end %> - -<%= link_back %> +
    \ No newline at end of file From 436c866a6fb95e219222384d8cfa60deee29cf70 Mon Sep 17 00:00:00 2001 From: Christophe Vilayphiou Date: Tue, 27 Mar 2012 15:10:29 +0800 Subject: [PATCH 044/125] admin now can post without fact check --- .../views/panel/announcement/back_end/bulletins/_form.html.erb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_form.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_form.html.erb index 9b2d3557..6815205c 100644 --- a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_form.html.erb +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_form.html.erb @@ -32,6 +32,8 @@ <% end %>
    + <% elsif current_user.admin? %> + <%= f.hidden_field :is_checked,:value => true%> <% end %>
    From 1451c3ac1d70e873a91fc45e07c2b837d2adde6d Mon Sep 17 00:00:00 2001 From: "Matthew K. Fu JuYuan" Date: Tue, 27 Mar 2012 15:34:21 +0800 Subject: [PATCH 045/125] changing to new admin_layout --- app/views/admin/ad_banners/_ad_banner.html.erb | 11 +++++++++++ .../back_end/bulletin_links_controller-複製.rb | 14 -------------- 2 files changed, 11 insertions(+), 14 deletions(-) create mode 100644 app/views/admin/ad_banners/_ad_banner.html.erb delete mode 100644 vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletin_links_controller-複製.rb diff --git a/app/views/admin/ad_banners/_ad_banner.html.erb b/app/views/admin/ad_banners/_ad_banner.html.erb new file mode 100644 index 00000000..787a03ed --- /dev/null +++ b/app/views/admin/ad_banners/_ad_banner.html.erb @@ -0,0 +1,11 @@ + + + <%= location %> + + > + + <%= link_to (ad_image.picture_intro || t("untitled")),'' %> + <%= start_date %> + <%= end_date.nil?? t('form.date_unlimited'): end_date %> + <%= style %> + \ No newline at end of file diff --git a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletin_links_controller-複製.rb b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletin_links_controller-複製.rb deleted file mode 100644 index 04a75fa6..00000000 --- a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletin_links_controller-複製.rb +++ /dev/null @@ -1,14 +0,0 @@ -class Panel::Announcement::BackEnd::BulletinLinksController < ApplicationController - - layout 'new_admin' - - def index - @bulletin_links = BulletinLink.all - - respond_to do |format| - format.html # index.html.erb - # format.xml { render :xml => @bulletins } - format.js - end - -end From 48d1d45ced0f8481f25876fb847c9a713544ef11 Mon Sep 17 00:00:00 2001 From: Christophe Vilayphiou Date: Tue, 27 Mar 2012 17:57:50 +0800 Subject: [PATCH 046/125] Nokogiri in parsers --- app/views/admin/pages/_show.html.erb | 6 +- lib/parsers/parser_back_end.rb | 190 ++++++++++----------------- lib/parsers/parser_common.rb | 52 ++++++++ lib/parsers/parser_front_end.rb | 183 +++++--------------------- 4 files changed, 162 insertions(+), 269 deletions(-) diff --git a/app/views/admin/pages/_show.html.erb b/app/views/admin/pages/_show.html.erb index 1937fe92..ba9bcf48 100644 --- a/app/views/admin/pages/_show.html.erb +++ b/app/views/admin/pages/_show.html.erb @@ -1,3 +1,7 @@ <%= flash_messages %> -<%= parse_page_edit(@item).html_safe %> \ No newline at end of file + +<%= page_stylesheets(@item).html_safe %> +<%= page_javascripts(@item).html_safe %> + +<%= parse_page_edit_noko(@item).html_safe %> \ No newline at end of file diff --git a/lib/parsers/parser_back_end.rb b/lib/parsers/parser_back_end.rb index 787f579b..3e641118 100644 --- a/lib/parsers/parser_back_end.rb +++ b/lib/parsers/parser_back_end.rb @@ -1,132 +1,86 @@ module ParserBackEnd - require 'radius' include ParserCommon - - def parse_page_edit(page) - if page._type == 'Page' - layout_content = page.design.layout.content.force_encoding('UTF-8') rescue '' - context = parser_context_edit(page) - parser = Radius::Parser.new(context, :tag_prefix => 'r') - parser.parse(parser.parse(layout_content)) + + require 'nokogiri' + + # c.define_tag 'language_bar' do + # @site.in_use_locales.map{ |locale| + # lang = I18nVariable.first(:conditions => {:key => locale})[locale] + # if I18n.locale.to_s.eql?(locale) + # lang + # else + # "#{lang}" + # end + # }.join(' | ') + # end + # c.define_tag 'link' do |tag| + # item = Item.first(:conditions => { :full_name => tag.attr['name'] }) + # ret = '' + # ret << "" + # ret << item.i18n_variable[I18n.locale] + # ret << "" + # end + + def parse_page_edit_noko(page, id = nil) + body = Nokogiri::HTML(page.design.layout.body) + parse_menu(body, page, true) + public_r_tags = parse_contents(body, page, id) + parse_images(body, page) + + public_r_tags.each do |tag| + send("parse_#{tag}s", body, page,id) end + + body.to_html end - - def parser_context_edit(page, attributes = {}) - Radius::Context.new do |c| - c.define_tag 'ad_banner' do |tag| - res = '' - ad_banner = AdBanner.find(tag.attr["id"]) rescue nil - if ad_banner - res << "" - res << "
    " - ad_banner.ad_images.each do |ad_image| - res << "" - end - res << "
    " - end - end - c.define_tag 'content' do |tag| - ret = '' - if (tag.attributes["main"] == "true" && !page.module_app.nil?) - ret << "
    " - else - part = page.page_parts.detect{ |p| p.name.to_s == tag.attr['name'].to_s } - ret << "
    " - ret << "' - case part.kind - when 'text' - ret << part.i18n_variable[I18n.locale] rescue '' - when 'module_widget' - if part[:category] - ret << "
    " - else - ret << "
    " - end - when 'public_r_tag' - ret << "" - else - '' - end - ret << '
    ' - end - end - c.define_tag 'image' do |tag| - # 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.images.detect{|image| image.name.eql?(tag.attr['name']) } unless image - if image - res = "' - end - end - c.define_tag 'javascripts' do |tag| - res = '' - res << "" - res << "" - res << "" - res << "" - page.design.javascripts.each do |js| - res << "" - end - res - end - c.define_tag 'language_bar' do - @site.in_use_locales.map{ |locale| - lang = I18nVariable.first(:conditions => {:key => locale})[locale] - if I18n.locale.to_s.eql?(locale) - lang + + # page_contents + def parse_contents(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 << "
    " + ret << "' + case part.kind + when 'text' + ret << part.i18n_variable[I18n.locale] rescue '' + when 'module_widget' + if part[:category] + ret << "
    " else - "#{lang}" + ret << "
    " end - }.join(' | ') + when 'public_r_tag' + ret << "" + public_r_tags << part.public_r_tag + else + '' + end end - c.define_tag 'link' do |tag| - item = Item.first(:conditions => { :full_name => tag.attr['name'] }) - ret = '' - ret << "" - ret << item.i18n_variable[I18n.locale] - ret << "" - end - c.define_tag 'menu' do |tag| - home = get_homepage - menu = page.design.layout.menu - menu_level(home, 0, menu, true) - end - c.define_tag 'meta' do |tag| - "" - end - c.define_tag 'stylesheets' do |tag| - res = '' - res << "" if page.design.reset_css - res << "" if page.design.default_css - theme = page.design.themes.detect{ |d| d.id == page.theme_id } - res << "" if theme - res - end - c.define_tag 'title' do |tag| - "#{page.title ? page.title : page.i18n_variable[I18n.locale]}" + 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 if base.respond_to? :helper_method + base.send :helper_method, :parse_page_edit_noko if base.respond_to? :helper_method end end diff --git a/lib/parsers/parser_common.rb b/lib/parsers/parser_common.rb index 8d43c070..96cbb4b9 100644 --- a/lib/parsers/parser_common.rb +++ b/lib/parsers/parser_common.rb @@ -44,4 +44,56 @@ module ParserCommon res << "" end + # ad_banners + def parse_ad_banners(body = nil, page = nil, id = nil) + body.css('ad_banner').each do |banner| + res = '' + ad_banner = AdBanner.find(banner["id"]) rescue nil + if ad_banner && ad_banner.display? + res << "" + res << "
    " + ad_banner.ad_images.each do |ad_image| + res << "" + end + res << "
    " + end + fragment = Nokogiri::HTML::DocumentFragment.new(body, res) + banner.swap(fragment) + end + end + + # page_images + def parse_images(body, page) + 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 + image = page.design.images.detect{|image| image.name.eql?(page_image['name']) } unless image + if image + res = "' + end + fragment = Nokogiri::HTML::DocumentFragment.new(body, res) + page_image.swap(fragment) + end + end + + # page_menu + def parse_menu(body, page, edit=nil) + page_menu = body.css('.page_menu').first + home = get_homepage + menu = page.design.layout.menu + fragment = Nokogiri::HTML::DocumentFragment.new(body, menu_level(home, 0, menu, true)) + page_menu.swap(fragment) + end + end diff --git a/lib/parsers/parser_front_end.rb b/lib/parsers/parser_front_end.rb index 529802ff..c3ca1787 100644 --- a/lib/parsers/parser_front_end.rb +++ b/lib/parsers/parser_front_end.rb @@ -1,113 +1,42 @@ module ParserFrontEnd - require 'radius' include ParserCommon - - def parser_context(page, attributes = {}, id = nil) - Radius::Context.new do |c| - c.define_tag 'ad_banner' do |tag| - res = '' - ad_banner = AdBanner.find(tag.attr["id"]) rescue nil - if ad_banner && ad_banner.display? - res << "" - res << "
    " - ad_banner.ad_images.each do |ad_image| - res << "" - end - res << "
    " - end - res - end - c.define_tag 'content' do |tag| - ret = '' - if (tag.attributes["main"] == "true" && !page.module_app.nil?) - ret << "
    " - else - part = page.page_parts.detect{ |p| p.name.to_s == tag.attr['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 - when 'public_r_tag' - ret << "" - else - '' - end - end - ret - end - c.define_tag 'image' do |tag| - # 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.images.detect{|image| image.name.eql?(tag.attr['name']) } unless image - if image - res = "' - end - end - c.define_tag 'language_bar' do - @site.in_use_locales.map{ |locale| - lang = I18nVariable.first(:conditions => {:key => locale})[locale] - if I18n.locale.to_s.eql?(locale) - lang - else - "#{lang}" - end - }.join(' | ') - end - c.define_tag 'link' do |tag| - item = Item.first(:conditions => { :full_name => tag.attr['name'] }) - ret = '' - ret << "" - ret << item.i18n_variable[I18n.locale] - ret << '' - end - c.define_tag 'menu' do |tag| - home = get_homepage - menu = page.design.layout.menu - menu_level(home, 0, menu) - end - end - end - - def parse_page(page, id = nil) - if page._type == 'Page' - context = parser_context(page, {}, id) - parser = Radius::Parser.new(context, :tag_prefix => 'r') - parser.parse(parser.parse(page.design.layout.body)) - end - end - - def self.included(base) - base.send :helper_method, :parse_page if base.respond_to? :helper_method - end - - + # c.define_tag 'language_bar' do + # @site.in_use_locales.map{ |locale| + # lang = I18nVariable.first(:conditions => {:key => locale})[locale] + # if I18n.locale.to_s.eql?(locale) + # lang + # else + # "#{lang}" + # end + # }.join(' | ') + # end + # c.define_tag 'link' do |tag| + # item = Item.first(:conditions => { :full_name => tag.attr['name'] }) + # ret = '' + # ret << "" + # ret << item.i18n_variable[I18n.locale] + # ret << '' + # end + # end require 'nokogiri' def parse_page_noko(page, id = nil) body = Nokogiri::HTML(page.design.layout.body) + parse_menu(body, page) + public_r_tags = parse_contents(body, page, id) + parse_images(body, page) - # page_contents + public_r_tags.each do |tag| + send("parse_#{tag}s", body, page,id) + end + + body.to_html + end + + # page_contents + def parse_contents(body, page, id) + public_r_tags = [] body.css('.page_content').each do |content| ret = '' if (content["main"] == "true" && !page.module_app.nil?) @@ -129,6 +58,7 @@ module ParserFrontEnd end when 'public_r_tag' ret << "" + public_r_tags << part.public_r_tag else '' end @@ -141,54 +71,7 @@ module ParserFrontEnd fragment = Nokogiri::HTML::DocumentFragment.new(body, scope) content.swap(fragment) end - - # page_menu - page_menu = body.css('.page_menu').first - home = get_homepage - menu = page.design.layout.menu - fragment = Nokogiri::HTML::DocumentFragment.new(body, menu_level(home, 0, menu)) - page_menu.swap(fragment) - - # page_image - 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 - image = page.design.images.detect{|image| image.name.eql?(page_image['name']) } unless image - if image - res = "' - end - fragment = Nokogiri::HTML::DocumentFragment.new(body, res) - page_image.swap(fragment) - end - - # ad_banner - body.css('ad_banner').each do |banner| - res = '' - ad_banner = AdBanner.find(banner["id"]) rescue nil - if ad_banner && ad_banner.display? - res << "" - res << "
    " - ad_banner.ad_images.each do |ad_image| - res << "" - end - res << "
    " - end - fragment = Nokogiri::HTML::DocumentFragment.new(body, res) - banner.swap(fragment) - end - - body.to_html + public_r_tags.uniq end end From f5fd3dec7a015f3974f388927bf8637a5ce7f0fd Mon Sep 17 00:00:00 2001 From: Christophe Vilayphiou Date: Thu, 22 Mar 2012 01:51:16 +0800 Subject: [PATCH 047/125] Trying nokogiri --- Gemfile | 1 + Gemfile.lock | 4 + app/controllers/application_controller.rb | 2 +- app/controllers/pages_controller.rb | 2 + app/helpers/application_helper.rb | 47 ++++++++++ app/models/design/layout.rb | 8 +- app/models/meta.rb | 4 + app/views/layouts/page_layout.html.erb | 17 ++++ lib/parsers/parser_front_end.rb | 105 ++++++++++++++-------- lib/parsers/parser_layout.rb | 57 +++++------- 10 files changed, 172 insertions(+), 75 deletions(-) create mode 100644 app/views/layouts/page_layout.html.erb diff --git a/Gemfile b/Gemfile index 024f3449..d1afdb8c 100644 --- a/Gemfile +++ b/Gemfile @@ -16,6 +16,7 @@ gem 'kaminari', :git => 'git://github.com/amatsuda/kaminari.git' gem 'mini_magick' gem 'mongoid' gem "mongo_session_store-rails3" +gem 'nokogiri' gem 'radius' gem 'rake' gem 'ruby-debug19' diff --git a/Gemfile.lock b/Gemfile.lock index 1df648c4..71742974 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -41,6 +41,7 @@ GEM archive-tar-minitar (0.5.2) arel (2.2.3) bcrypt-ruby (3.0.1) + bcrypt-ruby (3.0.1-x86-mingw32) brakeman (1.5.1) activesupport erubis (~> 2.6) @@ -115,6 +116,8 @@ GEM mongo (~> 1.3) tzinfo (~> 0.3.22) multi_json (1.1.0) + nokogiri (1.5.2) + nokogiri (1.5.2-x86-mingw32) orm_adapter (0.0.6) pdf-writer (1.1.8) color (>= 1.4.0) @@ -252,6 +255,7 @@ DEPENDENCIES mini_magick mongo_session_store-rails3 mongoid + nokogiri radius rails (>= 3.1.0, < 3.2.0) rake diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 4b433777..fb82774e 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -47,7 +47,7 @@ class ApplicationController < ActionController::Base # Render the page def render_page(id = nil) if @item - render :text => parse_page(@item, id) + render :text => process_page(@item, id), :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 8ea35391..4860ea2e 100644 --- a/app/controllers/pages_controller.rb +++ b/app/controllers/pages_controller.rb @@ -1,5 +1,7 @@ class PagesController < ApplicationController + include ApplicationHelper + before_filter :get_item, :only => [:index_from_link, :show_from_link] def index diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 50510e3c..9c03de3d 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -107,4 +107,51 @@ module ApplicationHelper end end + + def process_page(page, id) + parse_page_noko(page, id) + end + + def page_metas(page) + metas = '' + @site.page_metas.each do |meta| + name, content = meta.get_name_content + metas << "\n" + end rescue nil + return metas + end + + def page_title(page) + "#{page.title ? page.title[I18n.locale] : page.i18n_variable[I18n.locale]}\n" + end + + def page_stylesheets(page) + stylesheets = '' + stylesheets << "\n" + stylesheets << "\n" + stylesheets << "\n" + stylesheets << "\n" if page.design.reset_css + stylesheets << "\n" if page.design.default_css + theme = page.design.themes.detect{ |d| d.id == page.theme_id } + stylesheets << "\n" if theme + stylesheets + end + + def page_javascripts(page) + javascripts = '' + javascripts << "\n" + javascripts << "\n" + javascripts << "\n" + javascripts << "\n" + javascripts << "\n" + javascripts << "\n" + javascripts << "\n" + javascripts << "\n" + javascripts << "\n" + page.design.javascripts.each do |js| + # javascripts << "" + end + javascripts + end + end diff --git a/app/models/design/layout.rb b/app/models/design/layout.rb index e13498f3..bf48415c 100644 --- a/app/models/design/layout.rb +++ b/app/models/design/layout.rb @@ -2,6 +2,8 @@ class Layout < DesignFile include ParserLayout attr_reader :content + + field :body embeds_one :menu embedded_in :design @@ -17,8 +19,10 @@ class Layout < DesignFile Layout.count > 0 end - def parse_layout - parse_layout_contents(self) + def parse_layout + html = Nokogiri::HTML(self.file.read) + self.body = html.at_css("body").inner_html + parse_body(self) end end diff --git a/app/models/meta.rb b/app/models/meta.rb index 411a4f0c..dbeac167 100644 --- a/app/models/meta.rb +++ b/app/models/meta.rb @@ -7,5 +7,9 @@ class Meta field :value, :default => nil has_one :i18n_variable, :as => :language_value, :autosave => true, :dependent => :destroy + + def get_name_content + [self.key, self.value ? self.value : self.i18n_variable[I18n.locale]] + end end diff --git a/app/views/layouts/page_layout.html.erb b/app/views/layouts/page_layout.html.erb new file mode 100644 index 00000000..8fb884b0 --- /dev/null +++ b/app/views/layouts/page_layout.html.erb @@ -0,0 +1,17 @@ + + + + + <%= page_title(@item).html_safe %> + <%= page_metas(@item).html_safe %> + <%= @metas %> + + <%= page_stylesheets(@item).html_safe %> + <%= page_javascripts(@item).html_safe %> + + + <%= yield %> + + diff --git a/lib/parsers/parser_front_end.rb b/lib/parsers/parser_front_end.rb index 4b5a523f..8ea3840a 100644 --- a/lib/parsers/parser_front_end.rb +++ b/lib/parsers/parser_front_end.rb @@ -63,22 +63,6 @@ module ParserFrontEnd res << '>' end end - c.define_tag 'javascripts' do |tag| - res = '' - res << "" - res << "" - res << "" - res << "" - res << "" - res << "" - res << "" - res << "" - res << "" - page.design.javascripts.each do |js| - # res << "" - end - res - end c.define_tag 'language_bar' do @site.in_use_locales.map{ |locale| lang = I18nVariable.first(:conditions => {:key => locale})[locale] @@ -101,38 +85,87 @@ module ParserFrontEnd menu = page.design.layout.menu menu_level(home, 0, menu) end - c.define_tag 'meta' do |tag| - res = '' - #res << "" - end - c.define_tag 'stylesheets' do |tag| - res = '' - res << "" - res << "" - res << "" - res << "" if page.design.reset_css - res << " " if page.design.default_css - theme = page.design.themes.detect{ |d| d.id == page.theme_id } - res << "" if theme - res - end - c.define_tag 'title' do |tag| - "#{page.title ? page.title[I18n.locale] : page.i18n_variable[I18n.locale]}" - end end end def parse_page(page, id = nil) if page._type == 'Page' - layout_content = page.design.layout.content.force_encoding('UTF-8') rescue '' context = parser_context(page, {}, id) parser = Radius::Parser.new(context, :tag_prefix => 'r') - parser.parse(parser.parse(layout_content)) + parser.parse(parser.parse(page.design.layout.body)) end end def self.included(base) base.send :helper_method, :parse_page if base.respond_to? :helper_method end + + + + require 'nokogiri' + + def parse_page_noko(page, id = nil) + body = Nokogiri::HTML(page.design.layout.body, nil, 'UTF-8') + + # page_contents + 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 + when 'public_r_tag' + ret << "" + else + '' + end + 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 + + # page_menu + page_menu = body.css('.page_menu').first + home = get_homepage + menu = page.design.layout.menu + fragment = Nokogiri::HTML::DocumentFragment.new(body, menu_level(home, 0, menu)) + page_menu.swap(fragment) + + # page_image + 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 + image = page.design.images.detect{|image| image.name.eql?(page_image['name']) } unless image + if image + res = "' + end + fragment = Nokogiri::HTML::DocumentFragment.new(body, res) + page_image.swap(fragment) + end + + body.to_html + end end diff --git a/lib/parsers/parser_layout.rb b/lib/parsers/parser_layout.rb index 063078df..01d681ef 100644 --- a/lib/parsers/parser_layout.rb +++ b/lib/parsers/parser_layout.rb @@ -1,44 +1,27 @@ module ParserLayout - require 'radius' - include ParserCommon + require 'nokogiri' - def parse_layout_contents(layout) - content = layout.content.force_encoding('UTF-8') - context = parser_layout_contents(layout) - parser = Radius::Parser.new(context, :tag_prefix => 'r') - parser.parse(content) - end - - def parser_layout_contents(layout) - Radius::Context.new do |c| - c.define_tag 'ad_banner' do |tag| - end - c.define_tag 'content' do |tag| - layout.layout_parts.new(:name => tag.attr['name']) - end - c.define_tag 'image' do |tag| - image = layout.design.images.detect{ |i| i.file_identifier.eql?(parse_html_image(tag.expand)) } - image.update_attributes(:name => tag.attr['name'], :html_id => tag.attr['id'], :html_class => tag.attr['class']) if image - end - c.define_tag 'javascripts' do |tag| - end - c.define_tag 'menu' do |tag| - layout.build_menu(:levels => 0, :values => {}) unless layout.menu - layout.menu.levels = i = tag.attr['level'].to_i - layout.menu.values.merge!({'home' => tag.attr['home']}) if i == 1 - layout.menu.values.merge!({"id_#{i}" => tag.attr['id'], "class_#{i}" => tag.attr['class'], "li_class_#{i}" => tag.attr['li_class'], "li_incremental_#{i}" => tag.attr['li_incremental']}) - tag.expand - end - c.define_tag 'meta' do |tag| - end - c.define_tag 'stylesheets' do |tag| - end - c.define_tag 'title' do |tag| - end + def parse_body(layout) + body = Nokogiri::HTML(layout.body) + body.css('.page_content').each do |content| + layout.layout_parts.build(:name => content['name']) end + + body.css('.page_image').each do |image| + image = layout.design.images.detect{ |i| i.file_identifier.eql?(parse_html_image(image.to_html)) } + image.update_attributes(:name => image['name'], :html_id => image['id'], :html_class => image['class']) if image + end + + body.css('.page_menu').each do |menu| + layout.build_menu(:levels => 0, :values => {}) unless layout.menu + layout.menu.levels = i = menu['level'].to_i + layout.menu.values.merge!({'home' => menu['home']}) if i == 1 + layout.menu.values.merge!({"id_#{i}" => menu['id'], "class_#{i}" => menu['class'], "li_class_#{i}" => menu['li_class'], "li_incremental_#{i}" => menu['li_incremental']}) + end + end - + def parse_html_image(html) html.scan(/(?<=\)/){ $1.gsub(' ','').scan(/(?<=src=\")(.*?)(?=\")/){ @@ -46,4 +29,6 @@ module ParserLayout } } end + + end From 7efaddf57cb78c3f9203de59e456c548f9147fa3 Mon Sep 17 00:00:00 2001 From: Christophe Vilayphiou Date: Thu, 22 Mar 2012 10:11:02 +0800 Subject: [PATCH 048/125] Add ad_banner to nokogiri --- lib/parsers/parser_front_end.rb | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/lib/parsers/parser_front_end.rb b/lib/parsers/parser_front_end.rb index 8ea3840a..529802ff 100644 --- a/lib/parsers/parser_front_end.rb +++ b/lib/parsers/parser_front_end.rb @@ -105,7 +105,7 @@ module ParserFrontEnd require 'nokogiri' def parse_page_noko(page, id = nil) - body = Nokogiri::HTML(page.design.layout.body, nil, 'UTF-8') + body = Nokogiri::HTML(page.design.layout.body) # page_contents body.css('.page_content').each do |content| @@ -165,6 +165,29 @@ module ParserFrontEnd page_image.swap(fragment) end + # ad_banner + body.css('ad_banner').each do |banner| + res = '' + ad_banner = AdBanner.find(banner["id"]) rescue nil + if ad_banner && ad_banner.display? + res << "" + res << "
    " + ad_banner.ad_images.each do |ad_image| + res << "" + end + res << "
    " + end + fragment = Nokogiri::HTML::DocumentFragment.new(body, res) + banner.swap(fragment) + end + body.to_html end From 3ba89ecbcff0a7f513f5d6d469591e95e4e2c92c Mon Sep 17 00:00:00 2001 From: Matt Fu Date: Thu, 22 Mar 2012 14:33:59 +0800 Subject: [PATCH 049/125] Fact check program completed,Lin checked --- app/models/object_auth.rb | 2 +- app/views/layouts/_side_bar.html.erb | 3 +- lib/orbit_core_lib.rb | 16 ++- .../back_end/bulletin_categorys_controller.rb | 2 +- .../back_end/bulletins_controller.rb | 106 +++++++++--------- .../back_end/fact_checks_controller.rb | 2 +- .../front_end/bulletins_controller.rb | 6 +- .../widget/bulletins_controller.rb | 8 +- .../announcement/app/models/bulletin.rb | 48 ++++---- .../back_end/bulletins/_bulletin.html.erb | 12 +- .../bulletins/_bulletin_link_qe.html.erb | 66 +++++------ .../back_end/bulletins/_form.html.erb | 2 + .../widget/bulletins/index.html.erb | 1 - 13 files changed, 144 insertions(+), 130 deletions(-) diff --git a/app/models/object_auth.rb b/app/models/object_auth.rb index 8932bb76..ae3fd701 100644 --- a/app/models/object_auth.rb +++ b/app/models/object_auth.rb @@ -1,6 +1,6 @@ class ObjectAuth < PrototypeAuth include OrbitCoreLib::ObjectTokenUnility - validates_uniqueness_of :obj_authable_type,:scope => :title #{ |c| } + validates_uniqueness_of :title ,:scope => [:obj_authable_type,:obj_authable_id] #{ |c| } belongs_to :obj_authable, polymorphic: true # > - Something.find_with_auth(query) # > - or Something.find(query).auth diff --git a/app/views/layouts/_side_bar.html.erb b/app/views/layouts/_side_bar.html.erb index 71e8106d..baeef6c4 100644 --- a/app/views/layouts/_side_bar.html.erb +++ b/app/views/layouts/_side_bar.html.erb @@ -9,8 +9,9 @@ <%= content_tag :li, link_to(t('admin.add_new'), new_panel_announcement_back_end_bulletin_path), :class => active_for_action('bulletins', 'new') %> <%= content_tag :li, link_to(t('admin.categories'), panel_announcement_back_end_bulletin_categorys_path), :class => active_for_action('bulletin_categorys', 'index') %> <%= content_tag :li, link_to(t('admin.tags'), panel_announcement_back_end_tags_path), :class => active_for_action('tags', 'index') %> - <%= content_tag :li, link_to(t('announcement.bulletin.fact_check_setting'), panel_announcement_back_end_fact_checks_setting_path), :class => active_for_action('tags', 'index') %> + <%= content_tag :li, link_to(t('announcement.bulletin.fact_check_setting'), panel_announcement_back_end_fact_checks_setting_path), :class => active_for_action('tags', 'index') if is_manager? %> <% end -%> + <% end -%> <%= content_tag :li, :class => active_for_controllers('users') do -%> diff --git a/lib/orbit_core_lib.rb b/lib/orbit_core_lib.rb index 561fceba..bcde17e0 100644 --- a/lib/orbit_core_lib.rb +++ b/lib/orbit_core_lib.rb @@ -21,11 +21,19 @@ module OrbitCoreLib def authed_users(title=nil) users = [] - unless title.nil? - users = self.object_auths.where(title: title )[0].auth_users_after_block_list rescue [] + users = case title + when :all + ary = self.object_auths.collect{|t| t.auth_users} + ary.flatten! + when nil + if self.object_auths.count ==1 + self.object_auths.first.auth_users_after_block_list rescue [] + else + logger.info "Warning calling a auth commend without specificed value( has multi-auths ), return empty" + [] + end else - users = self.object_auths.collect{|t| t.auth_users_after_block_list} rescue [] - users.flatten!.uniq! + self.object_auths.where(title: title).first.auth_users rescue [] end users end diff --git a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletin_categorys_controller.rb b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletin_categorys_controller.rb index f55ad6e3..97378c5a 100644 --- a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletin_categorys_controller.rb +++ b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletin_categorys_controller.rb @@ -1,4 +1,4 @@ -class Panel::Announcement::BackEnd::BulletinCategorysController < ApplicationController +class Panel::Announcement::BackEnd::BulletinCategorysController < OrbitBackendController layout 'new_admin' diff --git a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletins_controller.rb b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletins_controller.rb index 31f446a0..31b3b4a2 100644 --- a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletins_controller.rb +++ b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletins_controller.rb @@ -159,12 +159,12 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController end def file_quick_add - # debugger + # debugger @bulletin_file = BulletinFile.new - @file_url = panel_announcement_back_end_bulletins_path + @file_url = panel_announcement_back_end_bulletins_path - @bulletin_file.bulletin_id = params[:bulletin_id] + @bulletin_file.bulletin_id = params[:bulletin_id] respond_to do |format| format.js @@ -173,75 +173,73 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController end def file_quick_edit - # debugger + # debugger @bulletin_file = BulletinFile.find(params[:bulletin_id]) - @file_url = panel_announcement_back_end_bulletin_path(@bulletin_file) + @file_url = panel_announcement_back_end_bulletin_path(@bulletin_file) respond_to do |format| format.js end - end # PUT /bulletins/1 # PUT /bulletins/1.xml def update - if params[:bulletin_link] - - @bulletin_link = BulletinLink.find(params[:id]) - - @link_url = panel_announcement_back_end_bulletin_path(@bulletin_link) + if params[:bulletin_link] + + @bulletin_link = BulletinLink.find(params[:id]) + + @link_url = panel_announcement_back_end_bulletin_path(@bulletin_link) - respond_to do |format| - if @bulletin_link.update_attributes(params[:bulletin_link]) - # format.html { redirect_to(panel_announcement_back_end_bulletins_url) } - format.js { render 'update_bulletin_link' } - end - end - - elsif params[:bulletin_file] - - @bulletin_file = BulletinFile.find(params[:id]) - - @file_url = panel_announcement_back_end_bulletin_path(@bulletin_file) + respond_to do |format| + if @bulletin_link.update_attributes(params[:bulletin_link]) + # format.html { redirect_to(panel_announcement_back_end_bulletins_url) } + format.js { render 'update_bulletin_link' } + end + end + + elsif params[:bulletin_file] + + @bulletin_file = BulletinFile.find(params[:id]) + + @file_url = panel_announcement_back_end_bulletin_path(@bulletin_file) - respond_to do |format| - if @bulletin_file.update_attributes(params[:bulletin_file]) - # format.html { redirect_to(panel_announcement_back_end_bulletins_url) } - format.js { render 'update_bulletin_file' } - end - end - - else - - @bulletin = Bulletin.find(params[:id]) - - @bulletin.update_user_id = current_user.id - - # @bulletin.image.clear if params[:bulletin][:image_del] == '1' - # if params[:bulletin][:image_del] == '1' - # @bulletin.remove_image! - # @bulletin.image_del = nil - # params[:bulletin][:image_del] = nil - # end + respond_to do |format| + if @bulletin_file.update_attributes(params[:bulletin_file]) + # format.html { redirect_to(panel_announcement_back_end_bulletins_url) } + format.js { render 'update_bulletin_file' } + end + end + + else + + @bulletin = Bulletin.find(params[:id]) + + @bulletin.update_user_id = current_user.id + + # @bulletin.image.clear if params[:bulletin][:image_del] == '1' + # if params[:bulletin][:image_del] == '1' + # @bulletin.remove_image! + # @bulletin.image_del = nil + # params[:bulletin][:image_del] = nil + # end - respond_to do |format| - if @bulletin.update_attributes(params[:bulletin]) && @bulletin.save - # format.html { redirect_to(panel_announcement_back_end_bulletin_url(@bulletin), :notice => t('bulletin.update_bulletin_success')) } - format.html { redirect_to(panel_announcement_back_end_bulletins_url, :notice => t('bulletin.update_bulletin_success')) } - format.js { render 'toggle_enable' } - format.xml { head :ok } - else - format.html { render :action => "edit" } - format.xml { render :xml => @bulletin.errors, :status => :unprocessable_entity } - end - end + respond_to do |format| + if @bulletin.update_attributes(params[:bulletin]) && @bulletin.save + # format.html { redirect_to(panel_announcement_back_end_bulletin_url(@bulletin), :notice => t('bulletin.update_bulletin_success')) } + format.html { redirect_to(panel_announcement_back_end_bulletins_url, :notice => t('bulletin.update_bulletin_success')) } + format.js { render 'toggle_enable' } + format.xml { head :ok } + else + format.html { render :action => "edit" } + format.xml { render :xml => @bulletin.errors, :status => :unprocessable_entity } + end + end end - end # DELETE /bulletins/1 diff --git a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/fact_checks_controller.rb b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/fact_checks_controller.rb index c47e91fb..9095a4d3 100644 --- a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/fact_checks_controller.rb +++ b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/fact_checks_controller.rb @@ -18,7 +18,7 @@ class Panel::Announcement::BackEnd::FactChecksController < OrbitBackendControll else first_category = @bulletin_categorys.first end - preload_object_auth = first_category.object_auths.where(title: 'fact_check') || (first_category.object_auths.create :title=> 'fact_check') + preload_object_auth = first_category.object_auths.where(title: 'fact_check').empty?? (first_category.object_auths.create! :title=> 'fact_check') : first_category.object_auths.where(title: 'fact_check') @users_array = preload_object_auth.first.privilege_users rescue [] respond_to do |format| format.html diff --git a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/front_end/bulletins_controller.rb b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/front_end/bulletins_controller.rb index ff3cbdc9..fe0b2aa5 100644 --- a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/front_end/bulletins_controller.rb +++ b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/front_end/bulletins_controller.rb @@ -12,9 +12,9 @@ class Panel::Announcement::FrontEnd::BulletinsController < OrbitWidgetController date_now = Time.now if params[:category_id] - @bulletins = Bulletin.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) else - @bulletins = Bulletin.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]).per(10) end get_categorys @@ -23,7 +23,7 @@ class Panel::Announcement::FrontEnd::BulletinsController < OrbitWidgetController end def show - @bulletin = Bulletin.find(params[:id]) + @bulletin = Bulletin.can_display.where.where(_id: params[:id]) get_categorys end 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 60aad3d9..783ee9ef 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 @@ -14,9 +14,9 @@ class Panel::Announcement::Widget::BulletinsController < OrbitWidgetController # @bulletin_categorys = BulletinCategory.first; # @bulletins = Bulletin.widget_datas(@bulletin_categorys.id).limit(9) if params[:category_id] - @bulletins = Bulletin.where(:bulletin_category_id => params[:category_id]).widget_datas.limit(9) + @bulletins = Bulletin.can_display.where(:bulletin_category_id => params[:category_id]).widget_datas.limit(9) else - @bulletins = Bulletin.widget_datas.limit(9) + @bulletins = Bulletin.can_display.widget_datas.limit(9) end get_categorys @@ -26,14 +26,14 @@ class Panel::Announcement::Widget::BulletinsController < OrbitWidgetController def bulletins_and_web_links @tags = AnnouncementTag.all @selected_tag = AnnouncementTag.find(params[:id]) rescue @tags[0] - @bulletins = @selected_tag.get_visible_bulletins.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 render :layout => 'module_widget' end def reload_bulletins @selected_tag = AnnouncementTag.find(params[:tag_id]) - @bulletins = @selected_tag.get_visible_bulletins.page(params[:page]).per(5) rescue nil + @bulletins = @selected_tag.get_visible_bulletins.can_display.page(params[:page]).per(5) rescue nil end def reload_web_links diff --git a/vendor/built_in_modules/announcement/app/models/bulletin.rb b/vendor/built_in_modules/announcement/app/models/bulletin.rb index d1b7f3c5..e24f7f21 100644 --- a/vendor/built_in_modules/announcement/app/models/bulletin.rb +++ b/vendor/built_in_modules/announcement/app/models/bulletin.rb @@ -19,12 +19,14 @@ class Bulletin field :is_top, :type => Boolean, :default => false field :is_hot, :type => Boolean, :default => false field :is_hidden, :type => Boolean, :default => false - field :is_checked, :type => Boolean, :default => false + field :is_checked, :type => Boolean, :default => nil field :not_checked_reason field :public, :type => Boolean, :default => true + scope :can_display,where(is_checked: true) + mount_uploader :image, ImageUploader belongs_to :bulletin_category @@ -47,28 +49,17 @@ class Bulletin def self.search( search = nil, category_id = nil ) - - if category_id.to_s.size > 0 and search.to_s.size > 0 - + if category_id.to_s.size > 0 and search.to_s.size > 0 key = /#{search}/ - - find(:all, :conditions => {title: key, bulletin_category_id: category_id}).desc( :is_top, :postdate ) - - elsif category_id.to_s.size > 0 and search.to_s.size < 1 - - find(:all, :conditions => {bulletin_category_id: category_id}).desc( :is_top, :postdate ) - - elsif search.to_s.size > 0 and category_id.to_s.size < 1 - + find(:all, :conditions => {title: key, bulletin_category_id: category_id}).desc( :is_top, :postdate ) + elsif category_id.to_s.size > 0 and search.to_s.size < 1 + find(:all, :conditions => {bulletin_category_id: category_id}).desc( :is_top, :postdate ) + elsif search.to_s.size > 0 and category_id.to_s.size < 1 key = /#{search}/ - - find(:all, :conditions => {title: key}).desc( :is_top, :postdate ) - else - - find(:all).desc( :is_top, :postdate) - - end - + find(:all, :conditions => {title: key}).desc( :is_top, :postdate ) + else + find(:all).desc( :is_top, :postdate) + end end @@ -87,7 +78,11 @@ class Bulletin end end - + + def is_expired? + Date.today > self.deadline ? true : false rescue false + #some dates might sat as nil so rescue false + end def is_top? self.is_top @@ -101,6 +96,15 @@ class Bulletin self.is_hidden end + def is_checked? + self.is_checked + end + + def is_check_rejected? + self.is_checked == false + end + + def save_bulletin_links self.bulletin_links.each do |t| if t.should_destroy diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletin.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletin.html.erb index 5338fb41..a67464c1 100644 --- a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletin.html.erb +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletin.html.erb @@ -10,8 +10,10 @@ <% if bulletin.is_hidden? %> <%= t(:hidden) %> <% end %> +
    - + <%#= debugger %> + <%#= a=1 %> + <% if (bulletin.bulletin_category.authed_users('fact_check').include?(current_user) or is_manager?) and !bulletin.is_expired? %>
  • <%= link_to t('bulletin.fact_check'), edit_panel_announcement_back_end_bulletin_path(bulletin) %>
  • <%#= #TODO add ancher so user can quick access into that part %> + <% end %> + <% end %> +
    + <%= bulletin.bulletin_category.i18n_variable[I18n.locale] %> <%= link_to bulletin.title[I18n.locale], panel_announcement_front_end_bulletin_path(bulletin, :category_id => bulletin.bulletin_category.id) rescue ''%> @@ -39,4 +47,4 @@ <%= User.from_id(bulletin.update_user_id).name rescue ''%> - \ No newline at end of file + diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletin_link_qe.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletin_link_qe.html.erb index b9006352..c146da48 100644 --- a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletin_link_qe.html.erb +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletin_link_qe.html.erb @@ -1,43 +1,37 @@ <% # encoding: utf-8 %> - <%= form_for(@bulletin_link, :remote => true, :url => @link_url) do |f| %> - - - - - - +<%= form_for(@bulletin_link, :remote => true, :url => @link_url) do |f| %> + + +