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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b93d02d3f49a69d9e37ab7f4e118c4bf34af0b6ed814f7d899e1a0494cd1d8cd
4
- data.tar.gz: 1854abfd403c674693f86d3a2d81c8221d996066e2203428617c0c6945f72475
3
+ metadata.gz: 7626abe88327e4f0878ec7263f7fd1d3df5bef105f9c32a7658292ec8e436561
4
+ data.tar.gz: 0cd4fa7b7ca5275b2651f28b11e9d16dd51a152b69df59d97e58e1c40cde6374
5
5
  SHA512:
6
- metadata.gz: c3304a43924d7820192ecb3f380c2a2618b3787b1fb29c974477cf07b843f567b35a5f74e4e68cf43ac12f0213411f135380ee088355fb46b4c773afac10c989
7
- data.tar.gz: a01eb23a236b0c9088fe0bc6e571713e6ea0bf76bebd7295ea252805742c5ea5dad5d686db99ae07e0a833b23bc1060b504495196fabae333bd3f4d32cd9b43c
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,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
- $& # keep numeric footnotes as-is
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
@@ -1,3 +1,3 @@
1
1
  module MarkdownServer
2
- VERSION = "0.3.8"
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.8
4
+ version: 0.3.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Dunn