lalala 4.0.0.dev.191 → 4.0.0.dev.192

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8abb57f6cc06fe407cc3dab84bc165a5a63b8601
4
- data.tar.gz: eb58f576a4aa169357f352cc53dfa613fec88d83
3
+ metadata.gz: abdac7f80c3c05f6d398582d7057e27456aeb13e
4
+ data.tar.gz: f3628af5e5b2601b4521e218fd062876260efdcc
5
5
  SHA512:
6
- metadata.gz: 27e10c18846ff6867ff3f2c96e1e8077897407e37eff4ab4b246ece110b1797732de9c1bd12487e3c42f7b932da8958132c02e23ae0f7620df9dabe82b9d8806
7
- data.tar.gz: 533574226ac2331af079e3e84c90589b22b07917a34a474d19833d03cd60f6dd67f3c89153b9ca592ae9711d4c658a34a8251d4ccad7db7c324eb84838eb5788
6
+ metadata.gz: c2eaaf24303dafe8cc5704f7a4e0cddb0a974270de9d9fb5691617bbf0b5ba7d47370b68dd282859e35d2b8730163bfdab229f6307998ea5ddf1cd40ce86b2f6
7
+ data.tar.gz: 778acd41e4e0395cffc9001305e202d7254df49913bc68ed807fc3ffb25b96461b15b9d21631fc6b3738f696034a1462b9ca4410d6fd59cc25d797c26dd84f3e
data/lib/lalala/engine.rb CHANGED
@@ -122,6 +122,9 @@ module Lalala
122
122
  ActionDispatch::Request.send(
123
123
  :include, Lalala::ExtActionDispatch::PageName)
124
124
 
125
+ ActionController::Base.send(
126
+ :include, Lalala::Pages::Helpers)
127
+
125
128
  end
126
129
 
127
130
  end
@@ -0,0 +1,18 @@
1
+ module Lalala::Pages::Helpers
2
+ extend ActiveSupport::Concern
3
+
4
+ included do
5
+ helper_method :current_page_chain, :current_page
6
+ end
7
+
8
+ protected
9
+
10
+ def current_page_chain
11
+ request.env["lalala.page_chain"] or []
12
+ end
13
+
14
+ def current_page
15
+ request.env["lalala.page"]
16
+ end
17
+
18
+ end
@@ -1,15 +1,7 @@
1
1
  class Lalala::Pages::PageTypeConstraint
2
2
 
3
3
  def initialize(type)
4
- type = "#{type}_page"
5
- type = type.classify
6
-
7
- while type.ends_with?("PagePage")
8
- type = type[0..-5]
9
- end
10
-
11
- type = type.constantize
12
- @type = type
4
+ @type = type.constantize
13
5
  end
14
6
 
15
7
  def matches?(request)
@@ -15,8 +15,8 @@ module Lalala::Pages::RouteMapper
15
15
  raise ArgumentError, "expected a page type"
16
16
  end
17
17
 
18
- type = args[0]
19
- options = { as: type }.merge(options)
18
+ type = Lalala::Pages::RouteMapper.page_class_name(args[0])
19
+ options = { as: type.underscore }.merge(options)
20
20
  options[:constraints] = Lalala::Pages::PageTypeConstraint.new(type)
21
21
 
22
22
  match '/', options
@@ -28,4 +28,15 @@ module Lalala::Pages::RouteMapper
28
28
  self
29
29
  end
30
30
 
31
+ def self.page_class_name(type)
32
+ type = "#{type}_page"
33
+ type = type.classify
34
+
35
+ while type.ends_with?("PagePage")
36
+ type = type[0..-5]
37
+ end
38
+
39
+ type
40
+ end
41
+
31
42
  end
data/lib/lalala/pages.rb CHANGED
@@ -7,5 +7,6 @@ module Lalala::Pages
7
7
 
8
8
  autoload :PageTypeConstraint
9
9
  autoload :RouteMapper
10
+ autoload :Helpers
10
11
 
11
12
  end
@@ -1,6 +1,6 @@
1
1
  module Lalala
2
2
  VERSION = "4.0.0"
3
- BUILD = "191"
3
+ BUILD = "192"
4
4
 
5
5
  if BUILD != ("{{BUILD_NUMBER" + "}}") # prevent sed replacement (see script/ci)
6
6
  BUILD_VERSION = "#{VERSION}.dev.#{BUILD}"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lalala
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.0.dev.191
4
+ version: 4.0.0.dev.192
5
5
  platform: ruby
6
6
  authors:
7
7
  - Simon Menke
@@ -1422,6 +1422,7 @@ files:
1422
1422
  - lib/lalala/pages.rb
1423
1423
  - lib/lalala/pages/child_type_validator.rb
1424
1424
  - lib/lalala/pages/children_length_validator.rb
1425
+ - lib/lalala/pages/helpers.rb
1425
1426
  - lib/lalala/pages/page_type_constraint.rb
1426
1427
  - lib/lalala/pages/path_handler.rb
1427
1428
  - lib/lalala/pages/route_mapper.rb