add thumb option

This commit is contained in:
邱博亞 2022-02-27 12:58:52 +08:00
parent 2a4b941495
commit 41de9ec906
5 changed files with 53 additions and 32 deletions

View File

@ -14,6 +14,37 @@ class AnnouncementsController < ApplicationController
def index
@type = 'index'
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
if sorted.nil?
sorted = []
@ -37,6 +68,13 @@ class AnnouncementsController < ApplicationController
target = a.is_external_link ? "_blank" : "_self"
doc = Nokogiri::HTML(a.title)
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,
"bulletin_links" => links,
@ -53,7 +91,7 @@ class AnnouncementsController < ApplicationController
"is_top" => (a.is_top? ? 1 : 0),
"link_to_show" => link_to_show+"\" #{(link_to_show[0] == '/' rescue true) ? '' : 'target="_blank"'} title=\"#{title}",
"target" => target,
"img_src" => a.image.thumb.url || "/assets/announcement-default.jpg",
"img_src" => image_url || "/assets/announcement-default.jpg",
"img_description" => desc,
"more" => t("announcement.more"),
"view_count" => a.view_count
@ -62,7 +100,6 @@ class AnnouncementsController < ApplicationController
a
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(/\*|\(|\)/)}
return nil
end
@ -417,11 +454,11 @@ class AnnouncementsController < ApplicationController
ModuleApp.all.select{|tmp| tmp.key.to_s=='announcement'}.each do |modile_app|
@show_options = modile_app.show_options rescue nil
end
subpart.select_options.each do |select_option|
if !(@show_options.nil?)
value = YAML.load(select_option.value)
tmp = value[:en]
I18n.with_locale(:en) do
I18n.with_locale(:en) do
subpart.select_options.each do |select_option|
if !(@show_options.nil?)
value = YAML.load(select_option.value)
tmp = value[:en]
case select_option.field_name
when @show_options.keys[0].to_s
if tmp == t('announcement.small_size')

View File

@ -183,8 +183,8 @@ module AnnouncementsHelper
.can_display_and_sorted.is_approved
.filter_by_categories(categories,false).filter_by_tags(tags).to_a
else
member_prfile = MemberProfile.any_in(:uid=>params[:uids])
user_ids = member_prfile.map{|m| m.user.id rescue nil}.select{|id| !id.nil?}
member_profile = MemberProfile.any_in(:uid=>params[:uids])
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)
.can_display_and_sorted.is_approved
.filter_by_categories(categories,false).filter_by_tags(tags).to_a

View File

@ -1,21 +1,4 @@
<% params = OrbitHelper.params
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 %>
<% if @enable_search_flag %>
<style type="text/css">
#category_select_box{
margin: 0;
@ -66,15 +49,15 @@
all_cat = [[t('announcement.all'),'all']]
%>
<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')) %>
<input class="search_box" type="text" name="keywords" value="<%= params['keywords'].to_s.gsub(/\"/,'') %>" placeholder="<%= t('announcement.keywords') %>">
<%= 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') %>">
<div style="display: flex;flex-wrap: wrap;">
<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 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>
<input type="hidden" name="authenticity_token" value="<%= (0...46).map { ('a'..'z').to_a[rand(26)] }.join %>">

View File

@ -1,6 +1,6 @@
<%
params = OrbitHelper.params
page = Page.where(url:params['url']).first
page = @page || Page.where(url:params['url']).first
@show_back_and_next_flag = 0
content = ''
prev_content = ''

View File

@ -71,6 +71,7 @@ module Announcement
data[key4] = key4_attr
data_item[key_item1] = [value_item1,value_item2,value_item3]
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')
require File.expand_path('../../../app/models/anns_cache', __FILE__)
if defined?(AnnsCache)