ramaze 2008.06 → 2008.11
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/README.markdown +6 -6
- data/Rakefile +33 -3
- data/bin/ramaze +18 -0
- data/doc/CHANGELOG +960 -0
- data/doc/LEGAL +5 -1
- data/doc/meta/announcement.txt +20 -36
- data/doc/tutorial/todolist.html +421 -313
- data/doc/tutorial/todolist.mkd +33 -16
- data/examples/app/blog/spec/blog.rb +3 -3
- data/examples/app/rapaste/controller/paste.rb +8 -1
- data/examples/app/rapaste/model/paste.rb +3 -0
- data/examples/app/rapaste/spec/rapaste.rb +3 -1
- data/examples/app/rapaste/start.rb +3 -2
- data/examples/app/sourceview/public/sourceview.js +2 -2
- data/examples/app/todolist/spec/todolist.rb +6 -6
- data/examples/app/todolist/template/index.xhtml +1 -1
- data/examples/app/whywiki/spec/whywiki.rb +2 -2
- data/examples/app/wikore/spec/wikore.rb +2 -2
- data/examples/app/wikore/src/model.rb +4 -3
- data/examples/app/wiktacular/spec/wiktacular.rb +7 -7
- data/examples/basic/simple.rb +2 -2
- data/examples/helpers/paginate.rb +71 -0
- data/examples/misc/simple_auth.rb +20 -8
- data/lib/proto/controller/init.rb +10 -0
- data/lib/proto/controller/main.rb +1 -3
- data/lib/proto/model/init.rb +4 -0
- data/lib/proto/public/dispatch.fcgi +1 -1
- data/lib/proto/spec/main.rb +2 -1
- data/lib/proto/start.rb +3 -3
- data/lib/proto/start.ru +1 -1
- data/lib/proto/view/error.xhtml +4 -4
- data/lib/ramaze.rb +8 -3
- data/lib/ramaze/action.rb +6 -6
- data/lib/ramaze/adapter.rb +1 -6
- data/lib/ramaze/adapter/base.rb +30 -27
- data/lib/ramaze/adapter/cgi.rb +1 -0
- data/lib/ramaze/cache.rb +1 -3
- data/lib/ramaze/cache/memcached.rb +3 -5
- data/lib/ramaze/contrib/auto_params.rb +2 -2
- data/lib/ramaze/contrib/auto_params/get_args.rb +2 -1
- data/lib/ramaze/contrib/gems.rb +17 -18
- data/lib/ramaze/contrib/gzip_filter.rb +22 -9
- data/lib/ramaze/contrib/maruku_uv.rb +59 -0
- data/lib/ramaze/contrib/profiling.rb +1 -1
- data/lib/ramaze/contrib/rest.rb +16 -13
- data/lib/ramaze/contrib/sequel/create_join.rb +25 -0
- data/lib/ramaze/contrib/sequel/form_field.rb +129 -0
- data/lib/ramaze/contrib/sequel/image.rb +198 -0
- data/lib/ramaze/contrib/sequel/relation.rb +82 -0
- data/lib/ramaze/controller.rb +33 -34
- data/lib/ramaze/controller/resolve.rb +29 -9
- data/lib/ramaze/current.rb +60 -20
- data/lib/ramaze/current/request.rb +8 -7
- data/lib/ramaze/current/response.rb +15 -3
- data/lib/ramaze/current/session/flash.rb +8 -0
- data/lib/ramaze/dispatcher.rb +17 -9
- data/lib/ramaze/dispatcher/action.rb +4 -5
- data/lib/ramaze/dispatcher/directory.rb +1 -1
- data/lib/ramaze/dispatcher/error.rb +4 -4
- data/lib/ramaze/dispatcher/file.rb +4 -4
- data/lib/ramaze/gestalt.rb +15 -20
- data/lib/ramaze/helper/cgi.rb +7 -15
- data/lib/ramaze/helper/formatting.rb +41 -1
- data/lib/ramaze/helper/httpdigest.rb +20 -7
- data/lib/ramaze/helper/link.rb +4 -6
- data/lib/ramaze/helper/paginate.rb +233 -0
- data/lib/ramaze/helper/redirect.rb +1 -1
- data/lib/ramaze/helper/rest.rb +1 -1
- data/lib/ramaze/helper/thread.rb +17 -0
- data/lib/ramaze/helper/ultraviolet.rb +44 -0
- data/lib/ramaze/helper/user.rb +4 -9
- data/lib/ramaze/log.rb +2 -2
- data/lib/ramaze/log/analogger.rb +21 -23
- data/lib/ramaze/log/growl.rb +21 -23
- data/lib/ramaze/log/hub.rb +1 -1
- data/lib/ramaze/log/informer.rb +97 -99
- data/lib/ramaze/log/knotify.rb +14 -16
- data/lib/ramaze/log/logger.rb +11 -13
- data/lib/ramaze/log/logging.rb +61 -63
- data/lib/ramaze/log/rotatinginformer.rb +168 -0
- data/lib/ramaze/log/syslog.rb +41 -31
- data/lib/ramaze/log/xosd.rb +70 -72
- data/lib/ramaze/option.rb +9 -6
- data/lib/ramaze/option/holder.rb +5 -27
- data/lib/ramaze/reloader.rb +186 -0
- data/lib/ramaze/setup.rb +1 -1
- data/lib/ramaze/snippets.rb +13 -0
- data/lib/ramaze/snippets/array/put_within.rb +31 -24
- data/lib/ramaze/snippets/binding/locals.rb +23 -11
- data/lib/ramaze/snippets/dictionary.rb +2 -2
- data/lib/ramaze/snippets/fiber.rb +63 -0
- data/lib/ramaze/snippets/kernel/constant.rb +36 -21
- data/lib/ramaze/snippets/kernel/pretty_inspect.rb +12 -6
- data/lib/ramaze/snippets/numeric/filesize_format.rb +24 -17
- data/lib/ramaze/snippets/numeric/time.rb +63 -0
- data/lib/ramaze/snippets/object/__dir__.rb +29 -0
- data/lib/ramaze/snippets/object/acquire.rb +40 -0
- data/lib/ramaze/snippets/object/instance_variable_defined.rb +16 -5
- data/lib/ramaze/snippets/object/pretty.rb +14 -4
- data/lib/ramaze/snippets/object/scope.rb +14 -7
- data/lib/ramaze/snippets/ordered_set.rb +25 -14
- data/lib/ramaze/snippets/proc/locals.rb +17 -9
- data/lib/ramaze/snippets/ramaze/deprecated.rb +13 -0
- data/lib/ramaze/snippets/ramaze/fiber.rb +24 -0
- data/lib/ramaze/snippets/ramaze/state.rb +86 -0
- data/lib/ramaze/snippets/ramaze/struct.rb +45 -0
- data/lib/ramaze/snippets/string/camel_case.rb +13 -8
- data/lib/ramaze/snippets/string/color.rb +24 -20
- data/lib/ramaze/snippets/string/each.rb +14 -3
- data/lib/ramaze/snippets/string/end_with.rb +20 -0
- data/lib/ramaze/snippets/string/esc.rb +26 -21
- data/lib/ramaze/snippets/string/ord.rb +12 -6
- data/lib/ramaze/snippets/string/snake_case.rb +13 -7
- data/lib/ramaze/snippets/string/start_with.rb +16 -5
- data/lib/ramaze/snippets/string/unindent.rb +23 -15
- data/lib/ramaze/snippets/thread/into.rb +3 -3
- data/lib/ramaze/spec/helper/bacon.rb +5 -5
- data/lib/ramaze/spec/helper/mock_http.rb +1 -1
- data/lib/ramaze/spec/helper/pretty_output.rb +2 -2
- data/lib/ramaze/spec/helper/snippets.rb +8 -0
- data/lib/ramaze/template.rb +4 -1
- data/lib/ramaze/template/ezamar/textpow.syntax +34 -0
- data/lib/ramaze/template/maruku.rb +34 -0
- data/lib/ramaze/template/tagz.rb +2 -2
- data/lib/ramaze/template/xslt.rb +2 -2
- data/lib/ramaze/tool/create.rb +27 -53
- data/lib/ramaze/tool/localize.rb +8 -4
- data/lib/ramaze/tool/mime.rb +11 -1
- data/lib/ramaze/tool/project_creator.rb +110 -0
- data/lib/ramaze/trinity.rb +4 -1
- data/lib/ramaze/version.rb +1 -1
- data/lib/vendor/bacon.rb +323 -0
- data/rake_tasks/gem.rake +10 -1
- data/rake_tasks/maintenance.rake +40 -2
- data/rake_tasks/metric.rake +24 -0
- data/rake_tasks/release.rake +17 -4
- data/rake_tasks/spec.rake +1 -2
- data/ramaze.gemspec +549 -495
- data/spec/contrib/auto_params.rb +3 -3
- data/spec/contrib/profiling.rb +2 -2
- data/spec/examples/simple_auth.rb +2 -2
- data/spec/examples/templates/template_haml.rb +0 -2
- data/spec/ramaze/action/file_cache.rb +22 -0
- data/spec/ramaze/adapter.rb +2 -2
- data/spec/ramaze/controller/actionless_templates.rb +1 -1
- data/spec/ramaze/controller/subclass.rb +15 -0
- data/spec/ramaze/controller/template_resolving.rb +1 -1
- data/spec/ramaze/controller/view/bar.xhtml +1 -0
- data/spec/ramaze/controller/view/base/another.xhtml +1 -0
- data/spec/ramaze/current/session.rb +1 -1
- data/spec/ramaze/dispatcher/file.rb +2 -2
- data/spec/ramaze/helper/aspect.rb +26 -17
- data/spec/ramaze/helper/formatting.rb +13 -0
- data/spec/ramaze/log/informer.rb +10 -10
- data/spec/ramaze/log/syslog.rb +67 -4
- data/spec/ramaze/rewrite.rb +1 -1
- data/spec/ramaze/route.rb +1 -1
- data/spec/ramaze/struct.rb +47 -0
- data/spec/ramaze/template/markaby.rb +1 -1
- data/spec/ramaze/template/tagz.rb +1 -1
- data/spec/snippets/binding/locals.rb +9 -0
- data/spec/snippets/numeric/time.rb +12 -0
- data/spec/snippets/{kernel → object}/__dir__.rb +0 -0
- data/spec/snippets/{kernel → object}/acquire.rb +0 -0
- metadata +90 -81
- data/cache.yaml +0 -7
- data/examples/app/rammit/spec/rammit.rb +0 -31
- data/examples/app/rammit/src/controller/main.rb +0 -3
- data/examples/app/rammit/src/controller/page.rb +0 -16
- data/examples/app/rammit/src/model.rb +0 -33
- data/examples/app/rammit/start.rb +0 -8
- data/examples/app/rammit/template/index.xhtml +0 -14
- data/examples/app/rammit/template/page/view.xhtml +0 -4
- data/lib/ramaze/snippets/kernel/__dir__.rb +0 -23
- data/lib/ramaze/snippets/kernel/acquire.rb +0 -34
- data/lib/ramaze/snippets/object/thread_accessor.rb +0 -5
- data/lib/ramaze/snippets/ramaze/thread_accessor.rb +0 -58
- data/lib/ramaze/snippets/struct/fill.rb +0 -23
- data/lib/ramaze/snippets/struct/values_at.rb +0 -39
- data/lib/ramaze/snippets/symbol/to_proc.rb +0 -24
- data/lib/ramaze/sourcereload.rb +0 -176
- data/spec/snippets/struct/fill.rb +0 -26
- data/spec/snippets/struct/values_at.rb +0 -52
- data/spec/snippets/symbol/to_proc.rb +0 -13
@@ -0,0 +1,233 @@
|
|
1
|
+
require 'ramaze/gestalt'
|
2
|
+
|
3
|
+
module Ramaze
|
4
|
+
module Helper
|
5
|
+
|
6
|
+
# Helper for pagination and pagination-navigation.
|
7
|
+
#
|
8
|
+
# See detailed API docs for Paginator below.
|
9
|
+
# Also have a look at the examples/helpers/paginate.rb
|
10
|
+
|
11
|
+
module Paginate
|
12
|
+
|
13
|
+
# Define default options in your Controller, they are being retrieved by
|
14
|
+
# ancestral_trait, so you can also put it into a common superclass
|
15
|
+
|
16
|
+
trait :paginate => {
|
17
|
+
:limit => 10,
|
18
|
+
:var => 'pager',
|
19
|
+
}
|
20
|
+
|
21
|
+
# Returns a new Paginator instance.
|
22
|
+
#
|
23
|
+
# Note that the pagination relies on being inside a Ramaze request to
|
24
|
+
# gain necessary metadata about the page it resides on, you cannot use it
|
25
|
+
# outside of Ramaze yet.
|
26
|
+
#
|
27
|
+
# The examples below are meant to be used within your controller or view.
|
28
|
+
#
|
29
|
+
# Usage with Array:
|
30
|
+
# data = (1..100).to_a
|
31
|
+
# @pager = paginate(data, :limit => 30, :page => 2)
|
32
|
+
# @pager.navigation
|
33
|
+
# @pager.each{|e| puts(e) }
|
34
|
+
#
|
35
|
+
# Usage with Sequel:
|
36
|
+
# data = Article.filter(:public => true)
|
37
|
+
# @pager = paginate(data, :limit => 5)
|
38
|
+
# @pager.navigation
|
39
|
+
# @pager.each{|e| puts(e)
|
40
|
+
#
|
41
|
+
# +dataset+ may be a Sequel dataset or Array
|
42
|
+
# +options+ Takes precedence to trait[:paginate] and may contain
|
43
|
+
# following pairs:
|
44
|
+
# :limit The number of elements used when you call #each on the
|
45
|
+
# paginator
|
46
|
+
# :var The variable name being used in the request, this is helpful
|
47
|
+
# if you want to use two or more independent paginations on the
|
48
|
+
# same page.
|
49
|
+
# :page The page you are currently on, if not given it will be
|
50
|
+
# retrieved from current request variables. Defaults to 1 if
|
51
|
+
# neither exists.
|
52
|
+
|
53
|
+
def paginate(dataset, options = {})
|
54
|
+
options = ancestral_trait[:paginate].merge(options)
|
55
|
+
limit = options[:limit]
|
56
|
+
var = options[:var]
|
57
|
+
page = options[:page] || (request[var] || 1).to_i
|
58
|
+
|
59
|
+
Paginator.new(dataset, page, limit, var)
|
60
|
+
end
|
61
|
+
|
62
|
+
# Provides easy pagination and navigation
|
63
|
+
|
64
|
+
class Paginator
|
65
|
+
include Ramaze::Helper::Link
|
66
|
+
include Ramaze::Helper::CGI
|
67
|
+
|
68
|
+
def initialize(data = [], page = 1, limit = 10, var = 'pager')
|
69
|
+
@data, @page, @limit, @var = data, page, limit, var
|
70
|
+
@pager = pager_for(data)
|
71
|
+
@page = @page > page_count ? page_count : @page
|
72
|
+
@pager = pager_for(data)
|
73
|
+
end
|
74
|
+
|
75
|
+
# Returns String with navigation div.
|
76
|
+
#
|
77
|
+
# This cannot be customized very nicely, but you can style it easily
|
78
|
+
# with CSS.
|
79
|
+
#
|
80
|
+
# Output with 5 elements, page 1, limit 3:
|
81
|
+
# <div class="pager">
|
82
|
+
# <span class="first grey"><<</span>
|
83
|
+
# <span class="previous grey"><</span>
|
84
|
+
# <a class="current" href="/index?pager=1">1</a>
|
85
|
+
# <a href="/index?pager=2">2</a>
|
86
|
+
# <a class="next" href="/index?pager=2">></a>
|
87
|
+
# <a class="last" href="/index?pager=2">>></a>
|
88
|
+
# </div>
|
89
|
+
#
|
90
|
+
# Output with 5 elements, page 2, limit 3:
|
91
|
+
# <div class="pager" />
|
92
|
+
# <a class="first" href="/index?user_page=1"><<</a>
|
93
|
+
# <a class="previous" href="/index?user_page=1"><</a>
|
94
|
+
# <a href="/index?user_page=1">1</a>
|
95
|
+
# <a class="current" href="/index?user_page=2">2</a>
|
96
|
+
# <span class="next grey">></span>
|
97
|
+
# <span class="last grey">>></span>
|
98
|
+
# </div>
|
99
|
+
|
100
|
+
|
101
|
+
def navigation(limit = 8)
|
102
|
+
out = [ g.div(:class => :pager) ]
|
103
|
+
|
104
|
+
if first_page?
|
105
|
+
out << g.span(:class => 'first grey'){ h('<<') }
|
106
|
+
out << g.span(:class => 'previous grey'){ h('<') }
|
107
|
+
else
|
108
|
+
out << link(1, '<<', :class => :first)
|
109
|
+
out << link(prev_page, '<', :class => :previous)
|
110
|
+
end
|
111
|
+
|
112
|
+
lower = limit ? (current_page - limit) : 1
|
113
|
+
lower = lower < 1 ? 1 : lower
|
114
|
+
|
115
|
+
(lower...current_page).each do |n|
|
116
|
+
out << link(n)
|
117
|
+
end
|
118
|
+
|
119
|
+
out << link(current_page, current_page, :class => :current)
|
120
|
+
|
121
|
+
if last_page?
|
122
|
+
out << g.span(:class => 'next grey'){ h('>') }
|
123
|
+
out << g.span(:class => 'last grey'){ h('>>') }
|
124
|
+
elsif next_page
|
125
|
+
higher = limit ? (next_page + limit) : page_count
|
126
|
+
higher = [higher, page_count].min
|
127
|
+
(next_page..higher).each do |n|
|
128
|
+
out << link(n)
|
129
|
+
end
|
130
|
+
|
131
|
+
out << link(next_page, '>', :class => :next)
|
132
|
+
out << link(page_count, '>>', :class => :last)
|
133
|
+
end
|
134
|
+
|
135
|
+
out << '</div>'
|
136
|
+
out.map{|e| e.to_s}.join("\n")
|
137
|
+
end
|
138
|
+
|
139
|
+
# Useful to omit pager if it's of no use.
|
140
|
+
|
141
|
+
def needed?
|
142
|
+
@pager.page_count > 1
|
143
|
+
end
|
144
|
+
|
145
|
+
# Forward everything to the inner @pager
|
146
|
+
|
147
|
+
def method_missing(meth, *args, &block)
|
148
|
+
@pager.send(meth, *args, &block)
|
149
|
+
end
|
150
|
+
|
151
|
+
private
|
152
|
+
|
153
|
+
def pager_for(obj)
|
154
|
+
@page = @page < 1 ? 1 : @page
|
155
|
+
|
156
|
+
case obj
|
157
|
+
when Array
|
158
|
+
ArrayPager.new(obj, @page, @limit)
|
159
|
+
else
|
160
|
+
obj.paginate(@page, @limit)
|
161
|
+
end
|
162
|
+
end
|
163
|
+
|
164
|
+
def link(n, text = n, hash = {})
|
165
|
+
text = h(text.to_s)
|
166
|
+
|
167
|
+
params = Ramaze::Request.current.params.merge(@var.to_s => n)
|
168
|
+
name = Ramaze::Request.current.request_path
|
169
|
+
hash[:href] = R(name, params)
|
170
|
+
|
171
|
+
g.a(hash){ text }
|
172
|
+
end
|
173
|
+
|
174
|
+
def g
|
175
|
+
Ramaze::Gestalt.new
|
176
|
+
end
|
177
|
+
|
178
|
+
# Wrapper for Array to behave like the Sequel pagination
|
179
|
+
|
180
|
+
class ArrayPager
|
181
|
+
def initialize(array, page, limit)
|
182
|
+
@array, @page, @limit = array, page, limit
|
183
|
+
@page = page_count if @page > page_count
|
184
|
+
end
|
185
|
+
|
186
|
+
def size
|
187
|
+
@array.size
|
188
|
+
end
|
189
|
+
|
190
|
+
def empty?
|
191
|
+
@array.empty?
|
192
|
+
end
|
193
|
+
|
194
|
+
def page_count
|
195
|
+
pages, rest = @array.size.divmod(@limit)
|
196
|
+
rest == 0 ? pages : pages + 1
|
197
|
+
end
|
198
|
+
|
199
|
+
def current_page
|
200
|
+
@page
|
201
|
+
end
|
202
|
+
|
203
|
+
def next_page
|
204
|
+
page_count == @page ? nil : @page + 1
|
205
|
+
end
|
206
|
+
|
207
|
+
def prev_page
|
208
|
+
@page <= 1 ? nil : @page - 1
|
209
|
+
end
|
210
|
+
|
211
|
+
def first_page?
|
212
|
+
@page <= 1
|
213
|
+
end
|
214
|
+
|
215
|
+
def last_page?
|
216
|
+
page_count == @page
|
217
|
+
end
|
218
|
+
|
219
|
+
def each(&block)
|
220
|
+
from = ((@page - 1) * @limit)
|
221
|
+
to = from + @limit
|
222
|
+
|
223
|
+
a = @array[from...to] || []
|
224
|
+
a.each(&block)
|
225
|
+
end
|
226
|
+
|
227
|
+
include Enumerable
|
228
|
+
end
|
229
|
+
|
230
|
+
end
|
231
|
+
end
|
232
|
+
end
|
233
|
+
end
|
@@ -59,7 +59,7 @@ module Ramaze
|
|
59
59
|
def raw_redirect(target, opts = {})
|
60
60
|
target = target.to_s
|
61
61
|
header = {'Location' => target}
|
62
|
-
status = opts[:status] || STATUS_CODE["
|
62
|
+
status = opts[:status] || STATUS_CODE["Moved Temporarily"]
|
63
63
|
body = %{You are being redirected, please follow <a href="#{target}">this link to: #{target}</a>!}
|
64
64
|
|
65
65
|
Log.info("Redirect to '#{target}'")
|
data/lib/ramaze/helper/rest.rb
CHANGED
@@ -25,7 +25,7 @@ module Ramaze
|
|
25
25
|
trait[:REST][:active] = hm
|
26
26
|
end
|
27
27
|
|
28
|
-
(%w[GET PUT POST DELETE] <<
|
28
|
+
(%w[GET PUT POST DELETE] << 'any').each do |http_method|
|
29
29
|
define_method("on_#{http_method.downcase}") do |*args|
|
30
30
|
if args.empty?
|
31
31
|
on(http_method)
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# Copyright (c) 2008 Michael Fellinger m.fellinger@gmail.com
|
2
|
+
# All files in this distribution are subject to the terms of the Ruby license.
|
3
|
+
|
4
|
+
module Ramaze
|
5
|
+
module Helper::Thread
|
6
|
+
def thread &block
|
7
|
+
parent_thread = Thread.current
|
8
|
+
Thread.new do
|
9
|
+
begin
|
10
|
+
block.call
|
11
|
+
rescue Exception => e
|
12
|
+
parent_thread.raise(e)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
module Ramaze
|
2
|
+
module Helper
|
3
|
+
module Ultraviolet
|
4
|
+
trait :ultraviolet => {
|
5
|
+
:output => 'xhtml',
|
6
|
+
:syntax => nil, # syntax_name, nil|false indicates automatic detection
|
7
|
+
:line_numbers => false,
|
8
|
+
:style => 'classic', # render_style
|
9
|
+
:headers => false, # ouput document with all headers
|
10
|
+
}
|
11
|
+
|
12
|
+
# Parse and output the file at the given path.
|
13
|
+
# Please head over to the Ultraviolet documentation for more information
|
14
|
+
# on possible options.
|
15
|
+
def ultraviolet(path, options = {})
|
16
|
+
o = ancestral_trait[:ultraviolet].merge(options)
|
17
|
+
output, syntax, lines, style, headers =
|
18
|
+
o.values_at(:output, :syntax, :line_numbers, :style, :headers)
|
19
|
+
|
20
|
+
syntax ||= Uv.syntax_for_file(path).first.first
|
21
|
+
code = File.read(path)
|
22
|
+
|
23
|
+
p [code, output, syntax, lines, style, headers]
|
24
|
+
Uv.parse(code, output, syntax, lines, style, headers)
|
25
|
+
end
|
26
|
+
|
27
|
+
# Return absolute path to the css of given name.
|
28
|
+
#
|
29
|
+
# Usually this will point to somewhere in the gem tree.
|
30
|
+
#
|
31
|
+
# It seems like Uv will add support for user-defined PATH in the future,
|
32
|
+
# so we will, to be future-proof, traverse the Uv.path even though it
|
33
|
+
# currently will only have one directory.
|
34
|
+
|
35
|
+
def ultraviolet_css(theme)
|
36
|
+
Uv.path.each do |path|
|
37
|
+
Dir[path/"render/xhtml/files/css/*.css"].each do |css|
|
38
|
+
return css if File.basename(css, '.css') == theme
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
data/lib/ramaze/helper/user.rb
CHANGED
@@ -25,7 +25,7 @@ module Ramaze
|
|
25
25
|
def user
|
26
26
|
model = ancestral_trait[:user_model] ||= ::User
|
27
27
|
callback = ancestral_trait[:user_callback] ||= nil
|
28
|
-
|
28
|
+
STATE[:user] ||= Wrapper.new(model, callback)
|
29
29
|
end
|
30
30
|
|
31
31
|
# shortcut for user.user_login but default argument are request.params
|
@@ -51,12 +51,7 @@ module Ramaze
|
|
51
51
|
# In order to not interfere with the wrapped instance/model we start our
|
52
52
|
# methods with an underscore.
|
53
53
|
# Suggestions on improvements as usual welcome.
|
54
|
-
class Wrapper
|
55
|
-
# make it a BlankSlate
|
56
|
-
instance_methods.each do |meth|
|
57
|
-
undef_method(meth) unless meth.to_s =~ /^__.+__$/
|
58
|
-
end
|
59
|
-
|
54
|
+
class Wrapper < BlankSlate
|
60
55
|
attr_accessor :_model, :_callback, :_user
|
61
56
|
|
62
57
|
def initialize(model, callback)
|
@@ -82,14 +77,14 @@ module Ramaze
|
|
82
77
|
elsif _model.respond_to?(:authenticate)
|
83
78
|
_model.authenticate(creds)
|
84
79
|
else
|
85
|
-
Log.warn("Helper::User has no callback and
|
80
|
+
Log.warn("Helper::User has no callback and %p doesn't respond to #authenticate" % _model)
|
86
81
|
nil
|
87
82
|
end
|
88
83
|
end
|
89
84
|
|
90
85
|
def _logout
|
91
86
|
_persistence.clear
|
92
|
-
|
87
|
+
STATE[:user] = nil
|
93
88
|
end
|
94
89
|
|
95
90
|
def _logged_in?
|
data/lib/ramaze/log.rb
CHANGED
@@ -10,7 +10,7 @@ begin
|
|
10
10
|
rescue LoadError => ex
|
11
11
|
puts ex
|
12
12
|
puts "For nice colors on windows, please `gem install win32console`"
|
13
|
-
Ramaze::Informer.trait[:colorize] = false
|
13
|
+
Ramaze::Logger::Informer.trait[:colorize] = false
|
14
14
|
end
|
15
15
|
|
16
16
|
module Ramaze
|
@@ -22,6 +22,6 @@ module Ramaze
|
|
22
22
|
autoload :Logger, "ramaze/log/logger.rb"
|
23
23
|
|
24
24
|
unless defined?(Log)
|
25
|
-
Log =
|
25
|
+
Log = Logger::LogHub.new(Logger::Informer)
|
26
26
|
end
|
27
27
|
end
|
data/lib/ramaze/log/analogger.rb
CHANGED
@@ -4,39 +4,37 @@
|
|
4
4
|
require 'swiftcore/Analogger/Client'
|
5
5
|
|
6
6
|
module Ramaze
|
7
|
-
module
|
8
|
-
module Logger
|
7
|
+
module Logger
|
9
8
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
9
|
+
# Informer for the Swiftcore Analogger logging system.
|
10
|
+
#
|
11
|
+
# You can find it at http://analogger.swiftcore.org and install with
|
12
|
+
# gem install analogger
|
14
13
|
|
15
|
-
|
16
|
-
|
14
|
+
class Analogger < ::Swiftcore::Analogger::Client
|
15
|
+
include Logging
|
17
16
|
|
18
|
-
|
19
|
-
|
17
|
+
# identifier for your application
|
18
|
+
trait :name => 'walrus'
|
20
19
|
|
21
|
-
|
22
|
-
|
20
|
+
# Host analogger runs on
|
21
|
+
trait :host => '127.0.0.1'
|
23
22
|
|
24
|
-
|
25
|
-
|
23
|
+
# Port analogger runs on
|
24
|
+
trait :port => 6766
|
26
25
|
|
27
|
-
|
26
|
+
# Create a new instance, parameters default to the traits.
|
28
27
|
|
29
|
-
|
30
|
-
|
31
|
-
|
28
|
+
def initialize(name = class_trait[:name], host = class_trait[:host], port = class_trait[:port])
|
29
|
+
super
|
30
|
+
end
|
32
31
|
|
33
|
-
|
32
|
+
# integration to Logging
|
34
33
|
|
35
|
-
|
36
|
-
|
37
|
-
end
|
34
|
+
def log(tag, *args)
|
35
|
+
log(tag, args.join("\n"))
|
38
36
|
end
|
39
|
-
|
40
37
|
end
|
38
|
+
|
41
39
|
end
|
42
40
|
end
|
data/lib/ramaze/log/growl.rb
CHANGED
@@ -4,37 +4,35 @@
|
|
4
4
|
require 'ruby-growl'
|
5
5
|
|
6
6
|
module Ramaze
|
7
|
-
module
|
8
|
-
module Logger
|
7
|
+
module Logger
|
9
8
|
|
10
|
-
|
9
|
+
# Informer for the growl notification system on OSX.
|
11
10
|
|
12
|
-
|
11
|
+
class Growl < ::Growl
|
13
12
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
13
|
+
trait :defaults => {
|
14
|
+
:name => 'walrus',
|
15
|
+
:host => 'localhost',
|
16
|
+
:password => 'walrus',
|
17
|
+
:all_notifies => %w[error warn debug info dev],
|
18
|
+
:default_notifies => %w[error warn info]
|
19
|
+
}
|
21
20
|
|
22
|
-
|
21
|
+
# Takes the options from the default trait for merging.
|
23
22
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
23
|
+
def initialize(options = {})
|
24
|
+
options = class_trait[:defaults].merge(options).values_at(:host, :name, :all_notifies, :default_notifies, :password)
|
25
|
+
super(*options)
|
26
|
+
end
|
28
27
|
|
29
|
-
|
28
|
+
# integration to Logging
|
30
29
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
end
|
30
|
+
def log(tag, *args)
|
31
|
+
notify(tag.to_s, Time.now.strftime("%X"), args.join("\n")[0..100])
|
32
|
+
rescue Errno::EMSGSIZE
|
33
|
+
# Send size was to big (not really), ignore
|
36
34
|
end
|
37
|
-
|
38
35
|
end
|
36
|
+
|
39
37
|
end
|
40
38
|
end
|