utopia 0.9.32 → 0.9.33
Sign up to get free protection for your applications and to get access to all the features.
@@ -111,6 +111,11 @@ module Utopia
|
|
111
111
|
headers['Content-Type'] ||= options[:type]
|
112
112
|
end
|
113
113
|
|
114
|
+
if options[:redirect]
|
115
|
+
headers["Location"] = options[:redirect]
|
116
|
+
status = 302 if status < 300 || status >= 400
|
117
|
+
end
|
118
|
+
|
114
119
|
body = []
|
115
120
|
if options[:body]
|
116
121
|
body = options[:body]
|
@@ -120,11 +125,6 @@ module Utopia
|
|
120
125
|
body = [Utopia::HTTP_STATUS_DESCRIPTIONS[status] || 'Status #{status}']
|
121
126
|
end
|
122
127
|
|
123
|
-
if options[:redirect]
|
124
|
-
headers["Location"] = options[:redirect]
|
125
|
-
status = 302 if status < 300 || status >= 400
|
126
|
-
end
|
127
|
-
|
128
128
|
# Utopia::LOG.debug([status, headers, body].inspect)
|
129
129
|
return [status, headers, body]
|
130
130
|
end
|
@@ -16,6 +16,8 @@ module Utopia
|
|
16
16
|
|
17
17
|
@error_path = error_path
|
18
18
|
@error_status = error_status
|
19
|
+
|
20
|
+
@log = Logger.new($stderr)
|
19
21
|
end
|
20
22
|
|
21
23
|
def to_s
|
@@ -53,6 +55,12 @@ module Utopia
|
|
53
55
|
begin
|
54
56
|
return @app.call(env)
|
55
57
|
rescue Exception => ex
|
58
|
+
@log.error "Exception #{ex.to_s.dump}!"
|
59
|
+
|
60
|
+
ex.backtrace.each do |bt|
|
61
|
+
@log.error bt
|
62
|
+
end
|
63
|
+
|
56
64
|
if env['PATH_INFO'] == @location
|
57
65
|
return fatal_error(env, ex)
|
58
66
|
else
|
data/lib/utopia/setup.rb
CHANGED
@@ -7,7 +7,7 @@ require 'rake'
|
|
7
7
|
module Utopia
|
8
8
|
module Setup
|
9
9
|
ROOT = File.join(File.dirname(__FILE__), "setup", "")
|
10
|
-
DIRECTORIES = ["access_log", "cache", "cache/meta", "cache/
|
10
|
+
DIRECTORIES = ["access_log", "cache", "cache/meta", "cache/body", "lib", "pages", "public"]
|
11
11
|
|
12
12
|
def self.copy(to, config = {})
|
13
13
|
$stderr.puts "Copying files from #{ROOT} to #{to}..."
|
@@ -3,5 +3,5 @@
|
|
3
3
|
|
4
4
|
<p>Utopia is designed to simply your life. It is not an application development framework. It is not a content management system. It does not require a database. It isn't model view controller. It is simply a platform on which websites can be easily developed with a minimum of effort.</p>
|
5
5
|
|
6
|
-
<p><a href="http://www.oriontransfer.co.nz/utopia/setup">Utopia Project Page & Documentation</a></p>
|
6
|
+
<p><a href="http://www.oriontransfer.co.nz/software/utopia/setup">Utopia Project Page & Documentation</a></p>
|
7
7
|
</page>
|
data/lib/utopia/tags/gallery.rb
CHANGED
@@ -8,23 +8,43 @@ require 'RMagick'
|
|
8
8
|
require 'fileutils'
|
9
9
|
|
10
10
|
class Utopia::Tags::Gallery
|
11
|
-
|
12
|
-
|
11
|
+
module Processes
|
12
|
+
def self.pdf_thumbnail(img)
|
13
13
|
img = img.resize_to_fit(300, 300)
|
14
14
|
|
15
|
-
shadow = img.
|
16
|
-
|
17
|
-
shadow
|
18
|
-
shadow.
|
19
|
-
shadow
|
15
|
+
shadow = img.dup
|
16
|
+
|
17
|
+
shadow = shadow.colorize(1, 1, 1, 'gray50')
|
18
|
+
shadow.background_color = 'transparent'
|
19
|
+
shadow.border!(10, 10, 'transparent')
|
20
|
+
|
21
|
+
shadow = shadow.gaussian_blur_channel(5, 5, Magick::AlphaChannel)
|
20
22
|
|
21
23
|
shadow.composite(img, 5, 5, Magick::OverCompositeOp)
|
22
|
-
end
|
23
|
-
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.photo_thumbnail(img)
|
24
27
|
img = img.resize_to_fit(300, 300)
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
+
|
29
|
+
shadow = img.dup
|
30
|
+
|
31
|
+
shadow = shadow.colorize(1, 1, 1, '#999999ff')
|
32
|
+
shadow.background_color = 'transparent'
|
33
|
+
shadow.border!(10, 10, '#99999900')
|
34
|
+
|
35
|
+
shadow = shadow.gaussian_blur_channel(5, 5, Magick::AlphaChannel)
|
36
|
+
|
37
|
+
shadow.composite(img, 5, 5, Magick::OverCompositeOp)
|
38
|
+
end
|
39
|
+
|
40
|
+
def self.thumbnail(img)
|
41
|
+
img = img.resize_to_fit(300, 300)
|
42
|
+
end
|
43
|
+
|
44
|
+
def self.large(img)
|
45
|
+
img.resize_to_fit(768, 768)
|
46
|
+
end
|
47
|
+
end
|
28
48
|
|
29
49
|
CACHE_DIR = "_cache"
|
30
50
|
|
@@ -32,26 +52,33 @@ class Utopia::Tags::Gallery
|
|
32
52
|
def initialize(original_path)
|
33
53
|
@original_path = original_path
|
34
54
|
@cache_root = @original_path.dirname + CACHE_DIR
|
55
|
+
|
56
|
+
@extensions = {}
|
35
57
|
end
|
36
58
|
|
37
59
|
attr :cache_root
|
60
|
+
attr :extensions
|
38
61
|
|
39
62
|
def original
|
40
63
|
@original_path
|
41
64
|
end
|
42
65
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
66
|
+
def self.append_suffix(name, suffix, extension = nil)
|
67
|
+
components = name.split(".")
|
68
|
+
|
69
|
+
components.insert(-2, suffix)
|
70
|
+
|
71
|
+
if (extension)
|
72
|
+
components[-1] = extension
|
73
|
+
end
|
74
|
+
|
75
|
+
return components.join(".")
|
49
76
|
end
|
50
77
|
|
51
78
|
def processed(process = nil)
|
52
79
|
if process
|
53
80
|
name = @original_path.basename
|
54
|
-
return cache_root + ImagePath.append_suffix(name, process.to_s)
|
81
|
+
return cache_root + ImagePath.append_suffix(name, process.to_s, @extensions[process.to_sym])
|
55
82
|
else
|
56
83
|
return @original_path
|
57
84
|
end
|
@@ -86,7 +113,7 @@ class Utopia::Tags::Gallery
|
|
86
113
|
end
|
87
114
|
|
88
115
|
def images(options = {})
|
89
|
-
options[:filter] ||= /(
|
116
|
+
options[:filter] ||= /(jpg|png)$/
|
90
117
|
|
91
118
|
paths = []
|
92
119
|
local_path = @node.local_path(@path)
|
@@ -120,16 +147,20 @@ class Utopia::Tags::Gallery
|
|
120
147
|
local_original_path = @node.local_path(image_path.original)
|
121
148
|
|
122
149
|
if processes.kind_of? String
|
123
|
-
processes = processes.split(",")
|
150
|
+
processes = processes.split(",").collect{|p| p.split(":")}
|
124
151
|
end
|
125
152
|
|
126
|
-
processes.each do |process|
|
153
|
+
processes.each do |process, extension|
|
154
|
+
process = process.to_sym
|
155
|
+
image_path.extensions[process] = extension if extension
|
156
|
+
|
127
157
|
local_processed_path = @node.local_path(image_path.processed(process))
|
128
158
|
|
129
159
|
unless File.exists? local_processed_path
|
130
160
|
image = Magick::ImageList.new(local_original_path)
|
131
|
-
|
132
|
-
|
161
|
+
image.scene = 0
|
162
|
+
|
163
|
+
processed_image = Processes.send(process, image)
|
133
164
|
processed_image.write(local_processed_path)
|
134
165
|
end
|
135
166
|
end
|
@@ -144,7 +175,8 @@ class Utopia::Tags::Gallery
|
|
144
175
|
|
145
176
|
options = {}
|
146
177
|
options[:process] = state["process"]
|
147
|
-
|
178
|
+
options[:filter] = Regexp.new("(#{state["filetypes"]})$") if state["filetypes"]
|
179
|
+
|
148
180
|
filter = Regexp.new(state["filter"]) if state["filter"]
|
149
181
|
|
150
182
|
transaction.tag("div", "class" => "gallery") do |node|
|
data/lib/utopia/version.rb
CHANGED
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 9
|
8
|
-
-
|
9
|
-
version: 0.9.
|
8
|
+
- 33
|
9
|
+
version: 0.9.33
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Samuel Williams
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-
|
17
|
+
date: 2010-06-22 00:00:00 +12:00
|
18
18
|
default_executable: utopia
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|