Compare commits

...
Author SHA1 Message Date
chris 18b36df573 Change colour for mobile sa 2013-09-13 15:10:46 +08:00
chris 09bb318d6a Changes for NTU Student Affairs 2013-09-13 15:10:33 +08:00
8 changed files with 221 additions and 39 deletions

No files matched your search

@@ -100,9 +100,8 @@ div[data-role="page"] {
padding: 0;
border: none;
z-index: 50;
/*background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#545b60), to(#191a1c));*/
background-image: -webkit-linear-gradient(top, #5282A6, #133757);
-webkit-box-shadow: 0 1px 3px rgba(0, 0, 0, 0.8), inset 0 1px 0 rgba(127, 149, 165, 1), 0 -1px 0 rgba(31, 32, 36, 1) inset;
background-image: -webkit-linear-gradient(top, #e35479, #cb2d56);
-webkit-box-shadow: 0 1px 3px rgba(0,0,0,0.8),inset 0 1px 0 #7f95a5,0 -1px 0 #1f2024 inset;
}
.header h1.ui-title {
margin: 8px 30%;
@@ -115,14 +114,12 @@ div[data-role="page"] {
left: 50%;
margin-left: -15px;
font-size: 20px;
/*color: #727272;*/
color: #7CA6C5;
/*background-color: #252525;*/
background-color: #144366;
color: #ffc8e7;
background-color: #cb2d56;
border-radius: 0 0 5px 5px;
height: 15px;
line-height: 16px;
box-shadow: 1px 2px 2px rgba(0, 0, 0, .5);
box-shadow: 1px 2px 2px rgba(0,0,0,0.5);
}
.header .language .ui-btn-text {
left: 0;
@@ -135,14 +132,14 @@ div[data-role="page"] {
background-image: none;
}
.header .ui-btn-up-a {
border: 1px solid #133547;
background-color: #0C4C64;
background-image: -webkit-gradient(linear, left top, left bottom, from( #0D6691 ), to( #0E3A4B ));
background-image: -webkit-linear-gradient( #0D6691 , #0E3A4B );
background-image: -moz-linear-gradient( #0D6691 , #0E3A4B );
background-image: -ms-linear-gradient( #0D6691 , #0E3A4B );
background-image: -o-linear-gradient( #0D6691 , #0E3A4B );
background-image: linear-gradient( #0D6691 , #0E3A4B );
border: 1px solid #a21050;
background-color: #cb2d56;
background-image: -webkit-gradient(linear, left top, left bottom, from(#e35479), to(#cb2d56));
background-image: -webkit-linear-gradient(#e35479, #cb2d56);
background-image: -moz-linear-gradient(#e35479, #cb2d56);
background-image: -ms-linear-gradient(#e35479, #cb2d56);
background-image: -o-linear-gradient(#e35479, #cb2d56);
background-image: linear-gradient(#e35479, #cb2d56);
}
.header h1 img {
height: 30px;
+11
View File
@@ -1,6 +1,17 @@
<!DOCTYPE HTML>
<html class="<%= I18n.locale.to_s %>">
<head>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-39393439-1']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
<meta charset="utf-8">
<%= page_title(@item).html_safe %>
<link rel="shortcut icon" href="<%= asset_path "ncculogo.ico" %>">
+2 -3
View File
@@ -3,7 +3,6 @@
<% end %>
<ul>
<li>總務處電話:<a href="tel:+886229393091">02-29393091</a></li>
<li>總務處傳真:02-29379611</li>
<li>總務處單一窗口 李梅森專員:<a href="tel:+886233662233">02-33662233</a></li>
<li>學務處電話:<a href="tel:+886-2-3366-2995~2997">+886-2-3366-2995~2997</a></li>
<li>學務處傳真:+886-2-2391-9095</li>
</ul>
+2 -2
View File
@@ -4,10 +4,10 @@ en:
bulletin: Bulletin
contact: Contact
copyright: Copyright
copyright_text: Thisi University © All RIGHTS RESERVED.
copyright_text: Copyright© 2008 National Taiwan University ALL RIGHTS RESERVED
copyright_orbit: Powered by RulingDigital
home: Home
language: Language
location: Location
location_description: '<h3>OFFICE OF GENERAL AFFAIRS, NTU</h3>No. 1, Sec. 4, Roosevelt Road, Taipei, 10617 Taiwan (R.O.C)'
location_description: '<h3>National Taiwan University</h3>No. 1, Sec. 4, Roosevelt Road, Taipei, 10617 Taiwan (R.O.C)'
page: Page
+1 -1
View File
@@ -4,7 +4,7 @@ zh_tw:
bulletin: 公告
contact: 聯絡資訊
copyright: 著作權宣告
copyright_text: 本網站著作權屬於本大學。
copyright_text: 本網站著作權屬於國立臺灣大學 學生事務處
copyright_orbit: 銳綸數位建置
home: 首頁
language: 語言
+99
View File
@@ -0,0 +1,99 @@
# encoding: utf-8
# encoding: utf-8
require 'rss'
require 'mongo'
AUTHORS = %w[ 學生事務處-學生住宿服務組
學生事務處-學生職業生涯發展中心
學生事務處-衛生保健及醫療中心
學生事務處-課外活動指導組
學生事務處-學生活動中心管理組
學生事務處-僑生及陸生輔導組
學生事務處-生活輔導組
學生事務處-軍訓組
學生事務處-學生心理輔導中心
學生事務處-學生事務處]
DB_BASE_NAME = "site"
all = []
continue = true
i = 1
yesterday = Time.now - 86400
while continue do
open("http://ann.cc.ntu.edu.tw/asp/rss.asp?page=#{i}") do |rss|
feed = RSS::Parser.parse(rss.read.encode('utf-8', 'big5', invalid: :replace, undef: :replace, replace: '').gsub('<pubDate>Wes,', '<pubDate>Wed,').gsub(/(encoding=\"big5\")/, 'encoding="utf-8"'))
feed.items.each do |item|
if item.pubDate > yesterday
if AUTHORS.include?(item.author)
author = item.author.strip
category = item.category.to_s.gsub(/\<(\/)*category\>/, '')
all << {title: item.title.strip, author: author, link: item.link.strip, date: item.pubDate, category: category, description: item.description.gsub("\r\n", '<br/>').strip}
end
else
continue = false
break
end
end
end
i += 1
end
# Get corresponding category_id or create a new one
def get_category_id(category, categories, coll_cat)
if categories.keys.include? "rss_#{category}"
[categories["rss_#{category}"], categories]
else
cat = {
_type: "BulletinCategory",
key: "rss_#{category}",
disable: false,
title: {:zh_tw => category},
created_at: Time.now,
updated_at: Time.now
}
categories["rss_#{category}"] = result = coll_cat.save(cat)
[result, categories]
end
end
# Get categories and id based on a given site number
def get_mongo_and_categories(site_number="0")
db = Mongo::Connection.new("localhost", 27017).db("#{DB_BASE_NAME}_#{site_number}")
coll_bulletin = db["bulletins"]
coll_cat = db["bulletin_categories"]
categories = coll_cat.find().to_a.inject({}) do |categories, category|
categories[category['key']] = category['_id']
categories
end
[categories, coll_bulletin, coll_cat]
end
# Get categories
categories, coll_bulletin, coll_cat = get_mongo_and_categories
all.each do |bul| # Loop through all the items
category_id, categories = get_category_id(bul[:category], categories, coll_cat)
unless coll_bulletin.find_one(rss_link: bul[:link])
bulletin = { _type: "Bulletin",
postdate: bul[:date],
created_at: bul[:date],
updated_at: bul[:date],
is_checked: true,
is_pending: false,
is_rejected: false,
bulletin_category_id: category_id,
title: {:zh_tw => bul[:title]},
text: {:zh_tw => bul[:description]},
available_for_zh_tw: true,
rss_link: bul[:link] }
coll_bulletin.save(bulletin)
end
end
+91
View File
@@ -0,0 +1,91 @@
# encoding: utf-8
require 'rss'
require 'mongo'
AUTHORS = %w[ 學生事務處-學生住宿服務組
學生事務處-學生職業生涯發展中心
學生事務處-衛生保健及醫療中心
學生事務處-課外活動指導組
學生事務處-學生活動中心管理組
學生事務處-僑生及陸生輔導組
學生事務處-生活輔導組
學生事務處-軍訓組
學生事務處-學生心理輔導中心
學生事務處-學生事務處]
DB_BASE_NAME = "site"
all = []
continue = true
i = 1
while continue do
open("http://ann.cc.ntu.edu.tw/asp/rss.asp?page=#{i}") do |rss|
feed = RSS::Parser.parse(rss.read.encode('utf-8', 'big5', invalid: :replace, undef: :replace, replace: '').gsub('<pubDate>Wes,', '<pubDate>Wed,').gsub(/(encoding=\"big5\")/, 'encoding="utf-8"'))
feed.items.size
feed.items.each do |item|
if AUTHORS.include?(item.author)
author = item.author.strip
category = item.category.to_s.gsub(/\<(\/)*category\>/, '')
all << {title: item.title.strip, author: author, link: item.link.strip, date: item.pubDate, category: category, description: item.description.gsub("\r\n", '<br/>').strip}
end
end
continue = false if feed.items.size < 100
end
i += 1
end
# Get corresponding category_id or create a new one
def get_category_id(category, categories, coll_cat)
if categories.keys.include? "rss_#{category}"
[categories["rss_#{category}"], categories]
else
cat = {
_type: "BulletinCategory",
key: "rss_#{category}",
disable: false,
title: {:zh_tw => category},
created_at: Time.now,
updated_at: Time.now
}
categories["rss_#{category}"] = result = coll_cat.save(cat)
[result, categories]
end
end
# Get categories and id based on a given site number
def get_mongo_and_categories(site_number="0")
db = Mongo::Connection.new("localhost", 27017).db("#{DB_BASE_NAME}_#{site_number}")
coll_bulletin = db["bulletins"]
coll_cat = db["bulletin_categories"]
categories = coll_cat.find().to_a.inject({}) do |categories, category|
categories[category['key']] = category['_id']
categories
end
[categories, coll_bulletin, coll_cat]
end
# Get categories
categories, coll_bulletin, coll_cat = get_mongo_and_categories
all.each do |bul| # Loop through all the items
category_id, categories = get_category_id(bul[:category], categories, coll_cat)
unless coll_bulletin.find_one(rss_link: bul[:link])
bulletin = { _type: "Bulletin",
postdate: bul[:date],
created_at: bul[:date],
updated_at: bul[:date],
is_checked: true,
is_pending: false,
is_rejected: false,
bulletin_category_id: category_id,
title: {:zh_tw => bul[:title]},
text: {:zh_tw => bul[:description]},
available_for_zh_tw: true,
rss_link: bul[:link] }
coll_bulletin.save(bulletin)
end
end
+2 -17
View File
@@ -26,18 +26,12 @@ namespace :mongo_files do
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
@@ -81,7 +75,7 @@ namespace :mongo_files do
# Remove duplicate files from db
def clean_duplicates
p "# of files in db: #{@files.count}"
file_hash = @files.find().inject({}) do |db_files, file|
file_hash = @files.find().sort({uploadDate: -1}).inject({}) do |db_files, file|
name = file['filename']
if db_files[name]
db_files[name] += [file['_id']]
@@ -119,17 +113,8 @@ namespace :mongo_files do
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 << file['filename'] if file['filename'] =~ /writing_journal_file|news_bulletin_file|image\/image/
db_files
end
p db_array.size