activa 0.0.8 → 0.0.9
Sign up to get free protection for your applications and to get access to all the features.
- data/app/models/activa/page.rb +16 -4
- data/app/views/activa/pages/_form.html.erb +5 -0
- data/app/views/activa/pages/partials/_sidebar.html.erb +11 -0
- data/app/views/activa/pages/partials/_sidebar_items.html.erb +5 -0
- data/app/views/activa/pages/show.html.erb +1 -1
- data/config/locales/en.yml +7 -0
- data/config/locales/ru.yml +7 -0
- data/db/migrate/20120530231335_add_menu_type_to_pages.rb +6 -0
- data/lib/activa/version.rb +1 -1
- metadata +28 -26
- data/app/views/activa/pages/partials/_neighbours.html.erb +0 -11
data/app/models/activa/page.rb
CHANGED
@@ -3,7 +3,9 @@ require 'awesome_nested_set'
|
|
3
3
|
# TODO Изменять slug только в том случае, когда он был изменен вручную
|
4
4
|
module Activa
|
5
5
|
class Page < ActiveRecord::Base
|
6
|
-
|
6
|
+
MENU_TYPES = %w(none neighbours children)
|
7
|
+
|
8
|
+
attr_accessible :title, :article, :menu_type, :slug, :parent_id
|
7
9
|
|
8
10
|
# see https://github.com/collectiveidea/awesome_nested_set
|
9
11
|
acts_as_nested_set
|
@@ -13,12 +15,15 @@ module Activa
|
|
13
15
|
:sync_url => false, # we update this manually
|
14
16
|
:only_when_blank => true
|
15
17
|
|
16
|
-
validates :title,
|
17
|
-
validates :article,
|
18
|
-
validates :slug,
|
18
|
+
validates :title, :presence => true
|
19
|
+
validates :article, :presence => true
|
20
|
+
validates :slug, :format => { :with => /^[0-9a-z_-]+$/i }, :allow_blank => true
|
21
|
+
validates :menu_type, :inclusion => { :in => MENU_TYPES }
|
19
22
|
|
20
23
|
default_scope order('lft')
|
21
24
|
|
25
|
+
before_save :set_default_values
|
26
|
+
|
22
27
|
# Если создаётся страница без указанного родителя,
|
23
28
|
# то автоматически назначаем родителем корневую страницу
|
24
29
|
# Но только если текущая страница не корневая!
|
@@ -124,6 +129,10 @@ module Activa
|
|
124
129
|
path.sub(/^\/+/, '')
|
125
130
|
end
|
126
131
|
|
132
|
+
def to_s
|
133
|
+
title
|
134
|
+
end
|
135
|
+
|
127
136
|
private
|
128
137
|
|
129
138
|
# После переноса узла запускается этот метод и успешно
|
@@ -135,5 +144,8 @@ module Activa
|
|
135
144
|
"/#{slices.join('/')}".gsub(/^\/+/, '/')
|
136
145
|
end
|
137
146
|
|
147
|
+
def set_default_values
|
148
|
+
self.menu_type ||= 'none'
|
149
|
+
end
|
138
150
|
end
|
139
151
|
end
|
@@ -10,6 +10,11 @@
|
|
10
10
|
<%= f.input :parent_id, :as => :pages_tree, :page => @page %>
|
11
11
|
<% end %>
|
12
12
|
|
13
|
+
<%= f.input :menu_type,
|
14
|
+
:collection => Activa::Page::MENU_TYPES.map {|menu_type| [t("simple_form.options.page.menu_type.#{menu_type}"), menu_type] },
|
15
|
+
:include_blank => false
|
16
|
+
%>
|
17
|
+
|
13
18
|
<%= f.input :article, :as => :editor %>
|
14
19
|
|
15
20
|
<div class="actions">
|
@@ -0,0 +1,11 @@
|
|
1
|
+
<% unless page.menu_type == 'none' %>
|
2
|
+
<div class="tabbable tabs-right">
|
3
|
+
<ul id="pages-<%= page.menu_type %>" class="nav nav-tabs">
|
4
|
+
<% if page.menu_type == 'children' && page.inner_pages.any? %>
|
5
|
+
<%= render 'activa/pages/partials/sidebar_items', :page => page, :items => page.inner_pages %>
|
6
|
+
<% elsif page.menu_type == 'neighbours' && page.neighbours.any? %>
|
7
|
+
<%= render 'activa/pages/partials/sidebar_items', :page => page, :items => page.neighbours %>
|
8
|
+
<% end %>
|
9
|
+
</ul>
|
10
|
+
</div>
|
11
|
+
<% end %>
|
data/config/locales/en.yml
CHANGED
@@ -12,6 +12,13 @@ en:
|
|
12
12
|
article: 'Page content'
|
13
13
|
parent_id: 'Choose parent page'
|
14
14
|
slug: 'Permalink'
|
15
|
+
menu_type: 'Sidebar view'
|
16
|
+
options:
|
17
|
+
page:
|
18
|
+
menu_type:
|
19
|
+
none: 'Do not show sidebar'
|
20
|
+
neighbours: 'Show neigbours pages'
|
21
|
+
children: 'Show children pages'
|
15
22
|
helpers:
|
16
23
|
submit:
|
17
24
|
slug:
|
data/config/locales/ru.yml
CHANGED
@@ -12,6 +12,13 @@ ru:
|
|
12
12
|
article: 'Содержимое'
|
13
13
|
parent_id: 'Родительская страница'
|
14
14
|
slug: 'Постоянная ссылка'
|
15
|
+
menu_type: 'Вид бокового меню'
|
16
|
+
options:
|
17
|
+
page:
|
18
|
+
menu_type:
|
19
|
+
none: 'Не показывать боковое меню'
|
20
|
+
neighbours: 'Показывать соседние страницы'
|
21
|
+
children: 'Показывать дочерние страницы'
|
15
22
|
helpers:
|
16
23
|
submit:
|
17
24
|
slug:
|
data/lib/activa/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activa
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.9
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2012-05-30 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
16
|
-
requirement: &
|
16
|
+
requirement: &85564360 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 3.2.3
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *85564360
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: stringex
|
27
|
-
requirement: &
|
27
|
+
requirement: &85564150 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *85564150
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: awesome_nested_set
|
38
|
-
requirement: &
|
38
|
+
requirement: &85563920 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *85563920
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: simple_form
|
49
|
-
requirement: &
|
49
|
+
requirement: &85563710 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: '0'
|
55
55
|
type: :runtime
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *85563710
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: cancan
|
60
|
-
requirement: &
|
60
|
+
requirement: &85563500 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ! '>='
|
@@ -65,10 +65,10 @@ dependencies:
|
|
65
65
|
version: '0'
|
66
66
|
type: :runtime
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *85563500
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: compass-rails
|
71
|
-
requirement: &
|
71
|
+
requirement: &85563290 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ! '>='
|
@@ -76,10 +76,10 @@ dependencies:
|
|
76
76
|
version: '0'
|
77
77
|
type: :runtime
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *85563290
|
80
80
|
- !ruby/object:Gem::Dependency
|
81
81
|
name: rspec
|
82
|
-
requirement: &
|
82
|
+
requirement: &85563080 !ruby/object:Gem::Requirement
|
83
83
|
none: false
|
84
84
|
requirements:
|
85
85
|
- - ! '>='
|
@@ -87,10 +87,10 @@ dependencies:
|
|
87
87
|
version: '0'
|
88
88
|
type: :development
|
89
89
|
prerelease: false
|
90
|
-
version_requirements: *
|
90
|
+
version_requirements: *85563080
|
91
91
|
- !ruby/object:Gem::Dependency
|
92
92
|
name: sqlite3
|
93
|
-
requirement: &
|
93
|
+
requirement: &85562870 !ruby/object:Gem::Requirement
|
94
94
|
none: false
|
95
95
|
requirements:
|
96
96
|
- - ! '>='
|
@@ -98,10 +98,10 @@ dependencies:
|
|
98
98
|
version: '0'
|
99
99
|
type: :development
|
100
100
|
prerelease: false
|
101
|
-
version_requirements: *
|
101
|
+
version_requirements: *85562870
|
102
102
|
- !ruby/object:Gem::Dependency
|
103
103
|
name: shoulda-matchers
|
104
|
-
requirement: &
|
104
|
+
requirement: &85562660 !ruby/object:Gem::Requirement
|
105
105
|
none: false
|
106
106
|
requirements:
|
107
107
|
- - ! '>='
|
@@ -109,10 +109,10 @@ dependencies:
|
|
109
109
|
version: '0'
|
110
110
|
type: :development
|
111
111
|
prerelease: false
|
112
|
-
version_requirements: *
|
112
|
+
version_requirements: *85562660
|
113
113
|
- !ruby/object:Gem::Dependency
|
114
114
|
name: capybara
|
115
|
-
requirement: &
|
115
|
+
requirement: &85562450 !ruby/object:Gem::Requirement
|
116
116
|
none: false
|
117
117
|
requirements:
|
118
118
|
- - ! '>='
|
@@ -120,10 +120,10 @@ dependencies:
|
|
120
120
|
version: '0'
|
121
121
|
type: :development
|
122
122
|
prerelease: false
|
123
|
-
version_requirements: *
|
123
|
+
version_requirements: *85562450
|
124
124
|
- !ruby/object:Gem::Dependency
|
125
125
|
name: pry
|
126
|
-
requirement: &
|
126
|
+
requirement: &85562240 !ruby/object:Gem::Requirement
|
127
127
|
none: false
|
128
128
|
requirements:
|
129
129
|
- - ! '>='
|
@@ -131,10 +131,10 @@ dependencies:
|
|
131
131
|
version: '0'
|
132
132
|
type: :development
|
133
133
|
prerelease: false
|
134
|
-
version_requirements: *
|
134
|
+
version_requirements: *85562240
|
135
135
|
- !ruby/object:Gem::Dependency
|
136
136
|
name: gem-release
|
137
|
-
requirement: &
|
137
|
+
requirement: &85562030 !ruby/object:Gem::Requirement
|
138
138
|
none: false
|
139
139
|
requirements:
|
140
140
|
- - ! '>='
|
@@ -142,7 +142,7 @@ dependencies:
|
|
142
142
|
version: '0'
|
143
143
|
type: :development
|
144
144
|
prerelease: false
|
145
|
-
version_requirements: *
|
145
|
+
version_requirements: *85562030
|
146
146
|
description: Rails 3.1+ dynamic page management
|
147
147
|
email:
|
148
148
|
- demerest@gmail.com
|
@@ -568,7 +568,8 @@ files:
|
|
568
568
|
- app/views/activa/pages/_form.html.erb
|
569
569
|
- app/views/activa/pages/index.html.erb
|
570
570
|
- app/views/activa/pages/edit.html.erb
|
571
|
-
- app/views/activa/pages/partials/
|
571
|
+
- app/views/activa/pages/partials/_sidebar.html.erb
|
572
|
+
- app/views/activa/pages/partials/_sidebar_items.html.erb
|
572
573
|
- app/views/activa/pages/partials/menu/_index.html.erb
|
573
574
|
- app/views/activa/pages/partials/menu/_show.html.erb
|
574
575
|
- app/views/activa/pages/_page.html.erb
|
@@ -577,6 +578,7 @@ files:
|
|
577
578
|
- config/locales/en.yml
|
578
579
|
- config/initializers/simple_form.rb
|
579
580
|
- config/routes.rb
|
581
|
+
- db/migrate/20120530231335_add_menu_type_to_pages.rb
|
580
582
|
- db/migrate/20110520121037_create_activa_pages.rb
|
581
583
|
- db/migrate/20120519124034_add_show_neighbours_to_activa_pages.rb
|
582
584
|
- lib/activa.rb
|
@@ -1,11 +0,0 @@
|
|
1
|
-
<ul id="pages-neighbours">
|
2
|
-
<% if page.inner_pages.any? %>
|
3
|
-
<% page.inner_pages.each do |page| %>
|
4
|
-
<li><%= link_to page.title, main_app.activa_page_path(page.path) %></li>
|
5
|
-
<% end %>
|
6
|
-
<% elsif page.neighbours.any? %>
|
7
|
-
<% page.neighbours.each do |page| %>
|
8
|
-
<li><%= link_to_unless_current page.title, main_app.activa_page_path(page.path) %></li>
|
9
|
-
<% end %>
|
10
|
-
<% end %>
|
11
|
-
</ul>
|