content_engine 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +4 -0
- data/Gemfile +40 -0
- data/README.md +43 -0
- data/Rakefile +86 -0
- data/VERSION +1 -0
- data/app/controllers/content_engine/articles_controller.rb +54 -0
- data/app/controllers/content_engine/pages_controller.rb +76 -0
- data/app/controllers/content_engine_controller.rb +14 -0
- data/app/helpers/application_helper.rb +2 -0
- data/app/models/article.rb +29 -0
- data/app/models/content.rb +64 -0
- data/app/models/page.rb +40 -0
- data/app/models/site.rb +26 -0
- data/app/models/tag.rb +53 -0
- data/app/models/user.rb +5 -0
- data/app/views/content_engine/articles/_form.erb +8 -0
- data/app/views/content_engine/articles/edit.html.erb +7 -0
- data/app/views/content_engine/articles/index.html.erb +10 -0
- data/app/views/content_engine/articles/new.html.erb +6 -0
- data/app/views/content_engine/articles/show.html.erb +9 -0
- data/app/views/content_engine/pages/_form.erb +8 -0
- data/app/views/content_engine/pages/edit.html.erb +7 -0
- data/app/views/content_engine/pages/index.html.erb +10 -0
- data/app/views/content_engine/pages/new.html.erb +6 -0
- data/app/views/content_engine/pages/show.html.erb +9 -0
- data/app/views/layouts/application.html.erb +16 -0
- data/config/application.rb +1 -0
- data/config/locales/en.yml +5 -0
- data/config/routes.rb +25 -0
- data/content_engine.gemspec +167 -0
- data/db/migrate/20100225105011_create_contents.rb +22 -0
- data/db/migrate/20100225105903_create_users.rb +8 -0
- data/db/migrate/20100225110024_create_sites.rb +15 -0
- data/db/migrate/20100225110037_create_memberships.rb +12 -0
- data/db/migrate/20100225112236_acts_as_taggable_on.rb +26 -0
- data/db/schema.rb +58 -0
- data/lib/content_engine.rb +24 -0
- data/lib/tasks/content_engine.rake +24 -0
- data/spec/blueprint.rb +41 -0
- data/spec/models/article_spec.rb +56 -0
- data/spec/models/page_spec.rb +158 -0
- data/spec/models/site_spec.rb +32 -0
- data/spec/rails_app/.gitignore +4 -0
- data/spec/rails_app/Rakefile +10 -0
- data/spec/rails_app/app/controllers/admins_controller.rb +6 -0
- data/spec/rails_app/app/controllers/application_controller.rb +6 -0
- data/spec/rails_app/app/controllers/home_controller.rb +4 -0
- data/spec/rails_app/app/controllers/sessions_controller.rb +6 -0
- data/spec/rails_app/app/controllers/users_controller.rb +12 -0
- data/spec/rails_app/app/helpers/application_helper.rb +3 -0
- data/spec/rails_app/app/views/home/index.html.erb +1 -0
- data/spec/rails_app/app/views/layouts/application.html.erb +19 -0
- data/spec/rails_app/config/application.rb +30 -0
- data/spec/rails_app/config/boot.rb +9 -0
- data/spec/rails_app/config/database.yml +16 -0
- data/spec/rails_app/config/environment.rb +5 -0
- data/spec/rails_app/config/environments/development.rb +19 -0
- data/spec/rails_app/config/environments/production.rb +33 -0
- data/spec/rails_app/config/environments/test.rb +29 -0
- data/spec/rails_app/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/rails_app/config/initializers/cookie_verification_secret.rb +7 -0
- data/spec/rails_app/config/initializers/inflections.rb +2 -0
- data/spec/rails_app/config/initializers/session_store.rb +15 -0
- data/spec/rails_app/config/routes.rb +21 -0
- data/spec/rails_app/config.ru +4 -0
- data/spec/rails_app/db/migrate/20100225105011_create_contents.rb +22 -0
- data/spec/rails_app/db/migrate/20100225105903_create_users.rb +8 -0
- data/spec/rails_app/db/migrate/20100225110024_create_sites.rb +15 -0
- data/spec/rails_app/db/migrate/20100225110037_create_memberships.rb +12 -0
- data/spec/rails_app/db/migrate/20100225112236_acts_as_taggable_on.rb +26 -0
- data/spec/rails_app/db/schema.rb +59 -0
- data/spec/rails_app/public/404.html +26 -0
- data/spec/rails_app/public/422.html +26 -0
- data/spec/rails_app/public/500.html +26 -0
- data/spec/rails_app/public/favicon.ico +0 -0
- data/spec/rails_app/public/images/rails.png +0 -0
- data/spec/rails_app/public/javascripts/application.js +2 -0
- data/spec/rails_app/public/javascripts/controls.js +963 -0
- data/spec/rails_app/public/javascripts/dragdrop.js +973 -0
- data/spec/rails_app/public/javascripts/effects.js +1128 -0
- data/spec/rails_app/public/javascripts/prototype.js +4320 -0
- data/spec/rails_app/public/javascripts/rails.js +110 -0
- data/spec/rails_app/public/robots.txt +5 -0
- data/spec/rails_app/public/stylesheets/.gitkeep +0 -0
- data/spec/rails_app/script/rails +10 -0
- data/spec/requests/user_manage_articles_spec.rb +85 -0
- data/spec/requests/user_manage_pages_spec.rb +92 -0
- data/spec/requests/webrat.log +17 -0
- data/spec/spec.opts +2 -0
- data/spec/spec_helper.rb +36 -0
- metadata +226 -0
data/config/routes.rb
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
Rails::Application.routes.draw do
|
2
|
+
# resources :users, :only => [:index] do
|
3
|
+
# get :expire, :on => :member
|
4
|
+
# end
|
5
|
+
#
|
6
|
+
# resources :admins, :only => [:index]
|
7
|
+
#
|
8
|
+
# devise_for :users
|
9
|
+
# devise_for :admin, :as => "admin_area", :controllers => { :sessions => "sessions" }
|
10
|
+
# devise_for :accounts, :scope => "manager", :path_prefix => ":locale",
|
11
|
+
# :class_name => "User", :path_names => {
|
12
|
+
# :sign_in => "login", :sign_out => "logout",
|
13
|
+
# :password => "secret", :confirmation => "verification",
|
14
|
+
# :unlock => "unblock", :sign_up => "register"
|
15
|
+
# }
|
16
|
+
#
|
17
|
+
# match "/admin_area/home", :to => "admins#index", :as => :admin_root
|
18
|
+
# match "/sign_in", :to => "devise/sessions#new"
|
19
|
+
|
20
|
+
resources :pages, :controller => 'content_engine/pages'
|
21
|
+
resources :articles, :controller => 'content_engine/articles'
|
22
|
+
|
23
|
+
match "/:year/:month/:id", :to => "content_engine/articles#show", :requirements => {:year => /\d{4}/, :month => /\d{2}/}
|
24
|
+
match "/*url", :to => 'content_engine/pages#lookup'
|
25
|
+
end
|
@@ -0,0 +1,167 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{content_engine}
|
8
|
+
s.version = "0.1.0"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Taylor Luk"]
|
12
|
+
s.date = %q{2010-02-28}
|
13
|
+
s.description = %q{Extracted from shop2, site-rest}
|
14
|
+
s.email = %q{taylor.luk@idealian.net}
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"README.md"
|
17
|
+
]
|
18
|
+
s.files = [
|
19
|
+
".gitignore",
|
20
|
+
"Gemfile",
|
21
|
+
"README.md",
|
22
|
+
"Rakefile",
|
23
|
+
"VERSION",
|
24
|
+
"app/controllers/content_engine/articles_controller.rb",
|
25
|
+
"app/controllers/content_engine/pages_controller.rb",
|
26
|
+
"app/controllers/content_engine_controller.rb",
|
27
|
+
"app/helpers/application_helper.rb",
|
28
|
+
"app/models/article.rb",
|
29
|
+
"app/models/content.rb",
|
30
|
+
"app/models/page.rb",
|
31
|
+
"app/models/site.rb",
|
32
|
+
"app/models/tag.rb",
|
33
|
+
"app/models/user.rb",
|
34
|
+
"app/views/content_engine/articles/_form.erb",
|
35
|
+
"app/views/content_engine/articles/edit.html.erb",
|
36
|
+
"app/views/content_engine/articles/index.html.erb",
|
37
|
+
"app/views/content_engine/articles/new.html.erb",
|
38
|
+
"app/views/content_engine/articles/show.html.erb",
|
39
|
+
"app/views/content_engine/pages/_form.erb",
|
40
|
+
"app/views/content_engine/pages/edit.html.erb",
|
41
|
+
"app/views/content_engine/pages/index.html.erb",
|
42
|
+
"app/views/content_engine/pages/new.html.erb",
|
43
|
+
"app/views/content_engine/pages/show.html.erb",
|
44
|
+
"app/views/layouts/application.html.erb",
|
45
|
+
"config/application.rb",
|
46
|
+
"config/locales/en.yml",
|
47
|
+
"config/routes.rb",
|
48
|
+
"content_engine.gemspec",
|
49
|
+
"db/migrate/20100225105011_create_contents.rb",
|
50
|
+
"db/migrate/20100225105903_create_users.rb",
|
51
|
+
"db/migrate/20100225110024_create_sites.rb",
|
52
|
+
"db/migrate/20100225110037_create_memberships.rb",
|
53
|
+
"db/migrate/20100225112236_acts_as_taggable_on.rb",
|
54
|
+
"db/schema.rb",
|
55
|
+
"lib/content_engine.rb",
|
56
|
+
"lib/tasks/content_engine.rake",
|
57
|
+
"spec/blueprint.rb",
|
58
|
+
"spec/models/article_spec.rb",
|
59
|
+
"spec/models/page_spec.rb",
|
60
|
+
"spec/models/site_spec.rb",
|
61
|
+
"spec/rails_app/.gitignore",
|
62
|
+
"spec/rails_app/Rakefile",
|
63
|
+
"spec/rails_app/app/controllers/application_controller.rb",
|
64
|
+
"spec/rails_app/app/controllers/home_controller.rb",
|
65
|
+
"spec/rails_app/app/helpers/application_helper.rb",
|
66
|
+
"spec/rails_app/app/views/home/index.html.erb",
|
67
|
+
"spec/rails_app/app/views/layouts/application.html.erb",
|
68
|
+
"spec/rails_app/config.ru",
|
69
|
+
"spec/rails_app/config/application.rb",
|
70
|
+
"spec/rails_app/config/boot.rb",
|
71
|
+
"spec/rails_app/config/database.yml",
|
72
|
+
"spec/rails_app/config/environment.rb",
|
73
|
+
"spec/rails_app/config/environments/development.rb",
|
74
|
+
"spec/rails_app/config/environments/production.rb",
|
75
|
+
"spec/rails_app/config/environments/test.rb",
|
76
|
+
"spec/rails_app/config/initializers/backtrace_silencers.rb",
|
77
|
+
"spec/rails_app/config/initializers/cookie_verification_secret.rb",
|
78
|
+
"spec/rails_app/config/initializers/inflections.rb",
|
79
|
+
"spec/rails_app/config/initializers/session_store.rb",
|
80
|
+
"spec/rails_app/config/routes.rb",
|
81
|
+
"spec/rails_app/db/migrate/20100225105011_create_contents.rb",
|
82
|
+
"spec/rails_app/db/migrate/20100225105903_create_users.rb",
|
83
|
+
"spec/rails_app/db/migrate/20100225110024_create_sites.rb",
|
84
|
+
"spec/rails_app/db/migrate/20100225110037_create_memberships.rb",
|
85
|
+
"spec/rails_app/db/migrate/20100225112236_acts_as_taggable_on.rb",
|
86
|
+
"spec/rails_app/db/schema.rb",
|
87
|
+
"spec/rails_app/public/404.html",
|
88
|
+
"spec/rails_app/public/422.html",
|
89
|
+
"spec/rails_app/public/500.html",
|
90
|
+
"spec/rails_app/public/favicon.ico",
|
91
|
+
"spec/rails_app/public/images/rails.png",
|
92
|
+
"spec/rails_app/public/javascripts/application.js",
|
93
|
+
"spec/rails_app/public/javascripts/controls.js",
|
94
|
+
"spec/rails_app/public/javascripts/dragdrop.js",
|
95
|
+
"spec/rails_app/public/javascripts/effects.js",
|
96
|
+
"spec/rails_app/public/javascripts/prototype.js",
|
97
|
+
"spec/rails_app/public/javascripts/rails.js",
|
98
|
+
"spec/rails_app/public/robots.txt",
|
99
|
+
"spec/rails_app/public/stylesheets/.gitkeep",
|
100
|
+
"spec/rails_app/script/rails",
|
101
|
+
"spec/requests/user_manage_articles_spec.rb",
|
102
|
+
"spec/requests/user_manage_pages_spec.rb",
|
103
|
+
"spec/requests/webrat.log",
|
104
|
+
"spec/spec.opts",
|
105
|
+
"spec/spec_helper.rb"
|
106
|
+
]
|
107
|
+
s.homepage = %q{http://github.com/idealian/content_engine}
|
108
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
109
|
+
s.require_paths = ["lib"]
|
110
|
+
s.rubygems_version = %q{1.3.6}
|
111
|
+
s.summary = %q{A Rails 3 Engine for sexier site and content management}
|
112
|
+
s.test_files = [
|
113
|
+
"spec/blueprint.rb",
|
114
|
+
"spec/models/article_spec.rb",
|
115
|
+
"spec/models/page_spec.rb",
|
116
|
+
"spec/models/site_spec.rb",
|
117
|
+
"spec/rails_app/app/controllers/admins_controller.rb",
|
118
|
+
"spec/rails_app/app/controllers/application_controller.rb",
|
119
|
+
"spec/rails_app/app/controllers/home_controller.rb",
|
120
|
+
"spec/rails_app/app/controllers/sessions_controller.rb",
|
121
|
+
"spec/rails_app/app/controllers/users_controller.rb",
|
122
|
+
"spec/rails_app/app/helpers/application_helper.rb",
|
123
|
+
"spec/rails_app/config/application.rb",
|
124
|
+
"spec/rails_app/config/boot.rb",
|
125
|
+
"spec/rails_app/config/environment.rb",
|
126
|
+
"spec/rails_app/config/environments/development.rb",
|
127
|
+
"spec/rails_app/config/environments/production.rb",
|
128
|
+
"spec/rails_app/config/environments/test.rb",
|
129
|
+
"spec/rails_app/config/initializers/backtrace_silencers.rb",
|
130
|
+
"spec/rails_app/config/initializers/cookie_verification_secret.rb",
|
131
|
+
"spec/rails_app/config/initializers/inflections.rb",
|
132
|
+
"spec/rails_app/config/initializers/session_store.rb",
|
133
|
+
"spec/rails_app/config/routes.rb",
|
134
|
+
"spec/rails_app/db/migrate/20100225105011_create_contents.rb",
|
135
|
+
"spec/rails_app/db/migrate/20100225105903_create_users.rb",
|
136
|
+
"spec/rails_app/db/migrate/20100225110024_create_sites.rb",
|
137
|
+
"spec/rails_app/db/migrate/20100225110037_create_memberships.rb",
|
138
|
+
"spec/rails_app/db/migrate/20100225112236_acts_as_taggable_on.rb",
|
139
|
+
"spec/rails_app/db/schema.rb",
|
140
|
+
"spec/requests/user_manage_articles_spec.rb",
|
141
|
+
"spec/requests/user_manage_pages_spec.rb",
|
142
|
+
"spec/spec_helper.rb"
|
143
|
+
]
|
144
|
+
|
145
|
+
if s.respond_to? :specification_version then
|
146
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
147
|
+
s.specification_version = 3
|
148
|
+
|
149
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
150
|
+
s.add_runtime_dependency(%q<will_paginate>, [">= 0"])
|
151
|
+
s.add_runtime_dependency(%q<rdiscount>, [">= 0"])
|
152
|
+
s.add_runtime_dependency(%q<formtastic>, [">= 0"])
|
153
|
+
s.add_development_dependency(%q<rspec>, [">= 1.2.9"])
|
154
|
+
else
|
155
|
+
s.add_dependency(%q<will_paginate>, [">= 0"])
|
156
|
+
s.add_dependency(%q<rdiscount>, [">= 0"])
|
157
|
+
s.add_dependency(%q<formtastic>, [">= 0"])
|
158
|
+
s.add_dependency(%q<rspec>, [">= 1.2.9"])
|
159
|
+
end
|
160
|
+
else
|
161
|
+
s.add_dependency(%q<will_paginate>, [">= 0"])
|
162
|
+
s.add_dependency(%q<rdiscount>, [">= 0"])
|
163
|
+
s.add_dependency(%q<formtastic>, [">= 0"])
|
164
|
+
s.add_dependency(%q<rspec>, [">= 1.2.9"])
|
165
|
+
end
|
166
|
+
end
|
167
|
+
|
@@ -0,0 +1,22 @@
|
|
1
|
+
class CreateContents < ActiveRecord::Migration
|
2
|
+
def self.up
|
3
|
+
create_table :contents do |t|
|
4
|
+
t.string :title
|
5
|
+
t.string :permalink
|
6
|
+
t.text :description
|
7
|
+
t.text :body
|
8
|
+
t.string :type, :default => 'Page'
|
9
|
+
t.integer :parent_id
|
10
|
+
t.integer :site_id
|
11
|
+
t.integer :user_id
|
12
|
+
t.integer :lft
|
13
|
+
t.integer :rgt
|
14
|
+
t.datetime :published_at
|
15
|
+
t.timestamps
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.down
|
20
|
+
drop_table :contents
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
class CreateSites < ActiveRecord::Migration
|
2
|
+
def self.up
|
3
|
+
create_table :sites do |t|
|
4
|
+
t.string :title
|
5
|
+
t.text :description
|
6
|
+
t.string :time_zone
|
7
|
+
t.integer :owner_id
|
8
|
+
t.string :host
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.down
|
13
|
+
drop_table :sites
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
class ActsAsTaggableOn < ActiveRecord::Migration
|
2
|
+
def self.up
|
3
|
+
create_table :tags do |t|
|
4
|
+
t.column :name, :string
|
5
|
+
end
|
6
|
+
|
7
|
+
create_table :taggings do |t|
|
8
|
+
t.column :tag_id, :integer
|
9
|
+
t.column :taggable_id, :integer
|
10
|
+
t.column :tagger_id, :integer
|
11
|
+
t.column :tagger_type, :string
|
12
|
+
|
13
|
+
# You should make sure that the column created is
|
14
|
+
# long enough to store the required class names.
|
15
|
+
t.column :taggable_type, :string
|
16
|
+
t.column :context, :string
|
17
|
+
|
18
|
+
t.column :created_at, :datetime
|
19
|
+
end
|
20
|
+
|
21
|
+
add_index :taggings, :tag_id
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.down
|
25
|
+
end
|
26
|
+
end
|
data/db/schema.rb
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
# This file is auto-generated from the current state of the database. Instead of editing this file,
|
2
|
+
# please use the migrations feature of Active Record to incrementally modify your database, and
|
3
|
+
# then regenerate this schema definition.
|
4
|
+
#
|
5
|
+
# Note that this schema.rb definition is the authoritative source for your database schema. If you need
|
6
|
+
# to create the application database on another system, you should be using db:schema:load, not running
|
7
|
+
# all the migrations from scratch. The latter is a flawed and unsustainable approach (the more migrations
|
8
|
+
# you'll amass, the slower it'll run and the greater likelihood for issues).
|
9
|
+
#
|
10
|
+
# It's strongly recommended to check this file into your version control system.
|
11
|
+
ActiveRecord::Schema.define(:version => 20100225112236) do
|
12
|
+
|
13
|
+
create_table "contents", :force => true do |t|
|
14
|
+
t.string "title"
|
15
|
+
t.string "permalink"
|
16
|
+
t.text "description"
|
17
|
+
t.text "body"
|
18
|
+
t.string "type", :default => "Page"
|
19
|
+
t.integer "parent_id"
|
20
|
+
t.integer "site_id"
|
21
|
+
t.integer "user_id"
|
22
|
+
t.integer "lft"
|
23
|
+
t.integer "rgt"
|
24
|
+
t.datetime "published_at"
|
25
|
+
t.datetime "created_at"
|
26
|
+
t.datetime "updated_at"
|
27
|
+
end
|
28
|
+
|
29
|
+
create_table "memberships", :force => true do |t|
|
30
|
+
t.integer "site_id"
|
31
|
+
t.integer "user_id"
|
32
|
+
end
|
33
|
+
|
34
|
+
create_table "sites", :force => true do |t|
|
35
|
+
t.string "title"
|
36
|
+
t.text "description"
|
37
|
+
t.string "time_zone"
|
38
|
+
t.integer "owner_id"
|
39
|
+
t.string "host"
|
40
|
+
end
|
41
|
+
|
42
|
+
create_table "taggings", :force => true do |t|
|
43
|
+
t.integer "tag_id"
|
44
|
+
t.integer "taggable_id"
|
45
|
+
t.integer "tagger_id"
|
46
|
+
t.string "tagger_type"
|
47
|
+
t.string "taggable_type"
|
48
|
+
t.string "context"
|
49
|
+
t.datetime "created_at"
|
50
|
+
end
|
51
|
+
|
52
|
+
add_index "taggings", ["tag_id"], :name => "index_taggings_on_tag_id"
|
53
|
+
|
54
|
+
create_table "tags", :force => true do |t|
|
55
|
+
t.string "name"
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'rdiscount'
|
2
|
+
require 'will_paginate'
|
3
|
+
require 'formtastic'
|
4
|
+
|
5
|
+
module ContentEngine
|
6
|
+
class Engine < ::Rails::Engine
|
7
|
+
engine_name :content_engine
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
|
12
|
+
# Mixing in plugin methods
|
13
|
+
|
14
|
+
# Permalink Fu
|
15
|
+
ActiveRecord::Base.send(:extend, PermalinkFu::PluginMethods)
|
16
|
+
|
17
|
+
# ActsAsTaggableOn
|
18
|
+
ActiveRecord::Base.send :include, ActiveRecord::Acts::TaggableOn
|
19
|
+
ActiveRecord::Base.send :include, ActiveRecord::Acts::Tagger
|
20
|
+
ActionView::Base.send :include, TagsHelper if defined?(ActionView::Base)
|
21
|
+
|
22
|
+
# require 'formtastic/layout_helper'
|
23
|
+
ActionView::Base.send :include, Formtastic::SemanticFormHelper
|
24
|
+
# ActionView::Base.send :include, Formtastic::LayoutHelper
|
@@ -0,0 +1,24 @@
|
|
1
|
+
namespace :content_engine do
|
2
|
+
|
3
|
+
desc "Generate content engine migration files"
|
4
|
+
task :migrate do
|
5
|
+
puts "Generating migration files"
|
6
|
+
|
7
|
+
system "rsync -ruv #{File.expand_path('../../../db/migrate', __FILE__)} db"
|
8
|
+
|
9
|
+
puts "========================="
|
10
|
+
puts " Please run db:migrate"
|
11
|
+
puts "========================="
|
12
|
+
end
|
13
|
+
|
14
|
+
desc "Execute pending migration and create default site"
|
15
|
+
task :install => :environment do
|
16
|
+
unless ENV.include?("site")
|
17
|
+
raise 'usage: rake content_engine:install site="My site name"'
|
18
|
+
end
|
19
|
+
|
20
|
+
Rake::Task["db:migrate"].invoke
|
21
|
+
|
22
|
+
Site.create(:name => ENV["site"])
|
23
|
+
end
|
24
|
+
end
|
data/spec/blueprint.rb
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'machinist/active_record'
|
2
|
+
require 'sham'
|
3
|
+
require 'faker'
|
4
|
+
|
5
|
+
Sham.name { Faker::Name.name }
|
6
|
+
Sham.email { Faker::Internet.email }
|
7
|
+
Sham.login { Faker::Internet.user_name }
|
8
|
+
Sham.title { Faker::Lorem.sentence }
|
9
|
+
Sham.host{|n| "something-else-#{n}"}
|
10
|
+
Sham.body { Faker::Company.bs }
|
11
|
+
|
12
|
+
|
13
|
+
Site.blueprint do
|
14
|
+
title "Article title"
|
15
|
+
host
|
16
|
+
end
|
17
|
+
#
|
18
|
+
Article.blueprint do
|
19
|
+
title
|
20
|
+
body
|
21
|
+
# site { Site.current }
|
22
|
+
end
|
23
|
+
|
24
|
+
Page.blueprint do
|
25
|
+
title
|
26
|
+
body
|
27
|
+
published_at {Time.now.utc}
|
28
|
+
# site { Site.current }
|
29
|
+
end
|
30
|
+
|
31
|
+
User.blueprint do
|
32
|
+
login
|
33
|
+
email
|
34
|
+
# password "test password"
|
35
|
+
# password_confirmation "test password"
|
36
|
+
end
|
37
|
+
#
|
38
|
+
# Tag.blueprint do
|
39
|
+
# title { Sham.title }
|
40
|
+
# body "Page body <br />......</br/> The end"
|
41
|
+
# end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Article do
|
4
|
+
# context "Validation" do
|
5
|
+
# should_validate_presence_of :title, :body
|
6
|
+
# should_belong_to :site
|
7
|
+
# should_belong_to :user
|
8
|
+
# end
|
9
|
+
|
10
|
+
before do
|
11
|
+
@site = Site.make
|
12
|
+
@post_1 = @site.articles.make(:title => "first post")
|
13
|
+
@post_2 = @site.articles.make(:title => "second post")
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should set published_at when publish" do
|
17
|
+
article = @site.articles.make
|
18
|
+
article.published?.should == false
|
19
|
+
|
20
|
+
article.publish!
|
21
|
+
|
22
|
+
article.published?.should == true
|
23
|
+
article.published_at.should be_a(Time)
|
24
|
+
end
|
25
|
+
|
26
|
+
it "has link to prev article" do
|
27
|
+
@post_1.publish!
|
28
|
+
@post_2.publish!
|
29
|
+
|
30
|
+
@post_1.prev.should == nil
|
31
|
+
@post_2.prev.should == @post_1
|
32
|
+
end
|
33
|
+
|
34
|
+
it "has link to next article" do
|
35
|
+
@post_1.publish!
|
36
|
+
@post_2.publish!
|
37
|
+
|
38
|
+
@post_1.next.should == @post_2
|
39
|
+
@post_2.next.should == nil
|
40
|
+
end
|
41
|
+
|
42
|
+
it "has a article style url (/:year/:month/:permalink)" do
|
43
|
+
pattern = /^\/articles\/[0-9]{4}\/[0-9]{2}\/[0-9]{2}\/([a-z0-9-]+)$/
|
44
|
+
Article.make.url.should =~ pattern
|
45
|
+
end
|
46
|
+
|
47
|
+
context "Tagging" do
|
48
|
+
it "tag list for multiple tagging" do
|
49
|
+
@post_1.tag_list = 'ruby, rails'
|
50
|
+
|
51
|
+
@post_1.save
|
52
|
+
|
53
|
+
@post_1.should have(2).tags
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,158 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Page do
|
4
|
+
before do
|
5
|
+
@site = Site.make
|
6
|
+
end
|
7
|
+
#
|
8
|
+
# context "Validations" do
|
9
|
+
# it { should validate_presence_of :title, :body, :site_id }
|
10
|
+
# it { should belong_to :site }
|
11
|
+
# it { should belong_to :user }
|
12
|
+
# end
|
13
|
+
|
14
|
+
context "Page content" do
|
15
|
+
before do
|
16
|
+
@page = @site.pages.make(:body => '# hello world')
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should make markdown into html" do
|
20
|
+
@page.body.should =~ /<h1>hello world<\/h1>/
|
21
|
+
|
22
|
+
p2 = @site.pages.make(:body => "testing content body")
|
23
|
+
p2.body.should =~ /<p>testing content body<\/p>/
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should have access of original source" do
|
27
|
+
@page.body_source.should == '# hello world'
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
context "Page hierachy" do
|
32
|
+
before do
|
33
|
+
@site.pages.count.should == 0
|
34
|
+
|
35
|
+
@page = @site.pages.make(:body => 'home page content')
|
36
|
+
end
|
37
|
+
|
38
|
+
it "should mark the first page of a site as homepage" do
|
39
|
+
@page.root?.should == true
|
40
|
+
|
41
|
+
@page.children.make(:body => 'second page').root?.should == false
|
42
|
+
end
|
43
|
+
|
44
|
+
it "all pages without a parent becomes direct children of home page" do
|
45
|
+
page = @site.pages.make(:title => 'standard page')
|
46
|
+
page2 = @site.pages.make(:title => 'standard page 2')
|
47
|
+
|
48
|
+
@page.children.first.should == page
|
49
|
+
@page.children.second.should == page2
|
50
|
+
|
51
|
+
page.root?.should == false
|
52
|
+
page2.root?.should == false
|
53
|
+
end
|
54
|
+
|
55
|
+
it "should have child pages" do
|
56
|
+
3.times { @page.children.make }
|
57
|
+
@page.children.count.should == 3
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
context "Page url" do
|
62
|
+
before do
|
63
|
+
@site.pages.count.should == 0
|
64
|
+
@page = @site.pages.make(:title => 'home page content')
|
65
|
+
end
|
66
|
+
|
67
|
+
it "should permalink should be valid" do
|
68
|
+
page = @site.pages.make(:title => 'Some of the most complecated page title !@#!123123')
|
69
|
+
page.permalink.should =~ /[a-z0-9-]+/
|
70
|
+
end
|
71
|
+
|
72
|
+
it "should make / as root url" do
|
73
|
+
@page.url.should == '/'
|
74
|
+
end
|
75
|
+
|
76
|
+
it "should make subpage url" do
|
77
|
+
@page.children.make(:title => 'sub page').url.should == '/sub-page'
|
78
|
+
end
|
79
|
+
|
80
|
+
it "should make url based on all ancestors" do
|
81
|
+
page2 = @page.children.make(:title => 'sub page 2')
|
82
|
+
page2.url.should == '/sub-page-2'
|
83
|
+
|
84
|
+
page3 = page2.children.make(:title => 'sub sub page')
|
85
|
+
page3.url.should == '/sub-page-2/sub-sub-page'
|
86
|
+
end
|
87
|
+
|
88
|
+
it "should be able to find by page url" do
|
89
|
+
@site.pages.destroy_all
|
90
|
+
|
91
|
+
p1 = @site.pages.make(:title => 'home page yo')
|
92
|
+
p2 = p1.children.make(:title => 'about')
|
93
|
+
p3 = p2.children.make(:title => 'about taylor')
|
94
|
+
|
95
|
+
@site.pages.root.should == p1
|
96
|
+
@site.pages.find_by_url('/about').should == p2
|
97
|
+
@site.pages.find_by_url('/about/about-taylor').should == p3
|
98
|
+
@site.pages.find_by_url('/about/about-taylor/not-exists').should == nil
|
99
|
+
|
100
|
+
p4 = @site.pages.make(:title => 'sections')
|
101
|
+
p5 = @site.pages.make(:title => 'customer support', :parent => p4)
|
102
|
+
p6 = @site.pages.make(:title => 'Return and Refund', :parent => p5)
|
103
|
+
|
104
|
+
@site.pages.find_by_url('/sections/customer-support/return-and-refund').should == p6
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
context "Permalink scoping" do
|
109
|
+
it "should be unique permalink within a site" do
|
110
|
+
# Site one
|
111
|
+
@site.pages.make(:title => 'home')
|
112
|
+
@site.pages.make(:title => 'about')
|
113
|
+
@site.pages.make(:title => 'profile')
|
114
|
+
|
115
|
+
# Site two
|
116
|
+
@site2 = Site.make(:title => 'different site')
|
117
|
+
@site2.pages.make :title => 'home' do |page|
|
118
|
+
page.children.make(:title => 'about', :site => @site2)
|
119
|
+
page.children.make(:title => 'profile', :site => @site2)
|
120
|
+
end
|
121
|
+
|
122
|
+
@site.pages.find_by_url('about').site.should == @site
|
123
|
+
@site2.pages.find_by_url('about').site.should == @site2
|
124
|
+
end
|
125
|
+
|
126
|
+
it "should scoped to a parent_id" do
|
127
|
+
p1 = @site.pages.make(:title => 'home')
|
128
|
+
p2 = @site.pages.make(:title => 'about')
|
129
|
+
|
130
|
+
p3 = @site.pages.make(:title => 'company')
|
131
|
+
p4 = p3.children.make(:title => 'about')
|
132
|
+
|
133
|
+
|
134
|
+
p2.permalink.should == 'about'
|
135
|
+
p4.permalink.should == 'about'
|
136
|
+
|
137
|
+
@site.pages.find_by_url('about').should == p2
|
138
|
+
@site.pages.find_by_url('company/about').should == p4
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
142
|
+
context "Tagging" do
|
143
|
+
it "tag list for multiple tagging" do
|
144
|
+
@page = @site.pages.make(:body => 'home page content')
|
145
|
+
|
146
|
+
@page.tag_list = 'ruby, rails'
|
147
|
+
|
148
|
+
@page.save
|
149
|
+
|
150
|
+
@page.should have(2).tags
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
154
|
+
#
|
155
|
+
# after do
|
156
|
+
# @site.destroy
|
157
|
+
# end
|
158
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Site do
|
4
|
+
before do
|
5
|
+
@site = Site.make
|
6
|
+
@first_page = @site.pages.make(:title => 'home')
|
7
|
+
@second_page = @site.pages.make(:title => 'about us')
|
8
|
+
end
|
9
|
+
|
10
|
+
it "has a homepage" do
|
11
|
+
@site.homepage.should be_a(Page)
|
12
|
+
end
|
13
|
+
|
14
|
+
it "marks the first page as homepage" do
|
15
|
+
@site.homepage.should == @first_page
|
16
|
+
end
|
17
|
+
|
18
|
+
it "has many pages" do
|
19
|
+
@site.pages.count.should == 2
|
20
|
+
end
|
21
|
+
|
22
|
+
it "has many articles" do
|
23
|
+
@post_1 = @site.articles.make(:title => "first post")
|
24
|
+
@post_2 = @site.articles.make(:title => "second post")
|
25
|
+
|
26
|
+
@site.should have(2).articles
|
27
|
+
end
|
28
|
+
|
29
|
+
it "finds pages by url" do
|
30
|
+
@site.pages.find_by_url("")
|
31
|
+
end
|
32
|
+
end
|