spree-faq 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (56) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +13 -0
  3. data/.hound.yml +3 -0
  4. data/.rspec +1 -0
  5. data/.travis.yml +11 -0
  6. data/CONTRIBUTING.md +30 -0
  7. data/Gemfile +6 -0
  8. data/Guardfile +8 -0
  9. data/LICENSE.md +26 -0
  10. data/README.md +37 -0
  11. data/Rakefile +15 -0
  12. data/app/assets/javascripts/admin/spree_faq.js.coffee +23 -0
  13. data/app/assets/javascripts/store/spree_faq.js.coffee +10 -0
  14. data/app/assets/stylesheets/admin/spree_faq.css +3 -0
  15. data/app/assets/stylesheets/store/spree_faq.css.scss +18 -0
  16. data/app/controllers/spree/admin/question_categories_controller.rb +13 -0
  17. data/app/controllers/spree/faqs_controller.rb +13 -0
  18. data/app/models/spree/question.rb +7 -0
  19. data/app/models/spree/question_category.rb +9 -0
  20. data/app/overrides/add_faq_admin_tab.rb +5 -0
  21. data/app/views/spree/admin/question_categories/_question.html.erb +14 -0
  22. data/app/views/spree/admin/question_categories/edit.html.erb +38 -0
  23. data/app/views/spree/admin/question_categories/index.html.erb +48 -0
  24. data/app/views/spree/admin/question_categories/new.html.erb +19 -0
  25. data/app/views/spree/admin/question_categories/new.js.erb +2 -0
  26. data/app/views/spree/faqs/index.html.erb +29 -0
  27. data/config/locales/en.yml +22 -0
  28. data/config/locales/sv.yml +22 -0
  29. data/config/routes.rb +6 -0
  30. data/db/migrate/20090526213535_create_questions.rb +16 -0
  31. data/db/migrate/20090526213550_create_question_categories.rb +14 -0
  32. data/db/migrate/20140331032743_rename_questions_to_spree_questions.rb +5 -0
  33. data/db/migrate/20140331032751_rename_question_categories_to_spree_question_categories.rb +5 -0
  34. data/lib/generators/spree_faq/install/install_generator.rb +30 -0
  35. data/lib/spree_faq/engine.rb +21 -0
  36. data/lib/spree_faq/version.rb +16 -0
  37. data/lib/spree_faq.rb +4 -0
  38. data/script/rails +7 -0
  39. data/spec/controllers/admin/question_categories_controller_spec.rb +67 -0
  40. data/spec/controllers/faqs_controller_spec.rb +29 -0
  41. data/spec/factories/question_category_factory.rb +5 -0
  42. data/spec/factories/question_factory.rb +7 -0
  43. data/spec/features/admin/faq_spec.rb +67 -0
  44. data/spec/features/faq_spec.rb +30 -0
  45. data/spec/models/question_category_spec.rb +50 -0
  46. data/spec/models/question_spec.rb +70 -0
  47. data/spec/spec_helper.rb +30 -0
  48. data/spec/support/capybara.rb +17 -0
  49. data/spec/support/database_cleaner.rb +18 -0
  50. data/spec/support/factory_girl.rb +7 -0
  51. data/spec/support/i18n.rb +13 -0
  52. data/spec/support/spree.rb +10 -0
  53. data/spec/translations/locale_spec.rb +15 -0
  54. data/spree_faq.gemspec +46 -0
  55. data/vendor/assets/javascripts/jquery.scrollTo-min.js +11 -0
  56. metadata +381 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 61e852d5ccf4cdef6e871e7641a0eb40f5785835
4
+ data.tar.gz: abd135909a2d1f7716502a66d49401c3e6967dfd
5
+ SHA512:
6
+ metadata.gz: f72f9618e2f0b45df23481be3af9d60ff46598cdb2fd7ecdd1b2a917865d8f288a866771dd1c07bc43cfd24ec44c677d2e0bd54d251d603f358c8231fc3edecd
7
+ data.tar.gz: a4e062c254e9973d862418ec27a0842a0e5dded6365a91f1e2695e6a0e3ae1bad1e9b5015536f3569f853ead203fd854f0a546d80fa562d579f4787988fe8c18
data/.gitignore ADDED
@@ -0,0 +1,13 @@
1
+ \#*
2
+ *~
3
+ .#*
4
+ .sass-cache
5
+ .DS_Store
6
+ .bundle
7
+ coverage
8
+ Gemfile.lock
9
+ tmp
10
+ pkg
11
+ spec/dummy
12
+ .rvmrc
13
+ .localeapp
data/.hound.yml ADDED
@@ -0,0 +1,3 @@
1
+ ---
2
+ LineLength:
3
+ Enabled: false
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,11 @@
1
+ language: ruby
2
+ before_script:
3
+ - sh -e /etc/init.d/xvfb start
4
+ - export DISPLAY=:99.0
5
+ - bundle exec rake test_app
6
+ script:
7
+ - bundle exec rspec spec
8
+ rvm:
9
+ - 1.9.3
10
+ - 2.0.0
11
+ - 2.1.0
data/CONTRIBUTING.md ADDED
@@ -0,0 +1,30 @@
1
+ # Contributing
2
+
3
+ In the spirit of [free software][1], **everyone** is encouraged to help improve this project.
4
+
5
+ Here are some ways *you* can contribute:
6
+
7
+ * by using prerelease versions
8
+ * by reporting [bugs][2]
9
+ * by suggesting new features
10
+ * by writing [translations][3]
11
+ * by writing or editing documentation
12
+ * by writing specifications
13
+ * by writing code (*no patch is too small*: fix typos, add comments, clean up inconsistent whitespace)
14
+ * by refactoring code
15
+ * by resolving [issues][2]
16
+ * by reviewing patches
17
+
18
+ Starting point:
19
+
20
+ * Fork the repo
21
+ * Clone your repo
22
+ * Run `bundle install`
23
+ * Run `bundle exec rake test_app` to create the test application in `spec/test_app`
24
+ * Make your changes
25
+ * Ensure specs pass by running `bundle exec rspec spec`
26
+ * Submit your pull request
27
+
28
+ [1]: http://www.fsf.org/licensing/essays/free-sw.html
29
+ [2]: https://github.com/futhr/spree-faq/issues
30
+ [3]: http://www.localeapp.com/projects/6629
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'spree', github: 'spree/spree', branch: '2-0-stable'
4
+ gem 'spree_auth_devise', github: 'spree/spree_auth_devise', branch: '2-0-stable'
5
+
6
+ gemspec
data/Guardfile ADDED
@@ -0,0 +1,8 @@
1
+ guard 'rspec', cmd: 'bundle exec rspec', all_on_start: true do
2
+ watch('spec/spec_helper.rb') { 'spec' }
3
+ watch('config/routes.rb') { 'spec/routing' }
4
+ watch(%r{^spec/(.+)_spec\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
5
+ watch(%r{^app/(.+)_decorator\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
6
+ watch(%r{^(app|lib)/(.+)(\.rb|\.erb)$}) { |m| "spec/#{m[2]}_spec.rb" }
7
+ watch(%r{^config/locales/(.+)\.yml$}) { 'spec/translations' }
8
+ end
data/LICENSE.md ADDED
@@ -0,0 +1,26 @@
1
+ Copyright (c) 2009-2014 Josh Nussbaum, Tobias Bohwalli, and other contributors.
2
+ All rights reserved.
3
+
4
+ Redistribution and use in source and binary forms, with or without modification,
5
+ are permitted provided that the following conditions are met:
6
+
7
+ * Redistributions of source code must retain the above copyright notice,
8
+ this list of conditions and the following disclaimer.
9
+ * Redistributions in binary form must reproduce the above copyright notice,
10
+ this list of conditions and the following disclaimer in the documentation
11
+ and/or other materials provided with the distribution.
12
+ * Neither the name Spree nor the names of its contributors may be used to
13
+ endorse or promote products derived from this software without specific
14
+ prior written permission.
15
+
16
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
20
+ CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
21
+ EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
22
+ PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
23
+ PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
24
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
25
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
data/README.md ADDED
@@ -0,0 +1,37 @@
1
+ # Spree Frequently Asked Question
2
+
3
+ [![Build Status](https://travis-ci.org/futhr/spree-faq.png?branch=2-0-stable)](https://travis-ci.org/futhr/spree-faq)
4
+ [![Coverage Status](https://coveralls.io/repos/futhr/spree-faq/badge.png?branch=2-0-stable)](https://coveralls.io/r/futhr/spree-faq)
5
+ [![Code Climate](https://codeclimate.com/github/futhr/spree-faq.png)](https://codeclimate.com/github/futhr/spree-faq)
6
+ [![Gem Version](https://badge.fury.io/rb/spree_postal_service.png)](http://badge.fury.io/rb/spree_postal_service)
7
+
8
+ An Spree Commerce extension for managing FAQs.
9
+
10
+ ## Installation
11
+
12
+ In your `Gemfile`
13
+
14
+ ```ruby
15
+ gem 'spree_faq', '~> 2.0.0'
16
+ ```
17
+
18
+ Then run from the command line:
19
+
20
+ bundle install
21
+ rails g spree_faq:install
22
+
23
+ ---
24
+
25
+ ## Contributing
26
+
27
+ See corresponding [guiedlines][1].
28
+
29
+ ---
30
+
31
+ Copyright (c) 2009-2014 [Josh Nussbaum][2], [Tobias Bohwalli][3], and other [contributors][4], released under the [New BSD License][5]
32
+
33
+ [1]: https://github.com/futhr/spree-faq/blob/master/CONTRIBUTING.md
34
+ [2]: https://github.com/joshnuss
35
+ [3]: https://github.com/futhr
36
+ [4]: https://github.com/futhr/spree-faq/graphs/contributors
37
+ [5]: https://github.com/futhr/spree-faq/blob/master/LICENSE.md
data/Rakefile ADDED
@@ -0,0 +1,15 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
3
+
4
+ require 'rspec/core/rake_task'
5
+ require 'spree/testing_support/common_rake'
6
+
7
+ RSpec::Core::RakeTask.new
8
+
9
+ task default: :spec
10
+
11
+ desc 'Generates a dummy app for testing'
12
+ task :test_app do
13
+ ENV['LIB_NAME'] = 'spree_faq'
14
+ Rake::Task['common:test_app'].invoke
15
+ end
@@ -0,0 +1,23 @@
1
+ #= require admin/spree_backend
2
+
3
+ (($) ->
4
+ $('form').on 'click', '.add_fields', ->
5
+ time = new Date().getTime()
6
+ regexp = new RegExp($(this).data('id'), 'g')
7
+ $(this).before($(this).data('fields').replace(regexp, time))
8
+ event.preventDefault()
9
+
10
+ $('form').on 'click', '.remove', ->
11
+ $(this).parent('.question').children(':hidden[id$=delete]').val(1)
12
+ $(this).parent('.question').slideUp('slow')
13
+ event.preventDefault()
14
+
15
+ $('#new_question_link').on 'click', ->
16
+ $('#questions').append(new_question_html.replace(/NEW_RECORD/g, $('#questions .question').size()))
17
+ $('#questions .question:last .remove').on 'click', ->
18
+ $(this).parent('.question').remove()
19
+
20
+ $.scrollTo($('#questions .question:last'), 800)
21
+ $('.question:last input:first').focus()
22
+
23
+ ) jQuery
@@ -0,0 +1,10 @@
1
+ #= require store/spree_frontend
2
+
3
+ (($) ->
4
+ $('.answer').hide()
5
+ $('.question').on 'click', ->
6
+ id = $(this).attr('id').split('_')[1]
7
+ $('#answer_' + id).slideToggle()
8
+ return false
9
+
10
+ ) jQuery
@@ -0,0 +1,3 @@
1
+ /*
2
+ *= require admin/spree_backend
3
+ */
@@ -0,0 +1,18 @@
1
+ /*
2
+ *= require store/spree_frontend
3
+ */
4
+
5
+ #questions .question {
6
+ margin-bottom: 1em;
7
+ padding: 1em;
8
+ border: solid 1px #ccc;
9
+
10
+ textarea, input {
11
+ width: 600px;
12
+ }
13
+
14
+ textarea {
15
+ height: 40px;
16
+ padding: 0;
17
+ }
18
+ }
@@ -0,0 +1,13 @@
1
+ module Spree
2
+ module Admin
3
+ class QuestionCategoriesController < ResourceController
4
+ before_filter :question_category, only: [:new, :edit]
5
+
6
+ private
7
+
8
+ def question_category
9
+ @question_category ||= @object
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,13 @@
1
+ module Spree
2
+ class FaqsController < StoreController
3
+ helper 'spree/products'
4
+
5
+ def index
6
+ @categories = QuestionCategory.all(include: :questions)
7
+ end
8
+
9
+ def default_title
10
+ Spree.t(:frequently_asked_questions, scope: :spree_faq)
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,7 @@
1
+ class Spree::Question < ActiveRecord::Base
2
+ acts_as_list
3
+
4
+ belongs_to :question_category, class_name: 'Spree::QuestionCategory'
5
+ validates :question_category_id, :question, :answer, presence: true
6
+ attr_accessible :question, :answer, :question_category_id, :question_category
7
+ end
@@ -0,0 +1,9 @@
1
+ class Spree::QuestionCategory < ActiveRecord::Base
2
+ acts_as_list
3
+
4
+ has_many :questions, class_name: 'Spree::Question'
5
+ validates :name, presence: true
6
+ validates :name, uniqueness: { case_sensitive: false }
7
+ accepts_nested_attributes_for :questions, allow_destroy: true
8
+ attr_accessible :name, :questions_attributes, :question, :answer
9
+ end
@@ -0,0 +1,5 @@
1
+ Deface::Override.new(virtual_path: "spree/admin/shared/_configuration_menu",
2
+ name: "add_faq_configuration_line",
3
+ insert_bottom: "[data-hook='admin_configurations_sidebar_menu']",
4
+ text: "<%= configurations_sidebar_menu_item Spree.t(:question_categories_admin, scope: :spree_faq), admin_question_categories_url %>",
5
+ disabled: false)
@@ -0,0 +1,14 @@
1
+ <div class="question" id="<%= dom_id f.object %>">
2
+ <fieldset class="no-border-bottom">
3
+ <div class="field">
4
+ <%= f.label :question, Spree::Question.model_name.human(count: 1) %> <span class="required">*</span><br />
5
+ <%= f.text_field :question, class: 'fullwidth title' %>
6
+ </div>
7
+ <div class="field">
8
+ <%= f.label :answer, Spree.t(:answer, scope: :spree_faq) %> <span class="required">*</span><br />
9
+ <%= f.text_area :answer, rows: 2, class: 'fullwidth' %>
10
+ </div>
11
+ <%= f.hidden_field :_destroy %>
12
+ <%= link_to_with_icon 'icon-trash', 'remove', '#', class: 'remove' %>
13
+ </fieldset>
14
+ </div>
@@ -0,0 +1,38 @@
1
+ <%= render 'spree/admin/shared/configuration_menu' %>
2
+
3
+ <% content_for :page_title do %>
4
+ <%= Spree.t(:editing_category_questions, scope: :spree_faq) %>
5
+ <% end %>
6
+
7
+ <% content_for :page_actions do %>
8
+ <li>
9
+ <%= button_link_to Spree.t(:add_question, scope: :spree_faq), '#', icon: 'icon-plus', id: 'new_question_link' %>
10
+ <%= button_link_to Spree.t(:back_to_categories, scope: :spree_faq), spree.admin_question_categories_path, icon: 'icon-arrow-left' %>
11
+ </li>
12
+ <% end %>
13
+
14
+ <%= render 'spree/shared/error_messages', target: @question_category %>
15
+
16
+ <%= form_for [:admin, @question_category] do |f| %>
17
+ <%= javascript_tag do %>
18
+ var new_question_html = '<%= generate_template(f, :questions) %>';
19
+ <% end %>
20
+ <div class="field">
21
+ <%= f.field_container :name do %>
22
+ <%= f.label :name, Spree.t(:category_name, scope: :spree_faq) %> <span class="required">*</span><br />
23
+ <%= f.text_field :name, class: 'fullwidth title' %>
24
+ <%= f.error_message_on :name %>
25
+ <% end %>
26
+ </div>
27
+ <div id="questions" style="margin-bottom: 20px">
28
+ <h3>Questions</h3>
29
+ <%= f.fields_for :questions do |question_form| %>
30
+ <%= render 'question', f: question_form %>
31
+ <% end %>
32
+ </div>
33
+ <div class="form-buttons filter-actions actions" data-hook="buttons">
34
+ <%= button Spree.t(:update), 'icon-refresh' %>
35
+ <span class="or"><%= Spree.t(:or) %></span>
36
+ <%= link_to_with_icon 'icon-remove', Spree.t(:cancel), admin_question_categories_url, class: 'button' %>
37
+ </div>
38
+ <% end %>
@@ -0,0 +1,48 @@
1
+ <%= render 'spree/admin/shared/configuration_menu' %>
2
+
3
+ <% content_for :page_title do %>
4
+ <%= Spree.t(:question_categories, scope: :spree_faq) %>
5
+ <% end %>
6
+
7
+ <% content_for :page_actions do %>
8
+ <li id="new_question_category_link">
9
+ <%= button_link_to Spree.t(:new_question_category, scope: :spree_faq), new_admin_question_category_url,
10
+ { remote: true, icon: 'icon-plus', 'data-update' => 'new_question_category', id: 'new_question_category_link' } %>
11
+ </li>
12
+ <% end %>
13
+
14
+ <div id="new_question_category"></div>
15
+
16
+ <% if @question_categories.any? %>
17
+ <table class="index" id="listing_faq">
18
+ <colgroup>
19
+ <col style="width: 40%">
20
+ <col style="width: 40%">
21
+ <col style="width: 20%">
22
+ </colgroup>
23
+ <thead>
24
+ <tr data-hook="admin_faq_category_index_headers">
25
+ <th><%= Spree::QuestionCategory.model_name.human(count: 2) %></td>
26
+ <th><%= Spree::Question.model_name.human(count: 2) %></td>
27
+ <th data-hook="admin_faq_category_index_header_actions" class="actions"></th>
28
+ </tr>
29
+ <thead>
30
+ <tbody>
31
+ <% @question_categories.each do |category| %>
32
+ <tr id="<%= spree_dom_id category %>" data-hook="admin_faq_category_index_rows" class="<%= cycle('odd', 'even') %>">
33
+ <td class="align-center"><%= h category.name %></td>
34
+ <td class="align-center"><%= category.questions.count %></td>
35
+ <td data-hook="admin_faq_category_index_row_actions" class="actions">
36
+ <%= link_to_edit category, no_text: true %>
37
+ <%= link_to_delete category, no_text: true %>
38
+ </td>
39
+ </tr>
40
+ <% end %>
41
+ </tbody>
42
+ </table>
43
+ <% else %>
44
+ <div class="alpha twelve columns no-objects-found">
45
+ <%= Spree.t(:no_resource_found, resource: Spree::QuestionCategory.model_name.human(count: 2)) %>,
46
+ <%= link_to Spree.t(:add_one), spree.new_admin_question_category_path %>!
47
+ </div>
48
+ <% end %>
@@ -0,0 +1,19 @@
1
+ <%= render 'spree/admin/shared/configuration_menu' %>
2
+
3
+ <% content_for :page_title do %>
4
+ <%= Spree.t(:new_question_category, scope: :spree_faq) %>
5
+ <% end %>
6
+
7
+ <%= render 'spree/shared/error_messages', target: @question_category %>
8
+ <%= form_for [:admin, @question_category] do |f| %>
9
+ <fieldset class="no-border-top">
10
+ <%= f.field_container :name do %>
11
+ <%= f.label :name, Spree.t(:name) %> <span class="required">*</span><br />
12
+ <%= f.text_field :name, class: 'fullwidth title' %>
13
+ <%= f.error_message_on :name %>
14
+ <% end %>
15
+ <div data-hook="buttons" class="filter-actions actions">
16
+ <%= button Spree.t(:create), 'icon-ok' %>
17
+ </div>
18
+ </fieldset>
19
+ <% end %>
@@ -0,0 +1,2 @@
1
+ $('#new_question_category').html('<%= escape_javascript(render template: "spree/admin/question_categories/new", formats: [:html], handlers: [:erb]) %>');
2
+ $('#new_question_category_link').parent().hide();
@@ -0,0 +1,29 @@
1
+ <h1><%= Spree.t(:frequently_asked_questions, scope: :spree_faq) %></h1>
2
+
3
+ <div id="faqs">
4
+ <% @categories.each do |category| %>
5
+ <div id="<%= dom_id category -%>" class="category">
6
+ <h2><%= h category.name %></h2>
7
+ <ul class="answers">
8
+ <% category.questions.each do |question| %>
9
+ <li>
10
+ <a class="question" id="<%= dom_id question -%>" href="#<%= "answer_#{question.id}" %>">
11
+ <%= raw(question.question) -%>
12
+ </a>
13
+ <div class="answer" id="<%= "answer_#{question.id}"-%>">
14
+ <%= raw(question.answer) %>
15
+ </div>
16
+ </li>
17
+ <% end %>
18
+ </ul>
19
+ </div>
20
+ <% end %>
21
+ </div>
22
+
23
+ <% content_for :sidebar do %>
24
+ <% if defined? @products && defined? @taxon %>
25
+ <%= render 'spree/shared/filters' %>
26
+ <% elsif defined? @taxonomies %>
27
+ <%= render 'spree/shared/taxonomies' %>
28
+ <% end %>
29
+ <% end %>
@@ -0,0 +1,22 @@
1
+ ---
2
+ en:
3
+ activerecord:
4
+ models:
5
+ spree/question_category:
6
+ one: Question Category
7
+ other: Question Categories
8
+ spree/question:
9
+ one: Question
10
+ other: Questions
11
+ spree:
12
+ spree_faq:
13
+ add_question: Add Question
14
+ answer: Answer
15
+ back_to_categories: Back to Categories
16
+ category_name: Category Name
17
+ create_category: Create Category
18
+ editing_category_questions: Editing Category Questions
19
+ frequently_asked_questions: Frequently Asked Questions
20
+ new_question_category: New Category
21
+ question_categories: Frequently Asked Questions
22
+ question_categories_admin: FAQ
@@ -0,0 +1,22 @@
1
+ ---
2
+ sv:
3
+ activerecord:
4
+ models:
5
+ spree/question_category:
6
+ one: Kategori
7
+ other: Kategorier
8
+ spree/question:
9
+ one: Fråga
10
+ other: Frågor
11
+ spree:
12
+ spree_faq:
13
+ add_question: Lägg till fråga
14
+ answer: Svar
15
+ back_to_categories: Tillbaka till kategorier
16
+ category_name: Kategorinamn
17
+ create_category: Skapa kategori
18
+ editing_category_questions: Ändra kategori frågor
19
+ frequently_asked_questions: Vanliga frågor och svar
20
+ new_question_category: Ny kategori
21
+ question_categories: Vanliga frågor och svar
22
+ question_categories_admin: FAQ
data/config/routes.rb ADDED
@@ -0,0 +1,6 @@
1
+ Spree::Core::Engine.routes.draw do
2
+ namespace :admin do
3
+ resources :question_categories
4
+ end
5
+ get 'faq', to: 'faqs#index'
6
+ end
@@ -0,0 +1,16 @@
1
+ class CreateQuestions < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :questions do |t|
4
+ t.integer :question_category_id
5
+ t.text :question
6
+ t.text :answer
7
+ t.integer :position
8
+
9
+ t.timestamps
10
+ end
11
+ end
12
+
13
+ def self.down
14
+ drop_table :questions
15
+ end
16
+ end
@@ -0,0 +1,14 @@
1
+ class CreateQuestionCategories < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :question_categories do |t|
4
+ t.string :name
5
+ t.integer :position
6
+
7
+ t.timestamps
8
+ end
9
+ end
10
+
11
+ def self.down
12
+ drop_table :question_categories
13
+ end
14
+ end
@@ -0,0 +1,5 @@
1
+ class RenameQuestionsToSpreeQuestions < ActiveRecord::Migration
2
+ def change
3
+ rename_table :questions, :spree_questions
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ class RenameQuestionCategoriesToSpreeQuestionCategories < ActiveRecord::Migration
2
+ def change
3
+ rename_table :question_categories, :spree_question_categories
4
+ end
5
+ end
@@ -0,0 +1,30 @@
1
+ module SpreeFaq
2
+ module Generators
3
+ class InstallGenerator < Rails::Generators::Base
4
+ class_option :auto_run_migrations, type: :boolean, default: false
5
+
6
+ def add_javascripts
7
+ append_file 'app/assets/javascripts/store/all.js', "//= require store/spree_faq\n"
8
+ append_file 'app/assets/javascripts/admin/all.js', "//= require admin/spree_faq\n"
9
+ end
10
+
11
+ def add_stylesheets
12
+ inject_into_file 'app/assets/stylesheets/store/all.css', " *= require store/spree_faq\n", before: /\*\//, verbose: true
13
+ inject_into_file 'app/assets/stylesheets/admin/all.css', " *= require admin/spree_faq\n", before: /\*\//, verbose: true
14
+ end
15
+
16
+ def add_migrations
17
+ run 'bundle exec rake railties:install:migrations FROM=spree_faq'
18
+ end
19
+
20
+ def run_migrations
21
+ run_migrations = options[:auto_run_migrations] || ['', 'y', 'Y'].include?(ask 'Would you like to run the migrations now? [Y/n]')
22
+ if run_migrations
23
+ run 'bundle exec rake db:migrate'
24
+ else
25
+ puts 'Skipping rake db:migrate, don\'t forget to run it!'
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,21 @@
1
+ module SpreeFaq
2
+ class Engine < Rails::Engine
3
+ require 'spree/core'
4
+ isolate_namespace Spree
5
+ engine_name 'spree_faq'
6
+
7
+ config.autoload_paths += %W(#{config.root}/lib)
8
+
9
+ def self.activate
10
+ Dir.glob(File.join(File.dirname(__FILE__), '../../app/**/*_decorator*.rb')) do |c|
11
+ Rails.configuration.cache_classes ? require(c) : load(c)
12
+ end
13
+
14
+ Dir.glob(File.join(File.dirname(__FILE__), '../../app/overrides/*.rb')) do |c|
15
+ Rails.configuration.cache_classes ? require(c) : load(c)
16
+ end
17
+ end
18
+
19
+ config.to_prepare &method(:activate).to_proc
20
+ end
21
+ end
@@ -0,0 +1,16 @@
1
+ module SpreeFaq
2
+
3
+ # Returns the version of the currently loaded SpreeFaq as a <tt>Gem::Version</tt>
4
+ def self.version
5
+ Gem::Version.new VERSION::STRING
6
+ end
7
+
8
+ module VERSION
9
+ MAJOR = 2
10
+ MINOR = 0
11
+ TINY = 0
12
+ PRE = nil
13
+
14
+ STRING = [MAJOR, MINOR, TINY, PRE].compact.join('.')
15
+ end
16
+ end
data/lib/spree_faq.rb ADDED
@@ -0,0 +1,4 @@
1
+ require 'spree_core'
2
+ require 'spree_faq/version'
3
+ require 'spree_faq/engine'
4
+ require 'coffee_script'
data/script/rails ADDED
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ ENGINE_ROOT = File.expand_path('../..', __FILE__)
4
+ ENGINE_PATH = File.expand_path('../../lib/spree_faq/engine', __FILE__)
5
+
6
+ require 'rails/all'
7
+ require 'rails/engine/commands'