lunox 0.1.0 → 1.0.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 +4 -4
- data/lib/lunox.rb +21 -30
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e82e4b7461f3b680683ed7448513b9e9421f774c8cba9add908b247f6e488e2c
|
|
4
|
+
data.tar.gz: 823d72bf6de3b1e8562fbde642841cdabdf2380224e17a1c8e9277ff60ec1f3d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: bd48f00ecc357281f17996678bc0e65f23e8e0eb080d35c6b9254fc025009101427dd56ca9455270ee27d4012529cbd736ffd6dfd3a525c39f2d9c21be74e056
|
|
7
|
+
data.tar.gz: 7bb6963dd71d2a1fd7df279bc664064cdd2097a79e9440ec0e682f15bc5498c7001ba151b1c8f5565e6c06cbb11803e0e2e15c722cab6080a353405d7cd0f137
|
data/lib/lunox.rb
CHANGED
|
@@ -1,33 +1,24 @@
|
|
|
1
|
-
require '
|
|
2
|
-
class CreateHTML
|
|
3
|
-
def create_html(content, bypass_html, file_name: 'index.html')
|
|
4
|
-
markup = content.gsub!(/[<>]/, '') if bypass_html == false
|
|
5
|
-
markup = content unless bypass_html == false
|
|
6
|
-
html = <<~HTML
|
|
7
|
-
<!doctype html>
|
|
8
|
-
<html lang="en">
|
|
9
|
-
<head>
|
|
10
|
-
<meta charset="UTF-8">
|
|
11
|
-
<title>#{file_name}</title>
|
|
12
|
-
</head>
|
|
13
|
-
<body>
|
|
14
|
-
#{markup}
|
|
15
|
-
</body>
|
|
16
|
-
</html>
|
|
17
|
-
HTML
|
|
18
|
-
File.write(file_name, html)
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
def update_html(content, file_name: 'index.html')
|
|
22
|
-
doc = File.open(file_name) { |f| Nokogiri::HTML(f) }
|
|
23
|
-
doc.at('body') << content
|
|
24
|
-
|
|
25
|
-
file = File.open(file_name, 'w+')
|
|
26
|
-
file.puts doc
|
|
27
|
-
file.close
|
|
28
|
-
end
|
|
1
|
+
require 'sanitize'
|
|
29
2
|
|
|
30
|
-
|
|
31
|
-
|
|
3
|
+
class Lunox
|
|
4
|
+
def self.save(body, file_name: 'index.html', bypass_html: false)
|
|
5
|
+
body = Sanitize.fragment(body) unless bypass_html
|
|
6
|
+
File.open(file_name, 'w+') do |f|
|
|
7
|
+
html = <<~HTML
|
|
8
|
+
<!doctype html>
|
|
9
|
+
<html lang="en">
|
|
10
|
+
<head>
|
|
11
|
+
<meta charset="UTF-8">
|
|
12
|
+
<title>#{file_name}</title>
|
|
13
|
+
</head>
|
|
14
|
+
<body>
|
|
15
|
+
<div class="info">
|
|
16
|
+
#{body}
|
|
17
|
+
</div>
|
|
18
|
+
</body>
|
|
19
|
+
</html>
|
|
20
|
+
HTML
|
|
21
|
+
f.write(html)
|
|
22
|
+
end
|
|
32
23
|
end
|
|
33
24
|
end
|