From 2d0e8b37b2b2aefeed1a4527bfb1411835d525c8 Mon Sep 17 00:00:00 2001 From: chris Date: Wed, 21 Nov 2012 18:42:14 +0800 Subject: [PATCH] Fix: - Widgets for announcement - Facebook link - AdBanner nav --- app/helpers/application_helper.rb | 10 +++---- lib/parsers/parser_common.rb | 27 +++++++++++++++++-- .../widget/bulletins_controller.rb | 6 ++--- .../widget/bulletins/_index.html.erb | 2 +- .../announcement/config/routes.rb | 2 +- 5 files changed, 35 insertions(+), 12 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 07d6b577..ba018099 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -260,12 +260,12 @@ module ApplicationHelper end def share_links(object, key) - js = '' - js << "\n" rescue '' - js << "\n" rescue '' - js << "\n" rescue '' + # js = '' + # js << "\n" rescue '' + # js << "\n" rescue '' + # js << "\n" rescue '' content_tag :div, :class => 'fb' do - concat social_share_button_tag(object.title, :fb_url => generate_fb_url(object,key), :image => "http://#{request.env['HTTP_HOST']}#{object.image.url}") + concat social_share_button_tag(object.title, :fb_url => generate_fb_url(object,key), :image => "http://#{request.env['HTTP_HOST']}#{object.image.url if !object.image.blank?}") # concat javascript_tag "$('head').append('#{j js}');" end end diff --git a/lib/parsers/parser_common.rb b/lib/parsers/parser_common.rb index 6364691e..047f72e6 100644 --- a/lib/parsers/parser_common.rb +++ b/lib/parsers/parser_common.rb @@ -54,7 +54,7 @@ module ParserCommon delay: -1000, fx: '#{ad_banner.ad_fx.nil? ? 'fade': ad_banner.ad_fx}', timeoutFn: getTimeout, - pager: '#banner_nav', + pager: '.banner_nav-#{ad_banner.title.dehumanize}', pagerAnchorBuilder: function(idx, slide) { return \"
  • \"; } @@ -62,7 +62,8 @@ module ParserCommon }; }); " - res << "" + res << "
    " + res << "" res << "
    " printable_ad_images = [] ad_banner.ad_images.each do |ad_image| @@ -84,6 +85,7 @@ module ParserCommon res << "style='#{'display:none;' if hide} #{'cursor:pointer;' if !ad_image.out_link.blank?}'" res << "/>" end + res << "
    " res << "
    " end fragment = Nokogiri::HTML::DocumentFragment.new(body, res) @@ -234,4 +236,25 @@ module ParserCommon public_r_tags.uniq end + # page_counter + def parse_counter(body = nil, page = nil, edit=nil) + body.css('.page_counter').each do |counter| + res = '' + case counter['option'] + when 'all' + res << display_visitors.to_s + when 'today' + res << display_visitors_today.to_s + when 'this_week' + res << display_visitors_this_week.to_s + when 'this_month' + res << display_visitors_this_month.to_s + when 'this_year' + res << display_visitors_this_year.to_s + end + fragment = Nokogiri::HTML::DocumentFragment.new(body, res) + counter.swap(fragment) + end + end + 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 0c5c3d91..622944a0 100644 --- a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/widget/bulletins_controller.rb +++ b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/widget/bulletins_controller.rb @@ -31,14 +31,14 @@ class Panel::Announcement::Widget::BulletinsController < OrbitWidgetController date_now = Time.now 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) + @bulletins = Bulletin.available_for_lang(I18n.locale).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 - @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) + @bulletins = @tag.bulletins.available_for_lang(I18n.locale).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) + @bulletins = Bulletin.available_for_lang(I18n.locale).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 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 a96cad81..95ab7f4f 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 @@ -22,7 +22,7 @@ <% if wf[1] == 'title' %> - <%= link_to post.send("#{wf[0]}")[I18n.locale], panel_announcement_front_end_bulletin_path(post, :category_id => post.send("#{post.class.to_s.underscore}_category_id")) %> + <%= link_to post.send("#{wf[0]}"), panel_announcement_front_end_bulletin_path(post, :category_id => post.send("#{post.class.to_s.underscore}_category_id")) %> <% elsif wf[1] == 'date' %> <%= display_date(post.send(wf[0])) %> <% elsif wf[1] == 'category' %> diff --git a/vendor/built_in_modules/announcement/config/routes.rb b/vendor/built_in_modules/announcement/config/routes.rb index 675d71f0..35500ac3 100644 --- a/vendor/built_in_modules/announcement/config/routes.rb +++ b/vendor/built_in_modules/announcement/config/routes.rb @@ -49,7 +49,7 @@ Rails.application.routes.draw do # end end namespace :widget do - match "bulletins" => "bulletins#index" + match "index" => "bulletins#index" match "bulletins_and_web_links" => "bulletins#bulletins_and_web_links" match "reload_bulletins" => "bulletins#reload_bulletins" match "reload_web_links" => "bulletins#reload_web_links"