classiccms 0.5.6 → 0.5.7
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/Guardfile +3 -2
- data/classiccms.gemspec +1 -1
- data/lib/classiccms/application.rb +1 -1
- data/lib/classiccms/controllers/website.rb +1 -1
- data/lib/classiccms/custom.rb +18 -9
- data/lib/classiccms/helpers.rb +1 -1
- data/lib/classiccms/lib/routing.rb +1 -1
- data/lib/classiccms/models/base.rb +4 -2
- data/lib/classiccms/models/connection.rb +2 -2
- data/lib/classiccms/models/slug.rb +6 -6
- data/lib/classiccms/scaffold/config/mongoid.yml +17 -8
- data/lib/classiccms/version.rb +1 -1
- data/lib/classiccms/views/cms/add_window.haml +1 -1
- data/lib/classiccms/views/cms/form.haml +3 -3
- data/spec/config/mongoid.yml +9 -20
- data/spec/controllers/appliction_spec.rb +1 -0
- data/spec/helpers_spec.rb +2 -3
- data/spec/models/base_spec.rb +1 -1
- data/spec/models/connection_spec.rb +1 -1
- data/spec/models/slug_spec.rb +3 -4
- data/spec/spec_helper.rb +2 -2
- metadata +4 -4
data/Guardfile
CHANGED
data/classiccms.gemspec
CHANGED
@@ -25,7 +25,7 @@ Gem::Specification.new do |s|
|
|
25
25
|
s.add_development_dependency "rack-test"
|
26
26
|
|
27
27
|
#database
|
28
|
-
s.add_runtime_dependency "mongoid", '
|
28
|
+
s.add_runtime_dependency "mongoid", '3.0.3'
|
29
29
|
s.add_runtime_dependency "mongo", '1.6.2'
|
30
30
|
s.add_runtime_dependency "bson_ext", '1.5'
|
31
31
|
|
@@ -26,7 +26,7 @@ module Classiccms
|
|
26
26
|
end
|
27
27
|
get '/:id/?*' do
|
28
28
|
response.headers['Cache-Control'] = 'no-cache'
|
29
|
-
pass unless Slug.
|
29
|
+
pass unless Slug.where(_id: params[:id]).exists?
|
30
30
|
index = CONFIG[:home].kind_of?(String) ? CONFIG[:home] : 'application/index'
|
31
31
|
|
32
32
|
|
data/lib/classiccms/custom.rb
CHANGED
@@ -1,16 +1,25 @@
|
|
1
1
|
class ImageField
|
2
|
-
include Mongoid::Fields::Serializable
|
2
|
+
#include Mongoid::Fields::Serializable
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
|
4
|
+
class << self
|
5
|
+
|
6
|
+
# Get the object as it was stored in the database, and instantiate
|
7
|
+
# this custom class from it.
|
8
|
+
def demongoize(object)
|
9
|
+
Image.find(object).file
|
10
|
+
end
|
7
11
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
12
|
+
# Takes any possible object and converts it to how it would be
|
13
|
+
# stored in the database.
|
14
|
+
def mongoize(object)
|
15
|
+
case object
|
16
|
+
when BSON::ObjectId then object
|
17
|
+
else BSON::ObjectId(object)
|
18
|
+
end
|
13
19
|
end
|
20
|
+
|
21
|
+
# Converts the object that was supplied to a criteria and converts it
|
22
|
+
# into a database friendly form.
|
14
23
|
end
|
15
24
|
end
|
16
25
|
|
data/lib/classiccms/helpers.rb
CHANGED
@@ -108,7 +108,7 @@ module Classiccms
|
|
108
108
|
|
109
109
|
#simple function that return id if user is allowed to sort the item
|
110
110
|
def sort(object)
|
111
|
-
if object.kind_of? BSON::ObjectId or object.kind_of? String
|
111
|
+
if object.kind_of? Moped::BSON::ObjectId or object.kind_of? String
|
112
112
|
object = Base.where(:_id => object).first
|
113
113
|
end
|
114
114
|
if @user != nil
|
@@ -3,7 +3,7 @@ module Classiccms
|
|
3
3
|
|
4
4
|
#in charge of get the first item of a given model (for menu items etc.)
|
5
5
|
def get_first_item
|
6
|
-
Base.where(:_type => CONFIG[:model], :connections.
|
6
|
+
Base.where(:_type => CONFIG[:model], :'connections.parrent' => nil, :'connections.section' => CONFIG[:section], :'connections.order_id'.lte => 1).first
|
7
7
|
end
|
8
8
|
|
9
9
|
#This method will get you the most awesome route through a tree! (OMG!)
|
@@ -1,5 +1,7 @@
|
|
1
1
|
require 'mongoid'
|
2
|
-
|
2
|
+
Mongoid::Fields.option :input do |model, field, value|
|
3
|
+
#model.validates_presence_of field if value
|
4
|
+
end
|
3
5
|
class Base
|
4
6
|
include Mongoid::Document
|
5
7
|
include Mongoid::Timestamps
|
@@ -15,7 +17,7 @@ class Base
|
|
15
17
|
|
16
18
|
|
17
19
|
def remove_slugs
|
18
|
-
Slug.
|
20
|
+
Slug.delete_all(:document_id => id)
|
19
21
|
end
|
20
22
|
def remove_connections
|
21
23
|
records = Base.where(:'connections.parent_id' => id)
|
@@ -3,7 +3,7 @@ class Connection
|
|
3
3
|
embedded_in :base
|
4
4
|
|
5
5
|
field :order_id, type: Integer, default: 0
|
6
|
-
field :parent_id, type: BSON::ObjectId
|
6
|
+
field :parent_id, type: Moped::BSON::ObjectId
|
7
7
|
field :file, type: String
|
8
8
|
field :section, type: String
|
9
9
|
|
@@ -12,7 +12,7 @@ class Connection
|
|
12
12
|
validate :parent_id_should_exist
|
13
13
|
|
14
14
|
def parent_id_should_exist
|
15
|
-
if parent_id != nil and !Base.
|
15
|
+
if parent_id != nil and !Base.where(_id: parent_id).exists?
|
16
16
|
errors.add :parent_id, "id doesn't exist"
|
17
17
|
end
|
18
18
|
end
|
@@ -2,25 +2,25 @@ require 'cgi'
|
|
2
2
|
|
3
3
|
class Slug
|
4
4
|
include Mongoid::Document
|
5
|
-
|
6
|
-
field :document_id, type: BSON::ObjectId
|
5
|
+
field :_id, :type => String
|
6
|
+
field :document_id, type: Moped::BSON::ObjectId
|
7
7
|
|
8
8
|
#validations
|
9
9
|
validate :document_id_should_exist
|
10
10
|
|
11
11
|
def document_id_should_exist
|
12
|
-
if !Base.
|
12
|
+
if !Base.where(_id: document_id).exists?
|
13
13
|
errors.add :document_id, "id doesn't exist"
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
17
17
|
def generate_id
|
18
18
|
i = 0
|
19
|
-
i+=1 while Slug.
|
19
|
+
i+=1 while Slug.where(_id: i.to_s).exists?
|
20
20
|
self.id = i.to_s
|
21
21
|
end
|
22
22
|
def set_id(url)
|
23
|
-
Slug.
|
24
|
-
self.
|
23
|
+
Slug.delete_all(_id: url)
|
24
|
+
self._id = url.gsub(/[^a-zA-Z0-9\-\/]+/, '-').downcase
|
25
25
|
end
|
26
26
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
defaults: &defaults
|
2
|
-
host: 127.0.0.1
|
3
|
-
port: 27017
|
4
2
|
logger: false
|
3
|
+
hosts:
|
4
|
+
- localhost:27017
|
5
5
|
# slaves:
|
6
6
|
# - host: slave1.local
|
7
7
|
# port: 27018
|
@@ -9,14 +9,23 @@ defaults: &defaults
|
|
9
9
|
# port: 27019
|
10
10
|
|
11
11
|
development:
|
12
|
-
|
13
|
-
|
12
|
+
sessions:
|
13
|
+
default:
|
14
|
+
hosts:
|
15
|
+
- localhost:27017
|
16
|
+
database: $_development
|
14
17
|
|
15
18
|
test:
|
16
|
-
|
17
|
-
|
19
|
+
sessions:
|
20
|
+
default:
|
21
|
+
hosts:
|
22
|
+
- localhost:27017
|
23
|
+
database: $_test
|
18
24
|
|
19
25
|
# set these environment variables on your prod server
|
20
26
|
production:
|
21
|
-
|
22
|
-
|
27
|
+
sessions:
|
28
|
+
default:
|
29
|
+
hosts:
|
30
|
+
- localhost:27017
|
31
|
+
database: $
|
data/lib/classiccms/version.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
%form{:action=>"/cms/#{record.
|
1
|
+
%form{:action=>"/cms/#{record.new_record? ? 'create' : 'update' }", :method=>'post', :enctype=>'multypart/form-date'}
|
2
2
|
#edit_bg
|
3
3
|
- model = record.class
|
4
|
-
- if !record.
|
4
|
+
- if !record.new_record?
|
5
5
|
%input{:type=>'hidden', :name=> "[#{model}][id]", :value=> record.id}
|
6
6
|
- model.fields.each do |key, info|
|
7
7
|
.item
|
@@ -23,7 +23,7 @@
|
|
23
23
|
- when 'images'
|
24
24
|
- else
|
25
25
|
%label Comming soon
|
26
|
-
- if record.
|
26
|
+
- if record.new_record?
|
27
27
|
- record.connections.each do |connection|
|
28
28
|
%input{:type=> 'hidden', :name=> "[#{record.class}][connections][][id]", :value => connection.id}
|
29
29
|
%input{:type=> 'hidden', :name=> "[#{record.class}][connections][][parent_id]", :value => connection.parent_id}
|
data/spec/config/mongoid.yml
CHANGED
@@ -1,22 +1,11 @@
|
|
1
|
-
defaults: &defaults
|
2
|
-
host: 127.0.0.1
|
3
|
-
port: 27017
|
4
|
-
logger: false
|
5
|
-
# slaves:
|
6
|
-
# - host: slave1.local
|
7
|
-
# port: 27018
|
8
|
-
# - host: slave2.local
|
9
|
-
# port: 27019
|
10
|
-
|
11
1
|
development:
|
12
|
-
|
13
|
-
|
14
|
-
|
2
|
+
sessions:
|
3
|
+
default:
|
4
|
+
database: mongoid
|
5
|
+
- localhost:27017
|
15
6
|
test:
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
<<: *defaults
|
22
|
-
database: ClassicCMS
|
7
|
+
sessions:
|
8
|
+
default:
|
9
|
+
database: mongoid
|
10
|
+
hosts:
|
11
|
+
- localhost:27017
|
data/spec/helpers_spec.rb
CHANGED
@@ -99,11 +99,10 @@ describe Classiccms do
|
|
99
99
|
it 'should return the rendered file' do
|
100
100
|
with_constants :CONFIG => {home: 'application/index4', model: 'Menu', section: 'menu'} do
|
101
101
|
set_file "views/application/index4.haml", "= layout 'menu', 1"
|
102
|
-
create_dir 'views/
|
103
|
-
set_file "views/
|
102
|
+
create_dir 'views/menu'
|
103
|
+
set_file "views/menu/index.haml", "%h1 menu"
|
104
104
|
|
105
105
|
m = Menu.create connections: [Connection.new(section: 'menu', file: 'index')]
|
106
|
-
m.connections
|
107
106
|
|
108
107
|
get '/'
|
109
108
|
last_response.body.should == "<h1>menu</h1>\n"
|
data/spec/models/base_spec.rb
CHANGED
data/spec/models/slug_spec.rb
CHANGED
@@ -69,14 +69,13 @@ describe :Slug do
|
|
69
69
|
@slug.id.should == 'string'
|
70
70
|
end
|
71
71
|
it 'should remove exissting slugs with the same id' do
|
72
|
-
slug = Slug.
|
73
|
-
|
74
|
-
slug.save
|
72
|
+
slug = Slug.create _id: 'string', document_id: Base.create.id
|
73
|
+
|
75
74
|
|
76
75
|
@slug.set_id 'string'
|
77
76
|
@slug.save
|
78
77
|
|
79
|
-
Slug.count.should == 1
|
78
|
+
Slug.all.count.should == 1
|
80
79
|
end
|
81
80
|
it 'should sanetize the slug' do
|
82
81
|
@slug.set_id 'test test'
|
data/spec/spec_helper.rb
CHANGED
@@ -18,10 +18,10 @@ require 'sinatra'
|
|
18
18
|
set :environment, :test
|
19
19
|
|
20
20
|
RSpec.configure do |config|
|
21
|
-
Mongoid.load!("spec/config/mongoid.yml")
|
21
|
+
Mongoid.load!("spec/config/mongoid.yml", :test)
|
22
22
|
|
23
23
|
config.before(:each) do
|
24
|
-
Mongoid.
|
24
|
+
Mongoid.default_session.collections.select {|c| c.name !~ /system/ }.each(&:drop)
|
25
25
|
end
|
26
26
|
config.include Rack::Test::Methods
|
27
27
|
config.include FactoryGirl::Syntax::Methods
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: classiccms
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.7
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-08-
|
12
|
+
date: 2012-08-09 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
@@ -98,7 +98,7 @@ dependencies:
|
|
98
98
|
requirements:
|
99
99
|
- - '='
|
100
100
|
- !ruby/object:Gem::Version
|
101
|
-
version:
|
101
|
+
version: 3.0.3
|
102
102
|
type: :runtime
|
103
103
|
prerelease: false
|
104
104
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -106,7 +106,7 @@ dependencies:
|
|
106
106
|
requirements:
|
107
107
|
- - '='
|
108
108
|
- !ruby/object:Gem::Version
|
109
|
-
version:
|
109
|
+
version: 3.0.3
|
110
110
|
- !ruby/object:Gem::Dependency
|
111
111
|
name: mongo
|
112
112
|
requirement: !ruby/object:Gem::Requirement
|