static_errors 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +55 -0
- data/lib/static_errors.rb +3 -0
- data/lib/static_errors/railtie.rb +10 -0
- data/lib/static_errors/tasks/static_errors.rb +38 -0
- metadata +61 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 366b74b0021aac86c4a4ecde8e580f50b927007d
|
4
|
+
data.tar.gz: 33a48b256aa1285b5f78dda53b6211b23915b5f2
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: f4da41c54d7169ffff20eb62c05fb6b076532ecc7cb62d635531cfb487adb3a9c795de4663509b0fc0a183606c9e2e7a7152e672a1d7ecc031de3d91a2ede074
|
7
|
+
data.tar.gz: 6d02934eefe496f267386fdc6c4c92c7123de3fa8c7bea080baed35d79af3d80101260ba97a10944ae6e54333dabb9c3c1fa5f3fd371c6272b327084dd0eb609
|
data/README.md
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
# Overview
|
2
|
+
|
3
|
+
StaticErrors is a gem to help with the creation of static error pages. It allows you to
|
4
|
+
use a dynamically generated page as a template, so all of your default styling and layouts
|
5
|
+
can be used to design the error page. This dynamic page is then saved for static rendering.
|
6
|
+
|
7
|
+
# Syntax
|
8
|
+
|
9
|
+
rake static_errors <options: option=value,value2>
|
10
|
+
|
11
|
+
| Options | Use | Default |
|
12
|
+
| --- | --- | --- |
|
13
|
+
| path | Changes the dynamic error root url | http://localhost:3000/errors/ |
|
14
|
+
| languages | Any additional languages to save | <none> |
|
15
|
+
| errors | Which errors to save | <none> |
|
16
|
+
| destination | Where to save the static error pages | public/ |
|
17
|
+
|
18
|
+
|
19
|
+
# Use Cases
|
20
|
+
|
21
|
+
## 1: Basic Operations
|
22
|
+
|
23
|
+
rake static_errors errors=404
|
24
|
+
|
25
|
+
Saving http://localhost:3000/errors/404 to public/404.html
|
26
|
+
|
27
|
+
|
28
|
+
## 2: Multiple Errors
|
29
|
+
|
30
|
+
rake static_errors errors=422,500
|
31
|
+
|
32
|
+
Saving http://localhost:3000/errors/422 to public/422.html
|
33
|
+
Saving http://localhost:3000/errors/500 to public/500.html
|
34
|
+
|
35
|
+
|
36
|
+
## 3: Multiple Languages
|
37
|
+
|
38
|
+
rake static_errors errors=422 languages=en-GB,de
|
39
|
+
|
40
|
+
Saving http://localhost:3000/errors/422 to public/422.html
|
41
|
+
Saving http://localhost:3000/errors/422?locale=en-GB to public/422.en-GB.html
|
42
|
+
Saving http://localhost:3000/errors/422?locale=de to public/422.de.html
|
43
|
+
|
44
|
+
|
45
|
+
## 4: Custom URL / Filepaths
|
46
|
+
|
47
|
+
rake static_errors errors=422 path=http://mytestserver/special_errors/ destination=public/local/errors/
|
48
|
+
|
49
|
+
Saving http://mytestserver/special_errors/422 to public/local/errors/422.html
|
50
|
+
|
51
|
+
|
52
|
+
# Final Considerations
|
53
|
+
|
54
|
+
You may wish to check the urls of any externally referenced files needed to render your
|
55
|
+
error pages. ex: Should jquery/bootstrap/etc be at the same url for your static errors?
|
@@ -0,0 +1,38 @@
|
|
1
|
+
def save(source, dest)
|
2
|
+
puts "Saving #{source} to #{dest}"
|
3
|
+
|
4
|
+
a = Mechanize.new
|
5
|
+
a.get(source) do |page|
|
6
|
+
File.delete(dest) if File.exist?(dest)
|
7
|
+
page.save dest
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
task :static_errors => :environment do
|
12
|
+
@path = 'http://localhost:3000/errors/'
|
13
|
+
@languages = ''
|
14
|
+
@errors = ''
|
15
|
+
@destination = "public/"
|
16
|
+
|
17
|
+
@path = ENV["path"] if ENV["path"]
|
18
|
+
@languages = ENV["languages"] if ENV["languages"]
|
19
|
+
@errors = ENV["errors"] if ENV["errors"]
|
20
|
+
@destination = ENV["destination"] if ENV["destination"]
|
21
|
+
|
22
|
+
=begin
|
23
|
+
puts "Path: #{@path}"
|
24
|
+
puts "Languages #{@languages}"
|
25
|
+
puts "Errors #{@errors}"
|
26
|
+
puts "Destination #{@destination}"
|
27
|
+
=end
|
28
|
+
|
29
|
+
languages = @languages.split(',')
|
30
|
+
errors = @errors.split(',')
|
31
|
+
|
32
|
+
errors.each do |error|
|
33
|
+
save("#{@path}#{error}", "#{@destination}#{error}.html")
|
34
|
+
languages.each do |language|
|
35
|
+
save("#{@path}#{error}?locale=#{language}", "#{@destination}#{error}.#{language}.html")
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
metadata
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: static_errors
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- shogarth
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-01-05 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: mechanize
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
description: Saves dynamic pages as a static error file
|
28
|
+
email: shogarth@shogarth.com
|
29
|
+
executables: []
|
30
|
+
extensions: []
|
31
|
+
extra_rdoc_files: []
|
32
|
+
files:
|
33
|
+
- README.md
|
34
|
+
- lib/static_errors.rb
|
35
|
+
- lib/static_errors/railtie.rb
|
36
|
+
- lib/static_errors/tasks/static_errors.rb
|
37
|
+
homepage: http://shogarth.com
|
38
|
+
licenses:
|
39
|
+
- Copyright 2014 - All Rights Reserved
|
40
|
+
metadata: {}
|
41
|
+
post_install_message:
|
42
|
+
rdoc_options: []
|
43
|
+
require_paths:
|
44
|
+
- lib
|
45
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - '>='
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: '0'
|
50
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
requirements: []
|
56
|
+
rubyforge_project:
|
57
|
+
rubygems_version: 2.0.0.rc.2
|
58
|
+
signing_key:
|
59
|
+
specification_version: 4
|
60
|
+
summary: Static Errors
|
61
|
+
test_files: []
|