From c0cac812c544743b80ad06d893838d378445600b Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 26 Jul 2012 16:39:29 +0800 Subject: [PATCH] demo site widget --- .../jquery.mu.image.resize.degsin.js | 6 + .../javascripts/jquery.mu.image.resize.js | 147 ++++++ app/assets/javascripts/page_edit.js.erb | 4 + .../admin/page_parts_controller.rb | 18 + app/models/module_app.rb | 1 + app/models/page_part.rb | 1 + app/models/site.rb | 2 + app/uploaders/image_uploader.rb | 5 +- .../admin/page_parts/_module_widget.html.erb | 21 +- .../admin/page_parts/_widget_styles.html.erb | 1 + .../page_parts/reload_widget_styles.js.erb | 1 + .../admin/page_parts/reload_widgets.js.erb | 1 + app/views/admin/sites/site_info.html.erb | 20 + config/routes.rb | 1 + lib/parsers/parser_common.rb | 2 +- .../announcement/announcement.json | 3 +- .../widget/bulletins_controller.rb | 224 +-------- .../widget/bulletins/_index.html.erb | 443 +++--------------- .../widget/bulletins/index.html.erb | 4 + 19 files changed, 312 insertions(+), 593 deletions(-) create mode 100644 app/assets/javascripts/jquery.mu.image.resize.degsin.js create mode 100644 app/assets/javascripts/jquery.mu.image.resize.js create mode 100644 app/views/admin/page_parts/_widget_styles.html.erb create mode 100644 app/views/admin/page_parts/reload_widget_styles.js.erb diff --git a/app/assets/javascripts/jquery.mu.image.resize.degsin.js b/app/assets/javascripts/jquery.mu.image.resize.degsin.js new file mode 100644 index 00000000..9c87bf78 --- /dev/null +++ b/app/assets/javascripts/jquery.mu.image.resize.degsin.js @@ -0,0 +1,6 @@ + var pic = $(".app-pic").length,w,h; + for(i=0; i'; + }); + } + + if (!$.browser.msie) + { + // Get original size for calcutation. + ow = this.width; + oh = this.height; + } + + // if cannot get width or height. + if (0==ow || 0==oh){ + $(this).width(_set.width); + $(this).height(_set.height); + }else{ + + // Merge position settings + var sh_margin_type=''; + + // if original image's width > height. + if (ow > oh) { + p = oh / _set.height; + oh = _set.height; + ow = ow / p; + + // original image width smaller than settings. + if (ow < _set.width){ + // need to resize again, + // because new image size range must can cover settings' range, than we can crop it correctly. + p = ow / _set.width; + ow = _set.width; + oh = oh / p; + + // the crop range would be in the center of new image size. + sh = (oh-_set.height)/2; + t=sh+'px'; + r=_set.width+'px'; + b=(_set.height+sh)+'px'; + l='0px'; + + // need to be adjust top position latter. + sh_margin_type = 'margin-top'; + + // original image width bigger than settings. + }else{ + // new image range can cover settings' range. + sh = (ow-_set.width)/2; + t='0px'; + r=(_set.width+sh)+'px'; + b=_set.height+'px'; + l=sh+'px'; + // need to be adjust left position latter. + sh_margin_type = 'margin-left'; + } + // ref above, change width to height then do same things. + }else{ + p = ow / _set.width; + ow = _set.width; + oh = oh / p; + + if (oh < _set.height) { + p = oh / _set.height; + oh = _set.height; + ow = ow / p; + + sh = (ow-_set.width)/2; + t='0px'; + r=(_set.width+sh)+'px'; + b=_set.height+'px'; + l=sh+'px'; + sh_margin_type = 'margin-left'; + }else{ + sh = (oh-_set.height)/2; + t=sh+'px'; + r=_set.width+'px'; + b=(_set.height+sh)+'px'; + l='0px'; + sh_margin_type = 'margin-top'; + } + } + + // Resize img. + $(this).width(ow); + $(this).height(oh); + + // Crop img by set clip style. + $(this).css('clip','rect('+t+' '+r+' '+b+' '+l+')'); + + var osh = 0; + if('auto' != $(this).css(sh_margin_type)){ + osh = parseInt($(this).css(sh_margin_type)); + } + + if (0 < sh) {sh*=-1;} + sh += osh; + + $(this).css(sh_margin_type, sh+'px'); + $(this).css('position','absolute'); + } + $(this).fadeIn('slow'); + }) + .one( "error", function() { + //$(this).hide(); + }) + .each(function() { + $(this).hide(); + // Trigger load event (for Gecko and MSIE) + if ( this.complete || $.browser.msie ) { + $( this ).trigger( "load" ).trigger( "error" ); + } + }); + }; + +})( jQuery ); \ No newline at end of file diff --git a/app/assets/javascripts/page_edit.js.erb b/app/assets/javascripts/page_edit.js.erb index d7aaccd0..8d2ca97c 100644 --- a/app/assets/javascripts/page_edit.js.erb +++ b/app/assets/javascripts/page_edit.js.erb @@ -24,6 +24,10 @@ $("#module_app_list select").live('change', function() { $.getScript($(this).attr('rel') + '/' + $(this).val() + '/reload_widgets'); }); +$("#widget_list select").live('change', function() { + $.getScript($(this).attr('rel') + '/' + $(this).val() + '/reload_widget_styles?module_app_id=' + $("#module_app_list select").val()); +}); + $("#tag_list select").live('change', function() { $.getScript($(this).attr('rel') + '/' + $(this).val() + '/reload_r_tag_options'); }); diff --git a/app/controllers/admin/page_parts_controller.rb b/app/controllers/admin/page_parts_controller.rb index 9ef2aa1b..d75b54aa 100644 --- a/app/controllers/admin/page_parts_controller.rb +++ b/app/controllers/admin/page_parts_controller.rb @@ -26,6 +26,10 @@ class Admin::PagePartsController < ApplicationController @module_app = @part.module_app ? @part.module_app : @module_apps[0] @r_tag = @part.public_r_tag.blank? ? LIST[:public_r_tags][0] : @part.public_r_tag @tag_objects = @r_tag.classify.constantize.all rescue nil + + @widget_path = @part.widget_path ? @part.widget_path : @module_app.widgets.keys[0] + @widget_style = @module_app.widgets[@widget_path] + case @module_app.key when 'announcement' @categories = BulletinCategory.all @@ -69,8 +73,12 @@ class Admin::PagePartsController < ApplicationController def reload_widgets @module_app = ModuleApp.find(params[:id]) + + @widget_path = @module_app.widgets.keys[0] + @widget_style = @module_app.widgets[@widget_path] case @module_app.key when 'announcement' + # @widget_style = @module_app.widgets['index'] @categories = BulletinCategory.all @tags = AnnouncementTag.all when 'news' @@ -84,6 +92,16 @@ class Admin::PagePartsController < ApplicationController format.js {} end end + + def reload_widget_styles + @module_app = ModuleApp.find(params[:module_app_id]) + + @widget_style = @module_app.widgets[params[:id]] + + respond_to do |format| + format.js {} + end + end def reload_r_tag_options @r_tag = (ModuleApp.find(params[:id]) rescue nil) || params[:id] diff --git a/app/models/module_app.rb b/app/models/module_app.rb index 315bc93e..007467de 100644 --- a/app/models/module_app.rb +++ b/app/models/module_app.rb @@ -16,6 +16,7 @@ class ModuleApp field :app_pages ,type: Array # field :widgets ,type: Array field :widgets ,type: Hash + field :widget_fields ,type: Array has_many :managers,as: :managing_app ,:class_name => "AppManager" #,:dependent => :destroy,:foreign_key => "managing_app_id",:inverse_of => :managing_app has_many :sub_managers,as: :sub_managing_app ,:class_name => "AppManager"#, :dependent => :destroy,:foreign_key => "sub_managing_app_id",:inverse_of => :sub_managing_app diff --git a/app/models/page_part.rb b/app/models/page_part.rb index 1cb095b2..4d75dbbf 100644 --- a/app/models/page_part.rb +++ b/app/models/page_part.rb @@ -11,6 +11,7 @@ class PagePart field :public_r_tag_option, :default => nil field :widget_path field :widget_style + field :widget_field , :type => Array field :widget_data_count has_one :i18n_variable, :class_name => "I18nVariable", :as => :language_value, :autosave => true, :dependent => :destroy diff --git a/app/models/site.rb b/app/models/site.rb index 55d6bfaf..0baa743f 100644 --- a/app/models/site.rb +++ b/app/models/site.rb @@ -17,6 +17,8 @@ class Site field :school field :department + + mount_uploader :default_image, ImageUploader has_one :title, :class_name => "I18nVariable", :as => :language_value, :autosave => true, :dependent => :destroy has_one :footer, :class_name => "I18nVariable", :as => :language_value, :autosave => true, :dependent => :destroy diff --git a/app/uploaders/image_uploader.rb b/app/uploaders/image_uploader.rb index 29a4d92b..ed142405 100644 --- a/app/uploaders/image_uploader.rb +++ b/app/uploaders/image_uploader.rb @@ -30,7 +30,10 @@ class ImageUploader < CarrierWave::Uploader::Base # def default_url # "/images/fallback/" + [version_name, "default.png"].compact.join('_') # end - + def default_url + Site.first.default_image.url rescue "-sign-in-logo.png" + end + # Process files as they are uploaded: # process :scale => [200, 300] # diff --git a/app/views/admin/page_parts/_module_widget.html.erb b/app/views/admin/page_parts/_module_widget.html.erb index 87439e3f..279ba62e 100644 --- a/app/views/admin/page_parts/_module_widget.html.erb +++ b/app/views/admin/page_parts/_module_widget.html.erb @@ -14,13 +14,13 @@ - <%= f.select :widget_path, @module_app.widgets.collect{|widget| [widget.humanize, widget]}, :selected => @part.widget_path %> - <%#= f.select :widget_path, @module_app.widgets.collect{|k,v| k}, :selected => @part.widget_path %> + <%#= f.select :widget_path, @module_app.widgets.collect{|widget| [widget.humanize, widget]}, :selected => @part.widget_path %> + <%= f.select :widget_path, @module_app.widgets.collect{|k,v| [k.humanize, k]}, {}, { :selected => @part.widget_path, :rel => admin_page_parts_path } %> -<%= @module_app.widget_indexs.collect { |k,v| v } %> - <%= f.select :widget_style, @module_app.widget_styles.each, :selected => @part.widget_style, :include_blank => 'None' %> + <%= f.select :widget_style, @widget_style, :selected => @part.widget_style %> + <%#= render 'widget_styles' %> : @@ -33,6 +33,19 @@ <%= render 'widget_tags' %> + + + <%= f.label :widget_field %> + + <% @module_app.widget_fields.each_with_index do |widget_field, i| %> + <%= i+1 %> + <%= select_tag "page_part[widget_field][]", options_for_select(@module_app.widget_fields.collect{|widget_field| [widget_field.humanize, widget_field]}, (@part.widget_field ? @part.widget_field[i] : nil) ), :include_blank => true %>
+ + <% end %> + + <%#= select_tag "page_part[widget_field][]", options_for_select(@module_app.widget_fields.collect{|widget_field| [widget_field.humanize, widget_field]}, @part.widget_field.collect{|widget_field| widget_field}), {:multiple => :multiple, :size => 6} %> +
+
<%= f.label :widget_data_count %> <%= f.text_field :widget_data_count %> diff --git a/app/views/admin/page_parts/_widget_styles.html.erb b/app/views/admin/page_parts/_widget_styles.html.erb new file mode 100644 index 00000000..1f9ef84f --- /dev/null +++ b/app/views/admin/page_parts/_widget_styles.html.erb @@ -0,0 +1 @@ + <%= select 'page_part', 'widget_style', @widget_style, :selected => (@part ? @part[:widget_style] : nil), :include_blank => true if @widget_style && @widget_style.size > 0 %> \ No newline at end of file diff --git a/app/views/admin/page_parts/reload_widget_styles.js.erb b/app/views/admin/page_parts/reload_widget_styles.js.erb new file mode 100644 index 00000000..41b2ad9c --- /dev/null +++ b/app/views/admin/page_parts/reload_widget_styles.js.erb @@ -0,0 +1 @@ +$('#widget_style_list select').html("<%= j options_for_select(@module_app.widgets[params[:id]]) %>") diff --git a/app/views/admin/page_parts/reload_widgets.js.erb b/app/views/admin/page_parts/reload_widgets.js.erb index 87e00ef1..8dca2040 100644 --- a/app/views/admin/page_parts/reload_widgets.js.erb +++ b/app/views/admin/page_parts/reload_widgets.js.erb @@ -1,3 +1,4 @@ $('#widget_list select').html("<%= j options_for_select(@module_app.widgets.collect{|k,v| k}) %>") +$('#widget_style_list select').html("<%= j options_for_select(@module_app.widgets[@widget_path]) %>") $('#widget_category').html("<%= j render 'widget_categories' %>") $('#widget_tag').html("<%= j render 'widget_tags' %>") \ No newline at end of file diff --git a/app/views/admin/sites/site_info.html.erb b/app/views/admin/sites/site_info.html.erb index e19307ca..1dccac31 100644 --- a/app/views/admin/sites/site_info.html.erb +++ b/app/views/admin/sites/site_info.html.erb @@ -1,3 +1,5 @@ +<% # encoding: utf-8 %> + <% content_for :side_bar do %> <%= render 'side_bar' %> <% end %> @@ -70,6 +72,24 @@ <% end %>
+
+ +
+ <%= f.file_field :default_image, :id => "input-upload", :class => 'upload', :onchange => "document.getElementById('fu').innerHTML = this.form.fu.value = this.value;" %> + + + <% if @site.default_image %> + <%= image_tag( @site.default_image, :size=>"120x120") rescue ''%> + <% else %> + + <% end %> +
+ <% if @site.default_image.file %> + <%= f.check_box :remove_default_image %> + <%= t('刪除已上傳檔案') %> + <% end %> +
+
<% end %> <% end %> diff --git a/config/routes.rb b/config/routes.rb index 60e8a205..570ab68a 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -97,6 +97,7 @@ Orbit::Application.routes.draw do resources :page_parts do member do get 'reload_widgets' + get 'reload_widget_styles' get 'reload_r_tag_options' end end diff --git a/lib/parsers/parser_common.rb b/lib/parsers/parser_common.rb index 06c937de..18140aa1 100644 --- a/lib/parsers/parser_common.rb +++ b/lib/parsers/parser_common.rb @@ -187,7 +187,7 @@ module ParserCommon ret << part.i18n_variable[I18n.locale] rescue '' when 'module_widget' url = "/panel/#{part.module_app.key}/widget/#{part.widget_path}?inner=true" - options = "&category_id=#{!part[:category].blank? ? part[:category].blank? : category}&tag_id=#{!part[:tag].blank? ? part[:tag] : tag}&page=#{params[:page]}&part_title=#{Rack::Utils.escape(part_title).gsub("+", "%20") rescue nil}&widget_style=#{part.widget_style}&widget_data_count=#{part[:widget_data_count]}" + options = "&category_id=#{!part[:category].blank? ? part[:category] : category}&tag_id=#{!part[:tag].blank? ? part[:tag] : tag}&page=#{params[:page]}&part_title=#{Rack::Utils.escape(part_title).gsub("+", "%20") rescue nil}&part_id=#{part.id}" ret << "
" when 'public_r_tag' ret << "" diff --git a/vendor/built_in_modules/announcement/announcement.json b/vendor/built_in_modules/announcement/announcement.json index 83e0fb51..a9f245f2 100644 --- a/vendor/built_in_modules/announcement/announcement.json +++ b/vendor/built_in_modules/announcement/announcement.json @@ -8,8 +8,9 @@ "create_date": "11-11-2011", "app_pages": ["bulletins"], "widgets": { - "index":["1","2","3","4","5","6","7","8","9",,"10","11","12","13","14","15","16","17","18","19"], + "index":["1","2"], "bulletins_and_web_links":[] }, + "widget_fields":["title","subtitle","date","image","status"], "enable_frontend": true } 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 fcdd7559..8d38802a 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 @@ -10,220 +10,30 @@ class Panel::Announcement::Widget::BulletinsController < OrbitWidgetController def index - if params[:widget_data_count] - @page_num = params[:widget_data_count]; + @part = PagePart.find(params[:part_id]) + + if @part.widget_data_count + @page_num = @part.widget_data_count else - @page_num = 4; + @page_num = 4 + end + + if @part.widget_field + @widget_fields = @part.widget_field + else + @widget_fields = [] end @title = params[:part_title] - @widget_style = params[:widget_style] + @widget_style = @part.widget_style + + @category_id = @part.category date_now = Time.now - if !params[:category_id].blank? - @bulletins = Bulletin.can_display.where(:bulletin_category_id => params[:category_id]).any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page] ).per(5) - @current_category = BulletinCategory.from_id(params[:category_id]) rescue nil - elsif !params[:tag_id].blank? - @tag = AnnouncementTag.find(params[:tag_id]) rescue nil - @tag = AnnouncementTag.where(key: params[:tag_id])[0] unless @tag - @bulletins = @tag.bulletins.can_display.any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page] ).per(@page_num) - else - @bulletins = Bulletin.can_display.any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page] ).per(@page_num) - end - - get_categorys - - end - - def bulletins_list_2 - - if params[:widget_data_count] - @page_num = params[:widget_data_count]; - else - @page_num = 4; - end - - @title = params[:part_title] - date_now = Time.now - if !params[:category_id].blank? - @bulletins = Bulletin.can_display.where(:bulletin_category_id => params[:category_id]).any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page] ).per(5) - @current_category = BulletinCategory.from_id(params[:category_id]) rescue nil - elsif !params[:tag_id].blank? - @tag = AnnouncementTag.find(params[:tag_id]) rescue nil - @tag = AnnouncementTag.where(key: params[:tag_id])[0] unless @tag - @bulletins = @tag.bulletins.can_display.any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page] ).per(@page_num) - else - @bulletins = Bulletin.can_display.any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page] ).per(@page_num) - end - - get_categorys - - end - - def bulletins_list_3 - - if params[:widget_data_count] - @page_num = params[:widget_data_count]; - else - @page_num = 4; - end - - @title = params[:part_title] - date_now = Time.now - if !params[:category_id].blank? - @bulletins = Bulletin.can_display.where(:bulletin_category_id => params[:category_id]).any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page] ).per(5) - @current_category = BulletinCategory.from_id(params[:category_id]) rescue nil - elsif !params[:tag_id].blank? - @tag = AnnouncementTag.find(params[:tag_id]) rescue nil - @tag = AnnouncementTag.where(key: params[:tag_id])[0] unless @tag - @bulletins = @tag.bulletins.can_display.any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page] ).per(@page_num) - else - @bulletins = Bulletin.can_display.any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page] ).per(@page_num) - end - - get_categorys - - end - - def bulletins_list_4 - - if params[:widget_data_count] - @page_num = params[:widget_data_count]; - else - @page_num = 4; - end - - @title = params[:part_title] - date_now = Time.now - if !params[:category_id].blank? - @bulletins = Bulletin.can_display.where(:bulletin_category_id => params[:category_id]).any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page] ).per(5) - @current_category = BulletinCategory.from_id(params[:category_id]) rescue nil - elsif !params[:tag_id].blank? - @tag = AnnouncementTag.find(params[:tag_id]) rescue nil - @tag = AnnouncementTag.where(key: params[:tag_id])[0] unless @tag - @bulletins = @tag.bulletins.can_display.any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page] ).per(@page_num) - else - @bulletins = Bulletin.can_display.any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page] ).per(@page_num) - end - - get_categorys - - end - - def bulletins_list_5 - - if params[:widget_data_count] - @page_num = params[:widget_data_count]; - else - @page_num = 4; - end - - @title = params[:part_title] - date_now = Time.now - if !params[:category_id].blank? - @bulletins = Bulletin.can_display.where(:bulletin_category_id => params[:category_id]).any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page] ).per(5) - @current_category = BulletinCategory.from_id(params[:category_id]) rescue nil - elsif !params[:tag_id].blank? - @tag = AnnouncementTag.find(params[:tag_id]) rescue nil - @tag = AnnouncementTag.where(key: params[:tag_id])[0] unless @tag - @bulletins = @tag.bulletins.can_display.any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page] ).per(@page_num) - else - @bulletins = Bulletin.can_display.any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page] ).per(@page_num) - end - - get_categorys - - end - - def bulletins_list_6 - - if params[:widget_data_count] - @page_num = params[:widget_data_count]; - else - @page_num = 4; - end - - @title = params[:part_title] - date_now = Time.now - if !params[:category_id].blank? - @bulletins = Bulletin.can_display.where(:bulletin_category_id => params[:category_id]).any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page] ).per(5) - @current_category = BulletinCategory.from_id(params[:category_id]) rescue nil - elsif !params[:tag_id].blank? - @tag = AnnouncementTag.find(params[:tag_id]) rescue nil - @tag = AnnouncementTag.where(key: params[:tag_id])[0] unless @tag - @bulletins = @tag.bulletins.can_display.any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page] ).per(@page_num) - else - @bulletins = Bulletin.can_display.any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page] ).per(@page_num) - end - - get_categorys - - end - - def bulletins_list_7 - - if params[:widget_data_count] - @page_num = params[:widget_data_count]; - else - @page_num = 4; - end - - @title = params[:part_title] - date_now = Time.now - if !params[:category_id].blank? - @bulletins = Bulletin.can_display.where(:bulletin_category_id => params[:category_id]).any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page] ).per(5) - @current_category = BulletinCategory.from_id(params[:category_id]) rescue nil - elsif !params[:tag_id].blank? - @tag = AnnouncementTag.find(params[:tag_id]) rescue nil - @tag = AnnouncementTag.where(key: params[:tag_id])[0] unless @tag - @bulletins = @tag.bulletins.can_display.any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page] ).per(@page_num) - else - @bulletins = Bulletin.can_display.any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page] ).per(@page_num) - end - - get_categorys - - end - - def bulletins_list_8 - - if params[:widget_data_count] - @page_num = params[:widget_data_count]; - else - @page_num = 4; - end - - @title = params[:part_title] - date_now = Time.now - if !params[:category_id].blank? - @bulletins = Bulletin.can_display.where(:bulletin_category_id => params[:category_id]).any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page] ).per(5) - @current_category = BulletinCategory.from_id(params[:category_id]) rescue nil - elsif !params[:tag_id].blank? - @tag = AnnouncementTag.find(params[:tag_id]) rescue nil - @tag = AnnouncementTag.where(key: params[:tag_id])[0] unless @tag - @bulletins = @tag.bulletins.can_display.any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page] ).per(@page_num) - else - @bulletins = Bulletin.can_display.any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page] ).per(@page_num) - end - - get_categorys - - end - - def bulletins_list_9 - - if params[:widget_data_count] - @page_num = params[:widget_data_count]; - else - @page_num = 4; - end - - @title = params[:part_title] - date_now = Time.now - if !params[:category_id].blank? - @bulletins = Bulletin.can_display.where(:bulletin_category_id => params[:category_id]).any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page] ).per(5) - @current_category = BulletinCategory.from_id(params[:category_id]) rescue nil + if !@category_id.blank? + @bulletins = Bulletin.can_display.where(:bulletin_category_id => @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(@page_num) + @current_category = BulletinCategory.from_id(@category_id) rescue nil elsif !params[:tag_id].blank? @tag = AnnouncementTag.find(params[:tag_id]) rescue nil @tag = AnnouncementTag.where(key: params[:tag_id])[0] unless @tag diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/widget/bulletins/_index.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/widget/bulletins/_index.html.erb index 77a8fa37..f6767b1b 100644 --- a/vendor/built_in_modules/announcement/app/views/panel/announcement/widget/bulletins/_index.html.erb +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/widget/bulletins/_index.html.erb @@ -5,403 +5,88 @@ <% if @widget_style == '1' %> -

========== 1狀態(置頂 熱門等) 日期 標題 ==========

+

========== 1 ==========

    - <% @bulletins.each do |post| %> + <% @bulletins.each_with_index do |post, i| %> -
  • - <% if post.is_top? %> - <%= t(:top) %> +
  • > + <% @widget_fields.each do |wf| %> + + <% if wf == 'title' %> + <%= link_to post.title[I18n.locale], panel_announcement_front_end_bulletin_path(post, :category_id => post.bulletin_category_id), :class=>"newstitle" %> + <% elsif wf == 'date' %> + <%= display_date(post.postdate) %> + <% elsif wf == 'status' %> + <% if post.is_top? %> + <%= t(:top) %> + <% end %> + <% if post.is_hot? %> + <%= t(:hot) %> + <% end %> + <% elsif wf == 'subtitle' %> + <%= post.subtitle[I18n.locale].html_safe %> + <% elsif wf == 'image' %> +
    <%#= image_tag(post.image.url, :size => "90x90") if post.image.file %><%= image_tag(post.image.url) %>
    + <% end %> + <% end %> - <% if post.is_hot? %> - <%= t(:hot) %> - <% end %> - <%= display_date(post.postdate) %> - <%= link_to post.title[I18n.locale], panel_announcement_front_end_bulletin_path(post, :category_id => post.bulletin_category_id), :class=>"newstitle" %>
  • <% end %>
-
more
+ + <% if !@category_id.blank? %> +
<%= link_to t('more'), panel_announcement_front_end_bulletins_path( :category_id => @category_id ) %>
+ <% else %> +
<%= link_to t('more'), panel_announcement_front_end_bulletins_path() %>
+ <% end %>
<% elsif @widget_style == '2' %> -

========== 2日期 標題 ==========

+

========== 2 ==========

+ +
+
<%= image_tag(@bulletins.first.image.url) %>
+
    + + <% @bulletins.each_with_index do |post, i| %> + +
  • > + <% @widget_fields.each do |wf| %> + + <% if wf == 'title' %> + <%= link_to post.title[I18n.locale], panel_announcement_front_end_bulletin_path(post, :category_id => post.bulletin_category_id), :class=>"newstitle" %> + <% elsif wf == 'date' %> + <%= display_date(post.postdate) %> + <% elsif wf == 'status' %> + <% if post.is_top? %> + <%= t(:top) %> + <% end %> + <% if post.is_hot? %> + <%= t(:hot) %> + <% end %> + <% elsif wf == 'subtitle' %> + <%= post.subtitle[I18n.locale].html_safe %> + <% end %> + + <% end %> +
  • + + <% end %> +
-
-
    - <% @bulletins.each do |post| %> - -
  • - <%= display_date(post.postdate) %> - <%= link_to post.title[I18n.locale], panel_announcement_front_end_bulletin_path(post, :category_id => post.bulletin_category_id), :class=>"newstitle" %> -
  • - - <% end %> -
-
more
-
- -<% elsif @widget_style == '3' %> - -

========== 3狀態(置頂 熱門等) 標題 ==========

+ <% if !@category_id.blank? %> +
<%= link_to t('more'), panel_announcement_front_end_bulletins_path( :category_id => @category_id ) %>
+ <% else %> +
<%= link_to t('more'), panel_announcement_front_end_bulletins_path() %>
+ <% end %> -
-
    - <% @bulletins.each do |post| %> - -
  • - <% if post.is_top? %> - <%= t(:top) %> - <% end %> - <% if post.is_hot? %> - <%= t(:hot) %> - <% end %> - <%= link_to post.title[I18n.locale], panel_announcement_front_end_bulletin_path(post, :category_id => post.bulletin_category_id), :class=>"newstitle" %> -
  • - - <% end %> -
-
more
-
- -<% elsif @widget_style == '4' %> - -

========== 4狀態(置頂 熱門等) 類別 日期 標題 ==========

- -
-
    - <% @bulletins.each do |post| %> - -
  • - <% if post.is_top? %> - <%= t(:top) %> - <% end %> - <% if post.is_hot? %> - <%= t(:hot) %> - <% end %> - <%= display_date(post.postdate) %> - <%= post.bulletin_category.i18n_variable[I18n.locale] rescue nil %> - <%= link_to post.title[I18n.locale], panel_announcement_front_end_bulletin_path(post, :category_id => post.bulletin_category_id), :class=>"newstitle" %> -
  • - - <% end %> -
-
more
- -<% elsif @widget_style == '5' %> - -

========== 5日期 類別 標題 ==========

- -
-
    - <% @bulletins.each do |post| %> - -
  • - <%= display_date(post.postdate) %> - <%= post.bulletin_category.i18n_variable[I18n.locale] rescue nil %> - <%= link_to post.title[I18n.locale], panel_announcement_front_end_bulletin_path(post, :category_id => post.bulletin_category_id), :class=>"newstitle" %> -
  • - - <% end %> -
-
more
-
- -<% elsif @widget_style == '6' %> - -

========== 6狀態(置頂 熱門等) 類別 標題 ==========

- -
-
    - <% @bulletins.each do |post| %> - -
  • - <% if post.is_top? %> - <%= t(:top) %> - <% end %> - <% if post.is_hot? %> - <%= t(:hot) %> - <% end %> - <%= post.bulletin_category.i18n_variable[I18n.locale] rescue nil %> - <%= link_to post.title[I18n.locale], panel_announcement_front_end_bulletin_path(post, :category_id => post.bulletin_category_id), :class=>"newstitle" %> -
  • - - <% end %> -
-
more
-
- -<% elsif @widget_style == '7' %> - -

========== 7上架日期 標題 契子 ==========

- -
-
    - <% @bulletins.each do |post| %> - -
  • - <%= display_date(post.postdate) %> - <%= link_to post.title[I18n.locale], panel_announcement_front_end_bulletin_path(post, :category_id => post.bulletin_category_id), :class=>"newstitle" %> - <%= post.subtitle[I18n.locale].html_safe %> -
  • - - <% end %> -
-
more
-
- -<% elsif @widget_style == '8' %> - -

========== 8上架日期 標題 契子 狀態 ==========

- -
-
    - <% @bulletins.each do |post| %> - -
  • - <% if post.is_top? %> - <%= t(:top) %> - <% end %> - <% if post.is_hot? %> - <%= t(:hot) %> - <% end %> - <%= display_date(post.postdate) %> - <%= link_to post.title[I18n.locale], panel_announcement_front_end_bulletin_path(post, :category_id => post.bulletin_category_id), :class=>"newstitle" %> - <%= post.subtitle[I18n.locale].html_safe %> -
  • - - <% end %> -
-
more
-
- -<% elsif @widget_style == '9' %> - -

========== 9上架日期 標題 瀏覽人次 ==========

- -
-
    - <% @bulletins.each do |post| %> - -
  • - <%= display_date(post.postdate) %> - <%= link_to post.title[I18n.locale], panel_announcement_front_end_bulletin_path(post, :category_id => post.bulletin_category_id), :class=>"newstitle" %> - <%= post.view_count %> -
  • - - <% end %> -
-
more
-
- -<% elsif @widget_style == '10' %> - -

========== 10圖 標題 ==========

- -
-
    - <% @bulletins.each do |post| %> -
  • -
    <%= image_tag(post.image.url, :size => "90x90") if post.image.file %>
    - <%= link_to post.title[I18n.locale], panel_announcement_front_end_bulletin_path(post, :category_id => post.bulletin_category_id), :class=>"newstitle" %> -
  • - <% end %> -
-
more
-
- -<% elsif @widget_style == '11' %> - -

========== 11圖 日期 標題 ==========

- -
-
    - <% @bulletins.each do |post| %> -
  • -
    <%= image_tag(post.image.url, :size => "90x90") if post.image.file %>
    - <%= display_date(post.postdate) %> - <%= link_to post.title[I18n.locale], panel_announcement_front_end_bulletin_path(post, :category_id => post.bulletin_category_id), :class=>"newstitle" %> -
  • - <% end %> -
-
more
-
- -<% elsif @widget_style == '12' %> - -

========== 12圖 標題 狀態 ==========

- -
-
    - <% @bulletins.each do |post| %> -
  • -
    <%= image_tag(post.image.url, :size => "90x90") if post.image.file %>
    - <%= link_to post.title[I18n.locale], panel_announcement_front_end_bulletin_path(post, :category_id => post.bulletin_category_id), :class=>"newstitle" %> - <% if post.is_top? %> - <%= t(:top) %> - <% end %> - <% if post.is_hot? %> - <%= t(:hot) %> - <% end %> -
  • - <% end %> -
-
more
-
- -<% elsif @widget_style == '13' %> - -

========== 13圖 日期 標題 狀態 ==========

- -
-
    - <% @bulletins.each do |post| %> -
  • -
    <%= image_tag(post.image.url, :size => "90x90") if post.image.file %>
    - <% if post.is_top? %> - <%= t(:top) %> - <% end %> - <% if post.is_hot? %> - <%= t(:hot) %> - <% end %> - <%= display_date(post.postdate) %> - <%= link_to post.title[I18n.locale], panel_announcement_front_end_bulletin_path(post, :category_id => post.bulletin_category_id), :class=>"newstitle" %> -
  • - <% end %> -
-
more
-
- -<% elsif @widget_style == '14' %> - -

========== 14圖 標題 契子 ==========

- -
-
    - <% @bulletins.each do |post| %> -
  • -
    <%= image_tag(post.image.url, :size => "90x90") if post.image.file %>
    - <%= link_to post.title[I18n.locale], panel_announcement_front_end_bulletin_path(post, :category_id => post.bulletin_category_id), :class=>"newstitle" %> - <%= post.subtitle[I18n.locale].html_safe %> -
  • - <% end %> -
-
more
-
- -<% elsif @widget_style == '15' %> - -

========== 15圖 標題 契子 狀態 ==========

- -
-
    - <% @bulletins.each do |post| %> -
  • -
    <%= image_tag(post.image.url, :size => "90x90") if post.image.file %>
    - <%= link_to post.title[I18n.locale], panel_announcement_front_end_bulletin_path(post, :category_id => post.bulletin_category_id), :class=>"newstitle" %> - <% if post.is_top? %> - <%= t(:top) %> - <% end %> - <% if post.is_hot? %> - <%= t(:hot) %> - <% end %> - <%= post.subtitle[I18n.locale].html_safe %> -
  • - <% end %> -
-
more
-
- -<% elsif @widget_style == '16' %> - -

========== 16 圖 日期 標題 契子 ==========

- -
-
    - <% @bulletins.each do |post| %> -
  • -
    <%= image_tag(post.image.url, :size => "90x90") if post.image.file %>
    - <%= display_date(post.postdate) %> - <%= link_to post.title[I18n.locale], panel_announcement_front_end_bulletin_path(post, :category_id => post.bulletin_category_id), :class=>"newstitle" %> - <%= post.subtitle[I18n.locale].html_safe %> -
  • - <% end %> -
-
more
-
- -<% elsif @widget_style == '17' %> - -

========== 17圖 日期 標題 契子 狀態 ==========

- -
-
    - <% @bulletins.each do |post| %> -
  • -
    <%= image_tag(post.image.url, :size => "90x90") if post.image.file %>
    - <%= display_date(post.postdate) %> - <%= link_to post.title[I18n.locale], panel_announcement_front_end_bulletin_path(post, :category_id => post.bulletin_category_id), :class=>"newstitle" %> - <% if post.is_top? %> - <%= t(:top) %> - <% end %> - <% if post.is_hot? %> - <%= t(:hot) %> - <% end %> - <%= post.subtitle[I18n.locale].html_safe %> -
  • - <% end %> -
-
more
-
- -<% elsif @widget_style == '18' %> - -

========== 18圖一張 日期 多標題 ==========

- -
-
    -
    default
    - <% @bulletins.each do |post| %> -
  • - <%= display_date(post.postdate) %> - <%= link_to post.title[I18n.locale], panel_announcement_front_end_bulletin_path(post, :category_id => post.bulletin_category_id), :class=>"newstitle" %> -
  • - <% end %> -
-
more
-
- - -<% elsif @widget_style == '19' %> - -

========== 19圖一張 日期 多標題 ==========

- -
-
    -
    default
    - <% @bulletins.each do |post| %> -
  • - <%= display_date(post.postdate) %> - <%= link_to post.title[I18n.locale], panel_announcement_front_end_bulletin_path(post, :category_id => post.bulletin_category_id), :class=>"newstitle" %> - <% if post.is_top? %> - <%= t(:top) %> - <% end %> - <% if post.is_hot? %> - <%= t(:hot) %> - <% end %> -
  • - <% end %> -
-
more
-
- <% end %> \ No newline at end of file diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/widget/bulletins/index.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/widget/bulletins/index.html.erb index dacb9eaf..81992d59 100644 --- a/vendor/built_in_modules/announcement/app/views/panel/announcement/widget/bulletins/index.html.erb +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/widget/bulletins/index.html.erb @@ -1,3 +1,7 @@ + + + +
<%= render 'index' %>
\ No newline at end of file