markdownr 0.3.8 → 0.3.9
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/bin/markdownr +5 -0
- data/lib/markdown_server/app.rb +14 -2
- data/lib/markdown_server/version.rb +1 -1
- 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: 7626abe88327e4f0878ec7263f7fd1d3df5bef105f9c32a7658292ec8e436561
|
|
4
|
+
data.tar.gz: 0cd4fa7b7ca5275b2651f28b11e9d16dd51a152b69df59d97e58e1c40cde6374
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: fdc6af6ff990a63e2aeb99eb0c37bf562849915e7406f313009f6a057665a5e601fe6b22c4241d28143b0a1b0bf60c2b849cfbc5b874f3158ea2a2cd82d02b6b
|
|
7
|
+
data.tar.gz: cda8888fdf35ac9e80042b6063579f02d8b0243adb4493b543ca63a9e55da6e9c58b33460789c0d68e71006e6dc95b4218a3ac6c48642238da4e90f2fe8b36b5
|
data/bin/markdownr
CHANGED
|
@@ -19,6 +19,10 @@ OptionParser.new do |opts|
|
|
|
19
19
|
options[:title] = t
|
|
20
20
|
end
|
|
21
21
|
|
|
22
|
+
opts.on("--allow-robots", "Allow search engine crawling (default: disallowed)") do
|
|
23
|
+
options[:allow_robots] = true
|
|
24
|
+
end
|
|
25
|
+
|
|
22
26
|
opts.on("-v", "--version", "Show version") do
|
|
23
27
|
puts "markdownr #{MarkdownServer::VERSION}"
|
|
24
28
|
exit
|
|
@@ -35,6 +39,7 @@ end
|
|
|
35
39
|
|
|
36
40
|
MarkdownServer::App.set :root_dir, dir
|
|
37
41
|
MarkdownServer::App.set :custom_title, options[:title]
|
|
42
|
+
MarkdownServer::App.set :allow_robots, options[:allow_robots] || false
|
|
38
43
|
MarkdownServer::App.set :port, options[:port]
|
|
39
44
|
MarkdownServer::App.set :bind, options[:bind]
|
|
40
45
|
|
data/lib/markdown_server/app.rb
CHANGED
|
@@ -18,6 +18,7 @@ module MarkdownServer
|
|
|
18
18
|
configure do
|
|
19
19
|
set :root_dir, Dir.pwd
|
|
20
20
|
set :custom_title, nil
|
|
21
|
+
set :allow_robots, false
|
|
21
22
|
set :show_exceptions, false
|
|
22
23
|
set :protection, false
|
|
23
24
|
set :host_authorization, { permitted_hosts: [] }
|
|
@@ -154,17 +155,19 @@ module MarkdownServer
|
|
|
154
155
|
# Restore non-numeric footnote labels: Kramdown converts all footnote
|
|
155
156
|
# references to sequential numbers, but we want [^abc] to display "abc".
|
|
156
157
|
html = html.gsub(%r{<sup id="fnref:([^"]+)"[^>]*>\s*<a href="#fn:\1"[^>]*>\d+</a>\s*</sup>}m) do
|
|
158
|
+
full_match = $&
|
|
157
159
|
name = $1
|
|
158
160
|
if name =~ /\A\d+\z/
|
|
159
|
-
|
|
161
|
+
full_match
|
|
160
162
|
else
|
|
161
163
|
%(<sup id="fnref:#{name}" role="doc-noteref"><a href="#fn:#{name}" class="footnote" rel="footnote">#{h(name)}</a></sup>)
|
|
162
164
|
end
|
|
163
165
|
end
|
|
164
166
|
html.gsub(%r{<li id="fn:([^"]+)"[^>]*>\s*<p>}m) do
|
|
167
|
+
full_match = $&
|
|
165
168
|
name = $1
|
|
166
169
|
if name =~ /\A\d+\z/
|
|
167
|
-
|
|
170
|
+
full_match
|
|
168
171
|
else
|
|
169
172
|
%(<li id="fn:#{name}"><p><strong>#{h(name)}:</strong> )
|
|
170
173
|
end
|
|
@@ -431,6 +434,15 @@ module MarkdownServer
|
|
|
431
434
|
|
|
432
435
|
# Routes
|
|
433
436
|
|
|
437
|
+
get "/robots.txt" do
|
|
438
|
+
content_type "text/plain"
|
|
439
|
+
if settings.allow_robots
|
|
440
|
+
"User-agent: *\nDisallow:"
|
|
441
|
+
else
|
|
442
|
+
"User-agent: *\nDisallow: /"
|
|
443
|
+
end
|
|
444
|
+
end
|
|
445
|
+
|
|
434
446
|
get "/" do
|
|
435
447
|
redirect "/browse/"
|
|
436
448
|
end
|