spree_faq 3.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +13 -0
- data/app/controllers/admin/question_categories_controller.rb +15 -0
- data/app/controllers/faqs_controller.rb +11 -0
- data/app/models/question.rb +6 -0
- data/app/models/question_category.rb +9 -0
- data/app/views/admin/question_categories/_question.html.erb +11 -0
- data/app/views/admin/question_categories/edit.html.erb +47 -0
- data/app/views/admin/question_categories/index.html.erb +41 -0
- data/app/views/admin/question_categories/new.html.erb +11 -0
- data/app/views/faqs/index.html.erb +33 -0
- data/config/locales/en-GB.yml +13 -0
- data/config/locales/en-US.yml +13 -0
- data/config/routes.rb +7 -0
- data/lib/generators/spree_faq/install_generator.rb +17 -0
- data/lib/generators/templates/db/migrate/20090526213535_create_questions.rb +17 -0
- data/lib/generators/templates/db/migrate/20090526213550_create_question_categories.rb +14 -0
- data/lib/generators/templates/public/javascripts/jquery.scrollTo-min.js +11 -0
- data/lib/generators/templates/public/stylesheets/spree_faq.css +18 -0
- data/lib/spree_faq.rb +3 -0
- data/lib/spree_faq/engine.rb +12 -0
- data/lib/spree_faq_hooks.rb +6 -0
- metadata +104 -0
data/README.md
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
class Admin::QuestionCategoriesController < Admin::BaseController
|
2
|
+
resource_controller
|
3
|
+
|
4
|
+
helper 'spree/base'
|
5
|
+
|
6
|
+
new_action.response do |format|
|
7
|
+
format.html {render :action => :new, :layout => false}
|
8
|
+
end
|
9
|
+
update.response do |format|
|
10
|
+
format.html { redirect_to admin_question_categories_path }
|
11
|
+
end
|
12
|
+
create.response do |format|
|
13
|
+
format.html { redirect_to edit_admin_question_category_path(@question_category) }
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
<div class="question">
|
2
|
+
<p>
|
3
|
+
<%= f.label :question, t("question") %> <span class="required">*</span><br />
|
4
|
+
<%= f.text_field :question %>
|
5
|
+
</p>
|
6
|
+
<p>
|
7
|
+
<%= f.label :answer, t("answer") %> <span class="required">*</span><br />
|
8
|
+
<%= f.text_area :answer, :rows => 2 %>
|
9
|
+
</p>
|
10
|
+
<%= remove_nested f %>
|
11
|
+
</div>
|
@@ -0,0 +1,47 @@
|
|
1
|
+
<% content_for :head do %>
|
2
|
+
<%= javascript_include_tag 'jquery.scrollTo-min' %>
|
3
|
+
<%= stylesheet_link_tag 'spree_faq' %>
|
4
|
+
<% end %>
|
5
|
+
<%= form_for @question_category, :url => object_path do |f| %>
|
6
|
+
<%= render "shared/error_messages", :target => f.object %>
|
7
|
+
<%= javascript_tag do %>
|
8
|
+
var new_question_html = '<%= generate_template(f, :questions) %>';
|
9
|
+
|
10
|
+
jQuery(document).ready(function($) {
|
11
|
+
$('#new_question_link').click(function() {
|
12
|
+
$('#questions').append(new_question_html.replace(/NEW_RECORD/g, $('#questions .question').size()));
|
13
|
+
$('#questions .question:last .remove').click(function() {
|
14
|
+
$(this).parent('.question').remove();
|
15
|
+
});
|
16
|
+
$.scrollTo(jQuery('#questions .question:last'), 800);
|
17
|
+
$('.question:last input:first').focus();
|
18
|
+
});
|
19
|
+
$('#questions .remove').click(function() {
|
20
|
+
$(this).parent('.question').children(':hidden[id$=delete]').val(1);
|
21
|
+
$(this).parent('.question').slideUp('slow');
|
22
|
+
});
|
23
|
+
});
|
24
|
+
<% end %>
|
25
|
+
<div class="yui-gc">
|
26
|
+
<div class="yui-u first">
|
27
|
+
|
28
|
+
<%= f.field_container :name do %>
|
29
|
+
<%= f.label :name, t("category_name") %> <span class="required">*</span><br />
|
30
|
+
<%= f.text_field :name, :class => 'fullwidth title' %>
|
31
|
+
<%= f.error_message_on :name %>
|
32
|
+
<% end %>
|
33
|
+
|
34
|
+
<div id="questions">
|
35
|
+
<h2>Questions</h2>
|
36
|
+
<%= link_to_with_icon 'add', t('add_question'), '#', :id => 'new_question_link' %>
|
37
|
+
|
38
|
+
<%= f.fields_for :questions do |question_form| %>
|
39
|
+
<%= render :partial => 'question', :locals => {:f => question_form } %>
|
40
|
+
<% end %>
|
41
|
+
</div>
|
42
|
+
|
43
|
+
<%= render :partial => 'admin/shared/edit_resource_links' %>
|
44
|
+
</div>
|
45
|
+
</div>
|
46
|
+
|
47
|
+
<% end %>
|
@@ -0,0 +1,41 @@
|
|
1
|
+
<div class='toolbar'>
|
2
|
+
<ul class='actions'>
|
3
|
+
<li id="new_question_category_link">
|
4
|
+
<%= button_link_to t("new_question_category"),
|
5
|
+
new_object_url,
|
6
|
+
{:remote => :true, :icon => 'add' } %>
|
7
|
+
</li>
|
8
|
+
</ul>
|
9
|
+
<br class='clear' />
|
10
|
+
</div>
|
11
|
+
<div id="new_question_category"></div>
|
12
|
+
|
13
|
+
<h1><%= t("question_categories") %></h1>
|
14
|
+
<table class="index">
|
15
|
+
<thead>
|
16
|
+
<%= hook :admin_question_categories_index_headers do %>
|
17
|
+
<th><%= t("category") %></td>
|
18
|
+
<th><%= t("questions") %></td>
|
19
|
+
<% end %>
|
20
|
+
<th>
|
21
|
+
<%= hook :admin_question_categories_header_actions %>
|
22
|
+
</th>
|
23
|
+
</tr>
|
24
|
+
<thead>
|
25
|
+
<% @question_categories.each do |category| %>
|
26
|
+
<tr id="<%= dom_id category %>">
|
27
|
+
<%- locals = {:category => category} %>
|
28
|
+
<%= hook :admin_question_categories_index_rows, locals do %>
|
29
|
+
<td><%= h category.name %></td>
|
30
|
+
<td><%= category.questions.count %></td>
|
31
|
+
<% end %>
|
32
|
+
<td class="actions">
|
33
|
+
<%= hook :admin_question_categories_index_row_actions, locals do %>
|
34
|
+
<%= link_to_edit category %>
|
35
|
+
<%= link_to_delete category %>
|
36
|
+
<% end %>
|
37
|
+
</td>
|
38
|
+
</tr>
|
39
|
+
<% end %>
|
40
|
+
</tbody>
|
41
|
+
</table>
|
@@ -0,0 +1,11 @@
|
|
1
|
+
<%= form_for @question_category, :url => collection_path do |f| %>
|
2
|
+
<%= render "shared/error_messages", :target => f.object %>
|
3
|
+
<fieldset>
|
4
|
+
<%= f.field_container :name do %>
|
5
|
+
<%= f.label :name, t("name") %> <span class="required">*</span><br />
|
6
|
+
<%= f.text_field :name, :class => 'fullwidth title' %>
|
7
|
+
<%= f.error_message_on :name %>
|
8
|
+
<% end %>
|
9
|
+
<%= render :partial => 'admin/shared/new_resource_links' %>
|
10
|
+
</fieldset>
|
11
|
+
<% end %>
|
@@ -0,0 +1,33 @@
|
|
1
|
+
<h1><%= t('frequently_asked_questions') %></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
|
+
<%= h question.question -%>
|
12
|
+
</a>
|
13
|
+
<div class="answer" id="<%= "answer_#{question.id}"-%>">
|
14
|
+
<%= question.answer %>
|
15
|
+
</div>
|
16
|
+
</li>
|
17
|
+
<% end %>
|
18
|
+
</ul>
|
19
|
+
</div>
|
20
|
+
<% end %>
|
21
|
+
</div>
|
22
|
+
|
23
|
+
<%= content_for :head do %>
|
24
|
+
<%= javascript_tag do %>
|
25
|
+
$(function() {
|
26
|
+
$('.answer').hide();
|
27
|
+
$('.question').click(function() {
|
28
|
+
var id = $(this).attr('id').split('_')[1];
|
29
|
+
$('#answer_' + id).slideToggle();
|
30
|
+
});
|
31
|
+
});
|
32
|
+
<% end %>
|
33
|
+
<% end %>
|
@@ -0,0 +1,13 @@
|
|
1
|
+
---
|
2
|
+
en:
|
3
|
+
frequently_asked_questions: Frequently Asked Questions
|
4
|
+
question_categories_admin: FAQ
|
5
|
+
question_categories: Frequently Asked Questions
|
6
|
+
new_question_category: New Category
|
7
|
+
questions: Questions
|
8
|
+
create_category: Create Category
|
9
|
+
category_name: Category Name
|
10
|
+
add_question: Add Question
|
11
|
+
question: Question
|
12
|
+
answer: Answer
|
13
|
+
|
@@ -0,0 +1,13 @@
|
|
1
|
+
---
|
2
|
+
en:
|
3
|
+
frequently_asked_questions: Frequently Asked Questions
|
4
|
+
question_categories_admin: FAQ
|
5
|
+
question_categories: Frequently Asked Questions
|
6
|
+
new_question_category: New Category
|
7
|
+
questions: Questions
|
8
|
+
create_category: Create Category
|
9
|
+
category_name: Category Name
|
10
|
+
add_question: Add Question
|
11
|
+
question: Question
|
12
|
+
answer: Answer
|
13
|
+
|
data/config/routes.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
module SpreeFaq
|
2
|
+
module Generators
|
3
|
+
class InstallGenerator < Rails::Generators::Base
|
4
|
+
source_root File.expand_path("../../templates", __FILE__)
|
5
|
+
|
6
|
+
desc "Configures your Rails application for use with spree_faq"
|
7
|
+
def copy_migrations
|
8
|
+
directory "db"
|
9
|
+
end
|
10
|
+
|
11
|
+
def copy_public
|
12
|
+
directory "public"
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,17 @@
|
|
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
|
+
|
10
|
+
t.timestamps
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.down
|
15
|
+
drop_table :questions
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
/**
|
2
|
+
* jQuery.ScrollTo - Easy element scrolling using jQuery.
|
3
|
+
* Copyright (c) 2007-2009 Ariel Flesler - aflesler(at)gmail(dot)com | http://flesler.blogspot.com
|
4
|
+
* Dual licensed under MIT and GPL.
|
5
|
+
* Date: 5/25/2009
|
6
|
+
* @author Ariel Flesler
|
7
|
+
* @version 1.4.2
|
8
|
+
*
|
9
|
+
* http://flesler.blogspot.com/2007/10/jqueryscrollto.html
|
10
|
+
*/
|
11
|
+
;(function(d){var k=d.scrollTo=function(a,i,e){d(window).scrollTo(a,i,e)};k.defaults={axis:'xy',duration:parseFloat(d.fn.jquery)>=1.3?0:1};k.window=function(a){return d(window)._scrollable()};d.fn._scrollable=function(){return this.map(function(){var a=this,i=!a.nodeName||d.inArray(a.nodeName.toLowerCase(),['iframe','#document','html','body'])!=-1;if(!i)return a;var e=(a.contentWindow||a).document||a.ownerDocument||a;return d.browser.safari||e.compatMode=='BackCompat'?e.body:e.documentElement})};d.fn.scrollTo=function(n,j,b){if(typeof j=='object'){b=j;j=0}if(typeof b=='function')b={onAfter:b};if(n=='max')n=9e9;b=d.extend({},k.defaults,b);j=j||b.speed||b.duration;b.queue=b.queue&&b.axis.length>1;if(b.queue)j/=2;b.offset=p(b.offset);b.over=p(b.over);return this._scrollable().each(function(){var q=this,r=d(q),f=n,s,g={},u=r.is('html,body');switch(typeof f){case'number':case'string':if(/^([+-]=)?\d+(\.\d+)?(px|%)?$/.test(f)){f=p(f);break}f=d(f,this);case'object':if(f.is||f.style)s=(f=d(f)).offset()}d.each(b.axis.split(''),function(a,i){var e=i=='x'?'Left':'Top',h=e.toLowerCase(),c='scroll'+e,l=q[c],m=k.max(q,i);if(s){g[c]=s[h]+(u?0:l-r.offset()[h]);if(b.margin){g[c]-=parseInt(f.css('margin'+e))||0;g[c]-=parseInt(f.css('border'+e+'Width'))||0}g[c]+=b.offset[h]||0;if(b.over[h])g[c]+=f[i=='x'?'width':'height']()*b.over[h]}else{var o=f[h];g[c]=o.slice&&o.slice(-1)=='%'?parseFloat(o)/100*m:o}if(/^\d+$/.test(g[c]))g[c]=g[c]<=0?0:Math.min(g[c],m);if(!a&&b.queue){if(l!=g[c])t(b.onAfterFirst);delete g[c]}});t(b.onAfter);function t(a){r.animate(g,j,b.easing,a&&function(){a.call(this,n,b)})}}).end()};k.max=function(a,i){var e=i=='x'?'Width':'Height',h='scroll'+e;if(!d(a).is('html,body'))return a[h]-d(a)[e.toLowerCase()]();var c='client'+e,l=a.ownerDocument.documentElement,m=a.ownerDocument.body;return Math.max(l[h],m[h])-Math.min(l[c],m[c])};function p(a){return typeof a=='object'?a:{top:a,left:a}}})(jQuery);
|
@@ -0,0 +1,18 @@
|
|
1
|
+
#questions {
|
2
|
+
}
|
3
|
+
|
4
|
+
#questions .question {
|
5
|
+
margin-bottom: 1em;
|
6
|
+
padding: 1em;
|
7
|
+
border: solid 1px #ccc;
|
8
|
+
-moz-border-radius: 10px;
|
9
|
+
-webkit-border-radius: 10px;
|
10
|
+
}
|
11
|
+
|
12
|
+
#questions .question textarea, #questions .question input {
|
13
|
+
width: 600px;
|
14
|
+
}
|
15
|
+
#questions .question textarea {
|
16
|
+
height: 40px;
|
17
|
+
padding: 0;
|
18
|
+
}
|
data/lib/spree_faq.rb
ADDED
metadata
ADDED
@@ -0,0 +1,104 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: spree_faq
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 1
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 3
|
8
|
+
- 0
|
9
|
+
- 3
|
10
|
+
version: 3.0.3
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Josh Nussbaum
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2011-01-06 00:00:00 -05:00
|
19
|
+
default_executable:
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
name: spree_core
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 101
|
30
|
+
segments:
|
31
|
+
- 0
|
32
|
+
- 30
|
33
|
+
- 1
|
34
|
+
version: 0.30.1
|
35
|
+
type: :runtime
|
36
|
+
version_requirements: *id001
|
37
|
+
description: With this gem you get an faq page and the management tools to make it very easy to update your faq and reduce the demand on your sites customer service
|
38
|
+
email: joshnuss@gmail.com
|
39
|
+
executables: []
|
40
|
+
|
41
|
+
extensions: []
|
42
|
+
|
43
|
+
extra_rdoc_files: []
|
44
|
+
|
45
|
+
files:
|
46
|
+
- README.md
|
47
|
+
- lib/spree_faq/engine.rb
|
48
|
+
- lib/spree_faq.rb
|
49
|
+
- lib/spree_faq_hooks.rb
|
50
|
+
- lib/generators/spree_faq/install_generator.rb
|
51
|
+
- lib/generators/templates/public/javascripts/jquery.scrollTo-min.js
|
52
|
+
- lib/generators/templates/public/stylesheets/spree_faq.css
|
53
|
+
- lib/generators/templates/db/migrate/20090526213535_create_questions.rb
|
54
|
+
- lib/generators/templates/db/migrate/20090526213550_create_question_categories.rb
|
55
|
+
- app/views/faqs/index.html.erb
|
56
|
+
- app/views/admin/question_categories/edit.html.erb
|
57
|
+
- app/views/admin/question_categories/_question.html.erb
|
58
|
+
- app/views/admin/question_categories/new.html.erb
|
59
|
+
- app/views/admin/question_categories/index.html.erb
|
60
|
+
- app/controllers/faqs_controller.rb
|
61
|
+
- app/controllers/admin/question_categories_controller.rb
|
62
|
+
- app/models/question.rb
|
63
|
+
- app/models/question_category.rb
|
64
|
+
- config/routes.rb
|
65
|
+
- config/locales/en-US.yml
|
66
|
+
- config/locales/en-GB.yml
|
67
|
+
has_rdoc: true
|
68
|
+
homepage: http://spreecommerce.com
|
69
|
+
licenses: []
|
70
|
+
|
71
|
+
post_install_message:
|
72
|
+
rdoc_options: []
|
73
|
+
|
74
|
+
require_paths:
|
75
|
+
- lib
|
76
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
77
|
+
none: false
|
78
|
+
requirements:
|
79
|
+
- - ">="
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
hash: 57
|
82
|
+
segments:
|
83
|
+
- 1
|
84
|
+
- 8
|
85
|
+
- 7
|
86
|
+
version: 1.8.7
|
87
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
88
|
+
none: false
|
89
|
+
requirements:
|
90
|
+
- - ">="
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
hash: 3
|
93
|
+
segments:
|
94
|
+
- 0
|
95
|
+
version: "0"
|
96
|
+
requirements:
|
97
|
+
- none
|
98
|
+
rubyforge_project: spree_faq
|
99
|
+
rubygems_version: 1.3.7
|
100
|
+
signing_key:
|
101
|
+
specification_version: 3
|
102
|
+
summary: Adds an easy faq page to your spree site
|
103
|
+
test_files: []
|
104
|
+
|