bookbindery 8.2.0 → 8.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fcd1dc76ec62824fab802bbb5e08808386ef14c7
4
- data.tar.gz: 8ff5324ec2299c32efb456ce6790bfc4e01f0b60
3
+ metadata.gz: 2b7c77c16ecbf1d55827b7eb99216d34de01ad9c
4
+ data.tar.gz: 2fbb5773c5a707b30e32773bc35fda5a337bd26a
5
5
  SHA512:
6
- metadata.gz: b48e8514aa4342a99e7c1baf6e4bd63db7c853b6a98a5ee7023c20e0bb25c8fdccf4ed7b7b3d91362972cb1f9e0faa2e6489fbc3003df285bbf8237b58f7a30d
7
- data.tar.gz: 2be9a7261db512afdf22020be057ceaae5b5395567e8c2f613a6342fc9eefd5d6ea33dae69549c02b194ddc5ab191848ac4d2ea4b5207eaabbf25aef0029c741
6
+ metadata.gz: 3c039454dac27d8cca438a0e4ec0019b0fe44ad4b5a0ac70f78af69970ccc6141ca0ef20ecd548c7a653139023cf2a5d2cb473e5adaf613d711d0910febeabe6
7
+ data.tar.gz: 3c25f9ab6cf73376322b9df8f13b1b680c91e2937e3796fc0175f34e6954b3011c37a0b6c384db32b588579844c055f753ca911f8374d3290e548a8ae004273b
data/bookbinder.gemspec CHANGED
@@ -2,10 +2,10 @@ require 'base64'
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = 'bookbindery'
5
- s.version = '8.2.0'
5
+ s.version = '8.3.0'
6
6
  s.summary = 'Markdown to Rackup application documentation generator'
7
7
  s.description = 'A command line utility to be run in Book repositories to stitch together their constituent Markdown repos into a static-HTML-serving application'
8
- s.authors = ['Mike Grafton', 'Lucas Marks', 'Gavin Morgan', 'Nikhil Gajwani', 'Dan Wendorf', 'Brenda Chan', 'Matthew Boedicker', 'Frank Kotsianas', 'Elena Sharma', 'Christa Hartsock', 'Michael Trestman']
8
+ s.authors = ['Mike Grafton', 'Lucas Marks', 'Gavin Morgan', 'Nikhil Gajwani', 'Dan Wendorf', 'Brenda Chan', 'Matthew Boedicker', 'Andrew Bruce', 'Frank Kotsianas', 'Elena Sharma', 'Christa Hartsock', 'Michael Trestman', 'Alpha Chen', 'Sarah McAlear', 'Gregg Van Hove']
9
9
  s.email = Base64.decode64('Z21vcmdhbkBnb3Bpdm90YWwuY29t') # Gavin's
10
10
 
11
11
  s.files = Dir['lib/**/*'] + Dir['template_app/**/*'] + Dir['master_middleman/**/*'] + Dir['install_bin/**/*'] + Dir['bookbinder.gemspec']
data/template_app/Gemfile CHANGED
@@ -2,7 +2,7 @@ source 'http://rubygems.org'
2
2
 
3
3
  ruby '2.3.0'
4
4
 
5
- gem 'vienna'
5
+ gem 'rack'
6
6
  gem 'rack-rewrite'
7
7
  gem 'therubyracer'
8
8
  gem 'sendgrid-ruby'
@@ -0,0 +1,19 @@
1
+ require 'rack'
2
+
3
+ module Bookbinder
4
+ class RackStaticIfExists < Rack::Static
5
+ def can_serve(path)
6
+ file_exists?(path) || dir_with_index_exists?(path)
7
+ end
8
+
9
+ private
10
+
11
+ def file_exists?(path)
12
+ File.file?(File.join(@file_server.root, path))
13
+ end
14
+
15
+ def dir_with_index_exists?(path)
16
+ File.directory?(File.join(@file_server.root, path)) && !!@index && file_exists?(File.join(path, @index))
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,52 @@
1
+ require_relative './rack_static_if_exists'
2
+
3
+ module Bookbinder
4
+ class Server
5
+ class << self
6
+ def call(env)
7
+ Bookbinder::Server.new.call(env)
8
+ end
9
+ end
10
+
11
+ def initialize
12
+ @app = Rack::Builder.new do
13
+ use RackStaticIfExists, {
14
+ urls: [''],
15
+ root: 'public',
16
+ index: 'index.html',
17
+ header_rules: [[:all, {
18
+ 'Cache-Control' => 'public, max-age=3600',
19
+ 'Access-Control-Allow-Origin' => '*'
20
+ }]]
21
+ }
22
+ run Bookbinder::NotFound.new("public/404.html")
23
+ end
24
+ end
25
+
26
+ def call(env)
27
+ if env['PATH_INFO'] == '' || env['PATH_INFO'] =~ MATCH
28
+ env['PATH_INFO'] += '/'
29
+ [301, {'Location' => Rack::Request.new(env).url, 'Content-Type' => ''}, []]
30
+ else
31
+ @app.call(env)
32
+ end
33
+ end
34
+
35
+ private
36
+ # regexp to match strings without periods that start but don't end with a slash
37
+ MATCH = %r{^/([^.]+)[^/]$}
38
+ end
39
+
40
+ class NotFound
41
+ def initialize(path = '')
42
+ @path = path
43
+ end
44
+
45
+ def call(env)
46
+ content = File.exist?(@path) ? File.read(@path) : 'Not Found'
47
+ length = content.length.to_s
48
+
49
+ [404, {'Content-Type' => 'text/html', 'Content-Length' => length}, [content]]
50
+ end
51
+ end
52
+ end
@@ -1,6 +1,6 @@
1
1
  require 'rack'
2
2
  require 'rack/rewrite'
3
- require_relative './lib/vienna_application'
3
+ require_relative './lib/server'
4
4
 
5
5
  module Bookbinder
6
6
  class RackApp
@@ -14,12 +14,20 @@ module Bookbinder
14
14
  path = redirect_pathname
15
15
  client = mail_client
16
16
  auth = auth_required
17
- Rack::Builder.new(Vienna) do
17
+ Rack::Builder.new do
18
18
  use ResolveRedirects, path
19
19
  use AuthorizeUser, auth
20
20
  map '/api/feedback' do
21
21
  use MailFeedback, client
22
- run Vienna::NotFound.new('public/404.html')
22
+ run Bookbinder::NotFound.new('public/404.html')
23
+ end
24
+ if ENV['CUSTOM_ROOT']
25
+ map ENV['CUSTOM_ROOT'] do
26
+ run Bookbinder::Server
27
+ end
28
+ run Bookbinder::NotFound.new('public/404.html')
29
+ else
30
+ run Bookbinder::Server
23
31
  end
24
32
  end
25
33
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bookbindery
3
3
  version: !ruby/object:Gem::Version
4
- version: 8.2.0
4
+ version: 8.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Grafton
@@ -11,14 +11,18 @@ authors:
11
11
  - Dan Wendorf
12
12
  - Brenda Chan
13
13
  - Matthew Boedicker
14
+ - Andrew Bruce
14
15
  - Frank Kotsianas
15
16
  - Elena Sharma
16
17
  - Christa Hartsock
17
18
  - Michael Trestman
19
+ - Alpha Chen
20
+ - Sarah McAlear
21
+ - Gregg Van Hove
18
22
  autorequire:
19
23
  bindir: install_bin
20
24
  cert_chain: []
21
- date: 2016-03-21 00:00:00.000000000 Z
25
+ date: 2016-04-04 00:00:00.000000000 Z
22
26
  dependencies:
23
27
  - !ruby/object:Gem::Dependency
24
28
  name: fog-aws
@@ -434,8 +438,8 @@ files:
434
438
  - template_app/Gemfile
435
439
  - template_app/Gemfile.lock
436
440
  - template_app/config.ru
437
- - template_app/lib/rack_static.rb
438
- - template_app/lib/vienna_application.rb
441
+ - template_app/lib/rack_static_if_exists.rb
442
+ - template_app/lib/server.rb
439
443
  - template_app/mail_sender.rb
440
444
  - template_app/rack_app.rb
441
445
  homepage: https://github.com/pivotal-cf/bookbinder
@@ -1,23 +0,0 @@
1
- require 'rack'
2
-
3
- module Bookbinder
4
- class RackStatic < Rack::Static
5
- def route_file(path)
6
- @urls.kind_of?(Array) && @urls.any? { |url| url.index(path) == 0 }
7
- end
8
-
9
- def overwrite_file_path(path)
10
- path_has_trailing_slash?(path) && we_can_serve_index_at_path?(path)
11
- end
12
-
13
- private
14
-
15
- def path_has_trailing_slash?(path)
16
- !((path =~ /\/$/).nil?)
17
- end
18
-
19
- def we_can_serve_index_at_path?(path)
20
- @index && File.exists?(File.join @file_server.root, path, @index)
21
- end
22
- end
23
- end
@@ -1,54 +0,0 @@
1
- require_relative './rack_static'
2
-
3
- module Bookbinder
4
- module Vienna
5
- class << self
6
- def call(env)
7
- Application.new.call(env)
8
- end
9
- end
10
-
11
- class Application
12
- def initialize(root = 'public')
13
- @app = Rack::Builder.new do
14
- use RackStatic, {
15
- urls: Dir.glob("#{root}/**/*").map { |fn| fn.gsub(/^#{root}/, '')},
16
- root: root,
17
- index: 'index.html',
18
- header_rules: [[:all, {
19
- 'Cache-Control' => 'public, max-age=3600',
20
- 'Access-Control-Allow-Origin' => '*'
21
- }]]
22
- }
23
- run NotFound.new("#{root}/404.html")
24
- end
25
- end
26
-
27
- def call(env)
28
- if env['PATH_INFO'] != '/' && env['PATH_INFO'] =~ MATCH
29
- env['PATH_INFO'] += '/'
30
- [301, {'Location' => Rack::Request.new(env).url, 'Content-Type' => ''}, []]
31
- else
32
- @app.call(env)
33
- end
34
- end
35
-
36
- private
37
- # regexp to match strings without periods that start and end with a slash
38
- MATCH = %r{^/([^.]*)[^/]$}
39
- end
40
-
41
- class NotFound
42
- def initialize(path = '')
43
- @path = path
44
- end
45
-
46
- def call(env)
47
- content = File.exist?(@path) ? File.read(@path) : 'Not Found'
48
- length = content.length.to_s
49
-
50
- [404, {'Content-Type' => 'text/html', 'Content-Length' => length}, [content]]
51
- end
52
- end
53
- end
54
- end