markdownr 0.3.7 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bc15590907558465b90d7d219e6bede5a9479141b0993843188a22a2723ab72a
4
- data.tar.gz: 34f073a1b9cf5c3a2550e61da3f1ffe9250bc4843fac344e140c1e0629a5f4a8
3
+ metadata.gz: 7626abe88327e4f0878ec7263f7fd1d3df5bef105f9c32a7658292ec8e436561
4
+ data.tar.gz: 0cd4fa7b7ca5275b2651f28b11e9d16dd51a152b69df59d97e58e1c40cde6374
5
5
  SHA512:
6
- metadata.gz: 19aad92e46d89d0cbec62ba172167a029a74794f6b1914cdc458d896eea4e25186852cf5f37c493e5459f680b922b19c3c7c44c0de71f6c528d8c18d37479b3f
7
- data.tar.gz: cb08bd3772391f5a0c742930953ac4982366c8657e89b802bc4b090ea476e3ec89e456fe255543622c0ab8e58b7191823d590cda143f7e37ba9b151bfec4e084
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
 
@@ -18,8 +18,10 @@ 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
24
+ set :host_authorization, { permitted_hosts: [] }
23
25
  end
24
26
 
25
27
  helpers do
@@ -153,17 +155,19 @@ module MarkdownServer
153
155
  # Restore non-numeric footnote labels: Kramdown converts all footnote
154
156
  # references to sequential numbers, but we want [^abc] to display "abc".
155
157
  html = html.gsub(%r{<sup id="fnref:([^"]+)"[^>]*>\s*<a href="#fn:\1"[^>]*>\d+</a>\s*</sup>}m) do
158
+ full_match = $&
156
159
  name = $1
157
160
  if name =~ /\A\d+\z/
158
- $& # keep numeric footnotes as-is
161
+ full_match
159
162
  else
160
163
  %(<sup id="fnref:#{name}" role="doc-noteref"><a href="#fn:#{name}" class="footnote" rel="footnote">#{h(name)}</a></sup>)
161
164
  end
162
165
  end
163
166
  html.gsub(%r{<li id="fn:([^"]+)"[^>]*>\s*<p>}m) do
167
+ full_match = $&
164
168
  name = $1
165
169
  if name =~ /\A\d+\z/
166
- $&
170
+ full_match
167
171
  else
168
172
  %(<li id="fn:#{name}"><p><strong>#{h(name)}:</strong> )
169
173
  end
@@ -430,6 +434,15 @@ module MarkdownServer
430
434
 
431
435
  # Routes
432
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
+
433
446
  get "/" do
434
447
  redirect "/browse/"
435
448
  end
@@ -1,3 +1,3 @@
1
1
  module MarkdownServer
2
- VERSION = "0.3.7"
2
+ VERSION = "0.3.9"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: markdownr
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.7
4
+ version: 0.3.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Dunn