hancock_cms_faq 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (69) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +9 -0
  3. data/.ruby-gemset +1 -0
  4. data/.ruby-version +1 -0
  5. data/.travis.yml +4 -0
  6. data/Gemfile +4 -0
  7. data/LICENSE.txt +21 -0
  8. data/README.md +55 -0
  9. data/Rakefile +1 -0
  10. data/app/assets/javascripts/hancock/faq.coffee +6 -0
  11. data/app/assets/javascripts/hancock/faq/form.coffee +9 -0
  12. data/app/assets/javascripts/hancock/faq/init.coffee +2 -0
  13. data/app/assets/stylesheets/hancock/faq.sass +0 -0
  14. data/app/controllers/concerns/hancock/faq/decorators/categories.rb +17 -0
  15. data/app/controllers/concerns/hancock/faq/decorators/questions.rb +71 -0
  16. data/app/controllers/hancock/faq/categories_controller.rb +7 -0
  17. data/app/controllers/hancock/faq/questions_controller.rb +7 -0
  18. data/app/models/concerns/hancock/faq/decorators/category.rb +36 -0
  19. data/app/models/concerns/hancock/faq/decorators/question.rb +48 -0
  20. data/app/models/hancock/faq/category.rb +11 -0
  21. data/app/models/hancock/faq/question.rb +11 -0
  22. data/app/views/hancock/faq/categories/index.html.slim +10 -0
  23. data/app/views/hancock/faq/categories/show.html.slim +8 -0
  24. data/app/views/hancock/faq/questions/_fields.html.slim +11 -0
  25. data/app/views/hancock/faq/questions/_fields_with_settings.html.slim +20 -0
  26. data/app/views/hancock/faq/questions/_form.html.slim +66 -0
  27. data/app/views/hancock/faq/questions/_form_with_wrapper.html.slim +2 -0
  28. data/app/views/hancock/faq/questions/_question_block.html.slim +33 -0
  29. data/app/views/hancock/faq/questions/_simple_captcha.html.slim +16 -0
  30. data/app/views/hancock/faq/questions/_success.html.slim +3 -0
  31. data/app/views/hancock/faq/questions/create.html.slim +1 -0
  32. data/app/views/hancock/faq/questions/index.html.slim +11 -0
  33. data/app/views/hancock/faq/questions/new.html.slim +6 -0
  34. data/app/views/hancock/faq/questions/show.html.slim +8 -0
  35. data/app/views/hancock/faq/questions/update_captcha.html.slim +16 -0
  36. data/bin/console +14 -0
  37. data/bin/setup +7 -0
  38. data/config/locales/hancock.faq.ru.yml +64 -0
  39. data/hancock_cms_faq.gemspec +36 -0
  40. data/lib/generators/hancock/faq/config/config_generator.rb +13 -0
  41. data/lib/generators/hancock/faq/config/templates/hancock_faq.erb +23 -0
  42. data/lib/generators/hancock/faq/controllers/all_generator.rb +28 -0
  43. data/lib/generators/hancock/faq/controllers/category_generator.rb +43 -0
  44. data/lib/generators/hancock/faq/controllers/decorators_generator.rb +24 -0
  45. data/lib/generators/hancock/faq/controllers/question_generator.rb +43 -0
  46. data/lib/generators/hancock/faq/controllers/templates/categories_controller.erb +10 -0
  47. data/lib/generators/hancock/faq/controllers/templates/questions_controller.erb +10 -0
  48. data/lib/generators/hancock/faq/models/all_generator.rb +28 -0
  49. data/lib/generators/hancock/faq/models/category_generator.rb +43 -0
  50. data/lib/generators/hancock/faq/models/decorators_generator.rb +24 -0
  51. data/lib/generators/hancock/faq/models/question_generator.rb +34 -0
  52. data/lib/generators/hancock/faq/models/templates/category.erb +36 -0
  53. data/lib/generators/hancock/faq/models/templates/question.erb +37 -0
  54. data/lib/hancock/faq/admin.rb +6 -0
  55. data/lib/hancock/faq/admin/category.rb +128 -0
  56. data/lib/hancock/faq/admin/question.rb +104 -0
  57. data/lib/hancock/faq/configuration.rb +53 -0
  58. data/lib/hancock/faq/controllers/categories.rb +88 -0
  59. data/lib/hancock/faq/controllers/questions.rb +174 -0
  60. data/lib/hancock/faq/engine.rb +7 -0
  61. data/lib/hancock/faq/models/category.rb +50 -0
  62. data/lib/hancock/faq/models/mongoid/category.rb +33 -0
  63. data/lib/hancock/faq/models/mongoid/question.rb +72 -0
  64. data/lib/hancock/faq/models/question.rb +85 -0
  65. data/lib/hancock/faq/routes.rb +83 -0
  66. data/lib/hancock/faq/version.rb +5 -0
  67. data/lib/hancock_cms_faq.rb +31 -0
  68. data/release.sh +6 -0
  69. 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,5 @@
1
+ module Hancock
2
+ module Faq
3
+ VERSION = "1.0.2".freeze
4
+ end
5
+ 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
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/bash
2
+ bundle update
3
+ git add --all .
4
+ git commit -am "${*:1}"
5
+ git push -u origin master
6
+ rake release
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: []