snails 0.3.8 → 0.4.0

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
  SHA256:
3
- metadata.gz: 56629b5fd4fe17181f87006b22a87919aab9dd8bfb9783b96ca526944dc5f72b
4
- data.tar.gz: d6b6ed7db6c9a37020cadfeef8781b9c7ff8f795249b88a2899302fbe508bfb6
3
+ metadata.gz: 6f9dc7b09b85e7614ba0360b3df7668ed828013d9e23f774dee4b928d21f9b97
4
+ data.tar.gz: 49ebbbaf8f15bc38da0bc0cff9f862e3a4f28e5f46b83e80c0cf45c4078429f7
5
5
  SHA512:
6
- metadata.gz: ab2bc8d6450137f1e4561aeb281360f246dc9a651558fb6b10f3046e0f0a2367bcb6f96d2179e2c32bc0b46f47e982d8a060fb46b8bc8d22be7f5eb3af816302
7
- data.tar.gz: 7492326e5866d34e9524b545807ff3bd1ecf20976a529eb9815b4a0e520566b5e85bd77beb991dde0282c825aba3f81d27a6903b07aff201116902a5b4f4a81a
6
+ metadata.gz: 052555354beb82ac3abdca759b9c7cafbe526e7d05820d47d5503f810af1c580212d1ce21ce2fd8419dc46876283177062caf7f4ae2eaeabfa326de31af9ca39
7
+ data.tar.gz: 0e2002deff4953ff17be75918130b7f9bf267d16c3c710f5f139596d457417292842c0927d871f7706f29c8f199fa303c2f1053e3e9d30fbb56275b4dc28bd96
@@ -353,6 +353,14 @@ module Snails
353
353
  erb(view_name.to_sym, { layout: layout }.merge(opts))
354
354
  end
355
355
 
356
+ def show_date(date)
357
+ date ? date.strftime("%d de %b, %Y") : ''
358
+ end
359
+
360
+ def show_time(time)
361
+ time ? time.strftime("%d de %b, %Y a las %H:%M") : ''
362
+ end
363
+
356
364
  #########################################
357
365
  # pagination
358
366
 
@@ -0,0 +1,53 @@
1
+ begin
2
+ require 'rinku'
3
+ require 'kramdown'
4
+ require 'sanitize'
5
+
6
+ module Snails
7
+ module Markdown
8
+
9
+ MARKDOWN_OPTS = {
10
+ input: 'GFM',
11
+ enable_coderay: true,
12
+ parse_block_html: false,
13
+ line_width: 72,
14
+ coderay_tab_width: 2,
15
+ coderay_line_numbers: nil,
16
+ coderay_default_lang: 'bash',
17
+ coderay_css: :class
18
+ }
19
+
20
+ SANITIZE_OPTS = Sanitize::Config::RELAXED
21
+
22
+ SANITIZE_OPTS[:elements] = %w(
23
+ p br a span sub sup strong em div hr abbr
24
+ ul ol li
25
+ blockquote pre code kbd
26
+ h1 h2 h3 h4 h5 h6
27
+ img object param del
28
+ )
29
+
30
+ SANITIZE_OPTS[:attributes] = {
31
+ :all => ['class', 'style', 'title', 'id'],
32
+ 'a' => ['href', 'rel', 'name'],
33
+ 'img' => ['src', 'title', 'alt', 'width', 'height']
34
+ }
35
+
36
+ SANITIZE_OPTS[:add_attributes] = { 'a' => {'rel' => 'nofollow', 'target' => '_blank'} }
37
+
38
+ def render_markdown(str, options = {})
39
+ html = Kramdown::Document.new(str, MARKDOWN_OPTS).to_html
40
+ html = Rinku.auto_link(html, :urls)
41
+ Sanitize.clean(html, SANITIZE_OPTS)
42
+ end
43
+
44
+ end
45
+
46
+ end
47
+
48
+ rescue LoadError => e
49
+ puts "Cannot load Snails's markdown lib. (#{e.class})"
50
+ puts "You need the `kramdown`, `rinku` and `sanitize` gems for this."
51
+ end
52
+
53
+
@@ -3,7 +3,7 @@
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "snails"
6
- s.version = '0.3.8'
6
+ s.version = '0.4.0'
7
7
  s.platform = Gem::Platform::RUBY
8
8
  s.authors = ['Tomás Pollak']
9
9
  s.email = ['tomas@forkhq.com']
@@ -17,6 +17,7 @@ Gem::Specification.new do |s|
17
17
  s.add_development_dependency "fuubar", '>= 2.3.2'
18
18
 
19
19
  s.add_runtime_dependency "i18n", ">= 1.0.1"
20
+ s.add_runtime_dependency "activerecord", "< 6.0"
20
21
  s.add_runtime_dependency "sinatra-contrib", ">= 2.0.3"
21
22
  s.add_runtime_dependency "sinatra-activerecord", ">= 2.0.13"
22
23
  s.add_runtime_dependency "sinatra-flash", ">= 0.3.0"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: snails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.8
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tomás Pollak
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-08-22 00:00:00.000000000 Z
11
+ date: 2019-08-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -72,6 +72,20 @@ dependencies:
72
72
  - - ">="
73
73
  - !ruby/object:Gem::Version
74
74
  version: 1.0.1
75
+ - !ruby/object:Gem::Dependency
76
+ name: activerecord
77
+ requirement: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - "<"
80
+ - !ruby/object:Gem::Version
81
+ version: '6.0'
82
+ type: :runtime
83
+ prerelease: false
84
+ version_requirements: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - "<"
87
+ - !ruby/object:Gem::Version
88
+ version: '6.0'
75
89
  - !ruby/object:Gem::Dependency
76
90
  name: sinatra-contrib
77
91
  requirement: !ruby/object:Gem::Requirement
@@ -159,6 +173,7 @@ files:
159
173
  - lib/snails.rb
160
174
  - lib/snails/app.rb
161
175
  - lib/snails/mailer.rb
176
+ - lib/snails/markdown.rb
162
177
  - lib/snails/rspec.rb
163
178
  - lib/snails/tasks.rb
164
179
  - lib/snails/util.rb