brightcontent 2.0.0.alpha2
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +8 -0
- data/MIT-LICENSE +20 -0
- data/README.md +44 -0
- data/Rakefile +14 -0
- data/brightcontent.gemspec +21 -0
- data/core/.gitignore +9 -0
- data/core/Gemfile +17 -0
- data/core/Gemfile.lock +163 -0
- data/core/MIT-LICENSE +20 -0
- data/core/README.md +44 -0
- data/core/Rakefile +14 -0
- data/core/app/assets/images/brightcontent/.gitkeep +0 -0
- data/core/app/assets/images/brightcontent/glyphicons-halflings-white.png +0 -0
- data/core/app/assets/images/brightcontent/glyphicons-halflings.png +0 -0
- data/core/app/assets/javascripts/brightcontent/bootstrap.min.js +6 -0
- data/core/app/assets/javascripts/brightcontent/brightcontent.js +17 -0
- data/core/app/assets/javascripts/brightcontent/custom.js +1 -0
- data/core/app/assets/javascripts/brightcontent/main.js +3 -0
- data/core/app/assets/stylesheets/brightcontent/bootstrap-responsive.min.css +9 -0
- data/core/app/assets/stylesheets/brightcontent/bootstrap.min.css +9 -0
- data/core/app/assets/stylesheets/brightcontent/brightcontent.css +17 -0
- data/core/app/assets/stylesheets/brightcontent/custom.css +1 -0
- data/core/app/assets/stylesheets/brightcontent/main.css +44 -0
- data/core/app/controllers/brightcontent/admin_users_controller.rb +6 -0
- data/core/app/controllers/brightcontent/application_controller.rb +22 -0
- data/core/app/controllers/brightcontent/base_controller.rb +27 -0
- data/core/app/controllers/brightcontent/sessions_controller.rb +24 -0
- data/core/app/helpers/brightcontent/application_helper.rb +4 -0
- data/core/app/helpers/brightcontent/base_helper.rb +17 -0
- data/core/app/models/brightcontent/admin_user.rb +7 -0
- data/core/app/views/brightcontent/application/_menu.html.erb +3 -0
- data/core/app/views/brightcontent/application/_show_flash_names.html.erb +5 -0
- data/core/app/views/brightcontent/base/_form.html.erb +10 -0
- data/core/app/views/brightcontent/base/_list.html.erb +8 -0
- data/core/app/views/brightcontent/base/_list_actions.html.erb +2 -0
- data/core/app/views/brightcontent/base/edit.html.erb +3 -0
- data/core/app/views/brightcontent/base/index.html.erb +22 -0
- data/core/app/views/brightcontent/base/new.html.erb +3 -0
- data/core/app/views/brightcontent/sessions/new.html.erb +12 -0
- data/core/app/views/layouts/brightcontent/application.html.erb +53 -0
- data/core/brightcontent-core.gemspec +31 -0
- data/core/config/initializers/simple_form.rb +142 -0
- data/core/config/initializers/simple_form_bootstrap.rb +45 -0
- data/core/config/initializers/will_paginate.rb +28 -0
- data/core/config/routes.rb +9 -0
- data/core/db/migrate/20121206121725_create_brightcontent_admin_users.rb +12 -0
- data/core/lib/brightcontent/core/version.rb +5 -0
- data/core/lib/brightcontent/core.rb +32 -0
- data/core/lib/brightcontent/default_actions.rb +19 -0
- data/core/lib/brightcontent/engine.rb +9 -0
- data/core/lib/brightcontent/pagination.rb +24 -0
- data/core/lib/brightcontent/rails/routes.rb +16 -0
- data/core/lib/brightcontent/routes_parser.rb +38 -0
- data/core/lib/brightcontent-core.rb +1 -0
- data/core/lib/generators/brightcontent/install_generator.rb +34 -0
- data/core/lib/generators/brightcontent/resource_generator.rb +22 -0
- data/core/lib/generators/brightcontent/templates/brightcontent_controller.rb +2 -0
- data/core/lib/generators/brightcontent/templates/initializer.rb +8 -0
- data/core/script/rails +8 -0
- data/core/spec/dummy/README.rdoc +261 -0
- data/core/spec/dummy/Rakefile +7 -0
- data/core/spec/dummy/app/assets/javascripts/application.js +15 -0
- data/core/spec/dummy/app/assets/javascripts/brightcontent/custom.js +1 -0
- data/core/spec/dummy/app/assets/stylesheets/application.css +13 -0
- data/core/spec/dummy/app/assets/stylesheets/brightcontent/custom.css +1 -0
- data/core/spec/dummy/app/controllers/application_controller.rb +3 -0
- data/core/spec/dummy/app/controllers/brightcontent/blogs_controller.rb +2 -0
- data/core/spec/dummy/app/controllers/pages_controller.rb +8 -0
- data/core/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/core/spec/dummy/app/mailers/.gitkeep +0 -0
- data/core/spec/dummy/app/models/.gitkeep +0 -0
- data/core/spec/dummy/app/models/blog.rb +3 -0
- data/core/spec/dummy/app/views/layouts/application.html.erb +14 -0
- data/core/spec/dummy/app/views/pages/index.html.erb +1 -0
- data/core/spec/dummy/config/application.rb +59 -0
- data/core/spec/dummy/config/boot.rb +10 -0
- data/core/spec/dummy/config/database.yml +25 -0
- data/core/spec/dummy/config/environment.rb +5 -0
- data/core/spec/dummy/config/environments/development.rb +37 -0
- data/core/spec/dummy/config/environments/production.rb +67 -0
- data/core/spec/dummy/config/environments/test.rb +37 -0
- data/core/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/core/spec/dummy/config/initializers/brightcontent.rb +3 -0
- data/core/spec/dummy/config/initializers/inflections.rb +15 -0
- data/core/spec/dummy/config/initializers/mime_types.rb +5 -0
- data/core/spec/dummy/config/initializers/secret_token.rb +7 -0
- data/core/spec/dummy/config/initializers/session_store.rb +8 -0
- data/core/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/core/spec/dummy/config/locales/en.yml +5 -0
- data/core/spec/dummy/config/routes.rb +7 -0
- data/core/spec/dummy/config.ru +4 -0
- data/core/spec/dummy/db/migrate/20121206225720_create_blogs.rb +10 -0
- data/core/spec/dummy/db/schema.rb +30 -0
- data/core/spec/dummy/lib/assets/.gitkeep +0 -0
- data/core/spec/dummy/public/404.html +26 -0
- data/core/spec/dummy/public/422.html +26 -0
- data/core/spec/dummy/public/500.html +25 -0
- data/core/spec/dummy/public/favicon.ico +0 -0
- data/core/spec/dummy/script/rails +6 -0
- data/core/spec/factories.rb +16 -0
- data/core/spec/features/login_spec.rb +29 -0
- data/core/spec/features/menu_spec.rb +27 -0
- data/core/spec/features/resources_form_spec.rb +51 -0
- data/core/spec/features/resources_index_spec.rb +50 -0
- data/core/spec/lib/brightcontent/routes_parser_spec.rb +34 -0
- data/core/spec/spec_helper.rb +18 -0
- data/core/spec/support/acceptance_helper.rb +8 -0
- data/lib/brightcontent.rb +2 -0
- data/lib/tasks/release.rake +0 -0
- data/lib/tasks/rspec.rake +5 -0
- data/pages/.gitignore +9 -0
- data/pages/Gemfile +5 -0
- data/pages/Gemfile.lock +173 -0
- data/pages/MIT-LICENSE +20 -0
- data/pages/README.md +35 -0
- data/pages/Rakefile +14 -0
- data/pages/app/assets/images/brightcontent/.gitkeep +0 -0
- data/pages/app/controllers/brightcontent/pages_controller.rb +16 -0
- data/pages/app/helpers/brightcontent/pages_helper.rb +13 -0
- data/pages/app/models/brightcontent/page.rb +27 -0
- data/pages/app/views/brightcontent/pages/_form_field_parent_id.html.erb +1 -0
- data/pages/app/views/brightcontent/pages/_list_field_name.html.erb +1 -0
- data/pages/brightcontent-pages.gemspec +26 -0
- data/pages/config/routes.rb +3 -0
- data/pages/db/migrate/20121207132810_create_brightcontent_pages.rb +16 -0
- data/pages/lib/brightcontent/pages/engine.rb +14 -0
- data/pages/lib/brightcontent/pages/methods.rb +9 -0
- data/pages/lib/brightcontent/pages/version.rb +5 -0
- data/pages/lib/brightcontent/pages.rb +10 -0
- data/pages/lib/brightcontent-pages.rb +1 -0
- data/pages/lib/generators/brightcontent/pages/install_generator.rb +15 -0
- data/pages/script/rails +8 -0
- data/pages/spec/dummy/README.rdoc +261 -0
- data/pages/spec/dummy/Rakefile +7 -0
- data/pages/spec/dummy/app/assets/javascripts/application.js +15 -0
- data/pages/spec/dummy/app/assets/javascripts/brightcontent/custom.js +1 -0
- data/pages/spec/dummy/app/assets/stylesheets/application.css +13 -0
- data/pages/spec/dummy/app/assets/stylesheets/brightcontent/custom.css +1 -0
- data/pages/spec/dummy/app/controllers/application_controller.rb +3 -0
- data/pages/spec/dummy/app/controllers/brightcontent/blogs_controller.rb +2 -0
- data/pages/spec/dummy/app/controllers/pages_controller.rb +8 -0
- data/pages/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/pages/spec/dummy/app/mailers/.gitkeep +0 -0
- data/pages/spec/dummy/app/models/.gitkeep +0 -0
- data/pages/spec/dummy/app/models/blog.rb +3 -0
- data/pages/spec/dummy/app/views/layouts/application.html.erb +14 -0
- data/pages/spec/dummy/app/views/pages/index.html.erb +1 -0
- data/pages/spec/dummy/config/application.rb +59 -0
- data/pages/spec/dummy/config/boot.rb +10 -0
- data/pages/spec/dummy/config/database.yml +25 -0
- data/pages/spec/dummy/config/environment.rb +5 -0
- data/pages/spec/dummy/config/environments/development.rb +37 -0
- data/pages/spec/dummy/config/environments/production.rb +67 -0
- data/pages/spec/dummy/config/environments/test.rb +37 -0
- data/pages/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/pages/spec/dummy/config/initializers/brightcontent.rb +3 -0
- data/pages/spec/dummy/config/initializers/inflections.rb +15 -0
- data/pages/spec/dummy/config/initializers/mime_types.rb +5 -0
- data/pages/spec/dummy/config/initializers/secret_token.rb +7 -0
- data/pages/spec/dummy/config/initializers/session_store.rb +8 -0
- data/pages/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/pages/spec/dummy/config/locales/en.yml +5 -0
- data/pages/spec/dummy/config/routes.rb +6 -0
- data/pages/spec/dummy/config.ru +4 -0
- data/pages/spec/dummy/db/schema.rb +44 -0
- data/pages/spec/dummy/lib/assets/.gitkeep +0 -0
- data/pages/spec/dummy/public/404.html +26 -0
- data/pages/spec/dummy/public/422.html +26 -0
- data/pages/spec/dummy/public/500.html +25 -0
- data/pages/spec/dummy/public/favicon.ico +0 -0
- data/pages/spec/dummy/script/rails +6 -0
- data/pages/spec/factories.rb +16 -0
- data/pages/spec/features/menu_spec.rb +16 -0
- data/pages/spec/features/pages_spec.rb +18 -0
- data/pages/spec/models/brightcontent/page_spec.rb +49 -0
- data/pages/spec/spec_helper.rb +18 -0
- data/pages/spec/support/acceptance_helper.rb +8 -0
- metadata +253 -0
@@ -0,0 +1,14 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
#
|
3
|
+
# This file contains settings for ActionController::ParamsWrapper which
|
4
|
+
# is enabled by default.
|
5
|
+
|
6
|
+
# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
|
7
|
+
ActiveSupport.on_load(:action_controller) do
|
8
|
+
wrap_parameters format: [:json]
|
9
|
+
end
|
10
|
+
|
11
|
+
# Disable root element in JSON by default.
|
12
|
+
ActiveSupport.on_load(:active_record) do
|
13
|
+
self.include_root_in_json = false
|
14
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
# This file is auto-generated from the current state of the database. Instead
|
3
|
+
# of editing this file, please use the migrations feature of Active Record to
|
4
|
+
# incrementally modify your database, and then regenerate this schema definition.
|
5
|
+
#
|
6
|
+
# Note that this schema.rb definition is the authoritative source for your
|
7
|
+
# database schema. If you need to create the application database on another
|
8
|
+
# system, you should be using db:schema:load, not running all the migrations
|
9
|
+
# from scratch. The latter is a flawed and unsustainable approach (the more migrations
|
10
|
+
# you'll amass, the slower it'll run and the greater likelihood for issues).
|
11
|
+
#
|
12
|
+
# It's strongly recommended to check this file into your version control system.
|
13
|
+
|
14
|
+
ActiveRecord::Schema.define(:version => 20121206225720) do
|
15
|
+
|
16
|
+
create_table "blogs", :force => true do |t|
|
17
|
+
t.string "name"
|
18
|
+
t.text "body"
|
19
|
+
t.datetime "created_at", :null => false
|
20
|
+
t.datetime "updated_at", :null => false
|
21
|
+
end
|
22
|
+
|
23
|
+
create_table "brightcontent_admin_users", :force => true do |t|
|
24
|
+
t.string "email"
|
25
|
+
t.string "password_digest"
|
26
|
+
t.datetime "created_at", :null => false
|
27
|
+
t.datetime "updated_at", :null => false
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
File without changes
|
@@ -0,0 +1,26 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>The page you were looking for doesn't exist (404)</title>
|
5
|
+
<style type="text/css">
|
6
|
+
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
|
7
|
+
div.dialog {
|
8
|
+
width: 25em;
|
9
|
+
padding: 0 4em;
|
10
|
+
margin: 4em auto 0 auto;
|
11
|
+
border: 1px solid #ccc;
|
12
|
+
border-right-color: #999;
|
13
|
+
border-bottom-color: #999;
|
14
|
+
}
|
15
|
+
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
|
16
|
+
</style>
|
17
|
+
</head>
|
18
|
+
|
19
|
+
<body>
|
20
|
+
<!-- This file lives in public/404.html -->
|
21
|
+
<div class="dialog">
|
22
|
+
<h1>The page you were looking for doesn't exist.</h1>
|
23
|
+
<p>You may have mistyped the address or the page may have moved.</p>
|
24
|
+
</div>
|
25
|
+
</body>
|
26
|
+
</html>
|
@@ -0,0 +1,26 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>The change you wanted was rejected (422)</title>
|
5
|
+
<style type="text/css">
|
6
|
+
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
|
7
|
+
div.dialog {
|
8
|
+
width: 25em;
|
9
|
+
padding: 0 4em;
|
10
|
+
margin: 4em auto 0 auto;
|
11
|
+
border: 1px solid #ccc;
|
12
|
+
border-right-color: #999;
|
13
|
+
border-bottom-color: #999;
|
14
|
+
}
|
15
|
+
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
|
16
|
+
</style>
|
17
|
+
</head>
|
18
|
+
|
19
|
+
<body>
|
20
|
+
<!-- This file lives in public/422.html -->
|
21
|
+
<div class="dialog">
|
22
|
+
<h1>The change you wanted was rejected.</h1>
|
23
|
+
<p>Maybe you tried to change something you didn't have access to.</p>
|
24
|
+
</div>
|
25
|
+
</body>
|
26
|
+
</html>
|
@@ -0,0 +1,25 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>We're sorry, but something went wrong (500)</title>
|
5
|
+
<style type="text/css">
|
6
|
+
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
|
7
|
+
div.dialog {
|
8
|
+
width: 25em;
|
9
|
+
padding: 0 4em;
|
10
|
+
margin: 4em auto 0 auto;
|
11
|
+
border: 1px solid #ccc;
|
12
|
+
border-right-color: #999;
|
13
|
+
border-bottom-color: #999;
|
14
|
+
}
|
15
|
+
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
|
16
|
+
</style>
|
17
|
+
</head>
|
18
|
+
|
19
|
+
<body>
|
20
|
+
<!-- This file lives in public/500.html -->
|
21
|
+
<div class="dialog">
|
22
|
+
<h1>We're sorry, but something went wrong.</h1>
|
23
|
+
</div>
|
24
|
+
</body>
|
25
|
+
</html>
|
File without changes
|
@@ -0,0 +1,6 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
|
3
|
+
|
4
|
+
APP_PATH = File.expand_path('../../config/application', __FILE__)
|
5
|
+
require File.expand_path('../../config/boot', __FILE__)
|
6
|
+
require 'rails/commands'
|
@@ -0,0 +1,16 @@
|
|
1
|
+
FactoryGirl.define do
|
2
|
+
sequence :email do |n|
|
3
|
+
"person#{n}@example.com"
|
4
|
+
end
|
5
|
+
|
6
|
+
factory :admin_user, class: Brightcontent::AdminUser do
|
7
|
+
email
|
8
|
+
password "password"
|
9
|
+
password_confirmation "password"
|
10
|
+
end
|
11
|
+
|
12
|
+
factory :blog do
|
13
|
+
name "Blogname"
|
14
|
+
body "Inhoud"
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
feature "Login" do
|
4
|
+
|
5
|
+
scenario "Login with invalid credentials" do
|
6
|
+
sign_in_with_invalid_email
|
7
|
+
page.should have_content "invalid"
|
8
|
+
end
|
9
|
+
|
10
|
+
scenario "Login with valid credentials" do
|
11
|
+
sign_in
|
12
|
+
page.should have_content "Admin users"
|
13
|
+
end
|
14
|
+
|
15
|
+
scenario "User logs out" do
|
16
|
+
sign_in
|
17
|
+
click_link "Logout"
|
18
|
+
page.should have_content "Please sign in"
|
19
|
+
end
|
20
|
+
|
21
|
+
def sign_in_with_invalid_email
|
22
|
+
@user = create(:admin_user)
|
23
|
+
visit "/admin"
|
24
|
+
fill_in "Email", with: @user.email
|
25
|
+
fill_in "Password", with: "wrongpass"
|
26
|
+
click_button "Login"
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
feature "Menu" do
|
4
|
+
|
5
|
+
scenario "Shows default menu" do
|
6
|
+
sign_in
|
7
|
+
menu_should_not_have_link "Sessions"
|
8
|
+
end
|
9
|
+
|
10
|
+
scenario "Shows menu for extra resources" do
|
11
|
+
sign_in
|
12
|
+
menu_should_have_link "Blogs"
|
13
|
+
end
|
14
|
+
|
15
|
+
def menu_should_have_link(link_name)
|
16
|
+
within "#menu" do
|
17
|
+
page.should have_link link_name
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def menu_should_not_have_link(link_name)
|
22
|
+
within "#menu" do
|
23
|
+
page.should have_no_link link_name
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
feature "Resources form" do
|
4
|
+
|
5
|
+
scenario "Adds a new item" do
|
6
|
+
sign_in
|
7
|
+
create_blog "Name for blogitem"
|
8
|
+
page.should have_content "Name for blogitem"
|
9
|
+
end
|
10
|
+
|
11
|
+
scenario "Edits an existing item" do
|
12
|
+
sign_in
|
13
|
+
create_blog "Name for blogitem"
|
14
|
+
update_blog "Name for blogitem", "New blog name"
|
15
|
+
page.should have_content "New blog name"
|
16
|
+
end
|
17
|
+
|
18
|
+
scenario "Removes an item" do
|
19
|
+
sign_in
|
20
|
+
create_blog "Name for blogitem"
|
21
|
+
remove_blog "Name for blogitem"
|
22
|
+
page.should_not have_content "Name for blogitem"
|
23
|
+
end
|
24
|
+
|
25
|
+
def create_blog(title)
|
26
|
+
visit brightcontent.blogs_url
|
27
|
+
click_link "Create new Blog"
|
28
|
+
fill_in "Name", with: title
|
29
|
+
click_button "Create Blog"
|
30
|
+
end
|
31
|
+
|
32
|
+
def update_blog(title, new_title)
|
33
|
+
within_blog_item(title) { click_link "Edit" }
|
34
|
+
fill_in "Name", with: new_title
|
35
|
+
click_button "Update Blog"
|
36
|
+
end
|
37
|
+
|
38
|
+
def remove_blog(title)
|
39
|
+
within_blog_item(title) do
|
40
|
+
click_link "Delete"
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def within_blog_item(title)
|
45
|
+
blog = Blog.find_by_name!(title)
|
46
|
+
within "#blog_#{blog.id}" do
|
47
|
+
yield
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
feature "Resources index" do
|
4
|
+
|
5
|
+
background do
|
6
|
+
sign_in
|
7
|
+
end
|
8
|
+
|
9
|
+
scenario "Visit the index view of resource" do
|
10
|
+
visit_blogs_page
|
11
|
+
page_should_have_valid_table
|
12
|
+
end
|
13
|
+
|
14
|
+
scenario "Multiple pages for items with more than 30 items" do
|
15
|
+
given_31_blog_items
|
16
|
+
visit_blogs_page
|
17
|
+
page.should have_css("tbody tr", :count => 30)
|
18
|
+
click_link "Next"
|
19
|
+
page.should have_css("tbody tr", :count => 1)
|
20
|
+
end
|
21
|
+
|
22
|
+
scenario "Editable paginate count" do
|
23
|
+
given_10_per_page
|
24
|
+
given_31_blog_items
|
25
|
+
visit_blogs_page
|
26
|
+
page.should have_css("tbody tr", :count => 10)
|
27
|
+
end
|
28
|
+
|
29
|
+
def visit_blogs_page
|
30
|
+
click_link "Blogs"
|
31
|
+
end
|
32
|
+
|
33
|
+
def page_should_have_valid_table
|
34
|
+
within "#overview" do
|
35
|
+
page.should have_content "Blogs"
|
36
|
+
page.should have_content "Name"
|
37
|
+
page.should have_content "Body"
|
38
|
+
page.should have_no_content "created_at"
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def given_31_blog_items
|
43
|
+
31.times { create :blog }
|
44
|
+
end
|
45
|
+
|
46
|
+
def given_10_per_page
|
47
|
+
Brightcontent::BlogsController.class_eval { per_page 10 }
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require "brightcontent/routes_parser"
|
2
|
+
|
3
|
+
class Blog ; end
|
4
|
+
class Article ; end
|
5
|
+
|
6
|
+
module Brightcontent
|
7
|
+
describe RoutesParser do
|
8
|
+
let(:engine_resources) { %w{sessions admin_users} }
|
9
|
+
let(:routes_hash) do
|
10
|
+
[ {}, nil, {:action=>"admin"},
|
11
|
+
{:action=>"index", :controller=>"brightcontent/blogs"},
|
12
|
+
{:action=>"create", :controller=>"brightcontent/blogs"} ]
|
13
|
+
end
|
14
|
+
|
15
|
+
subject(:parser) { RoutesParser.parse(routes_hash, engine_resources) }
|
16
|
+
|
17
|
+
it { should eq ["blogs"] }
|
18
|
+
|
19
|
+
context "with extra resource" do
|
20
|
+
before { routes_hash << {:action=>"index", :controller=>"brightcontent/articles"} }
|
21
|
+
it { should eq ["blogs", "articles"] }
|
22
|
+
end
|
23
|
+
|
24
|
+
context "with engine resources" do
|
25
|
+
before do
|
26
|
+
engine_resources.each do |resource_name|
|
27
|
+
routes_hash << {:action=>"index", :controller=>"brightcontent/#{resource_name}"}
|
28
|
+
end
|
29
|
+
end
|
30
|
+
it { should eq ["blogs"] }
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
ENV["RAILS_ENV"] = "test"
|
2
|
+
ENGINE_RAILS_ROOT = File.join(File.dirname(__FILE__), '../')
|
3
|
+
|
4
|
+
require File.expand_path("../dummy/config/environment.rb", __FILE__)
|
5
|
+
require 'rspec/rails'
|
6
|
+
require 'capybara/rspec'
|
7
|
+
require 'factory_girl_rails'
|
8
|
+
require 'brightcontent-core'
|
9
|
+
|
10
|
+
Dir[File.join(ENGINE_RAILS_ROOT, "spec/support/**/*.rb")].each {|f| require f }
|
11
|
+
|
12
|
+
Rails.backtrace_cleaner.remove_silencers!
|
13
|
+
|
14
|
+
RSpec.configure do |config|
|
15
|
+
config.mock_with :rspec
|
16
|
+
config.use_transactional_fixtures = true
|
17
|
+
config.include FactoryGirl::Syntax::Methods
|
18
|
+
end
|
File without changes
|
data/pages/.gitignore
ADDED
data/pages/Gemfile
ADDED
data/pages/Gemfile.lock
ADDED
@@ -0,0 +1,173 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
brightcontent-pages (0.0.1)
|
5
|
+
awesome_nested_set
|
6
|
+
brightcontent-core
|
7
|
+
|
8
|
+
PATH
|
9
|
+
remote: ../core
|
10
|
+
specs:
|
11
|
+
brightcontent-core (2.0.0.alpha2)
|
12
|
+
bcrypt-ruby
|
13
|
+
bootstrap-wysihtml5-rails
|
14
|
+
inherited_resources
|
15
|
+
jquery-rails
|
16
|
+
rails (~> 3.2.9)
|
17
|
+
simple_form
|
18
|
+
will_paginate
|
19
|
+
|
20
|
+
GEM
|
21
|
+
remote: http://rubygems.org/
|
22
|
+
specs:
|
23
|
+
actionmailer (3.2.9)
|
24
|
+
actionpack (= 3.2.9)
|
25
|
+
mail (~> 2.4.4)
|
26
|
+
actionpack (3.2.9)
|
27
|
+
activemodel (= 3.2.9)
|
28
|
+
activesupport (= 3.2.9)
|
29
|
+
builder (~> 3.0.0)
|
30
|
+
erubis (~> 2.7.0)
|
31
|
+
journey (~> 1.0.4)
|
32
|
+
rack (~> 1.4.0)
|
33
|
+
rack-cache (~> 1.2)
|
34
|
+
rack-test (~> 0.6.1)
|
35
|
+
sprockets (~> 2.2.1)
|
36
|
+
activemodel (3.2.9)
|
37
|
+
activesupport (= 3.2.9)
|
38
|
+
builder (~> 3.0.0)
|
39
|
+
activerecord (3.2.9)
|
40
|
+
activemodel (= 3.2.9)
|
41
|
+
activesupport (= 3.2.9)
|
42
|
+
arel (~> 3.0.2)
|
43
|
+
tzinfo (~> 0.3.29)
|
44
|
+
activeresource (3.2.9)
|
45
|
+
activemodel (= 3.2.9)
|
46
|
+
activesupport (= 3.2.9)
|
47
|
+
activesupport (3.2.9)
|
48
|
+
i18n (~> 0.6)
|
49
|
+
multi_json (~> 1.0)
|
50
|
+
addressable (2.3.2)
|
51
|
+
arel (3.0.2)
|
52
|
+
awesome_nested_set (2.1.5)
|
53
|
+
activerecord (>= 3.0.0)
|
54
|
+
bcrypt-ruby (3.0.1)
|
55
|
+
bootstrap-wysihtml5-rails (0.3.1.13)
|
56
|
+
railties (>= 3.0)
|
57
|
+
builder (3.0.4)
|
58
|
+
capybara (2.0.1)
|
59
|
+
mime-types (>= 1.16)
|
60
|
+
nokogiri (>= 1.3.3)
|
61
|
+
rack (>= 1.0.0)
|
62
|
+
rack-test (>= 0.5.4)
|
63
|
+
selenium-webdriver (~> 2.0)
|
64
|
+
xpath (~> 1.0.0)
|
65
|
+
childprocess (0.3.6)
|
66
|
+
ffi (~> 1.0, >= 1.0.6)
|
67
|
+
diff-lcs (1.1.3)
|
68
|
+
erubis (2.7.0)
|
69
|
+
factory_girl (4.1.0)
|
70
|
+
activesupport (>= 3.0.0)
|
71
|
+
factory_girl_rails (4.1.0)
|
72
|
+
factory_girl (~> 4.1.0)
|
73
|
+
railties (>= 3.0.0)
|
74
|
+
ffi (1.2.0)
|
75
|
+
has_scope (0.5.1)
|
76
|
+
hike (1.2.1)
|
77
|
+
i18n (0.6.1)
|
78
|
+
inherited_resources (1.3.1)
|
79
|
+
has_scope (~> 0.5.0)
|
80
|
+
responders (~> 0.6)
|
81
|
+
journey (1.0.4)
|
82
|
+
jquery-rails (2.1.4)
|
83
|
+
railties (>= 3.0, < 5.0)
|
84
|
+
thor (>= 0.14, < 2.0)
|
85
|
+
json (1.7.5)
|
86
|
+
launchy (2.1.2)
|
87
|
+
addressable (~> 2.3)
|
88
|
+
libwebsocket (0.1.7.1)
|
89
|
+
addressable
|
90
|
+
websocket
|
91
|
+
mail (2.4.4)
|
92
|
+
i18n (>= 0.4.0)
|
93
|
+
mime-types (~> 1.16)
|
94
|
+
treetop (~> 1.4.8)
|
95
|
+
mime-types (1.19)
|
96
|
+
multi_json (1.5.0)
|
97
|
+
nokogiri (1.5.6)
|
98
|
+
polyglot (0.3.3)
|
99
|
+
rack (1.4.1)
|
100
|
+
rack-cache (1.2)
|
101
|
+
rack (>= 0.4)
|
102
|
+
rack-ssl (1.3.2)
|
103
|
+
rack
|
104
|
+
rack-test (0.6.2)
|
105
|
+
rack (>= 1.0)
|
106
|
+
rails (3.2.9)
|
107
|
+
actionmailer (= 3.2.9)
|
108
|
+
actionpack (= 3.2.9)
|
109
|
+
activerecord (= 3.2.9)
|
110
|
+
activeresource (= 3.2.9)
|
111
|
+
activesupport (= 3.2.9)
|
112
|
+
bundler (~> 1.0)
|
113
|
+
railties (= 3.2.9)
|
114
|
+
railties (3.2.9)
|
115
|
+
actionpack (= 3.2.9)
|
116
|
+
activesupport (= 3.2.9)
|
117
|
+
rack-ssl (~> 1.3.2)
|
118
|
+
rake (>= 0.8.7)
|
119
|
+
rdoc (~> 3.4)
|
120
|
+
thor (>= 0.14.6, < 2.0)
|
121
|
+
rake (10.0.3)
|
122
|
+
rdoc (3.12)
|
123
|
+
json (~> 1.4)
|
124
|
+
responders (0.9.3)
|
125
|
+
railties (~> 3.1)
|
126
|
+
rspec-core (2.12.2)
|
127
|
+
rspec-expectations (2.12.1)
|
128
|
+
diff-lcs (~> 1.1.3)
|
129
|
+
rspec-mocks (2.12.1)
|
130
|
+
rspec-rails (2.12.0)
|
131
|
+
actionpack (>= 3.0)
|
132
|
+
activesupport (>= 3.0)
|
133
|
+
railties (>= 3.0)
|
134
|
+
rspec-core (~> 2.12.0)
|
135
|
+
rspec-expectations (~> 2.12.0)
|
136
|
+
rspec-mocks (~> 2.12.0)
|
137
|
+
rubyzip (0.9.9)
|
138
|
+
selenium-webdriver (2.27.2)
|
139
|
+
childprocess (>= 0.2.5)
|
140
|
+
libwebsocket (~> 0.1.3)
|
141
|
+
multi_json (~> 1.0)
|
142
|
+
rubyzip
|
143
|
+
simple_form (2.0.4)
|
144
|
+
actionpack (~> 3.0)
|
145
|
+
activemodel (~> 3.0)
|
146
|
+
sprockets (2.2.2)
|
147
|
+
hike (~> 1.2)
|
148
|
+
multi_json (~> 1.0)
|
149
|
+
rack (~> 1.0)
|
150
|
+
tilt (~> 1.1, != 1.3.0)
|
151
|
+
sqlite3 (1.3.6)
|
152
|
+
thor (0.16.0)
|
153
|
+
tilt (1.3.3)
|
154
|
+
treetop (1.4.12)
|
155
|
+
polyglot
|
156
|
+
polyglot (>= 0.3.1)
|
157
|
+
tzinfo (0.3.35)
|
158
|
+
websocket (1.0.6)
|
159
|
+
will_paginate (3.0.3)
|
160
|
+
xpath (1.0.0)
|
161
|
+
nokogiri (~> 1.3)
|
162
|
+
|
163
|
+
PLATFORMS
|
164
|
+
ruby
|
165
|
+
|
166
|
+
DEPENDENCIES
|
167
|
+
brightcontent-core!
|
168
|
+
brightcontent-pages!
|
169
|
+
capybara
|
170
|
+
factory_girl_rails
|
171
|
+
launchy
|
172
|
+
rspec-rails
|
173
|
+
sqlite3
|
data/pages/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2012 YOURNAME
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/pages/README.md
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
Requirements
|
2
|
+
------------
|
3
|
+
|
4
|
+
Brightcontent
|
5
|
+
|
6
|
+
Installation
|
7
|
+
------------
|
8
|
+
|
9
|
+
Include the gem in your Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem "brightcontent", :git => "git://github.com/stexy/brightcontent.git"
|
13
|
+
gem "brightcontent-pages", :git => "git://github.com/stexy/brightcontent-pages.git"
|
14
|
+
bundle install
|
15
|
+
```
|
16
|
+
|
17
|
+
Generate the initializer, copy migrations and edit routes file. This can be done via a generator. Migrate the database afterwards:
|
18
|
+
|
19
|
+
$ rails generate brightcontent:install
|
20
|
+
$ rails generate brightcontent:pages:install
|
21
|
+
$ rake db:migrate
|
22
|
+
|
23
|
+
Go to `/admin` and login with default user (email: `admin@example.com` / password: `password`).
|
24
|
+
|
25
|
+
|
26
|
+
Usage
|
27
|
+
-----
|
28
|
+
|
29
|
+
Pages gives you a Page model with tree structure and pretty urls. Every page relates to a specific path. For example, you could create a page with the path `/about/team`. The page is available on the url via `current_page`.
|
30
|
+
|
31
|
+
This adds an extra layer on top of your existing routes. However when there aren't any routes available for the specific url, Rails cannot render the page. Therefore it is best to add a catch-all route (at the very bottom of the file) for all general pages:
|
32
|
+
|
33
|
+
```ruby
|
34
|
+
get "*path" => "pages#show"
|
35
|
+
```
|