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,33 @@
|
|
1
|
+
- _cache_helper = (Hancock::Faq.config.cache_support ? :hancock_cache : :cache)
|
2
|
+
|
3
|
+
- send _cache_helper, q do
|
4
|
+
.qtable
|
5
|
+
- _category = q.main_category
|
6
|
+
- if _category and _category.enabled
|
7
|
+
= link_to _category.name, hancock_faq_category_path(_category), title: _category.name
|
8
|
+
|
9
|
+
.qtext_block
|
10
|
+
.questionblock
|
11
|
+
.questiontext
|
12
|
+
.qname
|
13
|
+
p= q.author_name
|
14
|
+
.qemail
|
15
|
+
p= q.author_email
|
16
|
+
.qdate
|
17
|
+
p= q.created_at
|
18
|
+
.qtext
|
19
|
+
- if q.question_text_after_editing.blank?
|
20
|
+
p== q.question_text
|
21
|
+
- else
|
22
|
+
p== q.question_text_after_editing
|
23
|
+
|
24
|
+
.answertext
|
25
|
+
- if q.answered or (current_user and current_user.admin?)
|
26
|
+
.aqname
|
27
|
+
p= q.answer_author_name
|
28
|
+
.aqdate
|
29
|
+
p= q.answered_time
|
30
|
+
.aqtext
|
31
|
+
p== q.answer_text
|
32
|
+
|
33
|
+
.mentionsdivider
|
@@ -0,0 +1,16 @@
|
|
1
|
+
ruby:
|
2
|
+
if Hancock::Faq.config.model_settings_support
|
3
|
+
settings_scope ||= Hancock::Faq::Question.settings
|
4
|
+
elsif defined?(Settings)
|
5
|
+
settings_scope ||= Settings.ns('FAQ')
|
6
|
+
end
|
7
|
+
|
8
|
+
- label = t('hancock.faq_plugin.fields.captcha.label')
|
9
|
+
- placeholder = t('hancock.faq_plugin.fields.captcha.placeholder')
|
10
|
+
- update_captcha = link_to ' (обн)', hancock_faq_question_update_captcha_path, class: 'update_captcha_link'
|
11
|
+
- if Hancock::Faq.config.model_settings_support
|
12
|
+
- label = settings_scope.simple_captcha_label(default: label, label: "Заголовок поля Код проверки")
|
13
|
+
- placeholder = settings_scope.simple_captcha_placeholder(default: placeholder, label: "Placeholder поля Код проверки")
|
14
|
+
= f.input :captcha, as: :simple_captcha, label: label, input_html: {placeholder: placeholder, update_captcha: update_captcha}, required: true
|
15
|
+
- else
|
16
|
+
= f.input :captcha, as: :simple_captcha, label: label, input_html: {placeholder: placeholder, update_captcha: update_captcha}, required: true
|
@@ -0,0 +1 @@
|
|
1
|
+
= render partial: "hancock/faq/questions/form_with_wrapper"
|
@@ -0,0 +1,11 @@
|
|
1
|
+
- _partial_path = (Hancock::Faq.config.seo_support ? 'shared/obj_with_seo' : 'shared/obj')
|
2
|
+
= render _partial_path, obj: (@seo_page || @seo_parent_page)
|
3
|
+
|
4
|
+
|
5
|
+
- @questions.each do |q|
|
6
|
+
.question_block{data-question-id="#{q._id.to_s}"}
|
7
|
+
= render partial: "hancock/faq/questions/question_block", locals: {q: q}
|
8
|
+
|
9
|
+
.newquestionform
|
10
|
+
p.newquestiontitle Задать свой вопрос:
|
11
|
+
= render partial: "hancock/faq/questions/form_with_wrapper"
|
@@ -0,0 +1,6 @@
|
|
1
|
+
- _partial_path = (Hancock::Faq.config.seo_support ? 'shared/obj_with_seo' : 'shared/obj')
|
2
|
+
= render _partial_path, obj: (@seo_page || @seo_parent_page)
|
3
|
+
|
4
|
+
.newquestionform
|
5
|
+
p.newquestiontitle Задать свой вопрос:
|
6
|
+
= render partial: "hancock/faq/questions/form_with_wrapper"
|
@@ -0,0 +1,8 @@
|
|
1
|
+
/ - _cache_helper = (Hancock::Faq.config.cache_support ? :hancock_cache : :cache)
|
2
|
+
|
3
|
+
- _partial_path = (Hancock::Faq.config.seo_support ? 'shared/obj_with_seo' : 'shared/obj')
|
4
|
+
= render _partial_path, obj: @question
|
5
|
+
|
6
|
+
|
7
|
+
.question_block{data-question-id="#{@question._id.to_s}"}
|
8
|
+
= render partial: "hancock/faq/questions/question_block", locals: {q: @question}
|
@@ -0,0 +1,16 @@
|
|
1
|
+
.input.simple_captcha.required.hancock_feedback_contact_message_captcha
|
2
|
+
- if Hancock::Feedback.config.captcha and Hancock::Feedback.config.simple_captcha_support
|
3
|
+
ruby:
|
4
|
+
options = {
|
5
|
+
label: t('hancock.feedback_plugin.fields.captcha.label'),
|
6
|
+
placeholder: t('hancock.feedback_plugin.fields.captcha.placeholder'),
|
7
|
+
update_captcha: link_to(' (обн)', hancock_feedback_update_captcha_path, class: 'update_captcha_link'),
|
8
|
+
object: Hancock::Feedback::ContactMessage.new
|
9
|
+
}
|
10
|
+
|
11
|
+
- if Hancock::Feedback.config.model_settings_support
|
12
|
+
- options[:label] = settings_scope.simple_captcha_label(default: options[:label], label: "Заголовок поля Код проверки")
|
13
|
+
- options[:placeholder] = settings_scope.simple_captcha_placeholder(default: options[:placeholder], label: "Placeholder поля Код проверки")
|
14
|
+
= show_simple_captcha options
|
15
|
+
- else
|
16
|
+
= show_simple_captcha options
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "hancock_cms_faq"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
ru:
|
2
|
+
hancock:
|
3
|
+
faq: FAQ
|
4
|
+
breadcrumbs:
|
5
|
+
faq: FAQ
|
6
|
+
errors:
|
7
|
+
faq:
|
8
|
+
recaptcha: Вы робот?
|
9
|
+
|
10
|
+
faq_plugin:
|
11
|
+
fields:
|
12
|
+
author_name:
|
13
|
+
label: 'ФИО'
|
14
|
+
placeholder: 'ФИО'
|
15
|
+
author_email:
|
16
|
+
label: E-mail
|
17
|
+
placeholder: E-mail
|
18
|
+
# phone:
|
19
|
+
# label: Телефон
|
20
|
+
# placeholder: Телефон
|
21
|
+
question_text:
|
22
|
+
label: Вопрос
|
23
|
+
placeholder: Вопрос
|
24
|
+
captcha:
|
25
|
+
label: "Введите код с картинки"
|
26
|
+
placeholder: "Введите код с картинки"
|
27
|
+
|
28
|
+
mongoid:
|
29
|
+
models:
|
30
|
+
hancock/faq/question: Вопросы
|
31
|
+
hancock/faq/category: Категории
|
32
|
+
attributes:
|
33
|
+
hancock/faq/question:
|
34
|
+
question_text: Текст вопроса
|
35
|
+
question_text_after_editing: Текст вопроса (редактированный)
|
36
|
+
author_name: Имя автора
|
37
|
+
author_name_after_editing: Имя автора (редактированное)
|
38
|
+
author_email: E-mail автора
|
39
|
+
|
40
|
+
answered: Есть ответ
|
41
|
+
answer_text: Текст ответа
|
42
|
+
answered_time: Время ответа
|
43
|
+
answer_author_name: Имя автора ответа
|
44
|
+
|
45
|
+
categories: Категории
|
46
|
+
category_ids: Категории
|
47
|
+
|
48
|
+
hancock/faq/category:
|
49
|
+
questions: Вопросы
|
50
|
+
|
51
|
+
|
52
|
+
errors:
|
53
|
+
models:
|
54
|
+
hancock/faq/question:
|
55
|
+
attributes:
|
56
|
+
author_email:
|
57
|
+
invalid_email_address: "Некорректный e-mail"
|
58
|
+
|
59
|
+
|
60
|
+
|
61
|
+
admin:
|
62
|
+
scopes:
|
63
|
+
rails_admin_settings~setting:
|
64
|
+
ns_rails_admin_model_settings_hancock_faq_question: 'FAQ'
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "hancock/faq/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "hancock_cms_faq"
|
8
|
+
spec.version = Hancock::Faq::VERSION
|
9
|
+
spec.authors = ["Alexander Kiseliev"]
|
10
|
+
spec.email = ["dev@redrocks.pro"]
|
11
|
+
|
12
|
+
spec.summary = %q{FAQ system with HancockCMS support.}
|
13
|
+
spec.description = %q{FAQ system with HancockCMS support.}
|
14
|
+
spec.homepage = "https://github.com/red-rocks/hancock_cms_faq"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
# Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
|
18
|
+
# delete this section to allow pushing this gem to any host.
|
19
|
+
# if spec.respond_to?(:metadata)
|
20
|
+
# spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'"
|
21
|
+
# else
|
22
|
+
# raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
|
23
|
+
# end
|
24
|
+
|
25
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
26
|
+
spec.bindir = "exe"
|
27
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
28
|
+
spec.require_paths = ["lib"]
|
29
|
+
|
30
|
+
spec.add_development_dependency "bundler", "~> 1.10"
|
31
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
32
|
+
|
33
|
+
spec.add_dependency 'hancock_cms', [">=1.0.2", "<2.1.x"]
|
34
|
+
# spec.add_dependency 'hancock_cms', ["~> 1.0.2", "~> 2.0"]
|
35
|
+
|
36
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'rails/generators'
|
2
|
+
|
3
|
+
module Hancock::Faq
|
4
|
+
class ConfigGenerator < Rails::Generators::Base
|
5
|
+
source_root File.expand_path('../templates', __FILE__)
|
6
|
+
|
7
|
+
desc 'Hancock::Faq Config generator'
|
8
|
+
def config
|
9
|
+
template 'hancock_faq.erb', "config/initializers/hancock_faq.rb"
|
10
|
+
end
|
11
|
+
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
Hancock::Faq.configure do |config|
|
2
|
+
##### defaults #####
|
3
|
+
# config.author_name_required = true
|
4
|
+
#
|
5
|
+
# config.default_answer_author_name = "Администрация сайта"
|
6
|
+
#
|
7
|
+
# config.captcha_error_message = "Код с картинки введен неверно"
|
8
|
+
#
|
9
|
+
# config.recaptcha_support = !!defined?(Recaptcha)
|
10
|
+
# config.simple_captcha_support = !!defined?(SimpleCaptcha)
|
11
|
+
# config.captcha = # config.recaptcha_support || # config.simple_captcha_support
|
12
|
+
#
|
13
|
+
# config.seo_support = !!defined?(Hancock::Seo)
|
14
|
+
# config.cache_support = !!defined?(Hancock::Cache)
|
15
|
+
#
|
16
|
+
# config.breadcrumbs_on_rails_support = !!defined?(BreadcrumbsOnRails)
|
17
|
+
#
|
18
|
+
# config.localize = Hancock.config.localize
|
19
|
+
#
|
20
|
+
# config.model_settings_support = !!defined?(RailsAdminModelSettings)
|
21
|
+
# config.user_abilities_support = !!defined?(RailsAdminUserAbilities)
|
22
|
+
# config.ra_comments_support = !!defined?(RailsAdminComments)
|
23
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'rails/generators'
|
2
|
+
|
3
|
+
module Hancock::Faq::Controllers
|
4
|
+
class AllGenerator < Rails::Generators::Base
|
5
|
+
source_root File.expand_path('../templates', __FILE__)
|
6
|
+
argument :class_name, type: :string
|
7
|
+
argument :category_class_name_arg, type: :string, default: ""
|
8
|
+
|
9
|
+
desc 'Hancock::Faq Controllers generator'
|
10
|
+
def all
|
11
|
+
generate "hancock:faq:controllers:question #{camelcased_class_name}"
|
12
|
+
generate "hancock:faq:controllers:category #{category_class_name}"
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
def capitalized_class_name
|
17
|
+
class_name.capitalize
|
18
|
+
end
|
19
|
+
def camelcased_class_name
|
20
|
+
class_name.camelcase
|
21
|
+
end
|
22
|
+
|
23
|
+
def category_class_name
|
24
|
+
category_class_name_arg.blank? ? "#{camelcased_class_name}Category" : category_class_name_arg
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'rails/generators'
|
2
|
+
|
3
|
+
module Hancock::Faq::Controllers
|
4
|
+
class CategoryGenerator < Rails::Generators::Base
|
5
|
+
source_root File.expand_path('../templates', __FILE__)
|
6
|
+
argument :class_name, type: :string
|
7
|
+
argument :question_class_name_arg, type: :string, default: ""
|
8
|
+
|
9
|
+
desc 'Hancock::Faq Category Controller generator'
|
10
|
+
def category
|
11
|
+
template 'categories_controller.erb', "app/controllers/#{file_name}_controller.rb"
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
def capitalized_class_name
|
16
|
+
class_name.capitalize
|
17
|
+
end
|
18
|
+
|
19
|
+
def camelcased_class_name
|
20
|
+
class_name.camelcase
|
21
|
+
end
|
22
|
+
|
23
|
+
def camelcased_pluralized_class_name
|
24
|
+
camelcased_class_name.pluralize
|
25
|
+
end
|
26
|
+
|
27
|
+
def file_name
|
28
|
+
underscored_pluralized_class_name
|
29
|
+
end
|
30
|
+
|
31
|
+
def underscored_class_name
|
32
|
+
camelcased_class_name.underscore
|
33
|
+
end
|
34
|
+
|
35
|
+
def underscored_pluralized_class_name
|
36
|
+
underscored_class_name.pluralize
|
37
|
+
end
|
38
|
+
|
39
|
+
def question_class_name
|
40
|
+
question_class_name_arg.blank? ? camelcased_class_name.sub(/Category$/, "") : question_class_name_arg
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'rails/generators'
|
2
|
+
|
3
|
+
module Hancock::Faq::Controllers
|
4
|
+
class DecoratorsGenerator < Rails::Generators::Base
|
5
|
+
source_root File.expand_path('../../../../../../app/controllers/concerns/hancock/faq/decorators', __FILE__)
|
6
|
+
argument :controllers, type: :array, default: []
|
7
|
+
|
8
|
+
desc 'Hancock::Faq Controllers generator'
|
9
|
+
def decorators
|
10
|
+
copied = false
|
11
|
+
(controllers == ['all'] ? permitted_controllers : controllers & permitted_controllers).each do |c|
|
12
|
+
copied = true
|
13
|
+
copy_file "#{c}.rb", "app/controllers/concerns/hancock/faq/decorators/#{c}.rb"
|
14
|
+
end
|
15
|
+
puts "U need to set controllers`s name. One of this: #{permitted_controllers.join(", ")}." unless copied
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
def permitted_controllers
|
20
|
+
['categories', 'questions']
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'rails/generators'
|
2
|
+
|
3
|
+
module Hancock::Faq::Controllers
|
4
|
+
class QuestionGenerator < Rails::Generators::Base
|
5
|
+
source_root File.expand_path('../templates', __FILE__)
|
6
|
+
argument :class_name, type: :string
|
7
|
+
argument :category_class_name_arg, type: :string, default: ""
|
8
|
+
|
9
|
+
desc 'Hancock::Faq Question Controller generator'
|
10
|
+
def question
|
11
|
+
template 'questions_controller.erb', "app/controllers/#{file_name}_controller.rb"
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
def capitalized_class_name
|
16
|
+
class_name.capitalize
|
17
|
+
end
|
18
|
+
|
19
|
+
def camelcased_class_name
|
20
|
+
class_name.camelcase
|
21
|
+
end
|
22
|
+
|
23
|
+
def camelcased_pluralized_class_name
|
24
|
+
camelcased_class_name.pluralize
|
25
|
+
end
|
26
|
+
|
27
|
+
def file_name
|
28
|
+
underscored_pluralized_class_name
|
29
|
+
end
|
30
|
+
|
31
|
+
def underscored_class_name
|
32
|
+
camelcased_class_name.underscore
|
33
|
+
end
|
34
|
+
|
35
|
+
def underscored_pluralized_class_name
|
36
|
+
underscored_class_name.pluralize
|
37
|
+
end
|
38
|
+
|
39
|
+
def category_class_name
|
40
|
+
category_class_name_arg.blank? ? "#{camelcased_class_name}Category" : category_class_name_arg
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|