thesis 0.0.1 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +147 -7
- data/lib/assets/javascripts/thesis/hallo.js +2949 -0
- data/lib/assets/javascripts/thesis/thesis.js.coffee +27 -0
- data/lib/assets/javascripts/thesis.js +2 -0
- data/lib/assets/stylesheets/thesis/thesis.css.scss +16 -0
- data/lib/assets/stylesheets/thesis.css +4 -0
- data/lib/generators/thesis/install/install_generator.rb +108 -0
- data/lib/generators/thesis/install/templates/migrations/create_page.rb +18 -0
- data/lib/generators/thesis/install/templates/migrations/create_page_content.rb +15 -0
- data/lib/generators/thesis/install/templates/page_templates/default.html.erb +38 -0
- data/lib/generators/thesis/install/templates/page_templates/default.html.haml +29 -0
- data/lib/generators/thesis/install/templates/page_templates/default.html.slim +29 -0
- data/lib/tasks/thesis_tasks.rake +4 -0
- data/lib/thesis/colorizer.rb +51 -0
- data/lib/thesis/controllers/controller_helpers.rb +39 -0
- data/lib/thesis/controllers/thesis_controller.rb +53 -0
- data/lib/thesis/engine.rb +5 -0
- data/lib/thesis/exceptions.rb +17 -0
- data/lib/thesis/models/page.rb +43 -0
- data/lib/thesis/models/page_content.rb +41 -0
- data/lib/thesis/railtie.rb +12 -0
- data/lib/thesis/routing/route_constraint.rb +7 -0
- data/lib/thesis/routing/routes.rb +10 -0
- data/lib/thesis/version.rb +1 -1
- data/lib/thesis.rb +10 -1
- data/spec/factories/page_contents.rb +7 -0
- data/spec/factories/pages.rb +9 -0
- data/spec/lib/thesis/controllers/thesis_controller_spec.rb +68 -0
- data/spec/lib/thesis/models/page_content_spec.rb +33 -0
- data/spec/lib/thesis/models/page_spec.rb +49 -0
- data/spec/spec_helper.rb +64 -0
- metadata +58 -14
- data/.gitignore +0 -17
- data/Gemfile +0 -4
- data/LICENSE.txt +0 -22
- data/Rakefile +0 -1
- data/lib/thesis/base.rb +0 -5
- data/thesis.gemspec +0 -19
@@ -0,0 +1,68 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Thesis::ThesisController do
|
4
|
+
let(:page) { create :page, template: "default" }
|
5
|
+
|
6
|
+
before do
|
7
|
+
described_class.any_instance.stub(:render).and_return(page.title)
|
8
|
+
described_class.any_instance.stub(:template_exists?).and_return(true)
|
9
|
+
described_class.any_instance.stub(:page_is_editable?).and_return(true)
|
10
|
+
end
|
11
|
+
|
12
|
+
describe "#show" do
|
13
|
+
it "displays a page when it can be found" do
|
14
|
+
make_request :show, path: page.slug
|
15
|
+
@response.should_not be_nil
|
16
|
+
end
|
17
|
+
|
18
|
+
it "raises RoutingError when the page slug can't be found" do
|
19
|
+
expect { make_request :show, path: "/nonexistent" }.to raise_error ActionController::RoutingError
|
20
|
+
end
|
21
|
+
|
22
|
+
it "raises PageRequiresTemplate when template can't be found" do
|
23
|
+
described_class.any_instance.stub(:template_exists?).and_return(false)
|
24
|
+
expect { make_request :show, path: page.slug }.to raise_error Thesis::PageRequiresTemplate
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
describe "#new_page" do
|
29
|
+
context "when the page can be edited" do
|
30
|
+
it "creates a page" do
|
31
|
+
make_request :new_page, name: "New Page"
|
32
|
+
page = Thesis::Page.last
|
33
|
+
expect(page.name).to eq "New Page"
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
context "when the page can't be edited" do
|
38
|
+
before { described_class.any_instance.stub(:page_is_editable?).and_return(false) }
|
39
|
+
|
40
|
+
it "returns a status of 403 'Forbidden'" do
|
41
|
+
make_request :new_page, name: "New Page"
|
42
|
+
expect(@response.status).to eq 403
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
describe "#update_page" do
|
48
|
+
context "when the page can be edited" do
|
49
|
+
it "updates the attributes of the page" do
|
50
|
+
make_request :update_page, path: page.slug, name: "New Name"
|
51
|
+
page.reload
|
52
|
+
expect(page.name).to eq "New Name"
|
53
|
+
expect(page.slug).to eq "/new-name"
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
# Mock a request to the controller without
|
60
|
+
# Using Rails routing. Makes the response available
|
61
|
+
# in the @response instance variable.
|
62
|
+
def make_request(action, params = {})
|
63
|
+
path = params[:path] || "/"
|
64
|
+
env = Rack::MockRequest.env_for(path, :params => params.except(:path), method: :post)
|
65
|
+
status, headers, body = described_class.action(action).call(env)
|
66
|
+
@response = ActionDispatch::TestResponse.new(status, headers, body)
|
67
|
+
@controller = body.request.env['action_controller.instance']
|
68
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Thesis::PageContent do
|
4
|
+
let(:page) { create(:page) }
|
5
|
+
let(:page_content) { create(:page_content, attributes.merge(page_id: page.id)) }
|
6
|
+
|
7
|
+
describe "#render" do
|
8
|
+
subject { page_content.render }
|
9
|
+
|
10
|
+
context "when the content type is 'html'" do
|
11
|
+
let(:attributes) {{ content_type: 'html' }}
|
12
|
+
|
13
|
+
it { should match /thesis-content-html/ }
|
14
|
+
it { should match page_content.content }
|
15
|
+
end
|
16
|
+
|
17
|
+
context "when the content type is 'text'" do
|
18
|
+
let(:attributes) {{ content_type: "text" }}
|
19
|
+
|
20
|
+
it { should match /thesis-content-text/ }
|
21
|
+
it { should match page_content.content }
|
22
|
+
end
|
23
|
+
|
24
|
+
context "when the content type is 'image'" do
|
25
|
+
let(:attributes) {{ content_type: "image" }}
|
26
|
+
|
27
|
+
pending "currently renders as 'html'. Consider using #render_image in #render."
|
28
|
+
# it { should match /thesis-content-image/ }
|
29
|
+
# it { should match /img/ }
|
30
|
+
# it { should match page_content.content }
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Thesis::Page do
|
4
|
+
subject(:page) { create(:page) }
|
5
|
+
|
6
|
+
describe "#update_slug" do
|
7
|
+
let(:page) { build(:page, slug: "/original-slug") }
|
8
|
+
|
9
|
+
it "updates the page's slug attribute, based on the page name" do
|
10
|
+
page.name = "New Name"
|
11
|
+
page.update_slug
|
12
|
+
expect(page.slug).to eq "/new-name"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
describe "#update_subpage_slugs" do
|
17
|
+
let!(:parent) { create(:page, name: "Parent") }
|
18
|
+
let!(:subpage) { create(:page, name: "Subpage", parent_id: parent.id) }
|
19
|
+
|
20
|
+
before { parent.reload }
|
21
|
+
|
22
|
+
it "fixes the subpage's slug attributes when the parent's name is updated" do
|
23
|
+
parent.name = "New Parent Name"
|
24
|
+
parent.save
|
25
|
+
|
26
|
+
expect(subpage.reload.slug).to eq "/new-parent-name/subpage"
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe "#content" do
|
31
|
+
it "creates a Thesis::PageContent record if one does not exist" do
|
32
|
+
page.content("nonexistent-content-block")
|
33
|
+
content = Thesis::PageContent.first
|
34
|
+
expect(content.name).to eq "nonexistent-content-block"
|
35
|
+
expect(content.content_type).to eq "html"
|
36
|
+
end
|
37
|
+
|
38
|
+
it "returns a string of content" do
|
39
|
+
result = page.content("nonexistent-content-block")
|
40
|
+
expect(result).to be_a String
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
describe "#path" do
|
45
|
+
it "is an alias for #slug" do
|
46
|
+
expect(page.path).to eq page.slug
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler/setup'
|
3
|
+
require 'rails/all'
|
4
|
+
require 'factory_girl'
|
5
|
+
require 'rspec/autorun'
|
6
|
+
require 'database_cleaner'
|
7
|
+
|
8
|
+
# Require all the Thesis files
|
9
|
+
Dir[File.join('.', '/lib/thesis/**/*.rb')].each {|file| require file }
|
10
|
+
|
11
|
+
# Load Factories
|
12
|
+
FactoryGirl.find_definitions
|
13
|
+
|
14
|
+
# Configure ActiveRecord Connection
|
15
|
+
# Use memory store since we don't care about persistent data here.
|
16
|
+
ActiveRecord::Base.establish_connection(
|
17
|
+
:adapter => "sqlite3",
|
18
|
+
:database => ":memory:"
|
19
|
+
)
|
20
|
+
|
21
|
+
# Configure ActiveRecord Testing Schema
|
22
|
+
ActiveRecord::Schema.define do
|
23
|
+
self.verbose = false
|
24
|
+
|
25
|
+
create_table :pages do |t|
|
26
|
+
t.integer :parent_id
|
27
|
+
t.string :name
|
28
|
+
t.string :slug
|
29
|
+
t.string :title
|
30
|
+
t.string :description
|
31
|
+
t.integer :sort_order, default: 0, null: false
|
32
|
+
t.string :template, default: "default", null: false
|
33
|
+
t.timestamps
|
34
|
+
end
|
35
|
+
|
36
|
+
create_table :page_contents do |t|
|
37
|
+
t.integer :page_id, null: false
|
38
|
+
t.string :name, null: false
|
39
|
+
t.text :content, default: "Edit This Content Area"
|
40
|
+
t.string :content_type, default: :html
|
41
|
+
t.timestamps
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
RSpec.configure do |config|
|
46
|
+
# Pretty FactoryGirl syntax. For more details, visit
|
47
|
+
# https://github.com/thoughtbot/factory_girl/blob/master/GETTING_STARTED.md#using-factories
|
48
|
+
config.include FactoryGirl::Syntax::Methods
|
49
|
+
|
50
|
+
DatabaseCleaner.strategy = :transaction
|
51
|
+
|
52
|
+
# Configure DatabaseCleaner to set up a new
|
53
|
+
# transaction at the beginning of each test.
|
54
|
+
config.before do
|
55
|
+
DatabaseCleaner.start
|
56
|
+
end
|
57
|
+
|
58
|
+
# Reload FactoryGirl definitions and clean
|
59
|
+
# the database after every test.
|
60
|
+
config.after do
|
61
|
+
FactoryGirl.reload
|
62
|
+
DatabaseCleaner.clean
|
63
|
+
end
|
64
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: thesis
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,8 +9,24 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-03-
|
13
|
-
dependencies:
|
12
|
+
date: 2013-03-23 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rails
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 3.2.13
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 3.2.13
|
14
30
|
description: ! 'Thesis: A Rails CMS that doesn''t hijack your development workflow.'
|
15
31
|
email:
|
16
32
|
- contact@clearsightstudio.com
|
@@ -18,15 +34,37 @@ executables: []
|
|
18
34
|
extensions: []
|
19
35
|
extra_rdoc_files: []
|
20
36
|
files:
|
21
|
-
- .
|
22
|
-
-
|
23
|
-
-
|
24
|
-
-
|
25
|
-
-
|
26
|
-
- lib/thesis.rb
|
27
|
-
- lib/thesis/
|
37
|
+
- lib/assets/javascripts/thesis/hallo.js
|
38
|
+
- lib/assets/javascripts/thesis/thesis.js.coffee
|
39
|
+
- lib/assets/javascripts/thesis.js
|
40
|
+
- lib/assets/stylesheets/thesis/thesis.css.scss
|
41
|
+
- lib/assets/stylesheets/thesis.css
|
42
|
+
- lib/generators/thesis/install/install_generator.rb
|
43
|
+
- lib/generators/thesis/install/templates/migrations/create_page.rb
|
44
|
+
- lib/generators/thesis/install/templates/migrations/create_page_content.rb
|
45
|
+
- lib/generators/thesis/install/templates/page_templates/default.html.erb
|
46
|
+
- lib/generators/thesis/install/templates/page_templates/default.html.haml
|
47
|
+
- lib/generators/thesis/install/templates/page_templates/default.html.slim
|
48
|
+
- lib/tasks/thesis_tasks.rake
|
49
|
+
- lib/thesis/colorizer.rb
|
50
|
+
- lib/thesis/controllers/controller_helpers.rb
|
51
|
+
- lib/thesis/controllers/thesis_controller.rb
|
52
|
+
- lib/thesis/engine.rb
|
53
|
+
- lib/thesis/exceptions.rb
|
54
|
+
- lib/thesis/models/page.rb
|
55
|
+
- lib/thesis/models/page_content.rb
|
56
|
+
- lib/thesis/railtie.rb
|
57
|
+
- lib/thesis/routing/route_constraint.rb
|
58
|
+
- lib/thesis/routing/routes.rb
|
28
59
|
- lib/thesis/version.rb
|
29
|
-
- thesis.
|
60
|
+
- lib/thesis.rb
|
61
|
+
- README.md
|
62
|
+
- spec/factories/page_contents.rb
|
63
|
+
- spec/factories/pages.rb
|
64
|
+
- spec/lib/thesis/controllers/thesis_controller_spec.rb
|
65
|
+
- spec/lib/thesis/models/page_content_spec.rb
|
66
|
+
- spec/lib/thesis/models/page_spec.rb
|
67
|
+
- spec/spec_helper.rb
|
30
68
|
homepage: https://github.com/clearsightstudio/thesis
|
31
69
|
licenses: []
|
32
70
|
post_install_message:
|
@@ -38,7 +76,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
38
76
|
requirements:
|
39
77
|
- - ! '>='
|
40
78
|
- !ruby/object:Gem::Version
|
41
|
-
version:
|
79
|
+
version: 1.9.3
|
42
80
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
43
81
|
none: false
|
44
82
|
requirements:
|
@@ -47,8 +85,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
47
85
|
version: '0'
|
48
86
|
requirements: []
|
49
87
|
rubyforge_project:
|
50
|
-
rubygems_version: 1.8.
|
88
|
+
rubygems_version: 1.8.25
|
51
89
|
signing_key:
|
52
90
|
specification_version: 3
|
53
91
|
summary: ! 'Thesis: A Rails CMS that doesn''t hijack your development workflow.'
|
54
|
-
test_files:
|
92
|
+
test_files:
|
93
|
+
- spec/factories/page_contents.rb
|
94
|
+
- spec/factories/pages.rb
|
95
|
+
- spec/lib/thesis/controllers/thesis_controller_spec.rb
|
96
|
+
- spec/lib/thesis/models/page_content_spec.rb
|
97
|
+
- spec/lib/thesis/models/page_spec.rb
|
98
|
+
- spec/spec_helper.rb
|
data/.gitignore
DELETED
data/Gemfile
DELETED
data/LICENSE.txt
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
Copyright (c) 2013 ClearSight Studio
|
2
|
-
|
3
|
-
MIT License
|
4
|
-
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
-
a copy of this software and associated documentation files (the
|
7
|
-
"Software"), to deal in the Software without restriction, including
|
8
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
-
permit persons to whom the Software is furnished to do so, subject to
|
11
|
-
the following conditions:
|
12
|
-
|
13
|
-
The above copyright notice and this permission notice shall be
|
14
|
-
included in all copies or substantial portions of the Software.
|
15
|
-
|
16
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
require "bundler/gem_tasks"
|
data/lib/thesis/base.rb
DELETED
data/thesis.gemspec
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
2
|
-
lib = File.expand_path('../lib', __FILE__)
|
3
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require 'thesis/version'
|
5
|
-
|
6
|
-
Gem::Specification.new do |gem|
|
7
|
-
gem.name = "thesis"
|
8
|
-
gem.version = Thesis::VERSION
|
9
|
-
gem.authors = ["ClearSight Studio"]
|
10
|
-
gem.email = ["contact@clearsightstudio.com"]
|
11
|
-
gem.description = %q{Thesis: A Rails CMS that doesn't hijack your development workflow.}
|
12
|
-
gem.summary = %q{Thesis: A Rails CMS that doesn't hijack your development workflow.}
|
13
|
-
gem.homepage = "https://github.com/clearsightstudio/thesis"
|
14
|
-
|
15
|
-
gem.files = `git ls-files`.split($/)
|
16
|
-
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
17
|
-
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
18
|
-
gem.require_paths = ["lib"]
|
19
|
-
end
|