parent
2226d59446
commit
70427d82e2
|
@ -27,7 +27,7 @@ class Admin::ArchiveFilesController < OrbitAdminController
|
||||||
def index
|
def index
|
||||||
|
|
||||||
if ArchiveSortOrder.count == 0
|
if ArchiveSortOrder.count == 0
|
||||||
ArchiveSortOrder.new('sort_order' => false).save
|
ArchiveSortOrder.create('sort_order' => false)
|
||||||
end
|
end
|
||||||
if !(params['order_asc'].nil?)
|
if !(params['order_asc'].nil?)
|
||||||
if params['order_asc'] == 'true'
|
if params['order_asc'] == 'true'
|
||||||
|
@ -41,7 +41,7 @@ class Admin::ArchiveFilesController < OrbitAdminController
|
||||||
@categories = @module_app.categories.enabled
|
@categories = @module_app.categories.enabled
|
||||||
@tags = @module_app.tags
|
@tags = @module_app.tags
|
||||||
@filter_fields = filter_fields(@categories, @tags)
|
@filter_fields = filter_fields(@categories, @tags)
|
||||||
@archives = ArchiveFile.order_by(sort)
|
@archives = ArchiveFile.local_data.order_by(sort)
|
||||||
.with_categories(filters("category"))
|
.with_categories(filters("category"))
|
||||||
.with_tags(filters("tag"))
|
.with_tags(filters("tag"))
|
||||||
.with_status(filters("status"))
|
.with_status(filters("status"))
|
||||||
|
@ -52,7 +52,8 @@ class Admin::ArchiveFilesController < OrbitAdminController
|
||||||
end
|
end
|
||||||
|
|
||||||
def new
|
def new
|
||||||
@archive_file = ArchiveFile.new
|
sort_number = ArchiveSortOrder.first.get_default_order
|
||||||
|
@archive_file = ArchiveFile.new(:sort_number=>sort_number)
|
||||||
@tags = @module_app.tags
|
@tags = @module_app.tags
|
||||||
@categories = @module_app.categories.enabled
|
@categories = @module_app.categories.enabled
|
||||||
end
|
end
|
||||||
|
@ -99,6 +100,9 @@ class Admin::ArchiveFilesController < OrbitAdminController
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
if @archive_file.save
|
if @archive_file.save
|
||||||
|
Thread.new do
|
||||||
|
@archive_file.notify_feed("create")
|
||||||
|
end
|
||||||
format.html { redirect_to(admin_archive_files_path) }
|
format.html { redirect_to(admin_archive_files_path) }
|
||||||
format.xml { render :xml => @archive_file, :status => :created, :location => @archive_file }
|
format.xml { render :xml => @archive_file, :status => :created, :location => @archive_file }
|
||||||
else
|
else
|
||||||
|
@ -129,6 +133,9 @@ class Admin::ArchiveFilesController < OrbitAdminController
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
if @archive_file.update_attributes(archive_vars)
|
if @archive_file.update_attributes(archive_vars)
|
||||||
|
Thread.new do
|
||||||
|
@archive_file.notify_feed("update")
|
||||||
|
end
|
||||||
format.html { redirect_to(admin_archive_files_path) }
|
format.html { redirect_to(admin_archive_files_path) }
|
||||||
format.xml { head :ok }
|
format.xml { head :ok }
|
||||||
else
|
else
|
||||||
|
@ -141,11 +148,72 @@ class Admin::ArchiveFilesController < OrbitAdminController
|
||||||
def destroy
|
def destroy
|
||||||
archive_file = ArchiveFile.find(params[:id])
|
archive_file = ArchiveFile.find(params[:id])
|
||||||
archive_file.destroy
|
archive_file.destroy
|
||||||
|
Thread.new do
|
||||||
|
archive_file.notify_feed("destroy")
|
||||||
|
end
|
||||||
redirect_to admin_archive_files_path
|
redirect_to admin_archive_files_path
|
||||||
end
|
end
|
||||||
|
def delete
|
||||||
|
if params[:ids]
|
||||||
|
ArchiveFile.any_in(:uid => params[:ids]).destroy_all
|
||||||
|
Thread.new do
|
||||||
|
ArchiveFile.notify_feed_delete(params[:ids])
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if request.xhr?
|
||||||
|
render :nothing => true, :status => 204
|
||||||
|
else
|
||||||
|
redirect_to admin_archive_files_path
|
||||||
|
end
|
||||||
|
end
|
||||||
|
def feed
|
||||||
|
@table_feed_fields = ["archive.feed_name",:tags , :category , "archive.rssfeed", "archive.jsonfeed"]
|
||||||
|
@feeds = ArchiveFileFeed.all.asc(:created_at)
|
||||||
|
end
|
||||||
|
def feedform
|
||||||
|
if params[:type] == "new"
|
||||||
|
@archive_feed = ArchiveFileFeed.new(id: nil)
|
||||||
|
render :partial => "feed_form"
|
||||||
|
else params[:type] == "edit"
|
||||||
|
@archive_feed = ArchiveFileFeed.find(params[:id])
|
||||||
|
render :partial => "edit_feed_form"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def createfeed
|
||||||
|
archive_feed = ArchiveFileFeed.new(feed_params)
|
||||||
|
archive_feed.save
|
||||||
|
#ArchiveFileFeed.create_feed_cache(nil,archive_feed)
|
||||||
|
feeds = ArchiveFileFeed.all.asc(:created_at)
|
||||||
|
render :partial => "feed", :collection => feeds
|
||||||
|
end
|
||||||
|
|
||||||
|
def updatefeed
|
||||||
|
archive_feed = ArchiveFileFeed.find(params[:id])
|
||||||
|
archive_feed.update_attributes(feed_params)
|
||||||
|
archive_feed.save
|
||||||
|
#ArchiveFileFeed.create_feed_cache(nil,archive_feed)
|
||||||
|
feeds = ArchiveFileFeed.all.asc(:created_at)
|
||||||
|
render :partial => "feed", :collection => feeds
|
||||||
|
end
|
||||||
|
|
||||||
|
def deletefeed
|
||||||
|
archive_feed = ArchiveFileFeed.find(params[:id])
|
||||||
|
archive_feed.destroy
|
||||||
|
feeds = ArchiveFileFeed.all.asc(:created_at)
|
||||||
|
render :partial => "feed", :collection => feeds
|
||||||
|
end
|
||||||
private
|
private
|
||||||
|
def feed_params
|
||||||
|
feed_params = params.require(:archive_file_feed).permit!
|
||||||
|
if feed_params[:tag_ids].nil?
|
||||||
|
feed_params[:tag_ids] = []
|
||||||
|
end
|
||||||
|
if feed_params[:category_ids].nil?
|
||||||
|
feed_params[:category_ids] = []
|
||||||
|
end
|
||||||
|
feed_params
|
||||||
|
end
|
||||||
def archive_vars
|
def archive_vars
|
||||||
params[:archive_file][:tags] ||=[]
|
params[:archive_file][:tags] ||=[]
|
||||||
params.require(:archive_file).permit!
|
params.require(:archive_file).permit!
|
||||||
|
|
|
@ -0,0 +1,92 @@
|
||||||
|
require "rss"
|
||||||
|
class ArchiveFeedsController < ApplicationController
|
||||||
|
include Admin::ArchiveFilesHelper
|
||||||
|
def feed_add_remote
|
||||||
|
if params[:url].present?
|
||||||
|
uid = params[:uid]
|
||||||
|
archive_file_feed = ArchiveFileFeed.where(uid: uid).first
|
||||||
|
if !(archive_file_feed.remote_urls.include?(params[:url]))
|
||||||
|
archive_file_feed.remote_urls << params[:url]
|
||||||
|
archive_file_feed.save
|
||||||
|
end
|
||||||
|
end
|
||||||
|
render :json => {success: true}
|
||||||
|
end
|
||||||
|
def feed_remove_remote
|
||||||
|
if params[:url].present?
|
||||||
|
uid = params[:uid]
|
||||||
|
archive_file_feed = ArchiveFileFeed.where(uid: uid).first
|
||||||
|
if archive_file_feed.remote_urls.delete(params[:url])
|
||||||
|
archive_file_feed.save
|
||||||
|
end
|
||||||
|
end
|
||||||
|
render :json => {success: true}
|
||||||
|
end
|
||||||
|
def feed
|
||||||
|
uid = params[:uid]
|
||||||
|
feed_cache = ArchiveFileFeedCache.where(uid: uid)
|
||||||
|
feed_cache_old = feed_cache.last
|
||||||
|
count = feed_cache.count
|
||||||
|
if count > 1
|
||||||
|
feed_cache.limit(count-1).destroy
|
||||||
|
end
|
||||||
|
feed_cache = feed_cache.first
|
||||||
|
archive_content = ''
|
||||||
|
if feed_cache.nil?
|
||||||
|
archive_content = ArchiveFileFeed.where(uid: uid).first.generate_one_cache_timeout(base_url: request.base_url,timeout: 20)
|
||||||
|
archive_content = (feed_cache_old.content rescue "") if archive_content.nil?
|
||||||
|
else
|
||||||
|
archive_content = feed_cache.content
|
||||||
|
end
|
||||||
|
render :json => archive_content
|
||||||
|
end
|
||||||
|
|
||||||
|
def rssfeed
|
||||||
|
uid = params[:uid]
|
||||||
|
@aff = ArchiveFileFeed.find_by(:uid => uid) rescue nil
|
||||||
|
if !@aff.nil?
|
||||||
|
tags = @aff.tag_ids
|
||||||
|
if !tags.empty?
|
||||||
|
@archive_files = ArchiveFile.local_data.can_display_and_sorted.filter_by_tags(tags)
|
||||||
|
else
|
||||||
|
@archive_files = ArchiveFile.local_data.can_display_and_sorted
|
||||||
|
end
|
||||||
|
categories = @aff.category_ids
|
||||||
|
if !categories.empty?
|
||||||
|
@archive_files = @archive_files.filter_by_categories(categories)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
respond_to do |format|
|
||||||
|
format.html {redirect_to "/xhr/archive_files/rssfeed/#{@aff.uid}.rss"}
|
||||||
|
format.rss
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def feeds
|
||||||
|
feeds = []
|
||||||
|
ArchiveFileFeed.all.each do |aff|
|
||||||
|
feed = {}
|
||||||
|
feed["title_translations"] = aff.title_translations
|
||||||
|
feed["uid"] = aff.uid
|
||||||
|
feed["url"] = "#{request.base_url}/xhr/archive_files/feed/#{aff.uid}"
|
||||||
|
feed["xml_url"] = "#{request.base_url}/xhr/archive_files/rssfeed/#{aff.uid}.rss"
|
||||||
|
feed["tags"] = []
|
||||||
|
aff.tag_ids.each do |t|
|
||||||
|
tag = Tag.find(t)
|
||||||
|
d = {}
|
||||||
|
d["name_translations"] = tag.name_translations
|
||||||
|
feed["tags"] << d
|
||||||
|
end
|
||||||
|
feeds << feed
|
||||||
|
end
|
||||||
|
render :json => {"feeds" => feeds}.to_json
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,17 @@ class ArchivesController < ApplicationController
|
||||||
render :file => "#{Rails.root}/app/views/errors/404.html", :layout => false, :status => :not_found, :content_type => 'text/html' and return
|
render :file => "#{Rails.root}/app/views/errors/404.html", :layout => false, :status => :not_found, :content_type => 'text/html' and return
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
def show
|
||||||
|
params = OrbitHelper.params
|
||||||
|
archive_file = ArchiveFile.find_by(:uid=>params[:uid])
|
||||||
|
locale = I18n.locale.to_s
|
||||||
|
data, serial_number, idx = archive_file.get_frontend_data(locale, 0, 0, true, OrbitHelper.url_to_show(""))
|
||||||
|
{
|
||||||
|
"data" => data
|
||||||
|
}
|
||||||
|
end
|
||||||
def index
|
def index
|
||||||
|
ArchiveFile.check_sort_number
|
||||||
page = OrbitHelper.page rescue nil
|
page = OrbitHelper.page rescue nil
|
||||||
unless page
|
unless page
|
||||||
page = Page.where(url:params['url']).first
|
page = Page.where(url:params['url']).first
|
||||||
|
@ -24,13 +34,13 @@ class ArchivesController < ApplicationController
|
||||||
if custom_data_field && custom_data_field["expanded"] == "yes"
|
if custom_data_field && custom_data_field["expanded"] == "yes"
|
||||||
in_class = "in"
|
in_class = "in"
|
||||||
end
|
end
|
||||||
|
locale = I18n.locale.to_s
|
||||||
cats_last = []
|
cats_last = []
|
||||||
sort_order = (ArchiveSortOrder.first['sort_order'] rescue false) ? 1 : -1 #Order with ascending
|
|
||||||
if !params['title'].nil?
|
if !params['title'].nil?
|
||||||
files_by_category = ArchiveFile.where(is_hidden: false).order_by(:created_at => "desc").group_by(&:category)
|
files_by_category = ArchiveFile.can_display.sorted.group_by(&:category)
|
||||||
categories = files_by_category.keys
|
categories = files_by_category.keys
|
||||||
categories_sort = get_sorted_cat_with_filter(categories,'orm')
|
categories_sort = get_sorted_cat_with_filter(categories,'orm')
|
||||||
categories_sort.each do |category|
|
categories_sort.each_with_index do |category, cat_idx|
|
||||||
url_to_edit = ""
|
url_to_edit = ""
|
||||||
flag = false
|
flag = false
|
||||||
archives = []
|
archives = []
|
||||||
|
@ -38,53 +48,13 @@ class ArchivesController < ApplicationController
|
||||||
files_by_category[category].each_with_index do |archive,idx|
|
files_by_category[category].each_with_index do |archive,idx|
|
||||||
if archive.title == params['title']
|
if archive.title == params['title']
|
||||||
flag = true
|
flag = true
|
||||||
statuses = archive.statuses_with_classname.collect do |status|
|
data, serial_number, idx = archive.get_frontend_data(locale, serial_number, idx)
|
||||||
{
|
data
|
||||||
"status" => status["name"] || "",
|
|
||||||
"status-class" => "status-#{status['classname']}"
|
|
||||||
}
|
|
||||||
end
|
|
||||||
files = []
|
|
||||||
archive.archive_file_multiples.order_by(:sort_number=>'desc').each do |file|
|
|
||||||
if file.choose_lang.include?(I18n.locale.to_s)
|
|
||||||
title = (file.file_title.blank? ? File.basename(file.file.path) : file.file_title) rescue ""
|
|
||||||
extension = file.file.file.extension.downcase rescue ""
|
|
||||||
serial_number += 1
|
|
||||||
files << {
|
|
||||||
"file-name" => title,
|
|
||||||
"file-type" => extension,
|
|
||||||
"file-url" => "/xhr/archive/download?file=#{file.id}",
|
|
||||||
"serial_number" => serial_number
|
|
||||||
}
|
|
||||||
end
|
|
||||||
end
|
|
||||||
if archive.urls.present?
|
|
||||||
archive.urls.each_with_index do |url,i|
|
|
||||||
serial_number += 1
|
|
||||||
files << {
|
|
||||||
"file-name" => archive.title,
|
|
||||||
"file-type" => archive.get_url_text(i),
|
|
||||||
"file-url" => url,
|
|
||||||
"serial_number" => serial_number
|
|
||||||
}
|
|
||||||
end
|
|
||||||
end
|
|
||||||
archives << {
|
|
||||||
"archive-title" => archive.title,
|
|
||||||
"description" => archive.description,
|
|
||||||
"created_at" => archive.created_at.strftime('%Y%m%d').to_i,
|
|
||||||
"archive-url" => archive.url,
|
|
||||||
"url" => archive.url,
|
|
||||||
"statuses" => statuses,
|
|
||||||
"sort_number" => archive.sort_number,
|
|
||||||
"is_top" => (archive.is_top ? 1 : 0),
|
|
||||||
"files" => files,
|
|
||||||
"idx" => (idx + 1)
|
|
||||||
}
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if flag
|
if flag
|
||||||
cats_last << {
|
cats_last << {
|
||||||
|
"category-id" => category.id,
|
||||||
"category-title" => category.title,
|
"category-title" => category.title,
|
||||||
"archives" => archives,
|
"archives" => archives,
|
||||||
"url_to_edit" => url_to_edit
|
"url_to_edit" => url_to_edit
|
||||||
|
@ -100,8 +70,8 @@ class ArchivesController < ApplicationController
|
||||||
page.save
|
page.save
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
categories = OrbitHelper.page_categories
|
categories = params["categories"].blank? ? OrbitHelper.page_categories : params["categories"]
|
||||||
tags = OrbitHelper.page_tags
|
tags = params["tags"].blank? ? OrbitHelper.page_tags : params["tags"]
|
||||||
module_app = ModuleApp.where(:key=>'archive').first
|
module_app = ModuleApp.where(:key=>'archive').first
|
||||||
if categories == ["all"]
|
if categories == ["all"]
|
||||||
categories = module_app.categories.pluck(:id).map(&:to_s)
|
categories = module_app.categories.pluck(:id).map(&:to_s)
|
||||||
|
@ -121,13 +91,13 @@ class ArchivesController < ApplicationController
|
||||||
page_no = params[:page_no].to_i
|
page_no = params[:page_no].to_i
|
||||||
end
|
end
|
||||||
if (tags.count > 1 && categories.count <= 1 rescue false)
|
if (tags.count > 1 && categories.count <= 1 rescue false)
|
||||||
archive_files = ArchiveFile.where(is_hidden: false,:title.nin=>["",nil]).filter_by_categories.order_by(:created_at => "desc")
|
archive_files = ArchiveFile.can_display.filter_by_categories(categories).sorted
|
||||||
group_archive_files = {}
|
group_archive_files = {}
|
||||||
cats = []
|
cats = []
|
||||||
each_data_count = []
|
each_data_count = []
|
||||||
archive_files_ids = archive_files.pluck(:id)
|
archive_files_ids = archive_files.pluck(:id)
|
||||||
archive_files_ids_count = archive_files_ids.count
|
archive_files_ids_count = archive_files_ids.count
|
||||||
tags.each do |tag_id|
|
tags.each_with_index do |tag_id, tag_idx|
|
||||||
tag_name = ""
|
tag_name = ""
|
||||||
if tag_id
|
if tag_id
|
||||||
tag = Tag.find(tag_id) rescue nil
|
tag = Tag.find(tag_id) rescue nil
|
||||||
|
@ -153,54 +123,14 @@ class ArchivesController < ApplicationController
|
||||||
end
|
end
|
||||||
serial_number = 0
|
serial_number = 0
|
||||||
if archives.count != 0
|
if archives.count != 0
|
||||||
archives = archives.sort_by{|k| [(k["is_top"] ? 0 : 1) ,(k["sort_number"].nil? ? Float::INFINITY : sort_order * k["sort_number"].to_i),-k["created_at"].to_i]}.map.with_index do |archive,idx|
|
archives = archives.map.with_index do |archive,idx|
|
||||||
statuses = archive.statuses_with_classname.collect do |status|
|
|
||||||
{
|
|
||||||
"status" => status["name"] || "",
|
|
||||||
"status-class" => "status-#{status['classname']}"
|
|
||||||
}
|
|
||||||
end
|
|
||||||
files = []
|
|
||||||
archive.archive_file_multiples.order_by(:sort_number=>'desc').each do |file|
|
|
||||||
if file.choose_lang.include?(I18n.locale.to_s)
|
|
||||||
title = (file.file_title.blank? ? File.basename(file.file.path) : file.file_title) rescue ""
|
|
||||||
extension = file.file.file.extension.downcase rescue ""
|
|
||||||
serial_number += 1
|
|
||||||
files << {
|
|
||||||
"file-name" => title,
|
|
||||||
"file-type" => extension,
|
|
||||||
"file-url" => "/xhr/archive/download?file=#{file.id}",
|
|
||||||
"serial_number" => serial_number
|
|
||||||
}
|
|
||||||
end
|
|
||||||
end
|
|
||||||
if archive.urls.present?
|
|
||||||
archive.urls.each_with_index do |url,i|
|
|
||||||
serial_number += 1
|
|
||||||
files << {
|
|
||||||
"file-name" => archive.title,
|
|
||||||
"file-type" => archive.get_url_text(i),
|
|
||||||
"file-url" => url,
|
|
||||||
"serial_number" => serial_number
|
|
||||||
}
|
|
||||||
end
|
|
||||||
end
|
|
||||||
{
|
|
||||||
"archive-title" => archive.title,
|
|
||||||
"description" => archive.description,
|
|
||||||
"created_at" => archive.created_at.strftime('%Y%m%d').to_i,
|
|
||||||
"archive-url" => archive.url,
|
|
||||||
"url" => archive.url,
|
|
||||||
"statuses" => statuses,
|
|
||||||
"sort_number" => archive.sort_number,
|
|
||||||
"is_top" => (archive.is_top ? 1 : 0),
|
|
||||||
"files" => files,
|
|
||||||
"idx" => (idx + 1)
|
|
||||||
}
|
|
||||||
end
|
end
|
||||||
each_data_count.push(archives.length)
|
each_data_count.push(archives.length)
|
||||||
sorted = archives
|
sorted = archives
|
||||||
cats << {
|
cats << {
|
||||||
|
"category-id" => tag_id,
|
||||||
"category-title" => tag_name,
|
"category-title" => tag_name,
|
||||||
"archives" => sorted,
|
"archives" => sorted,
|
||||||
"url_to_edit" => url_to_edit
|
"url_to_edit" => url_to_edit
|
||||||
|
@ -209,61 +139,21 @@ class ArchivesController < ApplicationController
|
||||||
end
|
end
|
||||||
cats_last = cats
|
cats_last = cats
|
||||||
else
|
else
|
||||||
files_by_category = ArchiveFile.where(is_hidden: false,:title.nin=>["",nil]).filter_by_categories.filter_by_tags.order_by(:created_at => "desc").group_by(&:category)
|
files_by_category = ArchiveFile.can_display.filter_by_categories(categories).filter_by_tags(tags).sorted.group_by(&:category)
|
||||||
each_data_count = []
|
each_data_count = []
|
||||||
categories = files_by_category.keys
|
categories = files_by_category.keys
|
||||||
categories_sort = get_sorted_cat_with_filter(categories,'orm')
|
categories_sort = get_sorted_cat_with_filter(categories,'orm')
|
||||||
cats = categories_sort.collect do |category|
|
cats = categories_sort.collect.with_index do |category, cat_idx|
|
||||||
url_to_edit = OrbitHelper.user_has_cateogry?(category) ? "/admin/archive_files?filters[category][]=#{category.id.to_s}" : ""
|
url_to_edit = OrbitHelper.user_has_cateogry?(category) ? "/admin/archive_files?filters[category][]=#{category.id.to_s}" : ""
|
||||||
serial_number = 0
|
serial_number = 0
|
||||||
archives = files_by_category[category].sort_by{|k| [(k["is_top"] ? 0 : 1) ,(k["sort_number"].nil? ? Float::INFINITY : sort_order * k["sort_number"].to_i),-k["created_at"].to_i]}.collect.with_index do |archive,idx|
|
archives = files_by_category[category].collect.with_index do |archive,idx|
|
||||||
statuses = archive.statuses_with_classname.collect do |status|
|
data, serial_number, idx = archive.get_frontend_data(locale, serial_number, idx)
|
||||||
{
|
data
|
||||||
"status" => status["name"] || "",
|
|
||||||
"status-class" => "status-#{status['classname']}"
|
|
||||||
}
|
|
||||||
end
|
|
||||||
files = []
|
|
||||||
archive.archive_file_multiples.order_by(:sort_number=>'desc').each do |file|
|
|
||||||
if file.choose_lang.include?(I18n.locale.to_s)
|
|
||||||
serial_number += 1
|
|
||||||
title = (file.file_title.blank? ? File.basename(file.file.path) : file.file_title) rescue ""
|
|
||||||
extension = file.file.file.extension.downcase rescue ""
|
|
||||||
files << {
|
|
||||||
"file-name" => title,
|
|
||||||
"file-type" => extension,
|
|
||||||
"file-url" => "/xhr/archive/download?file=#{file.id}",
|
|
||||||
"serial_number" => serial_number
|
|
||||||
}
|
|
||||||
end
|
|
||||||
end
|
|
||||||
if archive.urls.present?
|
|
||||||
archive.urls.each_with_index do |url,i|
|
|
||||||
serial_number += 1
|
|
||||||
files << {
|
|
||||||
"file-name" => archive.title,
|
|
||||||
"file-type" => archive.get_url_text(i),
|
|
||||||
"file-url" => url,
|
|
||||||
"serial_number" => serial_number
|
|
||||||
}
|
|
||||||
end
|
|
||||||
end
|
|
||||||
{
|
|
||||||
"archive-title" => archive.title,
|
|
||||||
"description" => archive.description,
|
|
||||||
"created_at" => archive.created_at.strftime('%Y%m%d').to_i,
|
|
||||||
"archive-url" => archive.url,
|
|
||||||
"url" => archive.url,
|
|
||||||
"statuses" => statuses,
|
|
||||||
"sort_number" => archive.sort_number,
|
|
||||||
"is_top" => (archive.is_top ? 1 : 0),
|
|
||||||
"files" => files,
|
|
||||||
"idx" => (idx + 1)
|
|
||||||
}
|
|
||||||
end
|
end
|
||||||
each_data_count.push(archives.length)
|
each_data_count.push(archives.length)
|
||||||
sorted = archives
|
sorted = archives
|
||||||
{
|
{
|
||||||
|
"category-id" => category.id,
|
||||||
"category-title" => (categories.count > 1 ? category.title : ""),
|
"category-title" => (categories.count > 1 ? category.title : ""),
|
||||||
"archives" => sorted,
|
"archives" => sorted,
|
||||||
"url_to_edit" => url_to_edit
|
"url_to_edit" => url_to_edit
|
||||||
|
@ -319,6 +209,11 @@ class ArchivesController < ApplicationController
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
if cats_last.count != 0
|
||||||
|
cats_last.each_with_index do |h, i|
|
||||||
|
h["active_class"] = (i == 0 ? 'active' : '')
|
||||||
|
end
|
||||||
|
end
|
||||||
{
|
{
|
||||||
"categories" => cats_last,
|
"categories" => cats_last,
|
||||||
"extras" =>{
|
"extras" =>{
|
||||||
|
@ -375,7 +270,7 @@ class ArchivesController < ApplicationController
|
||||||
files_by_category_tag.keys.each do |t|
|
files_by_category_tag.keys.each do |t|
|
||||||
archives = []
|
archives = []
|
||||||
archive_counts = archive_counts + 1
|
archive_counts = archive_counts + 1
|
||||||
files_by_category_tag[t].each_with_index do |archive,index|
|
files_by_category_tag[t].each do |archive|
|
||||||
a = {
|
a = {
|
||||||
"archive-title" => archive.title,
|
"archive-title" => archive.title,
|
||||||
"description" => archive.description,
|
"description" => archive.description,
|
||||||
|
@ -385,10 +280,10 @@ class ArchivesController < ApplicationController
|
||||||
|
|
||||||
if t.count > 1
|
if t.count > 1
|
||||||
t.each do |inner_tag|
|
t.each do |inner_tag|
|
||||||
index = ts.index{|tot| tot["tag-name"] == inner_tag.name}
|
idx = ts.index{|tot| tot["tag-name"] == inner_tag.name}
|
||||||
if !index.nil?
|
if !idx.nil?
|
||||||
break if ts[index]["archives"].count >= OrbitHelper.widget_data_count
|
break if ts[idx]["archives"].count >= OrbitHelper.widget_data_count
|
||||||
ts[index]["archives"] << a
|
ts[idx]["archives"] << a
|
||||||
else
|
else
|
||||||
break if archives.count >= OrbitHelper.widget_data_count
|
break if archives.count >= OrbitHelper.widget_data_count
|
||||||
archives << a
|
archives << a
|
||||||
|
@ -406,82 +301,88 @@ class ArchivesController < ApplicationController
|
||||||
} if !archives.blank? && archive_counts < OrbitHelper.widget_data_count
|
} if !archives.blank? && archive_counts < OrbitHelper.widget_data_count
|
||||||
end
|
end
|
||||||
{
|
{
|
||||||
|
"category-id" => cat.id,
|
||||||
"category-title" => cat.title,
|
"category-title" => cat.title,
|
||||||
"tags" => ts
|
"tags" => ts
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
{
|
{
|
||||||
"categories" => cats,
|
"categories" => cats,
|
||||||
"extras" => {"widget-title" => "Archives","more_url" => OrbitHelper.widget_more_url}
|
"extras" => {"more_url" => OrbitHelper.widget_more_url}
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
def get_archives_count(cats_with_archives)
|
||||||
def widget
|
cats_with_archives.map{|h| (h["archives"].count rescue 0)}.sum
|
||||||
|
end
|
||||||
|
def get_anncs_for_pack_data(categories,tags)
|
||||||
page_data_count = OrbitHelper.widget_data_count
|
page_data_count = OrbitHelper.widget_data_count
|
||||||
categories = OrbitHelper.widget_categories #data are categories' ids or 'all'
|
sort_order = (ArchiveSortOrder.first['sort_order'] rescue false) ? 1 : -1 #Order with ascending
|
||||||
|
subpart = OrbitHelper.get_current_widget
|
||||||
|
filter_cache_parent_id = subpart.id.to_s + categories.to_s + tags.to_s + page_data_count.to_s
|
||||||
|
archive_cache = ArchiveCache.where(parent_id: filter_cache_parent_id,locale: I18n.locale.to_s)
|
||||||
|
count = archive_cache.count
|
||||||
|
if count > 1
|
||||||
|
archive_cache.limit(count-1).destroy
|
||||||
|
end
|
||||||
|
if archive_cache.count == 0
|
||||||
@categories = []
|
@categories = []
|
||||||
|
categorie_ids = []
|
||||||
if categories.first == "all"
|
if categories.first == "all"
|
||||||
categories = OrbitHelper.widget_module_app.categories
|
categories = OrbitHelper.widget_module_app.categories
|
||||||
categories_sort = get_sorted_cat_with_filter(categories,'orm')
|
categories_sort = get_sorted_cat_with_filter(categories,'orm')
|
||||||
@categories = categories_sort.collect do |cat|
|
@categories = categories_sort.collect do |cat|
|
||||||
|
cat_id = cat.id.to_s
|
||||||
|
categorie_ids << cat_id
|
||||||
{
|
{
|
||||||
"title" => cat.title,
|
"title" => cat.title,
|
||||||
"id" => cat.id.to_s
|
"id" => cat_id
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
categories_sort = get_sorted_cat_with_filter(categories,'id')
|
categories_sort = get_sorted_cat_with_filter(categories,'id')
|
||||||
@categories = categories_sort.collect do |cat|
|
@categories = categories_sort.collect do |cat|
|
||||||
|
cat_id = cat.id.to_s
|
||||||
|
categorie_ids << cat_id
|
||||||
{
|
{
|
||||||
"title" => cat.title,
|
"title" => cat.title,
|
||||||
"id" => cat.id.to_s
|
"id" => cat_id
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
cats = @categories.collect do |cat|
|
cats_with_archives = @categories.collect do |cat|
|
||||||
if ArchiveSortOrder.first.sort_order #Order with ascending
|
archives_sorted = ArchiveFile.can_display.where(:category_id => cat["id"]).filter_by_tags(tags).sorted
|
||||||
archives_all = ArchiveFile.can_display.where(:category_id => cat["id"]).filter_by_tags(OrbitHelper.widget_tags)
|
archives = archives_sorted.collect do |archive|
|
||||||
temp_with_nil = archives_all.in(sort_number: nil).order_by(created_at: 'desc')
|
archive_url = archive.get_archive_url(locale, OrbitHelper.widget_more_url)
|
||||||
temp_no_nil = archives_all.not_in(sort_number: nil).order_by(sort_number: 'asc',created_at: 'desc')
|
|
||||||
archives_temp = temp_no_nil.concat(temp_with_nil)
|
|
||||||
archives = archives_temp.collect do |archive|
|
|
||||||
if archive.archive_file_multiples.count==0
|
|
||||||
url = (archive[:url][OrbitHelper.get_site_locale].to_s.empty? ? 'javascript:void' : archive[:url][OrbitHelper.get_site_locale])
|
|
||||||
else
|
|
||||||
url = archive.archive_file_multiples.count > 1 ? (OrbitHelper.widget_more_url + '?title=' + archive.title.to_s) : "/xhr/archive/download?file=#{archive.archive_file_multiples.first.id}"
|
|
||||||
end
|
|
||||||
{
|
{
|
||||||
"archive-title" => archive.title,
|
"archive-title" => archive.title,
|
||||||
"description" => archive.description,
|
"description" => archive.description,
|
||||||
"archive-url" => archive.url,
|
"archive-url" => archive.url,
|
||||||
"archive_url" => url
|
"archive_url" => archive_url
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
else
|
|
||||||
archives_temp = ArchiveFile.can_display.where(:category_id => cat["id"]).filter_by_tags(OrbitHelper.widget_tags).order_by(sort_number: 'desc',created_at: 'desc')
|
|
||||||
archives = archives_temp.collect do |archive|
|
|
||||||
if archive.archive_file_multiples.count==0
|
|
||||||
url = (archive[:url][OrbitHelper.get_site_locale].to_s.empty? ? 'javascript:void' : archive[:url][OrbitHelper.get_site_locale])
|
|
||||||
else
|
|
||||||
url = archive.archive_file_multiples.count > 1 ? (OrbitHelper.widget_more_url + '?title=' + archive.title.to_s) : "/xhr/archive/download?file=#{archive.archive_file_multiples.first.id}"
|
|
||||||
end
|
|
||||||
{
|
|
||||||
"archive-title" => archive.title,
|
|
||||||
"description" => archive.description,
|
|
||||||
"archive-url" => archive.url,
|
|
||||||
"archive_url" => url
|
|
||||||
}
|
|
||||||
end
|
|
||||||
end
|
|
||||||
{
|
{
|
||||||
"category-title" => cat["title"],
|
"category-title" => cat["title"],
|
||||||
"category-id" => cat["id"],
|
"category-id" => cat["id"],
|
||||||
"archives" => archives
|
"archives" => archives
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
cats_with_archives = cats_with_archives.select{|h| h["archives"].count != 0}
|
||||||
|
ArchiveCache.create(parent_id: filter_cache_parent_id,locale: I18n.locale.to_s,filter_result: cats_with_archives)
|
||||||
|
else
|
||||||
|
c = archive_cache.first
|
||||||
|
cats_with_archives = c.filter_result
|
||||||
|
end
|
||||||
|
cats_with_archives
|
||||||
|
end
|
||||||
|
def widget
|
||||||
|
ArchiveFile.check_sort_number
|
||||||
|
page_data_count = OrbitHelper.widget_data_count
|
||||||
|
categories = OrbitHelper.widget_categories #data are categories' ids or 'all'
|
||||||
|
tags = OrbitHelper.widget_tags
|
||||||
|
cats_with_archives = get_anncs_for_pack_data(categories, tags)
|
||||||
{
|
{
|
||||||
"categories" => cats,
|
"categories" => cats_with_archives,
|
||||||
"extras" => {"widget-title" => "Archives","more_url" => (OrbitHelper.widget_more_url + '?data_count=' + page_data_count.to_s)}
|
"extras" => {"more_url" => (OrbitHelper.widget_more_url + '?data_count=' + page_data_count.to_s)}
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
private
|
private
|
||||||
|
|
|
@ -1,2 +1,25 @@
|
||||||
module Admin::ArchiveFilesHelper
|
module Admin::ArchiveFilesHelper
|
||||||
|
def page_for_archive_file(archive_file)
|
||||||
|
archive_file_page = nil
|
||||||
|
pages = Page.where(:module=>'archive').select{|page| page.enabled_for.include?(I18n.locale.to_s)}
|
||||||
|
|
||||||
|
pages.each do |page|
|
||||||
|
if page.categories.count ==1
|
||||||
|
if (page.categories.include?(archive_file.category.id.to_s) rescue false)
|
||||||
|
archive_file_page = page
|
||||||
|
end
|
||||||
|
end
|
||||||
|
break if !archive_file_page.nil?
|
||||||
|
end
|
||||||
|
if archive_file_page.nil?
|
||||||
|
pages.each do |page|
|
||||||
|
if (page.categories.include?(archive_file.category.id.to_s) rescue false)
|
||||||
|
archive_file_page = page
|
||||||
|
end
|
||||||
|
break if !archive_file_page.nil?
|
||||||
|
end
|
||||||
|
end
|
||||||
|
archive_file_page = pages.first if archive_file_page.nil?
|
||||||
|
request.protocol+(request.host_with_port+archive_file_page.url+'/'+archive_file.to_param).gsub('//','/') rescue "#"
|
||||||
|
end
|
||||||
end
|
end
|
|
@ -0,0 +1,6 @@
|
||||||
|
class ArchiveCache
|
||||||
|
include Mongoid::Document
|
||||||
|
field :parent_id
|
||||||
|
field :filter_result
|
||||||
|
field :locale,type: String,default: 'zh_tw'
|
||||||
|
end
|
|
@ -7,8 +7,42 @@ class ArchiveFile
|
||||||
include OrbitModel::Status
|
include OrbitModel::Status
|
||||||
include OrbitTag::Taggable
|
include OrbitTag::Taggable
|
||||||
include Slug
|
include Slug
|
||||||
|
require 'archive_model/cache'
|
||||||
|
unless defined?(ArchiveModel)
|
||||||
|
Object.send(:remove_const, 'ArchiveModel') rescue nil
|
||||||
|
$LOADED_FEATURES.select!{|p| !p.include? 'archive_model'}
|
||||||
|
require 'archive_model/cache'
|
||||||
|
end
|
||||||
|
include ::ArchiveModel::Cache
|
||||||
|
SubPart.class_eval { include ::ArchiveModel::Cache }
|
||||||
|
Page.class_eval { include ::ArchiveModel::Cache }
|
||||||
|
index({tmp_sort_number: 1})
|
||||||
|
scope :sorted, ->{order(tmp_sort_number: :asc)}
|
||||||
|
attr_accessor :org_tag_ids,:org_category_id
|
||||||
|
def tags=(ids)
|
||||||
|
self.org_tag_ids = self.tag_ids
|
||||||
|
super(ids)
|
||||||
|
end
|
||||||
|
def category=(cat)
|
||||||
|
self.org_category_id = self.category_id
|
||||||
|
super(cat)
|
||||||
|
end
|
||||||
|
def tag_ids=(ids)
|
||||||
|
self.org_tag_ids = self.tag_ids
|
||||||
|
super(ids)
|
||||||
|
end
|
||||||
|
def category_id=(cat_id)
|
||||||
|
self.org_category_id = self.category_id
|
||||||
|
super(cat_id)
|
||||||
|
end
|
||||||
|
def []=(index,value)
|
||||||
|
if index.to_s=='tags' || index.to_s=='tag_ids'
|
||||||
|
self.org_tag_ids = self.tag_ids
|
||||||
|
elsif index.to_s=='category' || index.to_s=='category_id'
|
||||||
|
self.org_category_id = self.category_id
|
||||||
|
end
|
||||||
|
super(index,value)
|
||||||
|
end
|
||||||
# include Tire::Model::Search
|
# include Tire::Model::Search
|
||||||
# include Tire::Model::Callbacks
|
# include Tire::Model::Callbacks
|
||||||
|
|
||||||
|
@ -16,12 +50,29 @@ class ArchiveFile
|
||||||
|
|
||||||
# PAYMENT_TYPES = @site_valid_locales
|
# PAYMENT_TYPES = @site_valid_locales
|
||||||
before_save do
|
before_save do
|
||||||
|
unless @skip_callback
|
||||||
cat = self.category rescue nil
|
cat = self.category rescue nil
|
||||||
if cat && ArchiveCategory.where(:category_id => cat.id).count==0
|
if cat && ArchiveCategory.where(:category_id => cat.id).count==0
|
||||||
ArchiveCategory.create(category_id: cat.id.to_s,sort_number: cat.sort_number)
|
ArchiveCategory.create(category_id: cat.id.to_s,sort_number: cat.sort_number)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
after_save do
|
||||||
|
unless @skip_callback
|
||||||
|
if self.sort_number_changed?
|
||||||
|
self.class.recalc_sort_number
|
||||||
|
elsif self.tmp_sort_number.nil?
|
||||||
|
if self.is_top
|
||||||
|
self.tmp_sort_number = (ArchiveSortOrder.first.max_sort_number.to_i + 1 rescue 1)
|
||||||
|
@skip_callback = true
|
||||||
|
self.save
|
||||||
|
@skip_callback = false
|
||||||
|
else
|
||||||
|
self.class.recalc_sort_number
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
field :title, as: :slug_title, localize: true
|
field :title, as: :slug_title, localize: true
|
||||||
field :description, localize: true
|
field :description, localize: true
|
||||||
field :urls, localize: true, type: Array
|
field :urls, localize: true, type: Array
|
||||||
|
@ -33,11 +84,15 @@ class ArchiveFile
|
||||||
field :deadline , :type => DateTime
|
field :deadline , :type => DateTime
|
||||||
field :uid, type: String
|
field :uid, type: String
|
||||||
field :sort_number, type: Integer
|
field :sort_number, type: Integer
|
||||||
|
field :tmp_sort_number, type: Integer
|
||||||
field :rss2_sn
|
field :rss2_sn
|
||||||
|
field :feed_uid
|
||||||
|
field :site_feed_id
|
||||||
|
field :feed_data, :type => Hash, :default => {}
|
||||||
# scope :can_display,where(is_hidden: false)
|
# scope :can_display,where(is_hidden: false)
|
||||||
scope :can_display, ->{where(is_hidden: false).order_by([:is_top, :desc],[:sort_number, :asc])}
|
scope :local_data, ->{where(:site_feed_id=>nil)}
|
||||||
|
scope :can_display, ->{where(is_hidden: false,:title.nin=>["",nil])}
|
||||||
|
scope :can_display_and_sorted, ->{can_display.sorted}
|
||||||
# belongs_to :archive_file_category
|
# belongs_to :archive_file_category
|
||||||
|
|
||||||
has_many :archive_file_multiples, :autosave => true, :dependent => :destroy
|
has_many :archive_file_multiples, :autosave => true, :dependent => :destroy
|
||||||
|
@ -46,7 +101,7 @@ class ArchiveFile
|
||||||
|
|
||||||
# validates :title, :at_least_one => true
|
# validates :title, :at_least_one => true
|
||||||
|
|
||||||
after_save :save_archive_file_multiples
|
after_save :save_archive_file_multiples, :update_tmp_sort_number
|
||||||
|
|
||||||
before_save :add_http
|
before_save :add_http
|
||||||
|
|
||||||
|
@ -58,7 +113,32 @@ class ArchiveFile
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
def self.check_sort_number
|
||||||
|
archive_sort_order = ArchiveSortOrder.first
|
||||||
|
if archive_sort_order && archive_sort_order.need_update_sort
|
||||||
|
self.recalc_sort_number(archive_sort_order.sort_order)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
def self.recalc_sort_number(sort_order=nil)
|
||||||
|
if sort_order.nil?
|
||||||
|
sort_order = (ArchiveSortOrder.first['sort_order'] rescue false) ? 1 : -1
|
||||||
|
end
|
||||||
|
sorted_archives = self.all.to_a.sort_by{|k| [(k["is_top"] ? 0 : 1) ,(k["sort_number"].nil? ? Float::INFINITY : sort_order * k["sort_number"].to_i),-k["created_at"].to_i]}
|
||||||
|
sorted_archives.each_with_index do |a, i|
|
||||||
|
a.instance_variable_set(:@skip_callback, true)
|
||||||
|
self.where(:id=>a.id).update_all(:tmp_sort_number => i)
|
||||||
|
end
|
||||||
|
max_sort_number = (sorted_archives.count != 0) ? (sort_order == 1 ? sorted_archives.last.tmp_sort_number : sorted_archives.first.tmp_sort_number) : 0
|
||||||
|
ArchiveSortOrder.update_all(:max_sort_number=>max_sort_number,:need_update_sort=>false)
|
||||||
|
self.create_indexes
|
||||||
|
return max_sort_number
|
||||||
|
end
|
||||||
|
def update_tmp_sort_number
|
||||||
|
return if @skip_callback
|
||||||
|
if self.new_record? || self.sort_number_changed?
|
||||||
|
self.class.recalc_sort_number
|
||||||
|
end
|
||||||
|
end
|
||||||
def get_url_text(idx=0,org=false)
|
def get_url_text(idx=0,org=false)
|
||||||
url_text = self.url_texts[idx] rescue nil
|
url_text = self.url_texts[idx] rescue nil
|
||||||
if org
|
if org
|
||||||
|
@ -67,8 +147,293 @@ class ArchiveFile
|
||||||
url_text.present? ? url_text : "link"
|
url_text.present? ? url_text : "link"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
def get_data(more_url=nil, base_url=nil, cat_ids=nil, tag_ids=nil, locales=nil)
|
||||||
|
if locales.nil?
|
||||||
|
locales = Site.first.in_use_locales rescue I18n.available_locales
|
||||||
|
end
|
||||||
|
locale = I18n.locale if locale.nil?
|
||||||
|
base_url = Site.first.root_url if base_url.nil?
|
||||||
|
user = User.find(self.create_user_id) rescue nil
|
||||||
|
a = {}
|
||||||
|
if !user.nil?
|
||||||
|
author_translations = user.member_name_translations
|
||||||
|
locales.each do |locale|
|
||||||
|
if author_translations[locale].blank?
|
||||||
|
author_translations[locale] = user.user_name
|
||||||
|
end
|
||||||
|
end
|
||||||
|
else
|
||||||
|
author_translations = {}
|
||||||
|
end
|
||||||
|
a["author_translations"] = author_translations
|
||||||
|
if more_url.nil?
|
||||||
|
if cat_ids.nil?
|
||||||
|
cat_ids = [self.category_id]
|
||||||
|
end
|
||||||
|
if tag_ids.nil?
|
||||||
|
tag_ids = self.tag_ids
|
||||||
|
end
|
||||||
|
basic_query = {:module => 'archive',:enabled_for=>locale}
|
||||||
|
if !cat_ids.blank?
|
||||||
|
query = basic_query.merge({:categories.all => cat_ids})
|
||||||
|
else
|
||||||
|
query = basic_query.clone
|
||||||
|
end
|
||||||
|
if !tag_ids.blank?
|
||||||
|
query = query.merge({:tags.all => tag_ids})
|
||||||
|
end
|
||||||
|
page = Page.where(query).first || Page.where(basic_query).first
|
||||||
|
more_url = page ? page.get_url : nil
|
||||||
|
end
|
||||||
|
if more_url
|
||||||
|
a['show_url'] = "#{more_url}/#{self.to_param}"
|
||||||
|
end
|
||||||
|
a["id"] = self.uid
|
||||||
|
a["title_translations"] = self.title_translations
|
||||||
|
a["description_translations"] = {}
|
||||||
|
description_translations = self.description_translations
|
||||||
|
locales.each do |locale|
|
||||||
|
locale = locale.to_s
|
||||||
|
a["description_translations"][locale] = self.class.smart_convertor(description_translations[locale],base_url) if !description_translations[locale].blank?
|
||||||
|
end
|
||||||
|
a["created_at"] = self.created_at
|
||||||
|
a["url_translations"] = self.url_translations
|
||||||
|
a["tags"] = []
|
||||||
|
a["category"] = {}
|
||||||
|
a["files"] = []
|
||||||
|
a["params"] = self.to_param
|
||||||
|
self.tags.each do |tag|
|
||||||
|
if !tag_ids.include?(tag.id.to_s)
|
||||||
|
tag_ids << tag.id.to_s
|
||||||
|
end
|
||||||
|
a["tags"] << {"name_translations" => tag.name_translations}
|
||||||
|
end
|
||||||
|
cat = self.category
|
||||||
|
a["sort_number"] = nil
|
||||||
|
a["category"] = {"title_translations" => (cat.title_translations rescue {})}
|
||||||
|
self.archive_file_multiples.order_by(:sort_number=>'desc').each do |file|
|
||||||
|
if file.choose_lang.include?(I18n.locale.to_s)
|
||||||
|
title_translations = {}
|
||||||
|
locales.each do |locale|
|
||||||
|
title_translations[locale] = (file.file_title_translations[locale].blank? ? File.basename(file.file.path) : file.file_title_translations[locale]) rescue ""
|
||||||
|
end
|
||||||
|
extension = file.file.file.extension.downcase rescue ""
|
||||||
|
a["files"] << {
|
||||||
|
"file-name_translations" => title_translations,
|
||||||
|
"file-type" => extension,
|
||||||
|
"file-url" => "#{base_url}/xhr/archive/download?file=#{file.id}"
|
||||||
|
}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return a
|
||||||
|
end
|
||||||
|
def get_related_feeds
|
||||||
|
related_feeds = ArchiveFileFeed.where({:category_ids=>self.category_id.to_s, :tag_ids.in=>self.tag_ids.map(&:to_s)}).to_a
|
||||||
|
end
|
||||||
|
def update_feed_statuses(statuses) #ex: statuses = {:is_top=>1}
|
||||||
|
self.update(statuses)
|
||||||
|
end
|
||||||
|
def update_feed_data(data)
|
||||||
|
data = data.clone
|
||||||
|
feed_data_keys = ["author_translations", "tags", "category", "files", "params", "show_url"]
|
||||||
|
data["feed_data"] = {}
|
||||||
|
data["feed_uid"] = data["id"]
|
||||||
|
data.delete("id")
|
||||||
|
feed_data_keys.each do |k|
|
||||||
|
data["feed_data"][k] = data[k]
|
||||||
|
data.delete(k)
|
||||||
|
end
|
||||||
|
@skip_callback = true
|
||||||
|
# ArchiveSortOrder.update_all(:need_update_sort=>true)
|
||||||
|
self.update(data)
|
||||||
|
@skip_callback = nil
|
||||||
|
end
|
||||||
|
def self.feeds_finish_callback(action="update", args={})
|
||||||
|
if action != "destroy"
|
||||||
|
if action == "update_all"
|
||||||
|
data = args["data"]
|
||||||
|
if data
|
||||||
|
site_feed_id = args["feed_id"]
|
||||||
|
category_id = args["category_id"]
|
||||||
|
data.each do |a|
|
||||||
|
a["category_id"] = category_id if category_id
|
||||||
|
archive_file = self.where(:feed_uid=> a["id"], :site_feed_id=>site_feed_id).first
|
||||||
|
if archive_file.nil?
|
||||||
|
archive_file = self.new(:feed_uid=> a["id"], :site_feed_id=>site_feed_id)
|
||||||
|
archive_file.instance_variable_set(:@skip_callback, true)
|
||||||
|
archive_file.save
|
||||||
|
end
|
||||||
|
archive_file.update_feed_data(a)
|
||||||
|
end
|
||||||
|
self.where(:feed_uid.nin=>data.map{|a| a["id"]}, :site_feed_id=>site_feed_id).destroy
|
||||||
|
end
|
||||||
|
end
|
||||||
|
self.recalc_sort_number
|
||||||
|
end
|
||||||
|
ArchiveCache.destroy_all
|
||||||
|
end
|
||||||
|
def get_files(locale=nil, serial_number=0)
|
||||||
|
if locale.nil?
|
||||||
|
locale = I18n.locale.to_s
|
||||||
|
end
|
||||||
|
files = []
|
||||||
|
if self.feed_uid
|
||||||
|
files = self.feed_data["files"].map do |h|
|
||||||
|
serial_number += 1
|
||||||
|
h = h.clone
|
||||||
|
h["file-name"] = h["file-name_translations"][locale]
|
||||||
|
h.delete("file-name_translations")
|
||||||
|
h["serial_number"] = serial_number
|
||||||
|
h
|
||||||
|
end
|
||||||
|
else
|
||||||
|
self.archive_file_multiples.order_by(:sort_number=>'desc').each do |file|
|
||||||
|
if file.choose_lang.include?(locale)
|
||||||
|
title = (file.file_title.blank? ? File.basename(file.file.path) : file.file_title) rescue ""
|
||||||
|
extension = file.file.file.extension.downcase rescue ""
|
||||||
|
serial_number += 1
|
||||||
|
files << {
|
||||||
|
"file-name" => title,
|
||||||
|
"file-type" => extension,
|
||||||
|
"file-url" => "/xhr/archive/download?file=#{file.id}",
|
||||||
|
"serial_number" => serial_number
|
||||||
|
}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if self.urls.present?
|
||||||
|
self.urls.each_with_index do |url,i|
|
||||||
|
serial_number += 1
|
||||||
|
files << {
|
||||||
|
"file-name" => self.title,
|
||||||
|
"file-type" => self.get_url_text(i),
|
||||||
|
"file-url" => url,
|
||||||
|
"serial_number" => serial_number
|
||||||
|
}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
[files, serial_number]
|
||||||
|
end
|
||||||
|
def get_frontend_data(locale=nil, serial_number=0, idx=0, show_tags=false, more_url=nil)
|
||||||
|
created_at_int = self.created_at.strftime('%Y%m%d').to_i
|
||||||
|
statuses = self.statuses_with_classname.collect do |status|
|
||||||
|
{
|
||||||
|
"status" => status["name"] || "",
|
||||||
|
"status-class" => "status-#{status['classname']}"
|
||||||
|
}
|
||||||
|
end
|
||||||
|
files, serial_number = self.get_files(locale, serial_number)
|
||||||
|
data = {
|
||||||
|
"archive-file-url" => (files.count != 0 ? files[0]["file-url"] : "javascript:void"),
|
||||||
|
"archive-title" => self.title,
|
||||||
|
"description" => self.description,
|
||||||
|
"created_at" => created_at_int,
|
||||||
|
"archive-url" => self.url,
|
||||||
|
"url" => self.url,
|
||||||
|
"statuses" => statuses,
|
||||||
|
"sort_number" => self.sort_number,
|
||||||
|
"is_top" => (self.is_top ? 1 : 0),
|
||||||
|
"files" => files,
|
||||||
|
"idx" => (idx + 1)
|
||||||
|
}
|
||||||
|
if show_tags
|
||||||
|
data["tags"] = self.tags.map do |tag|
|
||||||
|
{"name"=>tag.name, "url"=>more_url.to_s + "?tags[]=#{tag.id}"}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if more_url
|
||||||
|
data["index_url"] = more_url
|
||||||
|
end
|
||||||
|
return [data, serial_number, idx]
|
||||||
|
end
|
||||||
|
def get_archive_url(locale, more_url)
|
||||||
|
archive_url = ""
|
||||||
|
if self.feed_uid
|
||||||
|
files = self.feed_data["files"]
|
||||||
|
if files.count == 0
|
||||||
|
tmp_urls = self.urls
|
||||||
|
archive_url = ((tmp_urls.nil? || tmp_urls.count == 0) ? 'javascript:void' : (tmp_urls.count > 1 ? (more_url + '?title=' + self.title.to_s) : tmp_urls[0]))
|
||||||
|
else
|
||||||
|
archive_url = files.count > 1 ? (more_url + '?title=' + self.title.to_s) : files[0]["file-url"]
|
||||||
|
end
|
||||||
|
else
|
||||||
|
if self.archive_file_multiples.count==0
|
||||||
|
tmp_urls = self.urls
|
||||||
|
archive_url = ((tmp_urls.nil? || tmp_urls.count == 0) ? 'javascript:void' : (tmp_urls.count > 1 ? (more_url + '?title=' + self.title.to_s) : tmp_urls[0]))
|
||||||
|
else
|
||||||
|
archive_url = self.archive_file_multiples.count > 1 ? (more_url + '?title=' + self.title.to_s) : "/xhr/archive/download?file=#{self.archive_file_multiples.first.id}"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
archive_url
|
||||||
|
end
|
||||||
|
def notify_feed(type="create")
|
||||||
|
related_feeds = self.get_related_feeds.select{|feed| feed.remote_urls.count != 0}
|
||||||
|
if related_feeds.count != 0
|
||||||
|
archive_data = self.get_data
|
||||||
|
if type == "destroy"
|
||||||
|
tmp_data = {'type'=>'destroy', 'data'=>[self.uid]}
|
||||||
|
else
|
||||||
|
tmp_data = {'type'=>type, 'data'=>[archive_data.to_json]}
|
||||||
|
end
|
||||||
|
request = Net::HTTP::Post.new('/xhr/feeds/notify_change', 'Content-Type' => 'application/json')
|
||||||
|
related_feeds.each do |feed|
|
||||||
|
tmp_data['uid'] = feed.uid
|
||||||
|
request.body = tmp_data.to_json
|
||||||
|
feed.remote_urls.each do |remote_url|
|
||||||
|
uri = URI(remote_url)
|
||||||
|
http_req = Net::HTTP.new(uri.host, uri.port)
|
||||||
|
if remote_url.include?('https')
|
||||||
|
http_req.use_ssl = true
|
||||||
|
end
|
||||||
|
response = self.class.http_request( http_req , request )
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
def self.notify_feed_delete(ids)
|
||||||
|
all_feeds = ArchiveFileFeed.all.select{|feed| feed.remote_urls.count != 0}
|
||||||
|
if all_feeds.count != 0
|
||||||
|
tmp_data = {'type'=>'destroy'}
|
||||||
|
request = Net::HTTP::Post.new('/xhr/feeds/notify_change', 'Content-Type' => 'application/json')
|
||||||
|
all_feeds.each do |feed|
|
||||||
|
feed_uid = feed.uid
|
||||||
|
feed_cache = ArchiveFileFeedCache.where(:uid=>feed_uid).first
|
||||||
|
if feed_cache
|
||||||
|
tmp_data['uid'] = feed_uid
|
||||||
|
tmp_data['data'] = ids & JSON.parse(feed_cache.content)["archives"].map{|a| a["id"]}
|
||||||
|
request.body = tmp_data.to_json
|
||||||
|
if tmp_data['data'].count != 0
|
||||||
|
feed.remote_urls.each do |remote_url|
|
||||||
|
uri = URI(remote_url)
|
||||||
|
http_req = Net::HTTP.new(uri.host, uri.port)
|
||||||
|
if remote_url.include?('https')
|
||||||
|
http_req.use_ssl = true
|
||||||
|
end
|
||||||
|
response = self.http_request( http_req , request )
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
def self.http_request(http, request)
|
||||||
|
response = http.request(request)
|
||||||
|
if response.code.to_i == 301 || response.code.to_i == 302
|
||||||
|
location = response["location"]
|
||||||
|
new_uri = URI(location)
|
||||||
|
http = Net::HTTP.new(new_uri.host, new_uri.port)
|
||||||
|
if location.include?('https')
|
||||||
|
http.use_ssl = true
|
||||||
|
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
||||||
|
end
|
||||||
|
request.instance_variable_set(:@path, new_uri.path)
|
||||||
|
response = self.http_request(http, request)
|
||||||
|
end
|
||||||
|
response
|
||||||
|
end
|
||||||
protected
|
protected
|
||||||
def add_http
|
def add_http
|
||||||
|
return if @skip_callback
|
||||||
in_use_locales = Site.first.in_use_locales
|
in_use_locales = Site.first.in_use_locales
|
||||||
temp_urls = {}
|
temp_urls = {}
|
||||||
in_use_locales.each do |locale|
|
in_use_locales.each do |locale|
|
||||||
|
@ -134,10 +499,34 @@ class ArchiveFile
|
||||||
end
|
end
|
||||||
|
|
||||||
def save_archive_file_multiples
|
def save_archive_file_multiples
|
||||||
|
return if @skip_callback
|
||||||
self.archive_file_multiples.each do |t|
|
self.archive_file_multiples.each do |t|
|
||||||
if t.should_destroy
|
if t.should_destroy
|
||||||
t.destroy
|
t.destroy
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
def self.smart_convertor(text,url)
|
||||||
|
doc = Nokogiri.HTML(text)
|
||||||
|
doc.search('a[href]').each do |link|
|
||||||
|
if link['href'].nil?
|
||||||
|
link.delete 'href'
|
||||||
|
elsif link['href'].start_with?('/')
|
||||||
|
link['href'] = url + link['href']
|
||||||
|
elsif link['href'].start_with?('../')
|
||||||
|
link['href'] = url + link['href'][3..-1]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
doc.search('img[src]').each do |link|
|
||||||
|
if link['src'].nil?
|
||||||
|
link.delete 'src'
|
||||||
|
elsif link['src'].start_with?('/')
|
||||||
|
link['src'] = url + link['src']
|
||||||
|
elsif link['src'].start_with?('../')
|
||||||
|
link['src'] = url + link['src'][3..-1]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return doc.css('body').inner_html
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -0,0 +1,107 @@
|
||||||
|
class ArchiveFileFeed
|
||||||
|
include Mongoid::Document
|
||||||
|
include Mongoid::Timestamps
|
||||||
|
include Slug
|
||||||
|
|
||||||
|
field :title, as: :slug_title, type: String, localize: true
|
||||||
|
field :tag_ids, type: Array, default: []
|
||||||
|
field :category_ids, type: Array, default: []
|
||||||
|
field :remote_urls, type: Array, default: []
|
||||||
|
before_save do
|
||||||
|
ArchiveFileFeedCache.where(uid: self.uid).each do |cache|
|
||||||
|
cache.regenerate
|
||||||
|
end
|
||||||
|
end
|
||||||
|
def self.create_feed_cache(archive_file=nil,archive_file_feed=nil)
|
||||||
|
Thread.new do
|
||||||
|
if !archive_file.nil?
|
||||||
|
ArchiveFileFeed.where(:tag_ids.in => Array(archive_file.tag_ids).collect{|v| v.to_s}).each do |archive_file_feed|
|
||||||
|
uid = archive_file_feed.uid
|
||||||
|
ArchiveFileFeedCache.where(:uid => uid).each do |cache|
|
||||||
|
cache.regenerate
|
||||||
|
end
|
||||||
|
end
|
||||||
|
elsif !archive_file_feed.nil?
|
||||||
|
uid = archive_file_feed.uid
|
||||||
|
ArchiveFileFeedCache.where(:uid => uid).each do |cache|
|
||||||
|
cache.regenerate
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
def generate_one_cache_timeout(base_url: nil, timeout: nil)
|
||||||
|
begin
|
||||||
|
if timeout.nil?
|
||||||
|
feed_cache_content = self.generate_one_cache(base_url: base_url)
|
||||||
|
else
|
||||||
|
Timeout::timeout(timeout) do
|
||||||
|
feed_cache_content = nil
|
||||||
|
thread = Thread.new do
|
||||||
|
feed_cache_content = self.generate_one_cache(base_url: base_url)
|
||||||
|
end
|
||||||
|
(1..(timeout.to_i+1)).each do
|
||||||
|
sleep(1)
|
||||||
|
break if !feed_cache_content.nil? && !thread.alive?
|
||||||
|
end
|
||||||
|
feed_cache_content
|
||||||
|
end
|
||||||
|
end
|
||||||
|
rescue=> e
|
||||||
|
puts [e,e.backtrace]
|
||||||
|
nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
def generate_one_cache(base_url: nil)
|
||||||
|
base_url = Site.first.root_url if base_url.nil?
|
||||||
|
uid = self.uid
|
||||||
|
aff = self
|
||||||
|
if !aff.nil?
|
||||||
|
tags = aff.tag_ids
|
||||||
|
categories = aff.category_ids
|
||||||
|
if !(categories.empty? && tags.empty?)
|
||||||
|
archives_before_filter = ArchiveFile.can_display.local_data
|
||||||
|
if !tags.empty?
|
||||||
|
archives_before_filter = archives_before_filter.filter_by_tags(tags)
|
||||||
|
end
|
||||||
|
if !categories.empty?
|
||||||
|
archives_before_filter = archives_before_filter.filter_by_categories(categories,paginate=false)
|
||||||
|
end
|
||||||
|
archives_before_filter.selector = {"$and"=>[archives_before_filter.selector,{"$or"=>(I18n.available_locales.map{|v| {"title.#{v}"=>{"$nin"=>["", nil]}}})}]}
|
||||||
|
archives = archives_before_filter.sorted.to_a
|
||||||
|
else
|
||||||
|
archives = []
|
||||||
|
end
|
||||||
|
end
|
||||||
|
all_archives = []
|
||||||
|
tag_ids = []
|
||||||
|
category_ids = []
|
||||||
|
cat_ids = archives.collect{|a| a.category_id.blank? ? nil : a.category_id.to_s}.compact.uniq
|
||||||
|
tag_ids = archives.collect{|a| a.tag_ids.collect{|v| v.blank? ? nil : v.to_s}}.flatten.compact.uniq
|
||||||
|
tag_names = tag_ids.map{|tag_id| Tag.find(tag_id).name_translations rescue nil}.compact
|
||||||
|
category_titles = cat_ids.map{|cat_id| Category.find(cat_id).title_translations rescue nil}.compact
|
||||||
|
basic_query = {:module => 'archive',:enabled_for=>I18n.locale}
|
||||||
|
if !cat_ids.blank?
|
||||||
|
query = basic_query.merge({:categories.all => cat_ids})
|
||||||
|
else
|
||||||
|
query = basic_query.clone
|
||||||
|
end
|
||||||
|
if !tag_ids.blank?
|
||||||
|
query = query.merge({:tags.all => tag_ids})
|
||||||
|
end
|
||||||
|
page = Page.where(query).first || Page.where(basic_query).first
|
||||||
|
more_url = page ? page.get_url : nil
|
||||||
|
locales = Site.first.in_use_locales rescue I18n.available_locales
|
||||||
|
archives.each_with_index do |archive,i|
|
||||||
|
a = archive.get_data(more_url, base_url, cat_ids, tag_ids, locales)
|
||||||
|
all_archives << a
|
||||||
|
end
|
||||||
|
archives = {
|
||||||
|
"archives" => all_archives,
|
||||||
|
"tags" => tag_names,
|
||||||
|
"categories" => category_titles
|
||||||
|
}.to_json
|
||||||
|
ArchiveFileFeedCache.where(uid: uid).destroy
|
||||||
|
feed_cache = ArchiveFileFeedCache.create(uid: uid,content: archives)
|
||||||
|
archives
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,27 @@
|
||||||
|
class ArchiveFileFeedCache
|
||||||
|
include Mongoid::Document
|
||||||
|
include Mongoid::Timestamps
|
||||||
|
|
||||||
|
field :content, type: String, default: ''
|
||||||
|
field :uid
|
||||||
|
def self.regenerate_all
|
||||||
|
caches = self.all.to_a
|
||||||
|
time_now = Time.now
|
||||||
|
caches.each do |cache|
|
||||||
|
if cache.invalid_date && cache.invalid_date <= time_now
|
||||||
|
cache.destroy
|
||||||
|
else
|
||||||
|
cache.regenerate
|
||||||
|
end
|
||||||
|
end
|
||||||
|
uids = ArchiveFileFeed.all.pluck(:uid) - caches.collect(&:uid)
|
||||||
|
ArchiveFileFeed.where(:uid.in=> uids).each do |feed|
|
||||||
|
feed.generate_one_cache()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
def regenerate
|
||||||
|
uid = self.uid
|
||||||
|
ArchiveFileFeed.where(uid: uid).each{|v| v.generate_one_cache} rescue nil
|
||||||
|
self.destroy
|
||||||
|
end
|
||||||
|
end
|
|
@ -1,8 +1,10 @@
|
||||||
class ArchiveSortOrder
|
class ArchiveSortOrder
|
||||||
include Mongoid::Document
|
include Mongoid::Document
|
||||||
field :sort_order, :type => Boolean # true => desc , false => asc
|
field :sort_order, :type => Boolean # true => asc , false => desc
|
||||||
|
field :need_update_sort, :type => Boolean, :default => true
|
||||||
|
field :max_sort_number, :type => Integer, :default => 0
|
||||||
after_initialize do |record|
|
after_initialize do |record|
|
||||||
if(!record.new_record? && record.sort_order.class != FalseClass && record.sort_order.class != TrueClass)
|
if(!record.new_record? && record.sort_order.nil?)
|
||||||
record.sort_order = true
|
record.sort_order = true
|
||||||
record.save
|
record.save
|
||||||
elsif(!record.new_record?)
|
elsif(!record.new_record?)
|
||||||
|
@ -17,6 +19,8 @@ class ArchiveSortOrder
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
after_save do |record|
|
after_save do |record|
|
||||||
|
unless record.instance_variable_get(:@skip_callback)
|
||||||
|
if record.sort_order_changed?
|
||||||
@module_app = ModuleApp.where(:key=>'archive').first
|
@module_app = ModuleApp.where(:key=>'archive').first
|
||||||
if !@module_app.nil?
|
if !@module_app.nil?
|
||||||
@sort_order = record.sort_order rescue nil
|
@sort_order = record.sort_order rescue nil
|
||||||
|
@ -27,5 +31,19 @@ class ArchiveSortOrder
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
record.instance_variable_set(:@skip_callback, true)
|
||||||
|
record.update(:need_update_sort=>true)
|
||||||
|
if record.need_update_sort
|
||||||
|
Thread.new do
|
||||||
|
sort_order = record.sort_order ? 1 : -1
|
||||||
|
ArchiveFile.recalc_sort_number(sort_order)
|
||||||
|
record.instance_variable_set(:@skip_callback, false)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
def get_default_order
|
||||||
|
self.sort_order ? 0 : self.max_sort_number
|
||||||
end
|
end
|
||||||
end
|
end
|
|
@ -0,0 +1,61 @@
|
||||||
|
<%= form_for @archive_feed, url: admin_archive_file_updatefeed_path(:id => @archive_feed.id), html: {class: "form-horizontal main-forms"} do |f| %>
|
||||||
|
<fieldset>
|
||||||
|
<% @site_in_use_locales.each do |locale| %>
|
||||||
|
<%= f.fields_for :title_translations do |f| %>
|
||||||
|
<div class="control-group">
|
||||||
|
<label class="control-label muted" for="<%=f.object_name%>_title_translations_<%= locale.to_s %>"><%= t(:title) + " (#{t(locale.to_s)})" %></label>
|
||||||
|
<div class="controls">
|
||||||
|
<%= f.text_field locale, data: {"fv-validation" => "required;","fv-messages" => "Cannot be empty.;"}, value: (@archive_feed.title_translations[locale.to_s] rescue nil) %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
|
<% end %>
|
||||||
|
<hr />
|
||||||
|
<div class="tags">
|
||||||
|
<h4><%=t(:tags)%></h4>
|
||||||
|
<div id="tags-list">
|
||||||
|
<div class="tags-groups checkbox-card module-tags">
|
||||||
|
<% @module_app.tags.each do |tag| %>
|
||||||
|
<label class="filter-item module <%= @archive_feed.tag_ids.include?(tag.id.to_s) ? "active" : "" %>">
|
||||||
|
<p class='card pull-left <%= @archive_feed.tag_ids.include?(tag.id.to_s) ? "active" : "" %>'>
|
||||||
|
<input type="checkbox" <%= @archive_feed.tag_ids.include?(tag.id.to_s) ? "checked=checked" : "" %> class="tag-checkbox" value="<%= tag.id.to_s %>" name="<%=f.object_name%>[tag_ids][]">
|
||||||
|
</p>
|
||||||
|
<div>
|
||||||
|
<% @site_in_use_locales.each_with_index do |locale,index| %>
|
||||||
|
<span class="tag"><%= tag.name_translations[locale] %></span>
|
||||||
|
<% if index < (@site_in_use_locales.count - 1) %>
|
||||||
|
/
|
||||||
|
<% end %>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
||||||
|
</label>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="categories">
|
||||||
|
<h4><%=t(:category)%></h4>
|
||||||
|
<div id="categories-list">
|
||||||
|
<div class="tags-groups checkbox-card module-categories">
|
||||||
|
<% @module_app.categories.each do |category| %>
|
||||||
|
<label class="filter-item module <%= @archive_feed.category_ids.include?(category.id.to_s) ? "active" : "" %>">
|
||||||
|
<p class="card pull-left <%= @archive_feed.category_ids.include?(category.id.to_s) ? "active" : "" %>">
|
||||||
|
<input type="checkbox" class="tag-checkbox" <%= @archive_feed.category_ids.include?(category.id.to_s) ? "checked=checked" : "" %> value="<%= category.id.to_s %>" name="<%=f.object_name%>[category_ids][]">
|
||||||
|
</p>
|
||||||
|
<div>
|
||||||
|
<% @site_in_use_locales.each_with_index do |locale,index| %>
|
||||||
|
<span class="tag"><%= category.title_translations[locale] %></span>
|
||||||
|
<% if index < (@site_in_use_locales.count - 1) %>
|
||||||
|
/
|
||||||
|
<% end %>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
||||||
|
</label>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</fieldset>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,83 @@
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<%= feed.title %>
|
||||||
|
<div class="quick-edit">
|
||||||
|
<ul class="nav nav-pills">
|
||||||
|
<% if can_edit_or_delete?(feed) %>
|
||||||
|
<li><a href="#" class="edit-feed" data-feed-id="<%= feed.id.to_s %>"><%= t(:edit) %></a></li>
|
||||||
|
<li><a href="/admin/archive_file/deletefeed?id=<%= feed.id.to_s %>" class="delete-feed text-error" ><%= t(:delete_) %></a></li>
|
||||||
|
<% end %>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<div class="tags">
|
||||||
|
<div id="tags-list">
|
||||||
|
<ul class="tags-groups checkbox-card module-tags">
|
||||||
|
<% tags_to_remove = [] %>
|
||||||
|
<% feed.tag_ids.each do |t| %>
|
||||||
|
<% tag = Tag.find(t) rescue nil %>
|
||||||
|
<% if !tag.nil? %>
|
||||||
|
<li class="filter-item module">
|
||||||
|
<a href="#" onclick="return false;">
|
||||||
|
<% @site_in_use_locales.each_with_index do |locale,index| %>
|
||||||
|
<span class="tag"><%= tag.name_translations[locale] %></span>
|
||||||
|
<% if index < (@site_in_use_locales.count - 1) %>
|
||||||
|
/
|
||||||
|
<% end %>
|
||||||
|
<% end %>
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
<% else %>
|
||||||
|
<% tags_to_remove << t %>
|
||||||
|
<% end %>
|
||||||
|
<% end %>
|
||||||
|
<% if !tags_to_remove.blank?
|
||||||
|
tags_to_remove.each do |t|
|
||||||
|
feed.tag_ids.delete(t)
|
||||||
|
end
|
||||||
|
feed.save
|
||||||
|
end %>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<div class="categories">
|
||||||
|
<div id="categories-list">
|
||||||
|
<ul class="tags-groups checkbox-card module-categories">
|
||||||
|
<% categories_to_remove = [] %>
|
||||||
|
<% feed.category_ids.each do |c| %>
|
||||||
|
<% category = Category.find(c) rescue nil %>
|
||||||
|
<% if !category.nil? %>
|
||||||
|
<li class="filter-item module">
|
||||||
|
<a href="#" onclick="return false;">
|
||||||
|
<% @site_in_use_locales.each_with_index do |locale,index| %>
|
||||||
|
<span class="tag"><%= category.title_translations[locale] %></span>
|
||||||
|
<% if index < (@site_in_use_locales.count - 1) %>
|
||||||
|
/
|
||||||
|
<% end %>
|
||||||
|
<% end %>
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
<% else %>
|
||||||
|
<% categories_to_remove << c %>
|
||||||
|
<% end %>
|
||||||
|
<% end %>
|
||||||
|
<% if !categories_to_remove.blank?
|
||||||
|
categories_to_remove.each do |c|
|
||||||
|
feed.category_ids.delete(c)
|
||||||
|
end
|
||||||
|
feed.save
|
||||||
|
end %>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<a href="/xhr/archive_files/rssfeed/<%= feed.uid %>.rss" target="_blank">RSS Feed</a>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<a href="/xhr/archive_files/feed/<%= feed.uid %>.json" target="_blank">JSON Feed</a>
|
||||||
|
</td>
|
||||||
|
</tr>
|
|
@ -0,0 +1,61 @@
|
||||||
|
<%= form_for @archive_feed, url: admin_archive_file_createfeed_path, html: {class: "form-horizontal main-forms"} do |f| %>
|
||||||
|
<fieldset>
|
||||||
|
<% @site_in_use_locales.each do |locale| %>
|
||||||
|
<%= f.fields_for :title_translations do |f| %>
|
||||||
|
<div class="control-group">
|
||||||
|
<label class="control-label muted" for="<%=f.object_name%>_title_translations_<%= locale.to_s %>"><%= t(:title) + " (#{t(locale.to_s)})" %></label>
|
||||||
|
<div class="controls">
|
||||||
|
<%= f.text_field locale, data: {"fv-validation" => "required;","fv-messages" => "Cannot be empty.;"}, value: (@archive_feed.title_translations[locale.to_s] rescue nil) %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
|
<% end %>
|
||||||
|
<hr />
|
||||||
|
<div class="tags">
|
||||||
|
<h4><%=t(:tags)%></h4>
|
||||||
|
<div id="tags-list">
|
||||||
|
<div class="tags-groups checkbox-card module-tags">
|
||||||
|
<% @module_app.tags.each do |tag| %>
|
||||||
|
<label class="filter-item module">
|
||||||
|
<p class="card pull-left">
|
||||||
|
<input type="checkbox" class="tag-checkbox" value="<%= tag.id.to_s %>" name="<%=f.object_name%>[tag_ids][]">
|
||||||
|
</p>
|
||||||
|
<div>
|
||||||
|
<% @site_in_use_locales.each_with_index do |locale,index| %>
|
||||||
|
<span class="tag"><%= tag.name_translations[locale] %></span>
|
||||||
|
<% if index < (@site_in_use_locales.count - 1) %>
|
||||||
|
/
|
||||||
|
<% end %>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
||||||
|
</label>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="categories">
|
||||||
|
<h4><%=t(:category)%></h4>
|
||||||
|
<div id="categories-list">
|
||||||
|
<div class="tags-groups checkbox-card module-categories">
|
||||||
|
<% @module_app.categories.each do |category| %>
|
||||||
|
<label class="filter-item module">
|
||||||
|
<p class="card pull-left">
|
||||||
|
<input type="checkbox" class="tag-checkbox" value="<%= category.id.to_s %>" name="<%=f.object_name%>[category_ids][]">
|
||||||
|
</p>
|
||||||
|
<div>
|
||||||
|
<% @site_in_use_locales.each_with_index do |locale,index| %>
|
||||||
|
<span class="tag"><%= category.title_translations[locale] %></span>
|
||||||
|
<% if index < (@site_in_use_locales.count - 1) %>
|
||||||
|
/
|
||||||
|
<% end %>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
||||||
|
</label>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</fieldset>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
|
|
@ -86,7 +86,8 @@
|
||||||
<div class="control-group">
|
<div class="control-group">
|
||||||
<label class="control-label muted"><%= t(:sort_number) %></label>
|
<label class="control-label muted"><%= t(:sort_number) %></label>
|
||||||
<div class="controls">
|
<div class="controls">
|
||||||
<%= f.text_field :sort_number %>
|
<% extra_data = f.object.new_record? ? {placeholder: f.object.sort_number, title: f.object.sort_number, value: ''} : {} %>
|
||||||
|
<%= f.number_field :sort_number, extra_data %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,96 @@
|
||||||
<script>
|
<script>
|
||||||
if(document.querySelectorAll("#orbit-bar").length==0) location.reload();
|
if(document.querySelectorAll("#orbit-bar").length==0) location.reload();
|
||||||
|
if( Array.prototype.delete == undefined ){
|
||||||
|
Array.prototype.delete = function(v){
|
||||||
|
var idx = this.indexOf(v);
|
||||||
|
if(idx != -1){
|
||||||
|
return this.splice(idx, 1)[0];
|
||||||
|
}else{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function reload_tbody(url){
|
||||||
|
console.log("done");
|
||||||
|
if(url == undefined){
|
||||||
|
url = window.location.href;
|
||||||
|
}
|
||||||
|
$.get(url).done(function(data){
|
||||||
|
$('#index_table tbody').replaceWith($(data).find('tbody'));
|
||||||
|
if(window.scroll_top){
|
||||||
|
$(window).scrollTop(window.scroll_top);
|
||||||
|
}
|
||||||
|
window.archive_delete_ids = [];
|
||||||
|
$(".delete_archives_btn").addClass('hide');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
$(document).on("click", ".select_delete", function(){
|
||||||
|
var that = $(this);
|
||||||
|
var id = that.data("id");
|
||||||
|
if(window.archive_delete_ids == undefined){
|
||||||
|
window.archive_delete_ids = [];
|
||||||
|
}
|
||||||
|
if(that.prop("checked")){
|
||||||
|
window.archive_delete_ids.push(id);
|
||||||
|
}else{
|
||||||
|
window.archive_delete_ids.delete(id);
|
||||||
|
}
|
||||||
|
if(window.archive_delete_ids.length == 0){
|
||||||
|
$(".delete_archives_btn").addClass('hide');
|
||||||
|
}else{
|
||||||
|
$(".delete_archives_btn").removeClass('hide');
|
||||||
|
}
|
||||||
|
})
|
||||||
|
function delete_archives(){
|
||||||
|
if(!window.archive_delete_ids || window.archive_delete_ids.length == 0){
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
var data = new FormData();
|
||||||
|
var csrf_token = document
|
||||||
|
.querySelector("meta[name='csrf-token']")
|
||||||
|
.getAttribute("content");
|
||||||
|
var csrf_param = document
|
||||||
|
.querySelector("meta[name='csrf-param']")
|
||||||
|
.getAttribute("content");
|
||||||
|
if (csrf_token && csrf_param) {
|
||||||
|
data.append(csrf_param, csrf_token);
|
||||||
|
}
|
||||||
|
window.archive_delete_ids.forEach(function(val){
|
||||||
|
data.append('ids[]', val);
|
||||||
|
});
|
||||||
|
$.ajax({
|
||||||
|
url: "<%=admin_archive_files_delete_path%>",
|
||||||
|
method: 'DELETE',
|
||||||
|
data: data,
|
||||||
|
headers: {
|
||||||
|
// 'Content-Type': 'multipart/form-data',
|
||||||
|
// 使用 multipart/form-data 在此不需要設定 Content-Type。
|
||||||
|
'X-Requested-With': 'XMLHttpRequest',
|
||||||
|
'Authorization': `Bearer ${ csrf_token }`,
|
||||||
|
},
|
||||||
|
contentType: false, //required
|
||||||
|
processData: false, // required
|
||||||
|
statusCode: {
|
||||||
|
204: reload_tbody,
|
||||||
|
403: function() {
|
||||||
|
alert( "Delete failed!" );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
$(document).on("click", ".delete_archives_btn", function(){
|
||||||
|
if(window.confirm("<%=t(:sure?)%>")){
|
||||||
|
if(window.confirm("<%=t(:sure?)%>")){
|
||||||
|
delete_archives();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<table class="table main-list">
|
<table class="table main-list">
|
||||||
<thead>
|
<thead>
|
||||||
<tr class="sort-header">
|
<tr class="sort-header">
|
||||||
|
<th style="width: 1em;"></th>
|
||||||
<% @table_fields.each do |f| %>
|
<% @table_fields.each do |f| %>
|
||||||
<% if f == "archive.downloaded_times" %>
|
<% if f == "archive.downloaded_times" %>
|
||||||
<%= thead(f,true,false) %>
|
<%= thead(f,true,false) %>
|
||||||
|
@ -17,6 +103,8 @@
|
||||||
<tbody>
|
<tbody>
|
||||||
<% @archives.each do |archive| %>
|
<% @archives.each do |archive| %>
|
||||||
<tr>
|
<tr>
|
||||||
|
<% is_editable = can_edit_or_delete?(archive) %>
|
||||||
|
<td><% if is_editable %><input type="checkbox" class="select_delete" data-id="<%= archive.uid %>"><% end %></td>
|
||||||
<td><%= archive.status_for_table %></td>
|
<td><%= archive.status_for_table %></td>
|
||||||
<td>
|
<td>
|
||||||
<%= archive.category.title rescue "" %>
|
<%= archive.category.title rescue "" %>
|
||||||
|
@ -28,7 +116,7 @@
|
||||||
<a href="/admin/archive_files/show?title=<%= archive.title %>" target="_blank"><%= archive.title %></a>
|
<a href="/admin/archive_files/show?title=<%= archive.title %>" target="_blank"><%= archive.title %></a>
|
||||||
<div class="quick-edit">
|
<div class="quick-edit">
|
||||||
<ul class="nav nav-pills">
|
<ul class="nav nav-pills">
|
||||||
<% if can_edit_or_delete?(archive) %>
|
<% if is_editable %>
|
||||||
<li><a href="/<%= I18n.locale.to_s %>/admin/archive_files/<%= archive.id.to_s %>/edit"><%= t(:edit) %></a></li>
|
<li><a href="/<%= I18n.locale.to_s %>/admin/archive_files/<%= archive.id.to_s %>/edit"><%= t(:edit) %></a></li>
|
||||||
<li><a href="/admin/archive_files/<%= archive.id.to_s %>" class="delete text-error" data-method="delete" data-confirm="Are you sure?"><%= t(:delete_) %></a></li>
|
<li><a href="/admin/archive_files/<%= archive.id.to_s %>" class="delete text-error" data-method="delete" data-confirm="Are you sure?"><%= t(:delete_) %></a></li>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
@ -51,6 +139,7 @@
|
||||||
<%=
|
<%=
|
||||||
content_tag :div, class: "bottomnav clearfix" do
|
content_tag :div, class: "bottomnav clearfix" do
|
||||||
content_tag(:div, paginate(@archives), class: "pagination pagination-centered") +
|
content_tag(:div, paginate(@archives), class: "pagination pagination-centered") +
|
||||||
|
content_tag(:div, link_to(t("archive.delete_selected"), "javascript:void(0)", :class=>"btn btn-primary"), class: "pull-right hide delete_archives_btn") +
|
||||||
content_tag(:div, link_to(t(:new_),new_admin_archive_file_path, :class=>"btn btn-primary"), class: "pull-right")
|
content_tag(:div, link_to(t(:new_),new_admin_archive_file_path, :class=>"btn btn-primary"), class: "pull-right")
|
||||||
end
|
end
|
||||||
%>
|
%>
|
|
@ -0,0 +1,126 @@
|
||||||
|
<% content_for :page_specific_css do %>
|
||||||
|
<%= stylesheet_link_tag("admin/tags") %>
|
||||||
|
<% end %>
|
||||||
|
<% content_for :page_specific_javascript do %>
|
||||||
|
<%= javascript_include_tag "validator" %>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
<table class="table main-list">
|
||||||
|
<thead>
|
||||||
|
<tr class="sort-header">
|
||||||
|
<% @table_feed_fields.each do |f| %>
|
||||||
|
<%= thead(f) %>
|
||||||
|
<% end %>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<%= render :partial => "feed", :collection => @feeds %>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
<% if current_user.is_admin? or current_user.is_manager?(@module_app) %>
|
||||||
|
|
||||||
|
<div class="bottomnav clearfix" style="left: 81px;">
|
||||||
|
<div class="action pull-right">
|
||||||
|
<a class="btn btn-primary new-feed" href="#">
|
||||||
|
<i class="icon-plus"></i> <%= t(:new_) %>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
<div class="pagination pagination-centered"></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="newFeedModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="newFeedModalLabel" aria-hidden="true">
|
||||||
|
<div class="modal-header">
|
||||||
|
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||||||
|
<h3 id="newFeedModalLabel">Create New Feed</h3>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body">
|
||||||
|
<%#= render :partial => "feed_form" %>
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer">
|
||||||
|
<button class="btn btn-primary" id="save_new_feed">Save changes</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
<script type="text/javascript">
|
||||||
|
|
||||||
|
$(".new-feed").on("click",function(){
|
||||||
|
var modal = $("#newFeedModal");
|
||||||
|
modal.find("#newFeedModalLabel").text("Create New Feed");
|
||||||
|
modal.modal("show");
|
||||||
|
openFeedModal("new",null);
|
||||||
|
})
|
||||||
|
|
||||||
|
var bindEditButtons = function(){
|
||||||
|
$(".edit-feed").on("click",function(){
|
||||||
|
var modal = $("#newFeedModal");
|
||||||
|
modal.find("#newFeedModalLabel").text("Edit Feed");
|
||||||
|
modal.modal("show");
|
||||||
|
openFeedModal("edit",$(this).data("feed-id"));
|
||||||
|
return false;
|
||||||
|
})
|
||||||
|
$(".delete-feed").on("click",function(){
|
||||||
|
if(confirm("Are you sure?")){
|
||||||
|
var el = $(this);
|
||||||
|
$.ajax({
|
||||||
|
url : el.attr("href"),
|
||||||
|
type : "delete",
|
||||||
|
dataType : "html"
|
||||||
|
}).done(function(data){
|
||||||
|
$("table.main-list tbody").html(data);
|
||||||
|
bindEditButtons();
|
||||||
|
})
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
})
|
||||||
|
}
|
||||||
|
bindEditButtons();
|
||||||
|
var openFeedModal = function(type,feed_id){
|
||||||
|
$.ajax({
|
||||||
|
url : "/admin/archive_files/feedform",
|
||||||
|
type : "get",
|
||||||
|
data : {"type" : type, "id" : feed_id},
|
||||||
|
dataType : "html"
|
||||||
|
}).done(function(form){
|
||||||
|
$("#newFeedModal .modal-body").html(form);
|
||||||
|
bindHandlers();
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
var bindHandlers = function(){
|
||||||
|
$(".tag-checkbox").on("click",function(){
|
||||||
|
if($(this).is(":checked")){
|
||||||
|
$(this).parent().addClass("active");
|
||||||
|
$(this).parent().parent().addClass("active");
|
||||||
|
}else{
|
||||||
|
$(this).parent().removeClass("active");
|
||||||
|
$(this).parent().parent().removeClass("active");
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
var fv = new FormValidator($("#newFeedModal form"));
|
||||||
|
fv.form.on("submit",function(){
|
||||||
|
$.ajax({
|
||||||
|
url : fv.form.attr("action"),
|
||||||
|
data : fv.form.serializeArray(),
|
||||||
|
type : "post",
|
||||||
|
dataType : "html"
|
||||||
|
}).done(function(data){
|
||||||
|
$("table.main-list tbody").html(data);
|
||||||
|
bindEditButtons();
|
||||||
|
$("#newFeedModal").modal("hide");
|
||||||
|
fv.form.resetForm();
|
||||||
|
fv.form.find("ul.tags-groups p.active").removeClass("active");
|
||||||
|
})
|
||||||
|
return false;
|
||||||
|
})
|
||||||
|
$("#save_new_feed").on("click",function(){
|
||||||
|
if(fv.isFormValidated()){
|
||||||
|
fv.form.submit();
|
||||||
|
}else{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
</br>
|
|
@ -0,0 +1,16 @@
|
||||||
|
xml.instruct! :xml, :version => "1.0"
|
||||||
|
xml.rss :version => "2.0" do
|
||||||
|
xml.channel do
|
||||||
|
xml.title @aff.title
|
||||||
|
xml.link "/xhr/archive_files/rssfeed/#{@aff.uid}.rss"
|
||||||
|
|
||||||
|
for archive_file in @archive_files
|
||||||
|
xml.item do
|
||||||
|
xml.title archive_file.title
|
||||||
|
xml.description archive_file.description
|
||||||
|
xml.pubDate archive_file.created_at.to_s(:rfc822)
|
||||||
|
xml.link page_for_archive_file(archive_file)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,34 @@
|
||||||
|
<%
|
||||||
|
data = action_data["data"]
|
||||||
|
%>
|
||||||
|
<article class="s-archive show-archive">
|
||||||
|
<h1 class="s-archive__show-title"><%= data["archive-title"] %></h1>
|
||||||
|
<ul class="s-archive__meta-wrap list-unstyled no-print">
|
||||||
|
<li class="s-archive__date-wrap s-archive__meta--item">
|
||||||
|
<i class="fa fa-calendar-o"></i>
|
||||||
|
<span class="s-archive__date" date-format="%Y-%m-%d"><%=data["created_at"]%></span>
|
||||||
|
</li>
|
||||||
|
<li class="s-archive__tag-wrap s-archive__meta--item ">
|
||||||
|
<i class="fa fa-tags"></i>
|
||||||
|
<span data-list="tags" data-level="0">
|
||||||
|
<% data["tags"].each do |tag| %>
|
||||||
|
<a href="<%= tag["url"] %>"><span class="s-archive__tag label label-default"><%= tag["name"] %></span></a>
|
||||||
|
<% end %>
|
||||||
|
</span>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
<section class="s-archive__post-wrap">
|
||||||
|
<div class="s-archive__description"><%= data["description"] %></div>
|
||||||
|
</section>
|
||||||
|
<ul class="s-archive__related-wrap list-unstyled no-print">
|
||||||
|
<li class="s-archive__related-file">
|
||||||
|
<i class="fa fa-fw fa-paperclip"></i>
|
||||||
|
<div class="s-archive__related-file-list" data-list="archive_files" data-level="0">
|
||||||
|
<% data["files"].each do |file| %>
|
||||||
|
<span class="label label-primary"></span><a class="s-archive__flie-title btn btn-default btn-sm" href="<%= file["file-url"] %>"><%= file["file-name"] %></a>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
<a class="btn btn-primary" href="<%= data['index_url'] %>" title="<%= t("archive.back_to_index_page") %>"><%= t("archive.back_to_index_page") %></a>
|
||||||
|
</article>
|
|
@ -82,6 +82,14 @@ if bundle_update_flag
|
||||||
"en" => "12. Accordion list - with drop down (widget-title, category, filename, download link)"
|
"en" => "12. Accordion list - with drop down (widget-title, category, filename, download link)"
|
||||||
},
|
},
|
||||||
"thumbnail" => "ar2.png"
|
"thumbnail" => "ar2.png"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"filename" => "archive_index13",
|
||||||
|
"name" => {
|
||||||
|
"zh_tw" => "13. 頁籤式 ( 模組標題, 類別標題, 標題, 檔案名稱, 下載連結, 描述 )",
|
||||||
|
"en" => "13. Tab list (widget-title, category, title, filename, download link, description)"
|
||||||
|
},
|
||||||
|
"thumbnail" => "ar-tab1.png"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
flags = []
|
flags = []
|
||||||
|
@ -103,7 +111,7 @@ if bundle_update_flag
|
||||||
end
|
end
|
||||||
flags << flag
|
flags << flag
|
||||||
end
|
end
|
||||||
force_update_files = ["archive_index1.html.erb","archive_index3.html.erb","archive_index12.html.erb"]
|
force_update_files = ["archive_index1.html.erb","archive_index3.html.erb","archive_index12.html.erb","archive_index13.html.erb"]
|
||||||
puts "updating archive index page"
|
puts "updating archive index page"
|
||||||
if flags.select{|flag| flag }.count != 0
|
if flags.select{|flag| flag }.count != 0
|
||||||
flags.each_with_index do |flag,i|
|
flags.each_with_index do |flag,i|
|
||||||
|
|
|
@ -2,6 +2,12 @@ en:
|
||||||
restful_actions:
|
restful_actions:
|
||||||
categories_order: Categories Order
|
categories_order: Categories Order
|
||||||
archive:
|
archive:
|
||||||
|
back_to_index_page: "Back to Index Page"
|
||||||
|
delete_selected: "Delete Selected"
|
||||||
|
feed_name: Feed Name
|
||||||
|
rssfeed: RSS Feed Link
|
||||||
|
jsonfeed: JSON Feed Link
|
||||||
|
feed_list: Feed List
|
||||||
expanded: Expanded
|
expanded: Expanded
|
||||||
other: Other
|
other: Other
|
||||||
serial_number: "Serial Number"
|
serial_number: "Serial Number"
|
||||||
|
|
|
@ -2,6 +2,12 @@ zh_tw:
|
||||||
restful_actions:
|
restful_actions:
|
||||||
categories_order: 類別排序
|
categories_order: 類別排序
|
||||||
archive:
|
archive:
|
||||||
|
back_to_index_page: "返回列表頁"
|
||||||
|
delete_selected: "刪除所選"
|
||||||
|
feed_name: Feed 標題
|
||||||
|
rssfeed: RSS 供給連結
|
||||||
|
jsonfeed: JSON 供給連結
|
||||||
|
feed_list: 訂閱清單
|
||||||
expanded: 展開的
|
expanded: 展開的
|
||||||
other: 其他
|
other: 其他
|
||||||
serial_number: "編號"
|
serial_number: "編號"
|
||||||
|
|
|
@ -1,15 +1,38 @@
|
||||||
Rails.application.routes.draw do
|
Rails.application.routes.draw do
|
||||||
|
locales = Site.find_by(site_active: true).in_use_locales rescue I18n.available_locales
|
||||||
locales = Site.find_by(site_active: true).in_use_locales rescue I18n.available_locales
|
if ENV['worker_num']=='0' && File.basename($0) != 'rake' && !Rails.const_defined?('Console')
|
||||||
|
Thread.new do
|
||||||
|
archive_sort_order = ArchiveSortOrder.first
|
||||||
|
if archive_sort_order.nil?
|
||||||
|
archive_sort_order = ArchiveSortOrder.create('sort_order' => false)
|
||||||
|
end
|
||||||
|
need_update_sort = (archive_sort_order.need_update_sort rescue false)
|
||||||
|
if need_update_sort
|
||||||
|
sort_order = (archive_sort_order.sort_order rescue false) ? 1 : -1
|
||||||
|
ArchiveFile.recalc_sort_number(sort_order)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
scope "(:locale)", locale: Regexp.new(locales.join("|")) do
|
scope "(:locale)", locale: Regexp.new(locales.join("|")) do
|
||||||
namespace :admin do
|
namespace :admin do
|
||||||
get 'archive_files/categories_order' => 'archive_files#categories_order'
|
get 'archive_files/categories_order' => 'archive_files#categories_order'
|
||||||
post 'archive_files/categories_order' => 'archive_files#save_categories_order'
|
post 'archive_files/categories_order' => 'archive_files#save_categories_order'
|
||||||
|
post 'archive_file/createfeed', to: 'archive_files#createfeed'
|
||||||
|
patch 'archive_file/updatefeed', to: 'archive_files#updatefeed'
|
||||||
|
delete 'archive_file/deletefeed', to: 'archive_files#deletefeed'
|
||||||
|
get 'archive_file/feed', to: 'archive_files#feed'
|
||||||
|
get 'archive_files/feedform', to: 'archive_files#feedform'
|
||||||
|
delete 'archive_files/delete', to: 'archive_files#delete'
|
||||||
resources :archive_files
|
resources :archive_files
|
||||||
end
|
end
|
||||||
|
get "/xhr/archive_files/feeds" => "archive_feeds#feeds"
|
||||||
get "/xhr/archive/download" => "archives#download_file"
|
get "/xhr/archive/download" => "archives#download_file"
|
||||||
get "/xhr/web/cmaps/:file_name.:extension" => "archives#serve_cmap"
|
get "/xhr/web/cmaps/:file_name.:extension" => "archives#serve_cmap"
|
||||||
|
post "/xhr/archives/feed_add_remote/:uid" => "archive_feeds#feed_add_remote"
|
||||||
|
post "/xhr/archives/feed_remove_remote/:uid" => "archive_feeds#feed_remove_remote"
|
||||||
|
get "/xhr/archive_files/feed/:uid" => "archive_feeds#feed"
|
||||||
|
get "/xhr/archive_files/rssfeed/:uid" => "archive_feeds#rssfeed"
|
||||||
|
get "/xhr/archive_files/feeds" => "archive_feeds#feeds"
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -15,9 +15,33 @@ module Archive
|
||||||
tmp = OrbitApp.registration "Archive", :type => "ModuleApp" do
|
tmp = OrbitApp.registration "Archive", :type => "ModuleApp" do
|
||||||
module_label "archive.archive"
|
module_label "archive.archive"
|
||||||
base_url File.expand_path File.dirname(__FILE__)
|
base_url File.expand_path File.dirname(__FILE__)
|
||||||
|
feeds_url "/xhr/archive_files/feeds"
|
||||||
|
begin
|
||||||
|
feeds_model "ArchiveFile"
|
||||||
|
feeds_uid_field "feed_uid"
|
||||||
|
feeds_update_callback "update_feed_data"
|
||||||
|
feeds_update_statuses_callback "update_feed_statuses"
|
||||||
|
feeds_time_field "created_at"
|
||||||
|
feeds_finish_callback "feeds_finish_callback"
|
||||||
|
rescue => e
|
||||||
|
puts "orbit kernel need update!"
|
||||||
|
end
|
||||||
widget_methods ["widget","group_by_category"]
|
widget_methods ["widget","group_by_category"]
|
||||||
widget_settings [{"data_count"=>30,"enable_custom_widget_data"=>true}]
|
widget_settings [{"data_count"=>30,"enable_custom_widget_data"=>true}]
|
||||||
models_to_cache [:archive_file]
|
models_to_cache [:archive_file]
|
||||||
|
begin
|
||||||
|
avoid_page_cache ArchiveCache
|
||||||
|
avoid_page_cache ArchiveFileFeed
|
||||||
|
avoid_page_cache ArchiveFileFeedCache
|
||||||
|
rescue => e
|
||||||
|
puts ["avoid_page_cache", e.to_s]
|
||||||
|
end
|
||||||
|
if ENV['worker_num']=='0' && File.basename($0) != 'rake' && !Rails.const_defined?('Console')
|
||||||
|
require File.expand_path('../../../app/models/archive_cache', __FILE__)
|
||||||
|
if defined?(ArchiveCache)
|
||||||
|
ArchiveCache.all.delete
|
||||||
|
end
|
||||||
|
end
|
||||||
taggable "ArchiveFile"
|
taggable "ArchiveFile"
|
||||||
categorizable
|
categorizable
|
||||||
authorizable
|
authorizable
|
||||||
|
@ -59,6 +83,11 @@ module Archive
|
||||||
:priority=>5,
|
:priority=>5,
|
||||||
:active_for_action=>{'admin/archive_files'=>'categories_order'},
|
:active_for_action=>{'admin/archive_files'=>'categories_order'},
|
||||||
:available_for => 'managers'
|
:available_for => 'managers'
|
||||||
|
context_link 'archive.feed_list',
|
||||||
|
:link_path=>"admin_archive_file_feed_path" ,
|
||||||
|
:priority=>6,
|
||||||
|
:active_for_action=>{'admin/archive_files'=>'feed'},
|
||||||
|
:available_for => 'managers'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
categories_temp = ModuleApp.where(:key => "archive").first.categories
|
categories_temp = ModuleApp.where(:key => "archive").first.categories
|
||||||
|
|
|
@ -0,0 +1,37 @@
|
||||||
|
module ArchiveModel
|
||||||
|
module Cache
|
||||||
|
require 'active_support/concern'
|
||||||
|
extend ActiveSupport::Concern
|
||||||
|
included do
|
||||||
|
after_save :cache_tag_ids, :do_before_save
|
||||||
|
after_destroy :do_before_save
|
||||||
|
before_destroy :cache_tag_ids
|
||||||
|
end
|
||||||
|
def cache_tag_ids
|
||||||
|
if !@skip_callback && self.class == ArchiveFile
|
||||||
|
@tag_ids = self.tag_ids
|
||||||
|
@org_tag_ids = self.org_tag_ids
|
||||||
|
@category_id = self.category_id
|
||||||
|
@org_category_id = self.org_category_id
|
||||||
|
end
|
||||||
|
end
|
||||||
|
def do_before_save
|
||||||
|
unless @skip_callback
|
||||||
|
if self.class == SubPart
|
||||||
|
ArchiveCache.where(parent_id: /^#{self.id}/).delete
|
||||||
|
elsif self.class == ArchiveFile || (self.class == Page && self.module == "archive")
|
||||||
|
if self.class == ArchiveFile
|
||||||
|
tmp_tag_ids = (Array(@tag_ids) + Array(@org_tag_ids)).uniq
|
||||||
|
tmp_cat_ids = (Array(@category_id) + Array(@org_category_id)).uniq
|
||||||
|
Thread.new do
|
||||||
|
ArchiveFileFeedCache.where(:uid.in => ArchiveFileFeed.any_of([{:tag_ids.in => tmp_tag_ids.collect{|v| v.to_s}},{:category_ids.in => tmp_cat_ids.collect{|v| v.to_s}}]).pluck(:uid)).each do |cache|
|
||||||
|
cache.regenerate
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
ArchiveCache.all.delete
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -14,7 +14,7 @@
|
||||||
<dl class="i-archive__file-list" data-list="files" data-level="2">
|
<dl class="i-archive__file-list" data-list="files" data-level="2">
|
||||||
<dd class="i-archive__file-wrap">
|
<dd class="i-archive__file-wrap">
|
||||||
<a class="i-archive__file-name" href="{{file-url}}" target="_blank" title="{{file-name}}">{{file-name}}</a>
|
<a class="i-archive__file-name" href="{{file-url}}" target="_blank" title="{{file-name}}">{{file-name}}</a>
|
||||||
<span class="i-archive__file-type label label-primary">{{file-type}}</span>
|
<span class="i-archive__file-type label label-primary {{file-type}}">{{file-type}}</span>
|
||||||
</dd>
|
</dd>
|
||||||
</dl>
|
</dl>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
</span>
|
</span>
|
||||||
</td>
|
</td>
|
||||||
<td class="i-archive__file-list col-sm-3" data-list="files" data-level="2">
|
<td class="i-archive__file-list col-sm-3" data-list="files" data-level="2">
|
||||||
<a href="{{file-url}}" class="i-archive-files-item" target="_blank" data-toggle="tooltip" data-placement="bottom" title="{{file-name}}"><span class="label label-primary">{{file-type}}</span></a>
|
<a href="{{file-url}}" class="i-archive-files-item" target="_blank" data-toggle="tooltip" data-placement="bottom" title="{{file-name}}"><span class="label label-primary {{file-type}}">{{file-type}}</span></a>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
<a class="i-archive__file-name" href="{{file-url}}" target="_blank" title="{{file-name}}">{{file-name}}</a>
|
<a class="i-archive__file-name" href="{{file-url}}" target="_blank" title="{{file-name}}">{{file-name}}</a>
|
||||||
</td>
|
</td>
|
||||||
<td class="col-sm-3">
|
<td class="col-sm-3">
|
||||||
<a href="{{file-url}}" class="i-archive-files-item" target="_blank" data-toggle="tooltip" data-placement="bottom" title="{{file-name}}"><span class="label label-primary">{{file-type}}</span></a>
|
<a href="{{file-url}}" class="i-archive-files-item" target="_blank" data-toggle="tooltip" data-placement="bottom" title="{{file-name}}"><span class="label label-primary {{file-type}}">{{file-type}}</span></a>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</span>
|
</span>
|
||||||
|
|
|
@ -25,8 +25,8 @@
|
||||||
</dt>
|
</dt>
|
||||||
<dl class="i-archive-files-list" data-list="files" data-level="2">
|
<dl class="i-archive-files-list" data-list="files" data-level="2">
|
||||||
<dd>
|
<dd>
|
||||||
<a href="{{file-url}}" class="i-archive-files-item" target="_blank">{{file-name}}</a>
|
<a href="{{file-url}}" class="i-archive-files-item" target="_blank" title="{{file-name}}">{{file-name}}</a>
|
||||||
<span class="label label-primary">{{file-type}}</span>
|
<span class="label label-primary {{file-type}}">{{file-type}}</span>
|
||||||
</dd>
|
</dd>
|
||||||
</dl>
|
</dl>
|
||||||
</dl>
|
</dl>
|
||||||
|
|
|
@ -0,0 +1,41 @@
|
||||||
|
<div class="i-archive index-archive-13">
|
||||||
|
<h3 class="i-archive-title">
|
||||||
|
<span>{{page-title}}</span>
|
||||||
|
</h3>
|
||||||
|
<ul class="archive-categories nav nav-tabs" role="tablist" data-list="categories" data-level="0" data-no-edit="true">
|
||||||
|
<li class="nav-item {{active_class}}" role="presentation">
|
||||||
|
<a href="#{{category-id}}" role="tab" data-toggle="tab" title="{{category-title}}" >{{category-title}}</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
<div class="tab-content" data-list="categories" data-level="0">
|
||||||
|
<div class="tab-pane {{active_class}}" id="{{category-id}}" role="tabpanel" aria-labelledby="{{category-id}}-tab">
|
||||||
|
<ul class="archives-ul" data-list="archives" data-level="1">
|
||||||
|
<li class="archive-li">
|
||||||
|
<p>
|
||||||
|
<span data-list="statuses" data-level="2">
|
||||||
|
<span class="label status {{status-class}}">{{status}}</span>
|
||||||
|
</span>
|
||||||
|
<a href="{{archive-file-url}}" target="_blank" title="{{archive-title}}">
|
||||||
|
{{archive-title}}
|
||||||
|
</a>
|
||||||
|
<span class="i-archive-files-list" data-list="files" data-level="2">
|
||||||
|
<a href="{{file-url}}" class="i-archive-files-item" title="{{file-name}}" data-toggle="tooltip" data-placement="bottom">
|
||||||
|
<span class="label label-primary {{file-type}}">{{file-type}}</span>
|
||||||
|
</a>
|
||||||
|
</span>
|
||||||
|
</p>
|
||||||
|
<div class="archive-description">{{description}}</div>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
{{link_to_edit}}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<style>
|
||||||
|
.index-archive-13 .archives-ul .archive-li{
|
||||||
|
list-style-type: disc;
|
||||||
|
}
|
||||||
|
.index-archive-13 .archive-description{
|
||||||
|
color: #9b9b9b;
|
||||||
|
}
|
||||||
|
</style>
|
|
@ -24,7 +24,7 @@
|
||||||
<dl class="i-archive-files-list col-sm-7" data-list="files" data-level="2">
|
<dl class="i-archive-files-list col-sm-7" data-list="files" data-level="2">
|
||||||
<dd>
|
<dd>
|
||||||
<a href="{{file-url}}" class="i-archive-files-item" target="_blank" title="{{file-name}}">{{file-name}}</a>
|
<a href="{{file-url}}" class="i-archive-files-item" target="_blank" title="{{file-name}}">{{file-name}}</a>
|
||||||
<span class="label label-primary">{{file-type}}</span>
|
<span class="label label-primary {{file-type}}">{{file-type}}</span>
|
||||||
</dd>
|
</dd>
|
||||||
</dl>
|
</dl>
|
||||||
</dl>
|
</dl>
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
<dl class="i-archive__file-list" data-list="files" data-level="2">
|
<dl class="i-archive__file-list" data-list="files" data-level="2">
|
||||||
<dd class="i-archive__file-wrap">
|
<dd class="i-archive__file-wrap">
|
||||||
<a class="i-archive__file-name" href="{{file-url}}" target="_blank" title="{{file-name}}">{{file-name}}</a>
|
<a class="i-archive__file-name" href="{{file-url}}" target="_blank" title="{{file-name}}">{{file-name}}</a>
|
||||||
<span class="i-archive__file-type label label-primary">{{file-type}}</span>
|
<span class="i-archive__file-type label label-primary {{file-type}}">{{file-type}}</span>
|
||||||
</dd>
|
</dd>
|
||||||
</dl>
|
</dl>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
<dl class="i-archive-files-list col-sm-7" data-list="files" data-level="2">
|
<dl class="i-archive-files-list col-sm-7" data-list="files" data-level="2">
|
||||||
<dd>
|
<dd>
|
||||||
<a href="{{file-url}}" class="i-archive-files-item" target="_blank" title="{{file-name}}">{{file-name}}</a>
|
<a href="{{file-url}}" class="i-archive-files-item" target="_blank" title="{{file-name}}">{{file-name}}</a>
|
||||||
<span class="label label-primary">{{file-type}}</span>
|
<span class="label label-primary {{file-type}}">{{file-type}}</span>
|
||||||
</dd>
|
</dd>
|
||||||
</dl>
|
</dl>
|
||||||
</dl>
|
</dl>
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="i-archive__file-list col-sm-3" data-list="files" data-level="2">
|
<div class="i-archive__file-list col-sm-3" data-list="files" data-level="2">
|
||||||
<a href="{{file-url}}" class="i-archive-files-item" target="_blank" data-toggle="tooltip" data-placement="bottom" title="{{file-name}}"><span class="label label-primary">{{file-type}}</span></a>
|
<a href="{{file-url}}" class="i-archive-files-item" target="_blank" data-toggle="tooltip" data-placement="bottom" title="{{file-name}}"><span class="label label-primary {{file-type}}">{{file-type}}</span></a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="i-archive__file-list col-sm-3" data-list="files" data-level="2">
|
<div class="i-archive__file-list col-sm-3" data-list="files" data-level="2">
|
||||||
<div class="file-item">
|
<div class="file-item">
|
||||||
<a href="{{file-url}}" class="i-archive-files-item" target="_blank" data-toggle="tooltip" data-placement="bottom" title="{{file-name}}"><span class="label label-primary">{{file-type}}</span></a>
|
<a href="{{file-url}}" class="i-archive-files-item" target="_blank" data-toggle="tooltip" data-placement="bottom" title="{{file-name}}"><span class="label label-primary {{file-type}}">{{file-type}}</span></a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="description col-sm-3" style="border-right: 0.05em solid #333;">{{description}}</div>
|
<div class="description col-sm-3" style="border-right: 0.05em solid #333;">{{description}}</div>
|
||||||
<div class="i-archive__file-list col-sm-3" data-list="files" data-level="2">
|
<div class="i-archive__file-list col-sm-3" data-list="files" data-level="2">
|
||||||
<a href="{{file-url}}" class="i-archive-files-item" target="_blank" data-toggle="tooltip" data-placement="bottom" title="{{file-name}}"><span class="label label-primary">{{file-type}}</span></a>
|
<a href="{{file-url}}" class="i-archive-files-item" target="_blank" data-toggle="tooltip" data-placement="bottom" title="{{file-name}}"><span class="label label-primary {{file-type}}">{{file-type}}</span></a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
<div class="description col-sm-3">{{description}}</div>
|
<div class="description col-sm-3">{{description}}</div>
|
||||||
<div class="i-archive__file-list col-sm-3" data-list="files" data-level="2">
|
<div class="i-archive__file-list col-sm-3" data-list="files" data-level="2">
|
||||||
<div class="file-item">
|
<div class="file-item">
|
||||||
<a href="{{file-url}}" class="i-archive-files-item" target="_blank" data-toggle="tooltip" data-placement="bottom" title="{{file-name}}"><span class="label label-primary">{{file-type}}</span></a>
|
<a href="{{file-url}}" class="i-archive-files-item" target="_blank" data-toggle="tooltip" data-placement="bottom" title="{{file-name}}"><span class="label label-primary {{file-type}}">{{file-type}}</span></a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
{{file-name}}
|
{{file-name}}
|
||||||
</td>
|
</td>
|
||||||
<td class="col-sm-4">
|
<td class="col-sm-4">
|
||||||
<a href="{{file-url}}" class="i-archive-files-item" target="_blank" data-toggle="tooltip" data-placement="bottom" title="{{file-name}}"><span class="label label-primary">{{file-type}}</span></a>
|
<a href="{{file-url}}" class="i-archive-files-item" target="_blank" data-toggle="tooltip" data-placement="bottom" title="{{file-name}}"><span class="label label-primary {{file-type}}">{{file-type}}</span></a>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
|
@ -95,6 +95,14 @@
|
||||||
"en" : "12. Accordion list - with drop down (widget-title, category, filename, download link)"
|
"en" : "12. Accordion list - with drop down (widget-title, category, filename, download link)"
|
||||||
},
|
},
|
||||||
"thumbnail" : "ar2.png"
|
"thumbnail" : "ar2.png"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"filename": "archive_index13",
|
||||||
|
"name": {
|
||||||
|
"zh_tw": "13. 頁籤式 ( 模組標題, 類別標題, 標題, 檔案名稱, 下載連結, 描述 )",
|
||||||
|
"en": "13. Tab list (widget-title, category, title, filename, download link, description)"
|
||||||
|
},
|
||||||
|
"thumbnail": "ar-tab1.png"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"widgets" : [
|
"widgets" : [
|
||||||
|
|
Binary file not shown.
After Width: | Height: | Size: 40 KiB |
Loading…
Reference in New Issue