From eb2b4b80b7b136baf526a8a81a108f090c052963 Mon Sep 17 00:00:00 2001 From: Matt Fu Date: Fri, 16 Mar 2012 15:48:13 +0800 Subject: [PATCH 01/47] 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

+ +<%= link_to "read more >",panel_announcement_front_end_bulletins_path(), :class => "btn" %> +read more > +
+ +
+

news

+ +<%= 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 02/47] 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 9c8b0235b06763fbc20d5930752579d83fe094d3 Mon Sep 17 00:00:00 2001 From: Matt Fu Date: Fri, 16 Mar 2012 15:48:13 +0800 Subject: [PATCH 03/47] 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 670011495560a810823b00b43aec20ad226e20a6 Mon Sep 17 00:00:00 2001 From: Matt Fu Date: Fri, 16 Mar 2012 15:51:59 +0800 Subject: [PATCH 04/47] 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 05/47] 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 06/47] 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? %> @@ -39,11 +39,4 @@ <%= User.from_id(bulletin.update_user_id).name rescue ''%> - -<%= render :partial => 'quick_edit', :locals => {:bulletin => bulletin} %> - -<% content_for :page_specific_javascript do %> - -<% end %> \ No newline at end of file + \ No newline at end of file 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 96e8237c..7c303b23 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 @@ -1,17 +1,10 @@ - - - - <%= 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 => "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' %> -
- <% end %> - - + + <%= t(:quick_edit) %> - <%= t(type) %> + <%= form_for @bulletin, :url => panel_announcement_back_end_bulletin_path(@bulletin), :html => {:class => 'form-horizontal'} do |f| %> + <%= render :partial => "panel/announcement/back_end/bulletins/quick_edit_#{@type}", :locals => { :f => f, :bulletin => @bulletin } %> +
+ <%= f.submit t(:submit), :class => 'btn btn-primary' %> + <%= f.submit t(:cancel), :class => 'btn quick_edit_cancel', :type => 'reset', :rel => dom_id(@bulletin, :edit) %> +
+ <% end %> + diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_quick_edit_basic.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_quick_edit_basic.html.erb index ce96acdc..9fc911ff 100644 --- a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_quick_edit_basic.html.erb +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_quick_edit_basic.html.erb @@ -1,4 +1,4 @@ -
+
diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_quick_edit_files.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_quick_edit_files.html.erb index d517e00d..e1999aef 100644 --- a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_quick_edit_files.html.erb +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_quick_edit_files.html.erb @@ -1,4 +1,4 @@ -
+
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 affd717c..7981c2bd 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 @@ -1,4 +1,4 @@ -
diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_quick_edit_picture.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_quick_edit_picture.html.erb index ff59280f..a1ee68fd 100644 --- a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_quick_edit_picture.html.erb +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_quick_edit_picture.html.erb @@ -1,4 +1,4 @@ -
+
diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_quick_edit_tags.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_quick_edit_tags.html.erb index a561fee1..d28c24e3 100644 --- a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_quick_edit_tags.html.erb +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_quick_edit_tags.html.erb @@ -32,7 +32,7 @@
--> -
+
<% @tags.each do |tag| %> diff --git a/vendor/built_in_modules/announcement/config/routes.rb b/vendor/built_in_modules/announcement/config/routes.rb index 61056e49..14eec7a2 100644 --- a/vendor/built_in_modules/announcement/config/routes.rb +++ b/vendor/built_in_modules/announcement/config/routes.rb @@ -10,6 +10,9 @@ Rails.application.routes.draw do 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 + member do + get 'load_quick_edit' + end end resources :bulletin_categorys, :controller => 'bulletin_categorys' do match "quick_edit/:bulletin_category_id" => "bulletin_categorys#quick_edit" ,:as => :quick_edit From f37eb5bf4319b3d0bf5f85858c7aaa33d419fa05 Mon Sep 17 00:00:00 2001 From: Christophe Vilayphiou Date: Fri, 23 Mar 2012 18:27:41 +0800 Subject: [PATCH 19/47] Add missing file --- .../announcement/back_end/bulletins/load_quick_edit.js.erb | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/load_quick_edit.js.erb diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/load_quick_edit.js.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/load_quick_edit.js.erb new file mode 100644 index 00000000..c418a9cc --- /dev/null +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/load_quick_edit.js.erb @@ -0,0 +1,2 @@ +$("#<%= dom_id @bulletin, :edit %>").show() +$("#<%= dom_id @bulletin, :edit %>").html("<%= j render :partial => 'quick_edit', :locals => {:type => @type} %>") \ No newline at end of file From 74636fb16d0c7f34946c26afa3ff252b947dd646 Mon Sep 17 00:00:00 2001 From: Christophe Vilayphiou Date: Tue, 27 Mar 2012 14:16:04 +0800 Subject: [PATCH 20/47] Delete file with Chinese character in the name --- .../back_end/bulletin_links_controller-ƻs.rb | 14 -------------- 1 file changed, 14 deletions(-) delete mode 100644 vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletin_links_controller-ƻs.rb diff --git a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletin_links_controller-ƻs.rb b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletin_links_controller-ƻs.rb deleted file mode 100644 index 04a75fa6..00000000 --- a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletin_links_controller-ƻs.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 a30bc499c72600431e07db39239c3a6d3547d8c8 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 23 Mar 2012 18:04:11 +0800 Subject: [PATCH 21/47] fix announcement & links --- app/assets/javascripts/bootstrap.js | 7 +- app/assets/javascripts/bulletin_form.js.erb | 6 +- .../back_end/bulletin_categorys_controller.rb | 2 +- .../back_end/bulletin_files_controller.rb | 48 +++++ .../back_end/bulletin_links_controller.rb | 49 +++++ .../back_end/bulletins_controller.rb | 172 ++++++++++++++---- .../bulletin_categorys/_form.html.erb | 10 +- .../bulletin_categorys/_quick_edit.html.erb | 13 -- .../bulletins/_bulletin_file_qe.html.erb | 51 ++++++ .../bulletins/_bulletin_link2.html.erb | 17 -- .../bulletins/_bulletin_link_qe.html.erb | 30 +-- .../back_end/bulletins/_form.html.erb | 19 +- ....html.erb => _form_bulletin_file.html.erb} | 12 +- ....html.erb => _form_bulletin_link.html.erb} | 10 +- .../bulletins/_list_bulletin_file.html.erb | 21 +++ .../bulletins/_list_bulletin_link.html.erb | 19 ++ .../bulletins/_quick_edit_files.html.erb | 46 +---- .../bulletins/_quick_edit_links.html.erb | 45 +---- .../bulletins/create_bulletin_file.js.erb | 2 + .../bulletins/create_bulletin_link.js.erb | 2 + .../back_end/bulletins/edit.html.erb | 2 +- .../back_end/bulletins/file_quick_add.js.erb | 1 + .../back_end/bulletins/file_quick_edit.js.erb | 1 + .../back_end/bulletins/index.html.erb | 13 ++ .../back_end/bulletins/link_quick_add.js.erb | 1 + .../back_end/bulletins/link_quick_edit.js.erb | 3 +- .../back_end/bulletins/new.html.erb | 4 +- .../bulletins/update_bulletin_file.js.erb | 2 + .../bulletins/update_bulletin_link.js.erb | 2 + .../announcement/config/routes.rb | 12 ++ .../back_end/page_contexts/_form.html.erb | 3 +- .../back_end/page_contexts/edit.html.erb | 2 +- .../back_end/web_link_categorys_controller.rb | 13 -- .../back_end/web_links_controller.rb | 4 +- .../_web_link_category.html.erb | 2 +- .../back_end/web_links/_form.html.erb | 29 +-- .../back_end/web_links/destroy.js.erb | 2 +- .../back_end/web_links/edit.html.erb | 13 +- .../back_end/web_links/new.html.erb | 19 +- .../web_resource/config/routes.rb | 4 +- 40 files changed, 446 insertions(+), 267 deletions(-) create mode 100644 vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletin_files_controller.rb create mode 100644 vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletin_links_controller.rb delete 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/bulletins/_bulletin_file_qe.html.erb delete mode 100644 vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletin_link2.html.erb rename vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/{_bulletin_file.html.erb => _form_bulletin_file.html.erb} (66%) rename vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/{_bulletin_link.html.erb => _form_bulletin_link.html.erb} (59%) create mode 100644 vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_list_bulletin_file.html.erb create mode 100644 vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_list_bulletin_link.html.erb create mode 100644 vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/create_bulletin_file.js.erb create mode 100644 vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/create_bulletin_link.js.erb create mode 100644 vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/file_quick_add.js.erb create mode 100644 vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/file_quick_edit.js.erb create mode 100644 vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/link_quick_add.js.erb create mode 100644 vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/update_bulletin_file.js.erb create mode 100644 vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/update_bulletin_link.js.erb diff --git a/app/assets/javascripts/bootstrap.js b/app/assets/javascripts/bootstrap.js index b822d62b..116cfe61 100644 --- a/app/assets/javascripts/bootstrap.js +++ b/app/assets/javascripts/bootstrap.js @@ -68,8 +68,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ========================================================= */ - - + !function( $ ){ "use strict" @@ -130,6 +129,7 @@ var that = this this.isShown = false + //alert(this.isShown+":"+this.$element.attr('class')) $('body').removeClass('modal-open') @@ -138,7 +138,7 @@ this.$element .trigger('hide') .removeClass('in') - + $.support.transition && this.$element.hasClass('fade') ? hideWithTransition.call(this) : hideModal.call(this) @@ -146,7 +146,6 @@ } - /* MODAL PRIVATE METHODS * ===================== */ diff --git a/app/assets/javascripts/bulletin_form.js.erb b/app/assets/javascripts/bulletin_form.js.erb index 894d82c1..24fee4d2 100644 --- a/app/assets/javascripts/bulletin_form.js.erb +++ b/app/assets/javascripts/bulletin_form.js.erb @@ -1,9 +1,9 @@ -$('.bulletin_links_block a.remove_existing_record').live('click', function(){ +$('.bulletin_links_block a.delete').live('click', function(){ //$(this).parents('.list_item').remove(); $(this).parents('tr.list_item').remove(); }); -$('.bulletin_files_block a.remove_existing_record').live('click', function(){ +$('.bulletin_files_block a.delete').live('click', function(){ //$(this).parents('.list_item').remove(); $(this).parents('tr.list_item').remove(); }); @@ -17,4 +17,6 @@ $('.action a.remove_existing_record').live('click', function(){ $('.quick_edit_cancel').live('click', function(){ tr = $(this).attr('rel'); $('#' + tr).hide(); + $("tr#bulletin_file_" + $(this).prev().attr('value')).hide(); + $("tr#bulletin_link_" + $(this).prev().attr('value')).hide(); }); \ No newline at end of file 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..f55ad6e3 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 @@ -94,7 +94,7 @@ class Panel::Announcement::BackEnd::BulletinCategorysController < ApplicationCon respond_to do |format| if @bulletin_category.update_attributes(params[:bulletin_category]) # format.html { redirect_to(panel_announcement_back_end_bulletin_category_url(@bulletin_category), :notice => t('bulletin_category.update_bulletin_category_success')) } - format.html { redirect_to(panel_announcement_back_end_bulletin_categorys_url, :notice => t('bulletin_category.update_bulletin_category_success')) } + # format.html { redirect_to(panel_announcement_back_end_bulletin_categorys_url, :notice => t('bulletin_category.update_bulletin_category_success')) } # format.xml { head :ok } format.js else diff --git a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletin_files_controller.rb b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletin_files_controller.rb new file mode 100644 index 00000000..223e2ba5 --- /dev/null +++ b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletin_files_controller.rb @@ -0,0 +1,48 @@ +class Panel::Announcement::BackEnd::BulletinFilesController < ApplicationController + + layout 'new_admin' + + def index + @bulletin_files = BulletinFile.all + + respond_to do |format| + format.html # index.html.erb + # format.xml { render :xml => @bulletins } + format.js + end + + end + + # POST /bulletins + # POST /bulletins.xml + def create + @bulletin_file = BulletinFile.new(params[:bulletin_file]) + + respond_to do |format| + if @bulletin_file.save + format.html { redirect_to(panel_announcement_back_end_bulletins_url) } + format.js + else + format.html { render :action => "new" } + format.js { render action: "new" } + end + end + end + + # PUT /bulletins/1 + # PUT /bulletins/1.xml + def update + @bulletin_file = BulletinFile.find(params[:id]) + + respond_to do |format| + if @bulletin_file.update_attributes(params[:bulletin_file]) + format.html { redirect_to(panel_announcement_back_end_bulletins_url) } + format.js + else + format.html { render :action => "edit" } + format.js { render :action => "edit" } + end + end + end + +end 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..59f164d9 --- /dev/null +++ b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletin_links_controller.rb @@ -0,0 +1,49 @@ +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 + + # POST /bulletins + # POST /bulletins.xml + def create + @bulletin_link = BulletinLink.new(params[:bulletin_link]) + # @bulletin_link.bulletin_id = params[:bulletin_link][:bulletin_id] + + respond_to do |format| + if @bulletin_link.save + format.html { redirect_to(panel_announcement_back_end_bulletins_url) } + format.js + else + format.html { render :action => "new" } + format.js { render action: "new" } + end + end + end + + # PUT /bulletins/1 + # PUT /bulletins/1.xml + def update + @bulletin_link = BulletinLink.find(params[:id]) + + respond_to do |format| + if @bulletin_link.update_attributes(params[:bulletin_link]) + format.html { redirect_to(panel_announcement_back_end_bulletins_url) } + format.js + else + format.html { render :action => "edit" } + format.js { render :action => "edit" } + end + end + 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 c81ed4d1..31f446a0 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 @@ -14,9 +14,15 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController # @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 - + + @bulletin_link = BulletinLink.new + @link_url = panel_announcement_back_end_bulletins_path + + @bulletin_file = BulletinFile.new + @file_url = panel_announcement_back_end_bulletins_path + respond_to do |format| format.html # index.html.erb format.js @@ -78,30 +84,58 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController # POST /bulletins # POST /bulletins.xml def create - @bulletin = Bulletin.new(params[:bulletin]) - @bulletin.create_user_id = current_user.id - @bulletin.update_user_id = current_user.id + if params[:bulletin_link] + + @bulletin_link = BulletinLink.new(params[:bulletin_link]) - respond_to do |format| - if @bulletin.save - # format.html { redirect_to(panel_announcement_back_end_bulletin_url(@bulletin), :notice => t('announcement.create_bulletin_success')) } - format.html { redirect_to(panel_announcement_back_end_bulletins_url, :notice => t('announcement.create_bulletin_success')) } - format.xml { render :xml => @bulletin, :status => :created, :location => @bulletin } - else - format.html { render :action => "new" } - format.xml { render :xml => @bulletin.errors, :status => :unprocessable_entity } - end - end + respond_to do |format| + if @bulletin_link.save + format.js { render 'create_bulletin_link' } + end + end + + elsif params[:bulletin_file] + + @bulletin_file = BulletinFile.new(params[:bulletin_file]) + + respond_to do |format| + if @bulletin_file.save + format.js { render 'create_bulletin_file' } + end + end + + else + + @bulletin = Bulletin.new(params[:bulletin]) + + @bulletin.create_user_id = current_user.id + @bulletin.update_user_id = current_user.id + + respond_to do |format| + if @bulletin.save + # format.html { redirect_to(panel_announcement_back_end_bulletin_url(@bulletin), :notice => t('announcement.create_bulletin_success')) } + format.html { redirect_to(panel_announcement_back_end_bulletins_url, :notice => t('announcement.create_bulletin_success')) } + format.xml { render :xml => @bulletin, :status => :created, :location => @bulletin } + format.js + else + format.html { render :action => "new" } + format.xml { render :xml => @bulletin.errors, :status => :unprocessable_entity } + end + end + + end + end def link_quick_add # debugger - - @bulletin = Bulletin.find(params[:bulletin_id]) - + + @bulletin_link = BulletinLink.new @link_url = panel_announcement_back_end_bulletins_path + @bulletin_link.bulletin_id = params[:bulletin_id] + respond_to do |format| format.js end @@ -110,10 +144,39 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController def link_quick_edit # debugger + @bulletin_link = BulletinLink.find(params[:bulletin_id]) - @bulletin = Bulletin.find(params[:bulletin_id]) + @link_url = panel_announcement_back_end_bulletin_path(@bulletin_link) - @link_url = panel_announcement_back_end_bulletin_path(@bulletin) + # @bulletin = Bulletin.find(params[:bulletin_id]) + + # @link_url = panel_announcement_back_end_bulletin_path(@bulletin) + + respond_to do |format| + format.js + end + + end + + def file_quick_add + # debugger + + @bulletin_file = BulletinFile.new + @file_url = panel_announcement_back_end_bulletins_path + + @bulletin_file.bulletin_id = params[:bulletin_id] + + respond_to do |format| + format.js + end + + end + + def file_quick_edit + # debugger + @bulletin_file = BulletinFile.find(params[:bulletin_id]) + + @file_url = panel_announcement_back_end_bulletin_path(@bulletin_file) respond_to do |format| format.js @@ -124,28 +187,61 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController # PUT /bulletins/1 # PUT /bulletins/1.xml def update - @bulletin = Bulletin.find(params[:id]) - @bulletin.update_user_id = current_user.id + if params[:bulletin_link] - # @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_link = BulletinLink.find(params[:id]) + + @link_url = panel_announcement_back_end_bulletin_path(@bulletin_link) - 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 + 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.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/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 1ce7f629..df0dc38c 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 @@ -23,14 +23,14 @@
- <%= f.label :display %> - <%= f.radio_button :display, "List" %>List - <%= f.radio_button :display, "Picture" %>Picture -
顯示方式是設定在前台頁面時,資訊所呈現的樣式 + <%#= f.label :display %> + <%#= f.radio_button :display, "List" List%> + <%#= f.radio_button :display, "Picture" Picture%> + <%#
顯示方式是設定在前台頁面時,資訊所呈現的樣式 %>
- <%= f.submit 'Submit/送出', :class=>'btn btn-primary' %> + <%= f.submit t('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 deleted file mode 100644 index 14a72951..00000000 --- a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletin_categorys/_quick_edit.html.erb +++ /dev/null @@ -1,13 +0,0 @@ - -
- - diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletin_file_qe.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletin_file_qe.html.erb new file mode 100644 index 00000000..4e47024c --- /dev/null +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletin_file_qe.html.erb @@ -0,0 +1,51 @@ +<% # encoding: utf-8 %> + + <%= form_for(@bulletin_file, :remote => true, :url => @file_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/_bulletin_link2.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletin_link2.html.erb deleted file mode 100644 index a3bc5243..00000000 --- a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletin_link2.html.erb +++ /dev/null @@ -1,17 +0,0 @@ - - "> - - - - - - - - \ 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 7208f73c..b9006352 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,39 +1,41 @@ <% # encoding: utf-8 %> - <%= form_for(@bulletin.bulletin_links, :remote => true, :url => @link_url) do |f| %> + <%= form_for(@bulletin_link, :remote => true, :url => @link_url) do |f| %> - -
- <%= f.label :image, t('announcement.image') %>
- <%= f.file_field :image %> - <% if @bulletin.image.file %> - <%= check_box_tag 'bulletin[image_del]' %> - <%= t('announcement.刪除已上傳檔案') %> - <% end %> -
@@ -200,7 +192,7 @@ <% @bulletin.bulletin_links.each_with_index do |bulletin_link, i| %> <%#= fields_for "bulletin[bulletin_links][]", bulletin_link do |f| %> <%= f.fields_for :bulletin_links, bulletin_link do |f| %> - <%= render :partial => 'bulletin_link', :object => bulletin_link, :locals => {:f => f, :i => i} %> + <%= render :partial => 'form_bulletin_link', :object => bulletin_link, :locals => {:f => f, :i => i} %> <% end %> <% end %> @@ -246,7 +238,7 @@ <% @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} %> + <%= render :partial => 'form_bulletin_file', :object => bulletin_file, :locals => {:f => f, :i => i} %> <% end %> <% end %> @@ -263,7 +255,8 @@
- <%= f.submit 'Submit/送出', :class=>'btn btn-primary' %> + <%= f.submit t('submit'), :class=>'btn btn-primary' %> + <%= link_to t('cancel'), get_go_back, :class=>"btn" %>
@@ -277,13 +270,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); - $(this).parents('table').append(("<%= escape_javascript(add_attribute 'bulletin_link', f, :bulletin_links) %>").replace(old_id, new_id)); + $(this).parents('table').append(("<%= escape_javascript(add_attribute 'form_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); - $(this).parents('table').append(("<%= escape_javascript(add_attribute 'bulletin_file', f, :bulletin_files) %>").replace(old_id, new_id)); + $(this).parents('table').append(("<%= escape_javascript(add_attribute 'form_bulletin_file', f, :bulletin_files) %>").replace(old_id, new_id)); }); <% end %> 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/_form_bulletin_file.html.erb similarity index 66% rename from vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletin_file.html.erb rename to vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_form_bulletin_file.html.erb index ef2d4bc7..65ac2fb8 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/_form_bulletin_file.html.erb @@ -1,5 +1,5 @@ - " class='list_item'> + " class='list_item'> " class='list_item'> + " class='list_item'> + + + + + + + + + + \ No newline at end of file diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_list_bulletin_link.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_list_bulletin_link.html.erb new file mode 100644 index 00000000..33cb9498 --- /dev/null +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_list_bulletin_link.html.erb @@ -0,0 +1,19 @@ + + + + + + + + + + \ No newline at end of file diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_quick_edit_files.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_quick_edit_files.html.erb index e1999aef..8360ad42 100644 --- a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_quick_edit_files.html.erb +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_quick_edit_files.html.erb @@ -11,52 +11,16 @@ - - - - - - - + + <%= render :partial => 'list_bulletin_file', :collection => bulletin.bulletin_files %>
- <%= 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 %> -
<%= 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' %> - -
@@ -8,7 +8,7 @@
- <%= f.fields_for :filetitle, (bulletin_file.new_record? ? bulletin_file.build_filetitle : bulletin_file.filetitle ) do |f| %> + <%= f.fields_for :filetitle, (form_bulletin_file.new_record? ? form_bulletin_file.build_filetitle : form_bulletin_file.filetitle ) do |f| %> <% @site_valid_locales.each do |locale| %>
@@ -20,7 +20,7 @@ <% end %>
- <%= f.fields_for :description, (bulletin_file.new_record? ? bulletin_file.build_description : bulletin_file.description ) do |f| %> + <%= f.fields_for :description, (form_bulletin_file.new_record? ? form_bulletin_file.build_description : form_bulletin_file.description ) do |f| %> <% @site_valid_locales.each do |locale| %>
@@ -33,11 +33,11 @@
- <% if bulletin_file.new_record? %> - + <% if form_bulletin_file.new_record? %> + <% else %> <%= f.hidden_field :id %> - + <%= 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/_form_bulletin_link.html.erb similarity index 59% rename from vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletin_link.html.erb rename to vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_form_bulletin_link.html.erb index c8503083..560e561d 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/_form_bulletin_link.html.erb @@ -1,5 +1,5 @@ -
@@ -9,7 +9,7 @@
- <%= f.fields_for :i18n_variable, (bulletin_link.new_record? ? bulletin_link.build_i18n_variable : bulletin_link.i18n_variable) do |f| %> + <%= f.fields_for :i18n_variable, (form_bulletin_link.new_record? ? form_bulletin_link.build_i18n_variable : form_bulletin_link.i18n_variable) do |f| %> <% @site_valid_locales.each do |locale| %>
@@ -25,11 +25,11 @@
- <% if bulletin_link.new_record? %> - + <% if form_bulletin_link.new_record? %> + <% else %> <%= f.hidden_field :id %> - + <%= 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/_list_bulletin_file.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_list_bulletin_file.html.erb new file mode 100644 index 00000000..c884d0ad --- /dev/null +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_list_bulletin_file.html.erb @@ -0,0 +1,21 @@ + +
<%= list_bulletin_file.file.file ? ( link_to list_bulletin_file.filetitle.zh_tw, list_bulletin_file.file.url, {:target => '_blank', :title => list_bulletin_file.description.zh_tw} ) : list_bulletin_file.filetitle.zh_tw %><%= list_bulletin_file.file.file ? ( link_to list_bulletin_file.filetitle.en, list_bulletin_file.file.url, {:target => '_blank', :title => list_bulletin_file.description.en} ) : list_bulletin_file.filetitle.en %> + + + <%= fields_for "bulletin[bulletin_files_attributes][]", list_bulletin_file, :index => list_bulletin_file_counter do |f| %> + <%= f.hidden_field :id %> + + <%= f.hidden_field :should_destroy, :value => nil , :class => 'should_destroy' %> + <% end %> + +
- ADD/新增 + + <%= t('add')%>
- +
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 7981c2bd..5fea2ded 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 @@ -1,7 +1,7 @@ diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/create_bulletin_file.js.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/create_bulletin_file.js.erb new file mode 100644 index 00000000..303a804a --- /dev/null +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/create_bulletin_file.js.erb @@ -0,0 +1,2 @@ +$("#modal-file").modal('hide'); +$('<%= j render :partial => 'list_bulletin_file', :collection => [@bulletin_file] %>').appendTo('#bulletin_files').hide().fadeIn(); diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/create_bulletin_link.js.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/create_bulletin_link.js.erb new file mode 100644 index 00000000..7d38ed6c --- /dev/null +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/create_bulletin_link.js.erb @@ -0,0 +1,2 @@ +$("#modal-link").modal('hide'); +$('<%= j render :partial => 'list_bulletin_link', :collection => [@bulletin_link] %>').appendTo('#bulletin_links').hide().fadeIn(); 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..ffe288cd 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 @@ -4,4 +4,4 @@ <%= render :partial => 'form', :locals => {:f => f} %> <% end %> -<%= link_back %> +<%#= link_back %> diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/file_quick_add.js.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/file_quick_add.js.erb new file mode 100644 index 00000000..87ded867 --- /dev/null +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/file_quick_add.js.erb @@ -0,0 +1 @@ +$("#modal-file").html("<%= j render "bulletin_file_qe" %>"); diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/file_quick_edit.js.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/file_quick_edit.js.erb new file mode 100644 index 00000000..87ded867 --- /dev/null +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/file_quick_edit.js.erb @@ -0,0 +1 @@ +$("#modal-file").html("<%= j render "bulletin_file_qe" %>"); 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 1fa59469..116455c5 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,6 +2,19 @@ <%= 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_add.js.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/link_quick_add.js.erb new file mode 100644 index 00000000..4e0f8039 --- /dev/null +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/link_quick_add.js.erb @@ -0,0 +1 @@ +$("#modal-link").html("<%= j render "bulletin_link_qe" %>"); 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 index cbe5e3c7..4e0f8039 100644 --- 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 @@ -1,2 +1 @@ -//$.each($(".quick_edit"),function(obj){ $(this).remove(); }); -$("#<%= "bulletin_#{bulletin_link2.id}" %>").append("<%= j render "bulletin_link_qe" %>"); +$("#modal-link").html("<%= j render "bulletin_link_qe" %>"); 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..c05b645b 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| %> +<%= form_for @bulletin, :url => panel_announcement_back_end_bulletins_path, :html => {:class => 'clear'} do |f| %> <%= render :partial => 'form', :locals => {:f => f} %> <% end %> -<%= link_back %> +<%#= link_back %> diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/update_bulletin_file.js.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/update_bulletin_file.js.erb new file mode 100644 index 00000000..bcfedb76 --- /dev/null +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/update_bulletin_file.js.erb @@ -0,0 +1,2 @@ +$("#modal-file").modal('hide'); +$("#<%= dom_id @bulletin_file %>").replaceWith("<%= j render :partial => 'list_bulletin_file', :collection => [@bulletin_file] %>"); diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/update_bulletin_link.js.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/update_bulletin_link.js.erb new file mode 100644 index 00000000..2f21aec8 --- /dev/null +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/update_bulletin_link.js.erb @@ -0,0 +1,2 @@ +$("#modal-link").modal('hide'); +$("#<%= dom_id @bulletin_link %>").replaceWith("<%= j render :partial => 'list_bulletin_link', :collection => [@bulletin_link] %>"); diff --git a/vendor/built_in_modules/announcement/config/routes.rb b/vendor/built_in_modules/announcement/config/routes.rb index 14eec7a2..7ac33a90 100644 --- a/vendor/built_in_modules/announcement/config/routes.rb +++ b/vendor/built_in_modules/announcement/config/routes.rb @@ -13,10 +13,22 @@ Rails.application.routes.draw do member do get 'load_quick_edit' end + match "file_quick_add/:bulletin_id" => "bulletins#file_quick_add" ,:as => :file_quick_add + match "file_quick_edit/:bulletin_id" => "bulletins#file_quick_edit" ,:as => :file_quick_edit end + resources :bulletin_categorys, :controller => 'bulletin_categorys' do match "quick_edit/:bulletin_category_id" => "bulletin_categorys#quick_edit" ,:as => :quick_edit end + + resources :bulletin_links, :controller => 'bulletin_links' do + match "link_quick_edit/:bulletin_link_id" => "bulletin_links#link_quick_edit" ,:as => :link_quick_edit + end + + resources :bulletin_files, :controller => 'bulletin_files' do + match "file_quick_edit/:bulletin_file_id" => "bulletin_files#file_quick_edit" ,:as => :file_quick_edit + end + resources :tags end namespace :front_end do 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 258aa55c..3c734bb0 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 @@ -23,7 +23,8 @@
- <%= f.submit 'Submit/送出', :class=>'btn btn-primary' %> + <%= f.submit t('submit'), :class=>'btn btn-primary' %> + <%= link_to t('cancel'), get_go_back, :class=>"btn" %>
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 86f2398c..7b969d4e 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,7 @@

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

-<%= form_for @page_context, :url => panel_page_content_back_end_page_context_path(@page_context) do |f| %> +<%= form_for @page_context, :url => panel_page_content_back_end_page_context_path(@page_context), :html => {:class => 'clear'} do |f| %> <%= render :partial => 'form', :locals => {:f => f} %> <% end %> 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 0ba3236a..f023995b 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 @@ -35,19 +35,6 @@ class Panel::WebResource::BackEnd::WebLinkCategorysController < ApplicationContr format.js end end - - def quick_edit - # debugger - - @web_link_category = WebLinkCategory.find(params[:web_link_category_id]) - - @url = panel_web_resource_back_end_web_link_category_path(@web_link_category) - - respond_to do |format| - format.js - end - - end # GET /web_links/1/edit def edit 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 dfe09ce5..064a6d46 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 @@ -64,7 +64,7 @@ class Panel::WebResource::BackEnd::WebLinksController < ApplicationController respond_to do |format| if @web_link.save - format.html { redirect_to(panel_web_resource_back_end_web_links_url, :notice => t('web_resource.create_web_resource_success')) } + format.html { redirect_to(panel_web_resource_back_end_web_links_url) } format.xml { render :xml => @web_link, :status => :created, :location => @web_link } else format.html { render :action => "new" } @@ -84,7 +84,7 @@ class Panel::WebResource::BackEnd::WebLinksController < ApplicationController respond_to do |format| if @web_link.update_attributes(params[:web_link]) - format.html { redirect_to(panel_web_resource_back_end_web_links_url, :notice => t('web_resource.update_web_resource_success')) } + format.html { redirect_to(panel_web_resource_back_end_web_links_url) } format.js { render 'toggle_enable' } format.xml { head :ok } else 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 3f6a1a71..9d43b94c 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 @@ -6,7 +6,7 @@
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 2abdf4a0..de163012 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 @@ -25,12 +25,12 @@

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 %> -
+
+ <% @tags.each do |tag| %> + <%= check_box_tag 'web_link[tag_ids][]', tag.id, @web_link.tag_ids.include?(tag.id)%> + <%= tag[I18n.locale] %> + <% end %> +
@@ -89,13 +89,16 @@ <% end %> <% end %>
+ + + + + + +
+ <%= f.submit t('submit'), :class=>'btn btn-primary' %> + <%= link_to t('cancel'), get_go_back, :class=>"btn" %> +
- - - - -
- <%= 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/destroy.js.erb b/vendor/built_in_modules/web_resource/app/views/panel/web_resource/back_end/web_links/destroy.js.erb index 05490b09..b0fbcf1f 100644 --- a/vendor/built_in_modules/web_resource/app/views/panel/web_resource/back_end/web_links/destroy.js.erb +++ b/vendor/built_in_modules/web_resource/app/views/panel/web_resource/back_end/web_links/destroy.js.erb @@ -1 +1 @@ -$("#<%= dom_id @bulletin %>").remove(); \ No newline at end of file +$("#<%= dom_id @web_link %>").remove(); \ No newline at end of file diff --git a/vendor/built_in_modules/web_resource/app/views/panel/web_resource/back_end/web_links/edit.html.erb b/vendor/built_in_modules/web_resource/app/views/panel/web_resource/back_end/web_links/edit.html.erb index 3bf35d16..f70cb1ea 100644 --- a/vendor/built_in_modules/web_resource/app/views/panel/web_resource/back_end/web_links/edit.html.erb +++ b/vendor/built_in_modules/web_resource/app/views/panel/web_resource/back_end/web_links/edit.html.erb @@ -1,16 +1,5 @@ -
-
-
-
-

<%= t('web_resource.editing_web_resource') %>

-<%= form_for @web_link, :url => panel_web_resource_back_end_web_link_path(@web_link) do |f| %> +<%= form_for @web_link, :url => panel_web_resource_back_end_web_link_path(@web_link), :html => {:class => 'clear'} do |f| %> <%= render :partial => 'form', :locals => {:f => f} %> <% end %> - -<%= link_back %> -
-
-
-
\ No newline at end of file diff --git a/vendor/built_in_modules/web_resource/app/views/panel/web_resource/back_end/web_links/new.html.erb b/vendor/built_in_modules/web_resource/app/views/panel/web_resource/back_end/web_links/new.html.erb index 5bc81f44..5e29d138 100644 --- a/vendor/built_in_modules/web_resource/app/views/panel/web_resource/back_end/web_links/new.html.erb +++ b/vendor/built_in_modules/web_resource/app/views/panel/web_resource/back_end/web_links/new.html.erb @@ -1,24 +1,9 @@ -
-
-
-
- -<% content_for :secondary do %> -
    -
  • <%= link_to t('web_link.index'), panel_web_resource_back_end_web_links_path, :class => 'seclink2' %>
  • -
-<% end -%> <%= flash_messages %>

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

-<%= form_for @web_link, :url => panel_web_resource_back_end_web_links_path do |f| %> +<%= form_for @web_link, :url => panel_web_resource_back_end_web_links_path, :html => {:class => 'clear'} do |f| %> <%= render :partial => 'form', :locals => {:f => f} %> <% end %> -<%= link_back %> +<%#= link_back %> - - -
-
-
\ No newline at end of file diff --git a/vendor/built_in_modules/web_resource/config/routes.rb b/vendor/built_in_modules/web_resource/config/routes.rb index 6783cc99..ca0c5d0d 100644 --- a/vendor/built_in_modules/web_resource/config/routes.rb +++ b/vendor/built_in_modules/web_resource/config/routes.rb @@ -5,9 +5,7 @@ Rails.application.routes.draw do namespace :back_end do root :to => "web_links#index" resources :web_links - resources :web_link_categorys, :controller => 'web_link_categorys' do - match "quick_edit/:web_link_category_id" => "web_link_categorys#quick_edit" ,:as => :quick_edit - end + resources :web_link_categorys resources :tags end namespace :front_end do From c4299245de5ae283e3e6950af15c6f2456c23aba Mon Sep 17 00:00:00 2001 From: Christophe Vilayphiou Date: Tue, 27 Mar 2012 14:17:48 +0800 Subject: [PATCH 22/47] Delete files with Chinese characters in name --- .../app/models/bulletin - ƻs.rb | 101 ------------------ .../bulletins/_bulletin_link.html - ƻs.erb | 27 ----- .../bulletins/_bulletin_link2.html - ƻs.erb | 16 --- .../back_end/bulletins/index.html - ƻs.erb | 9 -- .../widget/bulletins/index.html - ƻs.erb | 42 -------- 5 files changed, 195 deletions(-) delete mode 100644 vendor/built_in_modules/announcement/app/models/bulletin - ƻs.rb delete mode 100644 vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletin_link.html - ƻs.erb delete mode 100644 vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletin_link2.html - ƻs.erb delete mode 100644 vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/index.html - ƻs.erb delete mode 100644 vendor/built_in_modules/announcement/app/views/panel/announcement/widget/bulletins/index.html - ƻs.erb diff --git a/vendor/built_in_modules/announcement/app/models/bulletin - ƻs.rb b/vendor/built_in_modules/announcement/app/models/bulletin - ƻs.rb deleted file mode 100644 index c65e65f7..00000000 --- a/vendor/built_in_modules/announcement/app/models/bulletin - ƻs.rb +++ /dev/null @@ -1,101 +0,0 @@ -# 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/bulletins/_bulletin_link.html - ƻs.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletin_link.html - ƻs.erb deleted file mode 100644 index 33d1ba1e..00000000 --- a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletin_link.html - ƻs.erb +++ /dev/null @@ -1,27 +0,0 @@ - -
" 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 - ƻs.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletin_link2.html - ƻs.erb deleted file mode 100644 index c44b5c92..00000000 --- a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletin_link2.html - ƻs.erb +++ /dev/null @@ -1,16 +0,0 @@ - - "> - <%= 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 - ƻs.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/index.html - ƻs.erb deleted file mode 100644 index d37d2134..00000000 --- a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/index.html - ƻs.erb +++ /dev/null @@ -1,9 +0,0 @@ -<%= 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/widget/bulletins/index.html - ƻs.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/widget/bulletins/index.html - ƻs.erb deleted file mode 100644 index 2c4cd153..00000000 --- a/vendor/built_in_modules/announcement/app/views/panel/announcement/widget/bulletins/index.html - ƻs.erb +++ /dev/null @@ -1,42 +0,0 @@ - - -<% 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 33955b455423cfc2e7c941971370435dd37beac1 Mon Sep 17 00:00:00 2001 From: Christophe Vilayphiou Date: Tue, 27 Mar 2012 14:21:32 +0800 Subject: [PATCH 23/47] Delete files with Chinese characters in name --- .../app/models/bulletin - %BDƻs.rb | 101 ------------------ .../bulletins/_bulletin_link.html - %BDƻs.erb | 27 ----- .../_bulletin_link2.html - %BDƻs.erb | 16 --- .../back_end/bulletins/index.html - %BDƻs.erb | 9 -- .../widget/bulletins/index.html - %BDƻs.erb | 42 -------- 5 files changed, 195 deletions(-) delete mode 100644 vendor/built_in_modules/announcement/app/models/bulletin - %BDƻs.rb delete mode 100644 vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletin_link.html - %BDƻs.erb delete mode 100644 vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletin_link2.html - %BDƻs.erb delete mode 100644 vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/index.html - %BDƻs.erb delete 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 deleted file mode 100644 index c65e65f7..00000000 --- a/vendor/built_in_modules/announcement/app/models/bulletin - %BDƻs.rb +++ /dev/null @@ -1,101 +0,0 @@ -# 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/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 deleted file mode 100644 index 33d1ba1e..00000000 --- a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletin_link.html - %BDƻs.erb +++ /dev/null @@ -1,27 +0,0 @@ - -
" 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 deleted file mode 100644 index c44b5c92..00000000 --- a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletin_link2.html - %BDƻs.erb +++ /dev/null @@ -1,16 +0,0 @@ - - "> - <%= 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 deleted file mode 100644 index d37d2134..00000000 --- a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/index.html - %BDƻs.erb +++ /dev/null @@ -1,9 +0,0 @@ -<%= 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/widget/bulletins/index.html - %BDƻs.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/widget/bulletins/index.html - %BDƻs.erb deleted file mode 100644 index 2c4cd153..00000000 --- a/vendor/built_in_modules/announcement/app/views/panel/announcement/widget/bulletins/index.html - %BDƻs.erb +++ /dev/null @@ -1,42 +0,0 @@ - - -<% 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 422a49f56c50533807d7208068a416f589a37b77 Mon Sep 17 00:00:00 2001 From: Christophe Vilayphiou Date: Tue, 27 Mar 2012 15:03:00 +0800 Subject: [PATCH 24/47] 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 25/47] 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 48d1d45ced0f8481f25876fb847c9a713544ef11 Mon Sep 17 00:00:00 2001 From: Christophe Vilayphiou Date: Tue, 27 Mar 2012 17:57:50 +0800 Subject: [PATCH 26/47] 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 27/47] 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 28/47] 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 29/47] 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| %> + + +