css_naked_day_rails 0.0.1 → 1.0.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0da1589c4d629882033f9cc364486267c3d6318d67449a42584fced3e9959a30
4
- data.tar.gz: f9a295386a3dfe2bed03bad6ef27623a1458f148020e4faaf2ed3bdb678eb89f
3
+ metadata.gz: 33a312ce80eda0db21df01032dd9313026c560af2900e0703aa83d36f2b01d9d
4
+ data.tar.gz: ff011194dbe07a2aac16fa664907f6806b60bfc8292d6126dccf3107d969db2c
5
5
  SHA512:
6
- metadata.gz: 23cdbbbc2ff63f6c20365e97992463de9bb2d8e0b741042d9b01e443ecb82103526696f0d21ef881cc9c8b6aa49a68da9851a2096fb6ed5289eafb4cb23c3ede
7
- data.tar.gz: 239f144d46d7a7d086cc440e2bde48484bd7a5ffd773321ea3bd7303bb173c006b06413e8b4bfeec7b1b3ab4ad0dbf5fae641a3ae9b89a2a2dea1049fdf20fea
6
+ metadata.gz: 24089592b5a0febf52eab67c7c22cfa3b2a0375129456c1cc6290de94598cc1ae5ff003f19cef5dfe3db5653e9daea570f1f922393228b149895248f8f39354d
7
+ data.tar.gz: 016a0716dc37bba6d021ffe4f92611195d00aeb85c451a643363a539724c0056fc313d9202a8d57e3c903e50fd2a65f97f4bba8847879d3c41403b7f8a66972d
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2021 Daniel Sellergren
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,73 @@
1
+ # CSS Naked Day Rails
2
+
3
+ This gem gives Rails views a `css_naked_day?` helper that is true during [CSS Naked Day](https://css-naked-day.org/).
4
+
5
+ CSS Naked Day is April 9th, and it lasts for as long as it's April 9th somewhere on Earth. That's 50 hours, from 00:00 on April 9 in UTC+14 until 24:00 on April 9 in UTC-12 (10:00 UTC April 8 → 12:00 UTC April 10). The check doesn't depend on your server's time zone or `config.time_zone`.
6
+
7
+ Supports Rails 5.0 through 8.1.
8
+
9
+ ## Installation
10
+
11
+ Add the gem to your `Gemfile` and run `bundle install`.
12
+
13
+ ```ruby
14
+ gem "css_naked_day_rails"
15
+ ```
16
+
17
+ ## Usage
18
+
19
+ Wrap the tags that load your stylesheets in your layout:
20
+
21
+ ```erb
22
+ <% unless css_naked_day? %>
23
+ <%= stylesheet_link_tag :app, "data-turbo-track": "reload" %>
24
+ <% end %>
25
+ ```
26
+
27
+ The same works for `stylesheet_pack_tag`, `javascript_include_tag` and so on. Inline `<style>` blocks and `style=""` attributes need the same treatment if you want to go fully naked.
28
+
29
+ To tell visitors what's going on:
30
+
31
+ ```erb
32
+ <% if css_naked_day? %>
33
+ <p>The website isn't broken, it's <%= link_to "CSS Naked Day!", "https://css-naked-day.org" %></p>
34
+ <% end %>
35
+ ```
36
+
37
+ Outside of views, use `CssNakedDayRails.active?` (or `helpers.css_naked_day?` in a controller).
38
+
39
+ ### Previewing
40
+
41
+ To see your site naked before April 9th, put this in an initializer, e.g. `config/initializers/css_naked_day.rb`:
42
+
43
+ ```ruby
44
+ CssNakedDayRails.force = true if Rails.env.development?
45
+ ```
46
+
47
+ Set `force` to `false` to turn the check off entirely, or leave it as `nil` to follow the calendar.
48
+
49
+ ### Caching
50
+
51
+ If you cache your layout, pages or responses (fragment caching, a CDN, `expires_in`), a cached version can be served with styles during CSS Naked Day, or without them after it ends. Leave the stylesheet tags out of cached fragments, or include `css_naked_day?` in the cache key:
52
+
53
+ ```erb
54
+ <% cache [:head, css_naked_day?] do %>
55
+ ...
56
+ <% end %>
57
+ ```
58
+
59
+ ## Development
60
+
61
+ ```sh
62
+ bundle install
63
+ bundle exec rake
64
+ ```
65
+
66
+ To test against a specific Rails version:
67
+
68
+ ```sh
69
+ BUNDLE_GEMFILE=gemfiles/rails_7_2.gemfile bundle install
70
+ BUNDLE_GEMFILE=gemfiles/rails_7_2.gemfile bundle exec rake
71
+ ```
72
+
73
+ CI runs the tests against every Rails minor version from 5.0 to 8.1.
@@ -0,0 +1,7 @@
1
+ module CssNakedDayRails
2
+ module Helper
3
+ def css_naked_day?
4
+ CssNakedDayRails.active?
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,9 @@
1
+ module CssNakedDayRails
2
+ class Railtie < ::Rails::Railtie
3
+ initializer "css_naked_day_rails.helper" do
4
+ ActiveSupport.on_load(:action_view) do
5
+ include CssNakedDayRails::Helper
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,3 @@
1
+ module CssNakedDayRails
2
+ VERSION = "1.0.0".freeze
3
+ end
@@ -1,14 +1,27 @@
1
- module ApplicationHelper
2
- # CSS Naked Day is supposed to last for 48 hours because it's April 9th
3
- # somewhere in the world for that period of time. This is the best I've
4
- # come up with based on the furthest UTC offsets on April 9th.
5
- # https://css-naked-day.github.io
6
- # https://en.wikipedia.org/wiki/List_of_UTC_time_offsets
7
- def css_naked_day?
8
- css_naked_day = Date.parse('April 9').to_time
9
- css_naked_day_earliest = css_naked_day.beginning_of_day.utc - 11.hours
10
- css_naked_day_latest = css_naked_day.end_of_day.utc + 13.hours
11
-
12
- Time.zone.now.between?(css_naked_day_earliest, css_naked_day_latest)
1
+ require "css_naked_day_rails/version"
2
+ require "css_naked_day_rails/helper"
3
+
4
+ module CssNakedDayRails
5
+ # CSS Naked Day is April 9th, and it lasts for as long as it is April 9th
6
+ # anywhere on Earth: from 00:00 April 9 in UTC+14 to 24:00 April 9 in UTC-12.
7
+ # That is 50 hours, from 10:00 April 8 UTC to 12:00 April 10 UTC.
8
+ # https://css-naked-day.org
9
+ START_OFFSET = -14 * 60 * 60
10
+ END_OFFSET = (24 + 12) * 60 * 60
11
+
12
+ class << self
13
+ # Set to true or false to override the date check, e.g. to preview your
14
+ # site naked in development. Leave as nil to follow the calendar.
15
+ attr_accessor :force
16
+
17
+ def active?(time = Time.now)
18
+ return force unless force.nil?
19
+
20
+ now = time.to_time.getutc
21
+ april_9 = Time.utc(now.year, 4, 9)
22
+ now >= april_9 + START_OFFSET && now < april_9 + END_OFFSET
23
+ end
13
24
  end
14
- end
25
+ end
26
+
27
+ require "css_naked_day_rails/railtie" if defined?(Rails::Railtie)
metadata CHANGED
@@ -1,27 +1,54 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: css_naked_day_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Sellergren
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2021-04-07 00:00:00.000000000 Z
12
- dependencies: []
13
- description: Provides a Rails helper for CSS Naked Day.
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
+ dependencies:
12
+ - !ruby/object:Gem::Dependency
13
+ name: railties
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - ">="
17
+ - !ruby/object:Gem::Version
18
+ version: '5.0'
19
+ - - "<"
20
+ - !ruby/object:Gem::Version
21
+ version: '9'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ version: '5.0'
29
+ - - "<"
30
+ - !ruby/object:Gem::Version
31
+ version: '9'
32
+ description: Provides a Rails view helper, css_naked_day?, that is true during CSS
33
+ Naked Day (April 9th, anywhere on Earth).
14
34
  email: dss@hey.com
15
35
  executables: []
16
36
  extensions: []
17
37
  extra_rdoc_files: []
18
38
  files:
39
+ - LICENSE
40
+ - README.md
19
41
  - lib/css_naked_day_rails.rb
42
+ - lib/css_naked_day_rails/helper.rb
43
+ - lib/css_naked_day_rails/railtie.rb
44
+ - lib/css_naked_day_rails/version.rb
20
45
  homepage: https://github.com/danielsellergren/css_naked_day_rails
21
46
  licenses:
22
47
  - MIT
23
- metadata: {}
24
- post_install_message:
48
+ metadata:
49
+ source_code_uri: https://github.com/danielsellergren/css_naked_day_rails
50
+ changelog_uri: https://github.com/danielsellergren/css_naked_day_rails/blob/main/CHANGELOG.md
51
+ rubygems_mfa_required: 'true'
25
52
  rdoc_options: []
26
53
  require_paths:
27
54
  - lib
@@ -29,15 +56,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
29
56
  requirements:
30
57
  - - ">="
31
58
  - !ruby/object:Gem::Version
32
- version: '0'
59
+ version: 2.2.2
33
60
  required_rubygems_version: !ruby/object:Gem::Requirement
34
61
  requirements:
35
62
  - - ">="
36
63
  - !ruby/object:Gem::Version
37
64
  version: '0'
38
65
  requirements: []
39
- rubygems_version: 3.1.2
40
- signing_key:
66
+ rubygems_version: 4.0.21
41
67
  specification_version: 4
42
68
  summary: CSS Naked Day!
43
69
  test_files: []