safai 0.0.13 → 0.0.14
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/safai.rb +49 -0
- metadata +49 -1
data/lib/safai.rb
CHANGED
@@ -64,6 +64,54 @@ class Safai
|
|
64
64
|
|
65
65
|
#======================================
|
66
66
|
|
67
|
+
module WikiHelpers
|
68
|
+
|
69
|
+
def process_html_links(text)
|
70
|
+
url_re = %r{
|
71
|
+
(<[^>]+\s+\w+="?)?
|
72
|
+
(
|
73
|
+
(?:https?://)? # optional protocol
|
74
|
+
(?:[-\w]+\.)+ # subdomain/domain parts
|
75
|
+
(?:com|net|org|edu|gov|biz|int|mil|info|name|museum|coop|aero|[a-z][a-z]) # TLD
|
76
|
+
(?::\d+)? # Optional port
|
77
|
+
(?:/(?:(?:[~\w\+@%=-]|(?:[,.;:][^\s$]))+)?)* # Path
|
78
|
+
(?:\?[\w\+@%&=.;-]+)? # Query String ?foo=bar
|
79
|
+
(?:\#[\w\-]*)? # Anchor
|
80
|
+
)
|
81
|
+
}xi
|
82
|
+
|
83
|
+
# wrap links for html
|
84
|
+
text.gsub! url_re do
|
85
|
+
if $1.present?
|
86
|
+
$&
|
87
|
+
else
|
88
|
+
url = $2
|
89
|
+
unless url =~ /:\/\//
|
90
|
+
url = "http://" + url
|
91
|
+
end
|
92
|
+
"<a href=\"#{url}\">#{url}</a>"
|
93
|
+
end
|
94
|
+
end
|
95
|
+
text.gsub(/<a\s/, '<a target=\"_blank\" ')
|
96
|
+
end
|
97
|
+
|
98
|
+
def coderay(text)
|
99
|
+
text.gsub(/\<code( lang="(.+?)")?\>(.+?)\<\/code\>/m) do
|
100
|
+
content_tag("notextile", CodeRay.scan($3, $2).div(:css => :class))
|
101
|
+
end
|
102
|
+
|
103
|
+
def markdown(text)
|
104
|
+
text = sanitize(text, :tags => %w(object param embed))
|
105
|
+
text.gsub!(/<script.*>.*<\/script>/, '')
|
106
|
+
if defined? RDiscount
|
107
|
+
process_html_links RDiscount.new(text, :smart).to_html.gsub(/\n+/, "<br/>")
|
108
|
+
else
|
109
|
+
simple_format(process_html_links(text))
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
end
|
114
|
+
|
67
115
|
module DeviseHelpers
|
68
116
|
|
69
117
|
def resource_name
|
@@ -115,6 +163,7 @@ class Safai
|
|
115
163
|
end
|
116
164
|
|
117
165
|
require 'money'
|
166
|
+
include HTMLDiff
|
118
167
|
require 'roo'
|
119
168
|
require 'safai/spreadsheet'
|
120
169
|
require 'safai/address'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: safai
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.14
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -27,6 +27,38 @@ dependencies:
|
|
27
27
|
- - '='
|
28
28
|
- !ruby/object:Gem::Version
|
29
29
|
version: 0.2.13
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: htmldiff
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - '='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: 0.0.1
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - '='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 0.0.1
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: coderay
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - '='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: 1.0.8
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - '='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 1.0.8
|
30
62
|
- !ruby/object:Gem::Dependency
|
31
63
|
name: roo
|
32
64
|
requirement: !ruby/object:Gem::Requirement
|
@@ -43,6 +75,22 @@ dependencies:
|
|
43
75
|
- - '='
|
44
76
|
- !ruby/object:Gem::Version
|
45
77
|
version: 1.10.1
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: RedCloth
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - '='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: 4.2.9
|
86
|
+
type: :development
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - '='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: 4.2.9
|
46
94
|
description: A simple hello world gem
|
47
95
|
email: ritvij.j@gmail.com
|
48
96
|
executables: []
|