tzispa_helpers 0.1.7 → 0.1.8

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: 32211499a790019a60889b90bbca7806179aee31
4
- data.tar.gz: a82a4c432cf25627717cf2b82ab02079cdee4ba5
3
+ metadata.gz: 7246f7e42a315b2700166638e8c0d32a19ea825a
4
+ data.tar.gz: 98267d92dbd04420d0b26bce1970be58828cd860
5
5
  SHA512:
6
- metadata.gz: a84211773676e7c739192daee01b7ed8f5a89ed14d2b8c7b0dbfa3427d1a07c3342a299d5f9a1c40799c2726fde724da144b2d9f585f67c08ba8e72cf90a8af9
7
- data.tar.gz: 8b82804b2c1f1423af02f278d82dc065422efce51d11248ce5fdeca997b45217a59bd8288b7e24c15545594d7813aa4d735924616e958235b64e552ff2b97257
6
+ metadata.gz: c1e3e29f99766414cf726c14cd94944d7fa054f4c41046b91606c443d0afaf7c3d27b2d868142f9c842bf7e4c49bff2ab00b5ce1b9e98797524b41e462c1ff81
7
+ data.tar.gz: f5e3f0109818213be35a1122b4dc559ff3ebe5f20a23a084fe1ccd83a0d3f558b527ffd62b2a3b8bd55abe0c6b173d010ee512edb9e498905b57b583bb920a16
data/CHANGELOG.md CHANGED
@@ -1,5 +1,8 @@
1
1
  Tzispa Helpers
2
2
 
3
+ ## v0.1.8
4
+ - Add error_view module
5
+
3
6
  ## v0.1.7
4
7
  - Fix error in mime_formatter text/x-markdown when text is nil
5
8
 
@@ -0,0 +1,46 @@
1
+ require 'tzispa/rig/template'
2
+
3
+
4
+ module Tzispa
5
+ module Helpers
6
+ module ErrorView
7
+
8
+ def error_report(error=nil)
9
+ text = String.new('<!DOCTYPE html>')
10
+ text << '<html lang="es"><head>'
11
+ text << '<meta charset="utf-8" />'
12
+ text << '<style> html {background:#cccccc; font-family:Arial; font-size:15px; color:#555;} body {width:75%; max-width:1200px; margin:18px auto; background:#fff; border-radius:6px; padding:32px 24px;} ul{list-style:none; margin:0; padding:0;} li{font-style:italic; color:#666;} h1 {color:#2ECC71;} </style>'
13
+ text << '</head><body>'
14
+ text << "<h5>#{Tzispa::FRAMEWORK_NAME} #{Tzispa::VERSION}</h5>\n"
15
+ if error
16
+ text << "<h1>#{error.class.name}</h1><h3>#{error.message}</h1>\n"
17
+ text << '<ol>' + error.backtrace.map { |trace| "<li>#{trace}</li>\n" }.join + '</ol>' if error.respond_to?(:backtrace) && error.backtrace
18
+ else
19
+ text << "<h1>Error 500</h1>\n"
20
+ text << "Se ha producido un error inesperado al tramitar la petición"
21
+ end
22
+ text << '</body></html>'
23
+ end
24
+
25
+ def error_page(status, domain)
26
+ begin
27
+ error_file = "#{domain.path}/error/#{status}.htm"
28
+ Tzispa::Rig::File.new(error_file).load!.content
29
+ rescue
30
+ text = String.new('<!DOCTYPE html>')
31
+ text << '<html lang="es"><head>'
32
+ text << '<meta charset="utf-8" />'
33
+ text << '<style> html {background:#cccccc; font-family:Arial; font-size:15px; color:#555;} body {width:75%; max-width:1200px; margin:18px auto; background:#fff; border-radius:6px; padding:32px 24px;} #main {margin:auto; } h1 {color:#2ECC71; font-size:4em; text-align:center;} </style>'
34
+ text << '</head><body>'
35
+ text << '<div id="main">'
36
+ text << "<h5>#{Tzispa::FRAMEWORK_NAME} #{Tzispa::VERSION}</h5>\n"
37
+ text << "<h1>Error #{status}</h1>\n"
38
+ text << '</div>'
39
+ text << '</body></html>'
40
+ end
41
+ end
42
+
43
+
44
+ end
45
+ end
46
+ end
@@ -3,7 +3,7 @@
3
3
  module Tzispa
4
4
  module Helpers
5
5
 
6
- VERSION = '0.1.7'
6
+ VERSION = '0.1.8'
7
7
  NAME = 'Tzispa Helpers'
8
8
  GEM_NAME = 'tzispa_helpers'
9
9
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tzispa_helpers
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.7
4
+ version: 0.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Juan Antonio Piñero
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-05-13 00:00:00.000000000 Z
11
+ date: 2016-05-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mail
@@ -105,6 +105,7 @@ files:
105
105
  - README.md
106
106
  - lib/tzispa/helpers.rb
107
107
  - lib/tzispa/helpers/crawler.rb
108
+ - lib/tzispa/helpers/error_view.rb
108
109
  - lib/tzispa/helpers/hash_trans.rb
109
110
  - lib/tzispa/helpers/html.rb
110
111
  - lib/tzispa/helpers/mail.rb