flutterby 0.0.6 → 0.0.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.
- checksums.yaml +4 -4
- data/lib/flutterby/file.rb +13 -1
- data/lib/flutterby/server.rb +29 -19
- data/lib/flutterby/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 257ac8a84ea41487bbf327f0e7a925f2ec8f3f5c
|
4
|
+
data.tar.gz: 93dfaeda969555a8197f38d794502f3cd7116926
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5053ceb42b1769afe1e3a4755141bcb7944dc56f44d4ca587623e77c91b759362d9c499c23ecad0b621d8d5facc1c80e9c33e29df8005ac74594ca7971004fac
|
7
|
+
data.tar.gz: d9abe432d2f653ded73dec6b2140e7ca8a718632c81b25b16ba34300d6e66fe902d2a5ec9aa1c22912f55860bfbbe49df3be8c42e99e9042df0fda87b0c54796
|
data/lib/flutterby/file.rb
CHANGED
@@ -66,7 +66,19 @@ module Flutterby
|
|
66
66
|
end
|
67
67
|
|
68
68
|
def view
|
69
|
-
@view ||=
|
69
|
+
@view ||= begin
|
70
|
+
View.new(self).tap do |view|
|
71
|
+
# load additional view code
|
72
|
+
if view_entity = sibling("_view.rb")
|
73
|
+
case view_entity.ext
|
74
|
+
when "rb" then
|
75
|
+
view.instance_eval(view_entity.contents)
|
76
|
+
else
|
77
|
+
raise "Unknown view extension #{view_entity.full_name}"
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
70
82
|
end
|
71
83
|
|
72
84
|
def process_erb(input)
|
data/lib/flutterby/server.rb
CHANGED
@@ -40,29 +40,39 @@ module Flutterby
|
|
40
40
|
|
41
41
|
current = @root
|
42
42
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
43
|
+
result = catch :halt do
|
44
|
+
loop do
|
45
|
+
# halt if we're not supposed to serve current entity
|
46
|
+
throw :halt, :error_404 unless current.should_publish?
|
47
|
+
|
48
|
+
case current
|
49
|
+
when Flutterby::Folder then
|
50
|
+
# If no further parts are requested, let's look for an index
|
51
|
+
# document and serve that instead.
|
52
|
+
if child = current.find(parts.empty? ? "index" : parts.shift)
|
53
|
+
current = child
|
54
|
+
else
|
55
|
+
throw :halt, :error_404
|
56
|
+
end
|
57
|
+
when Flutterby::File then
|
58
|
+
# Determine MIME type
|
59
|
+
mime_type = MIME::Types.type_for(current.ext) || "text/plain"
|
58
60
|
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
61
|
+
# Build response
|
62
|
+
res.headers["Content-Type"] = mime_type
|
63
|
+
res.body = [current.render]
|
64
|
+
throw :halt
|
65
|
+
end
|
63
66
|
end
|
64
67
|
end
|
65
68
|
|
69
|
+
case result
|
70
|
+
when :error_404 then
|
71
|
+
res.status = 404
|
72
|
+
res.headers["Content-Type"] = "text/html"
|
73
|
+
res.body = ["404"]
|
74
|
+
end
|
75
|
+
|
66
76
|
res
|
67
77
|
end
|
68
78
|
end
|
data/lib/flutterby/version.rb
CHANGED