joofaq 0.0.3 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Joofaq
2
2
 
3
- TODO: Write a gem description
3
+ Joofaq is a FAQ page template building gem. In two easy steps you can have a FAQ page up and running on your rails app with questions and sections easily customizable from a yaml file.
4
4
 
5
5
  ## Installation
6
6
 
@@ -8,17 +8,25 @@ Add this line to your application's Gemfile:
8
8
 
9
9
  gem 'joofaq'
10
10
 
11
- And then execute:
12
11
 
13
- $ bundle
12
+ ## Usage
14
13
 
15
- Or install it yourself as:
14
+ After adding joofaq to your Gemfile, run the joofaq gem generator command:
16
15
 
17
- $ gem install joofaq
16
+ rails generate joofaq
18
17
 
19
- ## Usage
18
+ This will create a faq.yml file in your db/ directory. To add new sections and questions, follow the format shown in the faq.yml:
19
+
20
+ First_category_name_here:
21
+ - subtitle: first_category_subtitle_here
22
+ - q: question_1_text_here
23
+ a: answer_1_text_here
24
+
25
+ Subtitles are optional and you can add as many questions as you need. Remember, this is a yaml file so format (especially indentation) is important for it to work properly.
26
+
27
+ The generator also created several view files in a new app/views/faq/ directory. This gives you access to the views so that you can change the styling as you please.
20
28
 
21
- TODO: Write usage instructions here
29
+ You can now view your app's faq at '/faq' (localhost:3000/faq). Can you change this routing in your config/routes.rb file.
22
30
 
23
31
  ## Contributing
24
32
 
@@ -1,23 +1,14 @@
1
1
  class JoofaqGenerator < Rails::Generators::Base
2
2
  source_root File.expand_path('../templates', __FILE__)
3
3
 
4
-
5
- def generate_faq
4
+ def copy_faq_templates
6
5
  copy_file "joofaq.yml", "db/faq.yml"
7
6
  copy_file "joofaq/index.html.erb", "app/views/faq/index.html.erb"
8
7
  copy_file "joofaq/_qapair.html.erb", "app/views/faq/_qapair.html.erb"
9
8
  copy_file "joofaq/_subtitle.html.erb", "app/views/faq/_subtitle.html.erb"
10
- create_route
11
- add_gem_dependencies
12
9
  end
13
10
 
14
- private
15
-
16
11
  def create_route
17
12
  route "match '/faq' => 'Faq#index'"
18
13
  end
19
-
20
- def add_gem_dependencies
21
- gem 'rdiscount', version: '1.6.8'
22
- end
23
14
  end
@@ -1,11 +1,11 @@
1
- First Category:
1
+ First_category_name_here:
2
2
  - subtitle: first_category_subtitle_here
3
3
  - q: question_1_text_here
4
4
  a: answer_1_text_here
5
5
  - q: question_2_text_here
6
6
  a: answer_2_text_here
7
- Second Category:
7
+ Second_category_name_here:
8
8
  - q: question_1_text_here
9
9
  a: answer_1_text_here
10
10
  - q: question_2_text_here
11
- a: Add more using the same format. Subtitle is completely optional
11
+ a: Add more using the same format. Subtitle is completely optional (delete the line if you are not using one)
data/lib/joofaq.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  require "joofaq/version"
2
+ require 'rdiscount'
2
3
 
3
4
  module Joofaq
4
5
  module Rails
@@ -1,3 +1,3 @@
1
1
  module Joofaq
2
- VERSION = "0.0.3"
2
+ VERSION = "0.1.1"
3
3
  end
data/testapp/Gemfile CHANGED
@@ -6,7 +6,7 @@ gem 'rails', '3.2.8'
6
6
  # gem 'rails', :git => 'git://github.com/rails/rails.git'
7
7
 
8
8
  gem 'sqlite3'
9
- gem 'joofaq'
9
+ gem 'joofaq', path: '../'
10
10
 
11
11
  # Gems used only for assets and not required
12
12
  # in production environments by default.
@@ -4,4 +4,4 @@
4
4
  # If you change this key, all old signed cookies will become invalid!
5
5
  # Make sure the secret is at least 30 characters and all random,
6
6
  # no regular words or you'll be exposed to dictionary attacks.
7
- Testapp::Application.config.secret_token = '56c6e8803a79ac35475f6c4532374861a7825903cb146898692203b2d6f481582fce0f555abb4a65b6f5b0e268e3c549e3c941471b999481e9a466818ab6afd2'
7
+ Testapp::Application.config.secret_token = '982261504353ada7e497c5bafc64dd55eb7c1ad5728aa5a3f8beed18e86792b6600953f383c87eb6b2f27cd119489bb40986cdad92da68eaca7d13c4462f30d6'
@@ -1,5 +1,4 @@
1
1
  Testapp::Application.routes.draw do
2
-
3
2
  match '/faq' => 'Faq#index'
4
3
 
5
4
  # The priority is based upon order of creation:
data/testapp/db/faq.yml CHANGED
@@ -1,11 +1,11 @@
1
- First Category:
1
+ First_category_name_here:
2
2
  - subtitle: first_category_subtitle_here
3
3
  - q: question_1_text_here
4
4
  a: answer_1_text_here
5
5
  - q: question_2_text_here
6
6
  a: answer_2_text_here
7
- Second Category:
7
+ Second_category_name_here:
8
8
  - q: question_1_text_here
9
9
  a: answer_1_text_here
10
10
  - q: question_2_text_here
11
- a: Add more using the same format. Subtitle is completely optional
11
+ a: Add more using the same format. Subtitle is completely optional (delete the line if you are not using one)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: joofaq
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.1.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -64,8 +64,6 @@ files:
64
64
  - lib/generators/joofaq/templates/joofaq/_qapair.html.erb
65
65
  - lib/generators/joofaq/templates/joofaq/_subtitle.html.erb
66
66
  - lib/generators/joofaq/templates/joofaq/index.html.erb
67
- - lib/generators/joofaq/templates/joofaq_controller.rb
68
- - lib/generators/joofaq/templates/joofaq_model.rb
69
67
  - lib/joofaq.rb
70
68
  - lib/joofaq/version.rb
71
69
  - testapp/.gitignore
@@ -1,4 +0,0 @@
1
- class JoofaqController < ApplicationController
2
- def index
3
- end
4
- end
@@ -1,57 +0,0 @@
1
- class Joofaq
2
-
3
- class Section
4
- @attr_list = [:name, :pairs, :items]
5
- attr_accessor *@attr_list
6
-
7
- def initialize args
8
- @name = args[:name]
9
- @items = args[:item].map do |v|
10
- if ['subtitle'] == v.keys
11
- Subtitle.new v['subtitle']
12
- elsif ['q', 'a'] == v.keys
13
- QAPair.new q: v['q'], a: v['a']
14
- else
15
- raise "Item #{v} did not match subtitle or QApair format"
16
- end
17
- end
18
- end
19
-
20
- def name_html; Faq.markdown @name end
21
- end
22
-
23
- class Subtitle
24
- attr_accessor :str
25
-
26
- def initialize str
27
- @str = str
28
- end
29
-
30
- def template; 'joofaq/subtitle' end
31
- def to_html; Faq.markdown @str end
32
- end
33
-
34
- class QAPair
35
- @attr_list = [:q, :a]
36
- attr_accessor *@attr_list
37
-
38
- def initialize args
39
- @q = args[:q]
40
- @a = args[:a]
41
- end
42
-
43
- def template; 'joofaq/qapair' end
44
- def q_html; Faq.markdown @q end
45
- def a_html; Faq.markdown @a end
46
- end
47
-
48
- class << self
49
- def data; data = YAML.load_file 'db/joofaq.yml' end
50
- def markdown str
51
- RDiscount.new(str).to_html.html_safe
52
- end
53
- def sections
54
- data.map {|k,v| Faq::Section.new name: k, item: v }
55
- end
56
- end
57
- end