Skip to content

Commit

Permalink
Merge branch 'glitch-soc-main' into mastodon.galileivr.org
Browse files Browse the repository at this point in the history
  • Loading branch information
ciao1092 committed Feb 29, 2024
2 parents 577414d + 33aca62 commit 438ff90
Show file tree
Hide file tree
Showing 40 changed files with 347 additions and 393 deletions.
18 changes: 9 additions & 9 deletions .devcontainer/codespaces/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}",

"features": {
"ghcr.io/devcontainers/features/sshd:1": {},
"ghcr.io/devcontainers/features/sshd:1": {}
},

"runServices": ["app", "db", "redis"],
Expand All @@ -15,16 +15,16 @@
"portsAttributes": {
"3000": {
"label": "web",
"onAutoForward": "notify",
"onAutoForward": "notify"
},
"4000": {
"label": "stream",
"onAutoForward": "silent",
},
"onAutoForward": "silent"
}
},

"otherPortsAttributes": {
"onAutoForward": "silent",
"onAutoForward": "silent"
},

"remoteEnv": {
Expand All @@ -33,7 +33,7 @@
"STREAMING_API_BASE_URL": "https://${localEnv:CODESPACE_NAME}-4000.app.github.dev",
"DISABLE_FORGERY_REQUEST_PROTECTION": "true",
"ES_ENABLED": "",
"LIBRE_TRANSLATE_ENDPOINT": "",
"LIBRE_TRANSLATE_ENDPOINT": ""
},

"onCreateCommand": "git config --global --add safe.directory ${containerWorkspaceFolder}",
Expand All @@ -43,7 +43,7 @@
"customizations": {
"vscode": {
"settings": {},
"extensions": ["EditorConfig.EditorConfig", "webben.browserslist"],
},
},
"extensions": ["EditorConfig.EditorConfig", "webben.browserslist"]
}
}
}
16 changes: 8 additions & 8 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}",

"features": {
"ghcr.io/devcontainers/features/sshd:1": {},
"ghcr.io/devcontainers/features/sshd:1": {}
},

"forwardPorts": [3000, 4000],
Expand All @@ -14,17 +14,17 @@
"3000": {
"label": "web",
"onAutoForward": "notify",
"requireLocalPort": true,
"requireLocalPort": true
},
"4000": {
"label": "stream",
"onAutoForward": "silent",
"requireLocalPort": true,
},
"requireLocalPort": true
}
},

"otherPortsAttributes": {
"onAutoForward": "silent",
"onAutoForward": "silent"
},

"onCreateCommand": "git config --global --add safe.directory ${containerWorkspaceFolder}",
Expand All @@ -34,7 +34,7 @@
"customizations": {
"vscode": {
"settings": {},
"extensions": ["EditorConfig.EditorConfig", "webben.browserslist"],
},
},
"extensions": ["EditorConfig.EditorConfig", "webben.browserslist"]
}
}
}
4 changes: 3 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,6 @@ module.exports = defineConfig({
'plugin:import/typescript',
'plugin:promise/recommended',
'plugin:jsdoc/recommended-typescript',
'plugin:prettier/recommended',
],

parserOptions: {
Expand All @@ -364,6 +363,9 @@ module.exports = defineConfig({
},

rules: {
// Disable formatting rules that have been enabled in the base config
'indent': 'off',

'import/consistent-type-specifier-style': ['error', 'prefer-top-level'],

'@typescript-eslint/consistent-type-definitions': ['warn', 'interface'],
Expand Down
18 changes: 18 additions & 0 deletions .github/workflows/format-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Check formatting
on:
push:
pull_request:

jobs:
lint:
runs-on: ubuntu-latest

steps:
- name: Clone repository
uses: actions/checkout@v4

- name: Set up Javascript environment
uses: ./.github/actions/setup-javascript

- name: Check formatting with Prettier
run: yarn format:check
50 changes: 50 additions & 0 deletions .github/workflows/lint-css.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: CSS Linting
on:
push:
branches-ignore:
- 'dependabot/**'
- 'renovate/**'
paths:
- 'package.json'
- 'yarn.lock'
- '.nvmrc'
- '.prettier*'
- 'stylelint.config.js'
- '**/*.css'
- '**/*.scss'
- '.github/workflows/lint-css.yml'
- '.github/stylelint-matcher.json'

pull_request:
paths:
- 'package.json'
- 'yarn.lock'
- '.nvmrc'
- '.prettier*'
- 'stylelint.config.js'
- '**/*.css'
- '**/*.scss'
- '.github/workflows/lint-css.yml'
- '.github/stylelint-matcher.json'

jobs:
lint:
runs-on: ubuntu-latest

steps:
- name: Clone repository
uses: actions/checkout@v4

- name: Set up Javascript environment
uses: ./.github/actions/setup-javascript

- uses: xt0rted/stylelint-problem-matcher@v1

- run: echo "::add-matcher::.github/stylelint-matcher.json"

- name: Stylelint
run: yarn lint:css
<<<<<<< HEAD

=======
>>>>>>> 0d55610f9610b9fd84e393e5821184401a97b71b
8 changes: 8 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,13 @@
# Ignore Docker option files
docker-compose.override.yml

# Ignore public
/public/assets
/public/emoji
/public/packs
/public/packs-test
/public/system

# Ignore emoji map file
/app/javascript/mastodon/features/emoji/emoji_map.json

Expand All @@ -74,6 +81,7 @@ app/javascript/styles/mastodon/reset.scss
# Ignore the generated AUTHORS.md
AUTHORS.md

# Process a few selected JS files
!lint-staged.config.js

# Ignore glitch-soc emoji map file
Expand Down
22 changes: 13 additions & 9 deletions app/javascript/core/admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ const hideSelectAll = () => {
Rails.delegate(document, '#batch_checkbox_all', 'change', ({ target }) => {
const selectAllMatchingElement = document.querySelector('.batch-table__select-all');

[].forEach.call(document.querySelectorAll(batchCheckboxClassName), (content) => {
document.querySelectorAll(batchCheckboxClassName).forEach((content) => {
content.checked = target.checked;
});

Expand Down Expand Up @@ -80,8 +80,11 @@ Rails.delegate(document, batchCheckboxClassName, 'change', () => {
const selectAllMatchingElement = document.querySelector('.batch-table__select-all');

if (checkAllElement) {
checkAllElement.checked = [].every.call(document.querySelectorAll(batchCheckboxClassName), (content) => content.checked);
checkAllElement.indeterminate = !checkAllElement.checked && [].some.call(document.querySelectorAll(batchCheckboxClassName), (content) => content.checked);
const allCheckboxes = Array.from(
document.querySelectorAll(batchCheckboxClassName)
);
checkAllElement.checked = allCheckboxes.every((content) => content.checked);
checkAllElement.indeterminate = !checkAllElement.checked && allCheckboxes.some((content) => content.checked);

if (selectAllMatchingElement) {
if (checkAllElement.checked) {
Expand Down Expand Up @@ -132,11 +135,11 @@ Rails.delegate(document, '#form_admin_settings_enable_bootstrap_timeline_account
const onChangeRegistrationMode = (target) => {
const enabled = target.value === 'approved';

[].forEach.call(document.querySelectorAll('.form_admin_settings_registrations_mode .warning-hint'), (warning_hint) => {
document.querySelectorAll('.form_admin_settings_registrations_mode .warning-hint').forEach((warning_hint) => {
warning_hint.style.display = target.value === 'open' ? 'inline' : 'none';
});

[].forEach.call(document.querySelectorAll('#form_admin_settings_require_invite_text'), (input) => {
document.querySelectorAll('#form_admin_settings_require_invite_text').forEach((input) => {
input.disabled = !enabled;
if (enabled) {
let element = input;
Expand Down Expand Up @@ -182,8 +185,9 @@ ready(() => {

const checkAllElement = document.querySelector('#batch_checkbox_all');
if (checkAllElement) {
checkAllElement.checked = [].every.call(document.querySelectorAll(batchCheckboxClassName), (content) => content.checked);
checkAllElement.indeterminate = !checkAllElement.checked && [].some.call(document.querySelectorAll(batchCheckboxClassName), (content) => content.checked);
const allCheckboxes = Array.from(document.querySelectorAll(batchCheckboxClassName));
checkAllElement.checked = allCheckboxes.every( (content) => content.checked);
checkAllElement.indeterminate = !checkAllElement.checked && allCheckboxes.some((content) => content.checked);
}

document.querySelector('a#add-instance-button')?.addEventListener('click', (e) => {
Expand All @@ -196,7 +200,7 @@ ready(() => {
}
});

[].forEach.call(document.querySelectorAll('input[type="datetime-local"]'), element => {
document.querySelectorAll('input[type="datetime-local"]').forEach(element => {
if (element.value) {
element.value = convertUTCDateTimeToLocal(element.value);
}
Expand All @@ -206,7 +210,7 @@ ready(() => {
});

Rails.delegate(document, 'form', 'submit', ({ target }) => {
[].forEach.call(target.querySelectorAll('input[type="datetime-local"]'), element => {
target.querySelectorAll('input[type="datetime-local"]').forEach(element => {
if (element.value && element.validity.valid) {
element.value = convertLocalDatetimeToUTC(element.value);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export default class MediaContainer extends PureComponent {
return (
<IntlProvider>
<>
{[].map.call(components, (component, i) => {
{Array.from(components).map((component, i) => {
const componentName = component.getAttribute('data-component');
const Component = MEDIA_COMPONENTS[componentName];
const { media, card, poll, hashtag, ...props } = JSON.parse(component.getAttribute('data-props'));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Object.keys(emojiIndex.emojis).forEach(key => {
let emoji = emojiIndex.emojis[key];

// Emojis with skin tone modifiers are stored like this
if (Object.prototype.hasOwnProperty.call(emoji, '1')) {
if (Object.hasOwn(emoji, '1')) {
emoji = emoji['1'];
}

Expand Down Expand Up @@ -88,7 +88,7 @@ Object.keys(emojiIndex.emojis).forEach(key => {
let emoji = emojiIndex.emojis[key];

// Emojis with skin tone modifiers are stored like this
if (Object.prototype.hasOwnProperty.call(emoji, '1')) {
if (Object.hasOwn(emoji, '1')) {
emoji = emoji['1'];
}

Expand Down
10 changes: 5 additions & 5 deletions app/javascript/flavours/glitch/features/emoji/emoji_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,19 +135,19 @@ function getData(emoji, skin, set) {
}
}

if (Object.prototype.hasOwnProperty.call(data.short_names, emoji)) {
if (Object.hasOwn(data.short_names, emoji)) {
emoji = data.short_names[emoji];
}

if (Object.prototype.hasOwnProperty.call(data.emojis, emoji)) {
if (Object.hasOwn(data.emojis, emoji)) {
emojiData = data.emojis[emoji];
}
} else if (emoji.id) {
if (Object.prototype.hasOwnProperty.call(data.short_names, emoji.id)) {
if (Object.hasOwn(data.short_names, emoji.id)) {
emoji.id = data.short_names[emoji.id];
}

if (Object.prototype.hasOwnProperty.call(data.emojis, emoji.id)) {
if (Object.hasOwn(data.emojis, emoji.id)) {
emojiData = data.emojis[emoji.id];
skin = skin || emoji.skin;
}
Expand Down Expand Up @@ -216,7 +216,7 @@ function deepMerge(a, b) {
let originalValue = a[key],
value = originalValue;

if (Object.prototype.hasOwnProperty.call(b, key)) {
if (Object.hasOwn(b, key)) {
value = b[key];
}

Expand Down
4 changes: 2 additions & 2 deletions app/javascript/flavours/glitch/packs/admin.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import { createRoot } from 'react-dom/client';
import ready from 'flavours/glitch/ready';

ready(() => {
[].forEach.call(document.querySelectorAll('[data-admin-component]'), element => {
document.querySelectorAll('[data-admin-component]').forEach(element => {
const componentName = element.getAttribute('data-admin-component');
const { ...componentProps } = JSON.parse(element.getAttribute('data-props'));
const componentProps = JSON.parse(element.getAttribute('data-props'));

import('flavours/glitch/containers/admin_component').then(({ default: AdminComponent }) => {
return import('flavours/glitch/components/admin/' + componentName).then(({ default: Component }) => {
Expand Down
14 changes: 7 additions & 7 deletions app/javascript/flavours/glitch/packs/public.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,11 @@ function main() {
return messageFormat.format(values);
};

[].forEach.call(document.querySelectorAll('.emojify'), (content) => {
document.querySelectorAll('.emojify').forEach((content) => {
content.innerHTML = emojify(content.innerHTML);
});

[].forEach.call(document.querySelectorAll('time.formatted'), (content) => {
document.querySelectorAll('time.formatted').forEach((content) => {
const datetime = new Date(content.getAttribute('datetime'));
const formattedDate = dateTimeFormat.format(datetime);

Expand All @@ -89,7 +89,7 @@ function main() {
};
const todayFormat = new IntlMessageFormat(localeData['relative_format.today'] || 'Today at {time}', locale);

[].forEach.call(document.querySelectorAll('time.relative-formatted'), (content) => {
document.querySelectorAll('time.relative-formatted').forEach((content) => {
const datetime = new Date(content.getAttribute('datetime'));

let formattedContent;
Expand All @@ -106,7 +106,7 @@ function main() {
content.textContent = formattedContent;
});

[].forEach.call(document.querySelectorAll('time.time-ago'), (content) => {
document.querySelectorAll('time.time-ago').forEach((content) => {
const datetime = new Date(content.getAttribute('datetime'));
const now = new Date();

Expand All @@ -122,8 +122,8 @@ function main() {
if (reactComponents.length > 0) {
import(/* webpackChunkName: "containers/media_container" */ 'flavours/glitch/containers/media_container')
.then(({ default: MediaContainer }) => {
[].forEach.call(reactComponents, (component) => {
[].forEach.call(component.children, (child) => {
reactComponents.forEach((component) => {
Array.from(component.children).forEach((child) => {
component.removeChild(child);
});
});
Expand Down Expand Up @@ -188,7 +188,7 @@ function main() {
return false;
});

[].forEach.call(document.querySelectorAll('.status__content__spoiler-link'), (spoilerLink) => {
document.querySelectorAll('.status__content__spoiler-link').forEach((spoilerLink) => {
const statusEl = spoilerLink.parentNode.parentNode;
const message = (statusEl.dataset.spoiler === 'expanded') ? (localeData['status.show_less'] || 'Show less') : (localeData['status.show_more'] || 'Show more');
spoilerLink.textContent = (new IntlMessageFormat(message, locale)).format();
Expand Down
Loading

0 comments on commit 438ff90

Please sign in to comment.