raindeer 1.0.60 → 1.0.61
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 +4 -4
- data/lib/matrix/matrix.rb +10 -1
- data/lib/matrix/matrix.yaml +17 -0
- data/lib/sites/locale.rb +5 -2
- data/lib/sites/site.rb +8 -2
- data/lib/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e154ff21d5679cf65f53508a974447940f65447a13d8a09b02ea3d4a3a4bcca7
|
|
4
|
+
data.tar.gz: 16152dd4365bac4efb442b3e352f7682dd934611e1504f282dade927709c2b3b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 262694665b4dcbdfe1b2aceeac6cd4d83c8586a40b8565f09536a2b5467494d6f447fee02140b25d7672d863d54c272038bc5c58109f4cdc1a6e734bf6c9904c
|
|
7
|
+
data.tar.gz: c9139394a9fe29bc8c5b6e6095f7f255f49da1e1ea009b1ed0a4f8b4f4a0c196e46b4d3e920acb7d351089d58843e8f7c721799d484afc6bbc4adea73c898147
|
data/lib/matrix/matrix.rb
CHANGED
|
@@ -15,7 +15,16 @@ module Rain
|
|
|
15
15
|
include LowType
|
|
16
16
|
include Observers
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
# The gem's matrix.yaml is always there and an app's config/matrix.yaml overrides its settings.
|
|
19
|
+
def self.load_config
|
|
20
|
+
gem_path = File.expand_path('matrix.yaml', __dir__)
|
|
21
|
+
app_path = File.expand_path('config/matrix.yaml', Dir.pwd)
|
|
22
|
+
return ConfigLoader.load(gem_path) unless File.exist?(app_path)
|
|
23
|
+
|
|
24
|
+
ConfigLoader.load(gem_path, ConfigLoader.load(app_path).to_h)
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def initialize(event_pool:, config: Matrix.load_config)
|
|
19
28
|
@event_pool = event_pool
|
|
20
29
|
@config = config
|
|
21
30
|
@effects = [(LeetEffect.new(config:) if config.leet), ColorEffect.new(config:)].compact
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
cell_color: '#0098fc'
|
|
2
|
+
lead_color: '#ffffff'
|
|
3
|
+
start_col: :random # Options are :random, :latest
|
|
4
|
+
start_row: :random # Options are :random, 0
|
|
5
|
+
min_delay: 75
|
|
6
|
+
fade: true
|
|
7
|
+
fade_delay: 250
|
|
8
|
+
leet: true
|
|
9
|
+
leet_keys:
|
|
10
|
+
'a': '4'
|
|
11
|
+
'b': '8'
|
|
12
|
+
'e': '3'
|
|
13
|
+
'g': '9'
|
|
14
|
+
'i': '1'
|
|
15
|
+
'o': '0'
|
|
16
|
+
's': '5'
|
|
17
|
+
't': '7'
|
data/lib/sites/locale.rb
CHANGED
|
@@ -4,10 +4,13 @@ require_relative 'request_header'
|
|
|
4
4
|
|
|
5
5
|
module Rain
|
|
6
6
|
# Who a response is for: the language it's written in and the region its visitor is in, which can differ, like an
|
|
7
|
-
# American reading the Australian site. The language is the
|
|
8
|
-
# are, or else the site's own. The region is the site's, or else the
|
|
7
|
+
# American reading the Australian site. The language is the site's when config.yaml sets it, or else the visitor's
|
|
8
|
+
# Accept-Language among the translations there are, or else the site's own. The region is the site's, or else the
|
|
9
|
+
# country a CDN like Cloudflare found them in.
|
|
9
10
|
Locale = Data.define(:language, :region) do
|
|
10
11
|
def self.from_request(request, site:)
|
|
12
|
+
return new(language: site.language, region: site.region || cloudflare_country(request)) if site.fixed_language?
|
|
13
|
+
|
|
11
14
|
accept_language = RequestHeader.joined(request, 'accept-language')
|
|
12
15
|
language = Translations.negotiate(accept_language: (accept_language unless accept_language&.strip&.empty?), default: site.language)
|
|
13
16
|
new(language:, region: site.region || cloudflare_country(request))
|
data/lib/sites/site.rb
CHANGED
|
@@ -6,10 +6,11 @@ require_relative 'request_header'
|
|
|
6
6
|
module Rain
|
|
7
7
|
# A site the app serves, by the host a request came to, like sourdough.com.au: its origin to link back to, the region
|
|
8
8
|
# its visitors are most likely in, and the language its pages are written in. Hosts are set under "sites" in
|
|
9
|
-
# config.yaml, and a host that isn't there is a site of its own without a region
|
|
9
|
+
# config.yaml, and a host that isn't there is a site of its own without a region. A site whose language is set is
|
|
10
|
+
# always in it, whatever a visitor's browser asks for, and one without follows each visitor's Accept-Language:
|
|
10
11
|
#
|
|
11
12
|
# sites:
|
|
12
|
-
# sourdough.com.au: { region: AU }
|
|
13
|
+
# sourdough.com.au: { region: AU, language: en-AU }
|
|
13
14
|
# sourdough.com: {}
|
|
14
15
|
Site = Data.define(:host, :origin, :region, :language) do
|
|
15
16
|
# The site a request came to, by its Host header and the scheme a proxy like Caddy forwarded it with.
|
|
@@ -47,6 +48,11 @@ module Rain
|
|
|
47
48
|
configured
|
|
48
49
|
end
|
|
49
50
|
|
|
51
|
+
# Whether config.yaml sets its language, so every visitor reads it in that one.
|
|
52
|
+
def fixed_language?
|
|
53
|
+
!self.class.configured.dig(host, :language).nil?
|
|
54
|
+
end
|
|
55
|
+
|
|
50
56
|
# Its name in an hreflang link, like en-au, or x-default for a site without a region, which is for everyone else.
|
|
51
57
|
def hreflang
|
|
52
58
|
return 'x-default' unless region
|
data/lib/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: raindeer
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.0.
|
|
4
|
+
version: 1.0.61
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- maedi
|
|
@@ -336,6 +336,7 @@ files:
|
|
|
336
336
|
- lib/matrix/effects/effect.rb
|
|
337
337
|
- lib/matrix/effects/leet_effect.rb
|
|
338
338
|
- lib/matrix/matrix.rb
|
|
339
|
+
- lib/matrix/matrix.yaml
|
|
339
340
|
- lib/matrix/stream.rb
|
|
340
341
|
- lib/pages/pages.rb
|
|
341
342
|
- lib/raindeer/boot.rb
|