constructor-pages 0.5.0 → 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- data/app/controllers/constructor_pages/fields_controller.rb +5 -5
- data/app/controllers/constructor_pages/pages_controller.rb +3 -3
- data/app/models/constructor_pages/page.rb +7 -1
- data/app/views/constructor_pages/pages/index.haml +18 -16
- data/app/views/constructor_pages/templates/index.haml +9 -8
- data/config/locales/en.yml +17 -5
- data/config/locales/ru.yml +17 -4
- data/lib/constructor-pages.rb +2 -1
- data/spec/models/constructor_pages/page_model_spec.rb +10 -8
- data/spec/models/constructor_pages/template_model_spec.rb +4 -0
- metadata +4 -4
@@ -20,7 +20,7 @@ module ConstructorPages
|
|
20
20
|
@field = Field.new params[:field]
|
21
21
|
|
22
22
|
if @field.save
|
23
|
-
redirect_to edit_template_path(@field.template_id), :
|
23
|
+
redirect_to edit_template_path(@field.template_id), notice: t(:field_success_added, name: @field.name)
|
24
24
|
else
|
25
25
|
render :action => 'new', :template_id => @field.template_id
|
26
26
|
end
|
@@ -47,7 +47,7 @@ module ConstructorPages
|
|
47
47
|
end
|
48
48
|
end
|
49
49
|
if @field.update_attributes params[:field]
|
50
|
-
redirect_to edit_template_url(@field.template.id), :
|
50
|
+
redirect_to edit_template_url(@field.template.id), notice: t(:field_success_updated, name: @field.name)
|
51
51
|
else
|
52
52
|
render :action => "edit"
|
53
53
|
end
|
@@ -58,19 +58,19 @@ module ConstructorPages
|
|
58
58
|
name = @field.name
|
59
59
|
template = @field.template.id
|
60
60
|
@field.destroy
|
61
|
-
redirect_to edit_template_url(template), :
|
61
|
+
redirect_to edit_template_url(template), notice: t(:field_success_removed, name: name)
|
62
62
|
end
|
63
63
|
|
64
64
|
def move_up
|
65
65
|
@field = Field.find(params[:id])
|
66
66
|
@field.move_higher
|
67
|
-
redirect_to :back, :
|
67
|
+
redirect_to :back, notice: t(:field_success_moved, name: @field.name)
|
68
68
|
end
|
69
69
|
|
70
70
|
def move_down
|
71
71
|
@field = Field.find(params[:id])
|
72
72
|
@field.move_lower
|
73
|
-
redirect_to :back, :
|
73
|
+
redirect_to :back, notice: t(:field_success_moved, name: @field.name)
|
74
74
|
end
|
75
75
|
end
|
76
76
|
end
|
@@ -112,7 +112,7 @@ module ConstructorPages
|
|
112
112
|
@page = Page.new params[:page]
|
113
113
|
|
114
114
|
if @page.save
|
115
|
-
redirect_to pages_url, :
|
115
|
+
redirect_to pages_url, notice: t(:page_success_added, name: @page.name)
|
116
116
|
else
|
117
117
|
render :action => "new"
|
118
118
|
end
|
@@ -152,7 +152,7 @@ module ConstructorPages
|
|
152
152
|
end
|
153
153
|
end
|
154
154
|
|
155
|
-
redirect_to pages_url, :
|
155
|
+
redirect_to pages_url, notice: t(:page_success_updated, name: @page.name)
|
156
156
|
else
|
157
157
|
render :action => "edit"
|
158
158
|
end
|
@@ -162,7 +162,7 @@ module ConstructorPages
|
|
162
162
|
@page = Page.find(params[:id])
|
163
163
|
title = @page.name
|
164
164
|
@page.destroy
|
165
|
-
redirect_to pages_url, :
|
165
|
+
redirect_to pages_url, notice: t(:page_success_removed, name: @page.name)
|
166
166
|
end
|
167
167
|
|
168
168
|
def move_up
|
@@ -79,7 +79,13 @@ module ConstructorPages
|
|
79
79
|
|
80
80
|
# if url has been changed by manually or url is empty
|
81
81
|
def friendly_url
|
82
|
-
self.url = ((auto_url || url.empty?) ? name : url).parameterize
|
82
|
+
self.url = ((auto_url || url.empty?) ? translit(name) : url).parameterize
|
83
|
+
end
|
84
|
+
|
85
|
+
# TODO: add more languages
|
86
|
+
# translit to english
|
87
|
+
def translit(str)
|
88
|
+
Russian.translit(str)
|
83
89
|
end
|
84
90
|
|
85
91
|
# page is not valid if there is no template
|
@@ -5,7 +5,7 @@
|
|
5
5
|
.span4.clearfix.text-right
|
6
6
|
= link_to "<i class='icon-plus icon-white'></i> #{t :new_page}".html_safe, pages.new_page_path, :class => "btn btn-large btn-link"
|
7
7
|
|
8
|
-
%section.b-tree.
|
8
|
+
%section.b-tree.span12
|
9
9
|
%ul
|
10
10
|
- @roots.each do |root|
|
11
11
|
- level = root.level
|
@@ -22,25 +22,27 @@
|
|
22
22
|
|
23
23
|
<li>
|
24
24
|
- if page.active == true
|
25
|
-
= link_to page.name, page.full_url, :class => "btn"
|
25
|
+
= link_to page.name, page.full_url, :class => "btn btn-link"
|
26
26
|
- else
|
27
27
|
%button.btn.disabled= page.name
|
28
28
|
|
29
|
-
.
|
30
|
-
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
= link_to "<i class='icon-pencil icon-white'></i>".html_safe, edit_page_path(page), :class => "btn btn-primary btn-mini"
|
36
|
-
|
37
|
-
- unless page.template.nil?
|
38
|
-
- if page.template.child_id.nil?
|
39
|
-
- if !page.template.leaf?
|
40
|
-
= link_to "<i class='icon-plus icon-white'></i> #{page.template.descendants.first.name}".html_safe, new_child_page_path(page), :class => "btn btn-success btn-mini"
|
41
|
-
- else
|
42
|
-
= link_to "<i class='icon-plus icon-white'></i> #{ConstructorPages::Template.find(page.template.child_id).name}".html_safe, new_child_page_path(page), :class => "btn btn-success btn-mini"
|
29
|
+
.b-tree__buttons
|
30
|
+
.btn-group
|
31
|
+
- if not page.right_sibling.nil? and page.move_possible?(page.right_sibling)
|
32
|
+
= link_to "<i class='icon-arrow-down'></i>".html_safe, page_move_down_path(page), :method => :post, :class => "btn btn-mini"
|
33
|
+
- if not page.left_sibling.nil? and page.move_possible?(page.left_sibling)
|
34
|
+
= link_to "<i class='icon-arrow-up'></i>".html_safe, page_move_up_path(page), :method => :post, :class => "btn btn-mini"
|
43
35
|
|
36
|
+
= link_to "<i class='icon-pencil'></i> #{t :edit} #{page.template.name.downcase}".html_safe, edit_page_path(page), :class => "btn btn-primary btn-mini"
|
37
|
+
|
38
|
+
- unless page.template.nil?
|
39
|
+
- if page.template.child_id.nil?
|
40
|
+
- if !page.template.leaf?
|
41
|
+
= link_to "<i class='icon-chevron-down'></i> #{t :add} #{page.template.descendants.first.name.downcase}".html_safe, new_child_page_path(page), :class => "btn btn-success btn-mini"
|
42
|
+
- else
|
43
|
+
= link_to "<i class='icon-chevron-down'></i> #{t :add} #{ConstructorPages::Template.find(page.template.child_id).name.downcase}".html_safe, new_child_page_path(page), :class => "btn btn-success btn-mini"
|
44
|
+
|
45
|
+
= link_to "<i class='icon-remove'></i> #{t :delete}".html_safe, page_path(page), confirm: t(:are_you_sure?), method: :delete, class: 'btn btn-danger btn-mini pull-right'
|
44
46
|
|
45
47
|
|
46
48
|
|
@@ -5,7 +5,7 @@
|
|
5
5
|
.span4.clearfix.text-right
|
6
6
|
= link_to "<i class='icon-plus icon-white'></i> #{t :new_template}".html_safe, new_template_path, :class => "btn btn-link btn-large"
|
7
7
|
|
8
|
-
%section.b-tree.
|
8
|
+
%section.b-tree.span12
|
9
9
|
%ul
|
10
10
|
- @roots.each do |root|
|
11
11
|
- level = root.level
|
@@ -21,15 +21,16 @@
|
|
21
21
|
</li>
|
22
22
|
|
23
23
|
<li>
|
24
|
-
%button.btn.disabled= template.name
|
24
|
+
%button.btn.btn-link.disabled= template.name
|
25
25
|
|
26
|
-
.
|
27
|
-
-
|
28
|
-
|
29
|
-
|
30
|
-
|
26
|
+
.b-tree__buttons
|
27
|
+
.btn-group
|
28
|
+
- if not template.right_sibling.nil? and template.move_possible?(template.right_sibling)
|
29
|
+
= link_to "<i class='icon-arrow-down'></i>".html_safe, template_move_down_path(template), :method => :post, :class => "btn btn-mini"
|
30
|
+
- if not template.left_sibling.nil? and template.move_possible?(template.left_sibling)
|
31
|
+
= link_to "<i class='icon-arrow-up'></i>".html_safe, template_move_up_path(template), :method => :post, :class => "btn btn-mini"
|
31
32
|
|
32
|
-
|
33
|
+
= link_to "<i class='icon-pencil'></i> #{t :edit} #{ t(:template).downcase}".html_safe, edit_template_path(template), :class => "btn btn-primary btn-mini"
|
33
34
|
|
34
35
|
|
35
36
|
- level = template.level
|
data/config/locales/en.yml
CHANGED
@@ -6,6 +6,15 @@ en:
|
|
6
6
|
edit_field: 'Edit field'
|
7
7
|
seo: 'SEO'
|
8
8
|
display_in: 'Display in'
|
9
|
+
help: 'Help'
|
10
|
+
edit: 'Edit'
|
11
|
+
|
12
|
+
new_field: 'New field'
|
13
|
+
|
14
|
+
field_success_added: 'Field «%{name}» added successfully.'
|
15
|
+
field_success_updated: 'Field «%{name}» updated successfully.'
|
16
|
+
field_success_removed: 'Field «%{name}» removed successfully.'
|
17
|
+
field_success_moved: 'Field «%{name} moved successfully.'
|
9
18
|
|
10
19
|
string: 'String'
|
11
20
|
integer: 'Integer'
|
@@ -21,14 +30,17 @@ en:
|
|
21
30
|
|
22
31
|
are_you_sure?: 'Are you sure?'
|
23
32
|
|
33
|
+
page_not_found: 'Page not found'
|
34
|
+
|
24
35
|
new_page: 'New page'
|
25
36
|
edit_page: 'Edit page'
|
26
37
|
delete_page: 'Delete page'
|
27
38
|
|
39
|
+
page_success_added: 'Page «%{name}» added successfully.'
|
40
|
+
page_success_updated: 'Page «%{name}» updated successfully.'
|
41
|
+
page_success_removed: 'Page «%{name}» removed successfully.'
|
42
|
+
|
43
|
+
template: 'Template'
|
28
44
|
new_template: 'New template'
|
29
45
|
edit_template: 'Edit template'
|
30
|
-
delete_template: 'Delete template'
|
31
|
-
|
32
|
-
new_field: 'New field'
|
33
|
-
|
34
|
-
page_not_found: 'Page not found'
|
46
|
+
delete_template: 'Delete template'
|
data/config/locales/ru.yml
CHANGED
@@ -8,19 +8,22 @@ ru:
|
|
8
8
|
are_you_sure?: 'Вы уверены?'
|
9
9
|
display_in: 'Отображать в'
|
10
10
|
|
11
|
+
|
11
12
|
menu: 'Меню'
|
12
13
|
breadcrumbs: 'Хлебные крошки'
|
13
14
|
|
14
|
-
|
15
|
-
edit_page: 'Редактирование страницы'
|
16
|
-
delete_page: 'Удалить страницу'
|
17
|
-
|
15
|
+
template: 'Шаблон'
|
18
16
|
new_template: 'Создать шаблон'
|
19
17
|
edit_template: 'Редактирование шаблона'
|
20
18
|
delete_template: 'Удалить шаблон'
|
21
19
|
|
22
20
|
new_field: 'Добавить поле'
|
23
21
|
|
22
|
+
field_success_added: 'Поле «%{name}» успешно добавлено.'
|
23
|
+
field_success_updated: 'Поле «%{name}» успешно обновлено.'
|
24
|
+
field_success_removed: 'Поле «%{name}» успешно удалено.'
|
25
|
+
field_success_moved: 'Поле «%{name}» успешно перемещено.'
|
26
|
+
|
24
27
|
string: 'Строка'
|
25
28
|
integer: 'Целое число'
|
26
29
|
float: 'Дробное число'
|
@@ -29,9 +32,19 @@ ru:
|
|
29
32
|
text: 'Текст'
|
30
33
|
html: 'HTML'
|
31
34
|
image: 'Изображение'
|
35
|
+
help: 'Помощь'
|
36
|
+
edit: 'Редактировать'
|
32
37
|
|
33
38
|
page_not_found: 'Страница не найдена'
|
34
39
|
|
40
|
+
new_page: 'Создать страницу'
|
41
|
+
edit_page: 'Редактирование страницы'
|
42
|
+
delete_page: 'Удалить страницу'
|
43
|
+
|
44
|
+
page_success_added: 'Страница «%{name}» успешно добавлена.'
|
45
|
+
page_success_updated: 'Страница «%{name}» успешно обновлена.'
|
46
|
+
page_success_removed: 'Страница «%{name}» успешно удалена.'
|
47
|
+
|
35
48
|
activerecord:
|
36
49
|
attributes:
|
37
50
|
constructor_pages/field:
|
data/lib/constructor-pages.rb
CHANGED
@@ -97,14 +97,6 @@ module ConstructorPages
|
|
97
97
|
page_two.full_url.should == '/hello/world'
|
98
98
|
end
|
99
99
|
|
100
|
-
it 'should be translit utf-8' do
|
101
|
-
page = Page.create name: 'Проверка'
|
102
|
-
page.full_url.should == '/proverka'
|
103
|
-
|
104
|
-
page_two = Page.create name: 'Тест', parent: page
|
105
|
-
page_two.full_url.should == '/proverka/test'
|
106
|
-
end
|
107
|
-
|
108
100
|
context 'if parent or url has been changed' do
|
109
101
|
it 'should update full_url' do
|
110
102
|
page = Page.create name: 'Change url', url: 'change-url', auto_url: false
|
@@ -134,6 +126,16 @@ module ConstructorPages
|
|
134
126
|
end
|
135
127
|
end
|
136
128
|
|
129
|
+
describe 'translit' do
|
130
|
+
it 'should translit utf-8' do
|
131
|
+
page = Page.create name: 'Проверка'
|
132
|
+
page.full_url.should == '/proverka'
|
133
|
+
|
134
|
+
page_two = Page.create name: 'Тест', parent: page
|
135
|
+
page_two.full_url.should == '/proverka/test'
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
137
139
|
describe 'descendants_update' do
|
138
140
|
it 'should update descendants full_url' do
|
139
141
|
page = Page.create name: 'Update descendants', url: 'update-descendants', auto_url: false
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: constructor-pages
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.1
|
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: 2013-06-
|
12
|
+
date: 2013-06-16 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: constructor-core
|
@@ -18,7 +18,7 @@ dependencies:
|
|
18
18
|
requirements:
|
19
19
|
- - '='
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: 0.5.
|
21
|
+
version: 0.5.1
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -26,7 +26,7 @@ dependencies:
|
|
26
26
|
requirements:
|
27
27
|
- - '='
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version: 0.5.
|
29
|
+
version: 0.5.1
|
30
30
|
- !ruby/object:Gem::Dependency
|
31
31
|
name: dragonfly
|
32
32
|
requirement: !ruby/object:Gem::Requirement
|