tkh_menus 0.9 → 0.9.1
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -0
- data/app/controllers/menus_controller.rb +11 -4
- data/app/models/menu.rb +20 -20
- data/lib/tkh_menus/version.rb +1 -1
- data/lib/tkh_menus.rb +1 -1
- metadata +26 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9d2db02e4875f038bcec6574c3c5c1763bbd79ca
|
4
|
+
data.tar.gz: b6d887a2de36f34319d32850ea3f6d01618150f9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 01a27b2b33ebad980aa99801fd7d526d9c641ca326d99502cc0e55d46f0a139c25a0dca5edb09b0ccc81db5d30d467acbabe0f457457f73831b9d0870463642c
|
7
|
+
data.tar.gz: 5f1bbd8980ac83fb2e1e02af6e9d9652a0dc7b03f50a49469eb21d62d652f5a68ba51ba25ca3e45707b5723869491e747e69eda1ac8c84eccef67de702857d64
|
data/CHANGELOG.md
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
class MenusController < ApplicationController
|
2
|
-
|
2
|
+
|
3
3
|
before_filter :authenticate
|
4
4
|
before_filter :authenticate_with_admin
|
5
|
-
|
5
|
+
|
6
6
|
def index
|
7
7
|
@menus = Menu.ordered
|
8
8
|
switch_to_admin_layout
|
@@ -19,7 +19,7 @@ class MenusController < ApplicationController
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def create
|
22
|
-
@menu = Menu.new(
|
22
|
+
@menu = Menu.new(menu_params)
|
23
23
|
if @menu.save
|
24
24
|
redirect_to menus_path, notice: t('menus.create.notice')
|
25
25
|
else
|
@@ -29,7 +29,7 @@ class MenusController < ApplicationController
|
|
29
29
|
|
30
30
|
def update
|
31
31
|
@menu = Menu.find(params[:id])
|
32
|
-
if @menu.
|
32
|
+
if @menu.update(menu_params)
|
33
33
|
redirect_to menus_path, notice: t('menus.update.notice')
|
34
34
|
else
|
35
35
|
render action: "edit", warning: t('menus.update.warning'), layout: 'admin'
|
@@ -41,4 +41,11 @@ class MenusController < ApplicationController
|
|
41
41
|
@menu.destroy
|
42
42
|
redirect_to menus_url, notice: t('menus.destroy.notice')
|
43
43
|
end
|
44
|
+
|
45
|
+
private
|
46
|
+
|
47
|
+
# Never trust parameters from the scary internet, only allow the white list through.
|
48
|
+
def menu_params
|
49
|
+
params.require(:menu).permit(:name, :path, :parent_id, :parent_menu_name)
|
50
|
+
end
|
44
51
|
end
|
data/app/models/menu.rb
CHANGED
@@ -1,50 +1,50 @@
|
|
1
1
|
# this is needed for now to make mass assignment security compatible with the translation of globalize3
|
2
|
-
Globalize::ActiveRecord::Translation.class_eval do
|
3
|
-
|
4
|
-
end
|
2
|
+
# Globalize::ActiveRecord::Translation.class_eval do
|
3
|
+
# attr_accessible :locale
|
4
|
+
# end
|
5
5
|
|
6
6
|
class Menu < ActiveRecord::Base
|
7
|
-
|
8
|
-
attr_accessible :name, :path, :position, :parent_id, :parent_menu_name
|
9
|
-
|
7
|
+
|
8
|
+
# attr_accessible :name, :path, :position, :parent_id, :parent_menu_name
|
9
|
+
|
10
10
|
validates_presence_of :name, :path
|
11
|
-
|
11
|
+
|
12
12
|
translates :name, :path
|
13
|
-
|
13
|
+
|
14
14
|
def to_param
|
15
15
|
name ? "#{id}-#{name.to_url}" : id
|
16
16
|
end
|
17
|
-
|
18
|
-
scope :alphabetical, order('name')
|
19
|
-
scope :ordered, order('position, id')
|
17
|
+
|
18
|
+
scope :alphabetical, -> { order('name') }
|
19
|
+
scope :ordered, -> { order('position, id') }
|
20
20
|
# tree scopes
|
21
|
-
scope :orphans, where('parent_id IS ?', nil)
|
21
|
+
scope :orphans, -> { where('parent_id IS ?', nil) }
|
22
22
|
scope :with_parent_id, lambda { |id| where('parent_id = ?', id) }
|
23
|
-
|
23
|
+
|
24
24
|
def orphan?
|
25
25
|
parent_id == nil
|
26
26
|
end
|
27
|
-
|
27
|
+
|
28
28
|
def has_children?
|
29
29
|
Menu.with_parent_id(id).count >= 1
|
30
30
|
end
|
31
|
-
|
31
|
+
|
32
32
|
def children
|
33
33
|
Menu.with_parent_id(id)
|
34
34
|
end
|
35
|
-
|
35
|
+
|
36
36
|
def parent
|
37
37
|
Menu.find(parent_id)
|
38
38
|
end
|
39
|
-
|
39
|
+
|
40
40
|
def has_siblings?
|
41
41
|
Menu.with_parent_id(parent_id).count >= 1
|
42
42
|
end
|
43
|
-
|
43
|
+
|
44
44
|
def siblings
|
45
45
|
Menu.with_parent_id(parent_id)
|
46
46
|
end
|
47
|
-
|
47
|
+
|
48
48
|
### autocomplete related instance methods
|
49
49
|
def parent_menu_name
|
50
50
|
parent.try(:name) unless self.orphan?
|
@@ -57,5 +57,5 @@ class Menu < ActiveRecord::Base
|
|
57
57
|
self.parent_id = nil
|
58
58
|
end
|
59
59
|
end
|
60
|
-
|
60
|
+
|
61
61
|
end
|
data/lib/tkh_menus/version.rb
CHANGED
data/lib/tkh_menus.rb
CHANGED
metadata
CHANGED
@@ -1,57 +1,71 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tkh_menus
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 0.9.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Swami Atma
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2014-02-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - '>'
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '4.0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - '>'
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '4.0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: stringex
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 2.2.0
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 2.2.0
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: simple_form
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
30
44
|
requirements:
|
31
45
|
- - ~>
|
32
46
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
47
|
+
version: 3.0.1
|
34
48
|
type: :runtime
|
35
49
|
prerelease: false
|
36
50
|
version_requirements: !ruby/object:Gem::Requirement
|
37
51
|
requirements:
|
38
52
|
- - ~>
|
39
53
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
54
|
+
version: 3.0.1
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
56
|
+
name: globalize
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
44
58
|
requirements:
|
45
|
-
- -
|
59
|
+
- - ~>
|
46
60
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
61
|
+
version: 4.0.0
|
48
62
|
type: :runtime
|
49
63
|
prerelease: false
|
50
64
|
version_requirements: !ruby/object:Gem::Requirement
|
51
65
|
requirements:
|
52
|
-
- -
|
66
|
+
- - ~>
|
53
67
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
68
|
+
version: 4.0.0
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
70
|
name: sqlite3
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -156,7 +170,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
156
170
|
version: '0'
|
157
171
|
requirements: []
|
158
172
|
rubyforge_project:
|
159
|
-
rubygems_version: 2.
|
173
|
+
rubygems_version: 2.1.10
|
160
174
|
signing_key:
|
161
175
|
specification_version: 4
|
162
176
|
summary: Menu engine for the TKH CMS.
|