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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +23 -0
- data/Gemfile.lock +1 -1
- data/brut-css/package-lock.json +57 -106
- data/brut-css/package.json +1 -1
- data/brut-js/package-lock.json +50 -50
- data/brut-js/package.json +1 -1
- data/brutrb.com/.vitepress/config.mjs +0 -1
- data/brutrb.com/layouts.md +70 -12
- data/brutrb.com/package-lock.json +428 -381
- data/lib/brut/front_end/components/page_identifier.rb +7 -4
- data/lib/brut/front_end/layout.rb +11 -0
- data/lib/brut/front_end/page.rb +1 -1
- data/lib/brut/version.rb +1 -1
- data/mkbrut/Gemfile.lock +1 -1
- data/mkbrut/lib/mkbrut/version.rb +1 -1
- data/mkbrut/templates/Base/app/src/front_end/layouts/blank_layout.rb +11 -0
- data/mkbrut/templates/Base/app/src/front_end/layouts/default_layout.rb.erb +3 -6
- metadata +2 -2
- data/brutrb.com/recipes/blank-layouts.md +0 -22
@@ -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
|
-
|
4
|
-
|
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.
|
data/lib/brut/front_end/page.rb
CHANGED
data/lib/brut/version.rb
CHANGED
data/mkbrut/Gemfile.lock
CHANGED
@@ -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
|
-
|
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:
|
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.
|
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
|
-
|