lolita-menu 0.0.10 → 0.0.11
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/app/models/menu_item.rb +12 -8
- data/app/views/components/lolita/menu_items/_display.html.haml +2 -2
- data/config/locales/en.yml +3 -1
- data/config/locales/lv.yml +3 -1
- data/lolita-menu.gemspec +2 -2
- metadata +23 -23
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.11
|
data/app/models/menu_item.rb
CHANGED
@@ -9,6 +9,7 @@ class MenuItem < ActiveRecord::Base
|
|
9
9
|
validates :url, :format => {:with => /^(\/)|(http).*/}, :unless=>:root?
|
10
10
|
|
11
11
|
before_create :set_default_positions
|
12
|
+
before_save :normalize_url
|
12
13
|
after_create :put_in_place
|
13
14
|
before_validation :set_default_values, :if=>:new_record?
|
14
15
|
|
@@ -30,7 +31,7 @@ class MenuItem < ActiveRecord::Base
|
|
30
31
|
# instance methods
|
31
32
|
|
32
33
|
def active?(request,options={})
|
33
|
-
active_item =
|
34
|
+
active_item = self_and_descendants.detect{|item|
|
34
35
|
item.url_match?(request,options[:fullpath])
|
35
36
|
}
|
36
37
|
|
@@ -38,9 +39,8 @@ class MenuItem < ActiveRecord::Base
|
|
38
39
|
end
|
39
40
|
|
40
41
|
def url_match?(request,fullpath=false)
|
41
|
-
|
42
|
-
|
43
|
-
self.url==request.url
|
42
|
+
if self.url.strip.match(/^http/)
|
43
|
+
self.url.strip==request.url
|
44
44
|
else
|
45
45
|
only_path = (fullpath ? request.fullpath : request.path).gsub(/\?.*/,"")
|
46
46
|
self.real_url(request.params) == only_path
|
@@ -48,7 +48,7 @@ class MenuItem < ActiveRecord::Base
|
|
48
48
|
end
|
49
49
|
|
50
50
|
def real_url(params)
|
51
|
-
self.url.gsub(/(:\w+)\/?/) do |m|
|
51
|
+
self.url.strip.gsub(/(:\w+)\/?/) do |m|
|
52
52
|
params_key = $1.gsub(":","").to_sym
|
53
53
|
params.has_key?(params_key) ? "#{params[params_key]}#{m[m.size-1]=="/" ? "/" : ""}" : ""
|
54
54
|
end
|
@@ -78,11 +78,11 @@ class MenuItem < ActiveRecord::Base
|
|
78
78
|
@children
|
79
79
|
end
|
80
80
|
|
81
|
-
def
|
82
|
-
@
|
81
|
+
def self_and_descendants
|
82
|
+
@self_and_descendants||=self.class.where("lft>=:left AND rgt<=:right AND menu_id=:menu",{
|
83
83
|
:left => self.lft,:right => self.rgt, :menu=>self.menu_id
|
84
84
|
}).order("lft asc")
|
85
|
-
@
|
85
|
+
@self_and_descendants
|
86
86
|
end
|
87
87
|
|
88
88
|
def root
|
@@ -159,4 +159,8 @@ class MenuItem < ActiveRecord::Base
|
|
159
159
|
self.url||="/"
|
160
160
|
end
|
161
161
|
|
162
|
+
def normalize_url
|
163
|
+
self.url = self.url.to_s.strip
|
164
|
+
end
|
165
|
+
|
162
166
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
%button{:class => "add_new_menu_item",:"data-id" => menu.id,:"data-url" => menu_items_path(:menu_id=>menu.id)}
|
2
|
-
= "
|
2
|
+
= t("lolita.menu.add_new")
|
3
3
|
%button{:class => "save_menu_tree", :"data-id" => "menu_tree_#{menu.id}"}
|
4
|
-
= "
|
4
|
+
= t("lolita.menu.save_menu")
|
5
5
|
%ol{:class=>"menu-items-tree", :id=>"menu_tree_#{menu.id}", :"data-url"=>update_tree_menu_items_path(:menu_id=>menu.id)}
|
6
6
|
- menu.children.each do |item|
|
7
7
|
= render_component "lolita/menu_items", :row, :item => item, :menu => menu
|
data/config/locales/en.yml
CHANGED
data/config/locales/lv.yml
CHANGED
@@ -4,4 +4,6 @@ lv:
|
|
4
4
|
notice: "Izvēlne veiksmīgi saglabāta."
|
5
5
|
error: "Izvēlni neizdevās saglabāt. Mēģiniet vēlreiz."
|
6
6
|
"branch created": "Jauns izvēlnes sadaļa izveidota."
|
7
|
-
"branch deleted": "Izvēlnes sadaļa dzēsta."
|
7
|
+
"branch deleted": "Izvēlnes sadaļa dzēsta."
|
8
|
+
add_new: "Pievienot jaunu"
|
9
|
+
save_menu: "Saglabāt izvēlni"
|
data/lolita-menu.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{lolita-menu}
|
8
|
-
s.version = "0.0.
|
8
|
+
s.version = "0.0.11"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["ITHouse", "Arturs Meisters"]
|
12
|
-
s.date = %q{2011-
|
12
|
+
s.date = %q{2011-08-11}
|
13
13
|
s.description = %q{Manage public menus for each project inside Lolita.}
|
14
14
|
s.email = %q{support@ithouse.lv}
|
15
15
|
s.extra_rdoc_files = [
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lolita-menu
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.11
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,12 +10,12 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2011-
|
13
|
+
date: 2011-08-11 00:00:00.000000000 +03:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: lolita
|
18
|
-
requirement: &
|
18
|
+
requirement: &74478890 !ruby/object:Gem::Requirement
|
19
19
|
none: false
|
20
20
|
requirements:
|
21
21
|
- - ~>
|
@@ -23,10 +23,10 @@ dependencies:
|
|
23
23
|
version: 3.1.6
|
24
24
|
type: :runtime
|
25
25
|
prerelease: false
|
26
|
-
version_requirements: *
|
26
|
+
version_requirements: *74478890
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: haml
|
29
|
-
requirement: &
|
29
|
+
requirement: &74478580 !ruby/object:Gem::Requirement
|
30
30
|
none: false
|
31
31
|
requirements:
|
32
32
|
- - ! '>='
|
@@ -34,10 +34,10 @@ dependencies:
|
|
34
34
|
version: '0'
|
35
35
|
type: :runtime
|
36
36
|
prerelease: false
|
37
|
-
version_requirements: *
|
37
|
+
version_requirements: *74478580
|
38
38
|
- !ruby/object:Gem::Dependency
|
39
39
|
name: rspec
|
40
|
-
requirement: &
|
40
|
+
requirement: &74478210 !ruby/object:Gem::Requirement
|
41
41
|
none: false
|
42
42
|
requirements:
|
43
43
|
- - ~>
|
@@ -45,10 +45,10 @@ dependencies:
|
|
45
45
|
version: 2.6.0
|
46
46
|
type: :development
|
47
47
|
prerelease: false
|
48
|
-
version_requirements: *
|
48
|
+
version_requirements: *74478210
|
49
49
|
- !ruby/object:Gem::Dependency
|
50
50
|
name: sqlite3
|
51
|
-
requirement: &
|
51
|
+
requirement: &74477880 !ruby/object:Gem::Requirement
|
52
52
|
none: false
|
53
53
|
requirements:
|
54
54
|
- - ! '>='
|
@@ -56,10 +56,10 @@ dependencies:
|
|
56
56
|
version: '0'
|
57
57
|
type: :development
|
58
58
|
prerelease: false
|
59
|
-
version_requirements: *
|
59
|
+
version_requirements: *74477880
|
60
60
|
- !ruby/object:Gem::Dependency
|
61
61
|
name: rspec-rails
|
62
|
-
requirement: &
|
62
|
+
requirement: &74476870 !ruby/object:Gem::Requirement
|
63
63
|
none: false
|
64
64
|
requirements:
|
65
65
|
- - ~>
|
@@ -67,10 +67,10 @@ dependencies:
|
|
67
67
|
version: 2.6.0
|
68
68
|
type: :development
|
69
69
|
prerelease: false
|
70
|
-
version_requirements: *
|
70
|
+
version_requirements: *74476870
|
71
71
|
- !ruby/object:Gem::Dependency
|
72
72
|
name: haml-rails
|
73
|
-
requirement: &
|
73
|
+
requirement: &74476210 !ruby/object:Gem::Requirement
|
74
74
|
none: false
|
75
75
|
requirements:
|
76
76
|
- - ! '>='
|
@@ -78,10 +78,10 @@ dependencies:
|
|
78
78
|
version: '0'
|
79
79
|
type: :development
|
80
80
|
prerelease: false
|
81
|
-
version_requirements: *
|
81
|
+
version_requirements: *74476210
|
82
82
|
- !ruby/object:Gem::Dependency
|
83
83
|
name: shoulda
|
84
|
-
requirement: &
|
84
|
+
requirement: &74475510 !ruby/object:Gem::Requirement
|
85
85
|
none: false
|
86
86
|
requirements:
|
87
87
|
- - ! '>='
|
@@ -89,10 +89,10 @@ dependencies:
|
|
89
89
|
version: '0'
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
|
-
version_requirements: *
|
92
|
+
version_requirements: *74475510
|
93
93
|
- !ruby/object:Gem::Dependency
|
94
94
|
name: bundler
|
95
|
-
requirement: &
|
95
|
+
requirement: &74474950 !ruby/object:Gem::Requirement
|
96
96
|
none: false
|
97
97
|
requirements:
|
98
98
|
- - ~>
|
@@ -100,10 +100,10 @@ dependencies:
|
|
100
100
|
version: 1.0.0
|
101
101
|
type: :development
|
102
102
|
prerelease: false
|
103
|
-
version_requirements: *
|
103
|
+
version_requirements: *74474950
|
104
104
|
- !ruby/object:Gem::Dependency
|
105
105
|
name: jeweler
|
106
|
-
requirement: &
|
106
|
+
requirement: &74452710 !ruby/object:Gem::Requirement
|
107
107
|
none: false
|
108
108
|
requirements:
|
109
109
|
- - ~>
|
@@ -111,10 +111,10 @@ dependencies:
|
|
111
111
|
version: 1.5.2
|
112
112
|
type: :development
|
113
113
|
prerelease: false
|
114
|
-
version_requirements: *
|
114
|
+
version_requirements: *74452710
|
115
115
|
- !ruby/object:Gem::Dependency
|
116
116
|
name: rcov
|
117
|
-
requirement: &
|
117
|
+
requirement: &74452180 !ruby/object:Gem::Requirement
|
118
118
|
none: false
|
119
119
|
requirements:
|
120
120
|
- - ! '>='
|
@@ -122,7 +122,7 @@ dependencies:
|
|
122
122
|
version: '0'
|
123
123
|
type: :development
|
124
124
|
prerelease: false
|
125
|
-
version_requirements: *
|
125
|
+
version_requirements: *74452180
|
126
126
|
description: Manage public menus for each project inside Lolita.
|
127
127
|
email: support@ithouse.lv
|
128
128
|
executables: []
|
@@ -190,7 +190,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
190
190
|
version: '0'
|
191
191
|
segments:
|
192
192
|
- 0
|
193
|
-
hash:
|
193
|
+
hash: -50740721
|
194
194
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
195
195
|
none: false
|
196
196
|
requirements:
|