padrino-contrib 0.0.3 → 0.0.4
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
CHANGED
@@ -2,14 +2,15 @@
|
|
2
2
|
|
3
3
|
This package includes a variety of add-on components for Padrino Framework:
|
4
4
|
|
5
|
-
* exception_notifier
|
6
|
-
*
|
7
|
-
*
|
8
|
-
*
|
9
|
-
*
|
10
|
-
*
|
11
|
-
* orm_mm_permalink
|
12
|
-
* orm_mm_search
|
5
|
+
* exception_notifier - Send errors through mail or/and to redmine
|
6
|
+
* auto_locale - Switch for you automatically the I18n.locale
|
7
|
+
* flash_session - Middleware that help you in passing your session in the URI, when it should be in the cookie.
|
8
|
+
* orm_ar_permalink - Generate permalink for a specified column on ActiveRecord
|
9
|
+
* orm_ar_permalink_i18n - Generate permalink for a specified multi language column(s) on ActiveRecord
|
10
|
+
* orm_ar_translate - Translate for you your ActiveRecord columns
|
11
|
+
* orm_mm_permalink - Generate permalink for a specified column on MongoMapper
|
12
|
+
* orm_mm_search - Full text search in MongoMapper in specified columns
|
13
|
+
* helpers_assets_compressor - Joins and compress your js/css with yui-compressor
|
13
14
|
|
14
15
|
=== Use
|
15
16
|
|
@@ -24,10 +24,6 @@ module Padrino
|
|
24
24
|
def switch_to_lang(lang)
|
25
25
|
request.path_info.sub(/\/#{I18n.locale}/, "/#{lang}") if options.locales.include?(lang)
|
26
26
|
end
|
27
|
-
|
28
|
-
def url(*args)
|
29
|
-
"/#{I18n.locale}#{super}"
|
30
|
-
end
|
31
27
|
end # Helpers
|
32
28
|
|
33
29
|
def self.registered(app)
|
@@ -36,8 +32,6 @@ module Padrino
|
|
36
32
|
app.before do
|
37
33
|
if request.path_info =~ /^\/(#{options.locales.join('|')})(?=\/|$)/
|
38
34
|
I18n.locale = $1.to_sym
|
39
|
-
request.path_info.sub!(/^\/(#{$1})\/?/) { $2 || '' }
|
40
|
-
request.path_info.replace('/') if request.path_info.empty?
|
41
35
|
else
|
42
36
|
I18n.locale = options.locales.first
|
43
37
|
end
|
@@ -0,0 +1,76 @@
|
|
1
|
+
require 'open-uri'
|
2
|
+
|
3
|
+
module Padrino
|
4
|
+
module Contrib
|
5
|
+
module Helpers
|
6
|
+
##
|
7
|
+
# This extension joins and compress with yui-compressor your css/js files.
|
8
|
+
#
|
9
|
+
# ==== Usage
|
10
|
+
#
|
11
|
+
# # in your app.rb
|
12
|
+
# use Padrino::Contrib::Helpers::AssetsCompressor
|
13
|
+
#
|
14
|
+
# # in yours layouts/views
|
15
|
+
# =stylesheet_link_tag "grid", "base", "fancybox", "gallery", :cache => "bundle/lipsiasample"
|
16
|
+
# =javascript_include_tag "jquery", "gallery", "fancybox", "base", :cache => "bundle/lipsiasample"
|
17
|
+
# =stylesheet_link_tag "grid", "base", "fancybox", "gallery", :cache => true
|
18
|
+
# =javascript_include_tag "jquery", "gallery", "fancybox", "base", :cache => true
|
19
|
+
#
|
20
|
+
module AssetsCompressor
|
21
|
+
def self.registered(app)
|
22
|
+
raise "You need to add in your Gemfile: gem 'yui-compressor', :require => 'yui/compressor'" unless defined?(YUI)
|
23
|
+
app.helpers Padrino::Contrib::Helpers::AssetsCompressor::Helpers
|
24
|
+
end
|
25
|
+
|
26
|
+
module Helpers
|
27
|
+
def self.included(base)
|
28
|
+
base.alias_method_chain :javascript_include_tag, :compression
|
29
|
+
base.alias_method_chain :stylesheet_link_tag, :compression
|
30
|
+
end
|
31
|
+
|
32
|
+
def javascript_include_tag_with_compression(*sources)
|
33
|
+
javascript_include_tag_without_compression(*assets_compressor(:js, sources))
|
34
|
+
end
|
35
|
+
|
36
|
+
def stylesheet_link_tag_with_compression(*sources)
|
37
|
+
stylesheet_link_tag_without_compression(*assets_compressor(:css, sources))
|
38
|
+
end
|
39
|
+
|
40
|
+
def assets_compressor(kind, sources)
|
41
|
+
began_at = Time.now
|
42
|
+
asset_folder, compressor = *case kind
|
43
|
+
# 8000 for line break is more browser and texmate friendly
|
44
|
+
when :css then ['stylesheets', YUI::CssCompressor.new(:line_break => 8000)]
|
45
|
+
when :js then ['javascripts', YUI::JavaScriptCompressor.new(:line_break => 8000)]
|
46
|
+
else raise "YUI Compressor didn't support yet #{kind} compression"
|
47
|
+
end
|
48
|
+
options = sources.extract_options!.symbolize_keys
|
49
|
+
bundle = options.delete(:cache)
|
50
|
+
return sources if bundle.nil?
|
51
|
+
bundle = settings.app_name if bundle.is_a?(TrueClass)
|
52
|
+
path = Padrino.root("public", uri_root_path(asset_folder, bundle.to_s))
|
53
|
+
path += ".#{kind}" unless path =~ /\.#{kind}/
|
54
|
+
return bundle if File.exist?(path)
|
55
|
+
sources.map! do |source|
|
56
|
+
source = asset_path(kind, source).sub(/\?.*/, '') # Removes Timestamp
|
57
|
+
source = source =~ /^http/ ? open(source) : File.read(Padrino.root("public", source))
|
58
|
+
# Removes extra comments
|
59
|
+
if cs = source =~ /\/\*\!/
|
60
|
+
cr = source.slice(cs, source.length)
|
61
|
+
ce = cr =~ /\*\//
|
62
|
+
cr = source.slice(cs, ce+2)
|
63
|
+
source.sub!(cr,'')
|
64
|
+
end
|
65
|
+
source
|
66
|
+
end
|
67
|
+
Dir.mkdir(File.dirname(path)) unless File.exist?(File.dirname(path))
|
68
|
+
File.open(path, "w") { |f| f.write(compressor.compress(sources.join("\n"))) }
|
69
|
+
logger.debug "Compressed (%0.2fms) %s" % [Time.now-began_at, path] if defined?(logger)
|
70
|
+
bundle
|
71
|
+
end
|
72
|
+
end # Helpers
|
73
|
+
end # AssetsCompressor
|
74
|
+
end # Helpers
|
75
|
+
end # Contrib
|
76
|
+
end # Padrino
|
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
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 4
|
10
|
+
version: 0.0.4
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Padrino Team
|
@@ -18,7 +18,7 @@ autorequire:
|
|
18
18
|
bindir: bin
|
19
19
|
cert_chain: []
|
20
20
|
|
21
|
-
date: 2011-
|
21
|
+
date: 2011-04-03 00:00:00 +02:00
|
22
22
|
default_executable:
|
23
23
|
dependencies: []
|
24
24
|
|
@@ -38,6 +38,7 @@ files:
|
|
38
38
|
- lib/padrino-contrib/auto_locale.rb
|
39
39
|
- lib/padrino-contrib/exception_notifier.rb
|
40
40
|
- lib/padrino-contrib/flash_session.rb
|
41
|
+
- lib/padrino-contrib/helpers/assets_compressor.rb
|
41
42
|
- lib/padrino-contrib/orm/ar/permalink.rb
|
42
43
|
- lib/padrino-contrib/orm/ar/permalink_i18n.rb
|
43
44
|
- lib/padrino-contrib/orm/ar/textile.rb
|
@@ -77,7 +78,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
77
78
|
requirements: []
|
78
79
|
|
79
80
|
rubyforge_project: padrino-contrib
|
80
|
-
rubygems_version: 1.
|
81
|
+
rubygems_version: 1.5.2
|
81
82
|
signing_key:
|
82
83
|
specification_version: 3
|
83
84
|
summary: Contributed plugins and utilities for Padrino Framework
|