diff --git a/app/controllers/faqs_controller.rb b/app/controllers/faqs_controller.rb index 895e39d..2b48ae2 100644 --- a/app/controllers/faqs_controller.rb +++ b/app/controllers/faqs_controller.rb @@ -1,18 +1,25 @@ class FaqsController < ApplicationController def index faqs = Qa.can_display.order_by(:order_position => "asc").filter_by_categories - f = faqs.collect do |qa| + f = faqs.collect do |qa| statuses = qa.statuses_with_classname.collect do |status| { "status" => status["name"], "status-class" => "status-#{status['classname']}" } end + qa_files = qa.qa_files.map do |qa_file| + { + "file_url" => qa_file.file.url, + "file_title" => qa_file.title.blank? ? File.basename(qa_file["file"]) + } + end { "link_to_show" => OrbitHelper.url_to_show(qa.to_param), "question" => qa.title, "answer" => qa.answer, - "statuses" => statuses + "statuses" => statuses, + "qa_files" => qa_files } end { diff --git a/faq.gemspec b/faq.gemspec index 4162312..795c845 100644 --- a/faq.gemspec +++ b/faq.gemspec @@ -2,7 +2,18 @@ $:.push File.expand_path("../lib", __FILE__) # Maintain your gem's version: require "faq/version" - +app_path = File.expand_path(__dir__) +all_template = Dir.glob(template_path+'/*/') +all_template.each do |folder| + if !folder.include?('mobile') + begin + puts "updating faq index page" + 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 faq index page." + end + end +end # Describe your gem and declare its dependencies: Gem::Specification.new do |s| s.name = "faq" diff --git a/modules/faq/_faq_widget1.html.erb b/modules/faq/_faq_widget1.html.erb new file mode 100644 index 0000000..357ac03 --- /dev/null +++ b/modules/faq/_faq_widget1.html.erb @@ -0,0 +1,15 @@ +
+

+ {{widget-title}} +

+ +

+ <%= (I18n.locale.to_s =="zh_tw") ? "更多資訊" : "More" %>

+
\ No newline at end of file diff --git a/modules/faq/faq_index1.html.erb b/modules/faq/faq_index1.html.erb new file mode 100644 index 0000000..63b7fad --- /dev/null +++ b/modules/faq/faq_index1.html.erb @@ -0,0 +1,16 @@ +
+

+ {{page-title}} +

+ +
+{{pagination_goes_here}} \ No newline at end of file diff --git a/modules/faq/faq_index2.html.erb b/modules/faq/faq_index2.html.erb new file mode 100644 index 0000000..8db071d --- /dev/null +++ b/modules/faq/faq_index2.html.erb @@ -0,0 +1,31 @@ +
+

+ {{page-title}} +

+ +
+{{pagination_goes_here}} + + \ No newline at end of file diff --git a/modules/faq/info.json b/modules/faq/info.json new file mode 100644 index 0000000..5cefb92 --- /dev/null +++ b/modules/faq/info.json @@ -0,0 +1,30 @@ +{ + "frontend": [ + { + "filename" : "faq_index1", + "name" : { + "zh_tw" : "1. 列表 ( 模組標題, 問題 )", + "en" : "1. Thumbnail ( widget-title, question )" + }, + "thumbnail" : "thumb.png" + }, + { + "filename" : "faq_index2", + "name" : { + "zh_tw" : "2. 手風琴列表 ( 模組標題, 問題 )", + "en" : "2. Accordion list ( widget-title, question )" + }, + "thumbnail" : "thumb.png" + } + ], + "widgets" : [ + { + "filename" : "faq_widget1", + "name" : { + "zh_tw" : "1. 列表 ( 模組標題, 問題 )", + "en" : "1. List (widget-title, question)" + }, + "thumbnail" : "thumb.png" + } + ] +} \ No newline at end of file diff --git a/modules/faq/show.html.erb b/modules/faq/show.html.erb new file mode 100644 index 0000000..e003463 --- /dev/null +++ b/modules/faq/show.html.erb @@ -0,0 +1,20 @@ +
+
+

{{question}}

+
+ + + {{tag}} + +
+

{{answer}}

+
+
+ {{file_title}}
+
+
+ {{link_title}}
+
+
+ +{{link_to_edit}} \ No newline at end of file diff --git a/modules/faq/thumbs/thumb.png b/modules/faq/thumbs/thumb.png new file mode 100644 index 0000000..266af56 Binary files /dev/null and b/modules/faq/thumbs/thumb.png differ