sinatra-bootstrap 0.5.0 → 0.6.0
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.
- checksums.yaml +4 -4
- data/lib/sinatra/bootstrap.rb +101 -0
- data/lib/sinatra/bootstrap/helpers.rb +98 -0
- metadata +44 -12
- data/lib/sinatra/twitter-bootstrap.rb +0 -99
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 4efe9ab9b465d643e2218156c7741e7d7c810e15
|
|
4
|
+
data.tar.gz: ddcfe17210716c6501015115910a14cb15f267a2
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 3a65af50b43abf9e6a7aef1fa5adfa7ca9ec2d9a4fd36c9903017bdf1a7298a7427f9a910a1c4d7cdb63783a9133ce368fd913d228ccecc6f846d4cfa0e36401
|
|
7
|
+
data.tar.gz: 58de8ecf912a5e0748ab8784aff4105ac97fed2ce7d93ac14fa84426e4fa1ac3de616fdc2dab6c9e61afd966af673373166ce126805903e8b806e0fb4ff6fe00
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
require 'sinatra/outputbuffer'
|
|
2
|
+
require 'sinatra/bootstrap/helpers'
|
|
3
|
+
|
|
4
|
+
module Sinatra
|
|
5
|
+
module Bootstrap
|
|
6
|
+
module Assets
|
|
7
|
+
|
|
8
|
+
ASSETS = {
|
|
9
|
+
css: [
|
|
10
|
+
['bootstrap.min.css', 'cde1a9a9098238450afb8fccfce94c22fa2743e3']
|
|
11
|
+
],
|
|
12
|
+
default_js: [
|
|
13
|
+
['jquery.min.js', '0511abe9863c2ea7084efa7e24d1d86c5b3974f1'],
|
|
14
|
+
['bootstrap.min.js', '75a42212affc118fef849aba4b9326a7da2acda1']
|
|
15
|
+
],
|
|
16
|
+
legacy_js: [
|
|
17
|
+
['html5.js', 'c9d8ca77abcd9789b91b4c3263f257e1fc1ee103'],
|
|
18
|
+
['respond.min.js', '301398aa216be8655b976ba153d299c2c54a73d4']
|
|
19
|
+
],
|
|
20
|
+
fonts: [
|
|
21
|
+
['glyphicons-halflings-regular.eot', 'd53dff38dfb5c414015dfb31d30a473c95b50904'],
|
|
22
|
+
['glyphicons-halflings-regular.svg', '796e58aedfcfe8a3b0829bc0594f739936a9d7d0'],
|
|
23
|
+
['glyphicons-halflings-regular.ttf', 'c427041d38cd6597ae7e758028ab72756849ec26'],
|
|
24
|
+
['glyphicons-halflings-regular.woff','c707207e52ffe555a36880e9873d146c226e3533']
|
|
25
|
+
]
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
def self.css_tag(url, attrb = '')
|
|
29
|
+
"<link rel='stylesheet' type='text/css' #{attrb} href='#{url}'>\n"
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def self.js_tag(url, attrb = '')
|
|
33
|
+
"<script type='text/javascript' #{attrb} src='#{url}'></script>\n"
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def self.generate_bootstrap_asset_routes(app)
|
|
37
|
+
ASSETS.each do |kind, files|
|
|
38
|
+
files.each do |file|
|
|
39
|
+
name, sha1 = file
|
|
40
|
+
app.get '/%s/%s' % [kind.to_s.split('_').last, name], :provides => name.split('.').last do
|
|
41
|
+
cache_control :public, :must_revalidate, :max_age => 3600
|
|
42
|
+
etag sha1
|
|
43
|
+
File.read(File.join(File.dirname(__FILE__), 'assets', name))
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def self.registered(app)
|
|
50
|
+
generate_bootstrap_asset_routes(app)
|
|
51
|
+
app.helpers Sinatra::OutputBuffer::Helpers
|
|
52
|
+
app.helpers AssetsHelpers
|
|
53
|
+
app.helpers Helpers
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
module AssetsHelpers
|
|
59
|
+
|
|
60
|
+
def bootstrap_css(meta = true, attrb = '')
|
|
61
|
+
output = ''
|
|
62
|
+
output += "<meta name='viewport' content='width=device-width, initial-scale=1.0'>\n" if meta
|
|
63
|
+
|
|
64
|
+
Assets::ASSETS[:css].each do |file, _|
|
|
65
|
+
output += Assets::css_tag url('/css/%s' % file, attrb)
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
output.chomp
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
def bootstrap_js_legacy(attrb = '')
|
|
72
|
+
output = ''
|
|
73
|
+
|
|
74
|
+
Assets::ASSETS[:legacy_js].each do |file, _|
|
|
75
|
+
output += Assets::js_tag url('/js/%s' % file, attrb)
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
"<!--[if lt IE 9]> \n#{output.chomp} \n<![endif]-->"
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
def bootstrap_js_default(attrb = '')
|
|
82
|
+
output = ''
|
|
83
|
+
|
|
84
|
+
Assets::ASSETS[:default_js].each do |file, _|
|
|
85
|
+
output += Assets::js_tag url('/js/%s' % file, attrb)
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
output.chomp
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
def bootstrap_js(attrb = '')
|
|
92
|
+
"#{bootstrap_js_legacy(attrb)} \n#{bootstrap_js_default(attrb)}"
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
def bootstrap(attrb = '')
|
|
96
|
+
"#{bootstrap_css(attrb)} \n#{bootstrap_js_legacy(attrb)} \n#{bootstrap_js_default(attrb)}"
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
end
|
|
100
|
+
end
|
|
101
|
+
end
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
module Sinatra
|
|
2
|
+
module Bootstrap
|
|
3
|
+
module Helpers
|
|
4
|
+
|
|
5
|
+
def cols(tag, attrb = {}, &block)
|
|
6
|
+
cols = attrb[:cols] || ''
|
|
7
|
+
offset = attrb[:offset] || ''
|
|
8
|
+
extr_class = attrb[:class].nil? ? '' : " #{attrb[:class]}"
|
|
9
|
+
|
|
10
|
+
attrb.delete :cols
|
|
11
|
+
attrb.delete :offset
|
|
12
|
+
attrb.delete :class
|
|
13
|
+
|
|
14
|
+
extr_attrb = ''
|
|
15
|
+
attrb.each do |key, value|
|
|
16
|
+
extr_attrb << " #{key}=\"#{value}\""
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
#validate input with regex
|
|
20
|
+
unless /^([abcd]{1}\d+){1,}$/ === cols || /^([abcd]{1}\d+){1,}$/ === offset then return '' end
|
|
21
|
+
|
|
22
|
+
#set invalid to empty
|
|
23
|
+
unless /^([abcd]{1}\d+){1,}$/ === cols then cols = '' end
|
|
24
|
+
unless /^([abcd]{1}\d+){1,}$/ === offset then offset = '' end
|
|
25
|
+
|
|
26
|
+
values = { cols: [], offset: [] }
|
|
27
|
+
|
|
28
|
+
/a{1}(\d+)/.match(cols) do |m|
|
|
29
|
+
values[:cols] << ['xs', m.captures.first]
|
|
30
|
+
end
|
|
31
|
+
/b{1}(\d+)/.match(cols) do |m|
|
|
32
|
+
values[:cols] << ['sm', m.captures.first]
|
|
33
|
+
end
|
|
34
|
+
/c{1}(\d+)/.match(cols) do |m|
|
|
35
|
+
values[:cols] << ['md', m.captures.first]
|
|
36
|
+
end
|
|
37
|
+
/d{1}(\d+)/.match(cols) do |m|
|
|
38
|
+
values[:cols] << ['lg', m.captures.first]
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
/a{1}(\d+)/.match(offset) do |m|
|
|
42
|
+
values[:offset] << ['xs', m.captures.first]
|
|
43
|
+
end
|
|
44
|
+
/b{1}(\d+)/.match(offset) do |m|
|
|
45
|
+
values[:offset] << ['sm', m.captures.first]
|
|
46
|
+
end
|
|
47
|
+
/c{1}(\d+)/.match(offset) do |m|
|
|
48
|
+
values[:offset] << ['md', m.captures.first]
|
|
49
|
+
end
|
|
50
|
+
/d{1}(\d+)/.match(offset) do |m|
|
|
51
|
+
values[:offset] << ['lg', m.captures.first]
|
|
52
|
+
end
|
|
53
|
+
#e.g. values now = { cols: [["xs", "2"], ["sm", "3"]], offset: [["sm", "3"], ["md", "3"]] }
|
|
54
|
+
|
|
55
|
+
classes = ''
|
|
56
|
+
values[:cols].each do |type, number|
|
|
57
|
+
classes << "col-#{type}-#{number} "
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
values[:offset].each do |type, number|
|
|
61
|
+
classes << "col-#{type}-offset-#{number} "
|
|
62
|
+
end
|
|
63
|
+
classes.strip!
|
|
64
|
+
|
|
65
|
+
concat_content "<#{tag} class=\"#{classes}#{extr_class}\"#{extr_attrb}>"
|
|
66
|
+
concat_content "#{ capture_html &block }</#{tag}>"
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
def container(tag, attrb = {}, &block)
|
|
70
|
+
extr_class = attrb[:class].nil? ? '' : " #{attrb[:class]}"
|
|
71
|
+
|
|
72
|
+
attrb.delete :class
|
|
73
|
+
|
|
74
|
+
extr_attrb = ''
|
|
75
|
+
attrb.each do |key, value|
|
|
76
|
+
extr_attrb << " #{key}=\"#{value}\""
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
concat_content "<#{tag} class=\"container#{extr_class}\"#{extr_attrb}>"
|
|
80
|
+
concat_content "#{ capture_html &block }</#{tag}>"
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
def row(tag, attrb = {}, &block)
|
|
84
|
+
extr_class = attrb[:class].nil? ? '' : " #{attrb[:class]}"
|
|
85
|
+
|
|
86
|
+
attrb.delete :class
|
|
87
|
+
|
|
88
|
+
extr_attrb = ''
|
|
89
|
+
attrb.each do |key, value|
|
|
90
|
+
extr_attrb << " #{key}=\"#{value}\""
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
concat_content "<#{tag} class=\"row#{extr_class}\"#{extr_attrb}>"
|
|
94
|
+
concat_content "#{ capture_html &block }</#{tag}>"
|
|
95
|
+
end
|
|
96
|
+
end
|
|
97
|
+
end
|
|
98
|
+
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: sinatra-bootstrap
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.6.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Michal Fojtik
|
|
@@ -9,28 +9,60 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date: 2013-10-
|
|
13
|
-
dependencies:
|
|
14
|
-
|
|
12
|
+
date: 2013-10-20 00:00:00.000000000 Z
|
|
13
|
+
dependencies:
|
|
14
|
+
- !ruby/object:Gem::Dependency
|
|
15
|
+
type: :runtime
|
|
16
|
+
name: sinatra
|
|
17
|
+
prerelease: false
|
|
18
|
+
requirement: !ruby/object:Gem::Requirement
|
|
19
|
+
requirements:
|
|
20
|
+
- - ">="
|
|
21
|
+
- !ruby/object:Gem::Version
|
|
22
|
+
version: '1.0'
|
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
24
|
+
requirements:
|
|
25
|
+
- - ">="
|
|
26
|
+
- !ruby/object:Gem::Version
|
|
27
|
+
version: '1.0'
|
|
28
|
+
- !ruby/object:Gem::Dependency
|
|
29
|
+
type: :runtime
|
|
30
|
+
name: sinatra-outputbuffer
|
|
31
|
+
prerelease: false
|
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
|
33
|
+
requirements:
|
|
34
|
+
- - ">="
|
|
35
|
+
- !ruby/object:Gem::Version
|
|
36
|
+
version: '0'
|
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
38
|
+
requirements:
|
|
39
|
+
- - ">="
|
|
40
|
+
- !ruby/object:Gem::Version
|
|
41
|
+
version: '0'
|
|
42
|
+
description: This gem is a fork of sinatra-twitter-bootstrap remade for bootstrap
|
|
43
|
+
3. Usable, though still somewhat of a work-in-progress. Check the homepage for details.
|
|
15
44
|
email: dood-ad@outlook.com
|
|
16
45
|
executables: []
|
|
17
46
|
extensions: []
|
|
18
47
|
extra_rdoc_files:
|
|
19
48
|
- README.md
|
|
20
49
|
files:
|
|
21
|
-
- lib/sinatra/
|
|
50
|
+
- lib/sinatra/bootstrap.rb
|
|
22
51
|
- README.md
|
|
52
|
+
- lib/sinatra/bootstrap/helpers.rb
|
|
53
|
+
- lib/sinatra/assets/glyphicons-halflings-regular.svg
|
|
23
54
|
- lib/sinatra/assets/html5.js
|
|
55
|
+
- lib/sinatra/assets/glyphicons-halflings-regular.woff
|
|
56
|
+
- lib/sinatra/assets/jquery.min.js
|
|
24
57
|
- lib/sinatra/assets/bootstrap.min.css
|
|
25
58
|
- lib/sinatra/assets/bootstrap.min.js
|
|
26
59
|
- lib/sinatra/assets/glyphicons-halflings-regular.eot
|
|
27
|
-
- lib/sinatra/assets/respond.min.js
|
|
28
60
|
- lib/sinatra/assets/glyphicons-halflings-regular.ttf
|
|
29
|
-
- lib/sinatra/assets/
|
|
30
|
-
- lib/sinatra/assets/glyphicons-halflings-regular.svg
|
|
31
|
-
- lib/sinatra/assets/jquery.min.js
|
|
61
|
+
- lib/sinatra/assets/respond.min.js
|
|
32
62
|
homepage: http://github.com/mateusmedeiros/sinatra-bootstrap
|
|
33
|
-
licenses:
|
|
63
|
+
licenses:
|
|
64
|
+
- Apache-2.0
|
|
65
|
+
- WTFPL
|
|
34
66
|
metadata: {}
|
|
35
67
|
post_install_message:
|
|
36
68
|
rdoc_options: []
|
|
@@ -38,12 +70,12 @@ require_paths:
|
|
|
38
70
|
- lib
|
|
39
71
|
required_ruby_version: !ruby/object:Gem::Requirement
|
|
40
72
|
requirements:
|
|
41
|
-
- -
|
|
73
|
+
- - ">="
|
|
42
74
|
- !ruby/object:Gem::Version
|
|
43
75
|
version: '0'
|
|
44
76
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
45
77
|
requirements:
|
|
46
|
-
- -
|
|
78
|
+
- - ">="
|
|
47
79
|
- !ruby/object:Gem::Version
|
|
48
80
|
version: '0'
|
|
49
81
|
requirements: []
|
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
module Sinatra
|
|
2
|
-
module Twitter
|
|
3
|
-
module Bootstrap
|
|
4
|
-
|
|
5
|
-
module Assets
|
|
6
|
-
|
|
7
|
-
ASSETS = {
|
|
8
|
-
css: [
|
|
9
|
-
['bootstrap.min.css', 'cde1a9a9098238450afb8fccfce94c22fa2743e3']
|
|
10
|
-
],
|
|
11
|
-
default_js: [
|
|
12
|
-
['jquery.min.js', '0511abe9863c2ea7084efa7e24d1d86c5b3974f1'],
|
|
13
|
-
['bootstrap.min.js', '75a42212affc118fef849aba4b9326a7da2acda1']
|
|
14
|
-
],
|
|
15
|
-
legacy_js: [
|
|
16
|
-
['html5.js', 'c9d8ca77abcd9789b91b4c3263f257e1fc1ee103'],
|
|
17
|
-
['respond.min.js', '301398aa216be8655b976ba153d299c2c54a73d4']
|
|
18
|
-
],
|
|
19
|
-
fonts: [
|
|
20
|
-
['glyphicons-halflings-regular.eot', 'd53dff38dfb5c414015dfb31d30a473c95b50904'],
|
|
21
|
-
['glyphicons-halflings-regular.svg', '796e58aedfcfe8a3b0829bc0594f739936a9d7d0'],
|
|
22
|
-
['glyphicons-halflings-regular.ttf', 'c427041d38cd6597ae7e758028ab72756849ec26'],
|
|
23
|
-
['glyphicons-halflings-regular.woff','c707207e52ffe555a36880e9873d146c226e3533']
|
|
24
|
-
]
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
def self.css_tag(url, attrb = '')
|
|
28
|
-
"<link rel='stylesheet' type='text/css' #{attrb} href='#{url}'>\n"
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
def self.js_tag(url, attrb = '')
|
|
32
|
-
"<script type='text/javascript' #{attrb} src='#{url}'></script>\n"
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
def self.generate_bootstrap_asset_routes(app)
|
|
36
|
-
ASSETS.each do |kind, files|
|
|
37
|
-
files.each do |file|
|
|
38
|
-
name, sha1 = file
|
|
39
|
-
app.get '/%s/%s' % [kind.to_s.split('_').last, name], :provides => name.split('.').last do
|
|
40
|
-
cache_control :public, :must_revalidate, :max_age => 3600
|
|
41
|
-
etag sha1
|
|
42
|
-
File.read(File.join(File.dirname(__FILE__), 'assets', name))
|
|
43
|
-
end
|
|
44
|
-
end
|
|
45
|
-
end
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
def self.registered(app)
|
|
49
|
-
generate_bootstrap_asset_routes(app)
|
|
50
|
-
app.helpers AssetsHelper
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
module AssetsHelper
|
|
56
|
-
|
|
57
|
-
def bootstrap_css(meta = true, attrb = '')
|
|
58
|
-
output = ''
|
|
59
|
-
output += "<meta name='viewport' content='width=device-width, initial-scale=1.0'>\n" if meta
|
|
60
|
-
|
|
61
|
-
Assets::ASSETS[:css].each do |file, _|
|
|
62
|
-
output += Assets::css_tag url('/css/%s' % file, attrb)
|
|
63
|
-
end
|
|
64
|
-
|
|
65
|
-
output.chomp
|
|
66
|
-
end
|
|
67
|
-
|
|
68
|
-
def bootstrap_js_legacy(attrb = '')
|
|
69
|
-
output = ''
|
|
70
|
-
|
|
71
|
-
Assets::ASSETS[:legacy_js].each do |file, _|
|
|
72
|
-
output += Assets::js_tag url('/js/%s' % file, attrb)
|
|
73
|
-
end
|
|
74
|
-
|
|
75
|
-
"<!--[if lt IE 9]> \n#{output.chomp} \n<![endif]-->"
|
|
76
|
-
end
|
|
77
|
-
|
|
78
|
-
def bootstrap_js_default(attrb = '')
|
|
79
|
-
output = ''
|
|
80
|
-
|
|
81
|
-
Assets::ASSETS[:default_js].each do |file, _|
|
|
82
|
-
output += Assets::js_tag url('/js/%s' % file, attrb)
|
|
83
|
-
end
|
|
84
|
-
|
|
85
|
-
output.chomp
|
|
86
|
-
end
|
|
87
|
-
|
|
88
|
-
def bootstrap_js(attrb = '')
|
|
89
|
-
"#{bootstrap_js_legacy(attrb)} \n#{bootstrap_js_default(attrb)}"
|
|
90
|
-
end
|
|
91
|
-
|
|
92
|
-
def bootstrap(attrb = '')
|
|
93
|
-
"#{bootstrap_css(attrb)} \n#{bootstrap_js_legacy(attrb)} \n#{bootstrap_js_default(attrb)}"
|
|
94
|
-
end
|
|
95
|
-
|
|
96
|
-
end
|
|
97
|
-
end
|
|
98
|
-
end
|
|
99
|
-
end
|