Skip to content

Commit bae09a6

Browse files
committed
Merge remote-tracking branch 'philo/1_2_stable'
2 parents 1188845 + d8da7ad commit bae09a6

File tree

104 files changed

+1460
-2124
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

104 files changed

+1460
-2124
lines changed

.dialyzer_ignore.exs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
[
2+
{"lib/philomena/adverts/restrictions.ex", :call_without_opaque},
3+
{"lib/philomena/artist_links.ex", :call_without_opaque},
4+
{"lib/philomena/bans.ex", :call_without_opaque},
5+
{"lib/philomena/comments.ex", :call_without_opaque},
6+
{"lib/philomena/commissions.ex", :call_without_opaque},
7+
{"lib/philomena/conversations.ex", :call_without_opaque},
8+
{"lib/philomena/duplicate_reports.ex", :call_without_opaque},
9+
{"lib/philomena/galleries.ex", :call_without_opaque},
10+
{"lib/philomena/image_faves.ex", :call_without_opaque},
11+
{"lib/philomena/image_hides.ex", :call_without_opaque},
12+
{"lib/philomena/image_votes.ex", :call_without_opaque},
13+
{"lib/philomena/images.ex", :call_without_opaque},
14+
{"lib/philomena/images/tag_validator.ex", :call_without_opaque},
15+
{"lib/philomena/interactions.ex", :call_without_opaque},
16+
{"lib/philomena/poll_votes.ex", :call_without_opaque},
17+
{"lib/philomena/posts.ex", :call_without_opaque},
18+
{"lib/philomena/static_pages.ex", :call_without_opaque},
19+
{"lib/philomena/tags.ex", :call_without_opaque},
20+
{"lib/philomena/topics.ex", :call_without_opaque},
21+
{"lib/philomena/users.ex", :call_without_opaque},
22+
{"lib/philomena/users/user.ex", :call_without_opaque},
23+
{"lib/philomena_web/plugs/content_security_policy_plug.ex", :call_without_opaque}
24+
]

.github/workflows/elixir.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,12 @@ jobs:
4545
name: Rust Linting and Unit Tests
4646
runs-on: ubuntu-latest
4747
steps:
48-
- uses: actions/checkout@v4
48+
- uses: actions/checkout@v5
4949

5050
- name: Setup Rust
51-
uses: dtolnay/rust-toolchain@stable
51+
uses: dtolnay/[email protected]
52+
with:
53+
components: clippy, rustfmt
5254

5355
- name: cargo fmt
5456
run: (cd native/philomena && cargo fmt --check)

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ npm-debug.log
3030

3131
# The directory NPM downloads your dependencies sources to.
3232
/assets/node_modules/
33+
/node_modules
3334

3435
# Since we are building assets from assets/,
3536
# we ignore priv/static. You may want to comment
@@ -64,3 +65,6 @@ npm-debug.log
6465

6566
# Vitest coverage
6667
/assets/coverage
68+
69+
# OS junk
70+
.DS_Store

assets/js/__tests__/tagsinput.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ describe('Fancy tags input', () => {
166166
it('adds new tag when comma is pressed', () => {
167167
setupTagsInput(tagBlock);
168168

169-
const ev = new KeyboardEvent('keydown', { keyCode: 188, bubbles: true });
169+
const ev = new KeyboardEvent('keydown', { keyCode: 188, key: ',', bubbles: true });
170170
fancyText.value = 'a';
171171
fancyText.dispatchEvent(ev);
172172

assets/js/image_expansion.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ function selectVersion(imageWidth, imageHeight, imageSize, imageMime) {
4444
// Sanity check to make sure we're not serving unintentionally huge assets
4545
// all at once (where "huge" > 25 MiB). Videos are loaded in chunks so it
4646
// doesn't matter too much there.
47-
if (imageMime === 'video/webm' || imageSize <= 26214400) {
47+
if (imageMime === 'video/webm' || imageSize <= 26_214_400) {
4848
return 'full';
4949
}
5050

assets/js/tagsinput.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ export function setupTagsInput(tagBlock: HTMLDivElement) {
7171
}
7272

7373
function handleKeyEvent(event: KeyboardEvent) {
74-
const { ctrlKey, shiftKey } = event;
74+
const { ctrlKey } = event;
7575
const key = normalizedKeyboardKey(event);
7676

7777
// allow form submission with ctrl+enter if no text was typed
@@ -86,7 +86,7 @@ export function setupTagsInput(tagBlock: HTMLDivElement) {
8686
if (erased) removeTag(tags[tags.length - 1], erased);
8787
}
8888

89-
if (key === keys.Enter || (key === keys.Comma && !shiftKey)) {
89+
if (key === keys.Enter || key === keys.Comma) {
9090
event.preventDefault();
9191
inputField.value.split(',').forEach(t => insertTag(t));
9292
inputField.value = '';

assets/js/utils/keyboard.ts

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,23 @@ const keysMapping = {
4141
88: 'KeyX',
4242
89: 'KeyY',
4343
90: 'KeyZ',
44-
188: 'Comma',
44+
// keyCode stays the same in various layouts, but actual value of the key differs
45+
// and works in unexpected way
46+
// 188: 'Comma',
4547
} as const;
4648

49+
const literalKeysMapping = {
50+
',': 'Comma',
51+
} as const;
52+
53+
type keysAsEnum<Obj extends Record<string, string>> = Record<Obj[keyof Obj], string>;
54+
4755
/**
4856
* A map of known keys to be used in code to avoid typos.
4957
*/
50-
export const keys = Object.fromEntries(Object.values(keysMapping).map(key => [key, key]));
58+
export const keys = Object.fromEntries(
59+
(Object.values(keysMapping) as string[]).concat(Object.values(literalKeysMapping)).map(key => [key, key]),
60+
) as keysAsEnum<typeof keysMapping & typeof literalKeysMapping>;
5161

5262
/**
5363
* There are many inconsistencies in the way different browsers handle keyboard
@@ -58,12 +68,15 @@ export const keys = Object.fromEntries(Object.values(keysMapping).map(key => [ke
5868
* pressed via the virtual keyboard.
5969
* - There seems to be no way to reliably detect the `,` key on virtual
6070
* keyboards on phones.
71+
* - `,` key also have different placements in different layouts.
6172
* - The `event.code` uses `NumpadEnter` for the numpad enter key on regular
6273
* keyboards
6374
*/
6475
export function normalizedKeyboardKey(event: KeyboardEvent): string {
76+
const literalKey = asRecord(literalKeysMapping)[event.key];
77+
6578
// It is possible that this chain goes all the way to the `event.key` because
6679
// on mobile phones the `Enter` key has empty `code` for some reason, but it
6780
// has `Enter` as `key`.
68-
return asRecord(keysMapping)[event.keyCode] || event.code || event.key;
81+
return literalKey || asRecord(keysMapping)[event.keyCode] || event.code || event.key;
6982
}

0 commit comments

Comments
 (0)