css_naked 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -0
- data/LICENSE +20 -0
- data/README.md +55 -0
- data/Rakefile +39 -0
- data/VERSION +1 -0
- data/lib/css_naked.rb +33 -0
- data/lib/rails/init.rb +1 -0
- data/test/helper.rb +7 -0
- data/test/test_css_naked.rb +50 -0
- metadata +112 -0
data/.gitignore
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2009 Andreas Neuhaus
|
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.md
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
CSS Naked Day Plugin for Rails
|
2
|
+
==============================
|
3
|
+
|
4
|
+
CSS Naked Day is an annual event where websites remove all CSS from their
|
5
|
+
site for one day to promote web standards. More information on this event
|
6
|
+
can be found on [Dustin's site][dustin].
|
7
|
+
|
8
|
+
This plugin makes a Rails application strip off the stylesheets during the
|
9
|
+
CSS Naked Day event. It does this by modifying the `stylesheet_link_tag`
|
10
|
+
helper to skip including stylesheets into the layout during the event.
|
11
|
+
|
12
|
+
Install
|
13
|
+
-------
|
14
|
+
|
15
|
+
Add the css_naked gem to your Rails application. With Rails 3.x, add the
|
16
|
+
following to you `Gemfile`:
|
17
|
+
|
18
|
+
gem 'css_naked'
|
19
|
+
|
20
|
+
If you're using Rails 2.x without Bundler, you need to add `config.gem 'css_naked'`
|
21
|
+
to `config/environments.rb` instead.
|
22
|
+
|
23
|
+
If you previously used the css_naked plugin, you should remove it after
|
24
|
+
switching to the gem by simply deleting the directory `vendor/plugins/css_naked`
|
25
|
+
in your application.
|
26
|
+
|
27
|
+
Manual usage
|
28
|
+
------------
|
29
|
+
|
30
|
+
If you manually need to do stuff on CSS Naked Day (e.g. skipping stylesheets
|
31
|
+
you placed without using `stylesheet_link_tag` or adding a note for visitors
|
32
|
+
why the stylesheets are missing), you can use the `css_naked?` method:
|
33
|
+
|
34
|
+
<%- if css_naked? -%>
|
35
|
+
<h3>What happened to the design?</h3>
|
36
|
+
<p>To know more about why styles are disabled on this website visit the
|
37
|
+
<a href="http://naked.dustindiaz.com" title="Web Standards Naked Day Host Website">
|
38
|
+
Annual CSS Naked Day</a> website for more information.</p>
|
39
|
+
<%- end -%>
|
40
|
+
|
41
|
+
Trying it out
|
42
|
+
-------------
|
43
|
+
|
44
|
+
To see, how your site will look like without any styles, you can manually activate
|
45
|
+
the CSS Naked Day mode by overriding the `css_naked?` in `application_helper.rb`:
|
46
|
+
|
47
|
+
def css_naked?
|
48
|
+
true
|
49
|
+
end
|
50
|
+
|
51
|
+
Author
|
52
|
+
------
|
53
|
+
[Andreas Neuhaus](http://zargony.com/)
|
54
|
+
|
55
|
+
[dustin]: http://naked.dustindiaz.com
|
data/Rakefile
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'rake'
|
2
|
+
|
3
|
+
desc 'Default: run unit tests.'
|
4
|
+
task :default => :test
|
5
|
+
|
6
|
+
require 'jeweler'
|
7
|
+
Jeweler::Tasks.new do |gem|
|
8
|
+
gem.name = 'css_naked'
|
9
|
+
gem.summary = 'Rails plugin to disable stylesheets during the CSS Naked Day event'
|
10
|
+
gem.description = 'This plugin makes a Rails application strip off the stylesheets during the CSS Naked Day event. It does this by modifying the stylesheet_link_tag helper to skip including stylesheets into the layout during the event.'
|
11
|
+
gem.homepage = 'http://github.com/zargony/css_naked'
|
12
|
+
gem.authors = ['Andreas Neuhaus']
|
13
|
+
gem.files << 'lib/rails/init.rb'
|
14
|
+
gem.add_dependency 'activesupport'
|
15
|
+
gem.add_dependency 'actionpack'
|
16
|
+
gem.has_rdoc = false
|
17
|
+
gem.add_development_dependency 'mocha'
|
18
|
+
end
|
19
|
+
Jeweler::GemcutterTasks.new
|
20
|
+
|
21
|
+
require 'rake/testtask'
|
22
|
+
task :test => :check_dependencies
|
23
|
+
desc 'Test the css_naked plugin.'
|
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
|
+
require 'rake/rdoctask'
|
31
|
+
desc 'Generate documentation for the css_naked plugin.'
|
32
|
+
Rake::RDocTask.new(:rdoc) do |rdoc|
|
33
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ''
|
34
|
+
rdoc.rdoc_dir = 'rdoc'
|
35
|
+
rdoc.title = "CSS Naked Day Rails Plugin #{version}"
|
36
|
+
rdoc.options << '--line-numbers' << '--inline-source'
|
37
|
+
rdoc.rdoc_files.include('README')
|
38
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
39
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
1.0.0
|
data/lib/css_naked.rb
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
#
|
2
|
+
# This Rails plugin overrides the stylesheet_link_tag helper and modifies
|
3
|
+
# it to skip outputting stylesheet link tags on css naked day. Css naked
|
4
|
+
# day is an annual event where websites remove all css from their site to
|
5
|
+
# promote web standards. See http://naked.dustindiaz.com for more info.
|
6
|
+
#
|
7
|
+
module CssNaked
|
8
|
+
module ViewHelpers
|
9
|
+
class << self
|
10
|
+
def included (base) # :nodoc:
|
11
|
+
base.class_eval do
|
12
|
+
alias_method_chain :stylesheet_link_tag, :css_naked
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
# Returns true if today is a css naked day (April 9th in any timezone)
|
18
|
+
# Previous naked days: 2006-04-05, 2007-04-05, 2008-04-09, 2009-04-09,
|
19
|
+
# 2010-04-09. Since 2008, all future naked days will be on April 9th.
|
20
|
+
# See also http://naked.dustindiaz.com/
|
21
|
+
def css_naked?
|
22
|
+
start = Date.new(Time.current.year, 4, 9).to_time(:utc) - 12.hours
|
23
|
+
Time.current >= start && Time.current <= start + 47.hours
|
24
|
+
end
|
25
|
+
|
26
|
+
# Modified stylesheet_link_tag that does nothing on css naked day
|
27
|
+
def stylesheet_link_tag_with_css_naked (*args)
|
28
|
+
stylesheet_link_tag_without_css_naked(*args) unless css_naked?
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
ActionView::Base.send :include, CssNaked::ViewHelpers
|
data/lib/rails/init.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'css_naked'
|
data/test/helper.rb
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
class CssNakedTest < ActiveSupport::TestCase
|
4
|
+
|
5
|
+
def setup
|
6
|
+
@view = ActionView::Base.new
|
7
|
+
end
|
8
|
+
|
9
|
+
def test_css_naked_inclusion
|
10
|
+
assert @view.respond_to?(:css_naked?)
|
11
|
+
end
|
12
|
+
|
13
|
+
def local_beginning_of_naked_day
|
14
|
+
Time.zone.local(Date.today.year + 2, 4, 9)
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_naked_day_detection_early
|
18
|
+
Time.use_zone('Pacific/Fiji') do # Earliest timezone: Fiji with GMT+12
|
19
|
+
assert_equal 12.hours, Time.zone.utc_offset
|
20
|
+
Time.stubs(:current).returns(local_beginning_of_naked_day - 1.second)
|
21
|
+
assert !@view.css_naked?
|
22
|
+
Time.stubs(:current).returns(local_beginning_of_naked_day)
|
23
|
+
assert @view.css_naked?
|
24
|
+
Time.stubs(:current).returns(local_beginning_of_naked_day + 24.hours)
|
25
|
+
assert @view.css_naked?
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_naked_day_detection_europe
|
30
|
+
Time.use_zone('Europe/London') do # Central Europe timezone: London with GMT
|
31
|
+
assert_equal 0, Time.zone.utc_offset
|
32
|
+
Time.stubs(:current).returns(local_beginning_of_naked_day)
|
33
|
+
assert @view.css_naked?
|
34
|
+
Time.stubs(:current).returns(local_beginning_of_naked_day + 24.hours)
|
35
|
+
assert @view.css_naked?
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_naked_day_detection_late
|
40
|
+
Time.use_zone('Pacific/Pago_Pago') do # Latest timezone: Pago Pago with GMT-11
|
41
|
+
assert_equal -11.hours, Time.zone.utc_offset
|
42
|
+
Time.stubs(:current).returns(local_beginning_of_naked_day)
|
43
|
+
assert @view.css_naked?
|
44
|
+
Time.stubs(:current).returns(local_beginning_of_naked_day + 24.hours)
|
45
|
+
assert @view.css_naked?
|
46
|
+
Time.stubs(:current).returns(local_beginning_of_naked_day + 24.hours + 1.second)
|
47
|
+
assert !@view.css_naked?
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
metadata
ADDED
@@ -0,0 +1,112 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: css_naked
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 1
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
version: 1.0.0
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- Andreas Neuhaus
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2010-08-12 00:00:00 +02:00
|
18
|
+
default_executable:
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: activesupport
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
none: false
|
25
|
+
requirements:
|
26
|
+
- - ">="
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
segments:
|
29
|
+
- 0
|
30
|
+
version: "0"
|
31
|
+
type: :runtime
|
32
|
+
version_requirements: *id001
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: actionpack
|
35
|
+
prerelease: false
|
36
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
37
|
+
none: false
|
38
|
+
requirements:
|
39
|
+
- - ">="
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
segments:
|
42
|
+
- 0
|
43
|
+
version: "0"
|
44
|
+
type: :runtime
|
45
|
+
version_requirements: *id002
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: mocha
|
48
|
+
prerelease: false
|
49
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
segments:
|
55
|
+
- 0
|
56
|
+
version: "0"
|
57
|
+
type: :development
|
58
|
+
version_requirements: *id003
|
59
|
+
description: This plugin makes a Rails application strip off the stylesheets during the CSS Naked Day event. It does this by modifying the stylesheet_link_tag helper to skip including stylesheets into the layout during the event.
|
60
|
+
email:
|
61
|
+
executables: []
|
62
|
+
|
63
|
+
extensions: []
|
64
|
+
|
65
|
+
extra_rdoc_files:
|
66
|
+
- LICENSE
|
67
|
+
- README.md
|
68
|
+
files:
|
69
|
+
- .gitignore
|
70
|
+
- LICENSE
|
71
|
+
- README.md
|
72
|
+
- Rakefile
|
73
|
+
- VERSION
|
74
|
+
- lib/css_naked.rb
|
75
|
+
- lib/rails/init.rb
|
76
|
+
- test/helper.rb
|
77
|
+
- test/test_css_naked.rb
|
78
|
+
has_rdoc: true
|
79
|
+
homepage: http://github.com/zargony/css_naked
|
80
|
+
licenses: []
|
81
|
+
|
82
|
+
post_install_message:
|
83
|
+
rdoc_options:
|
84
|
+
- --charset=UTF-8
|
85
|
+
require_paths:
|
86
|
+
- lib
|
87
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
88
|
+
none: false
|
89
|
+
requirements:
|
90
|
+
- - ">="
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
segments:
|
93
|
+
- 0
|
94
|
+
version: "0"
|
95
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
96
|
+
none: false
|
97
|
+
requirements:
|
98
|
+
- - ">="
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
segments:
|
101
|
+
- 0
|
102
|
+
version: "0"
|
103
|
+
requirements: []
|
104
|
+
|
105
|
+
rubyforge_project:
|
106
|
+
rubygems_version: 1.3.7
|
107
|
+
signing_key:
|
108
|
+
specification_version: 3
|
109
|
+
summary: Rails plugin to disable stylesheets during the CSS Naked Day event
|
110
|
+
test_files:
|
111
|
+
- test/helper.rb
|
112
|
+
- test/test_css_naked.rb
|