padrino-contrib 0.1.5 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of padrino-contrib might be problematic. Click here for more details.
- data/README.rdoc +1 -1
- data/lib/padrino-contrib.rb +10 -1
- data/lib/padrino-contrib/auto_locale.rb +3 -3
- data/lib/padrino-contrib/exception_notifier.rb +5 -5
- data/lib/padrino-contrib/flash_session.rb +1 -1
- data/lib/padrino-contrib/helpers/assets_compressor.rb +1 -1
- data/lib/padrino-contrib/helpers/flash.rb +32 -0
- data/lib/padrino-contrib/helpers/jquery.rb +1 -1
- data/lib/padrino-contrib/orm/active_record/permalink.rb +1 -1
- data/lib/padrino-contrib/orm/active_record/permalink_i18n.rb +1 -1
- data/lib/padrino-contrib/orm/active_record/textile.rb +3 -4
- data/lib/padrino-contrib/orm/active_record/translate.rb +3 -3
- data/lib/padrino-contrib/orm/mongo_mapper/permalink.rb +1 -1
- data/lib/padrino-contrib/orm/mongo_mapper/search.rb +1 -1
- data/lib/padrino-contrib/version.rb +1 -1
- data/spec/autoload_spec.rb +1 -1
- data/spec/spec_helper.rb +1 -1
- metadata +5 -4
data/README.rdoc
CHANGED
data/lib/padrino-contrib.rb
CHANGED
@@ -8,6 +8,15 @@ module Padrino
|
|
8
8
|
module Helpers
|
9
9
|
autoload :AssetsCompressor, 'padrino-contrib/helpers/assets_compressor.rb'
|
10
10
|
autoload :JQuery, 'padrino-contrib/helpers/jquery.rb'
|
11
|
+
autoload :Flash, 'padrino-contrib/helpers/flash.rb'
|
11
12
|
end # Helpers
|
12
13
|
end # Contrib
|
13
|
-
end # Padrino
|
14
|
+
end # Padrino
|
15
|
+
|
16
|
+
if defined?(ActiveRecord)
|
17
|
+
Dir[File.join(File.expand_path('../', __FILE__), '/padrino-contrib/orm/active_record/**/*.rb')].each { |d| require d }
|
18
|
+
end
|
19
|
+
|
20
|
+
if defined?(MongoMapper)
|
21
|
+
Dir[File.join(File.expand_path('../', __FILE__), '/padrino-contrib/orm/mongo_mapper/**/*.rb')].each { |d| require d }
|
22
|
+
end
|
@@ -22,7 +22,7 @@ module Padrino
|
|
22
22
|
# This reload the page changing the I18n.locale
|
23
23
|
#
|
24
24
|
def switch_to_lang(lang)
|
25
|
-
request.path_info.sub(/\/#{I18n.locale}/, "/#{lang}") if
|
25
|
+
request.path_info.sub(/\/#{I18n.locale}/, "/#{lang}") if settings.locales.include?(lang)
|
26
26
|
end
|
27
27
|
end # Helpers
|
28
28
|
|
@@ -31,10 +31,10 @@ module Padrino
|
|
31
31
|
app.extend ClassMethods
|
32
32
|
app.set :locales, [:en]
|
33
33
|
app.before do
|
34
|
-
if request.path_info =~ /^\/(#{
|
34
|
+
if request.path_info =~ /^\/(#{settings.locales.join('|')})\b/
|
35
35
|
I18n.locale = $1.to_sym
|
36
36
|
else
|
37
|
-
I18n.locale =
|
37
|
+
I18n.locale = settings.locales[0]
|
38
38
|
not_found if request.path_info !~ /^\/?$/
|
39
39
|
end
|
40
40
|
end
|
@@ -20,11 +20,11 @@ module Padrino
|
|
20
20
|
module ExceptionNotifier
|
21
21
|
|
22
22
|
def self.registered(app)
|
23
|
-
app.set :exceptions_subject, "Exception"
|
24
|
-
app.set :exceptions_to, "errors@localhost.local"
|
25
|
-
app.set :exceptions_from, "foo@bar.local"
|
26
|
-
app.set :exceptions_layout, :layout
|
27
|
-
app.set :redmine, {}
|
23
|
+
app.set :exceptions_subject, "Exception" unless app.respond_to?(:exceptions_subject)
|
24
|
+
app.set :exceptions_to, "errors@localhost.local" unless app.respond_to?(:exceptions_to)
|
25
|
+
app.set :exceptions_from, "foo@bar.local" unless app.respond_to?(:exceptions_from)
|
26
|
+
app.set :exceptions_layout, :layout unless app.respond_to?(:exceptions_layout)
|
27
|
+
app.set :redmine, {} unless app.respond_to?(:redmine)
|
28
28
|
app.error 500 do
|
29
29
|
boom = env['sinatra.error']
|
30
30
|
body = ["#{boom.class} - #{boom.message}:", *boom.backtrace].join("\n ")
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module Padrino
|
2
|
+
module Contrib
|
3
|
+
module Helpers
|
4
|
+
##
|
5
|
+
# Dead simple version of rack-flash.
|
6
|
+
# You still use flash without session, but remember that
|
7
|
+
# they can't work after a redirect.
|
8
|
+
#
|
9
|
+
# ==== Usage:
|
10
|
+
#
|
11
|
+
# register Padrino::Contrib::Helpers::Flash
|
12
|
+
#
|
13
|
+
module Flash
|
14
|
+
def self.register(app)
|
15
|
+
app.before { @_flash, session[:_flash] = session[:_flash], nil if settings.sessions? && session[:_flash] }
|
16
|
+
app.helpers InstanceMethods
|
17
|
+
end
|
18
|
+
|
19
|
+
module InstanceMethods
|
20
|
+
def flash
|
21
|
+
@_flash ||= {}
|
22
|
+
end
|
23
|
+
|
24
|
+
def redirect(uri, *args)
|
25
|
+
session[:_flash] = @_flash if settings.sessions? && flash.present?
|
26
|
+
super(uri, *args)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end # Flash
|
30
|
+
end # Helpers
|
31
|
+
end # Contrib
|
32
|
+
end # Padrino
|
@@ -1,5 +1,3 @@
|
|
1
|
-
require 'RedCloth'
|
2
|
-
|
3
1
|
module Padrino
|
4
2
|
module Contrib
|
5
3
|
module Orm
|
@@ -18,6 +16,7 @@ module Padrino
|
|
18
16
|
module Textile
|
19
17
|
module ClassMethods
|
20
18
|
def has_textile(*fields)
|
19
|
+
require 'RedCloth'
|
21
20
|
include InstanceMethods
|
22
21
|
options = fields.extract_options!
|
23
22
|
options.reverse_merge!(:internal_links => :blog)
|
@@ -52,8 +51,8 @@ module Padrino
|
|
52
51
|
end
|
53
52
|
end
|
54
53
|
end # InstanceMethods
|
55
|
-
end #
|
56
|
-
end #
|
54
|
+
end # Textile
|
55
|
+
end # ActiveRecord
|
57
56
|
end # Orm
|
58
57
|
end # Contrib
|
59
58
|
end # Padrino
|
@@ -35,9 +35,9 @@ module Padrino
|
|
35
35
|
super
|
36
36
|
end
|
37
37
|
end # InstanceMethods
|
38
|
-
end #
|
39
|
-
end #
|
38
|
+
end # Translate
|
39
|
+
end # ActiveRecord
|
40
40
|
end # Orm
|
41
41
|
end # Contrib
|
42
42
|
end # Padrino
|
43
|
-
::ActiveRecord::Base.extend(Padrino::Contrib::Orm::ActiveRecord::Translate::ClassMethods)
|
43
|
+
::ActiveRecord::Base.extend(Padrino::Contrib::Orm::ActiveRecord::Translate::ClassMethods)
|
data/spec/autoload_spec.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: padrino-contrib
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 23
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 6
|
10
|
+
version: 0.1.6
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Davide D'Agostino
|
@@ -17,7 +17,7 @@ autorequire:
|
|
17
17
|
bindir: bin
|
18
18
|
cert_chain: []
|
19
19
|
|
20
|
-
date: 2011-
|
20
|
+
date: 2011-09-26 00:00:00 +02:00
|
21
21
|
default_executable:
|
22
22
|
dependencies: []
|
23
23
|
|
@@ -40,6 +40,7 @@ files:
|
|
40
40
|
- lib/padrino-contrib/exception_notifier.rb
|
41
41
|
- lib/padrino-contrib/flash_session.rb
|
42
42
|
- lib/padrino-contrib/helpers/assets_compressor.rb
|
43
|
+
- lib/padrino-contrib/helpers/flash.rb
|
43
44
|
- lib/padrino-contrib/helpers/jquery.rb
|
44
45
|
- lib/padrino-contrib/orm/active_record/permalink.rb
|
45
46
|
- lib/padrino-contrib/orm/active_record/permalink_i18n.rb
|