pubba 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +8 -0
- data/README.md +34 -12
- data/lib/sinatra/pubba/assets/configuration.rb +1 -1
- data/lib/sinatra/pubba/html/helpers.rb +10 -4
- data/lib/sinatra/pubba/page.rb +75 -14
- data/lib/sinatra/pubba/site.rb +10 -21
- data/lib/sinatra/pubba/version.rb +1 -1
- data/test/helper.rb +3 -3
- data/test/pubba/assets/test_configuration.rb +4 -2
- data/test/pubba/html/test_helpers.rb +6 -4
- data/test/pubba/test_page.rb +128 -0
- data/test/pubba/test_site.rb +0 -13
- data/test/sinatra/app/assets/javascripts/custom/lightbox.js +3 -0
- data/test/sinatra/app/assets/javascripts/custom/{track.js → tracker.js} +0 -0
- data/test/sinatra/app/assets/javascripts/third-party/backbone.js +3 -0
- data/test/sinatra/app/assets/javascripts/third-party/modernizr.js +3 -0
- data/test/sinatra/app/assets/stylesheets/custom/large.css +1 -0
- data/test/sinatra/app/assets/stylesheets/custom/small.css +1 -0
- data/test/sinatra/config/pubba.yml +31 -12
- metadata +21 -17
- data/test/sinatra/app/assets/javascripts/third-party/jq.js +0 -3
- data/test/sinatra/app/assets/javascripts/third-party/jqc.js +0 -3
data/CHANGES
ADDED
data/README.md
CHANGED
@@ -6,10 +6,10 @@ pubba is a Sinatra extension designed to help you manage your site. It uses [Spr
|
|
6
6
|
|
7
7
|
This extension is under heavy, heavy development and is subject to massive changes over the next week or so.
|
8
8
|
|
9
|
+
__I do not consider this project production ready at this time. It will be soon though.__
|
10
|
+
|
9
11
|
TODO:
|
10
12
|
|
11
|
-
* Support 3rd part script tags in pubba.yml
|
12
|
-
* Add support for media queries on style definitions. This will obviously change the current pubba.yml format.
|
13
13
|
* Remove requirement for placing of scripts/styles in subdirectories. For instance, the convention now is scripts would be in subdirs like javascripts/custom and javscripts/third-party. The only scripts/styles in the root dir are those generated by this extension.
|
14
14
|
* Compress the combined assets
|
15
15
|
* More tests!
|
@@ -23,7 +23,7 @@ If you've ever had to deal with an audit department, you understand some of the
|
|
23
23
|
|
24
24
|
Any process that involves changing code between environments, even in an automated fashion, is great fodder for the audit machine. This extension makes sure the javascript and css you work with in development is the same as it will be in production.
|
25
25
|
|
26
|
-
This does
|
26
|
+
This does result in the use of a cache bursting query parameter to be added to the url instead of the digest per asset approach. While the digest approach is much more accurate it complicates using a commit/tag to completely represent the deployment contents.
|
27
27
|
|
28
28
|
As mentioned, code organization is another focus of Pubba. The config file __pubba.yml__ uses the global section to clearly state which assets should be on all pages. In addition, when using R18n, Pubba gives you access through a single page object.
|
29
29
|
|
@@ -80,23 +80,45 @@ Next up is creating the all important __pubba.yml__ config file:
|
|
80
80
|
|
81
81
|
global:
|
82
82
|
styles:
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
83
|
+
all:
|
84
|
+
urls:
|
85
|
+
- "http://twitter.github.com/bootstrap/1.4.0/bootstrap.min.css"
|
86
|
+
- "custom/global"
|
87
|
+
phone:
|
88
|
+
media: "only screen and (min-width: 480px)"
|
89
|
+
urls:
|
90
|
+
- "custom/large"
|
91
|
+
desktop:
|
92
|
+
media: "only screen and (max-width: 480px)"
|
93
|
+
urls:
|
94
|
+
- "custom/small"
|
95
|
+
scripts:
|
96
|
+
head:
|
97
|
+
- "https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"
|
98
|
+
- "third-party/modernizr"
|
99
|
+
body:
|
100
|
+
- "https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/jquery-ui.min.js"
|
101
|
+
- "third-party/backbone"
|
102
|
+
- "custom/app"
|
103
|
+
- "custom/tracker"
|
90
104
|
|
91
105
|
# Home page configuration
|
92
106
|
home:
|
93
107
|
styles:
|
94
|
-
|
108
|
+
all:
|
109
|
+
urls:
|
110
|
+
- "custom/home"
|
95
111
|
|
96
112
|
# Search results page configuration
|
97
113
|
search:
|
98
114
|
styles:
|
99
|
-
|
115
|
+
all:
|
116
|
+
urls:
|
117
|
+
- "custom/search"
|
118
|
+
scripts:
|
119
|
+
body:
|
120
|
+
- "custom/lightbox"
|
121
|
+
|
100
122
|
|
101
123
|
The config file is referencing the javascripts and stylesheets located in the `asset_folder`.
|
102
124
|
|
@@ -3,11 +3,17 @@ module Sinatra
|
|
3
3
|
module HTML
|
4
4
|
module Helpers
|
5
5
|
def page_head_tags
|
6
|
-
|
6
|
+
@page.head_tags.collect do |tag|
|
7
|
+
type = tag.delete(:tag)
|
8
|
+
tag_content(type, '', tag)
|
9
|
+
end
|
7
10
|
end
|
8
11
|
|
9
12
|
def page_body_tags
|
10
|
-
|
13
|
+
@page.body_tags.collect do |tag|
|
14
|
+
type = tag.delete(:tag)
|
15
|
+
tag_content(type, '', tag)
|
16
|
+
end
|
11
17
|
end
|
12
18
|
|
13
19
|
def burst(url)
|
@@ -23,8 +29,8 @@ module Sinatra
|
|
23
29
|
def tag_attrs(attrs)
|
24
30
|
return '' if attrs.empty?
|
25
31
|
|
26
|
-
return " " + attrs.collect do |k
|
27
|
-
%|#{k}="#{
|
32
|
+
return " " + attrs.keys.sort.collect do |k|
|
33
|
+
%|#{k}="#{attrs[k]}"|
|
28
34
|
end.join(' ')
|
29
35
|
end
|
30
36
|
end
|
data/lib/sinatra/pubba/page.rb
CHANGED
@@ -2,23 +2,42 @@ module Sinatra
|
|
2
2
|
module Pubba
|
3
3
|
class Page
|
4
4
|
attr_accessor :name
|
5
|
-
attr_reader :assets
|
5
|
+
attr_reader :assets, :head_tags, :body_tags
|
6
6
|
|
7
7
|
def initialize(name, global_configuration = {})
|
8
8
|
@name = name
|
9
|
-
@assets = {}
|
9
|
+
@assets = {"styles" => {}, "scripts" => {}}
|
10
|
+
@head_tags = []
|
11
|
+
@body_tags = []
|
10
12
|
|
11
|
-
|
12
|
-
|
13
|
+
global_configuration["styles"].each do |key, value|
|
14
|
+
@assets["styles"][key] = value.dup
|
13
15
|
end
|
16
|
+
|
17
|
+
@assets["scripts"]["head"] = global_configuration["scripts"]["head"] || []
|
18
|
+
@assets["scripts"]["body"] = global_configuration["scripts"]["body"] || []
|
14
19
|
end
|
15
20
|
|
16
|
-
def add_asset(
|
17
|
-
|
21
|
+
def add_asset(type, section)
|
22
|
+
if type == "styles"
|
23
|
+
section.each do |section_name, hsh|
|
24
|
+
hsh.each do |key, value|
|
25
|
+
if key == "urls"
|
26
|
+
@assets[type][section_name][key] += value
|
27
|
+
else
|
28
|
+
@assets[type][section_name][key] = value
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
else
|
33
|
+
@assets["scripts"]["head"] += section["head"] if section["head"]
|
34
|
+
@assets["scripts"]["body"] += section["body"] if section["body"]
|
35
|
+
end
|
18
36
|
end
|
19
37
|
|
20
38
|
def assetize
|
21
|
-
|
39
|
+
create_style_assets
|
40
|
+
create_script_assets
|
22
41
|
end
|
23
42
|
|
24
43
|
def method_missing(meth, *args)
|
@@ -36,15 +55,57 @@ module Sinatra
|
|
36
55
|
array.each{|ele| scripts << ele }
|
37
56
|
end
|
38
57
|
|
39
|
-
def
|
40
|
-
|
41
|
-
|
58
|
+
def create_style_assets
|
59
|
+
@assets["styles"].each do |part, hsh|
|
60
|
+
content = []
|
61
|
+
@assets["styles"][part]["urls"].each do |url|
|
62
|
+
add_style_tag(part, hsh, url)
|
63
|
+
next if url.start_with?("http")
|
64
|
+
content << "//= require #{url}.css"
|
65
|
+
end
|
66
|
+
write_asset(Site.style_asset_folder, part, "css", content.compact.join("\n"))
|
67
|
+
end
|
68
|
+
end
|
42
69
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
70
|
+
def create_script_assets
|
71
|
+
["head", "body"].each do |part|
|
72
|
+
content = []
|
73
|
+
@assets["scripts"][part].each do |url|
|
74
|
+
add_script_tag(part, url)
|
75
|
+
next if url.start_with?("http")
|
76
|
+
content << "//= require #{url}.js"
|
47
77
|
end
|
78
|
+
write_asset(Site.script_asset_folder, part, "js", content.compact.join("\n"))
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
def add_style_tag(part, hsh, url)
|
83
|
+
h = { tag: 'link', type: 'text/css', rel: 'stylesheet' }
|
84
|
+
h[:media] = hsh['media'] if hsh['media']
|
85
|
+
h[:href] = url.start_with?("http") ? url : "/stylesheets/#{name}-#{part}.css"
|
86
|
+
|
87
|
+
maybe_add_tag(@head_tags, h, :href)
|
88
|
+
end
|
89
|
+
|
90
|
+
def add_script_tag(part, url)
|
91
|
+
hsh = { tag: 'script', type: "text/javascript" }
|
92
|
+
hsh[:src] = url.start_with?("http") ? url : "/javascripts/#{name}-#{part}.js"
|
93
|
+
|
94
|
+
tag_set = (part == "head") ? @head_tags : @body_tags
|
95
|
+
maybe_add_tag(tag_set, hsh, :src)
|
96
|
+
end
|
97
|
+
|
98
|
+
def maybe_add_tag(tag_set, hsh, key)
|
99
|
+
found = false
|
100
|
+
tag_set.each{|tag| found = true if tag[key] == hsh[key]}
|
101
|
+
tag_set << hsh unless found
|
102
|
+
end
|
103
|
+
|
104
|
+
def write_asset(dir, type, ext, content)
|
105
|
+
fname = File.join(dir, "#{name}-#{type}.#{ext}")
|
106
|
+
File.open(fname, 'w') do |f|
|
107
|
+
f.write Site.disclaimer
|
108
|
+
f.write content
|
48
109
|
end
|
49
110
|
end
|
50
111
|
end # Page
|
data/lib/sinatra/pubba/site.rb
CHANGED
@@ -6,15 +6,11 @@ module Sinatra
|
|
6
6
|
module Pubba
|
7
7
|
module Site
|
8
8
|
extend self
|
9
|
-
attr_accessor :global_asset_configuration, :asset_handler
|
10
|
-
|
11
|
-
attr_reader :asset_types
|
12
9
|
attr_reader :script_asset_folder, :style_asset_folder
|
13
10
|
attr_reader :script_public_folder, :style_public_folder
|
14
11
|
|
15
|
-
attr_reader :
|
16
|
-
|
17
|
-
attr_reader :locale, :r18n_folder, :r18n_locale
|
12
|
+
attr_reader :global_asset_configuration, :asset_handler
|
13
|
+
attr_reader :disclaimer, :locale, :r18n_folder, :r18n_locale
|
18
14
|
|
19
15
|
|
20
16
|
def configure(app)
|
@@ -36,12 +32,12 @@ module Sinatra
|
|
36
32
|
@global_asset_configuration = asset_configuration.global_config!
|
37
33
|
|
38
34
|
# Process the remaining @pubba_config sections
|
39
|
-
asset_configuration.process do |
|
40
|
-
|
35
|
+
asset_configuration.process do |p, config|
|
36
|
+
add_page(p, config).assetize
|
41
37
|
end
|
42
38
|
|
43
39
|
# Write assets to public_folder
|
44
|
-
compile_assets(app)
|
40
|
+
# compile_assets(app)
|
45
41
|
end
|
46
42
|
|
47
43
|
|
@@ -67,10 +63,6 @@ module Sinatra
|
|
67
63
|
@script_asset_folder = File.join(settings.asset_folder, 'javascripts')
|
68
64
|
@style_asset_folder = File.join(settings.asset_folder, 'stylesheets')
|
69
65
|
|
70
|
-
@asset_types = {'styles' => style_asset_folder,
|
71
|
-
'head_scripts' => script_asset_folder,
|
72
|
-
'body_scripts' => script_asset_folder}
|
73
|
-
|
74
66
|
@disclaimer = "// This file is automatically generated from the contents\n// in #{settings.pubba_config}\n//\n"
|
75
67
|
end
|
76
68
|
|
@@ -106,14 +98,13 @@ module Sinatra
|
|
106
98
|
@pages ||= {}
|
107
99
|
end
|
108
100
|
|
109
|
-
def add_page(name,
|
110
|
-
|
101
|
+
def add_page(name, hsh)
|
102
|
+
p = Page.new(name, @global_asset_configuration)
|
111
103
|
|
112
|
-
|
113
|
-
|
114
|
-
end
|
104
|
+
p.add_asset('styles', hsh['styles']) if hsh['styles']
|
105
|
+
p.add_asset('scripts', hsh['scripts']) if hsh['scripts']
|
115
106
|
|
116
|
-
pages[name] =
|
107
|
+
pages[name] = p
|
117
108
|
end
|
118
109
|
|
119
110
|
private
|
@@ -129,8 +120,6 @@ module Sinatra
|
|
129
120
|
asset.save_as "#{to_folder}/#{File.basename(file)}"
|
130
121
|
end
|
131
122
|
end
|
132
|
-
|
133
|
-
@global_asset_configuration = {}
|
134
123
|
end # Site
|
135
124
|
end # Pubba
|
136
125
|
end # Sinatra
|
data/test/helper.rb
CHANGED
@@ -42,12 +42,12 @@ class TestPubba < MiniTest::Unit::TestCase
|
|
42
42
|
|
43
43
|
register Sinatra::Pubba
|
44
44
|
|
45
|
-
get('/home-page-head-tags') do
|
45
|
+
get('/home-page-head-tags') do
|
46
46
|
@page = Sinatra::Pubba::Site.page('home');
|
47
47
|
page_head_tags
|
48
48
|
end
|
49
|
-
|
50
|
-
get('/home-page-body-tags') do
|
49
|
+
|
50
|
+
get('/home-page-body-tags') do
|
51
51
|
@page = Sinatra::Pubba::Site.page('home');
|
52
52
|
page_body_tags
|
53
53
|
end
|
@@ -6,12 +6,14 @@ class TestPubbaAssetsConfiguration < TestPubba
|
|
6
6
|
end
|
7
7
|
|
8
8
|
def test_yaml_is_initialized
|
9
|
-
hsh = {"global"=>{"styles"=>["custom/global"], "
|
9
|
+
hsh = {"global"=>{"styles"=>{"all"=>{"urls"=>["http://twitter.github.com/bootstrap/1.4.0/bootstrap.min.css", "custom/global"]}, "phone"=>{"media"=>"only screen and (max-width: 480px)", "urls"=>["custom/small"]}, "desktop"=>{"media"=>"only screen and (min-width: 480px)", "urls"=>["custom/large"]}}, "scripts"=>{"head"=>["https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js", "third-party/modernizr"], "body"=>["https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/jquery-ui.min.js", "third-party/backbone", "custom/app", "custom/tracker"]}}, "home"=>{"styles"=>{"all"=>{"urls"=>["custom/home"]}}}, "search"=>{"styles"=>{"all"=>{"urls"=>["custom/search", "third-party/widget"]}}, "scripts"=>{"body"=>["custom/lightbox"]}}}
|
10
|
+
|
10
11
|
assert_equal hsh, @config.yaml
|
11
12
|
end
|
12
13
|
|
13
14
|
def test_global_config
|
14
|
-
hsh = {"styles"=>["custom/global"], "
|
15
|
+
hsh = {"styles"=>{"all"=>{"urls"=>["http://twitter.github.com/bootstrap/1.4.0/bootstrap.min.css", "custom/global"]}, "phone"=>{"media"=>"only screen and (max-width: 480px)", "urls"=>["custom/small"]}, "desktop"=>{"media"=>"only screen and (min-width: 480px)", "urls"=>["custom/large"]}}, "scripts"=>{"head"=>["https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js", "third-party/modernizr"], "body"=>["https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/jquery-ui.min.js", "third-party/backbone", "custom/app", "custom/tracker"]}}
|
16
|
+
|
15
17
|
assert_equal hsh, @config.global_config!
|
16
18
|
|
17
19
|
assert_nil @config.yaml["global"]
|
@@ -5,14 +5,16 @@ class TestPubbaHTMLHelper < TestPubba
|
|
5
5
|
include Sinatra::Pubba::HTML::Helpers
|
6
6
|
|
7
7
|
def test_home_page_head_tags
|
8
|
-
res = get('/home-page-head-tags').body
|
9
|
-
str = %|<link href="/stylesheets/home-
|
8
|
+
res = get('/home-page-head-tags').body
|
9
|
+
str = %|<link href="http://twitter.github.com/bootstrap/1.4.0/bootstrap.min.css" rel="stylesheet" type="text/css"></link><link href="/stylesheets/home-all.css" rel="stylesheet" type="text/css"></link><link href="/stylesheets/home-phone.css" media="only screen and (max-width: 480px)" rel="stylesheet" type="text/css"></link><link href="/stylesheets/home-desktop.css" media="only screen and (min-width: 480px)" rel="stylesheet" type="text/css"></link><script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"></script><script src="/javascripts/home-head.js" type="text/javascript"></script>|
|
10
|
+
|
10
11
|
assert_equal str, res
|
11
12
|
end
|
12
13
|
|
13
14
|
def test_home_page_body_tags
|
14
|
-
res = get('/home-page-body-tags').body
|
15
|
-
str = %|<script src="/javascripts/home-body.js
|
15
|
+
res = get('/home-page-body-tags').body
|
16
|
+
str = %|<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/jquery-ui.min.js" type="text/javascript"></script><script src="/javascripts/home-body.js" type="text/javascript"></script>|
|
17
|
+
|
16
18
|
assert_equal str, res
|
17
19
|
end
|
18
20
|
end
|
data/test/pubba/test_page.rb
CHANGED
@@ -14,4 +14,132 @@ class TestPubbaPage < TestPubba
|
|
14
14
|
assert_equal 'Search title', page.title
|
15
15
|
assert_equal 'Logout', page.logout_link
|
16
16
|
end
|
17
|
+
|
18
|
+
def test_home_all_css_asset
|
19
|
+
css = File.open( File.join(R.asset_folder, 'stylesheets', 'home-all.css')){|f| f.read }
|
20
|
+
contents = <<TEXT
|
21
|
+
// This file is automatically generated from the contents
|
22
|
+
// in #{R.pubba_config_file}
|
23
|
+
//
|
24
|
+
//= require custom/global.css
|
25
|
+
//= require custom/home.css
|
26
|
+
TEXT
|
27
|
+
|
28
|
+
assert_equal contents.chomp, css
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_home_phone_css_asset
|
32
|
+
css = File.open( File.join(R.asset_folder, 'stylesheets', 'home-phone.css')){|f| f.read }
|
33
|
+
contents = <<TEXT
|
34
|
+
// This file is automatically generated from the contents
|
35
|
+
// in #{R.pubba_config_file}
|
36
|
+
//
|
37
|
+
//= require custom/small.css
|
38
|
+
TEXT
|
39
|
+
|
40
|
+
assert_equal contents.chomp, css
|
41
|
+
end
|
42
|
+
|
43
|
+
def test_home_desktop_css_asset
|
44
|
+
css = File.open( File.join(R.asset_folder, 'stylesheets', 'home-desktop.css')){|f| f.read }
|
45
|
+
contents = <<TEXT
|
46
|
+
// This file is automatically generated from the contents
|
47
|
+
// in #{R.pubba_config_file}
|
48
|
+
//
|
49
|
+
//= require custom/large.css
|
50
|
+
TEXT
|
51
|
+
|
52
|
+
assert_equal contents.chomp, css
|
53
|
+
end
|
54
|
+
|
55
|
+
def test_search_all_css_asset
|
56
|
+
css = File.open( File.join(R.asset_folder, 'stylesheets', 'search-all.css')){|f| f.read }
|
57
|
+
contents = <<TEXT
|
58
|
+
// This file is automatically generated from the contents
|
59
|
+
// in #{R.pubba_config_file}
|
60
|
+
//
|
61
|
+
//= require custom/global.css
|
62
|
+
//= require custom/search.css
|
63
|
+
//= require third-party/widget.css
|
64
|
+
TEXT
|
65
|
+
|
66
|
+
assert_equal contents.chomp, css
|
67
|
+
end
|
68
|
+
|
69
|
+
def test_search_phone_css_asset
|
70
|
+
css = File.open( File.join(R.asset_folder, 'stylesheets', 'search-phone.css')){|f| f.read }
|
71
|
+
contents = <<TEXT
|
72
|
+
// This file is automatically generated from the contents
|
73
|
+
// in #{R.pubba_config_file}
|
74
|
+
//
|
75
|
+
//= require custom/small.css
|
76
|
+
TEXT
|
77
|
+
|
78
|
+
assert_equal contents.chomp, css
|
79
|
+
end
|
80
|
+
|
81
|
+
def test_search_desktop_css_asset
|
82
|
+
css = File.open( File.join(R.asset_folder, 'stylesheets', 'search-desktop.css')){|f| f.read }
|
83
|
+
contents = <<TEXT
|
84
|
+
// This file is automatically generated from the contents
|
85
|
+
// in #{R.pubba_config_file}
|
86
|
+
//
|
87
|
+
//= require custom/large.css
|
88
|
+
TEXT
|
89
|
+
|
90
|
+
assert_equal contents.chomp, css
|
91
|
+
end
|
92
|
+
|
93
|
+
def test_home_head_js_asset
|
94
|
+
js = File.open( File.join(R.asset_folder, 'javascripts', 'home-head.js')){|f| f.read }
|
95
|
+
contents = <<TEXT
|
96
|
+
// This file is automatically generated from the contents
|
97
|
+
// in #{R.pubba_config_file}
|
98
|
+
//
|
99
|
+
//= require third-party/modernizr.js
|
100
|
+
TEXT
|
101
|
+
|
102
|
+
assert_equal contents.chomp, js
|
103
|
+
end
|
104
|
+
|
105
|
+
def test_home_body_js_asset
|
106
|
+
js = File.open( File.join(R.asset_folder, 'javascripts', 'home-body.js')){|f| f.read }
|
107
|
+
contents = <<TEXT
|
108
|
+
// This file is automatically generated from the contents
|
109
|
+
// in #{R.pubba_config_file}
|
110
|
+
//
|
111
|
+
//= require third-party/backbone.js
|
112
|
+
//= require custom/app.js
|
113
|
+
//= require custom/tracker.js
|
114
|
+
TEXT
|
115
|
+
|
116
|
+
assert_equal contents.chomp, js
|
117
|
+
end
|
118
|
+
|
119
|
+
def test_search_head_js_asset
|
120
|
+
js = File.open( File.join(R.asset_folder, 'javascripts', 'search-head.js')){|f| f.read }
|
121
|
+
contents = <<TEXT
|
122
|
+
// This file is automatically generated from the contents
|
123
|
+
// in #{R.pubba_config_file}
|
124
|
+
//
|
125
|
+
//= require third-party/modernizr.js
|
126
|
+
TEXT
|
127
|
+
|
128
|
+
assert_equal contents.chomp, js
|
129
|
+
end
|
130
|
+
|
131
|
+
def test_search_body_js_asset
|
132
|
+
js = File.open( File.join(R.asset_folder, 'javascripts', 'search-body.js')){|f| f.read }
|
133
|
+
contents = <<TEXT
|
134
|
+
// This file is automatically generated from the contents
|
135
|
+
// in #{R.pubba_config_file}
|
136
|
+
//
|
137
|
+
//= require third-party/backbone.js
|
138
|
+
//= require custom/app.js
|
139
|
+
//= require custom/tracker.js
|
140
|
+
//= require custom/lightbox.js
|
141
|
+
TEXT
|
142
|
+
|
143
|
+
assert_equal contents.chomp, js
|
144
|
+
end
|
17
145
|
end
|
data/test/pubba/test_site.rb
CHANGED
@@ -1,11 +1,6 @@
|
|
1
1
|
require 'helper'
|
2
2
|
|
3
3
|
class TestPubbaSite < TestPubba
|
4
|
-
def test_global_asset_configuration_initialization
|
5
|
-
hsh = {"styles"=>["custom/global"], "head_scripts"=>["third-party/jq"], "body_scripts"=>["third-party/jqc", "custom/app"]}
|
6
|
-
assert_equal hsh, Sinatra::Pubba::Site.global_asset_configuration
|
7
|
-
end
|
8
|
-
|
9
4
|
def test_asset_handler_initialization
|
10
5
|
assert_equal Sinatra::Pubba::Assets::SprocketsHandler, Sinatra::Pubba::Site.asset_handler
|
11
6
|
end
|
@@ -25,12 +20,4 @@ class TestPubbaSite < TestPubba
|
|
25
20
|
def test_style_asset_folder_initialization
|
26
21
|
assert_equal "#{R.asset_folder}/stylesheets", Sinatra::Pubba::Site.style_asset_folder
|
27
22
|
end
|
28
|
-
|
29
|
-
def test_asset_types_initialization
|
30
|
-
asset_types = Sinatra::Pubba::Site.asset_types
|
31
|
-
assert_equal Sinatra::Pubba::Site.style_asset_folder, asset_types.delete('styles')
|
32
|
-
assert_equal Sinatra::Pubba::Site.script_asset_folder, asset_types.delete('head_scripts')
|
33
|
-
assert_equal Sinatra::Pubba::Site.script_asset_folder, asset_types.delete('body_scripts')
|
34
|
-
assert asset_types.empty?
|
35
|
-
end
|
36
23
|
end
|
File without changes
|
@@ -0,0 +1 @@
|
|
1
|
+
#page {width:800px;margin:0 auto;position:relative;}
|
@@ -0,0 +1 @@
|
|
1
|
+
#page {width:320px;margin:0 auto;position:relative;padding:0 }
|
@@ -1,20 +1,39 @@
|
|
1
|
-
# Global configuration. Settings here will be applied to all pages.
|
2
1
|
global:
|
3
2
|
styles:
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
3
|
+
all:
|
4
|
+
urls:
|
5
|
+
- "http://twitter.github.com/bootstrap/1.4.0/bootstrap.min.css"
|
6
|
+
- "custom/global"
|
7
|
+
phone:
|
8
|
+
media: "only screen and (max-width: 480px)"
|
9
|
+
urls:
|
10
|
+
- "custom/small"
|
11
|
+
desktop:
|
12
|
+
media: "only screen and (min-width: 480px)"
|
13
|
+
urls:
|
14
|
+
- "custom/large"
|
15
|
+
scripts:
|
16
|
+
head:
|
17
|
+
- "https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"
|
18
|
+
- "third-party/modernizr"
|
19
|
+
body:
|
20
|
+
- "https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/jquery-ui.min.js"
|
21
|
+
- "third-party/backbone"
|
22
|
+
- "custom/app"
|
23
|
+
- "custom/tracker"
|
10
24
|
|
11
|
-
# Home page configuration
|
12
25
|
home:
|
13
26
|
styles:
|
14
|
-
|
27
|
+
all:
|
28
|
+
urls:
|
29
|
+
- "custom/home"
|
15
30
|
|
16
|
-
# Search page configuration
|
17
31
|
search:
|
18
32
|
styles:
|
19
|
-
|
20
|
-
|
33
|
+
all:
|
34
|
+
urls:
|
35
|
+
- "custom/search"
|
36
|
+
- "third-party/widget"
|
37
|
+
scripts:
|
38
|
+
body:
|
39
|
+
- "custom/lightbox"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pubba
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-12-
|
12
|
+
date: 2011-12-05 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: sprockets
|
16
|
-
requirement: &
|
16
|
+
requirement: &2151907280 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 2.1.2
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *2151907280
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: r18n-desktop
|
27
|
-
requirement: &
|
27
|
+
requirement: &2151906520 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: 0.4.11
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *2151906520
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rake
|
38
|
-
requirement: &
|
38
|
+
requirement: &2151906000 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: 0.9.2
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *2151906000
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: sinatra
|
49
|
-
requirement: &
|
49
|
+
requirement: &2151905480 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: 1.3.1
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *2151905480
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: sinatra-contrib
|
60
|
-
requirement: &
|
60
|
+
requirement: &2151904780 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ! '>='
|
@@ -65,10 +65,10 @@ dependencies:
|
|
65
65
|
version: 1.3.1
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *2151904780
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: yard
|
71
|
-
requirement: &
|
71
|
+
requirement: &2151904200 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ! '>='
|
@@ -76,7 +76,7 @@ dependencies:
|
|
76
76
|
version: '0'
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *2151904200
|
80
80
|
description: Pubba is a Sinatra extension designed to help you manage your site.
|
81
81
|
email:
|
82
82
|
- andy@stonean.com
|
@@ -87,6 +87,7 @@ extra_rdoc_files:
|
|
87
87
|
files:
|
88
88
|
- .gitignore
|
89
89
|
- .yardopts
|
90
|
+
- CHANGES
|
90
91
|
- Gemfile
|
91
92
|
- README.md
|
92
93
|
- Rakefile
|
@@ -108,12 +109,15 @@ files:
|
|
108
109
|
- test/pubba/test_page.rb
|
109
110
|
- test/pubba/test_site.rb
|
110
111
|
- test/sinatra/app/assets/javascripts/custom/app.js
|
111
|
-
- test/sinatra/app/assets/javascripts/custom/
|
112
|
-
- test/sinatra/app/assets/javascripts/
|
113
|
-
- test/sinatra/app/assets/javascripts/third-party/
|
112
|
+
- test/sinatra/app/assets/javascripts/custom/lightbox.js
|
113
|
+
- test/sinatra/app/assets/javascripts/custom/tracker.js
|
114
|
+
- test/sinatra/app/assets/javascripts/third-party/backbone.js
|
115
|
+
- test/sinatra/app/assets/javascripts/third-party/modernizr.js
|
114
116
|
- test/sinatra/app/assets/stylesheets/custom/global.css
|
115
117
|
- test/sinatra/app/assets/stylesheets/custom/home.css
|
118
|
+
- test/sinatra/app/assets/stylesheets/custom/large.css
|
116
119
|
- test/sinatra/app/assets/stylesheets/custom/search.css
|
120
|
+
- test/sinatra/app/assets/stylesheets/custom/small.css
|
117
121
|
- test/sinatra/app/assets/stylesheets/third-party/widget.css
|
118
122
|
- test/sinatra/app/i18n/en.yml
|
119
123
|
- test/sinatra/config/pubba.yml
|