hancock_cms_faq 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/.travis.yml +4 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +55 -0
- data/Rakefile +1 -0
- data/app/assets/javascripts/hancock/faq.coffee +6 -0
- data/app/assets/javascripts/hancock/faq/form.coffee +9 -0
- data/app/assets/javascripts/hancock/faq/init.coffee +2 -0
- data/app/assets/stylesheets/hancock/faq.sass +0 -0
- data/app/controllers/concerns/hancock/faq/decorators/categories.rb +17 -0
- data/app/controllers/concerns/hancock/faq/decorators/questions.rb +71 -0
- data/app/controllers/hancock/faq/categories_controller.rb +7 -0
- data/app/controllers/hancock/faq/questions_controller.rb +7 -0
- data/app/models/concerns/hancock/faq/decorators/category.rb +36 -0
- data/app/models/concerns/hancock/faq/decorators/question.rb +48 -0
- data/app/models/hancock/faq/category.rb +11 -0
- data/app/models/hancock/faq/question.rb +11 -0
- data/app/views/hancock/faq/categories/index.html.slim +10 -0
- data/app/views/hancock/faq/categories/show.html.slim +8 -0
- data/app/views/hancock/faq/questions/_fields.html.slim +11 -0
- data/app/views/hancock/faq/questions/_fields_with_settings.html.slim +20 -0
- data/app/views/hancock/faq/questions/_form.html.slim +66 -0
- data/app/views/hancock/faq/questions/_form_with_wrapper.html.slim +2 -0
- data/app/views/hancock/faq/questions/_question_block.html.slim +33 -0
- data/app/views/hancock/faq/questions/_simple_captcha.html.slim +16 -0
- data/app/views/hancock/faq/questions/_success.html.slim +3 -0
- data/app/views/hancock/faq/questions/create.html.slim +1 -0
- data/app/views/hancock/faq/questions/index.html.slim +11 -0
- data/app/views/hancock/faq/questions/new.html.slim +6 -0
- data/app/views/hancock/faq/questions/show.html.slim +8 -0
- data/app/views/hancock/faq/questions/update_captcha.html.slim +16 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/config/locales/hancock.faq.ru.yml +64 -0
- data/hancock_cms_faq.gemspec +36 -0
- data/lib/generators/hancock/faq/config/config_generator.rb +13 -0
- data/lib/generators/hancock/faq/config/templates/hancock_faq.erb +23 -0
- data/lib/generators/hancock/faq/controllers/all_generator.rb +28 -0
- data/lib/generators/hancock/faq/controllers/category_generator.rb +43 -0
- data/lib/generators/hancock/faq/controllers/decorators_generator.rb +24 -0
- data/lib/generators/hancock/faq/controllers/question_generator.rb +43 -0
- data/lib/generators/hancock/faq/controllers/templates/categories_controller.erb +10 -0
- data/lib/generators/hancock/faq/controllers/templates/questions_controller.erb +10 -0
- data/lib/generators/hancock/faq/models/all_generator.rb +28 -0
- data/lib/generators/hancock/faq/models/category_generator.rb +43 -0
- data/lib/generators/hancock/faq/models/decorators_generator.rb +24 -0
- data/lib/generators/hancock/faq/models/question_generator.rb +34 -0
- data/lib/generators/hancock/faq/models/templates/category.erb +36 -0
- data/lib/generators/hancock/faq/models/templates/question.erb +37 -0
- data/lib/hancock/faq/admin.rb +6 -0
- data/lib/hancock/faq/admin/category.rb +128 -0
- data/lib/hancock/faq/admin/question.rb +104 -0
- data/lib/hancock/faq/configuration.rb +53 -0
- data/lib/hancock/faq/controllers/categories.rb +88 -0
- data/lib/hancock/faq/controllers/questions.rb +174 -0
- data/lib/hancock/faq/engine.rb +7 -0
- data/lib/hancock/faq/models/category.rb +50 -0
- data/lib/hancock/faq/models/mongoid/category.rb +33 -0
- data/lib/hancock/faq/models/mongoid/question.rb +72 -0
- data/lib/hancock/faq/models/question.rb +85 -0
- data/lib/hancock/faq/routes.rb +83 -0
- data/lib/hancock/faq/version.rb +5 -0
- data/lib/hancock_cms_faq.rb +31 -0
- data/release.sh +6 -0
- metadata +159 -0
@@ -0,0 +1,85 @@
|
|
1
|
+
module Hancock::Faq
|
2
|
+
module Models
|
3
|
+
module Question
|
4
|
+
extend ActiveSupport::Concern
|
5
|
+
include Hancock::Model
|
6
|
+
include Hancock::Enableable
|
7
|
+
|
8
|
+
if Hancock::Faq.config.seo_support
|
9
|
+
include Hancock::Seo::Seoable
|
10
|
+
include Hancock::Seo::SitemapDataField
|
11
|
+
end
|
12
|
+
|
13
|
+
if Hancock::Pages.config.cache_support
|
14
|
+
include Hancock::Cache::Cacheable
|
15
|
+
end
|
16
|
+
|
17
|
+
include ManualSlug
|
18
|
+
|
19
|
+
include Hancock::Faq.orm_specific('Question')
|
20
|
+
|
21
|
+
included do
|
22
|
+
if Hancock.rails4?
|
23
|
+
belongs_to :main_category, class_name: "Hancock::Faq::Category", inverse_of: nil
|
24
|
+
else
|
25
|
+
belongs_to :main_category, class_name: "Hancock::Faq::Category", inverse_of: nil, optional: true
|
26
|
+
end
|
27
|
+
before_validation :set_default_main_category
|
28
|
+
def set_default_main_category(force = false)
|
29
|
+
if force or main_category.blank? or !main_category.enabled and self.respond_to?(:categories)
|
30
|
+
self.main_category = self.categories.enabled.sorted.first
|
31
|
+
end
|
32
|
+
self.categories << self.main_category if self.main_category
|
33
|
+
self
|
34
|
+
end
|
35
|
+
|
36
|
+
if Hancock::Feedback.config.model_settings_support
|
37
|
+
include RailsAdminModelSettings::ModelSettingable
|
38
|
+
end
|
39
|
+
|
40
|
+
manual_slug :full_name
|
41
|
+
|
42
|
+
if Hancock::Faq.config.simple_captcha_support
|
43
|
+
include SimpleCaptcha::ModelHelpers
|
44
|
+
apply_simple_captcha message: Hancock::Faq.configuration.captcha_error_message
|
45
|
+
end
|
46
|
+
|
47
|
+
validates_email_format_of :author_email
|
48
|
+
if Hancock::Faq.config.author_name_required
|
49
|
+
validates_presence_of :author_name
|
50
|
+
end
|
51
|
+
validates_presence_of :question_text, :author_email
|
52
|
+
|
53
|
+
def self.manager_can_add_actions
|
54
|
+
ret = [:nested_set]
|
55
|
+
ret << :model_settings if Hancock::Faq.config.model_settings_support
|
56
|
+
# ret << :model_accesses if Hancock::Faq.config.user_abilities_support
|
57
|
+
ret << :hancock_touch if Hancock::Faq.config.cache_support
|
58
|
+
ret += [:comments, :model_comments] if Hancock::Faq.config.ra_comments_support
|
59
|
+
ret.freeze
|
60
|
+
end
|
61
|
+
def self.rails_admin_add_visible_actions
|
62
|
+
ret = [:nested_set]
|
63
|
+
ret << :model_settings if Hancock::Faq.config.model_settings_support
|
64
|
+
ret << :model_accesses if Hancock::Faq.config.user_abilities_support
|
65
|
+
ret << :hancock_touch if Hancock::Faq.config.cache_support
|
66
|
+
ret += [:comments, :model_comments] if Hancock::Faq.config.ra_comments_support
|
67
|
+
ret.freeze
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
def name
|
72
|
+
"#{self.question_text_output} (#{self.author_name_output})".freeze
|
73
|
+
end
|
74
|
+
|
75
|
+
def full_name
|
76
|
+
"#{self.author_name_output}: \"#{self.question_text_output}\"".freeze
|
77
|
+
end
|
78
|
+
|
79
|
+
def category_class
|
80
|
+
Hancock::Faq::Category
|
81
|
+
end
|
82
|
+
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
@@ -0,0 +1,83 @@
|
|
1
|
+
module ActionDispatch::Routing
|
2
|
+
class Mapper
|
3
|
+
def hancock_cms_faq_routes(config = {})
|
4
|
+
routes_config = {
|
5
|
+
use_questions_path: true,
|
6
|
+
use_categories_path: true,
|
7
|
+
use_faq_path: true,
|
8
|
+
faq_path: '/',
|
9
|
+
faq_scope: '/faq',
|
10
|
+
classes: {
|
11
|
+
questions: :questions,
|
12
|
+
categories: :categories,
|
13
|
+
faq_controller: :categories
|
14
|
+
},
|
15
|
+
paths: {
|
16
|
+
questions: :questions,
|
17
|
+
categories: :categories
|
18
|
+
},
|
19
|
+
pagination: {
|
20
|
+
questions: true,
|
21
|
+
categories: true,
|
22
|
+
category_questions: true
|
23
|
+
},
|
24
|
+
actions: {
|
25
|
+
questions: [:show, :create],
|
26
|
+
categories: [:show],
|
27
|
+
}
|
28
|
+
}
|
29
|
+
routes_config.deep_merge!(config)
|
30
|
+
|
31
|
+
generate_hancock_faq_user_routes(routes_config)
|
32
|
+
generate_hancock_faq_cms_routes(routes_config)
|
33
|
+
end
|
34
|
+
|
35
|
+
|
36
|
+
private
|
37
|
+
def generate_hancock_faq_user_routes(routes_config)
|
38
|
+
if !routes_config[:use_questions_path] and !routes_config[:classes][:questions].nil?
|
39
|
+
resources routes_config[:classes][:questions].to_sym, only: routes_config[:actions][:questions], path: routes_config[:paths][:questions] do
|
40
|
+
get '(/page/:page)', action: :index, on: :collection, as: "" if routes_config[:pagination][:questions]
|
41
|
+
end
|
42
|
+
get "sent" => "#{routes_config[:classes][:questions]}#sent"
|
43
|
+
get "update_captcha" => "#{routes_config[:classes][:questions]}#update_captcha"
|
44
|
+
end
|
45
|
+
|
46
|
+
if !routes_config[:use_categories_path] and !routes_config[:classes][:categories].nil?
|
47
|
+
resources routes_config[:classes][:categories].to_sym, only: routes_config[:actions][:categories], path: routes_config[:paths][:categories] do
|
48
|
+
get '(/page/:page)', action: :index, on: :collection, as: "" if routes_config[:pagination][:categories]
|
49
|
+
get 'questions(/page/:page)', action: :questions, on: :member, as: :questions if routes_config[:pagination][:category_questions]
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
if !routes_config[:use_faq_path] and !routes_config[:classes][:faq_controller].nil?
|
54
|
+
get "#{routes_config[:faq_path]}" => "#{routes_config[:classes][:faq_controller]}#index"
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
def generate_hancock_faq_cms_routes(routes_config)
|
59
|
+
scope module: 'hancock' do
|
60
|
+
scope routes_config[:faq_scope], module: 'faq' do
|
61
|
+
if routes_config[:use_questions_path] and !routes_config[:classes][:questions].nil?
|
62
|
+
resources routes_config[:classes][:questions].to_sym, only: routes_config[:actions][:questions], path: routes_config[:paths][:questions], as: :hancock_faq_questions do
|
63
|
+
get '(/page/:page)', action: :index, on: :collection, as: "" if routes_config[:pagination][:questions]
|
64
|
+
end
|
65
|
+
get "sent" => "#{routes_config[:classes][:questions]}#sent"
|
66
|
+
get "update_captcha" => "#{routes_config[:classes][:questions]}#update_captcha"
|
67
|
+
end
|
68
|
+
|
69
|
+
if routes_config[:use_categories_path] and !routes_config[:classes][:categories].nil?
|
70
|
+
resources routes_config[:classes][:categories].to_sym, only: routes_config[:actions][:categories], path: routes_config[:paths][:categories], as: :hancock_faq_categories do
|
71
|
+
get '(/page/:page)', action: :index, on: :collection, as: "" if routes_config[:pagination][:categories]
|
72
|
+
get 'questions(/page/:page)', action: :items, on: :member, as: :questions if routes_config[:pagination][:category_questions]
|
73
|
+
end
|
74
|
+
end
|
75
|
+
if routes_config[:use_faq_path] and !routes_config[:classes][:faq_controller].nil?
|
76
|
+
get "#{routes_config[:faq_path]}" => "#{routes_config[:classes][:faq_controller]}#index", as: :hancock_faq
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
end
|
83
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require "hancock/faq/version"
|
2
|
+
|
3
|
+
require 'hancock/faq/routes'
|
4
|
+
|
5
|
+
require 'hancock/faq/configuration'
|
6
|
+
require 'hancock/faq/engine'
|
7
|
+
|
8
|
+
module Hancock::Faq
|
9
|
+
include Hancock::Plugin
|
10
|
+
|
11
|
+
autoload :Admin, 'hancock/faq/admin'
|
12
|
+
module Admin
|
13
|
+
autoload :Question, 'hancock/faq/admin/question'
|
14
|
+
autoload :Category, 'hancock/faq/admin/category'
|
15
|
+
end
|
16
|
+
|
17
|
+
module Models
|
18
|
+
autoload :Question, 'hancock/faq/models/question'
|
19
|
+
autoload :Category, 'hancock/faq/models/category'
|
20
|
+
|
21
|
+
module Mongoid
|
22
|
+
autoload :Question, 'hancock/faq/models/mongoid/question'
|
23
|
+
autoload :Category, 'hancock/faq/models/mongoid/category'
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
module Controllers
|
28
|
+
autoload :Questions, 'hancock/faq/controllers/questions'
|
29
|
+
autoload :Categories, 'hancock/faq/controllers/categories'
|
30
|
+
end
|
31
|
+
end
|
data/release.sh
ADDED
metadata
ADDED
@@ -0,0 +1,159 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: hancock_cms_faq
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Alexander Kiseliev
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-04-01 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.10'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.10'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: hancock_cms
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 1.0.2
|
48
|
+
- - "<"
|
49
|
+
- !ruby/object:Gem::Version
|
50
|
+
version: 2.1.x
|
51
|
+
type: :runtime
|
52
|
+
prerelease: false
|
53
|
+
version_requirements: !ruby/object:Gem::Requirement
|
54
|
+
requirements:
|
55
|
+
- - ">="
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: 1.0.2
|
58
|
+
- - "<"
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: 2.1.x
|
61
|
+
description: FAQ system with HancockCMS support.
|
62
|
+
email:
|
63
|
+
- dev@redrocks.pro
|
64
|
+
executables: []
|
65
|
+
extensions: []
|
66
|
+
extra_rdoc_files: []
|
67
|
+
files:
|
68
|
+
- ".gitignore"
|
69
|
+
- ".ruby-gemset"
|
70
|
+
- ".ruby-version"
|
71
|
+
- ".travis.yml"
|
72
|
+
- Gemfile
|
73
|
+
- LICENSE.txt
|
74
|
+
- README.md
|
75
|
+
- Rakefile
|
76
|
+
- app/assets/javascripts/hancock/faq.coffee
|
77
|
+
- app/assets/javascripts/hancock/faq/form.coffee
|
78
|
+
- app/assets/javascripts/hancock/faq/init.coffee
|
79
|
+
- app/assets/stylesheets/hancock/faq.sass
|
80
|
+
- app/controllers/concerns/hancock/faq/decorators/categories.rb
|
81
|
+
- app/controllers/concerns/hancock/faq/decorators/questions.rb
|
82
|
+
- app/controllers/hancock/faq/categories_controller.rb
|
83
|
+
- app/controllers/hancock/faq/questions_controller.rb
|
84
|
+
- app/models/concerns/hancock/faq/decorators/category.rb
|
85
|
+
- app/models/concerns/hancock/faq/decorators/question.rb
|
86
|
+
- app/models/hancock/faq/category.rb
|
87
|
+
- app/models/hancock/faq/question.rb
|
88
|
+
- app/views/hancock/faq/categories/index.html.slim
|
89
|
+
- app/views/hancock/faq/categories/show.html.slim
|
90
|
+
- app/views/hancock/faq/questions/_fields.html.slim
|
91
|
+
- app/views/hancock/faq/questions/_fields_with_settings.html.slim
|
92
|
+
- app/views/hancock/faq/questions/_form.html.slim
|
93
|
+
- app/views/hancock/faq/questions/_form_with_wrapper.html.slim
|
94
|
+
- app/views/hancock/faq/questions/_question_block.html.slim
|
95
|
+
- app/views/hancock/faq/questions/_simple_captcha.html.slim
|
96
|
+
- app/views/hancock/faq/questions/_success.html.slim
|
97
|
+
- app/views/hancock/faq/questions/create.html.slim
|
98
|
+
- app/views/hancock/faq/questions/index.html.slim
|
99
|
+
- app/views/hancock/faq/questions/new.html.slim
|
100
|
+
- app/views/hancock/faq/questions/show.html.slim
|
101
|
+
- app/views/hancock/faq/questions/update_captcha.html.slim
|
102
|
+
- bin/console
|
103
|
+
- bin/setup
|
104
|
+
- config/locales/hancock.faq.ru.yml
|
105
|
+
- hancock_cms_faq.gemspec
|
106
|
+
- lib/generators/hancock/faq/config/config_generator.rb
|
107
|
+
- lib/generators/hancock/faq/config/templates/hancock_faq.erb
|
108
|
+
- lib/generators/hancock/faq/controllers/all_generator.rb
|
109
|
+
- lib/generators/hancock/faq/controllers/category_generator.rb
|
110
|
+
- lib/generators/hancock/faq/controllers/decorators_generator.rb
|
111
|
+
- lib/generators/hancock/faq/controllers/question_generator.rb
|
112
|
+
- lib/generators/hancock/faq/controllers/templates/categories_controller.erb
|
113
|
+
- lib/generators/hancock/faq/controllers/templates/questions_controller.erb
|
114
|
+
- lib/generators/hancock/faq/models/all_generator.rb
|
115
|
+
- lib/generators/hancock/faq/models/category_generator.rb
|
116
|
+
- lib/generators/hancock/faq/models/decorators_generator.rb
|
117
|
+
- lib/generators/hancock/faq/models/question_generator.rb
|
118
|
+
- lib/generators/hancock/faq/models/templates/category.erb
|
119
|
+
- lib/generators/hancock/faq/models/templates/question.erb
|
120
|
+
- lib/hancock/faq/admin.rb
|
121
|
+
- lib/hancock/faq/admin/category.rb
|
122
|
+
- lib/hancock/faq/admin/question.rb
|
123
|
+
- lib/hancock/faq/configuration.rb
|
124
|
+
- lib/hancock/faq/controllers/categories.rb
|
125
|
+
- lib/hancock/faq/controllers/questions.rb
|
126
|
+
- lib/hancock/faq/engine.rb
|
127
|
+
- lib/hancock/faq/models/category.rb
|
128
|
+
- lib/hancock/faq/models/mongoid/category.rb
|
129
|
+
- lib/hancock/faq/models/mongoid/question.rb
|
130
|
+
- lib/hancock/faq/models/question.rb
|
131
|
+
- lib/hancock/faq/routes.rb
|
132
|
+
- lib/hancock/faq/version.rb
|
133
|
+
- lib/hancock_cms_faq.rb
|
134
|
+
- release.sh
|
135
|
+
homepage: https://github.com/red-rocks/hancock_cms_faq
|
136
|
+
licenses:
|
137
|
+
- MIT
|
138
|
+
metadata: {}
|
139
|
+
post_install_message:
|
140
|
+
rdoc_options: []
|
141
|
+
require_paths:
|
142
|
+
- lib
|
143
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
144
|
+
requirements:
|
145
|
+
- - ">="
|
146
|
+
- !ruby/object:Gem::Version
|
147
|
+
version: '0'
|
148
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - ">="
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '0'
|
153
|
+
requirements: []
|
154
|
+
rubyforge_project:
|
155
|
+
rubygems_version: 2.5.1
|
156
|
+
signing_key:
|
157
|
+
specification_version: 4
|
158
|
+
summary: FAQ system with HancockCMS support.
|
159
|
+
test_files: []
|