brut 0.13.0 → 0.14.0

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.
@@ -1,13 +1,16 @@
1
- # Renders a `<meta>` tag that contains the name of the page. This is useful for end to end tests to assert that they are on a specific page before continuing with the test. It can eliminate a lot of confusion when a test fails.
1
+ # Renders a `<meta>` tag (in dev and test) that contains the name of the page. This is useful for end to end tests to assert that they are on a specific page before continuing with the test. It can eliminate a lot of confusion when a test fails.
2
2
  class Brut::FrontEnd::Components::PageIdentifier < Brut::FrontEnd::Component
3
- def initialize(page_name)
4
- @page_name = page_name
3
+ # Create the component
4
+ #
5
+ # @param [Brut::FrontEnd::Page] page the current page
6
+ def initialize(page)
7
+ @page = page
5
8
  end
6
9
 
7
10
  def view_template
8
11
  if Brut.container.project_env.production?
9
12
  return nil
10
13
  end
11
- meta(name: "class", content: @page_name)
14
+ meta(name: "class", content: @page.page_name)
12
15
  end
13
16
  end
@@ -6,6 +6,17 @@
6
6
  #
7
7
  # This base class contains helper methods needed for implementing a layout.
8
8
  class Brut::FrontEnd::Layout < Brut::FrontEnd::Component
9
+
10
+ # Access the page being laid out
11
+ attr_reader :page
12
+
13
+ # Create the layout for a given page.
14
+ #
15
+ # @param [Brut::FrontEnd::Page] page the page being laid out.
16
+ def initialize(page:)
17
+ @page = page
18
+ end
19
+
9
20
  # Get the actual path of an asset managed by Brut. This handles
10
21
  # locating the asset's URL as well as ensuring the hash is properly
11
22
  # inserted into the filename.
@@ -90,7 +90,7 @@ private
90
90
  ].join("_")).camelize
91
91
  )
92
92
  Brut.container.instrumentation.add_prefixed_attributes("brut", layout_class: layout_class)
93
- render layout_class.new(page_name:,&block)
93
+ render layout_class.new(page:self,&block)
94
94
  end
95
95
 
96
96
 
data/lib/brut/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  module Brut
2
2
  # @!visibility private
3
- VERSION = "0.13.0"
3
+ VERSION = "0.14.0"
4
4
  end
data/mkbrut/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- mkbrut (0.13.0)
4
+ mkbrut (0.14.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -1,3 +1,3 @@
1
1
  module MKBrut
2
- VERSION = "0.13.0"
2
+ VERSION = "0.14.0"
3
3
  end
@@ -0,0 +1,11 @@
1
+ # A blank layout that just renders whatever the page content is.
2
+ # This is useful for a page that can respond to Ajax and not want
3
+ # the surrounding HTML metadata.
4
+ class BlankLayout < Brut::FrontEnd::Layout
5
+ include Brut::FrontEnd::Components
6
+
7
+ def view_template
8
+ yield
9
+ end
10
+ end
11
+
@@ -4,10 +4,6 @@
4
4
  class DefaultLayout < Brut::FrontEnd::Layout
5
5
  include Brut::FrontEnd::Components
6
6
 
7
- def initialize(page_name:)
8
- @page_name = page_name
9
- end
10
-
11
7
  # Brut::FrontEnd::Page's view_template ultimately calls this method
12
8
  # to wrap itself in the layout defined below.
13
9
  def view_template
@@ -35,7 +31,8 @@ class DefaultLayout < Brut::FrontEnd::Layout
35
31
 
36
32
  # Brut::FrontEnd::Components::PageIdentifier, which produces
37
33
  # a <meta> tag with the page's name. Useful for end to end tests.
38
- PageIdentifier(@page_name)
34
+ # Does not generate anything in production.
35
+ PageIdentifier(page)
39
36
 
40
37
  # Brut::FrontEnd::Components::I18nTranslations, which includes
41
38
  # translations starting with cv.cs for use with client-side
@@ -60,7 +57,7 @@ class DefaultLayout < Brut::FrontEnd::Layout
60
57
  end
61
58
  # Adds the page's name as a class name. You can use this for
62
59
  # CSS if needed.
63
- body(class: @page_name) do
60
+ body(class: page.page_name) do
64
61
  # Render the <brut-tracing> element, which will send
65
62
  # OpenTelemetry traces back to the server to be joined up with
66
63
  # the server's traces.
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: brut
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.13.0
4
+ version: 0.14.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Bryant Copeland
@@ -703,7 +703,6 @@ files:
703
703
  - brutrb.com/public/favicon.ico
704
704
  - brutrb.com/recipes/alternate-layouts.md
705
705
  - brutrb.com/recipes/authentication.md
706
- - brutrb.com/recipes/blank-layouts.md
707
706
  - brutrb.com/recipes/custom-flash.md
708
707
  - brutrb.com/recipes/form-errors.md
709
708
  - brutrb.com/recipes/indexed-forms.md
@@ -1475,6 +1474,7 @@ files:
1475
1474
  - mkbrut/templates/Base/app/src/front_end/images/icon.png
1476
1475
  - mkbrut/templates/Base/app/src/front_end/images/mkicons.sh
1477
1476
  - mkbrut/templates/Base/app/src/front_end/js/index.js
1477
+ - mkbrut/templates/Base/app/src/front_end/layouts/blank_layout.rb
1478
1478
  - mkbrut/templates/Base/app/src/front_end/layouts/default_layout.rb.erb
1479
1479
  - mkbrut/templates/Base/app/src/front_end/pages/app_page.rb
1480
1480
  - mkbrut/templates/Base/app/src/front_end/pages/home_page.rb
@@ -1,22 +0,0 @@
1
- # Blank or No Layout
2
-
3
- If you don't want a layout, you are encouraged to create a blank layout, for example:
4
-
5
- ```ruby
6
- class BlankLayout < Brut::FrontEnd::Layout
7
- def view_template
8
- yield
9
- end
10
- end
11
-
12
- # use like so:
13
-
14
- class NakedPage < AppPage
15
- def layout = "blank"
16
-
17
- def page_template
18
- # ...
19
- end
20
- end
21
- ```
22
-