smallvictories 0.0.16 → 0.0.17
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/smallvictories/server.rb +27 -24
- data/lib/smallvictories/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: a012abc5e4e26ee5e48bf0577689ace065e6de1e
|
|
4
|
+
data.tar.gz: 0f68a60487282ac4c6c9a11be0c017ef3549149b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 5590c7692d2bc9ac0975fa412eabf7283faf01cf990d05e52ae28ecacb2e5e8635151a64bc35ef93ed8e03c40c3b491988dd58a3b397b557693dd841cb22c320
|
|
7
|
+
data.tar.gz: 1f546b231f4a53fe1804490d34087e7d564d51474508ab217c8dfc36f840f47ab7c5a12da3987a8c3a6409b2eec247d9aac2d85542a3e56fd66e79f17de9811b
|
|
@@ -115,37 +115,40 @@ module SmallVictories
|
|
|
115
115
|
loop do
|
|
116
116
|
@socket = @server.accept
|
|
117
117
|
request_line = socket.gets
|
|
118
|
-
socket.close if request_line == nil
|
|
119
118
|
|
|
120
119
|
STDERR.puts request_line
|
|
121
120
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
File.
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
121
|
+
begin
|
|
122
|
+
path = requested_file(request_line)
|
|
123
|
+
path = File.join(path, 'index.html') if File.directory?(path)
|
|
124
|
+
|
|
125
|
+
if path == File.join(WEB_ROOT, '_sv_custom.css')
|
|
126
|
+
render_stylesheet
|
|
127
|
+
elsif File.exist?(path) && !File.directory?(path)
|
|
128
|
+
File.open(path, "rb") do |file|
|
|
129
|
+
if File.extname(path) == '.html'
|
|
130
|
+
# parse liquid
|
|
131
|
+
template = Liquid::Template.parse(file.read, error_mode: :warn)
|
|
132
|
+
render_string(template.render(SiteFile.files_hash))
|
|
133
|
+
else
|
|
134
|
+
render_file(file)
|
|
135
|
+
end
|
|
135
136
|
end
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
message = "File not found\n"
|
|
137
|
+
else
|
|
138
|
+
message = "File not found\n"
|
|
139
139
|
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
140
|
+
# respond with a 404 error code to indicate the file does not exist
|
|
141
|
+
socket.print "HTTP/1.1 404 Not Found\r\n" +
|
|
142
|
+
"Content-Type: text/plain\r\n" +
|
|
143
|
+
"Content-Length: #{message.size}\r\n" +
|
|
144
|
+
"Connection: close\r\n"
|
|
145
145
|
|
|
146
|
-
|
|
146
|
+
socket.print "\r\n"
|
|
147
147
|
|
|
148
|
-
|
|
148
|
+
socket.print message
|
|
149
|
+
end
|
|
150
|
+
rescue => e
|
|
151
|
+
socket.print "\r\n"
|
|
149
152
|
end
|
|
150
153
|
|
|
151
154
|
socket.close
|