cat_router 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +4 -8
- data/app/models/cat_route.rb +1 -0
- data/lib/cat_router/instance_methods.rb +0 -1
- data/lib/cat_router/version.rb +1 -1
- data/lib/generators/templates/migration.rb +4 -1
- metadata +5 -7
data/README.rdoc
CHANGED
@@ -40,10 +40,6 @@ app/models/cat_route.rb file with content
|
|
40
40
|
class CatRoute
|
41
41
|
end
|
42
42
|
|
43
|
-
or app/controllers/cat_router_controller.rb file with content
|
44
|
-
|
45
|
-
class CatRouterController
|
46
|
-
end
|
47
43
|
|
48
44
|
== Examples
|
49
45
|
|
@@ -59,7 +55,7 @@ Note that :locale column is set to I18n.locale value by default but you can set
|
|
59
55
|
|
60
56
|
The plugin will auto generate the :slug value but you can set it manually:
|
61
57
|
|
62
|
-
myRoute = CatRoute.create(:title => 'Welcome', :html => '<b>welcome</b>', :slug => 'home/first_page')
|
58
|
+
myRoute = CatRoute.create(:title => 'Welcome', :html => '<b>welcome</b>', :slug => 'home/first_page', :domain => 'mydomain.com')
|
63
59
|
|
64
60
|
If you would like to create a subroute (a sub button of myRoute) you would do it like this
|
65
61
|
|
@@ -77,11 +73,11 @@ You can get a list of subbuttons like this
|
|
77
73
|
|
78
74
|
To get the list of main buttons for your main menu, you will use
|
79
75
|
|
80
|
-
mainButtons = CatRoute.base_routes.with_locale(
|
76
|
+
mainButtons = CatRoute.base_routes.with_locale('en').with_domain('mydomain.com')
|
81
77
|
|
82
78
|
You get a root button like this
|
83
79
|
|
84
|
-
rootButton = CatRoute.root_routes.with_locale(
|
80
|
+
rootButton = CatRoute.root_routes.with_locale('en').first
|
85
81
|
|
86
82
|
You get a button by slug like this
|
87
83
|
|
@@ -94,7 +90,7 @@ The @cat_route variable is also available (defined inside CatRoutesController) w
|
|
94
90
|
Using HAML you will define a main-menu like this
|
95
91
|
|
96
92
|
.mainmenu
|
97
|
-
- CatRoute.base_routes.with_locale(I18n.locale).each do |b|
|
93
|
+
- CatRoute.base_routes.with_locale(I18n.locale).with_domain(request.host).each do |b|
|
98
94
|
= link_to b.title, b.url, :class => b.slug == @cat_route.slug || b.id == @cat_route.parent_id ? 'selected' : ''
|
99
95
|
|
100
96
|
and a sub-menu like this
|
data/app/models/cat_route.rb
CHANGED
@@ -3,6 +3,7 @@ class CatRoute < ActiveRecord::Base
|
|
3
3
|
belongs_to :cat_route, :class_name => "CatRoute"
|
4
4
|
|
5
5
|
scope :with_locale, lambda{|locale| where('locale=?', locale) }
|
6
|
+
scope :with_domain, lambda{|domain| where('domain=?', domain) }
|
6
7
|
scope :base_routes, where('parent_id IS NULL')
|
7
8
|
scope :root_routes, where('slug=""')
|
8
9
|
scope :with_slug, lambda{|slug| where('slug=?', slug) }
|
data/lib/cat_router/version.rb
CHANGED
@@ -2,6 +2,7 @@ class CatRouterMigration < ActiveRecord::Migration
|
|
2
2
|
def self.up
|
3
3
|
create_table :cat_routes do |t|
|
4
4
|
t.string :locale
|
5
|
+
t.string :domain
|
5
6
|
t.string :title
|
6
7
|
t.string :slug
|
7
8
|
t.text :html
|
@@ -9,9 +10,11 @@ class CatRouterMigration < ActiveRecord::Migration
|
|
9
10
|
t.timestamps
|
10
11
|
end
|
11
12
|
|
13
|
+
add_index :cat_routes, :domain
|
12
14
|
add_index :cat_routes, :locale
|
13
15
|
add_index :cat_routes, :slug
|
14
|
-
add_index :cat_routes, [:
|
16
|
+
add_index :cat_routes, [:domain, :locale]
|
17
|
+
add_index :cat_routes, [:domain, :locale, :slug]
|
15
18
|
end
|
16
19
|
|
17
20
|
def self.down
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cat_router
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 19
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 4
|
10
|
+
version: 0.1.4
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Kristijan Sedlak
|
@@ -15,8 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-04-06 00:00:00
|
19
|
-
default_executable:
|
18
|
+
date: 2011-04-06 00:00:00 Z
|
20
19
|
dependencies: []
|
21
20
|
|
22
21
|
description: A simple router/CMS for displaying dynamic content on your site.
|
@@ -44,7 +43,6 @@ files:
|
|
44
43
|
- test/test_helper.rb
|
45
44
|
- README.rdoc
|
46
45
|
- MIT-LICENSE
|
47
|
-
has_rdoc: true
|
48
46
|
homepage: http://github.com/xpepermint/cat_router
|
49
47
|
licenses: []
|
50
48
|
|
@@ -76,7 +74,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
76
74
|
requirements: []
|
77
75
|
|
78
76
|
rubyforge_project:
|
79
|
-
rubygems_version: 1.
|
77
|
+
rubygems_version: 1.7.2
|
80
78
|
signing_key:
|
81
79
|
specification_version: 3
|
82
80
|
summary: CatRouter - The most simplistic CMS in the world.
|