From f97ccb04362bf8ecb505073ba19262668cd2f5ef Mon Sep 17 00:00:00 2001 From: Harry Bomrah Date: Fri, 23 May 2014 14:03:16 +0800 Subject: [PATCH] added widget and engine settings --- app/controllers/faqs_controller.rb | 14 ++++++++++++++ lib/faq/engine.rb | 3 ++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/app/controllers/faqs_controller.rb b/app/controllers/faqs_controller.rb index 5acb529..9e52db1 100644 --- a/app/controllers/faqs_controller.rb +++ b/app/controllers/faqs_controller.rb @@ -33,4 +33,18 @@ class FaqsController < ApplicationController "faqs_files" => faqs_files } end + + def widget + faqs = Qa.filter_by_widget_categories.collect do |qa| + { + "link_to_show" => OrbitHelper.url_to_show(qa.to_param), + "title" => qa.title, + "postdate" => qa.created_at.strftime('%Y-%m-%d %H:%M') + } + end + { + "faqs" => faqs, + "extras" => {"widget-title"=>"Faqs"} + } + end end \ No newline at end of file diff --git a/lib/faq/engine.rb b/lib/faq/engine.rb index 4fb1197..c917628 100644 --- a/lib/faq/engine.rb +++ b/lib/faq/engine.rb @@ -4,7 +4,8 @@ module Faq OrbitApp.registration "Faq", :type => "ModuleApp" do module_label "faq.faq" base_url File.expand_path File.dirname(__FILE__) - + widget_methods ['widget'] + widget_settings [{"data_count"=>10}] taggable "Qa" categorizable authorizable