utopia 0.9.38 → 0.9.39
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/utopia/middleware/filter.rb +41 -0
- data/lib/utopia/middleware/static.rb +2 -1
- data/lib/utopia/version.rb +1 -1
- metadata +5 -4
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# This file is part of the "Utopia Framework" project, and is licensed under the GNU AGPLv3.
|
|
2
|
+
# Copyright 2010 Samuel Williams. All rights reserved.
|
|
3
|
+
# See <utopia.rb> for licensing details.
|
|
4
|
+
require 'utopia/middleware'
|
|
5
|
+
require 'utopia/path'
|
|
6
|
+
|
|
7
|
+
require 'time'
|
|
8
|
+
|
|
9
|
+
require 'digest/sha1'
|
|
10
|
+
require 'mime/types'
|
|
11
|
+
|
|
12
|
+
module Utopia
|
|
13
|
+
module Middleware
|
|
14
|
+
|
|
15
|
+
# This class filters a incoming request and only executes a given block if it matches the given filter path.
|
|
16
|
+
class Filter
|
|
17
|
+
def initialize(app, filter, &block)
|
|
18
|
+
@app = app
|
|
19
|
+
@filter = filter
|
|
20
|
+
branch = Rack::Builder.new(&block)
|
|
21
|
+
branch.run(@app)
|
|
22
|
+
@process = branch.to_app
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def applicable(request)
|
|
26
|
+
return request.path.index(@filter) != nil
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def call(env)
|
|
30
|
+
request = Rack::Request.new(env)
|
|
31
|
+
|
|
32
|
+
if applicable(request)
|
|
33
|
+
@process.call(env)
|
|
34
|
+
else
|
|
35
|
+
@app.call(env)
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
end
|
|
41
|
+
end
|
|
@@ -32,7 +32,8 @@ module Utopia
|
|
|
32
32
|
"html", "css", "js", "txt", "rtf", "xml", "pdf"
|
|
33
33
|
],
|
|
34
34
|
:archive => [
|
|
35
|
-
"zip", "tar", "tgz", "tar.gz", "tar.bz2", ["dmg", "application/x-apple-diskimage"]
|
|
35
|
+
"zip", "tar", "tgz", "tar.gz", "tar.bz2", ["dmg", "application/x-apple-diskimage"],
|
|
36
|
+
["torrent", "application/x-bittorrent"]
|
|
36
37
|
],
|
|
37
38
|
:images => [
|
|
38
39
|
"png", "gif", "jpeg", "tiff"
|
data/lib/utopia/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: utopia
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
hash:
|
|
4
|
+
hash: 117
|
|
5
5
|
prerelease: false
|
|
6
6
|
segments:
|
|
7
7
|
- 0
|
|
8
8
|
- 9
|
|
9
|
-
-
|
|
10
|
-
version: 0.9.
|
|
9
|
+
- 39
|
|
10
|
+
version: 0.9.39
|
|
11
11
|
platform: ruby
|
|
12
12
|
authors:
|
|
13
13
|
- Samuel Williams
|
|
@@ -15,7 +15,7 @@ autorequire:
|
|
|
15
15
|
bindir: bin
|
|
16
16
|
cert_chain: []
|
|
17
17
|
|
|
18
|
-
date: 2010-
|
|
18
|
+
date: 2010-10-22 00:00:00 +13:00
|
|
19
19
|
default_executable: utopia
|
|
20
20
|
dependencies:
|
|
21
21
|
- !ruby/object:Gem::Dependency
|
|
@@ -128,6 +128,7 @@ files:
|
|
|
128
128
|
- lib/utopia/middleware/content.rb
|
|
129
129
|
- lib/utopia/middleware/controller.rb
|
|
130
130
|
- lib/utopia/middleware/directory_index.rb
|
|
131
|
+
- lib/utopia/middleware/filter.rb
|
|
131
132
|
- lib/utopia/middleware/localization/name.rb
|
|
132
133
|
- lib/utopia/middleware/localization.rb
|
|
133
134
|
- lib/utopia/middleware/logger.rb
|