knowledge_base 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/Rakefile +28 -0
- data/app/assets/javascripts/knowledge_base/application.js +13 -0
- data/app/assets/stylesheets/knowledge_base/application.css +15 -0
- data/app/controllers/knowledge_base/application_controller.rb +4 -0
- data/app/controllers/knowledge_base/articles_controller.rb +17 -0
- data/app/controllers/knowledge_base/categories_controller.rb +13 -0
- data/app/helpers/knowledge_base/application_helper.rb +4 -0
- data/app/models/knowledge_base/article.rb +13 -0
- data/app/models/knowledge_base/category.rb +16 -0
- data/app/models/knowledge_base/category_article_association.rb +6 -0
- data/app/models/knowledge_base/section.rb +9 -0
- data/app/models/knowledge_base/sectionables.rb +7 -0
- data/app/models/knowledge_base/sectionables/gallery.rb +5 -0
- data/app/models/knowledge_base/sectionables/gallery/image.rb +7 -0
- data/app/models/knowledge_base/sectionables/image.rb +5 -0
- data/app/models/knowledge_base/sectionables/links.rb +5 -0
- data/app/models/knowledge_base/sectionables/links/link.rb +10 -0
- data/app/models/knowledge_base/sectionables/list.rb +5 -0
- data/app/models/knowledge_base/sectionables/list/item.rb +5 -0
- data/app/models/knowledge_base/sectionables/text.rb +4 -0
- data/app/models/knowledge_base/sectionables/video.rb +9 -0
- data/app/uploaders/knowledge_base/image_uploader.rb +53 -0
- data/app/views/knowledge_base/articles/show.html.erb +11 -0
- data/app/views/knowledge_base/categories/index.html.erb +11 -0
- data/app/views/knowledge_base/categories/show.html.erb +15 -0
- data/app/views/knowledge_base/sectionables/galleries/_gallery.html.erb +17 -0
- data/app/views/knowledge_base/sectionables/images/_image.html.erb +5 -0
- data/app/views/knowledge_base/sectionables/links/_links.html.erb +5 -0
- data/app/views/knowledge_base/sectionables/lists/_list.html.erb +17 -0
- data/app/views/knowledge_base/sectionables/texts/_text.html.erb +9 -0
- data/app/views/knowledge_base/sectionables/videos/_video.html.erb +1 -0
- data/app/views/layouts/knowledge_base/application.html.erb +14 -0
- data/config/routes.rb +5 -0
- data/db/migrate/20140303102920_create_knowledge_base_categories.rb +16 -0
- data/db/migrate/20140303152945_create_knowledge_base_articles.rb +13 -0
- data/db/migrate/20140305134249_create_knowledge_base_sections.rb +13 -0
- data/db/migrate/20140306103853_create_knowledge_base_sectionables_texts.rb +11 -0
- data/db/migrate/20140306123236_create_knowledge_base_sectionables_images.rb +10 -0
- data/db/migrate/20140306134124_add_article_id_to_sections.rb +7 -0
- data/db/migrate/20140306134616_remove_kind_from_sections.rb +5 -0
- data/db/migrate/20140306162143_polymorphize_sections.rb +11 -0
- data/db/migrate/20140306181906_create_knowledge_base_sectionables_videos.rb +9 -0
- data/db/migrate/20140306194339_create_knowledge_base_sectionables_galleries.rb +10 -0
- data/db/migrate/20140306194600_create_knowledge_base_sectionables_gallery_images.rb +12 -0
- data/db/migrate/20140306200631_create_knowledge_base_sectionables_lists.rb +10 -0
- data/db/migrate/20140306210259_create_knowledge_base_sectionables_list_items.rb +12 -0
- data/db/migrate/20140307080616_create_knowledge_base_category_article_associations.rb +16 -0
- data/db/migrate/20140307092627_create_knowledge_base_sectionables_links.rb +8 -0
- data/db/migrate/20140307092719_create_knowledge_base_sectionables_links_links.rb +12 -0
- data/lib/knowledge_base.rb +15 -0
- data/lib/knowledge_base/configuration.rb +5 -0
- data/lib/knowledge_base/engine.rb +15 -0
- data/lib/knowledge_base/version.rb +3 -0
- data/lib/tasks/knowledge_base_tasks.rake +4 -0
- data/spec/controllers/knowledge_base/articles_controller_spec.rb +20 -0
- data/spec/controllers/knowledge_base/categories_controller_spec.rb +25 -0
- data/spec/dummy/README.rdoc +28 -0
- data/spec/dummy/Rakefile +6 -0
- data/spec/dummy/app/assets/javascripts/application.js +13 -0
- data/spec/dummy/app/assets/stylesheets/application.css +15 -0
- data/spec/dummy/app/controllers/application_controller.rb +5 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/views/layouts/application.html.erb +14 -0
- data/spec/dummy/bin/bundle +3 -0
- data/spec/dummy/bin/rails +4 -0
- data/spec/dummy/bin/rake +4 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/config/application.rb +23 -0
- data/spec/dummy/config/boot.rb +5 -0
- data/spec/dummy/config/database.yml +30 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +37 -0
- data/spec/dummy/config/environments/production.rb +83 -0
- data/spec/dummy/config/environments/test.rb +39 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/cookies_serializer.rb +3 -0
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/spec/dummy/config/initializers/inflections.rb +16 -0
- data/spec/dummy/config/initializers/mime_types.rb +5 -0
- data/spec/dummy/config/initializers/session_store.rb +3 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/locales/en.yml +23 -0
- data/spec/dummy/config/routes.rb +4 -0
- data/spec/dummy/config/secrets.yml +22 -0
- data/spec/dummy/db/development.sqlite3 +0 -0
- data/spec/dummy/db/schema.rb +134 -0
- data/spec/dummy/db/seeds.rb +28 -0
- data/spec/dummy/log/development.log +12030 -0
- data/spec/dummy/log/test.log +917 -0
- data/spec/dummy/public/404.html +67 -0
- data/spec/dummy/public/422.html +67 -0
- data/spec/dummy/public/500.html +66 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/public/uploads/knowledge_base/sectionables/gallery/image/image/1/parrot.png +0 -0
- data/spec/dummy/public/uploads/knowledge_base/sectionables/gallery/image/image/2/parrot.png +0 -0
- data/spec/dummy/public/uploads/knowledge_base/sectionables/image/image/1/parrot.png +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/062b47a3a70e4df7224b893bf001a98f +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/183c0bd4fe8641adfc2b9f735484664a +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/2f86727a5dfdf38270057bb8a6b140bc +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/32c50a0141ffd19eb481b35a22532865 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/806fae72d2de8ab235cdf1503e8c950b +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/e9c371dd2bf884ad2ab7c34915daf486 +0 -0
- data/spec/dummy/tmp/pids/server.pid +1 -0
- data/spec/factories/knowledge_base_articles.rb +9 -0
- data/spec/factories/knowledge_base_categories.rb +10 -0
- data/spec/factories/knowledge_base_category_article_associations.rb +9 -0
- data/spec/factories/knowledge_base_sectionables_galleries.rb +8 -0
- data/spec/factories/knowledge_base_sectionables_gallery_images.rb +10 -0
- data/spec/factories/knowledge_base_sectionables_images.rb +8 -0
- data/spec/factories/knowledge_base_sectionables_links.rb +6 -0
- data/spec/factories/knowledge_base_sectionables_links_links.rb +9 -0
- data/spec/factories/knowledge_base_sectionables_list_items.rb +10 -0
- data/spec/factories/knowledge_base_sectionables_lists.rb +8 -0
- data/spec/factories/knowledge_base_sectionables_texts.rb +11 -0
- data/spec/factories/knowledge_base_sectionables_videos.rb +7 -0
- data/spec/factories/knowledge_base_sections.rb +9 -0
- data/spec/fixtures/parrot.png +0 -0
- data/spec/lib/knowledge_base/configuration_spec.rb +14 -0
- data/spec/models/knowledge_base/article_spec.rb +7 -0
- data/spec/models/knowledge_base/category_article_association_spec.rb +7 -0
- data/spec/models/knowledge_base/category_spec.rb +7 -0
- data/spec/models/knowledge_base/section_spec.rb +7 -0
- data/spec/models/knowledge_base/sectionables/gallery/image_spec.rb +7 -0
- data/spec/models/knowledge_base/sectionables/gallery_spec.rb +7 -0
- data/spec/models/knowledge_base/sectionables/image_spec.rb +7 -0
- data/spec/models/knowledge_base/sectionables/links/link_spec.rb +7 -0
- data/spec/models/knowledge_base/sectionables/links_spec.rb +7 -0
- data/spec/models/knowledge_base/sectionables/list/item_spec.rb +7 -0
- data/spec/models/knowledge_base/sectionables/list_spec.rb +7 -0
- data/spec/models/knowledge_base/sectionables/text_spec.rb +7 -0
- data/spec/models/knowledge_base/sectionables/video_spec.rb +13 -0
- data/spec/spec_helper.rb +20 -0
- data/spec/views/knowledge_base/articles/show.html.erb_spec.rb +5 -0
- data/spec/views/knowledge_base/categories/index.html.erb_spec.rb +5 -0
- data/spec/views/knowledge_base/categories/show.html.erb_spec.rb +5 -0
- metadata +375 -0
data/config/routes.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
class CreateKnowledgeBaseCategories < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
create_table :knowledge_base_categories do |t|
|
4
|
+
t.string :title
|
5
|
+
t.string :slug
|
6
|
+
t.text :description
|
7
|
+
t.references :category, index: true
|
8
|
+
t.integer :position
|
9
|
+
t.datetime :published_at
|
10
|
+
|
11
|
+
t.timestamps
|
12
|
+
end
|
13
|
+
|
14
|
+
add_index :knowledge_base_categories, :slug, unique: true
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
class CreateKnowledgeBaseArticles < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
create_table :knowledge_base_articles do |t|
|
4
|
+
t.string :title
|
5
|
+
t.string :slug
|
6
|
+
t.text :description
|
7
|
+
t.references :category, index: true
|
8
|
+
t.datetime :published_at
|
9
|
+
|
10
|
+
t.timestamps
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
class CreateKnowledgeBaseSections < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
create_table :knowledge_base_sections do |t|
|
4
|
+
t.references :sectionable, polymorphic: true
|
5
|
+
t.integer :position
|
6
|
+
t.string :kind
|
7
|
+
|
8
|
+
t.timestamps
|
9
|
+
end
|
10
|
+
|
11
|
+
add_index "knowledge_base_sections", ["sectionable_id", "sectionable_type"], name: "index_knowledge_base_sections_on_sectionable"
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
class PolymorphizeSections < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
remove_column :knowledge_base_sections, :article_id, :integer
|
4
|
+
|
5
|
+
change_table :knowledge_base_sections do |t|
|
6
|
+
t.references :container, polymorphic: true
|
7
|
+
end
|
8
|
+
|
9
|
+
add_index :knowledge_base_sections, [:container_id, :container_type], name: "index_knowledge_base_sections_on_container"
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
class CreateKnowledgeBaseSectionablesGalleryImages < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
create_table :knowledge_base_sectionables_gallery_images do |t|
|
4
|
+
t.string :caption
|
5
|
+
t.string :image
|
6
|
+
t.integer :position
|
7
|
+
t.references :gallery, index: true
|
8
|
+
|
9
|
+
t.timestamps
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
class CreateKnowledgeBaseSectionablesListItems < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
create_table :knowledge_base_sectionables_list_items do |t|
|
4
|
+
t.string :title
|
5
|
+
t.text :body
|
6
|
+
t.integer :position
|
7
|
+
t.references :list, index: true
|
8
|
+
|
9
|
+
t.timestamps
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
class CreateKnowledgeBaseCategoryArticleAssociations < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
create_table :knowledge_base_category_article_associations do |t|
|
4
|
+
t.references :category
|
5
|
+
t.references :article
|
6
|
+
t.integer :position
|
7
|
+
|
8
|
+
t.timestamps
|
9
|
+
end
|
10
|
+
|
11
|
+
add_index :knowledge_base_category_article_associations, [:category_id], name: 'index_knowledge_base_c_a_association_on_category_id'
|
12
|
+
add_index :knowledge_base_category_article_associations, [:article_id], name: 'index_knowledge_base_c_a_association_on_article_id'
|
13
|
+
|
14
|
+
remove_column :knowledge_base_articles, :category_id, :references
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
class CreateKnowledgeBaseSectionablesLinksLinks < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
create_table :knowledge_base_sectionables_links_links do |t|
|
4
|
+
t.string :title
|
5
|
+
t.string :url
|
6
|
+
t.integer :position
|
7
|
+
t.references :links
|
8
|
+
|
9
|
+
t.timestamps
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require "knowledge_base/engine"
|
2
|
+
require "knowledge_base/configuration"
|
3
|
+
require "carrierwave"
|
4
|
+
|
5
|
+
module KnowledgeBase
|
6
|
+
class << self
|
7
|
+
def configure
|
8
|
+
yield config
|
9
|
+
end
|
10
|
+
|
11
|
+
def config
|
12
|
+
@config ||= KnowledgeBase::Configuration.new
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'friendly_id'
|
2
|
+
require 'publishable'
|
3
|
+
|
4
|
+
module KnowledgeBase
|
5
|
+
class Engine < ::Rails::Engine
|
6
|
+
isolate_namespace KnowledgeBase
|
7
|
+
|
8
|
+
config.generators do |g|
|
9
|
+
g.test_framework :rspec, fixture: false
|
10
|
+
g.fixture_replacement :factory_girl, dir: 'spec/factories'
|
11
|
+
g.assets false
|
12
|
+
g.helper false
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module KnowledgeBase
|
4
|
+
describe ArticlesController do
|
5
|
+
routes { KnowledgeBase::Engine.routes }
|
6
|
+
|
7
|
+
describe "GET 'show'" do
|
8
|
+
it "returns http success" do
|
9
|
+
category = create :category
|
10
|
+
article = create :article
|
11
|
+
association = create :category_article_association, category: category, article: article
|
12
|
+
|
13
|
+
get :show, category_id: category.slug, id: article.slug
|
14
|
+
|
15
|
+
response.should be_success
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module KnowledgeBase
|
4
|
+
describe CategoriesController do
|
5
|
+
routes { KnowledgeBase::Engine.routes }
|
6
|
+
|
7
|
+
describe "GET 'index'" do
|
8
|
+
it "returns http success" do
|
9
|
+
get :index
|
10
|
+
response.should be_success
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
describe "GET 'show'" do
|
15
|
+
it "returns http success" do
|
16
|
+
category = create :category
|
17
|
+
|
18
|
+
get :show, id: category.slug
|
19
|
+
|
20
|
+
response.should be_success
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
== README
|
2
|
+
|
3
|
+
This README would normally document whatever steps are necessary to get the
|
4
|
+
application up and running.
|
5
|
+
|
6
|
+
Things you may want to cover:
|
7
|
+
|
8
|
+
* Ruby version
|
9
|
+
|
10
|
+
* System dependencies
|
11
|
+
|
12
|
+
* Configuration
|
13
|
+
|
14
|
+
* Database creation
|
15
|
+
|
16
|
+
* Database initialization
|
17
|
+
|
18
|
+
* How to run the test suite
|
19
|
+
|
20
|
+
* Services (job queues, cache servers, search engines, etc.)
|
21
|
+
|
22
|
+
* Deployment instructions
|
23
|
+
|
24
|
+
* ...
|
25
|
+
|
26
|
+
|
27
|
+
Please feel free to use a different markup language if you do not plan to run
|
28
|
+
<tt>rake doc:app</tt>.
|
data/spec/dummy/Rakefile
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
// This is a manifest file that'll be compiled into application.js, which will include all the files
|
2
|
+
// listed below.
|
3
|
+
//
|
4
|
+
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
|
5
|
+
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
|
6
|
+
//
|
7
|
+
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
8
|
+
// compiled file.
|
9
|
+
//
|
10
|
+
// Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
|
11
|
+
// about supported directives.
|
12
|
+
//
|
13
|
+
//= require_tree .
|
@@ -0,0 +1,15 @@
|
|
1
|
+
/*
|
2
|
+
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
3
|
+
* listed below.
|
4
|
+
*
|
5
|
+
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
|
6
|
+
* or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
|
7
|
+
*
|
8
|
+
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
|
9
|
+
* compiled file so the styles you add here take precedence over styles defined in any styles
|
10
|
+
* defined in the other CSS/SCSS files in this directory. It is generally better to create a new
|
11
|
+
* file per style scope.
|
12
|
+
*
|
13
|
+
*= require_tree .
|
14
|
+
*= require_self
|
15
|
+
*/
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>Dummy</title>
|
5
|
+
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
|
6
|
+
<%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
|
7
|
+
<%= csrf_meta_tags %>
|
8
|
+
</head>
|
9
|
+
<body>
|
10
|
+
|
11
|
+
<%= yield %>
|
12
|
+
|
13
|
+
</body>
|
14
|
+
</html>
|
data/spec/dummy/bin/rake
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
require File.expand_path('../boot', __FILE__)
|
2
|
+
|
3
|
+
require 'rails/all'
|
4
|
+
|
5
|
+
Bundler.require(*Rails.groups)
|
6
|
+
require "knowledge_base"
|
7
|
+
|
8
|
+
module Dummy
|
9
|
+
class Application < Rails::Application
|
10
|
+
# Settings in config/environments/* take precedence over those specified here.
|
11
|
+
# Application configuration should go into files in config/initializers
|
12
|
+
# -- all .rb files in that directory are automatically loaded.
|
13
|
+
|
14
|
+
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
|
15
|
+
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
|
16
|
+
# config.time_zone = 'Central Time (US & Canada)'
|
17
|
+
|
18
|
+
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
|
19
|
+
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
|
20
|
+
# config.i18n.default_locale = :de
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|