static_error_pages 0.1.0 → 0.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: edd5ae7a438aa70c6f805c8f76c79417c9c9d2c247d55427b8b86282a7851138
4
- data.tar.gz: 4262cb87418728eb0e64d9c8b7c552c2bda6d4f9873d26dfed8f6cbae4d4c7c7
3
+ metadata.gz: 801b1c433409f78a0f2a8890ea564936bb63324114562d1f9b72dd28edcad882
4
+ data.tar.gz: 14a71821948bcfc2a314f47539edf2a1c1db56a96ad56ed2bc0b2fe12156c02c
5
5
  SHA512:
6
- metadata.gz: 5def53668dea2221670c6cd0f10dfced127c5f1b8ecf17ed4eabf05bcdeaa8f5058d44c9e79adc64928a593af3b21e151cae398e1262e952d110cb44c02004ae
7
- data.tar.gz: 9c61b36c8682410bfa859d97016527bfa32f2d659007b7610c6ba702bc88ed7891f213c698c1237194d80b5ebec0261a62f5c3cd920a2887c04a34c60de714da
6
+ metadata.gz: 834d09a85d154ae6886bd96960858277cc3cdc3096c591fa64e375cd31543d28548fc5405cbf41770cfb3b6089b96841f8612a04809ef1e8b253d38db22659d4
7
+ data.tar.gz: 38da88f2a8d86df047e3cc24d1f277105c51e2f44d960e94f3a685f5aad35327571a08baf2c8014ab82519ac696b14efe0f22196472bb3c81dd7a62315028009
data/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # StaticErrorPages
2
2
 
3
+ [![Gem Version](https://badge.fury.io/rb/static_error_pages.svg)](https://badge.fury.io/rb/static_error_pages)
4
+
3
5
  Quick'n Dirty static error pages generator for Rails
4
6
 
5
7
  - Relies on ``ApplicationController.renderer`` to generate 404.html, 500.html, 503.html, 422.html during deploy
@@ -13,3 +15,26 @@ bundle exec rails g static_error_pages:copy
13
15
 
14
16
  Afterwards, adjust the files in ``app/views/error_pages/*``, especially the layout file and include a minimalistic CSS for the error page.
15
17
 
18
+ ## Developing error pages
19
+
20
+ Currently, run the rake task after every change: ``rails assets:error_pages`` and it will generate all files into public/*
21
+
22
+ ## Config
23
+
24
+ Rails initializer / application.rb / environments:
25
+
26
+ ```ruby
27
+ ## add oder change list of files
28
+ Rails.application.config.static_error_pages.pages = ["404.html", "500.html", "503.html", "422.html"]
29
+
30
+
31
+ ## default layout file = error_pages/layout
32
+ Rails.application.config.static_error_pages = "../error_pages/layout"
33
+ ```
34
+
35
+ ## Webpacker
36
+
37
+ If you naively link the javascript/stylesheet pack tag, they might end of empty. Depending on your setup, you can try:
38
+
39
+ - 1. activate `` extract_css: true`` in ``config/webpacker.yml``
40
+ - 2. use the ``inline_pack_tag`` helper function to fully inline css/js webpack packs
@@ -0,0 +1,11 @@
1
+ module ErrorPagesHelper
2
+ def inline_pack_tag(asset)
3
+ file_path = 'public' + asset_pack_path(asset)
4
+ content = File.read(file_path)
5
+ if asset.include?('.js')
6
+ "<script type='text/javascript'>#{content}</script>".html_safe
7
+ else
8
+ "<style type='text/css'>#{content}</style>".html_safe
9
+ end
10
+ end
11
+ end
@@ -1,2 +1,2 @@
1
- h1 Nicht gefunden
1
+ h1 = @title = "Nicht gefunden"
2
2
  p Diese Seite wurde leider nicht gefunden.
@@ -5,10 +5,16 @@ html lang='de'
5
5
  meta[name="viewport" content="width=device-width, initial-scale=1.0"]
6
6
  meta(name="robots" content="noindex")
7
7
  == stylesheet_link_tag "application", media: 'all'
8
+ / if you are using Webpacker maybe you can try:
9
+ / - if Rails.env.production?
10
+ / = inline_pack_tag 'public.css'
11
+ / - else
12
+ / = javascript_packs_with_chunks_tag 'public'
13
+ / = stylesheet_packs_with_chunks_tag 'public' rescue ""
8
14
  title
9
15
  = @title
10
16
  = ' '
11
- |&ndash; Empfehlungsbund.de
17
+ |&ndash;
12
18
  //link rel="shortcut icon" href=image_path('favicons/icon.ico')
13
19
  body
14
20
  main(style='min-height: 60vh')
@@ -6,5 +6,8 @@ module StaticErrorPages
6
6
  config.static_error_pages = ActiveSupport::OrderedOptions.new
7
7
  config.static_error_pages.pages = %w(404.html 500.html 503.html 422.html)
8
8
  config.static_error_pages.layout = '../error_pages/layout'
9
+ config.to_prepare do
10
+ ApplicationController.helper(ErrorPagesHelper)
11
+ end
9
12
  end
10
13
  end
@@ -1,3 +1,3 @@
1
1
  module StaticErrorPages
2
- VERSION = '0.1.0'
2
+ VERSION = '0.2.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: static_error_pages
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stefan Wienert
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-06-25 00:00:00.000000000 Z
11
+ date: 2020-08-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -35,6 +35,7 @@ files:
35
35
  - MIT-LICENSE
36
36
  - README.md
37
37
  - Rakefile
38
+ - app/helpers/error_pages_helper.rb
38
39
  - app/views/error_pages/404.html.slim
39
40
  - app/views/error_pages/422.html.slim
40
41
  - app/views/error_pages/500.html.slim
@@ -45,7 +46,7 @@ files:
45
46
  - lib/static_error_pages/railtie.rb
46
47
  - lib/static_error_pages/version.rb
47
48
  - lib/tasks/static_error_pages_tasks.rake
48
- homepage: ''
49
+ homepage: https://github.com/pludoni/rails-static_error_pages
49
50
  licenses:
50
51
  - MIT
51
52
  metadata: {}