benofsky-bolt 0.4.5 → 0.4.7
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.
- data/lib/bolt/base.rb +2 -2
- data/lib/bolt/serve.rb +10 -3
- metadata +6 -14
data/lib/bolt/base.rb
CHANGED
|
@@ -12,7 +12,7 @@ require 'ftools' if RUBY_VERSION.to_f <= 1.8
|
|
|
12
12
|
$BOLT_BASE = File.dirname(__FILE__) + "/../../"
|
|
13
13
|
|
|
14
14
|
module Bolt
|
|
15
|
-
class Base
|
|
15
|
+
class Base
|
|
16
16
|
def initialize
|
|
17
17
|
STDOUT.sync = true
|
|
18
18
|
end
|
|
@@ -45,7 +45,7 @@ module Bolt
|
|
|
45
45
|
options[:copy_from] ||= false
|
|
46
46
|
|
|
47
47
|
if options[:copy_from]
|
|
48
|
-
f =
|
|
48
|
+
f = FileUtils.copy(options[:copy_from], file)
|
|
49
49
|
else
|
|
50
50
|
f = File.new(file, options[:mode])
|
|
51
51
|
end
|
data/lib/bolt/serve.rb
CHANGED
|
@@ -45,6 +45,8 @@ module Bolt
|
|
|
45
45
|
end
|
|
46
46
|
end
|
|
47
47
|
|
|
48
|
+
class NotFound404 < Exception; end;
|
|
49
|
+
|
|
48
50
|
class Serve < Build
|
|
49
51
|
attr_accessor :pages
|
|
50
52
|
|
|
@@ -82,7 +84,11 @@ module Bolt
|
|
|
82
84
|
page_name = "index" if page_name == ""
|
|
83
85
|
page = @pages[page_name]
|
|
84
86
|
|
|
85
|
-
|
|
87
|
+
# Handle subdirectories
|
|
88
|
+
page = @pages[page_name + "index"] if page.nil?
|
|
89
|
+
page = @pages[page_name + "/index"] if page.nil?
|
|
90
|
+
|
|
91
|
+
if(!page.nil?)
|
|
86
92
|
# A tad hacky, otherwise @current_page isn't set properly and all hell breaks loose
|
|
87
93
|
body = PageBinding.new(page_name).instance_eval(&page)
|
|
88
94
|
@server.reply(body)
|
|
@@ -90,10 +96,11 @@ module Bolt
|
|
|
90
96
|
f = File.new(d($config.resources) + request['GET'])
|
|
91
97
|
@server.reply(f.to_s, 200, 'Content-Type' => f.content_type)
|
|
92
98
|
else
|
|
93
|
-
|
|
94
|
-
@server.reply(File.new(@errors_base + '404.html').to_s, 404)
|
|
99
|
+
raise NotFound404
|
|
95
100
|
end
|
|
96
101
|
end
|
|
102
|
+
rescue NotFound404
|
|
103
|
+
@server.reply(File.new(@errors_base + '404.html').to_s, 404)
|
|
97
104
|
rescue Exception => e
|
|
98
105
|
puts "Error: #{e}"
|
|
99
106
|
puts e.backtrace
|
metadata
CHANGED
|
@@ -1,12 +1,8 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: benofsky-bolt
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
prerelease:
|
|
5
|
-
|
|
6
|
-
- 0
|
|
7
|
-
- 4
|
|
8
|
-
- 5
|
|
9
|
-
version: 0.4.5
|
|
4
|
+
prerelease:
|
|
5
|
+
version: 0.4.7
|
|
10
6
|
platform: ruby
|
|
11
7
|
authors:
|
|
12
8
|
- Ben McRedmond
|
|
@@ -22,12 +18,10 @@ dependencies:
|
|
|
22
18
|
name: haml
|
|
23
19
|
prerelease: false
|
|
24
20
|
requirement: &id001 !ruby/object:Gem::Requirement
|
|
21
|
+
none: false
|
|
25
22
|
requirements:
|
|
26
23
|
- - ">="
|
|
27
24
|
- !ruby/object:Gem::Version
|
|
28
|
-
segments:
|
|
29
|
-
- 2
|
|
30
|
-
- 2
|
|
31
25
|
version: "2.2"
|
|
32
26
|
type: :runtime
|
|
33
27
|
version_requirements: *id001
|
|
@@ -66,23 +60,21 @@ rdoc_options: []
|
|
|
66
60
|
require_paths:
|
|
67
61
|
- lib
|
|
68
62
|
required_ruby_version: !ruby/object:Gem::Requirement
|
|
63
|
+
none: false
|
|
69
64
|
requirements:
|
|
70
65
|
- - ">="
|
|
71
66
|
- !ruby/object:Gem::Version
|
|
72
|
-
segments:
|
|
73
|
-
- 0
|
|
74
67
|
version: "0"
|
|
75
68
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
69
|
+
none: false
|
|
76
70
|
requirements:
|
|
77
71
|
- - ">="
|
|
78
72
|
- !ruby/object:Gem::Version
|
|
79
|
-
segments:
|
|
80
|
-
- 0
|
|
81
73
|
version: "0"
|
|
82
74
|
requirements: []
|
|
83
75
|
|
|
84
76
|
rubyforge_project:
|
|
85
|
-
rubygems_version: 1.
|
|
77
|
+
rubygems_version: 1.6.2
|
|
86
78
|
signing_key:
|
|
87
79
|
specification_version: 3
|
|
88
80
|
summary: Bolt is a simple static website generator with great support for dynamic content insertion.
|