add thumb option
This commit is contained in:
parent
2a4b941495
commit
41de9ec906
|
@ -14,6 +14,37 @@ class AnnouncementsController < ApplicationController
|
||||||
def index
|
def index
|
||||||
@type = 'index'
|
@type = 'index'
|
||||||
Bulletin.remove_expired_status
|
Bulletin.remove_expired_status
|
||||||
|
params = @params = OrbitHelper.params
|
||||||
|
page = @page || Page.where(url: params['url']).first
|
||||||
|
@enable_search_flag = false
|
||||||
|
@image_version = 'orignal'
|
||||||
|
if page.methods.include? 'select_option_items'.to_sym
|
||||||
|
ModuleApp.all.select{|tmp| tmp.key.to_s=='announcement'}.each do |modile_app|
|
||||||
|
@show_option_items = modile_app.show_option_items rescue nil
|
||||||
|
end
|
||||||
|
I18n.with_locale(:en) do
|
||||||
|
page.select_option_items.each do |select_option_item|
|
||||||
|
if !(@show_option_items.nil?)
|
||||||
|
case select_option_item.field_name
|
||||||
|
when @show_option_items.keys[1].to_s
|
||||||
|
value = YAML.load(select_option_item.value)
|
||||||
|
if value[:en] == t('announcement.yes')
|
||||||
|
@enable_search_flag = true
|
||||||
|
end
|
||||||
|
when @show_option_items.keys[2].to_s
|
||||||
|
if tmp == t('announcement.small_size')
|
||||||
|
@image_version = 'thumb'
|
||||||
|
elsif tmp == t('announcement.medium_size')
|
||||||
|
@image_version = 'mobile'
|
||||||
|
elsif tmp == t('announcement.orignal_size')
|
||||||
|
@image_version = 'orignal'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
sorted,total_pages = get_sorted_annc
|
sorted,total_pages = get_sorted_annc
|
||||||
if sorted.nil?
|
if sorted.nil?
|
||||||
sorted = []
|
sorted = []
|
||||||
|
@ -37,6 +68,13 @@ class AnnouncementsController < ApplicationController
|
||||||
target = a.is_external_link ? "_blank" : "_self"
|
target = a.is_external_link ? "_blank" : "_self"
|
||||||
doc = Nokogiri::HTML(a.title)
|
doc = Nokogiri::HTML(a.title)
|
||||||
title = doc.text.empty? ? 'no content' : doc.text
|
title = doc.text.empty? ? 'no content' : doc.text
|
||||||
|
if @image_version == 'thumb'
|
||||||
|
image_url = a.image.thumb.url
|
||||||
|
elsif @image_version == 'mobile'
|
||||||
|
image_url = a.image.mobile.url
|
||||||
|
else
|
||||||
|
image_url = a.image.url
|
||||||
|
end
|
||||||
{
|
{
|
||||||
"department" => author,
|
"department" => author,
|
||||||
"bulletin_links" => links,
|
"bulletin_links" => links,
|
||||||
|
@ -53,7 +91,7 @@ class AnnouncementsController < ApplicationController
|
||||||
"is_top" => (a.is_top? ? 1 : 0),
|
"is_top" => (a.is_top? ? 1 : 0),
|
||||||
"link_to_show" => link_to_show+"\" #{(link_to_show[0] == '/' rescue true) ? '' : 'target="_blank"'} title=\"#{title}",
|
"link_to_show" => link_to_show+"\" #{(link_to_show[0] == '/' rescue true) ? '' : 'target="_blank"'} title=\"#{title}",
|
||||||
"target" => target,
|
"target" => target,
|
||||||
"img_src" => a.image.thumb.url || "/assets/announcement-default.jpg",
|
"img_src" => image_url || "/assets/announcement-default.jpg",
|
||||||
"img_description" => desc,
|
"img_description" => desc,
|
||||||
"more" => t("announcement.more"),
|
"more" => t("announcement.more"),
|
||||||
"view_count" => a.view_count
|
"view_count" => a.view_count
|
||||||
|
@ -62,7 +100,6 @@ class AnnouncementsController < ApplicationController
|
||||||
a
|
a
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
params = OrbitHelper.params
|
|
||||||
if anns.count == 0 && params.any?{|k,v| v.class==Array ? v.any?{|v1| v1.to_s.match(/\*|\(|\)/)} : v.to_s.match(/\*|\(|\)/)}
|
if anns.count == 0 && params.any?{|k,v| v.class==Array ? v.any?{|v1| v1.to_s.match(/\*|\(|\)/)} : v.to_s.match(/\*|\(|\)/)}
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
@ -417,11 +454,11 @@ class AnnouncementsController < ApplicationController
|
||||||
ModuleApp.all.select{|tmp| tmp.key.to_s=='announcement'}.each do |modile_app|
|
ModuleApp.all.select{|tmp| tmp.key.to_s=='announcement'}.each do |modile_app|
|
||||||
@show_options = modile_app.show_options rescue nil
|
@show_options = modile_app.show_options rescue nil
|
||||||
end
|
end
|
||||||
|
I18n.with_locale(:en) do
|
||||||
subpart.select_options.each do |select_option|
|
subpart.select_options.each do |select_option|
|
||||||
if !(@show_options.nil?)
|
if !(@show_options.nil?)
|
||||||
value = YAML.load(select_option.value)
|
value = YAML.load(select_option.value)
|
||||||
tmp = value[:en]
|
tmp = value[:en]
|
||||||
I18n.with_locale(:en) do
|
|
||||||
case select_option.field_name
|
case select_option.field_name
|
||||||
when @show_options.keys[0].to_s
|
when @show_options.keys[0].to_s
|
||||||
if tmp == t('announcement.small_size')
|
if tmp == t('announcement.small_size')
|
||||||
|
|
|
@ -183,8 +183,8 @@ module AnnouncementsHelper
|
||||||
.can_display_and_sorted.is_approved
|
.can_display_and_sorted.is_approved
|
||||||
.filter_by_categories(categories,false).filter_by_tags(tags).to_a
|
.filter_by_categories(categories,false).filter_by_tags(tags).to_a
|
||||||
else
|
else
|
||||||
member_prfile = MemberProfile.any_in(:uid=>params[:uids])
|
member_profile = MemberProfile.any_in(:uid=>params[:uids])
|
||||||
user_ids = member_prfile.map{|m| m.user.id rescue nil}.select{|id| !id.nil?}
|
user_ids = member_profile.map{|m| m.user.id rescue nil}.select{|id| !id.nil?}
|
||||||
announcements = Bulletin.where(:title.nin => ["",nil],:is_preview.in=>[false,nil],:create_user_id.in=>user_ids)
|
announcements = Bulletin.where(:title.nin => ["",nil],:is_preview.in=>[false,nil],:create_user_id.in=>user_ids)
|
||||||
.can_display_and_sorted.is_approved
|
.can_display_and_sorted.is_approved
|
||||||
.filter_by_categories(categories,false).filter_by_tags(tags).to_a
|
.filter_by_categories(categories,false).filter_by_tags(tags).to_a
|
||||||
|
|
|
@ -1,21 +1,4 @@
|
||||||
<% params = OrbitHelper.params
|
<% if @enable_search_flag %>
|
||||||
page = Page.where(url:params['url']).first
|
|
||||||
enable_search_flag = false
|
|
||||||
if page.methods.include? 'select_option_items'.to_sym
|
|
||||||
ModuleApp.all.select{|tmp| tmp.key.to_s=='announcement'}.each do |modile_app|
|
|
||||||
@show_option_items = modile_app.show_option_items rescue nil
|
|
||||||
end
|
|
||||||
page.select_option_items.each do |select_option_item|
|
|
||||||
if !(@show_option_items.nil?) && select_option_item.field_name == @show_option_items.keys[1].to_s
|
|
||||||
value = YAML.load(select_option_item.value)
|
|
||||||
if value[I18n.locale] == t('announcement.yes')
|
|
||||||
enable_search_flag = true
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
%>
|
|
||||||
<% if enable_search_flag %>
|
|
||||||
<style type="text/css">
|
<style type="text/css">
|
||||||
#category_select_box{
|
#category_select_box{
|
||||||
margin: 0;
|
margin: 0;
|
||||||
|
@ -66,15 +49,15 @@
|
||||||
all_cat = [[t('announcement.all'),'all']]
|
all_cat = [[t('announcement.all'),'all']]
|
||||||
%>
|
%>
|
||||||
<div class="search_widget" style="display: flex;flex-wrap: wrap;font-size: 1.1em;">
|
<div class="search_widget" style="display: flex;flex-wrap: wrap;font-size: 1.1em;">
|
||||||
<%= select_tag('category',options_for_select(all_cat.concat(cats.map{|v| [v.title,v.id.to_s]}),:selected => params['category'].to_s),:id=>"category_select_box",:prompt => t('announcement.select_prompt')) %>
|
<%= select_tag('category',options_for_select(all_cat.concat(cats.map{|v| [v.title,v.id.to_s]}),:selected => @params['category'].to_s),:id=>"category_select_box",:prompt => t('announcement.select_prompt')) %>
|
||||||
<input class="search_box" type="text" name="keywords" value="<%= params['keywords'].to_s.gsub(/\"/,'') %>" placeholder="<%= t('announcement.keywords') %>">
|
<input class="search_box" type="text" name="keywords" value="<%= @params['keywords'].to_s.gsub(/\"/,'') %>" placeholder="<%= t('announcement.keywords') %>">
|
||||||
<div style="display: flex;flex-wrap: wrap;">
|
<div style="display: flex;flex-wrap: wrap;">
|
||||||
<div class="default_picker">
|
<div class="default_picker">
|
||||||
<input class="search_box" type="text" name="stime" value="<%= params['stime'].to_s.gsub(/\"/,'') %>" placeholder="<%= t('announcement.stime') %>" data-format="yyyy/mm/dd">
|
<input class="search_box" type="text" name="stime" value="<%= @params['stime'].to_s.gsub(/\"/,'') %>" placeholder="<%= t('announcement.stime') %>" data-format="yyyy/mm/dd">
|
||||||
</div>
|
</div>
|
||||||
~
|
~
|
||||||
<div class="default_picker">
|
<div class="default_picker">
|
||||||
<input class="search_box" type="text" name="etime" value="<%= params['etime'].to_s.gsub(/\"/,'') %>" placeholder="<%= t('announcement.etime') %>" data-format="yyyy/mm/dd">
|
<input class="search_box" type="text" name="etime" value="<%= @params['etime'].to_s.gsub(/\"/,'') %>" placeholder="<%= t('announcement.etime') %>" data-format="yyyy/mm/dd">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<input type="hidden" name="authenticity_token" value="<%= (0...46).map { ('a'..'z').to_a[rand(26)] }.join %>">
|
<input type="hidden" name="authenticity_token" value="<%= (0...46).map { ('a'..'z').to_a[rand(26)] }.join %>">
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<%
|
<%
|
||||||
params = OrbitHelper.params
|
params = OrbitHelper.params
|
||||||
page = Page.where(url:params['url']).first
|
page = @page || Page.where(url:params['url']).first
|
||||||
@show_back_and_next_flag = 0
|
@show_back_and_next_flag = 0
|
||||||
content = ''
|
content = ''
|
||||||
prev_content = ''
|
prev_content = ''
|
||||||
|
|
|
@ -71,6 +71,7 @@ module Announcement
|
||||||
data[key4] = key4_attr
|
data[key4] = key4_attr
|
||||||
data_item[key_item1] = [value_item1,value_item2,value_item3]
|
data_item[key_item1] = [value_item1,value_item2,value_item3]
|
||||||
data_item[key_item2] = [value2_item1,value2_item2]
|
data_item[key_item2] = [value2_item1,value2_item2]
|
||||||
|
data_item[key1] = key1_attr.remove
|
||||||
if ENV['worker_num']=='0' && File.basename($0) != 'rake' && !Rails.const_defined?('Console')
|
if ENV['worker_num']=='0' && File.basename($0) != 'rake' && !Rails.const_defined?('Console')
|
||||||
require File.expand_path('../../../app/models/anns_cache', __FILE__)
|
require File.expand_path('../../../app/models/anns_cache', __FILE__)
|
||||||
if defined?(AnnsCache)
|
if defined?(AnnsCache)
|
||||||
|
|
Loading…
Reference in New Issue