padrino-contrib 0.1.0 → 0.1.1

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.

@@ -7,6 +7,7 @@ module Padrino
7
7
 
8
8
  module Helpers
9
9
  autoload :AssetsCompressor, 'padrino-contrib/helpers/assets_compressor.rb'
10
+ autoload :JQuery, 'padrino-contrib/helpers/jquery.rb'
10
11
  end # Helpers
11
12
  end # Contrib
12
13
  end # Padrino
@@ -0,0 +1,62 @@
1
+ module Padrino
2
+ module Contrib
3
+ module Helpers
4
+ ##
5
+ # Download in your public/javascript dir the latest jquery lib.
6
+ #
7
+ # ==== Usage:
8
+ #
9
+ # javascript_include_tag_jquery :cache => :lib, :ui => true, :i18n => true
10
+ #
11
+ module JQuery
12
+ def self.registered(app)
13
+ app.helpers Helpers
14
+ end
15
+
16
+ module Helpers
17
+ def javascript_include_tag_jquery(options={})
18
+ libs = ["http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"]
19
+
20
+ if options.delete(:ui)
21
+ libs << "http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.14/jquery-ui.min.js"
22
+ end
23
+
24
+ if options.delete(:i18n)
25
+ libs << "http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.6/i18n/jquery-ui-i18n.min.js"
26
+ end
27
+
28
+ if cache = options.delete(:cache)
29
+ cache = 'jquery' if cache.is_a?(TrueClass)
30
+ lib = cache.to_s
31
+ path = Padrino.root("public", uri_root_path('javascripts', lib))
32
+ path += ".js" unless path =~ /\.js$/
33
+
34
+ unless File.exist?(path)
35
+ began_at = Time.now
36
+ require 'open-uri' unless defined?(OpenURI)
37
+ sources = libs.map do |l|
38
+ source = open(l).read
39
+ # Removes extra comments
40
+ if cs = source =~ /\/\*\!/
41
+ cr = source.slice(cs, source.length)
42
+ ce = cr =~ /\*\//
43
+ cr = source.slice(cs, ce+2)
44
+ source.sub!(cr,'')
45
+ end
46
+ # Removes empty lines
47
+ source.each_line.reject { |l| l.strip == "" }.join
48
+ end
49
+ File.open(path, "w") { |f| f.write sources.join("\n") }
50
+ logger.debug "JQuery Cached (%0.2fms) %s" % [Time.now-began_at, path] if defined?(logger)
51
+ end
52
+
53
+ libs = lib
54
+ end
55
+
56
+ javascript_include_tag(libs)
57
+ end
58
+ end # Helpers
59
+ end # JQuery
60
+ end # Helpers
61
+ end # Contrib
62
+ end # Padrino
@@ -1,5 +1,5 @@
1
1
  module Padrino
2
2
  module Contrib
3
- VERSION = "0.1.0"
3
+ VERSION = "0.1.1"
4
4
  end
5
5
  end
@@ -13,7 +13,8 @@ describe 'Autoload' do
13
13
  gsub(/\/|-/, "::").
14
14
  gsub(/_(.)/) { $1.upcase }.
15
15
  gsub(/::(.)/) { "::" + $1.upcase }.
16
- gsub(/version/i, 'VERSION') # this is a constant
16
+ gsub(/version/i, 'VERSION'). # this is a constant
17
+ gsub(/Jquery/, 'JQuery')
17
18
 
18
19
  it(klass) { eval("#{klass}").should be_true }
19
20
  end
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: 27
4
+ hash: 25
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 0
10
- version: 0.1.0
9
+ - 1
10
+ version: 0.1.1
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-07-22 00:00:00 +02:00
20
+ date: 2011-07-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/jquery.rb
43
44
  - lib/padrino-contrib/orm/active_record/permalink.rb
44
45
  - lib/padrino-contrib/orm/active_record/permalink_i18n.rb
45
46
  - lib/padrino-contrib/orm/active_record/textile.rb