brighter_planet_layout 0.3.2 → 0.3.3
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.
- data/.gitignore +2 -0
- data/Gemfile +4 -0
- data/Rakefile +58 -43
- data/brighter_planet_layout.gemspec +19 -110
- data/examples/apache2-webfont-header.conf +6 -0
- data/lib/brighter_planet_layout/version.rb +3 -0
- data/lib/brighter_planet_layout.rb +4 -63
- data/public/javascripts/prototype.rails-3.0.4.js +6001 -0
- data/public/javascripts/rails.rails-3.0.4.js +191 -0
- data/public/stylesheets/images/gears-small.png +0 -0
- data/test/helper.rb +3 -3
- data/test/test_brighter_planet_layout.rb +29 -2
- metadata +45 -11
- data/VERSION +0 -1
@@ -0,0 +1,191 @@
|
|
1
|
+
(function() {
|
2
|
+
// Technique from Juriy Zaytsev
|
3
|
+
// http://thinkweb2.com/projects/prototype/detecting-event-support-without-browser-sniffing/
|
4
|
+
function isEventSupported(eventName) {
|
5
|
+
var el = document.createElement('div');
|
6
|
+
eventName = 'on' + eventName;
|
7
|
+
var isSupported = (eventName in el);
|
8
|
+
if (!isSupported) {
|
9
|
+
el.setAttribute(eventName, 'return;');
|
10
|
+
isSupported = typeof el[eventName] == 'function';
|
11
|
+
}
|
12
|
+
el = null;
|
13
|
+
return isSupported;
|
14
|
+
}
|
15
|
+
|
16
|
+
function isForm(element) {
|
17
|
+
return Object.isElement(element) && element.nodeName.toUpperCase() == 'FORM'
|
18
|
+
}
|
19
|
+
|
20
|
+
function isInput(element) {
|
21
|
+
if (Object.isElement(element)) {
|
22
|
+
var name = element.nodeName.toUpperCase()
|
23
|
+
return name == 'INPUT' || name == 'SELECT' || name == 'TEXTAREA'
|
24
|
+
}
|
25
|
+
else return false
|
26
|
+
}
|
27
|
+
|
28
|
+
var submitBubbles = isEventSupported('submit'),
|
29
|
+
changeBubbles = isEventSupported('change')
|
30
|
+
|
31
|
+
if (!submitBubbles || !changeBubbles) {
|
32
|
+
// augment the Event.Handler class to observe custom events when needed
|
33
|
+
Event.Handler.prototype.initialize = Event.Handler.prototype.initialize.wrap(
|
34
|
+
function(init, element, eventName, selector, callback) {
|
35
|
+
init(element, eventName, selector, callback)
|
36
|
+
// is the handler being attached to an element that doesn't support this event?
|
37
|
+
if ( (!submitBubbles && this.eventName == 'submit' && !isForm(this.element)) ||
|
38
|
+
(!changeBubbles && this.eventName == 'change' && !isInput(this.element)) ) {
|
39
|
+
// "submit" => "emulated:submit"
|
40
|
+
this.eventName = 'emulated:' + this.eventName
|
41
|
+
}
|
42
|
+
}
|
43
|
+
)
|
44
|
+
}
|
45
|
+
|
46
|
+
if (!submitBubbles) {
|
47
|
+
// discover forms on the page by observing focus events which always bubble
|
48
|
+
document.on('focusin', 'form', function(focusEvent, form) {
|
49
|
+
// special handler for the real "submit" event (one-time operation)
|
50
|
+
if (!form.retrieve('emulated:submit')) {
|
51
|
+
form.on('submit', function(submitEvent) {
|
52
|
+
var emulated = form.fire('emulated:submit', submitEvent, true)
|
53
|
+
// if custom event received preventDefault, cancel the real one too
|
54
|
+
if (emulated.returnValue === false) submitEvent.preventDefault()
|
55
|
+
})
|
56
|
+
form.store('emulated:submit', true)
|
57
|
+
}
|
58
|
+
})
|
59
|
+
}
|
60
|
+
|
61
|
+
if (!changeBubbles) {
|
62
|
+
// discover form inputs on the page
|
63
|
+
document.on('focusin', 'input, select, texarea', function(focusEvent, input) {
|
64
|
+
// special handler for real "change" events
|
65
|
+
if (!input.retrieve('emulated:change')) {
|
66
|
+
input.on('change', function(changeEvent) {
|
67
|
+
input.fire('emulated:change', changeEvent, true)
|
68
|
+
})
|
69
|
+
input.store('emulated:change', true)
|
70
|
+
}
|
71
|
+
})
|
72
|
+
}
|
73
|
+
|
74
|
+
function handleRemote(element) {
|
75
|
+
var method, url, params;
|
76
|
+
|
77
|
+
var event = element.fire("ajax:before");
|
78
|
+
if (event.stopped) return false;
|
79
|
+
|
80
|
+
if (element.tagName.toLowerCase() === 'form') {
|
81
|
+
method = element.readAttribute('method') || 'post';
|
82
|
+
url = element.readAttribute('action');
|
83
|
+
params = element.serialize();
|
84
|
+
} else {
|
85
|
+
method = element.readAttribute('data-method') || 'get';
|
86
|
+
url = element.readAttribute('href');
|
87
|
+
params = {};
|
88
|
+
}
|
89
|
+
|
90
|
+
new Ajax.Request(url, {
|
91
|
+
method: method,
|
92
|
+
parameters: params,
|
93
|
+
evalScripts: true,
|
94
|
+
|
95
|
+
onComplete: function(request) { element.fire("ajax:complete", request); },
|
96
|
+
onSuccess: function(request) { element.fire("ajax:success", request); },
|
97
|
+
onFailure: function(request) { element.fire("ajax:failure", request); }
|
98
|
+
});
|
99
|
+
|
100
|
+
element.fire("ajax:after");
|
101
|
+
}
|
102
|
+
|
103
|
+
function handleMethod(element) {
|
104
|
+
var method = element.readAttribute('data-method'),
|
105
|
+
url = element.readAttribute('href'),
|
106
|
+
csrf_param = $$('meta[name=csrf-param]')[0],
|
107
|
+
csrf_token = $$('meta[name=csrf-token]')[0];
|
108
|
+
|
109
|
+
var form = new Element('form', { method: "POST", action: url, style: "display: none;" });
|
110
|
+
element.parentNode.insert(form);
|
111
|
+
|
112
|
+
if (method !== 'post') {
|
113
|
+
var field = new Element('input', { type: 'hidden', name: '_method', value: method });
|
114
|
+
form.insert(field);
|
115
|
+
}
|
116
|
+
|
117
|
+
if (csrf_param) {
|
118
|
+
var param = csrf_param.readAttribute('content'),
|
119
|
+
token = csrf_token.readAttribute('content'),
|
120
|
+
field = new Element('input', { type: 'hidden', name: param, value: token });
|
121
|
+
form.insert(field);
|
122
|
+
}
|
123
|
+
|
124
|
+
form.submit();
|
125
|
+
}
|
126
|
+
|
127
|
+
|
128
|
+
document.on("click", "*[data-confirm]", function(event, element) {
|
129
|
+
var message = element.readAttribute('data-confirm');
|
130
|
+
if (!confirm(message)) event.stop();
|
131
|
+
});
|
132
|
+
|
133
|
+
document.on("click", "a[data-remote]", function(event, element) {
|
134
|
+
if (event.stopped) return;
|
135
|
+
handleRemote(element);
|
136
|
+
event.stop();
|
137
|
+
});
|
138
|
+
|
139
|
+
document.on("click", "a[data-method]", function(event, element) {
|
140
|
+
if (event.stopped) return;
|
141
|
+
handleMethod(element);
|
142
|
+
event.stop();
|
143
|
+
});
|
144
|
+
|
145
|
+
document.on("submit", function(event) {
|
146
|
+
var element = event.findElement(),
|
147
|
+
message = element.readAttribute('data-confirm');
|
148
|
+
if (message && !confirm(message)) {
|
149
|
+
event.stop();
|
150
|
+
return false;
|
151
|
+
}
|
152
|
+
|
153
|
+
var inputs = element.select("input[type=submit][data-disable-with]");
|
154
|
+
inputs.each(function(input) {
|
155
|
+
input.disabled = true;
|
156
|
+
input.writeAttribute('data-original-value', input.value);
|
157
|
+
input.value = input.readAttribute('data-disable-with');
|
158
|
+
});
|
159
|
+
|
160
|
+
var element = event.findElement("form[data-remote]");
|
161
|
+
if (element) {
|
162
|
+
handleRemote(element);
|
163
|
+
event.stop();
|
164
|
+
}
|
165
|
+
});
|
166
|
+
|
167
|
+
document.on("ajax:after", "form", function(event, element) {
|
168
|
+
var inputs = element.select("input[type=submit][disabled=true][data-disable-with]");
|
169
|
+
inputs.each(function(input) {
|
170
|
+
input.value = input.readAttribute('data-original-value');
|
171
|
+
input.removeAttribute('data-original-value');
|
172
|
+
input.disabled = false;
|
173
|
+
});
|
174
|
+
});
|
175
|
+
|
176
|
+
Ajax.Responders.register({
|
177
|
+
onCreate: function(request) {
|
178
|
+
var csrf_meta_tag = $$('meta[name=csrf-token]')[0];
|
179
|
+
|
180
|
+
if (csrf_meta_tag) {
|
181
|
+
var header = 'X-CSRF-Token',
|
182
|
+
token = csrf_meta_tag.readAttribute('content');
|
183
|
+
|
184
|
+
if (!request.options.requestHeaders) {
|
185
|
+
request.options.requestHeaders = {};
|
186
|
+
}
|
187
|
+
request.options.requestHeaders[header] = token;
|
188
|
+
}
|
189
|
+
}
|
190
|
+
});
|
191
|
+
})();
|
Binary file
|
data/test/helper.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
require 'rubygems'
|
2
|
+
require 'bundler'
|
3
|
+
Bundler.setup
|
2
4
|
require 'test/unit'
|
3
|
-
require 'shoulda'
|
4
|
-
|
5
|
-
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
6
5
|
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
6
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
7
7
|
require 'brighter_planet_layout'
|
8
8
|
|
9
9
|
class Test::Unit::TestCase
|
@@ -1,7 +1,34 @@
|
|
1
1
|
require 'helper'
|
2
2
|
|
3
|
+
require 'singleton'
|
4
|
+
module Rails
|
5
|
+
module VERSION
|
6
|
+
MAJOR = 3
|
7
|
+
MINOR = 0
|
8
|
+
PATCH = 4
|
9
|
+
STRING = '3.0.4'
|
10
|
+
end
|
11
|
+
def self.application
|
12
|
+
Application.instance
|
13
|
+
end
|
14
|
+
class Application
|
15
|
+
include Singleton
|
16
|
+
def name
|
17
|
+
'Foobar'
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
3
22
|
class TestBrighterPlanetLayout < Test::Unit::TestCase
|
4
|
-
|
5
|
-
|
23
|
+
def test_application_name
|
24
|
+
assert_equal 'Foobar', BrighterPlanetLayout.application_name
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_latest_blog_post
|
28
|
+
assert !BrighterPlanetLayout.latest_blog_post.empty?
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_latest_tweet
|
32
|
+
assert !BrighterPlanetLayout.latest_tweet.empty?
|
6
33
|
end
|
7
34
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: brighter_planet_layout
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 21
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 3
|
9
|
-
-
|
10
|
-
version: 0.3.
|
9
|
+
- 3
|
10
|
+
version: 0.3.3
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Andy Rossmeissl
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2011-
|
19
|
+
date: 2011-02-10 00:00:00 -06:00
|
20
20
|
default_executable:
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|
@@ -35,21 +35,50 @@ dependencies:
|
|
35
35
|
version: 1.2.3
|
36
36
|
type: :runtime
|
37
37
|
version_requirements: *id001
|
38
|
+
- !ruby/object:Gem::Dependency
|
39
|
+
name: eat
|
40
|
+
prerelease: false
|
41
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
42
|
+
none: false
|
43
|
+
requirements:
|
44
|
+
- - ">="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
hash: 3
|
47
|
+
segments:
|
48
|
+
- 0
|
49
|
+
version: "0"
|
50
|
+
type: :runtime
|
51
|
+
version_requirements: *id002
|
52
|
+
- !ruby/object:Gem::Dependency
|
53
|
+
name: test-unit
|
54
|
+
prerelease: false
|
55
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
56
|
+
none: false
|
57
|
+
requirements:
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
hash: 3
|
61
|
+
segments:
|
62
|
+
- 0
|
63
|
+
version: "0"
|
64
|
+
type: :development
|
65
|
+
version_requirements: *id003
|
38
66
|
description: Layouts, partials, stylesheets, and images
|
39
|
-
email:
|
67
|
+
email:
|
68
|
+
- andy@rossmeissl.net
|
40
69
|
executables: []
|
41
70
|
|
42
71
|
extensions: []
|
43
72
|
|
44
|
-
extra_rdoc_files:
|
45
|
-
|
73
|
+
extra_rdoc_files: []
|
74
|
+
|
46
75
|
files:
|
47
76
|
- .document
|
48
77
|
- .gitattributes
|
49
78
|
- .gitignore
|
79
|
+
- Gemfile
|
50
80
|
- README.rdoc
|
51
81
|
- Rakefile
|
52
|
-
- VERSION
|
53
82
|
- app/helpers/brighter_planet_helper.rb
|
54
83
|
- app/views/layouts/_elsewhere.html.erb
|
55
84
|
- app/views/layouts/_footer.html.erb
|
@@ -57,10 +86,12 @@ files:
|
|
57
86
|
- app/views/layouts/_header.html.erb
|
58
87
|
- app/views/layouts/brighter_planet.html.erb
|
59
88
|
- brighter_planet_layout.gemspec
|
89
|
+
- examples/apache2-webfont-header.conf
|
60
90
|
- lib/brighter_planet_layout.rb
|
61
91
|
- lib/brighter_planet_layout/rails.rb
|
62
92
|
- lib/brighter_planet_layout/railtie.rb
|
63
93
|
- lib/brighter_planet_layout/rake_tasks.rb
|
94
|
+
- lib/brighter_planet_layout/version.rb
|
64
95
|
- public/401.html
|
65
96
|
- public/403.html
|
66
97
|
- public/403.xml
|
@@ -77,8 +108,10 @@ files:
|
|
77
108
|
- public/javascripts/prototype.rails-2.3.10.js
|
78
109
|
- public/javascripts/prototype.rails-3.0.1.js
|
79
110
|
- public/javascripts/prototype.rails-3.0.3.js
|
111
|
+
- public/javascripts/prototype.rails-3.0.4.js
|
80
112
|
- public/javascripts/rails.rails-3.0.1.js
|
81
113
|
- public/javascripts/rails.rails-3.0.3.js
|
114
|
+
- public/javascripts/rails.rails-3.0.4.js
|
82
115
|
- public/maintenance.html
|
83
116
|
- public/stylesheets/brighter_planet.css
|
84
117
|
- public/stylesheets/fonts.css
|
@@ -103,6 +136,7 @@ files:
|
|
103
136
|
- public/stylesheets/images/bg.png
|
104
137
|
- public/stylesheets/images/cards.png
|
105
138
|
- public/stylesheets/images/derek.jpg
|
139
|
+
- public/stylesheets/images/gears-small.png
|
106
140
|
- public/stylesheets/images/gears.png
|
107
141
|
- public/stylesheets/images/glow.png
|
108
142
|
- public/stylesheets/images/ian.jpg
|
@@ -122,8 +156,8 @@ homepage: http://github.com/brighterplanet/brighter_planet_layout
|
|
122
156
|
licenses: []
|
123
157
|
|
124
158
|
post_install_message:
|
125
|
-
rdoc_options:
|
126
|
-
|
159
|
+
rdoc_options: []
|
160
|
+
|
127
161
|
require_paths:
|
128
162
|
- lib
|
129
163
|
required_ruby_version: !ruby/object:Gem::Requirement
|
@@ -146,7 +180,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
146
180
|
version: "0"
|
147
181
|
requirements: []
|
148
182
|
|
149
|
-
rubyforge_project:
|
183
|
+
rubyforge_project: brighter_planet_layout
|
150
184
|
rubygems_version: 1.3.7
|
151
185
|
signing_key:
|
152
186
|
specification_version: 3
|
data/VERSION
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
0.3.2
|