Add description field.

Upload template files.
This commit is contained in:
BoHung Chiu 2021-03-23 17:50:53 +08:00
parent 715c51552c
commit c618a295b8
25 changed files with 519 additions and 4 deletions

View File

@ -87,7 +87,7 @@ class Admin::ArchiveFilesController < OrbitAdminController
respond_to do |format|
if @archive_file.save
format.html { redirect_to(edit_admin_archive_file_path(@archive_file.id)) }
format.html { redirect_to(admin_archive_files_path) }
format.xml { render :xml => @archive_file, :status => :created, :location => @archive_file }
else
@tags = @module_app.tags
@ -106,7 +106,7 @@ class Admin::ArchiveFilesController < OrbitAdminController
respond_to do |format|
if @archive_file.update_attributes(archive_vars)
format.html { redirect_to(edit_admin_archive_file_path(@archive_file.id)) }
format.html { redirect_to(admin_archive_files_path) }
format.xml { head :ok }
else
format.html { render :action => "edit" }

View File

@ -48,6 +48,7 @@ class ArchivesController < ApplicationController
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,
@ -103,6 +104,7 @@ class ArchivesController < ApplicationController
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,
@ -190,7 +192,8 @@ class ArchivesController < ApplicationController
end
end
{
"categories" => cats_last
"categories" => cats_last,
"extras" =>{"description-head"=>I18n.t("archive.description")}
}
end
@ -236,6 +239,7 @@ class ArchivesController < ApplicationController
files_by_category_tag[t].each_with_index do |archive,index|
a = {
"archive-title" => archive.title,
"description" => archive.description,
"archive-url" => archive.url,
"archive_url" => OrbitHelper.widget_more_url
}
@ -309,6 +313,7 @@ class ArchivesController < ApplicationController
end
{
"archive-title" => archive.title,
"description" => archive.description,
"archive-url" => archive.url,
"archive_url" => url
}
@ -323,6 +328,7 @@ class ArchivesController < ApplicationController
end
{
"archive-title" => archive.title,
"description" => archive.description,
"archive-url" => archive.url,
"archive_url" => url
}

View File

@ -18,6 +18,7 @@ class ArchiveFile
field :title, as: :slug_title, localize: true
field :description, localize: true
field :url, localize: true
field :create_user_id
field :update_user_id

View File

@ -121,6 +121,15 @@
<% end %>
</div>
</div>
<!-- description -->
<div class="control-group input-title">
<label class="control-label muted"><%= t("archive.description") %></label>
<div class="controls">
<%= f.fields_for :description_translations do |f| %>
<%= f.text_field locale, class: "input-block-level", placeholder: t("archive.description"), value: (@archive_file.description_translations[locale] rescue nil) %>
<% end %>
</div>
</div>
<!-- url -->
<div class="control-group input-title">
<label class="control-label muted"><%= t(:url) %></label>

View File

@ -2,7 +2,58 @@ $:.push File.expand_path("../lib", __FILE__)
# Maintain your gem's version:
require "archive/version"
env_pwd = ENV['PWD']
app_path = File.expand_path(__dir__)
template_path = env_pwd + '/app/templates'
all_template = Dir.glob(template_path+'/*/')
all_template.each do |folder|
if !folder.include?('mobile')
begin
next unless File.exist?("#{folder}modules/archive/info.json")
info_json_file = "#{folder}modules/archive/info.json"
info_json = JSON.parse(File.read(info_json_file))
check_files = ["archive_index7","archive_index8"]
file_infos = [
{
"filename" : "archive_index7",
"name" : {
"zh_tw" : "7. 表格列表 ( 模組標題, 類別標題, 檔案名稱, 檔案簡介, 下載連結 )",
"en" : "7. Table list (widget-title, category, filename, download link)"
},
"thumbnail" : "ar5.png"
},
{
"filename" : "archive_index8",
"name" : {
"zh_tw" : "8. 表格列表 ( 模組標題, 檔案名稱, 檔案簡介, 下載連結 )",
"en" : "8. Table list (widget-title, filename, download link)"
},
"thumbnail" : "ar5.png"
}
]
flags = []
check_files.each_with_index do |check_file,i|
flag = (info_json["frontend"].select{|h| h["filename"] == check_file}.count == 0 rescue false)
if flag
info_json["frontend"].push(file_infos[i])
end
flags << flag
end
if flags.select{|flag| flag }.count != 0
puts "updating archive index page"
flags.each_with_index do |flag,i|
if flag
Bundler.with_clean_env{%x[cp -f #{app_path}/modules/archive/#{check_files[i]} #{folder}modules/archive/#{check_files[i]}]}
end
end
File.open(info_json_file,"w+"){|f| f.write(info_json.to_json)}
end
Bundler.with_clean_env{%x[cp -f #{app_path}/modules/faq/faq_index2.html.erb #{folder}modules/faq/faq_index2.html.erb]}
rescue
puts "There has some error when updating archive index page."
end
end
end
# Describe your gem and declare its dependencies:
Gem::Specification.new do |s|
s.name = "archive"

View File

@ -2,6 +2,7 @@ en:
restful_actions:
categories_order: Categories Order
archive:
description: File description
category: Category
sort_number: Sort Order
save: Save

View File

@ -2,6 +2,7 @@ zh_tw:
restful_actions:
categories_order: 類別排序
archive:
description: 檔案簡介
category: 類別
sort_number: 排序號碼
save: 儲存

View File

@ -0,0 +1,18 @@
<div class="w-archive widget-archive-1" module="archive" data-ps="">
<h3 class="w-archive__widget-title">{{widget-title}}</h3>
<ul class="w-archive__list level-1 list-unstyled" data-list="categories" data-level="0">
<li class="w-archive__item level-1">
<h4 class="w-archive__item-heading">{{category-title}}</h4>
<li class="w-archive__item level-2">
<ul class="w-archive__list level-3" data-list="archives" data-level="1">
<li class="w-archive__item level-3">
<a class="w-archive__link" href="{{archive_url}}">{{archive-title}}</a>
</li>
</ul>
</li>
</li>
</ul>
<p class="more">
<a class="btn btn-sm btn-primary" href="{{more_url}}"><%= (I18n.locale.to_s =="zh_tw") ? "更多資訊" : "More" %></a>
</p>
</div>

View File

@ -0,0 +1,28 @@
<div class="w-archive widget-archive-2">
<h3 class="widget-title">
<span>{{widget-title}}</span>
</h3>
<div class="panel-group" id="widget-archive-group" data-list="categories" data-level="0">
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">
<a data-toggle="collapse" data-parent="#widget-archive-group" href="#collapse" class="collapsed">
{{category-title}}
</a>
</h4>
</div>
<div id="collapse" class="panel-collapse collapse">
<div class="panel-body">
<ul class="widget-archive-item-group" data-list="archives" data-level="1">
<li class="widget-archive-item-list">
<a href="{{archive_url}}">{{archive-title}}</a>
</li>
</ul>
</div>
</div>
</div>
</div>
<p class="more">
<a class="btn btn-sm btn-primary" href="{{more_url}}"><%= (I18n.locale.to_s =="zh_tw") ? "更多資訊" : "More" %></a>
</p>
</div>

View File

@ -0,0 +1,24 @@
<div class="i-archive index-archive-1">
<h3 class="i-archive__page-title">{{page-title}}</h3>
<ul class="i-archive__list list-unstyled" data-list="categories" data-level="0">
<li class="i-archive__item">
<h4 class="i-archive__category-title">{{category-title}}</h4>
<dl class="i-archive__category-list list-unstyled" data-list="archives" data-level="1">
<div class="i-archive__item-wrap">
<dt class="i-archive__category-item">
<sapn class="i-archive__archive-title">{{archive-title}}</span>
<span class="i-archive__status-wrap" data-list="statuses" data-level="2">
<span class="i-archive__status label status {{status-class}}">{{status}}</span>
</span>
</dt>
<dl class="i-archive__file-list" data-list="files" data-level="2">
<dd class="i-archive__file-wrap">
<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>
</dd>
</dl>
</div>
</dl>
</li>
</ul>
</div>

View File

@ -0,0 +1,36 @@
<div class="i-archive index-archive-2">
<h1 class="i-archive-title">
<span>{{page-title}}</span>
</h1>
<div class="panel-group" id="index-archive-group" data-list="categories" data-level="0">
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">
<a data-toggle="collapse" data-parent="#index-archive-group" href="#collapse" class="collapsed" title="{{category-title}}">
<i class="fa fa-th-list"></i>
{{category-title}}
</a>
</h4>
</div>
<div id="collapse" class="panel-collapse collapse">
<div class="panel-body">
<dl class="dl-horizontal i-archive-item-group" data-list="archives" data-level="1">
<dt class="i-archive-item-list col-sm-5">
<sapn class="i-archive-item-title">{{archive-title}}</span>
<span data-list="statuses" data-level="2">
<span class="label status {{status-class}}">{{status}}</span>
</span>
</dt>
<dl class="i-archive-files-list col-sm-7" data-list="files" data-level="2">
<dd>
<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>
</dd>
</dl>
</dl>
</div>
</div>
</div>
{{link_to_edit}}
</div>
</div>

View File

@ -0,0 +1,23 @@
<div class="i-archive index-archive-3">
<h3 class="i-archive__page-title">{{page-title}}</h3>
<ul class="i-archive__list list-unstyled" data-list="categories" data-level="0">
<li class="i-archive__item">
<h4 class="i-archive__category-title">{{category-title}}</h4>
<dl class="i-archive__category-list list-unstyled" data-list="archives" data-level="1">
<div class="i-archive__item-wrap">
<dt class="i-archive__category-item">
<span class="i-archive__status-wrap" data-list="statuses" data-level="2">
<span class="i-archive__status label status {{status-class}}">{{status}}</span>
</span>
</dt>
<dl class="i-archive__file-list" data-list="files" data-level="2">
<dd class="i-archive__file-wrap">
<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>
</dd>
</dl>
</div>
</dl>
</li>
</ul>
</div>

View File

@ -0,0 +1,34 @@
<div class="i-archive index-archive-4">
<h3 class="i-archive-title">
<span>{{page-title}}</span>
</h3>
<div class="panel-group" id="index-archive-group" data-list="categories" data-level="0">
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">
<a data-toggle="collapse" data-parent="#index-archive-group" href="#collapse" class="collapsed" title="{{category-title}}">
<i class="fa fa-th-list"></i>{{category-title}}
</a>
</h4>
</div>
<div id="collapse" class="panel-collapse collapse">
<div class="panel-body">
<dl class="dl-horizontal i-archive-item-group" data-list="archives" data-level="1">
<dt class="i-archive-item-list col-sm-5">
<span data-list="statuses" data-level="2">
<span class="label status {{status-class}}">{{status}}</span>
</span>
</dt>
<dl class="i-archive-files-list col-sm-7" data-list="files" data-level="2">
<dd>
<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>
</dd>
</dl>
</dl>
</div>
</div>
</div>
{{link_to_edit}}
</div>
</div>

View File

@ -0,0 +1,40 @@
<div class="i-archive index-archive-5">
<h3 class="i-archive-title">
<span>{{page-title}}</span>
</h3>
<div class="i-archive__list list-unstyled" id="index-archive-group" data-list="categories" data-level="0">
<h4 class="i-archive__category-title">{{category-title}}</h4>
<div class="i-items">
<div class="thead row">
<div class="col-sm-2 date-thead">上傳日期</div>
<div class="col-sm-7 title-thead">標題</div>
<div class="col-sm-3 file-thead">檔案下載</div>
</div>
<div class="tbody">
<div class="i-archive__category-list list-unstyled" data-list="archives" data-level="1">
<div class="archive-items clearfix">
<div class="date col-sm-2">{{created_at}}</div>
<div class="head col-sm-7">
{{archive-title}}
<span class="i-archive__status-wrap" data-list="statuses" data-level="2">
<span class="i-archive__status label status {{status-class}}">{{status}}</span>
</span>
</div>
<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>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<script>
if( window.location.href.indexOf('/en/') > -1 ) {
$('.date-thead').replaceWith('<div class="col-sm-2 date-thead-en">Updated At</div>')
$('.title-thead').replaceWith('<div class="col-sm-7 title-thead-en">Title</div>')
$('.file-thead').replaceWith('<div class="col-sm-3 file-thead-en">Download file</div>')
}
</script>

View File

@ -0,0 +1,46 @@
<div class="i-archive index-archive-6">
<h3 class="i-archive-title">
<span>{{page-title}}</span>
</h3>
<div class="i-archive__list list-unstyled" id="index-archive-group" data-list="categories" data-level="0">
<h4 class="i-archive__category-title">{{category-title}}</h4>
<div class="i-items">
<div class="thead row">
<div class="col-sm-2 date-thead">上傳日期</div>
<div class="col-sm-7 title-thead">標題</div>
<div class="col-sm-3 file-thead">檔案下載</div>
</div>
<div class="tbody">
<div class="i-archive__category-list list-unstyled" data-list="archives" data-level="1">
<div class="archive-items clearfix">
<div class="date col-sm-2">{{created_at}}</div>
<div class="head col-sm-7">
<dl class="i-archive__file" data-list="files" data-level="2">
<div class="file-name">
<a class="i-archive__file-name" href="{{file-url}}" target="_blank" title="{{file-name}}">{{file-name}}</a>
<span class="i-archive__status-wrap" data-list="statuses" data-level="2">
<span class="i-archive__status label status {{status-class}}">{{status}}</span>
</span>
</div>
</dl>
</div>
<div class="i-archive__file-list col-sm-3" data-list="files" data-level="2">
<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>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<script>
if( window.location.href.indexOf('/en/') > -1 ) {
$('.date-thead').replaceWith('<div class="col-sm-2 date-thead-en">Updated At</div>')
$('.title-thead').replaceWith('<div class="col-sm-7 title-thead-en">Title</div>')
$('.file-thead').replaceWith('<div class="col-sm-3 file-thead-en">Download file</div>')
}
</script>

View File

@ -0,0 +1,42 @@
<div class="i-archive index-archive-5">
<h3 class="i-archive-title">
<span>{{page-title}}</span>
</h3>
<div class="i-archive__list list-unstyled" id="index-archive-group" data-list="categories" data-level="0">
<h4 class="i-archive__category-title">{{category-title}}</h4>
<div class="i-items">
<div class="thead row">
<div class="col-sm-2 date-thead">上傳日期</div>
<div class="col-sm-3 title-thead">標題</div>
<div class="col-sm-3 description-thead" style="border-right: 0.05em solid #333;">{{description-head}}</div>
<div class="col-sm-2 file-thead">檔案下載</div>
</div>
<div class="tbody">
<div class="i-archive__category-list list-unstyled" data-list="archives" data-level="1">
<div class="archive-items clearfix">
<div class="date col-sm-2">{{created_at}}</div>
<div class="head col-sm-3">
{{archive-title}}
<span class="i-archive__status-wrap" data-list="statuses" data-level="2">
<span class="i-archive__status label status {{status-class}}">{{status}}</span>
</span>
</div>
<div class="description col-sm-3">{{description}}</div>
<div class="i-archive__file-list col-sm-2" 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>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<script>
if( window.location.href.indexOf('/en/') > -1 ) {
$('.date-thead').replaceWith('<div class="col-sm-2 date-thead-en">Updated At</div>')
$('.title-thead').replaceWith('<div class="col-sm-7 title-thead-en">Title</div>')
$('.file-thead').replaceWith('<div class="col-sm-3 file-thead-en">Download file</div>')
}
</script>

View File

@ -0,0 +1,48 @@
<div class="i-archive index-archive-6">
<h3 class="i-archive-title">
<span>{{page-title}}</span>
</h3>
<div class="i-archive__list list-unstyled" id="index-archive-group" data-list="categories" data-level="0">
<h4 class="i-archive__category-title">{{category-title}}</h4>
<div class="i-items">
<div class="thead row">
<div class="col-sm-2 date-thead">上傳日期</div>
<div class="col-sm-3 title-thead">標題</div>
<div class="col-sm-3 description-thead">{{description-head}}</div>
<div class="col-sm-2 file-thead">檔案下載</div>
</div>
<div class="tbody">
<div class="i-archive__category-list list-unstyled" data-list="archives" data-level="1">
<div class="archive-items clearfix">
<div class="date col-sm-2">{{created_at}}</div>
<div class="head col-sm-3">
<dl class="i-archive__file" data-list="files" data-level="2">
<div class="file-name">
<a class="i-archive__file-name" href="{{file-url}}" target="_blank" title="{{file-name}}">{{file-name}}</a>
<span class="i-archive__status-wrap" data-list="statuses" data-level="2">
<span class="i-archive__status label status {{status-class}}">{{status}}</span>
</span>
</div>
</dl>
</div>
<div class="description col-sm-3">{{description}}</div>
<div class="i-archive__file-list col-sm-2" data-list="files" data-level="2">
<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>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<script>
if( window.location.href.indexOf('/en/') > -1 ) {
$('.date-thead').replaceWith('<div class="col-sm-2 date-thead-en">Updated At</div>')
$('.title-thead').replaceWith('<div class="col-sm-7 title-thead-en">Title</div>')
$('.file-thead').replaceWith('<div class="col-sm-3 file-thead-en">Download file</div>')
}
</script>

86
modules/archive/info.json Normal file
View File

@ -0,0 +1,86 @@
{
"frontend": [
{
"filename" : "archive_index1",
"name" : {
"zh_tw" : "1. 列表 ( 模組標題, 類別標題, 檔案名稱, 下載連結 )",
"en" : "1. List (widget-title, category, filename, download link)"
},
"thumbnail" : "ar1.png"
},
{
"filename" : "archive_index2",
"name" : {
"zh_tw" : "2. 手風琴式列表 ( 模組標題, 類別標題, 檔案名稱, 下載連結 )",
"en" : "2. Accordion list (widget-title, category, filename, download link)"
},
"thumbnail" : "ar2.png"
},
{
"filename" : "archive_index3",
"name" : {
"zh_tw" : "3. 列表( 無檔案名稱 ) ( 模組標題, 類別標題, 下載連結 )",
"en" : "3. List(no filename) (widget-title, category, download link)"
},
"thumbnail" : "ar3.png"
},
{
"filename" : "archive_index4",
"name" : {
"zh_tw" : "4. 手風琴式列表( 無檔案名稱 ( 模組標題, 類別標題, 下載連結 )",
"en" : "4. Accordion list(no filename) (widget-title, category, download link)"
},
"thumbnail" : "ar4.png"
},
{
"filename" : "archive_index5",
"name" : {
"zh_tw" : "5. 表格列表 ( 模組標題, 類別標題, 檔案名稱, 下載連結 )",
"en" : "5. Table list (widget-title, category, filename, download link)"
},
"thumbnail" : "ar5.png"
},
{
"filename" : "archive_index6",
"name" : {
"zh_tw" : "6. 表格列表 ( 模組標題, 檔案名稱, 下載連結 )",
"en" : "6. Table list (widget-title, filename, download link)"
},
"thumbnail" : "ar5.png"
},
{
"filename" : "archive_index7",
"name" : {
"zh_tw" : "7. 表格列表 ( 模組標題, 類別標題, 檔案名稱, 檔案簡介, 下載連結 )",
"en" : "7. Table list (widget-title, category, filename, download link)"
},
"thumbnail" : "ar5.png"
},
{
"filename" : "archive_index8",
"name" : {
"zh_tw" : "8. 表格列表 ( 模組標題, 檔案名稱, 檔案簡介, 下載連結 )",
"en" : "8. Table list (widget-title, filename, download link)"
},
"thumbnail" : "ar5.png"
}
],
"widgets" : [
{
"filename" : "archive_widget1",
"name" : {
"zh_tw" : "1. 列表 ( 模組標題, 類別標題, 檔案名稱, 下載頁面連結 )",
"en" : "1. List (widget-title, category, link of download page)"
},
"thumbnail" : "thumb.png"
},
{
"filename" : "archive_widget2",
"name" : {
"zh_tw" : "2. 手風琴式列表 ( 模組標題, 類別標題, 下載頁面連結 )",
"en" : "2. Accordion list (widget-title, category, link of download page)"
},
"thumbnail" : "thumb.png"
}
]
}

View File

@ -0,0 +1,21 @@
<div class="show-archive">
<h1 class="show-title">
<span>{{title}}</span>
</h1>
<div class="show-archive-body">
<dl class="dl-horizontal show-archive-item-group" data-list="archives" data-level="1">
<dt class="show-archive-item-list">
<sapn class="show-archive-item-title">{{archive-title}}</span>
<span data-list="statuses" data-level="2">
<span class="label status {{status-class}}">{{status}}</span>
</span>
</dt>
<dl class="show-archives-files-list" data-list="files" data-level="2">
<dd>
<a href="{{file-url}}" class="show-archives-files-item" target="_blank">{{file-name}}</a>
<span class="label label-primary">{{file-type}}</span>
</dd>
</dl>
</dl>
</div>
</div>

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.0 KiB