- Widgets for announcement
  - Facebook link
  - AdBanner nav
This commit is contained in:
chris 2012-11-21 18:42:14 +08:00
parent bfa6579aad
commit 2d0e8b37b2
5 changed files with 35 additions and 12 deletions

View File

@ -260,12 +260,12 @@ module ApplicationHelper
end end
def share_links(object, key) def share_links(object, key)
js = '' # js = ''
js << "<meta property='og:title' content='#{object.title}' />\n" rescue '' # js << "<meta property='og:title' content='#{object.title}' />\n" rescue ''
js << "<meta property='og:description' content='#{object.subtitle}' />\n" rescue '' # js << "<meta property='og:description' content='#{object.subtitle}' />\n" rescue ''
js << "<meta property='og:image' content='#{object.image.url}' />\n" rescue '' # js << "<meta property='og:image' content='#{object.image.url}' />\n" rescue ''
content_tag :div, :class => 'fb' do 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}');" # concat javascript_tag "$('head').append('#{j js}');"
end end
end end

View File

@ -54,7 +54,7 @@ module ParserCommon
delay: -1000, delay: -1000,
fx: '#{ad_banner.ad_fx.nil? ? 'fade': ad_banner.ad_fx}', fx: '#{ad_banner.ad_fx.nil? ? 'fade': ad_banner.ad_fx}',
timeoutFn: getTimeout, timeoutFn: getTimeout,
pager: '#banner_nav', pager: '.banner_nav-#{ad_banner.title.dehumanize}',
pagerAnchorBuilder: function(idx, slide) { pagerAnchorBuilder: function(idx, slide) {
return \"<li><a href='#'></a></li>\"; return \"<li><a href='#'></a></li>\";
} }
@ -62,7 +62,8 @@ module ParserCommon
}; };
}); });
</script>" </script>"
res << "<ul id='banner_nav' class='clear'></ul>" res << "<div style='position:relative'>"
res << "<ul id='banner_nav' class='clear banner_nav-#{ad_banner.title.dehumanize}'></ul>"
res << "<div id='slideshow-#{ad_banner.title.dehumanize}' class='slideshow'>" res << "<div id='slideshow-#{ad_banner.title.dehumanize}' class='slideshow'>"
printable_ad_images = [] printable_ad_images = []
ad_banner.ad_images.each do |ad_image| 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 << "style='#{'display:none;' if hide} #{'cursor:pointer;' if !ad_image.out_link.blank?}'"
res << "/>" res << "/>"
end end
res << "</div>"
res << "</div>" res << "</div>"
end end
fragment = Nokogiri::HTML::DocumentFragment.new(body, res) fragment = Nokogiri::HTML::DocumentFragment.new(body, res)
@ -234,4 +236,25 @@ module ParserCommon
public_r_tags.uniq public_r_tags.uniq
end 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 end

View File

@ -31,14 +31,14 @@ class Panel::Announcement::Widget::BulletinsController < OrbitWidgetController
date_now = Time.now date_now = Time.now
if !@category_id.blank? 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 @current_category = BulletinCategory.from_id(@category_id) rescue nil
elsif !params[:tag_id].blank? elsif !params[:tag_id].blank?
@tag = AnnouncementTag.find(params[:tag_id]) rescue nil @tag = AnnouncementTag.find(params[:tag_id]) rescue nil
@tag = AnnouncementTag.where(key: params[:tag_id])[0] unless @tag @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 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 end
get_categorys get_categorys

View File

@ -22,7 +22,7 @@
<td> <td>
<span class="<%= wf[1] %>"> <span class="<%= wf[1] %>">
<% if wf[1] == 'title' %> <% 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' %> <% elsif wf[1] == 'date' %>
<%= display_date(post.send(wf[0])) %> <%= display_date(post.send(wf[0])) %>
<% elsif wf[1] == 'category' %> <% elsif wf[1] == 'category' %>

View File

@ -49,7 +49,7 @@ Rails.application.routes.draw do
# end # end
end end
namespace :widget do namespace :widget do
match "bulletins" => "bulletins#index" match "index" => "bulletins#index"
match "bulletins_and_web_links" => "bulletins#bulletins_and_web_links" match "bulletins_and_web_links" => "bulletins#bulletins_and_web_links"
match "reload_bulletins" => "bulletins#reload_bulletins" match "reload_bulletins" => "bulletins#reload_bulletins"
match "reload_web_links" => "bulletins#reload_web_links" match "reload_web_links" => "bulletins#reload_web_links"