hydeweb 0.1.10 → 0.1.11
Sign up to get free protection for your applications and to get access to all the features.
- data/HISTORY.md +7 -0
- data/data/new_site/config.ru +6 -1
- data/data/new_site/hyde.conf +2 -2
- data/lib/hyde/cli.rb +1 -8
- data/lib/hyde/server.rb +8 -11
- data/lib/hyde.rb +1 -1
- data/test/unit/page_test.rb +0 -7
- metadata +1 -1
data/HISTORY.md
CHANGED
data/data/new_site/config.ru
CHANGED
@@ -4,6 +4,11 @@
|
|
4
4
|
require 'hyde'
|
5
5
|
require 'hyde/server'
|
6
6
|
|
7
|
+
begin
|
8
|
+
# Add the 'rack-cache' gem if you want to enable caching.
|
9
|
+
require 'rack/cache'
|
10
|
+
use Rack::Cache
|
11
|
+
end
|
12
|
+
|
7
13
|
Hyde::Project.new File.dirname(__FILE__)
|
8
|
-
Hyde::Server.options[:cache] = true
|
9
14
|
run Hyde::Server
|
data/data/new_site/hyde.conf
CHANGED
@@ -9,7 +9,7 @@ output_path: _output
|
|
9
9
|
# Other paths:
|
10
10
|
layouts_path: _layouts
|
11
11
|
extensions_path: _extensions
|
12
|
-
partials_path:
|
12
|
+
partials_path: .
|
13
13
|
|
14
14
|
# Files to be excluded from processing
|
15
15
|
ignore:
|
@@ -17,7 +17,7 @@ ignore:
|
|
17
17
|
- README*
|
18
18
|
- config.ru
|
19
19
|
- **/.*
|
20
|
-
- **/_
|
20
|
+
- **/_*
|
21
21
|
|
22
22
|
# Optional options for layout engines
|
23
23
|
tilt_options:
|
data/lib/hyde/cli.rb
CHANGED
@@ -68,13 +68,9 @@ class CLI < Shake
|
|
68
68
|
port = (params.extract('-p') || 4833).to_i
|
69
69
|
host = (params.extract('-o') || '0.0.0.0')
|
70
70
|
daemon = (!! params.delete('-D'))
|
71
|
-
cache = (!! params.delete('--cache'))
|
72
71
|
|
73
72
|
require 'hyde/server'
|
74
73
|
|
75
|
-
# No caching whatsoever.
|
76
|
-
Hyde::Server.options[:cache] = cache
|
77
|
-
|
78
74
|
if daemon
|
79
75
|
pid = fork { Hyde::Server.run! :Host => host, :Port => port, :quiet => true }
|
80
76
|
sleep 2
|
@@ -91,16 +87,13 @@ class CLI < Shake
|
|
91
87
|
task.help = %{
|
92
88
|
Usage:
|
93
89
|
|
94
|
-
#{executable} start [-p PORT] [-o HOST] [
|
90
|
+
#{executable} start [-p PORT] [-o HOST] [-D]
|
95
91
|
|
96
92
|
Starts an HTTP server so you may rapidly test your project locally.
|
97
93
|
|
98
94
|
If the -p and/or -o is specified, it will listen on the specified HOST:PORT.
|
99
95
|
Otherwise, the default is 0.0.0.0:4833.
|
100
96
|
|
101
|
-
Hyde doesn't send cache instructions, ensuring that every page load is fresh.
|
102
|
-
You can use --cache to override this behavior.
|
103
|
-
|
104
97
|
If -D is specified, it goes into daemon mode.
|
105
98
|
}.gsub(/^ {4}/, '').strip.split("\n")
|
106
99
|
|
data/lib/hyde/server.rb
CHANGED
@@ -48,16 +48,17 @@ class Hyde
|
|
48
48
|
begin
|
49
49
|
page = Hyde::Page[env['PATH_INFO']] or break not_found
|
50
50
|
|
51
|
-
|
52
|
-
|
53
|
-
res['Cache-Control'] = 'max-age=86400, public'
|
54
|
-
else
|
55
|
-
res['Cache-Control'] = 'no-cache'
|
56
|
-
end
|
51
|
+
# Make the clients use If-Modified-Since
|
52
|
+
res['Cache-Control'] = 'max-age=86400, public, must-revalidate'
|
57
53
|
|
54
|
+
mtime = [server.options[:last_modified], File.mtime(page.file)].compact.max
|
55
|
+
res['Last-Modified'] = mtime.to_s if mtime
|
56
|
+
|
57
|
+
# Get the MIME type from Hyde, then fallback to Rack
|
58
58
|
type = mime_type_for(page)
|
59
59
|
res['Content-Type'] = type if type
|
60
60
|
|
61
|
+
# Okay, we're done
|
61
62
|
res.write page.to_html
|
62
63
|
show_status page
|
63
64
|
rescue => e
|
@@ -71,13 +72,9 @@ end
|
|
71
72
|
|
72
73
|
module Hyde::Server
|
73
74
|
# Available options:
|
74
|
-
#
|
75
|
+
# :last_modified -- timestamp for all files
|
75
76
|
def self.options
|
76
77
|
@options ||= Hash.new
|
77
|
-
if @options.empty?
|
78
|
-
@options[:cache] = true
|
79
|
-
end
|
80
|
-
@options
|
81
78
|
end
|
82
79
|
|
83
80
|
# :Host, :Port
|
data/lib/hyde.rb
CHANGED
data/test/unit/page_test.rb
CHANGED
@@ -41,15 +41,8 @@ class PageTest < TestCase
|
|
41
41
|
assert_equal 'text/html', Page['/about/us.html'].mime_type
|
42
42
|
assert_equal 'html', Page['/about/us.html'].default_ext
|
43
43
|
assert_equal 'css', Page['/css/style.css'].default_ext
|
44
|
-
|
45
|
-
assert_equal 'image/jpeg', Page['/images/foo.jpg'].mime_type
|
46
44
|
end
|
47
45
|
|
48
|
-
test "ext" do
|
49
|
-
assert_equal '.html', Page['/'].ext
|
50
|
-
assert_equal '.jpg', Page['/images/foo.jpg'].ext
|
51
|
-
end
|
52
|
-
|
53
46
|
test "no layout" do
|
54
47
|
page = Page['/hi.html']
|
55
48
|
assert_equal false, page.meta.layout
|