utopia 0.9.32 → 0.9.33

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.
@@ -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/head", "lib", "pages", "public"]
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 &amp; Documentation</a></p>
6
+ <p><a href="http://www.oriontransfer.co.nz/software/utopia/setup">Utopia Project Page &amp; Documentation</a></p>
7
7
  </page>
@@ -8,23 +8,43 @@ require 'RMagick'
8
8
  require 'fileutils'
9
9
 
10
10
  class Utopia::Tags::Gallery
11
- PROCESSES = {
12
- :photo_thumbnail => lambda do |img|
11
+ module Processes
12
+ def self.pdf_thumbnail(img)
13
13
  img = img.resize_to_fit(300, 300)
14
14
 
15
- shadow = img.flop
16
- shadow = shadow.colorize(1, 1, 1, "gray50")
17
- shadow.background_color = "white"
18
- shadow.border!(10, 10, "white")
19
- shadow = shadow.blur_image(0, 5)
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
- :thumbnail => lambda do |img|
24
+ end
25
+
26
+ def self.photo_thumbnail(img)
24
27
  img = img.resize_to_fit(300, 300)
25
- end,
26
- :large => lambda{|img| img.resize_to_fit(768, 768)}
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
- # def basename
44
- # @original_path.basename
45
- # end
46
-
47
- def self.append_suffix(name, suffix)
48
- name.split(".").insert(-2, suffix).join(".")
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] ||= /(\.jpg|\.png)$/
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
- processed_image = PROCESSES[process.to_sym].call(image)
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|
@@ -6,7 +6,7 @@ module Utopia
6
6
  module VERSION
7
7
  MAJOR = 0
8
8
  MINOR = 9
9
- TINY = 32
9
+ TINY = 33
10
10
 
11
11
  STRING = [MAJOR, MINOR, TINY].join('.')
12
12
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 9
8
- - 32
9
- version: 0.9.32
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-05-19 00:00:00 +12:00
17
+ date: 2010-06-22 00:00:00 +12:00
18
18
  default_executable: utopia
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency