Compare commits
10
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
18b36df573 | ||
|
|
09bb318d6a | ||
|
|
d766eea9f4 | ||
|
|
d5dc3ef793 | ||
|
|
b3366b48a1 | ||
|
|
36e7e3d3e8 | ||
|
|
06c2240d34 | ||
|
|
c4e8ed96a9 | ||
|
|
8ad015af7f | ||
|
|
1857ad428c |
No files matched your search
@@ -4,6 +4,8 @@
|
||||
.rvmrc
|
||||
|
||||
Gemfile.lock
|
||||
Procfile
|
||||
log/*
|
||||
|
||||
db/*.sqlite3
|
||||
log/*.log
|
||||
|
||||
+13
-16
@@ -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;
|
||||
@@ -0,0 +1,7 @@
|
||||
class GetAnnouncementFromRss
|
||||
@queue = :high
|
||||
|
||||
def self.perform()
|
||||
%x(ruby "#{Rails.root}/lib/rss_ntu_job.rb")
|
||||
end
|
||||
end
|
||||
@@ -42,7 +42,6 @@ class User
|
||||
|
||||
before_create :initialize_desktop
|
||||
before_save :rebuild_status_record
|
||||
before_save :save_roles
|
||||
scope :remote_account, where(:nccu_id.ne => nil)
|
||||
scope :not_guest_user, all_of(:name.ne => "guest")
|
||||
|
||||
@@ -89,9 +88,9 @@ class User
|
||||
var[:id].each do |id,val|
|
||||
# binding.pry if id == '5052c5b22b5c49ab02000004'
|
||||
if (val=="true")
|
||||
self.roles = self.roles.reject{|t| t.id.to_s==id}
|
||||
self.role_ids.reject!{|t| t.to_s == id}
|
||||
elsif(val=="false")
|
||||
self.roles << Role.find(id)
|
||||
self.role_ids += Array(id)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -106,9 +105,9 @@ class User
|
||||
# binding.pry if id == '5052c5b22b5c49ab02000004'
|
||||
|
||||
if ( self.roles.include?(@roid) == false or val=="true")
|
||||
self.sub_roles = self.sub_roles.reject{|t| t.id.to_s==id}
|
||||
self.sub_role_ids.reject!{|t| t.to_s == id}
|
||||
elsif(val=="false")
|
||||
self.sub_roles << SubRole.find(id)
|
||||
self.sub_role_ids += Array(id)
|
||||
end
|
||||
|
||||
end
|
||||
@@ -273,10 +272,6 @@ class User
|
||||
end
|
||||
|
||||
protected
|
||||
def save_roles
|
||||
# self.roles = self.sub_roles.collect{|t| t.role}.uniq
|
||||
self.roles = self.roles.uniq
|
||||
end
|
||||
|
||||
def rebuild_status_record
|
||||
self.status_record = {}
|
||||
|
||||
@@ -17,4 +17,4 @@
|
||||
<%= render :partial=> "widget_ext_options" %>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
<% end %>
|
||||
@@ -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" %>">
|
||||
|
||||
@@ -3,9 +3,6 @@
|
||||
<% end %>
|
||||
|
||||
<ul>
|
||||
<li>總機電話:<a href="tel:+886229393091">02-29393091</a></li>
|
||||
<li>傳真:02-29379611</li>
|
||||
<li>緊急重大事件通聯窗口:校內分機 66119、66110</li>
|
||||
<li>總值日室:<a href="tel:+88229387132">02-29387132</a></li>
|
||||
<li>駐警衛室:<a href="tel:+88229387129">02-29387129</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>
|
||||
@@ -5,6 +5,6 @@
|
||||
<div id='map_canvas'></div>
|
||||
|
||||
<script type='text/javascript'>
|
||||
var $map_center = "24.987449, 121.576117"
|
||||
var $map_center = "25.015205, 121.535491"
|
||||
var $map_zoom = 17
|
||||
</script>
|
||||
@@ -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>This University</h3>No.101,Sec. 2, Jiafeng S Road, Zhubei City, Hsinchu County 302, Taiwan'
|
||||
location_description: '<h3>National Taiwan University</h3>No. 1, Sec. 4, Roosevelt Road, Taipei, 10617 Taiwan (R.O.C)'
|
||||
page: Page
|
||||
@@ -4,10 +4,10 @@ zh_tw:
|
||||
bulletin: 公告
|
||||
contact: 聯絡資訊
|
||||
copyright: 著作權宣告
|
||||
copyright_text: 本網站著作權屬於本大學。
|
||||
copyright_text: 本網站著作權屬於國立臺灣大學 學生事務處
|
||||
copyright_orbit: 銳綸數位建置
|
||||
home: 首頁
|
||||
language: 語言
|
||||
location: 地理位置
|
||||
location_description: '<h3>本大學</h3>302新竹縣竹北市嘉豐南路二段101號'
|
||||
location_description: '<h3>臺灣大學總務處 版權所有</h3>10617 臺北市大安區羅斯福路四段一號'
|
||||
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
|
||||
|
||||
update_tag_cloud:
|
||||
cron: 0 0 [0,12] * * *
|
||||
cron: 0 30 2 * * *
|
||||
class: UpdateTagCloud
|
||||
args:
|
||||
description: UpdateTagCloud
|
||||
@@ -27,3 +27,9 @@ email_cron:
|
||||
class: EmailCron
|
||||
args:
|
||||
description: EmailCron
|
||||
|
||||
get_announcement_from_rss:
|
||||
cron: 0 0 [2,12] * * *
|
||||
class: GetAnnouncementFromRss
|
||||
args:
|
||||
description: Loop through the announcement RSS until 24h ago
|
||||
@@ -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
|
||||
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -310,6 +310,34 @@ namespace :migrate do
|
||||
Rake::Task["web_link_url:web_link_url_i18n"].execute
|
||||
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
|
||||
Tag.all.each do |tag|
|
||||
tag.taggings.each do |tagging|
|
||||
@@ -326,4 +354,44 @@ namespace :migrate do
|
||||
`mongo #{Mongoid.config.database.name} --eval "db.tags.remove({_type: {$ne: 'Tag'}})"`
|
||||
end
|
||||
|
||||
task :add_missing_user_link => :environment do
|
||||
User.all.each do |user|
|
||||
user.role_ids.uniq!
|
||||
user.sub_role_ids.uniq!
|
||||
user.save
|
||||
user.roles.each do |role|
|
||||
unless role.user_ids.include?(user.id)
|
||||
role.user_ids << user.id
|
||||
role.save
|
||||
end
|
||||
end
|
||||
user.sub_roles.each do |sub_role|
|
||||
unless sub_role.user_ids.include?(user.id)
|
||||
sub_role.user_ids << user.id
|
||||
sub_role.save
|
||||
end
|
||||
end
|
||||
end
|
||||
Role.all.each do |role|
|
||||
role.user_ids.uniq!
|
||||
role.save
|
||||
role.users.each do |user|
|
||||
unless user.role_ids.include?(role.id)
|
||||
user.role_ids << role.id
|
||||
user.save
|
||||
end
|
||||
end
|
||||
end
|
||||
SubRole.all.each do |sub_role|
|
||||
sub_role.user_ids.uniq!
|
||||
sub_role.save
|
||||
sub_role.users.each do |user|
|
||||
unless user.sub_role_ids.include?(sub_role.id)
|
||||
user.sub_role_ids << sub_role.id
|
||||
user.save
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
@@ -0,0 +1,168 @@
|
||||
# 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]
|
||||
|
||||
task :clean => :environment do
|
||||
@files = Mongoid.database['fs.files']
|
||||
@chunks = Mongoid.database['fs.chunks']
|
||||
clean_duplicates
|
||||
clean_unused
|
||||
remove_objects
|
||||
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().sort({uploadDate: -1}).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()
|
||||
|
||||
db_array = @files.find().inject([]) do |db_files, file|
|
||||
db_files << file['filename'] if file['filename'] =~ /writing_journal_file|news_bulletin_file|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
|
||||
+10
-10
@@ -9,17 +9,17 @@ namespace :web_link_url do
|
||||
|
||||
@weblinks.each do |wl|
|
||||
|
||||
if wl.url.nil?
|
||||
if wl.url_translations.is_a?(String)
|
||||
|
||||
@wlurl = wl.url_translations
|
||||
|
||||
wl.url_translations = {}
|
||||
|
||||
wl.url_translations["zh_tw"] = @wlurl
|
||||
|
||||
wl.url_translations["en"] = @wlurl
|
||||
|
||||
@wlurl = wl.url_translations
|
||||
|
||||
wl.url_translations = {}
|
||||
|
||||
wl.url_translations["zh_tw"] = @wlurl
|
||||
|
||||
wl.url_translations["en"] = @wlurl
|
||||
|
||||
wl.save
|
||||
wl.save
|
||||
|
||||
else
|
||||
puts 'no data'
|
||||
|
||||
vendor/built_in_modules/announcement/app/assets/stylesheets/announcement/bulletins_and_web_links.css
Vendored
+78
@@ -0,0 +1,78 @@
|
||||
|
||||
.mega_tab_block {
|
||||
clear: both;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.mega_tab_block h3 {
|
||||
font: 22px/100% 'arial',sans-serif;
|
||||
margin: 0 0 10px;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.mega_tab_block .pagination {
|
||||
float: left;
|
||||
height: auto;
|
||||
margin: 10px 0 0;
|
||||
width: auto;
|
||||
}
|
||||
.mega_tab_block .pagination a {
|
||||
background: none repeat scroll 0 0 #EEEEEE;
|
||||
display: block;
|
||||
float: left;
|
||||
margin: 0 5px 0 0;
|
||||
padding: 10px;
|
||||
}
|
||||
|
||||
|
||||
.tag_block {
|
||||
clear: both;
|
||||
margin: 0 0 20px;
|
||||
position: relative;
|
||||
}
|
||||
.mega_tab_block .tag_list {
|
||||
background: none repeat scroll 0 0 #EEEEEE;
|
||||
margin: 0;
|
||||
overflow: hidden;
|
||||
padding: 0 0 0 5px;
|
||||
}
|
||||
.mega_tab_block .tag_list li {
|
||||
float: left;
|
||||
list-style: none outside none;
|
||||
}
|
||||
.mega_tab_block .tag_list li a {
|
||||
background: none repeat scroll 0 0 #DDDDDD;
|
||||
float: left;
|
||||
margin: 0 5px 0 0;
|
||||
padding: 10px;
|
||||
}
|
||||
|
||||
.news_block {
|
||||
clear: both;
|
||||
margin: 0 0 20px;
|
||||
overflow: hidden;
|
||||
position: relative;
|
||||
}
|
||||
.mega_tab_block .news_list {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
.mega_tab_block .news_list li {
|
||||
list-style: none outside none;
|
||||
padding: 5px 0;
|
||||
}
|
||||
|
||||
|
||||
.links_block {
|
||||
clear: both;
|
||||
overflow: hidden;
|
||||
position: relative;
|
||||
}
|
||||
.mega_tab_block .links_list {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
.mega_tab_block .links_list li {
|
||||
list-style: none outside none;
|
||||
padding: 5px 0;
|
||||
}
|
||||
+65
-4
@@ -66,14 +66,75 @@ class Panel::Announcement::Widget::BulletinsController < OrbitWidgetController
|
||||
|
||||
end
|
||||
|
||||
def bulletins_and_web_links
|
||||
|
||||
@part = PagePart.find(params[:part_id]) if !params[:part_id].blank?
|
||||
|
||||
@title = @part.title_translations[I18n.locale.to_s]
|
||||
|
||||
if !@part.blank? and @part.widget_data_count
|
||||
@page_num = @part.widget_data_count
|
||||
else
|
||||
@page_num = 5
|
||||
end
|
||||
|
||||
date_now = Time.now
|
||||
|
||||
if !params[:tag_id].blank?
|
||||
@tags = Tag.any_in(:_id => params[:tag_id]).asc(:created_at)
|
||||
elsif params[:tag_id].blank? and !@part.tag.blank?
|
||||
@tags = Tag.any_in(:_id => @part.tag).asc(:created_at)
|
||||
else
|
||||
@ModuleApp_b = ModuleApp.first(:conditions => {:key=>'announcement'})
|
||||
@tags = Tag.where(:module_tag_id => @ModuleApp_b.id).asc(:created_at)
|
||||
end
|
||||
|
||||
@selected_tag = Tag.find(params[:id]).first rescue @tags[0]
|
||||
|
||||
@bulletins = Bulletin.available_for_lang(I18n.locale).can_display.where(:tagged_ids => @selected_tag.id.to_s, :is_hidden => false).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) rescue nil
|
||||
|
||||
if @part.widget_style == 'bulletins_and_web_links'
|
||||
@ModuleApp_w = ModuleApp.first(:conditions => {:key=>'web_resource'})
|
||||
@link_selected_tag = Tag.first(:conditions => {:name => @selected_tag.name, :module_tag_id => @ModuleApp_w.id})
|
||||
@web_links = WebLink.where(:tagged_ids => @link_selected_tag.id.to_s, :is_hidden => false).desc(:is_top,:created_at).available_for_lang(I18n.locale).page(params[:page]).per(@page_num) rescue nil
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
def reload_bulletins
|
||||
@selected_tag = Tag.find(params[:tag_id])
|
||||
@bulletins = Bulletin.available_for_lang(I18n.locale).can_display.where(:tagged_ids => params[:tag_id]).where(:is_hidden => false).any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc(:is_top, sort).page(params[:page]).per(5) rescue nil
|
||||
|
||||
@part = PagePart.find(params[:part_id]) if !params[:part_id].blank?
|
||||
|
||||
@title = @part.title_translations[I18n.locale.to_s]
|
||||
|
||||
if !@part.blank? and @part.widget_data_count
|
||||
@page_num = @part.widget_data_count
|
||||
else
|
||||
@page_num = 5
|
||||
end
|
||||
|
||||
date_now = Time.now
|
||||
|
||||
@selected_tag = Tag.find(params[:tag_id]).first
|
||||
@bulletins = Bulletin.available_for_lang(I18n.locale).can_display.where(:tagged_ids => @selected_tag.id.to_s, :is_hidden => false).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) rescue nil
|
||||
end
|
||||
|
||||
def reload_web_links
|
||||
@selected_tag = Tag.find(params[:tag_id])
|
||||
@web_links = WebLink.where(:name => @selected_tag.name).where(:is_hidden => false).desc(:is_top, sort).available_for_lang(I18n.locale).page(params[:page]).per(5) rescue nil
|
||||
|
||||
@part = PagePart.find(params[:part_id]) if !params[:part_id].blank?
|
||||
|
||||
if !@part.blank? and @part.widget_data_count
|
||||
@page_num = @part.widget_data_count
|
||||
else
|
||||
@page_num = 5
|
||||
end
|
||||
|
||||
date_now = Time.now
|
||||
|
||||
@selected_tag = Tag.find(params[:tag_id]).first
|
||||
@ModuleApp = ModuleApp.first(:conditions => {:key=>'web_resource'})
|
||||
@link_selected_tag = Tag.first(:conditions => {:name => @selected_tag.name, :module_tag_id => @ModuleApp.id})
|
||||
@web_links = WebLink.where(:tagged_ids => @link_selected_tag.id.to_s, :is_hidden => false).desc(:is_top,:created_at).available_for_lang(I18n.locale).page(params[:page]).per(@page_num) rescue nil
|
||||
end
|
||||
|
||||
def bulletins_side_bar
|
||||
|
||||
@@ -40,6 +40,7 @@ class Bulletin
|
||||
field :not_checked_reason
|
||||
|
||||
field :public, :type => Boolean, :default => true
|
||||
field :rss_link
|
||||
|
||||
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) }
|
||||
|
||||
Vendored
+5
@@ -36,6 +36,11 @@
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
<% unless @bulletin.rss_link.blank? %>
|
||||
<div>
|
||||
<%= link_to t('ntu.rss_origin'), @bulletin.rss_link %>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<%= share_links(@bulletin, 'announcement') %>
|
||||
+3
-3
@@ -1,10 +1,10 @@
|
||||
<% @bulletins.each do |bulletin| %>
|
||||
<li>
|
||||
<%= link_to bulletin.title, panel_announcement_front_end_bulletin_path(bulletin, :category_id => bulletin.bulletin_category_id , :tag_id => @selected_tag.id ) %>
|
||||
<%= link_to bulletin.title, panel_announcement_front_end_bulletin_path(bulletin, :category_id => bulletin.bulletin_category_id , :part_id => params[:part_id], :tag_id => [@selected_tag.id] ) %>
|
||||
</li>
|
||||
<% end %>
|
||||
|
||||
<div class='pagination'>
|
||||
<%= link_to_previous_page @bulletins, 'Previous Page', :params => {:controller => 'widget/bulletins', :action => 'reload_bulletins', :tag_id => @selected_tag.id}, :remote => true, :class => 'previous' %>
|
||||
<%= link_to_next_page @bulletins, 'Next Page', :params => {:controller => 'widget/bulletins', :action => 'reload_bulletins', :tag_id => @selected_tag.id}, :remote => true, :class => 'next' %>
|
||||
<%= link_to_previous_page @bulletins, 'Previous Page', :params => {:controller => 'widget/bulletins', :action => 'reload_bulletins', :part_id => params[:part_id], :tag_id => [@selected_tag.id]}, :remote => true, :class => 'previous' %>
|
||||
<%= link_to_next_page @bulletins, 'Next Page', :params => {:controller => 'widget/bulletins', :action => 'reload_bulletins', :part_id => params[:part_id], :tag_id => [@selected_tag.id]}, :remote => true, :class => 'next' %>
|
||||
</div>
|
||||
Vendored
+1
-1
@@ -1,3 +1,3 @@
|
||||
<li>
|
||||
<%= link_to tag.name, panel_announcement_widget_bulletins_and_web_links_path(:id => tag.id), :remote => true, :class => ('active' if tag.eql?(@selected_tag)) %>
|
||||
<%= link_to tag.name, panel_announcement_widget_bulletins_and_web_links_path(:inner=>true, :id => [tag.id], :part_id=>params[:part_id]), :remote => true, :class => ('active' if tag.eql?(@selected_tag)) %>
|
||||
</li>
|
||||
+2
-2
@@ -5,6 +5,6 @@
|
||||
<% end %>
|
||||
|
||||
<div class='pagination'>
|
||||
<%= link_to_previous_page @web_links, 'Previous Page', :params => {:controller => 'widget/bulletins', :action => 'reload_web_links', :tag_id => @selected_tag.id}, :remote => true, :class => 'previous' %>
|
||||
<%= link_to_next_page @web_links, 'Next Page', :params => {:controller => 'widget/bulletins', :action => 'reload_web_links', :tag_id => @selected_tag.id}, :remote => true, :class => 'next' %>
|
||||
<%= link_to_previous_page @web_links, 'Previous Page', :params => {:controller => 'widget/bulletins', :action => 'reload_web_links', :part_id => params[:part_id], :tag_id => @selected_tag.id}, :remote => true, :class => 'previous' %>
|
||||
<%= link_to_next_page @web_links, 'Next Page', :params => {:controller => 'widget/bulletins', :action => 'reload_web_links', :part_id => params[:part_id], :tag_id => @selected_tag.id}, :remote => true, :class => 'next' %>
|
||||
</div>
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
<div class="mega_tab_block">
|
||||
|
||||
<div class="tag_block">
|
||||
<ul id='bulletins_web_links_tags' class="tag_list">
|
||||
<%= render :partial => 'tag', :collection => @tags %>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="news_block">
|
||||
<h3 class="news_title2">
|
||||
<%#= link_to t("announcement.bulletins"), panel_announcement_front_end_bulletins_path, :class => 'more' %>
|
||||
<%= link_to @title, panel_announcement_front_end_bulletins_path, :class => 'more' %>
|
||||
</h3>
|
||||
<ul id='bulletins_web_links_bulletins' class="news_list">
|
||||
<%= render 'bulletins' if @bulletins %>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<% if @part.widget_style == 'bulletins_and_web_links' %>
|
||||
|
||||
<div class="links_block">
|
||||
<h3 class="links_title"><%= t(:related_links) %></h3>
|
||||
<ul id='bulletins_web_links_web_links' class="links_list">
|
||||
<%= render 'web_links' if @web_links %>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<% end %>
|
||||
|
||||
</div>
|
||||
|
||||
<% content_for :page_specific_javascript do %>
|
||||
<%= javascript_include_tag "news_link" %>
|
||||
<% end %>
|
||||
|
||||
<%= stylesheet_link_tag "announcement/bulletins_and_web_links" %>
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
$('#bulletins_web_links_tags').html("<%= j render :partial => 'tag', :collection => @tags %>")
|
||||
$('#bulletins_web_links_bulletins').html("<%= j render 'bulletins' if @bulletins %>")
|
||||
$('#bulletins_web_links_web_links').html("<%= j render 'web_links' if @web_links %>")
|
||||
@@ -35,6 +35,6 @@ en:
|
||||
update_bulletin_category_success: Update Category Successfully
|
||||
url: URL
|
||||
widget:
|
||||
bulletins_and_web_links: Bulletins and Web Resources
|
||||
bulletins_and_web_links: Differential Nav.
|
||||
index: Index
|
||||
search: Search
|
||||
@@ -35,6 +35,6 @@ zh_tw:
|
||||
update_bulletin_category_success: 更新類別成功
|
||||
url: 連結位置
|
||||
widget:
|
||||
bulletins_and_web_links: 索引
|
||||
bulletins_and_web_links: 分眾頁籤
|
||||
index: 索引
|
||||
search: 搜尋
|
||||
@@ -52,6 +52,11 @@ module Announcement
|
||||
widget_i18n "announcement.widget.search"
|
||||
end
|
||||
|
||||
customize_widget "bulletins_and_web_links" do
|
||||
widget_i18n "announcement.widget.bulletins_and_web_links"
|
||||
style ["bulletins_and_links","bulletins_only"]
|
||||
end
|
||||
|
||||
# item "index","announcement.widget.index",:default_template=>true,:fields=>["title","category","postdate"]
|
||||
# item "bulletins_and_web_links","announcement.widget.bulletins_and_web_links"
|
||||
end
|
||||
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
class Panel::Location::BackEnd::LocationCategoriesController < OrbitBackendController
|
||||
|
||||
def index
|
||||
@categorylist = LocationCategory.all
|
||||
@new_category = LocationCategory.new
|
||||
end
|
||||
|
||||
def create
|
||||
@category = LocationCategory.new(params[:location_category])
|
||||
@category.save!
|
||||
respond_to do |h|
|
||||
h.js
|
||||
end
|
||||
end
|
||||
|
||||
def edit
|
||||
@category = LocationCategory.find(params[:id])
|
||||
render :layout => false
|
||||
end
|
||||
|
||||
def update
|
||||
@category = LocationCategory.find(params[:id])
|
||||
@category.update_attributes(params[:location_category])
|
||||
respond_to do |h|
|
||||
h.js
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def destroy
|
||||
@category = LocationCategory.find(params['id'])
|
||||
@category.delete
|
||||
render :json=>{"success"=>"true"}.to_json
|
||||
end
|
||||
|
||||
end
|
||||
Vendored
-1
@@ -14,7 +14,6 @@ class Panel::Location::BackEnd::LocationsController < OrbitBackendController
|
||||
|
||||
def new
|
||||
@location_info = LocationInfo.new
|
||||
|
||||
respond_to do |format|
|
||||
format.html # new.html.erb
|
||||
format.json { render json: @location }
|
||||
|
||||
@@ -8,4 +8,6 @@ class Location
|
||||
field :description
|
||||
field :longitude, type: Float
|
||||
field :latitude, type: Float
|
||||
|
||||
belongs_to :location_category
|
||||
end
|
||||
@@ -0,0 +1,14 @@
|
||||
class LocationCategory
|
||||
include Mongoid::Document
|
||||
include Mongoid::Timestamps
|
||||
|
||||
# include OrbitCoreLib::ObjectAuthable
|
||||
|
||||
# ObjectAuthTitlesOptions = %W{new_album}
|
||||
# APP_NAME = "album"
|
||||
|
||||
field :name, localize: true
|
||||
|
||||
has_many :location_infos, :autosave => true, :dependent => :destroy
|
||||
|
||||
end
|
||||
@@ -9,6 +9,8 @@ class LocationInfo
|
||||
field :longitude, type: Float
|
||||
field :latitude, type: Float
|
||||
|
||||
belongs_to :location_category
|
||||
|
||||
validates :file, presence: true
|
||||
validates :longitude,
|
||||
numericality: { less_than_or_equal_to: 180.0, greater_than_or_equal_to: -180.0 },
|
||||
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
<div class="tag clear">
|
||||
<div class="tagitem">
|
||||
<i class="icon-folder-close"></i>
|
||||
<% @site_valid_locales.each do |locale| %>
|
||||
<span class="value" for="<%= locale %>"><%= category.name_translations[locale] rescue nil %> </span>
|
||||
<% end %>
|
||||
</div>
|
||||
<div class="action">
|
||||
<%= link_to(t(:delete_), panel_location_back_end_location_category_path(category), :method => :delete, :confirm => t("sure?"), :remote => true, :class => "delete") %>
|
||||
<%= link_to(t(:edit), edit_panel_location_back_end_location_category_path(category), :remote => true, :class => "edit") %>
|
||||
<%#= show_gallery_category_permission_link(category) %>
|
||||
</div>
|
||||
</div>
|
||||
vendor/built_in_modules/location/app/views/panel/location/back_end/location_categories/create.js.erb
Vendored
+2
@@ -0,0 +1,2 @@
|
||||
var dom = $("<%= j render :partial => 'category', :object => @category %>");
|
||||
$("div#tags").append(dom);
|
||||
vendor/built_in_modules/location/app/views/panel/location/back_end/location_categories/edit.html.erb
Vendored
+10
@@ -0,0 +1,10 @@
|
||||
<%= form_for @category, :url => panel_location_back_end_location_category_path(@category), :remote => true do |f| %>
|
||||
<%= f.fields_for :name_translations do |name| %>
|
||||
<% @site_valid_locales.each do |locale| %>
|
||||
<%= label_tag(locale,t("location.new_category")+"["+I18nVariable.from_locale(locale)+"]") %>
|
||||
<%= name.text_field locale, :value =>(@category.name_translations[locale]) %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<%= f.submit "Save", :class=> "btn btn-primary temp_save_btn" %>
|
||||
<a href="#" class="btn btn-primary" id="temp_cancel_btn" onclick="return false;"><%= I18n.t(:cancel) %></a>
|
||||
<% end %>
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
<div id="tags" class="clear">
|
||||
<%= render :partial => 'category', :collection => @categorylist %>
|
||||
</div>
|
||||
<div class="form-actions form-fixed form-inline pagination-right">
|
||||
<%= form_for @new_category, :url => {:action => "create"}, :remote => true do |f| %>
|
||||
<%= f.fields_for :name_translations do |name| %>
|
||||
<% @site_valid_locales.each do |locale| %>
|
||||
<%= label_tag(locale,t("location.new_category")+"["+I18nVariable.from_locale(locale)+"]") %>
|
||||
<%= name.text_field locale %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<%= f.submit "Save", :class=> "btn btn-primary" %>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
var deleteCategory = function(a){
|
||||
var parent = a.parent().parent();
|
||||
parent.hide("slide",function(){parent.remove();})
|
||||
}
|
||||
var parent;
|
||||
var editCategory = function(a,data){
|
||||
parent = a.parent().parent();
|
||||
var parenthtml = parent.html();
|
||||
var tempdom = $("<div class='tagitem'></div>");
|
||||
tempdom.append(data);
|
||||
parent.html(tempdom);
|
||||
tempdom.find("a#temp_cancel_btn").click(function(){
|
||||
parent.html(parenthtml);
|
||||
})
|
||||
}
|
||||
|
||||
$(document).ready(function(){
|
||||
$("#tags div.action a.delete").live('ajax:success', function(){
|
||||
deleteCategory($(this));
|
||||
})
|
||||
$("#tags div.action a.edit").live('ajax:success',function(evt, data, status, xhr){
|
||||
editCategory($(this),data);
|
||||
})
|
||||
})
|
||||
</script>
|
||||
vendor/built_in_modules/location/app/views/panel/location/back_end/location_categories/update.js.erb
Vendored
+2
@@ -0,0 +1,2 @@
|
||||
var dom = $("<%= j render :partial => 'category', :object => @category %>");
|
||||
parent.html(dom.html());
|
||||
Vendored
+7
-1
@@ -9,6 +9,12 @@
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label" for=""><%= t "category" %></label>
|
||||
<div class="controls">
|
||||
<%= f.select(:location_category_id, LocationCategory.all.collect {|p| [ p.name, p.id ] },{:prompt => t("location.select_category")},:class => "validate input-xlarge") %>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label" for=""><%= t 'picture' %></label>
|
||||
<div class="controls">
|
||||
@@ -20,7 +26,7 @@
|
||||
<label class="control-label" for=""><%= t 'coordinates' %></label>
|
||||
<div class="controls">
|
||||
<%= f.text_field :longitude, :class=>"span2", :placeholder => "Longitude" %>
|
||||
<%= f.text_field :latitude, :class=>"span2", :placeholder => "Langitude" %>
|
||||
<%= f.text_field :latitude, :class=>"span2", :placeholder => "Lantitude" %>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
|
||||
+1
-1
@@ -1,3 +1,3 @@
|
||||
<%= form_for @location_info, :url=> panel_location_back_end_locations_path, :html => { :class=>"form-horizontal"} do |f| %>
|
||||
<%= form_for @location_info, :url=> panel_location_back_end_locations_path, :html => { :class=>"form-horizontal",:multipart => true} do |f| %>
|
||||
<%= render :partial => 'form', :locals => {:f => f} %>
|
||||
<% end %>
|
||||
+5
-2
@@ -1,3 +1,6 @@
|
||||
en:
|
||||
location:
|
||||
location: Location
|
||||
location: Location
|
||||
locations: Locations
|
||||
new_category: "New Category"
|
||||
save: Save
|
||||
select_category: "Select Category"
|
||||
@@ -6,6 +6,7 @@ Rails.application.routes.draw do
|
||||
match "locations/get_locations" => "locations#get_locations"
|
||||
|
||||
resources :locations
|
||||
resources :location_categories
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
+9
-2
@@ -1,6 +1,6 @@
|
||||
module Location
|
||||
OrbitApp.registration "Location",:type=> 'ModuleApp' do
|
||||
module_label 'location.location'
|
||||
module_label 'locations'
|
||||
base_url File.expand_path File.dirname(__FILE__)
|
||||
# personal_plugin :enable => true,:path=>"panel/location/plugin/profile",:i18n=>'admin.location'
|
||||
|
||||
@@ -32,12 +32,19 @@ module Location
|
||||
# end
|
||||
|
||||
side_bar do
|
||||
head_label_i18n 'location.location',:icon_class=>"icons-location"
|
||||
head_label_i18n 'locations',:icon_class=>"icons-location"
|
||||
available_for [:admin,:guest,:manager,:sub_manager]
|
||||
active_for_controllers ({:private=>['locations']})
|
||||
|
||||
head_link_path "panel_location_back_end_locations_path"
|
||||
|
||||
context_link 'categories',
|
||||
:link_path=>"panel_location_back_end_location_categories_path" ,
|
||||
:priority=>1,
|
||||
:active_for_action=>{:localtion_categories=>:index},
|
||||
:available_for => [:manager]
|
||||
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in new issue
Block a user