constructor-cms 0.5.8 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +3 -3
- data/README.md +1 -1
- data/{script → bin}/rails +1 -1
- data/constructor-cms.gemspec +1 -3
- data/core/app/controllers/constructor_core/application_controller.rb +1 -1
- data/core/app/controllers/constructor_core/users_controller.rb +2 -2
- data/core/app/models/constructor_core/user.rb +0 -1
- data/core/config/initializers/devise.rb +8 -8
- data/core/constructor-core.gemspec +2 -2
- data/core/lib/constructor_core/version.rb +1 -1
- data/pages/app/controllers/constructor_pages/fields_controller.rb +11 -2
- data/pages/app/controllers/constructor_pages/pages_controller.rb +20 -12
- data/pages/app/controllers/constructor_pages/templates_controller.rb +13 -7
- data/pages/app/models/constructor_pages/field.rb +1 -3
- data/pages/app/models/constructor_pages/page.rb +15 -21
- data/pages/app/models/constructor_pages/template.rb +0 -3
- data/pages/app/models/constructor_pages/types/boolean_type.rb +1 -2
- data/pages/app/models/constructor_pages/types/date_type.rb +1 -6
- data/pages/app/models/constructor_pages/types/float_type.rb +1 -2
- data/pages/app/models/constructor_pages/types/html_type.rb +1 -2
- data/pages/app/models/constructor_pages/types/image_type.rb +3 -2
- data/pages/app/models/constructor_pages/types/integer_type.rb +1 -2
- data/pages/app/models/constructor_pages/types/string_type.rb +1 -2
- data/pages/app/models/constructor_pages/types/text_type.rb +1 -2
- data/pages/app/views/constructor_pages/fields/types/_date.haml +1 -1
- data/pages/app/views/constructor_pages/pages/_form.haml +2 -2
- data/pages/app/views/constructor_pages/pages/index.haml +4 -4
- data/pages/app/views/constructor_pages/templates/_form.haml +2 -2
- data/pages/config/locales/ru.yml +0 -1
- data/pages/constructor-pages.gemspec +2 -1
- data/spec/dummy/README.rdoc +15 -248
- data/spec/dummy/Rakefile +0 -1
- data/spec/dummy/app/controllers/application_controller.rb +1 -1
- 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 +1 -1
- data/spec/dummy/config/application.rb +4 -43
- data/spec/dummy/config/boot.rb +2 -3
- data/spec/dummy/config/environment.rb +2 -2
- data/spec/dummy/config/environments/development.rb +11 -19
- data/spec/dummy/config/environments/production.rb +40 -27
- data/spec/dummy/config/environments/test.rb +13 -14
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/spec/dummy/config/initializers/inflections.rb +6 -5
- data/spec/dummy/config/initializers/secret_token.rb +7 -2
- data/spec/dummy/config/initializers/session_store.rb +0 -5
- data/spec/dummy/config/initializers/wrap_parameters.rb +6 -6
- data/spec/dummy/config/routes.rb +2 -57
- data/spec/dummy/public/404.html +48 -16
- data/spec/dummy/public/422.html +48 -16
- data/spec/dummy/public/500.html +48 -16
- data/spec/dummy/public/robots.txt +1 -1
- metadata +19 -27
- data/spec/dummy/script/rails +0 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1f20c51a1d988a4130e232048b3bd6cbd386834f
|
4
|
+
data.tar.gz: ac6c3b2c45985db4bf5604028ee94a5076251571
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 88d01166d105e8ad84a1032f150228d3c287e5a9b366c7e30b95dbcb5dc3676a373e4de286f2f1e458207b5a3ae320f0ecd1cd51f84bc3ce374580c1e1bd258e
|
7
|
+
data.tar.gz: d529723a118b866cb573506af6dd3fbdffada473ded047cf2982c8a48022bd8a989c5e697819c53c31a391cbb09e77f6159bfab9843c525bd1b09eb88d561327
|
data/Gemfile
CHANGED
@@ -9,12 +9,12 @@ group :test do
|
|
9
9
|
end
|
10
10
|
|
11
11
|
group :assets do
|
12
|
-
gem 'sass-rails', '~>
|
13
|
-
gem 'coffee-rails', '~>
|
12
|
+
gem 'sass-rails', '~> 4.0.0.rc2'
|
13
|
+
gem 'coffee-rails', '~> 4.0.0'
|
14
14
|
gem 'less-rails'
|
15
15
|
gem 'therubyracer', :platforms => :ruby
|
16
16
|
|
17
|
-
gem 'uglifier', '>= 1.0
|
17
|
+
gem 'uglifier', '>= 1.3.0'
|
18
18
|
end
|
19
19
|
|
20
20
|
gem 'jquery-rails'
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Constructor CMS
|
2
2
|
|
3
|
-
|
3
|
+
Constructor – Ruby on Rails 4 content management system (cms)
|
4
4
|
|
5
5
|
[![Gem Version](https://badge.fury.io/rb/constructor-cms.png)](https://rubygems.org/gems/constructor-cms)
|
6
6
|
[![Build Status](https://travis-ci.org/ivanzotov/constructor.png?branch=master)](https://travis-ci.org/ivanzotov/constructor)
|
data/{script → bin}/rails
RENAMED
@@ -1,5 +1,5 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
# This command will automatically be run when you run "rails" with Rails
|
2
|
+
# This command will automatically be run when you run "rails" with Rails 4 gems installed from the root of your application.
|
3
3
|
|
4
4
|
ENGINE_ROOT = File.expand_path('../..', __FILE__)
|
5
5
|
ENGINE_PATH = File.expand_path('../../lib/constructor-cms/engine', __FILE__)
|
data/constructor-cms.gemspec
CHANGED
@@ -15,14 +15,12 @@ Gem::Specification.new do |s|
|
|
15
15
|
|
16
16
|
s.files = `git ls-files`.split("\n")
|
17
17
|
s.test_files = `git ls-files -- spec/*`.split("\n")
|
18
|
-
s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
|
19
18
|
|
20
19
|
s.add_dependency 'constructor-core', ConstructorCore::VERSION
|
21
20
|
s.add_dependency 'constructor-pages', ConstructorCore::VERSION
|
22
|
-
s.add_dependency 'russian'
|
23
21
|
|
24
22
|
s.add_development_dependency 'sqlite3'
|
25
|
-
s.add_development_dependency 'rspec-rails'
|
23
|
+
s.add_development_dependency 'rspec-rails', '2.14.0.rc1'
|
26
24
|
s.add_development_dependency 'database_cleaner'
|
27
25
|
s.add_development_dependency 'capybara'
|
28
26
|
end
|
@@ -1,8 +1,8 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
3
|
module ConstructorCore
|
4
|
-
class UsersController < ApplicationController
|
5
|
-
layout 'constructor_core/
|
4
|
+
class UsersController < ConstructorCore::ApplicationController
|
5
|
+
layout 'constructor_core/application'
|
6
6
|
|
7
7
|
def profile
|
8
8
|
@user = current_user
|
@@ -3,6 +3,5 @@
|
|
3
3
|
module ConstructorCore
|
4
4
|
class User < ActiveRecord::Base
|
5
5
|
devise :database_authenticatable, :recoverable, :rememberable, :trackable, :validatable, :token_authenticatable, :timeoutable, :registerable #:confirmable, :omniauthable, :lockable, :encryptable
|
6
|
-
attr_accessible :email, :password, :password_confirmation, :remember_me
|
7
6
|
end
|
8
7
|
end
|
@@ -1,15 +1,15 @@
|
|
1
1
|
Devise.setup do |config|
|
2
2
|
config.mailer_sender = 'ivanzotov@gmail.com'
|
3
3
|
|
4
|
-
config.parent_controller = 'ActionController::Base'
|
4
|
+
#config.parent_controller = 'ActionController::Base'
|
5
5
|
|
6
6
|
require 'devise/orm/active_record'
|
7
7
|
|
8
|
-
config.case_insensitive_keys = [ :email ]
|
9
|
-
config.strip_whitespace_keys = [ :email ]
|
10
|
-
config.skip_session_storage = [:http_auth]
|
11
|
-
config.stretches = Rails.env.test? ? 1 : 10
|
12
|
-
config.reconfirmable = true
|
13
|
-
config.reset_password_within = 6.hours
|
14
|
-
config.sign_out_via = :delete
|
8
|
+
#config.case_insensitive_keys = [ :email ]
|
9
|
+
#config.strip_whitespace_keys = [ :email ]
|
10
|
+
#config.skip_session_storage = [:http_auth]
|
11
|
+
#config.stretches = Rails.env.test? ? 1 : 10
|
12
|
+
#config.reconfirmable = true
|
13
|
+
#config.reset_password_within = 6.hours
|
14
|
+
#config.sign_out_via = :delete
|
15
15
|
end
|
@@ -17,8 +17,8 @@ Gem::Specification.new do |s|
|
|
17
17
|
s.test_files = `git ls-files -- spec/*`.split("\n")
|
18
18
|
s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
|
19
19
|
|
20
|
-
s.add_dependency 'rails', '~>
|
21
|
-
s.add_dependency 'devise'
|
20
|
+
s.add_dependency 'rails', '~> 4.0.0.rc2'
|
21
|
+
s.add_dependency 'devise', '~> 3.0.0.rc'
|
22
22
|
s.add_dependency 'bootstrap-sass'
|
23
23
|
s.add_dependency 'font-awesome-sass-rails'
|
24
24
|
end
|
@@ -13,7 +13,7 @@ module ConstructorPages
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def create
|
16
|
-
@field = Field.new
|
16
|
+
@field = Field.new field_params
|
17
17
|
|
18
18
|
if @field.save
|
19
19
|
redirect_to edit_template_path(@field.template_id), notice: t(:field_success_added, name: @field.name)
|
@@ -42,7 +42,7 @@ module ConstructorPages
|
|
42
42
|
field.destroy
|
43
43
|
end
|
44
44
|
end
|
45
|
-
if @field.
|
45
|
+
if @field.update field_params
|
46
46
|
redirect_to edit_template_url(@field.template.id), notice: t(:field_success_updated, name: @field.name)
|
47
47
|
else
|
48
48
|
render :action => "edit"
|
@@ -61,6 +61,15 @@ module ConstructorPages
|
|
61
61
|
|
62
62
|
private
|
63
63
|
|
64
|
+
def field_params
|
65
|
+
params.require(:field).permit(
|
66
|
+
:name,
|
67
|
+
:code_name,
|
68
|
+
:template_id,
|
69
|
+
:type_value
|
70
|
+
)
|
71
|
+
end
|
72
|
+
|
64
73
|
def move_to(to)
|
65
74
|
@field = Field.find(params[:id])
|
66
75
|
to == :up ? @field.move_higher : @field.move_lower
|
@@ -3,10 +3,8 @@
|
|
3
3
|
module ConstructorPages
|
4
4
|
class PagesController < ConstructorCore::ApplicationController
|
5
5
|
include MoveHelper
|
6
|
-
caches_page :show
|
7
6
|
|
8
7
|
before_filter {@roots = Page.roots}
|
9
|
-
before_filter :cache, only: [:create, :update, :destroy, :move_up, :move_down]
|
10
8
|
|
11
9
|
def new
|
12
10
|
@page, @template_id, @multipart = Page.new, Template.first.id, false
|
@@ -92,7 +90,7 @@ module ConstructorPages
|
|
92
90
|
end
|
93
91
|
|
94
92
|
def create
|
95
|
-
@page = Page.new
|
93
|
+
@page = Page.new page_params
|
96
94
|
|
97
95
|
if @page.save
|
98
96
|
redirect_to pages.pages_url, notice: t(:page_success_added, name: @page.name)
|
@@ -108,7 +106,7 @@ module ConstructorPages
|
|
108
106
|
@page.remove_fields_values
|
109
107
|
end
|
110
108
|
|
111
|
-
if @page.
|
109
|
+
if @page.update page_params
|
112
110
|
@page.create_fields_values
|
113
111
|
@page.update_fields_values params[:fields]
|
114
112
|
|
@@ -129,16 +127,26 @@ module ConstructorPages
|
|
129
127
|
|
130
128
|
private
|
131
129
|
|
132
|
-
def
|
133
|
-
|
130
|
+
def page_params
|
131
|
+
params.require(:page).permit(
|
132
|
+
:active,
|
133
|
+
:name,
|
134
|
+
:url,
|
135
|
+
:title,
|
136
|
+
:keywords,
|
137
|
+
:description,
|
138
|
+
:auto_url,
|
139
|
+
:parent_id,
|
140
|
+
:template_id,
|
141
|
+
:in_nav,
|
142
|
+
:in_map,
|
143
|
+
:in_menu,
|
144
|
+
:link
|
145
|
+
)
|
134
146
|
end
|
135
147
|
|
136
|
-
def
|
137
|
-
|
138
|
-
cache_dir = ActionController::Base.page_cache_directory
|
139
|
-
unless cache_dir == Rails.root.to_s+"/public"
|
140
|
-
FileUtils.rm_r(Dir.glob(cache_dir+"/*")) rescue Errno::ENOENT
|
141
|
-
end
|
148
|
+
def error_404
|
149
|
+
render file: "#{Rails.root}/public/404", layout: false, status: 404
|
142
150
|
end
|
143
151
|
end
|
144
152
|
end
|
@@ -8,11 +8,6 @@ module ConstructorPages
|
|
8
8
|
|
9
9
|
def new
|
10
10
|
@template = Template.new
|
11
|
-
|
12
|
-
if params[:template]
|
13
|
-
@parent = Template.find(params[:template])
|
14
|
-
@template.parent_id = @parent.id
|
15
|
-
end
|
16
11
|
end
|
17
12
|
|
18
13
|
def edit
|
@@ -20,7 +15,7 @@ module ConstructorPages
|
|
20
15
|
end
|
21
16
|
|
22
17
|
def create
|
23
|
-
@template = Template.new
|
18
|
+
@template = Template.new template_params
|
24
19
|
|
25
20
|
if @template.save
|
26
21
|
redirect_to templates_url, notice: t(:template_success_added, name: @template.name)
|
@@ -32,7 +27,7 @@ module ConstructorPages
|
|
32
27
|
def update
|
33
28
|
@template = Template.find params[:id]
|
34
29
|
|
35
|
-
if @template.
|
30
|
+
if @template.update template_params
|
36
31
|
redirect_to templates_url, notice: t(:template_success_updated, name: @template.name)
|
37
32
|
else
|
38
33
|
render action: :edit
|
@@ -47,5 +42,16 @@ module ConstructorPages
|
|
47
42
|
end
|
48
43
|
|
49
44
|
%w{up down}.each {|m| define_method "move_#{m}" do move_to :template, m.to_sym end}
|
45
|
+
|
46
|
+
private
|
47
|
+
|
48
|
+
def template_params
|
49
|
+
params.require(:template).permit(
|
50
|
+
:name,
|
51
|
+
:code_name,
|
52
|
+
:parent_id,
|
53
|
+
:child_id
|
54
|
+
)
|
55
|
+
end
|
50
56
|
end
|
51
57
|
end
|
@@ -5,8 +5,6 @@ module ConstructorPages
|
|
5
5
|
#
|
6
6
|
# Each field has type of value such as float, integer, string...
|
7
7
|
class Field < ActiveRecord::Base
|
8
|
-
attr_accessible :name, :code_name, :type_value, :template_id, :template
|
9
|
-
|
10
8
|
# Adding code_name_uniqueness method
|
11
9
|
include CodeNameUniq
|
12
10
|
|
@@ -38,7 +36,7 @@ module ConstructorPages
|
|
38
36
|
def type_class; "constructor_pages/types/#{type_value}_type".classify.constantize end
|
39
37
|
|
40
38
|
# Return object of type_value by page
|
41
|
-
def find_type_object(page); type_class.
|
39
|
+
def find_type_object(page); type_class.where(field_id: id, page_id: page.id).first end
|
42
40
|
|
43
41
|
# Create object of type_value by page
|
44
42
|
def create_type_object(page); type_class.create(field_id: id, page_id: page.id) end
|
@@ -3,11 +3,6 @@
|
|
3
3
|
module ConstructorPages
|
4
4
|
# Page model. Pages are core for company websites, blogs etc.
|
5
5
|
class Page < ActiveRecord::Base
|
6
|
-
attr_accessible :name, :title, :keywords, :description,
|
7
|
-
:url, :full_url, :active, :auto_url,
|
8
|
-
:parent, :parent_id, :link, :in_menu, :in_map,
|
9
|
-
:in_nav, :template_id, :template
|
10
|
-
|
11
6
|
# Adding has_many for all field types
|
12
7
|
Field::TYPES.each do |t|
|
13
8
|
class_eval %{
|
@@ -19,7 +14,7 @@ module ConstructorPages
|
|
19
14
|
|
20
15
|
belongs_to :template
|
21
16
|
|
22
|
-
default_scope order
|
17
|
+
default_scope -> { order(:lft)}
|
23
18
|
|
24
19
|
validate :template_check
|
25
20
|
|
@@ -32,7 +27,7 @@ module ConstructorPages
|
|
32
27
|
# Used for find page by request. It return first page if no request given
|
33
28
|
# @param request for example <tt>'/conditioners/split-systems/zanussi'</tt>
|
34
29
|
def self.find_by_request_or_first(request = nil)
|
35
|
-
request.nil? ? Page.first : Page.
|
30
|
+
request.nil? ? Page.first : Page.where(full_url: request).first
|
36
31
|
end
|
37
32
|
|
38
33
|
# Generate full_url from parent id and url
|
@@ -47,6 +42,7 @@ module ConstructorPages
|
|
47
42
|
# field and template code_name should be uniqueness for page methods
|
48
43
|
def self.check_code_name(code_name)
|
49
44
|
[code_name, code_name.pluralize, code_name.singularize].each do |name|
|
45
|
+
# TODO: replace Page.first
|
50
46
|
if Page.first.respond_to?(name)
|
51
47
|
return false
|
52
48
|
end
|
@@ -57,7 +53,7 @@ module ConstructorPages
|
|
57
53
|
|
58
54
|
# Get field by code_name
|
59
55
|
def field(code_name)
|
60
|
-
Field.
|
56
|
+
Field.find_by code_name: code_name, template_id: template_id
|
61
57
|
end
|
62
58
|
|
63
59
|
# Get value of field by code_name
|
@@ -80,13 +76,16 @@ module ConstructorPages
|
|
80
76
|
value = params[field.code_name.to_sym]
|
81
77
|
|
82
78
|
_type_object = field.find_type_object(self)
|
83
|
-
_type_object.value = 0 if field.type_value == 'boolean' and reset_booleans
|
84
79
|
|
85
|
-
if
|
86
|
-
_type_object.value = field.type_value == '
|
87
|
-
|
80
|
+
if _type_object
|
81
|
+
_type_object.value = 0 if field.type_value == 'boolean' and reset_booleans
|
82
|
+
|
83
|
+
if value
|
84
|
+
_type_object.value = value
|
85
|
+
end
|
88
86
|
|
89
|
-
|
87
|
+
_type_object.save
|
88
|
+
end
|
90
89
|
end
|
91
90
|
end
|
92
91
|
|
@@ -107,12 +106,12 @@ module ConstructorPages
|
|
107
106
|
# It determines if code_name is singular or nor
|
108
107
|
# @param code_name template code name
|
109
108
|
def find_page_in_branch(code_name)
|
110
|
-
_template = Template.
|
109
|
+
_template = Template.where(code_name: code_name.singularize).first
|
111
110
|
|
112
111
|
if _template
|
113
112
|
result = []
|
114
113
|
result = descendants.where(template_id: _template.id) if code_name == code_name.pluralize
|
115
|
-
result = ancestors.
|
114
|
+
result = ancestors.where(template_id: _template.id).first if result.empty?
|
116
115
|
result
|
117
116
|
end
|
118
117
|
end
|
@@ -158,13 +157,8 @@ module ConstructorPages
|
|
158
157
|
self.url = ((auto_url || url.empty?) ? translit(name) : url).parameterize
|
159
158
|
end
|
160
159
|
|
161
|
-
# TODO: move out
|
162
|
-
def parse_date(value)
|
163
|
-
Date.new(value['date(1i)'].to_i, value['date(2i)'].to_i, value['date(3i)'].to_i)
|
164
|
-
end
|
165
|
-
|
166
160
|
# TODO: add more languages
|
167
|
-
#
|
161
|
+
# translit to english
|
168
162
|
def translit(str)
|
169
163
|
Russian.translit(str)
|
170
164
|
end
|
@@ -7,12 +7,9 @@ module ConstructorPages
|
|
7
7
|
# For example:
|
8
8
|
# template "Product" should has fields like "price", "description", "size" etc.
|
9
9
|
class Template < ActiveRecord::Base
|
10
|
-
|
11
10
|
# Adding code_name_uniqueness method
|
12
11
|
include CodeNameUniq
|
13
12
|
|
14
|
-
attr_accessible :name, :code_name, :child_id, :parent_id, :parent
|
15
|
-
|
16
13
|
validates_presence_of :name, :code_name
|
17
14
|
validates_uniqueness_of :code_name
|
18
15
|
validate :code_name_uniqueness
|
@@ -2,15 +2,10 @@
|
|
2
2
|
|
3
3
|
module ConstructorPages
|
4
4
|
module Types
|
5
|
+
# Date time. Render as three select lists (day, month, year).
|
5
6
|
class DateType < ActiveRecord::Base
|
6
|
-
attr_accessible :value, :field_id, :field, :page_id, :page
|
7
|
-
|
8
7
|
belongs_to :field
|
9
8
|
belongs_to :page
|
10
|
-
|
11
|
-
def russian
|
12
|
-
Russian::strftime(self.value, "%d %B %Y").gsub(/0(\d\D)/, '\1')
|
13
|
-
end
|
14
9
|
end
|
15
10
|
end
|
16
11
|
end
|