brighter_planet_layout-ruby19 0.2.37
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.gitattributes +2 -0
- data/.gitignore +21 -0
- data/LICENSE +20 -0
- data/README.rdoc +12 -0
- data/Rakefile +55 -0
- data/VERSION +1 -0
- data/app/helpers/brighter_planet_helper.rb +23 -0
- data/app/views/layouts/_elsewhere.html.erb +21 -0
- data/app/views/layouts/_footer.html.erb +42 -0
- data/app/views/layouts/_google_analytics.html.erb +13 -0
- data/app/views/layouts/_header.html.erb +25 -0
- data/app/views/layouts/brighter_planet.html.erb +33 -0
- data/brighter_planet_layout.gemspec +98 -0
- data/lib/brighter_planet_layout.rb +111 -0
- data/lib/brighter_planet_layout/rails.rb +11 -0
- data/lib/brighter_planet_layout/railtie.rb +21 -0
- data/lib/brighter_planet_layout/rake_tasks.rb +5 -0
- data/public/401.html +15 -0
- data/public/403.html +29 -0
- data/public/403.xml +2 -0
- data/public/404.html +29 -0
- data/public/404.json +1 -0
- data/public/404.xml +2 -0
- data/public/409.html +29 -0
- data/public/422.html +29 -0
- data/public/500.html +30 -0
- data/public/favicon.ico +0 -0
- data/public/javascripts/controls.js +965 -0
- data/public/javascripts/dragdrop.js +974 -0
- data/public/javascripts/effects.js +1123 -0
- data/public/javascripts/prototype.js +4874 -0
- data/public/javascripts/rails.js +118 -0
- data/public/maintenance.html +30 -0
- data/public/stylesheets/brighter_planet.css +838 -0
- data/public/stylesheets/fonts/DejaVuSansMono-Oblique.eot +0 -0
- data/public/stylesheets/fonts/DejaVuSansMono-Oblique.ttf +0 -0
- data/public/stylesheets/fonts/DejaVuSansMono.eot +0 -0
- data/public/stylesheets/fonts/DejaVuSansMono.ttf +0 -0
- data/public/stylesheets/fonts/KievitOT-Bold.otf +0 -0
- data/public/stylesheets/fonts/KievitOT-BoldItalic.otf +0 -0
- data/public/stylesheets/fonts/KievitOT-Italic.otf +0 -0
- data/public/stylesheets/fonts/KievitOT-Regular.otf +0 -0
- data/public/stylesheets/fonts/KievitWebPro-Bold.eot +0 -0
- data/public/stylesheets/fonts/KievitWebPro-Bold.woff +0 -0
- data/public/stylesheets/fonts/KievitWebPro-BoldIta.eot +0 -0
- data/public/stylesheets/fonts/KievitWebPro-BoldIta.woff +0 -0
- data/public/stylesheets/fonts/KievitWebPro-Ita.eot +0 -0
- data/public/stylesheets/fonts/KievitWebPro-Ita.woff +0 -0
- data/public/stylesheets/fonts/KievitWebPro.eot +0 -0
- data/public/stylesheets/fonts/KievitWebPro.woff +0 -0
- data/public/stylesheets/idle.css +63 -0
- data/public/stylesheets/images/bg.png +0 -0
- data/public/stylesheets/images/cards.png +0 -0
- data/public/stylesheets/images/gears.png +0 -0
- data/public/stylesheets/images/logo.png +0 -0
- data/public/stylesheets/images/meter.png +0 -0
- data/public/stylesheets/images/prism.png +0 -0
- data/public/stylesheets/images/radiant_earth-small.png +0 -0
- data/rails/init.rb +3 -0
- data/test/helper.rb +10 -0
- data/test/test_brighter_planet_layout.rb +7 -0
- metadata +162 -0
data/.document
ADDED
data/.gitattributes
ADDED
data/.gitignore
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2009 Andy Rossmeissl
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
= brighter_planet_layout
|
2
|
+
|
3
|
+
== Requirements
|
4
|
+
|
5
|
+
* You need to create <tt>app/views/layouts/_title.html.erb</tt> with something like:
|
6
|
+
|
7
|
+
<h1>APPLICATION_NAME</h1>
|
8
|
+
<h2>THE SOCIAL WEB APP</h2>
|
9
|
+
|
10
|
+
== Copyright
|
11
|
+
|
12
|
+
Copyright (c) 2010 Andy Rossmeissl. See LICENSE for details.
|
data/Rakefile
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
|
4
|
+
# sabshere 9/27/10 not using so that we edit gemspec manually
|
5
|
+
# begin
|
6
|
+
# require 'jeweler'
|
7
|
+
# Jeweler::Tasks.new do |gem|
|
8
|
+
# gem.name = "brighter_planet_layout"
|
9
|
+
# gem.summary = %Q{Layout assets for Brighter Planet sites}
|
10
|
+
# gem.description = %Q{Layouts, partials, stylesheets, and images}
|
11
|
+
# gem.email = "andy@rossmeissl.net"
|
12
|
+
# gem.homepage = "http://github.com/brighterplanet/brighter_planet_layout"
|
13
|
+
# gem.authors = ["Andy Rossmeissl", "Seamus Abshere"]
|
14
|
+
# gem.add_dependency 'ultraviolet', '>=0.10.2'
|
15
|
+
# gem.add_dependency 'simple-rss', '>=1.2.3'
|
16
|
+
# gem.files.reject! { |fn| fn.downcase =~ /\.ai$/ }
|
17
|
+
# end
|
18
|
+
# Jeweler::GemcutterTasks.new
|
19
|
+
# rescue LoadError
|
20
|
+
# puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
|
21
|
+
# end
|
22
|
+
|
23
|
+
require 'rake/testtask'
|
24
|
+
Rake::TestTask.new(:test) do |test|
|
25
|
+
test.libs << 'lib' << 'test'
|
26
|
+
test.pattern = 'test/**/test_*.rb'
|
27
|
+
test.verbose = true
|
28
|
+
end
|
29
|
+
|
30
|
+
begin
|
31
|
+
require 'rcov/rcovtask'
|
32
|
+
Rcov::RcovTask.new do |test|
|
33
|
+
test.libs << 'test'
|
34
|
+
test.pattern = 'test/**/test_*.rb'
|
35
|
+
test.verbose = true
|
36
|
+
end
|
37
|
+
rescue LoadError
|
38
|
+
task :rcov do
|
39
|
+
abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
task :test => :check_dependencies
|
44
|
+
|
45
|
+
task :default => :test
|
46
|
+
|
47
|
+
require 'rake/rdoctask'
|
48
|
+
Rake::RDocTask.new do |rdoc|
|
49
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
50
|
+
|
51
|
+
rdoc.rdoc_dir = 'rdoc'
|
52
|
+
rdoc.title = "brighter_planet_layout #{version}"
|
53
|
+
rdoc.rdoc_files.include('README*')
|
54
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
55
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.2.37
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'uv'
|
2
|
+
module BrighterPlanetHelper
|
3
|
+
def render_or_nothing(*args)
|
4
|
+
begin
|
5
|
+
render(*args)
|
6
|
+
rescue ::ActionView::MissingTemplate
|
7
|
+
nil
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
def syntax(code, lang = 'ruby')
|
12
|
+
::Uv.parse(code, 'xhtml', lang, false, :idle).html_safe
|
13
|
+
end
|
14
|
+
|
15
|
+
def link_to_homesite(text, path = '')
|
16
|
+
if ::BrighterPlanetLayout.application_name == 'Brighter Planet'
|
17
|
+
path.insert 0, '/'
|
18
|
+
else
|
19
|
+
path.insert 0, 'http://brighterplanet.com/'
|
20
|
+
end
|
21
|
+
link_to text, path
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
<div id="elsewhere">
|
2
|
+
<% cache "#{__FILE__}/latest_tweet", :ttl => 3.minutes do %>
|
3
|
+
<% tweet = ::BrighterPlanetLayout.latest_tweet -%>
|
4
|
+
<% if tweet %>
|
5
|
+
<div id="twitter">
|
6
|
+
<p>
|
7
|
+
<%= auto_link tweet.description.sub('brighterplanet: ', '') %>
|
8
|
+
<span>via <%= link_to '@brighterplanet', 'http://twitter.com/brighterplanet' %></span>
|
9
|
+
</p>
|
10
|
+
</div>
|
11
|
+
<% end %>
|
12
|
+
<% end %>
|
13
|
+
<% cache "#{__FILE__}/latest_blog_post", :ttl => 3.minutes do %>
|
14
|
+
<% blog_post = ::BrighterPlanetLayout.latest_blog_post -%>
|
15
|
+
<% if blog_post %>
|
16
|
+
<div id="blog" class="<%= blog_post.author.downcase.dasherize %>">
|
17
|
+
<p><%= link_to blog_post.title, blog_post.link %> <span>by <%= blog_post.author %> <%= time_ago_in_words blog_post.updated %> ago on <%= link_to 'Safety in Numbers', 'http://numbers.brighterplanet.com' %>, our blog</span></p>
|
18
|
+
</div>
|
19
|
+
<% end %>
|
20
|
+
<% end %>
|
21
|
+
</div>
|
@@ -0,0 +1,42 @@
|
|
1
|
+
<div id="footer">
|
2
|
+
<div id="shortcuts">
|
3
|
+
<h3>Shortcuts</h3>
|
4
|
+
<ul>
|
5
|
+
<li><%= link_to_homesite 'Home' %></li>
|
6
|
+
<li><%= link_to 'Blog', 'http://numbers.brighterplanet.com' %></li>
|
7
|
+
<li><%= link_to 'Dev', 'http://brighterplanet.github.com' %></li>
|
8
|
+
<li><%= link_to 'Keys', 'http://keys.brighterplanet.com' %></li>
|
9
|
+
<li><%= link_to 'Carbon', 'http://carbon.brighterplanet.com' %></li>
|
10
|
+
<li><%= link_to 'Data', 'http://data.brighterplanet.com' %></li>
|
11
|
+
<li><%= link_to_homesite 'Cards', 'cards' %></li>
|
12
|
+
<li><%= link_to_homesite 'Footprint', 'users/me/footprint' %></li>
|
13
|
+
</ul>
|
14
|
+
</div>
|
15
|
+
<div id="map">
|
16
|
+
<div id="slogan">
|
17
|
+
<h1>Brighter Planet</h1>
|
18
|
+
<p class="slogan">Carbon is everywhere</p>
|
19
|
+
<p class="description">Enterprise-grade cloud technology for carbon intelligence.</p>
|
20
|
+
<p class="description"><%= link_to_homesite 'About us', 'about' %></p>
|
21
|
+
<p class="terms"><%= link_to_homesite 'Terms', 'terms' %></p>
|
22
|
+
</div>
|
23
|
+
<div id="middleware">
|
24
|
+
<div class="main">
|
25
|
+
<h3>Carbon Middleware</h3>
|
26
|
+
<p>Real-time, scalable web services to enhance your business applications. <%= link_to_homesite 'Learn more', 'middleware' %></p>
|
27
|
+
</div>
|
28
|
+
<ul class="links">
|
29
|
+
<li><%= link_to 'Information for developers', 'http://brighterplanet.github.com' %> Documentation, code samples, and libraries</li>
|
30
|
+
<li><%= link_to_homesite 'Information for executives', 'products' %> Industry solutions and case studies</li>
|
31
|
+
</ul>
|
32
|
+
</div>
|
33
|
+
<div id="applications">
|
34
|
+
<h3>Live applications</h3>
|
35
|
+
<ul>
|
36
|
+
<li class="cards"><%= link_to_homesite 'Visa credit and debit cards', 'cards' %> powered by Carbon Middleware technology</li>
|
37
|
+
<li class="profiler"><%= link_to_homesite 'Carbon footprint profiles', 'users/me/footprint' %> powered by Carbon Middleware technology</li>
|
38
|
+
</ul>
|
39
|
+
</div>
|
40
|
+
<%= render :partial => 'layouts/elsewhere' %>
|
41
|
+
</div>
|
42
|
+
</div>
|
@@ -0,0 +1,13 @@
|
|
1
|
+
<script type="text/javascript">
|
2
|
+
//<![CDATA[
|
3
|
+
var _gaq = _gaq || [];
|
4
|
+
_gaq.push(['_setAccount', '<%= ::BrighterPlanetLayout.google_analytics_ua_number %>']);
|
5
|
+
_gaq.push(['_trackPageview']);
|
6
|
+
|
7
|
+
(function() {
|
8
|
+
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
|
9
|
+
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
|
10
|
+
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
|
11
|
+
})();
|
12
|
+
//]]>
|
13
|
+
</script>
|
@@ -0,0 +1,25 @@
|
|
1
|
+
<div id="header">
|
2
|
+
<h1><span>Brighter Planet</span></h1>
|
3
|
+
<ul>
|
4
|
+
<li><%= link_to_homesite 'Home' %></li>
|
5
|
+
<li><%= link_to_homesite 'About us', 'about' %></li>
|
6
|
+
<li><%= link_to_homesite 'Products', 'products' %></li>
|
7
|
+
<li><%= link_to 'Developers', 'http://brighterplanet.github.com' %></li>
|
8
|
+
<li><%= link_to 'Blog', 'http://numbers.brighterplanet.com/' %></li>
|
9
|
+
</ul>
|
10
|
+
</div>
|
11
|
+
|
12
|
+
<div id="title">
|
13
|
+
<%= render :partial => 'layouts/title' %>
|
14
|
+
</div>
|
15
|
+
|
16
|
+
<% if flash[:error] or flash[:notice] %>
|
17
|
+
<div id="flash">
|
18
|
+
<% if error = flash[:error] %>
|
19
|
+
<p class="flash error"><%= error %></p>
|
20
|
+
<% elsif notice = flash[:notice] %>
|
21
|
+
<p class="flash notice"><%= notice %></p>
|
22
|
+
<% end %>
|
23
|
+
</div>
|
24
|
+
<% end %>
|
25
|
+
|
@@ -0,0 +1,33 @@
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
2
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" dir="ltr" id="brighterplanet-com">
|
3
|
+
<head>
|
4
|
+
<title><%= title = @title ? "#{@title} [#{::BrighterPlanetLayout.application_name}]" : ::BrighterPlanetLayout.application_name %></title>
|
5
|
+
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
6
|
+
<meta http-equiv="Content-Language" content="en" />
|
7
|
+
<%= stylesheet_link_tag 'brighter_planet', 'application', 'idle' %>
|
8
|
+
<%= javascript_include_tag :defaults %>
|
9
|
+
<%= csrf_meta_tag if ::Rails::VERSION::MAJOR == 3 %>
|
10
|
+
<link rel="shortcut icon" type="image/ico" href="/favicon.ico" />
|
11
|
+
<%= render_or_nothing :partial => 'layouts/head' %>
|
12
|
+
<%= yield :head %>
|
13
|
+
</head>
|
14
|
+
<body<%= " class=\"#{ @bodyclass }\"".html_safe if @bodyclass %>>
|
15
|
+
|
16
|
+
<%= render :partial => 'layouts/google_analytics' %>
|
17
|
+
|
18
|
+
<%= render :partial => 'layouts/header' %>
|
19
|
+
|
20
|
+
<%= render_or_nothing :partial => 'layouts/top' %>
|
21
|
+
<%= yield :top %>
|
22
|
+
|
23
|
+
<div id="content">
|
24
|
+
<%= yield %>
|
25
|
+
</div>
|
26
|
+
|
27
|
+
<%= render_or_nothing :partial => 'layouts/bottom' %>
|
28
|
+
<%= yield :bottom %>
|
29
|
+
|
30
|
+
<%= render :partial => 'layouts/footer' %>
|
31
|
+
|
32
|
+
</body>
|
33
|
+
</html>
|
@@ -0,0 +1,98 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = %q{brighter_planet_layout-ruby19}
|
5
|
+
s.version = "0.2.37"
|
6
|
+
|
7
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
|
+
s.authors = ["Andy Rossmeissl", "Seamus Abshere"]
|
9
|
+
s.date = %q{2010-09-27}
|
10
|
+
s.description = %q{Layouts, partials, stylesheets, and images}
|
11
|
+
s.email = %q{andy@rossmeissl.net}
|
12
|
+
s.extra_rdoc_files = [
|
13
|
+
"LICENSE",
|
14
|
+
"README.rdoc"
|
15
|
+
]
|
16
|
+
s.files = [
|
17
|
+
".document",
|
18
|
+
".gitattributes",
|
19
|
+
".gitignore",
|
20
|
+
"LICENSE",
|
21
|
+
"README.rdoc",
|
22
|
+
"Rakefile",
|
23
|
+
"VERSION",
|
24
|
+
"app/helpers/brighter_planet_helper.rb",
|
25
|
+
"app/views/layouts/_elsewhere.html.erb",
|
26
|
+
"app/views/layouts/_footer.html.erb",
|
27
|
+
"app/views/layouts/_google_analytics.html.erb",
|
28
|
+
"app/views/layouts/_header.html.erb",
|
29
|
+
"app/views/layouts/brighter_planet.html.erb",
|
30
|
+
"brighter_planet_layout.gemspec",
|
31
|
+
"lib/brighter_planet_layout.rb",
|
32
|
+
"lib/brighter_planet_layout/rails.rb",
|
33
|
+
"lib/brighter_planet_layout/railtie.rb",
|
34
|
+
"lib/brighter_planet_layout/rake_tasks.rb",
|
35
|
+
"public/401.html",
|
36
|
+
"public/403.html",
|
37
|
+
"public/403.xml",
|
38
|
+
"public/404.html",
|
39
|
+
"public/404.json",
|
40
|
+
"public/404.xml",
|
41
|
+
"public/409.html",
|
42
|
+
"public/422.html",
|
43
|
+
"public/500.html",
|
44
|
+
"public/favicon.ico",
|
45
|
+
"public/javascripts/controls.js",
|
46
|
+
"public/javascripts/dragdrop.js",
|
47
|
+
"public/javascripts/effects.js",
|
48
|
+
"public/javascripts/prototype.js",
|
49
|
+
"public/javascripts/rails.js",
|
50
|
+
"public/maintenance.html",
|
51
|
+
"public/stylesheets/brighter_planet.css",
|
52
|
+
"public/stylesheets/fonts/DejaVuSansMono-Oblique.eot",
|
53
|
+
"public/stylesheets/fonts/DejaVuSansMono-Oblique.ttf",
|
54
|
+
"public/stylesheets/fonts/DejaVuSansMono.eot",
|
55
|
+
"public/stylesheets/fonts/DejaVuSansMono.ttf",
|
56
|
+
"public/stylesheets/fonts/KievitOT-Bold.otf",
|
57
|
+
"public/stylesheets/fonts/KievitOT-BoldItalic.otf",
|
58
|
+
"public/stylesheets/fonts/KievitOT-Italic.otf",
|
59
|
+
"public/stylesheets/fonts/KievitOT-Regular.otf",
|
60
|
+
"public/stylesheets/fonts/KievitWebPro-Bold.eot",
|
61
|
+
"public/stylesheets/fonts/KievitWebPro-Bold.woff",
|
62
|
+
"public/stylesheets/fonts/KievitWebPro-BoldIta.eot",
|
63
|
+
"public/stylesheets/fonts/KievitWebPro-BoldIta.woff",
|
64
|
+
"public/stylesheets/fonts/KievitWebPro-Ita.eot",
|
65
|
+
"public/stylesheets/fonts/KievitWebPro-Ita.woff",
|
66
|
+
"public/stylesheets/fonts/KievitWebPro.eot",
|
67
|
+
"public/stylesheets/fonts/KievitWebPro.woff",
|
68
|
+
"public/stylesheets/idle.css",
|
69
|
+
"public/stylesheets/images/bg.png",
|
70
|
+
"public/stylesheets/images/cards.png",
|
71
|
+
"public/stylesheets/images/gears.png",
|
72
|
+
"public/stylesheets/images/logo.png",
|
73
|
+
"public/stylesheets/images/meter.png",
|
74
|
+
"public/stylesheets/images/prism.png",
|
75
|
+
"public/stylesheets/images/radiant_earth-small.png",
|
76
|
+
"rails/init.rb",
|
77
|
+
"test/helper.rb",
|
78
|
+
"test/test_brighter_planet_layout.rb"
|
79
|
+
]
|
80
|
+
s.homepage = %q{http://github.com/brighterplanet/brighter_planet_layout}
|
81
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
82
|
+
s.require_paths = ["lib"]
|
83
|
+
s.rubygems_version = %q{1.3.7}
|
84
|
+
s.summary = %q{Layout assets for Brighter Planet sites}
|
85
|
+
s.test_files = [
|
86
|
+
"test/helper.rb",
|
87
|
+
"test/test_brighter_planet_layout.rb"
|
88
|
+
]
|
89
|
+
if RUBY_VERSION >= "1.9"
|
90
|
+
# sabshere 9/27/10 this one doesn't depend on oniguruma
|
91
|
+
s.add_runtime_dependency(%q<spox-ultraviolet>, [">= 0.10.3"])
|
92
|
+
s.add_runtime_dependency(%q<simple-rss>, [">= 1.2.3"])
|
93
|
+
else
|
94
|
+
s.add_runtime_dependency(%q<ultraviolet>, [">= 0.10.2"])
|
95
|
+
s.add_runtime_dependency(%q<simple-rss>, [">= 1.2.3"])
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
@@ -0,0 +1,111 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
require 'yaml'
|
3
|
+
require 'simple-rss'
|
4
|
+
require 'open-uri'
|
5
|
+
|
6
|
+
# http://ph7spot.com/musings/system-timer
|
7
|
+
begin
|
8
|
+
require 'system_timer'
|
9
|
+
BrighterPlanetLayoutTimer = ::SystemTimer
|
10
|
+
rescue ::LoadError
|
11
|
+
require 'timeout'
|
12
|
+
BrighterPlanetLayoutTimer = ::Timeout
|
13
|
+
end
|
14
|
+
|
15
|
+
module BrighterPlanetLayout
|
16
|
+
GEM_ROOT = ::File.expand_path ::File.join(::File.dirname(__FILE__), '..')
|
17
|
+
VERSION = ::YAML.load ::File.read(::File.join(GEM_ROOT, 'VERSION'))
|
18
|
+
TWITTER_RSS = 'http://twitter.com/statuses/user_timeline/15042574.rss'
|
19
|
+
BLOG_ATOM = 'http://numbers.brighterplanet.com/atom.xml'
|
20
|
+
FEED_TIMEOUT = 5 # seconds
|
21
|
+
|
22
|
+
def self.view_path
|
23
|
+
::File.join GEM_ROOT, 'app', 'views'
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.helper_file
|
27
|
+
::File.join GEM_ROOT, 'app', 'helpers', 'brighter_planet_helper.rb'
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.layout_warning_file
|
31
|
+
::File.join rails_root, 'public', "BRIGHTER_PLANET_LAYOUT_VERSION_#{VERSION}"
|
32
|
+
end
|
33
|
+
|
34
|
+
def self.public_path
|
35
|
+
::File.join GEM_ROOT, 'public'
|
36
|
+
end
|
37
|
+
|
38
|
+
def self.copy_static_files_to_web_server_document_root
|
39
|
+
::Dir[::File.join(public_path, '*')].each do |source_path|
|
40
|
+
dest_path = ::File.join(rails_root, 'public', source_path.gsub(public_path, ''))
|
41
|
+
if ::File.directory? source_path
|
42
|
+
::FileUtils.cp_r source_path.concat('/.'), dest_path
|
43
|
+
else
|
44
|
+
::FileUtils.cp source_path, dest_path
|
45
|
+
end
|
46
|
+
end
|
47
|
+
install_layout_warning
|
48
|
+
end
|
49
|
+
|
50
|
+
def self.install_layout_warning
|
51
|
+
::FileUtils.touch layout_warning_file
|
52
|
+
end
|
53
|
+
|
54
|
+
def self.layout_warning_installed?
|
55
|
+
::File.readable? layout_warning_file
|
56
|
+
end
|
57
|
+
|
58
|
+
def self.copy_static_files?
|
59
|
+
not heroku? and not serve_static_files_using_rack? and not layout_warning_installed?
|
60
|
+
end
|
61
|
+
|
62
|
+
def self.heroku?
|
63
|
+
::File.readable? '/home/heroku_rack/heroku.ru'
|
64
|
+
end
|
65
|
+
|
66
|
+
def self.serve_static_files_using_rack?
|
67
|
+
not heroku? and not ::Rails.env.production?
|
68
|
+
end
|
69
|
+
|
70
|
+
def self.application_name
|
71
|
+
(::Rails::VERSION::MAJOR == 3) ? ::Rails.application.name : ::APPLICATION_NAME
|
72
|
+
end
|
73
|
+
|
74
|
+
def self.google_analytics_ua_number
|
75
|
+
(::Rails::VERSION::MAJOR == 3) ? ::Rails.application.google_analytics_ua_number : ::GOOGLE_ANALYTICS_UA_NUMBER
|
76
|
+
end
|
77
|
+
|
78
|
+
def self.rails_root
|
79
|
+
::Rails.respond_to?(:root) ? ::Rails.root : ::RAILS_ROOT
|
80
|
+
end
|
81
|
+
|
82
|
+
def self.latest_tweet
|
83
|
+
::BrighterPlanetLayoutTimer.timeout(FEED_TIMEOUT) do
|
84
|
+
::SimpleRSS.parse(open(TWITTER_RSS)).entries.first
|
85
|
+
end
|
86
|
+
rescue ::OpenURI::HTTPError
|
87
|
+
# nil
|
88
|
+
rescue ::SocketError, ::Timeout::Error, ::Errno::ETIMEDOUT, ::Errno::ENETUNREACH, ::Errno::ECONNRESET, ::Errno::ECONNREFUSED
|
89
|
+
# nil
|
90
|
+
rescue ::NoMethodError
|
91
|
+
# nil
|
92
|
+
end
|
93
|
+
|
94
|
+
def self.latest_blog_post
|
95
|
+
::BrighterPlanetLayoutTimer.timeout(FEED_TIMEOUT) do
|
96
|
+
::SimpleRSS.parse(open(BLOG_ATOM)).entries.first
|
97
|
+
end
|
98
|
+
rescue ::OpenURI::HTTPError
|
99
|
+
# nil
|
100
|
+
rescue ::SocketError, ::Timeout::Error, ::Errno::ETIMEDOUT, ::Errno::ENETUNREACH, ::Errno::ECONNRESET, ::Errno::ECONNREFUSED
|
101
|
+
# nil
|
102
|
+
rescue ::NoMethodError
|
103
|
+
# nil
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
if defined? ::Rails::Railtie and ::Rails::VERSION::MAJOR == 3
|
108
|
+
require 'brighter_planet_layout/railtie'
|
109
|
+
elsif defined? ::Rails and ::Rails::VERSION::MAJOR == 2
|
110
|
+
require 'brighter_planet_layout/rails'
|
111
|
+
end
|