markdownr 0.3.8 → 0.4.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/bin/markdownr +5 -0
- data/lib/markdown_server/app.rb +17 -4
- data/lib/markdown_server/version.rb +1 -1
- data/views/directory.erb +1 -0
- 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: 719c684f6ed25cb57662a6a78234695ef2fea07b1c4f301159a79e0383bd7426
|
|
4
|
+
data.tar.gz: 1c1b1fc19db8308c8e47479a45b3fea84bb797bfe22fb16e4b5e19c8387e8c0e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: fccc91e9f80f3848af6bb2bede88e65ebea736275189e2f7beb9db326c948d9c85c2000da77386acc71a424626a0f6b6e7115c9df1d2ff157956c56126706f58
|
|
7
|
+
data.tar.gz: 8d6c8c6cf5dbf13040ccc83e891548e20f2fc7f30f385b3e2ee19d8adfa56273dc385cad897d3e17e88cd2ab5fa02d08299e4b446d5c3e0b8134700841e34f99
|
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
|
|
@@ -520,9 +532,9 @@ module MarkdownServer
|
|
|
520
532
|
}
|
|
521
533
|
end.compact
|
|
522
534
|
|
|
523
|
-
@sort = %w[name mtime ctime].include?(params[:sort]) ? params[:sort] : "mtime"
|
|
535
|
+
@sort = %w[name mtime ctime size].include?(params[:sort]) ? params[:sort] : "mtime"
|
|
524
536
|
@order = %w[asc desc].include?(params[:order]) ? params[:order] : nil
|
|
525
|
-
# Default order: name=asc, times=desc
|
|
537
|
+
# Default order: name=asc, size=desc, times=desc
|
|
526
538
|
effective_order = @order || (@sort == "name" ? "asc" : "desc")
|
|
527
539
|
@order_display = effective_order
|
|
528
540
|
|
|
@@ -530,6 +542,7 @@ module MarkdownServer
|
|
|
530
542
|
sorted = case @sort
|
|
531
543
|
when "name" then list.sort_by { |i| i[:name].downcase }
|
|
532
544
|
when "ctime" then list.sort_by { |i| i[:ctime].to_f }
|
|
545
|
+
when "size" then list.sort_by { |i| i[:size] || -1 }
|
|
533
546
|
else list.sort_by { |i| i[:mtime].to_f }
|
|
534
547
|
end
|
|
535
548
|
effective_order == "desc" ? sorted.reverse : sorted
|
data/views/directory.erb
CHANGED