diff --git a/app/controllers/archives_controller.rb b/app/controllers/archives_controller.rb
index fd42ede..3a6a971 100644
--- a/app/controllers/archives_controller.rb
+++ b/app/controllers/archives_controller.rb
@@ -12,6 +12,7 @@ class ArchivesController < ApplicationController
params = OrbitHelper.params
@@total_pages = 1
cats_last = []
+ sort_order = (ArchiveSortOrder.first['sort_order'] rescue false) ? 1 : -1 #Order with ascending
if !params['title'].nil?
files_by_category = ArchiveFile.where(is_hidden: false).order_by(:created_at => "desc").group_by(&:category)
categories = files_by_category.keys
@@ -20,7 +21,8 @@ class ArchivesController < ApplicationController
url_to_edit = ""
flag = false
archives = []
- files_by_category[category].each do |archive|
+ serial_number = 0
+ files_by_category[category].each_with_index do |archive,idx|
if archive.title == params['title']
flag = true
statuses = archive.statuses_with_classname.collect do |status|
@@ -34,19 +36,23 @@ class ArchivesController < ApplicationController
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}"
+ "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
+ "file-url" => url,
+ "serial_number" => serial_number
}
end
end
@@ -59,7 +65,8 @@ class ArchivesController < ApplicationController
"statuses" => statuses,
"sort_number" => archive.sort_number,
"is_top" => (archive.is_top ? 1 : 0),
- "files" => files
+ "files" => files,
+ "idx" => (idx + 1)
}
end
end
@@ -110,8 +117,9 @@ class ArchivesController < ApplicationController
url_to_edit = OrbitHelper.current_user ? "/admin/archive_files?filters[tags][]=#{tag_id}" : ""
taggings = Tagging.where(:tag_id=>tag_id).pluck(:taggable_id)
archives = archive_files.where(:id.in=>taggings).to_a
+ serial_number = 0
if archives.count != 0
- archives = archives.map do |archive|
+ archives = archives.sort_by{|k| [(k["is_top"] ? 0 : 1) ,sort_order * (k["sort_number"].nil? ? Float::INFINITY : k["sort_number"].to_i),-k["created_at"].to_i]}.map.with_index do |archive,idx|
statuses = archive.statuses_with_classname.collect do |status|
{
"status" => status["name"] || "",
@@ -123,19 +131,23 @@ class ArchivesController < ApplicationController
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}"
+ "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
+ "file-url" => url,
+ "serial_number" => serial_number
}
end
end
@@ -148,12 +160,12 @@ class ArchivesController < ApplicationController
"statuses" => statuses,
"sort_number" => archive.sort_number,
"is_top" => (archive.is_top ? 1 : 0),
- "files" => files
+ "files" => files,
+ "idx" => (idx + 1)
}
end
each_data_count.push(archives.length)
- sorted = archives.sort_by{|k,v| -k["sort_number"].to_i}
- sorted = sorted.sort{|k,v| v["is_top"] <=> k["is_top"]}
+ sorted = archives
cats << {
"category-title" => Tag.find(tag_id).name,
"archives" => sorted,
@@ -169,7 +181,8 @@ class ArchivesController < ApplicationController
categories_sort = get_sorted_cat_with_filter(categories,'orm')
cats = categories_sort.collect do |category|
url_to_edit = OrbitHelper.user_has_cateogry?(category) ? "/admin/archive_files?filters[category][]=#{category.id.to_s}" : ""
- archives = files_by_category[category].collect do |archive|
+ serial_number = 0
+ archives = files_by_category[category].sort_by{|k| [(k["is_top"] ? 0 : 1) ,sort_order * (k["sort_number"].nil? ? Float::INFINITY : k["sort_number"].to_i),-k["created_at"].to_i]}.collect.with_index do |archive,idx|
statuses = archive.statuses_with_classname.collect do |status|
{
"status" => status["name"] || "",
@@ -179,21 +192,25 @@ class ArchivesController < ApplicationController
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}"
+ "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
+ "file-url" => url,
+ "serial_number" => serial_number
}
end
end
@@ -206,27 +223,18 @@ class ArchivesController < ApplicationController
"statuses" => statuses,
"sort_number" => archive.sort_number,
"is_top" => (archive.is_top ? 1 : 0),
- "files" => files
+ "files" => files,
+ "idx" => (idx + 1)
}
end
each_data_count.push(archives.length)
- sorted = archives.sort_by{|k,v| -k["sort_number"].to_i}
- sorted = sorted.sort{|k,v| v["is_top"] <=> k["is_top"]}
+ sorted = archives
{
"category-title" => category.title,
"archives" => sorted,
"url_to_edit" => url_to_edit
}
end
- if ArchiveSortOrder.first['sort_order'] #Order with ascending
- cats = cats.collect do |cat|
- Hash[cat.map{|k,v| [k,k=='archives' ? (v.sort_by{|tp| [(tp['sort_number'].nil? ? Float::INFINITY : tp['sort_number'].to_i),-tp['created_at']]}) : v] }]
- end
- else
- cats = cats.collect do |cat|
- Hash[cat.map{|k,v| [k,k=='archives' ? (v.sort_by{|tp| [(tp['sort_number'].nil? ? Float::INFINITY : -tp['sort_number'].to_i),-tp['created_at']]}) : v] }]
- end
- end
if page_data_count != 0
all_data_count = 0
data_start = -1
@@ -280,8 +288,9 @@ class ArchivesController < ApplicationController
{
"categories" => cats_last,
"extras" =>{
+ "serial_number-head" => I18n.t("archive.serial_number"),
"date-head" => I18n.t("archive.updated_at"),
- "title-head" => I18n.t("archive.Title"),
+ "title-head" => I18n.t(:name),
"description-head"=>I18n.t("archive.description"),
"file-head" =>I18n.t("archive.download_file")
}
diff --git a/archive.gemspec b/archive.gemspec
index be32bc8..3761635 100644
--- a/archive.gemspec
+++ b/archive.gemspec
@@ -56,6 +56,22 @@ all_template.each do |folder|
"en" => "9. Table list - Simple (widget-title, download link)"
},
"thumbnail" => "ar9.png"
+ },
+ {
+ "filename" => "archive_index10",
+ "name" => {
+ "zh_tw" => "10. 表格列表 ( 模組標題, 類別標題, 編號, 檔案名稱, 下載連結 )",
+ "en" => "10. Table list (widget-title, category, Serial Number, filename, download link)"
+ },
+ "thumbnail" => "ar5.png"
+ },
+ {
+ "filename" => "archive_index11",
+ "name" => {
+ "zh_tw" => "11. 表格列表 - 簡約 - 展開檔案 ( 模組標題, 類別標題, 編號, 檔案名稱, 下載連結 )",
+ "en" => "11. Table list - Simple - Unfold Files (widget-title, category, Serial Number, filename, download link)"
+ },
+ "thumbnail" => "ar9.png"
}
]
flags = []
diff --git a/config/locales/en.yml b/config/locales/en.yml
index 9b0ddaa..11cac90 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -2,6 +2,7 @@ en:
restful_actions:
categories_order: Categories Order
archive:
+ serial_number: "Serial Number"
url_text: "URL Text"
url_text_hint: "URL Text, default: link"
updated_at: Updated At
diff --git a/config/locales/zh_tw.yml b/config/locales/zh_tw.yml
index 7284567..c415979 100644
--- a/config/locales/zh_tw.yml
+++ b/config/locales/zh_tw.yml
@@ -2,6 +2,7 @@ zh_tw:
restful_actions:
categories_order: 類別排序
archive:
+ serial_number: "編號"
url_text: "連結文字"
url_text_hint: "連結文字,預設為link"
updated_at: 上傳日期
diff --git a/modules/archive/archive_index10.html.erb b/modules/archive/archive_index10.html.erb
new file mode 100644
index 0000000..b9b5bcd
--- /dev/null
+++ b/modules/archive/archive_index10.html.erb
@@ -0,0 +1,32 @@
+
+
+ {{page-title}}
+
+
+
{{category-title}}
+
+
+
+ {{serial_number-head}} |
+ {{title-head}} |
+ {{file-head}} |
+
+
+
+
+ {{idx}} |
+
+ {{archive-title}}
+
+ {{status}}
+
+ |
+
+ {{file-type}}
+ |
+
+
+
+
+
+
\ No newline at end of file
diff --git a/modules/archive/archive_index11.html.erb b/modules/archive/archive_index11.html.erb
new file mode 100644
index 0000000..1ba6aa7
--- /dev/null
+++ b/modules/archive/archive_index11.html.erb
@@ -0,0 +1,34 @@
+
+
+ {{page-title}}
+
+
+
{{category-title}}
+
+
+
+ {{serial_number-head}} |
+ {{title-head}} |
+ {{file-head}} |
+
+
+
+
+
+
+
+ {{serial_number}}
+ |
+
+ {{file-name}}
+ |
+
+ {{file-type}}
+ |
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/modules/archive/info.json b/modules/archive/info.json
index a1fd1d5..daf5caf 100644
--- a/modules/archive/info.json
+++ b/modules/archive/info.json
@@ -68,7 +68,23 @@
"filename" : "archive_index9",
"name" : {
"zh_tw" : "9. 表格列表 - 簡約 ( 模組標題, 檔案名稱, 下載連結 )",
- "en" : "9. Table list - Simple (widget-title, download link)"
+ "en" : "9. Table list - Simple (widget-title, filename, download link)"
+ },
+ "thumbnail" : "ar9.png"
+ },
+ {
+ "filename" : "archive_index10",
+ "name" : {
+ "zh_tw" : "10. 表格列表 ( 模組標題, 類別標題, 編號, 檔案名稱, 下載連結 )",
+ "en" : "10. Table list (widget-title, category, Serial Number, filename, download link)"
+ },
+ "thumbnail" : "ar5.png"
+ },
+ {
+ "filename" : "archive_index11",
+ "name" : {
+ "zh_tw" : "11. 表格列表 - 簡約 - 展開檔案 ( 模組標題, 類別標題, 編號, 檔案名稱, 下載連結 )",
+ "en" : "11. Table list - Simple - Unfold Files (widget-title, category, Serial Number, filename, download link)"
},
"thumbnail" : "ar9.png"
}