Compare commits
1 Commits
master
...
0913_ntu_c
Author | SHA1 | Date |
---|---|---|
chris | d766eea9f4 |
|
@ -4,6 +4,8 @@
|
||||||
.rvmrc
|
.rvmrc
|
||||||
|
|
||||||
Gemfile.lock
|
Gemfile.lock
|
||||||
|
Procfile
|
||||||
|
log/*
|
||||||
|
|
||||||
db/*.sqlite3
|
db/*.sqlite3
|
||||||
log/*.log
|
log/*.log
|
||||||
|
|
|
@ -15,11 +15,6 @@ function load_tinymce() {
|
||||||
theme_advanced_statusbar_location : "bottom",
|
theme_advanced_statusbar_location : "bottom",
|
||||||
theme_advanced_resizing : true,
|
theme_advanced_resizing : true,
|
||||||
|
|
||||||
// Domain Absolute URLs
|
|
||||||
relative_urls : false,
|
|
||||||
remove_script_host : false,
|
|
||||||
document_base_url: window.location.protocol + '//' + window.location.host,
|
|
||||||
|
|
||||||
// Skin options
|
// Skin options
|
||||||
skin : "o2k7",
|
skin : "o2k7",
|
||||||
skin_variant : "silver",
|
skin_variant : "silver",
|
||||||
|
|
|
@ -43,7 +43,7 @@ class MobileController < ApplicationController
|
||||||
|
|
||||||
def page
|
def page
|
||||||
@page_title = t('mobile.page')
|
@page_title = t('mobile.page')
|
||||||
@page_contexts = get_sorted_page_from_structure
|
@page_contexts = PageContext.where(:archived => false).page(params[:page_main]).per(15)
|
||||||
end
|
end
|
||||||
|
|
||||||
def page_content
|
def page_content
|
||||||
|
@ -57,12 +57,4 @@ class MobileController < ApplicationController
|
||||||
@no_footer = true if request.path =~ /app/
|
@no_footer = true if request.path =~ /app/
|
||||||
end
|
end
|
||||||
|
|
||||||
def get_sorted_page_from_structure
|
|
||||||
page_contexts = Item.structure_ordered_items.inject([]){ |pages, page|
|
|
||||||
pages << page.page_contexts.where(archived: false).limit(1)[0] if page.is_a?(Page) && !page.page_contexts.blank?
|
|
||||||
pages
|
|
||||||
}
|
|
||||||
Kaminari.paginate_array(page_contexts).page(params[:page]).per(15)
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
class GetAnnouncementFromRss
|
||||||
|
@queue = :high
|
||||||
|
|
||||||
|
def self.perform()
|
||||||
|
%x(ruby "#{Rails.root}/lib/rss_ntu_job.rb")
|
||||||
|
end
|
||||||
|
end
|
|
@ -3,9 +3,7 @@
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<ul>
|
<ul>
|
||||||
<li>總機電話:<a href="tel:+886229393091">02-29393091</a></li>
|
<li>總務處電話:<a href="tel:+886229393091">02-29393091</a></li>
|
||||||
<li>傳真:02-29379611</li>
|
<li>總務處傳真:02-29379611</li>
|
||||||
<li>緊急重大事件通聯窗口:校內分機 66119、66110</li>
|
<li>總務處單一窗口 李梅森專員:<a href="tel:+886233662233">02-33662233</a></li>
|
||||||
<li>總值日室:<a href="tel:+88229387132">02-29387132</a></li>
|
|
||||||
<li>駐警衛室:<a href="tel:+88229387129">02-29387129</a></li>
|
|
||||||
</ul>
|
</ul>
|
||||||
|
|
|
@ -5,6 +5,6 @@
|
||||||
<div id='map_canvas'></div>
|
<div id='map_canvas'></div>
|
||||||
|
|
||||||
<script type='text/javascript'>
|
<script type='text/javascript'>
|
||||||
var $map_center = "24.987449, 121.576117"
|
var $map_center = "25.015205, 121.535491"
|
||||||
var $map_zoom = 17
|
var $map_zoom = 17
|
||||||
</script>
|
</script>
|
|
@ -9,5 +9,5 @@ en:
|
||||||
home: Home
|
home: Home
|
||||||
language: Language
|
language: Language
|
||||||
location: Location
|
location: Location
|
||||||
location_description: '<h3>This University</h3>No.101,Sec. 2, Jiafeng S Road, Zhubei City, Hsinchu County 302, Taiwan'
|
location_description: '<h3>OFFICE OF GENERAL AFFAIRS, NTU</h3>No. 1, Sec. 4, Roosevelt Road, Taipei, 10617 Taiwan (R.O.C)'
|
||||||
page: Page
|
page: Page
|
|
@ -9,5 +9,5 @@ zh_tw:
|
||||||
home: 首頁
|
home: 首頁
|
||||||
language: 語言
|
language: 語言
|
||||||
location: 地理位置
|
location: 地理位置
|
||||||
location_description: '<h3>本大學</h3>302新竹縣竹北市嘉豐南路二段101號'
|
location_description: '<h3>臺灣大學總務處 版權所有</h3>10617 臺北市大安區羅斯福路四段一號'
|
||||||
page: 頁面
|
page: 頁面
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
en:
|
||||||
|
|
||||||
|
ntu:
|
||||||
|
rss_origin: Back to NTU Announcements
|
|
@ -0,0 +1,4 @@
|
||||||
|
zh_tw:
|
||||||
|
|
||||||
|
ntu:
|
||||||
|
rss_origin: 回臺大校園公佈欄
|
|
@ -11,7 +11,7 @@ backup_server:
|
||||||
description: BackupServer and remove old backups
|
description: BackupServer and remove old backups
|
||||||
|
|
||||||
update_tag_cloud:
|
update_tag_cloud:
|
||||||
cron: 0 0 [0,12] * * *
|
cron: 0 30 2 * * *
|
||||||
class: UpdateTagCloud
|
class: UpdateTagCloud
|
||||||
args:
|
args:
|
||||||
description: UpdateTagCloud
|
description: UpdateTagCloud
|
||||||
|
@ -27,3 +27,9 @@ email_cron:
|
||||||
class: EmailCron
|
class: EmailCron
|
||||||
args:
|
args:
|
||||||
description: EmailCron
|
description: EmailCron
|
||||||
|
|
||||||
|
get_announcement_from_rss:
|
||||||
|
cron: 0 0 [2,12] * * *
|
||||||
|
class: GetAnnouncementFromRss
|
||||||
|
args:
|
||||||
|
description: Loop through the announcement RSS until 24h ago
|
||||||
|
|
|
@ -310,6 +310,34 @@ namespace :migrate do
|
||||||
Rake::Task["web_link_url:web_link_url_i18n"].execute
|
Rake::Task["web_link_url:web_link_url_i18n"].execute
|
||||||
end
|
end
|
||||||
|
|
||||||
|
task :save_users => :environment do
|
||||||
|
User.where(:email.not => /guest/).each{|s|s.save}
|
||||||
|
end
|
||||||
|
|
||||||
|
task :fix_bulletin_rss_available_lang => :environment do
|
||||||
|
Bulletin.all.each do |bull|
|
||||||
|
if bull.create_user_id.nil?
|
||||||
|
bull.update_attribute(:available_for_zh_tw, true)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
task :fix_imported_rss => :environment do
|
||||||
|
categories = BulletinCategory.where(key: /rss_/).entries
|
||||||
|
unless categories.blank?
|
||||||
|
categories.each do |category|
|
||||||
|
bulletins = category.bulletins
|
||||||
|
unless bulletins.blank?
|
||||||
|
bulletins.each do |bulletin|
|
||||||
|
bulletin.update_attribute(:is_top, false) unless bulletin.is_top?
|
||||||
|
bulletin.update_attribute(:is_hot, false) unless bulletin.is_hot?
|
||||||
|
bulletin.update_attribute(:is_hidden, false) unless bulletin.is_hidden?
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
task :fix_tagged_ids => :environment do
|
task :fix_tagged_ids => :environment do
|
||||||
Tag.all.each do |tag|
|
Tag.all.each do |tag|
|
||||||
tag.taggings.each do |tagging|
|
tag.taggings.each do |tagging|
|
||||||
|
|
|
@ -0,0 +1,183 @@
|
||||||
|
# encoding: utf-8
|
||||||
|
|
||||||
|
namespace :mongo_files do
|
||||||
|
|
||||||
|
MODELS = { 'ad_image' => 'file',
|
||||||
|
'archive_file_multiple' => 'file',
|
||||||
|
'asset' => 'data',
|
||||||
|
'bulletin' => 'image',
|
||||||
|
'bulletin_file' => 'file',
|
||||||
|
'design' => 'zip_file',
|
||||||
|
'design_file' => 'file',
|
||||||
|
'gallery_image' => 'file',
|
||||||
|
'image' => 'file',
|
||||||
|
'lab_file' => 'file',
|
||||||
|
'location_info' => 'file',
|
||||||
|
'preview_file' => 'file',
|
||||||
|
'project_file' => 'file',
|
||||||
|
'research_file' => 'file',
|
||||||
|
'site' => 'default_image',
|
||||||
|
'stylesheet' => 'file_orig',
|
||||||
|
'user' => 'avatar',
|
||||||
|
'writing_book_file' => 'file',
|
||||||
|
'writing_conference_file' => 'file',
|
||||||
|
'writing_journal_file' => 'file',
|
||||||
|
'writing_patent_file' => 'file' }
|
||||||
|
|
||||||
|
IMAGE_UPLOADER_MODELS = %w[ad_image bulletin image site]
|
||||||
|
|
||||||
|
# ad_banner
|
||||||
|
# bulletin
|
||||||
|
# design
|
||||||
|
# site
|
||||||
|
|
||||||
|
task :clean => :environment do
|
||||||
|
@files = Mongoid.database['fs.files']
|
||||||
|
@chunks = Mongoid.database['fs.chunks']
|
||||||
|
clean_duplicates
|
||||||
|
clean_unused
|
||||||
|
remove_objects
|
||||||
|
# remove_unlinked
|
||||||
|
end
|
||||||
|
|
||||||
|
# Remove unused files from db
|
||||||
|
def clean_unused
|
||||||
|
db_array = @files.find().inject([]) do |db_files, file|
|
||||||
|
db_files << file['filename']
|
||||||
|
db_files
|
||||||
|
end
|
||||||
|
|
||||||
|
p "# of files in db: #{db_array.size}"
|
||||||
|
|
||||||
|
name_array = MODELS.inject([]) do |model_files, (model, type)|
|
||||||
|
model.classify.constantize.all.each do |item|
|
||||||
|
url = item.send(type).url
|
||||||
|
thumb_url = item.send(type).thumb.url rescue nil
|
||||||
|
if url && !url.eql?('sign-in-logo.png')
|
||||||
|
url = url.gsub('/gridfs/', '')
|
||||||
|
model_files << url
|
||||||
|
end
|
||||||
|
if thumb_url && !thumb_url.eql?('sign-in-logo.png')
|
||||||
|
thumb_url = thumb_url.gsub('/gridfs/', '')
|
||||||
|
model_files << thumb_url
|
||||||
|
end
|
||||||
|
end
|
||||||
|
model_files
|
||||||
|
end
|
||||||
|
|
||||||
|
p "# of files from uploaders: #{name_array.size}"
|
||||||
|
useless_files = db_array - name_array
|
||||||
|
p "# of unmatched files: #{useless_files.size}"
|
||||||
|
|
||||||
|
useless_files.each do |file|
|
||||||
|
id = @files.find_one('filename' => file)['_id']
|
||||||
|
@files.remove('_id' => id)
|
||||||
|
@chunks.remove('files_id' => id)
|
||||||
|
end
|
||||||
|
# p files.remove('filename' => { "$in" => useless_files})
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
# Remove duplicate files from db
|
||||||
|
def clean_duplicates
|
||||||
|
p "# of files in db: #{@files.count}"
|
||||||
|
file_hash = @files.find().inject({}) do |db_files, file|
|
||||||
|
name = file['filename']
|
||||||
|
if db_files[name]
|
||||||
|
db_files[name] += [file['_id']]
|
||||||
|
else
|
||||||
|
db_files[name] = [file['_id']]
|
||||||
|
end
|
||||||
|
db_files
|
||||||
|
end
|
||||||
|
file_array = file_hash.inject([]) do |files, (key, value)|
|
||||||
|
files += value.drop(1) if value.size > 1
|
||||||
|
files
|
||||||
|
end
|
||||||
|
p "# of duplicate ids to delete: #{file_array.size}"
|
||||||
|
file_array.each do |id|
|
||||||
|
@files.remove('_id' => id)
|
||||||
|
@chunks.remove('files_id' => id)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
task :file_size => :environment do
|
||||||
|
files = Mongoid.database['fs.files']
|
||||||
|
size_array = files.find().inject([]) do |size, file|
|
||||||
|
# size << [file['length'], file['filename']]
|
||||||
|
size << [file['filename'], file['length']]
|
||||||
|
size
|
||||||
|
end
|
||||||
|
size_array.sort.each do |pair|
|
||||||
|
p "#{pair[0]} - #{pair[1]}"
|
||||||
|
end
|
||||||
|
p size_array.size
|
||||||
|
end
|
||||||
|
|
||||||
|
def remove_objects
|
||||||
|
# Destroy writing_journals and writing_journal_files
|
||||||
|
Mongoid.database['writing_journals'].remove()
|
||||||
|
Mongoid.database['writing_journal_files'].remove()
|
||||||
|
|
||||||
|
# Destroy bulletins, bulletin_files and bulletin_links
|
||||||
|
Bulletin.excludes(create_user_id: nil).destroy
|
||||||
|
BulletinFile.destroy_all
|
||||||
|
BulletinLink.destroy_all
|
||||||
|
|
||||||
|
# Destroy gallery_albums and gallery_images
|
||||||
|
Mongoid.database['gallery_albums'].remove()
|
||||||
|
Mongoid.database['gallery_images'].remove()
|
||||||
|
|
||||||
|
db_array = @files.find().inject([]) do |db_files, file|
|
||||||
|
db_files << file['filename'] if file['filename'] =~ /writing_journal_file|news_bulletin_file|bulletin_file|gallery_image|image\/image/
|
||||||
|
db_files
|
||||||
|
end
|
||||||
|
p db_array.size
|
||||||
|
db_array.each do |file|
|
||||||
|
id = @files.find_one('filename' => file)['_id']
|
||||||
|
@files.remove('_id' => id)
|
||||||
|
@chunks.remove('files_id' => id)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def remove_unlinked
|
||||||
|
# name_array = AdBanner.all.inject([]) do |files, banner|
|
||||||
|
# banner.ad_images.inject(files) do |image_files, image|
|
||||||
|
# url = image.file.url
|
||||||
|
# thumb_url = image.file.thumb.url rescue nil
|
||||||
|
# if url && !url.eql?('sign-in-logo.png')
|
||||||
|
# url = url.gsub('/gridfs/', '')
|
||||||
|
# image_files << url
|
||||||
|
# end
|
||||||
|
# if thumb_url && !thumb_url.eql?('sign-in-logo.png')
|
||||||
|
# thumb_url = thumb_url.gsub('/gridfs/', '')
|
||||||
|
# image_files << thumb_url
|
||||||
|
# end
|
||||||
|
# image_files
|
||||||
|
# end
|
||||||
|
# files
|
||||||
|
# end
|
||||||
|
name_array = Design.all.inject([]) do |files, design|
|
||||||
|
files += design.images.inject(files) do |image_files, image|
|
||||||
|
p image_files += get_url_and_thumb(image.file)
|
||||||
|
image_files
|
||||||
|
end
|
||||||
|
files
|
||||||
|
end
|
||||||
|
p name_array.size
|
||||||
|
end
|
||||||
|
|
||||||
|
def get_url_and_thumb(file)
|
||||||
|
url = file.url
|
||||||
|
thumb_url = file.thumb.url rescue nil
|
||||||
|
files = [url, thumb_url].inject([]) do |urls, current|
|
||||||
|
urls << current.gsub('/gridfs/', '') if current && !current.eql?('sign-in-logo.png')
|
||||||
|
urls
|
||||||
|
end
|
||||||
|
files
|
||||||
|
end
|
||||||
|
|
||||||
|
task :delete_rss_ann => :environment do
|
||||||
|
Bulletin.where(create_user_id: nil).destroy
|
||||||
|
end
|
||||||
|
end
|
|
@ -9,7 +9,7 @@ namespace :web_link_url do
|
||||||
|
|
||||||
@weblinks.each do |wl|
|
@weblinks.each do |wl|
|
||||||
|
|
||||||
if wl.url.nil?
|
if wl.url_translations.is_a?(String)
|
||||||
|
|
||||||
@wlurl = wl.url_translations
|
@wlurl = wl.url_translations
|
||||||
|
|
||||||
|
|
|
@ -40,6 +40,7 @@ class Bulletin
|
||||||
field :not_checked_reason
|
field :not_checked_reason
|
||||||
|
|
||||||
field :public, :type => Boolean, :default => true
|
field :public, :type => Boolean, :default => true
|
||||||
|
field :rss_link
|
||||||
|
|
||||||
scope :can_display, where(is_checked: true, is_rejected: false, is_pending: false)
|
scope :can_display, where(is_checked: true, is_rejected: false, is_pending: false)
|
||||||
scope :available_for_lang, ->(locale){ where("available_for_#{locale}".to_sym => true) }
|
scope :available_for_lang, ->(locale){ where("available_for_#{locale}".to_sym => true) }
|
||||||
|
|
|
@ -36,6 +36,11 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
<% unless @bulletin.rss_link.blank? %>
|
||||||
|
<div>
|
||||||
|
<%= link_to t('ntu.rss_origin'), @bulletin.rss_link %>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<%= share_links(@bulletin, 'announcement') %>
|
<%= share_links(@bulletin, 'announcement') %>
|
||||||
|
|
|
@ -29,8 +29,8 @@ module Announcement
|
||||||
|
|
||||||
widgets do
|
widgets do
|
||||||
default_widget do
|
default_widget do
|
||||||
sorting 'desc(:is_top, :postdate)'
|
sorting 'desc(:postdate)'
|
||||||
query 'Bulletin.can_display.available_for_lang(I18n.locale).any_of( {deadline: nil,:postdate.lte => Time.now} , {:deadline.gte => Time.now,:postdate.lte => Time.now} )'
|
query 'Bulletin.available_for_lang(I18n.locale).any_of( {deadline: nil,:postdate.lte => Time.now} , {:deadline.gte => Time.now,:postdate.lte => Time.now} )'
|
||||||
enable ["typeA","typeB_style3","typeC"]
|
enable ["typeA","typeB_style3","typeC"]
|
||||||
image :image
|
image :image
|
||||||
field :postdate
|
field :postdate
|
||||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 12 KiB |
|
@ -9,40 +9,17 @@ class Panel::Gallery::Widget::AlbumsController < OrbitWidgetController
|
||||||
@album = GalleryAlbum.find(@part.widget_options['album_id']) rescue nil
|
@album = GalleryAlbum.find(@part.widget_options['album_id']) rescue nil
|
||||||
@album_images = @album.gallery_images if @album
|
@album_images = @album.gallery_images if @album
|
||||||
|
|
||||||
|
|
||||||
@settings = {"vertical"=>vertical,"horizontal"=>horizontal} #[note] horizontal has it's limitation from 2 to 6
|
@settings = {"vertical"=>vertical,"horizontal"=>horizontal} #[note] horizontal has it's limitation from 2 to 6
|
||||||
@class = "c" + @settings["horizontal"].to_s
|
@class = "c" + @settings["horizontal"].to_s
|
||||||
@total = @settings["vertical"] * @settings["horizontal"]
|
@total = @settings["vertical"] * @settings["horizontal"]
|
||||||
@rnd = Random.new
|
@rnd = Random.new
|
||||||
@images = []
|
@images = []
|
||||||
|
for i in 0..@total-1
|
||||||
if @album_images.count > @total
|
image = @album_images[@rnd.rand(0...@album_images.count)]
|
||||||
@randoms = []
|
|
||||||
until @randoms.count == @total do
|
|
||||||
r = @rnd.rand(0...@album_images.count)
|
|
||||||
if !@randoms.include?r
|
|
||||||
@randoms << r
|
|
||||||
image = @album_images[r]
|
|
||||||
values = {"show_link"=>theater_panel_gallery_front_end_album_path(image),"thumb"=>image.file.thumb.url}
|
values = {"show_link"=>theater_panel_gallery_front_end_album_path(image),"thumb"=>image.file.thumb.url}
|
||||||
@images << values
|
@images << values
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
elsif @album_images.count == @total
|
|
||||||
@album_images.each do |image|
|
|
||||||
values = {"show_link"=>theater_panel_gallery_front_end_album_path(image),"thumb"=>image.file.thumb.url}
|
|
||||||
@images << values
|
|
||||||
end
|
|
||||||
else
|
|
||||||
@album_images.each do |image|
|
|
||||||
values = {"show_link"=>theater_panel_gallery_front_end_album_path(image),"thumb"=>image.file.thumb.url}
|
|
||||||
@images << values
|
|
||||||
end
|
|
||||||
until @images.count == @total do
|
|
||||||
values = {"show_link"=>"javascript:void(0);","thumb"=>"assets/gallery/nodata.jpg"}
|
|
||||||
@images << values
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def widget2
|
def widget2
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue