forked from mastodon/mastodon
-
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'parent/main' into upstream-20240408
- Loading branch information
Showing
27 changed files
with
324 additions
and
119 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -208,3 +208,5 @@ gem 'net-http', '~> 0.4.0' | |
gem 'rubyzip', '~> 2.3' | ||
|
||
gem 'hcaptcha', '~> 7.1' | ||
|
||
gem 'mail', '~> 2.8' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# frozen_string_literal: true | ||
|
||
module ThemeHelper | ||
def theme_style_tags(theme) | ||
if theme == 'system' | ||
concat stylesheet_pack_tag('mastodon-light', media: 'not all and (prefers-color-scheme: dark)', crossorigin: 'anonymous') | ||
concat stylesheet_pack_tag('default', media: '(prefers-color-scheme: dark)', crossorigin: 'anonymous') | ||
else | ||
stylesheet_pack_tag theme, media: 'all', crossorigin: 'anonymous' | ||
end | ||
end | ||
|
||
def theme_color_tags(theme) | ||
if theme == 'system' | ||
concat tag.meta(name: 'theme-color', content: Themes::THEME_COLORS[:dark], media: '(prefers-color-scheme: dark)') | ||
concat tag.meta(name: 'theme-color', content: Themes::THEME_COLORS[:light], media: '(prefers-color-scheme: light)') | ||
else | ||
tag.meta name: 'theme-color', content: theme_color_for(theme) | ||
end | ||
end | ||
|
||
private | ||
|
||
def theme_color_for(theme) | ||
theme == 'mastodon-light' ? Themes::THEME_COLORS[:light] : Themes::THEME_COLORS[:dark] | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { DECIMAL_UNITS, toShortNumber } from '../numbers'; | ||
|
||
interface TableRow { | ||
input: number; | ||
base: number; | ||
unit: number; | ||
digits: number; | ||
} | ||
|
||
describe.each` | ||
input | base | unit | digits | ||
${10_000_000} | ${10} | ${DECIMAL_UNITS.MILLION} | ${0} | ||
${2_789_123} | ${2.789123} | ${DECIMAL_UNITS.MILLION} | ${1} | ||
${12_345_789} | ${12.345789} | ${DECIMAL_UNITS.MILLION} | ${0} | ||
${10_000_000_000} | ${10} | ${DECIMAL_UNITS.BILLION} | ${0} | ||
${12} | ${12} | ${DECIMAL_UNITS.ONE} | ${0} | ||
${123} | ${123} | ${DECIMAL_UNITS.ONE} | ${0} | ||
${1234} | ${1.234} | ${DECIMAL_UNITS.THOUSAND} | ${1} | ||
${6666} | ${6.666} | ${DECIMAL_UNITS.THOUSAND} | ${1} | ||
`('toShortNumber', ({ input, base, unit, digits }: TableRow) => { | ||
test(`correctly formats ${input}`, () => { | ||
expect(toShortNumber(input)).toEqual([base, unit, digits]); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# frozen_string_literal: true | ||
|
||
module CustomFilterCache | ||
extend ActiveSupport::Concern | ||
|
||
included do | ||
after_commit :invalidate_cache! | ||
before_destroy :prepare_cache_invalidation! | ||
before_save :prepare_cache_invalidation! | ||
|
||
delegate( | ||
:invalidate_cache!, | ||
:prepare_cache_invalidation!, | ||
to: :custom_filter | ||
) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# frozen_string_literal: true | ||
|
||
# NOTE: I initially wrote this as `EmailValidator` but it ended up clashing | ||
# with an indirect dependency of ours, `validate_email`, which, turns out, | ||
# has the same approach as we do, but with an extra check disallowing | ||
# single-label domains. Decided to not switch to `validate_email` because | ||
# we do want to allow at least `localhost`. | ||
|
||
class EmailAddressValidator < ActiveModel::EachValidator | ||
def validate_each(record, attribute, value) | ||
value = value.strip | ||
|
||
address = Mail::Address.new(value) | ||
record.errors.add(attribute, :invalid) if address.address != value | ||
rescue Mail::Field::FieldError | ||
record.errors.add(attribute, :invalid) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.