Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: custom splash text #153

Merged
merged 4 commits into from
Aug 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 5 additions & 11 deletions .github/workflows/deploy-test-environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,13 @@ jobs:
- name: Check allowed users
id: check-allowed-users
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
ORG_ID: ${{ github.repository_owner_id }}
COMMENT_AUTHOR: ${{ github.event.comment.user.login }}
ALLOWED_USER: ${{ github.repository_owner_id }}
COMMENT_AUTHOR: ${{ github.event.comment.user.id }}
run: |
MEMBERSHIP_STATUS=$(curl -s -H "Authorization: Bearer $GITHUB_TOKEN" \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
"https://api.github.com/organizations/$ORG_ID/public_members/$COMMENT_AUTHOR" \
-o /dev/null -w '%{http_code}\n' -s)
if [ "$MEMBERSHIP_STATUS" -eq 204 ]; then
echo "is-allowed-user=true" > $GITHUB_OUTPUT
if ["$COMMENT_AUTHOR" = "$ALLOWED_USER"]; then
echo "is-allowed-user=true" >> $GITHUB_OUTPUT
else
echo "is-allowed-user=false" > $GITHUB_OUTPUT
echo "is-allowed-user=false" >> $GITHUB_OUTPUT
fi

- name: Get PR ref
Expand Down
18 changes: 17 additions & 1 deletion CHANGELOG_engawa.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,23 @@
### Misc

-->
## x.x.x (unreleased)
## 0.5.1(unreleased)

### Release Date

### General
- スプラッシュスクリーン(画面ロード時にぐるぐるが表示される画面)にカスタムテキストを適用できるように

### Client
-

### Server
-

### Misc


## 0.5.0

### Release Date

Expand Down
2 changes: 2 additions & 0 deletions locales/en-US.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1179,6 +1179,8 @@ sensitiveWordsDescription2: "Using spaces will create AND expressions and surrou
prohibitedWords: "Prohibited words"
prohibitedWordsDescription: "Enables an error when attempting to post a note containing the set word(s). Multiple words can be set, separated by a new line."
prohibitedWordsDescription2: "Using spaces will create AND expressions and surrounding keywords with slashes will turn them into a regular expression."
customSplashText: "Custom splash text"
customSplashTextDescription: "This text will be displayed on the loading page."
hiddenTags: "Hidden hashtags"
hiddenTagsDescription: "Select tags which will not shown on trend list.\nMultiple tags could be registered by lines."
notesSearchNotAvailable: "Note search is unavailable."
Expand Down
8 changes: 8 additions & 0 deletions locales/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4756,6 +4756,14 @@ export interface Locale extends ILocale {
* スペースで区切るとAND指定になり、キーワードをスラッシュで囲むと正規表現になります。
*/
"prohibitedWordsDescription2": string;
/**
* カスタムスプラッシュテキスト
*/
"customSplashText": string;
/**
* ロード画面に表示されるテキストを設定します。改行で区切って複数設定できます。
*/
"customSplashTextDescription": string;
/**
* 非表示ハッシュタグ
*/
Expand Down
2 changes: 2 additions & 0 deletions locales/ja-JP.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1183,6 +1183,8 @@ sensitiveWordsDescription2: "スペースで区切るとAND指定になり、キ
prohibitedWords: "禁止ワード"
prohibitedWordsDescription: "設定したワードが含まれるノートを投稿しようとした際、エラーとなるようにします。改行で区切って複数設定できます。"
prohibitedWordsDescription2: "スペースで区切るとAND指定になり、キーワードをスラッシュで囲むと正規表現になります。"
customSplashText: "カスタムスプラッシュテキスト"
customSplashTextDescription: "ロード画面に表示されるテキストを設定します。改行で区切って複数設定できます。"
hiddenTags: "非表示ハッシュタグ"
hiddenTagsDescription: "設定したタグをトレンドに表示させないようにします。改行で区切って複数設定できます。"
notesSearchNotAvailable: "ノート検索は利用できません。"
Expand Down
11 changes: 11 additions & 0 deletions packages/backend/migration/1723982389378-AddCustomSplash.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
export class AddCustomSplash1723982389378 {
name = 'AddCustomSplash1723982389378'

async up(queryRunner) {
await queryRunner.query(`ALTER TABLE "meta" ADD "customSplashText" character varying(1024) array NOT NULL DEFAULT '{}'`);
}

async down(queryRunner) {
await queryRunner.query(`ALTER TABLE "meta" DROP COLUMN "customSplashText"`);
}
}
7 changes: 7 additions & 0 deletions packages/backend/src/models/Meta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -765,4 +765,11 @@ export class MiMeta {
nullable: true,
})
public skipCherryPickVersion: string | null;

@Column('varchar', {
length: 1024,
array: true,
default: '{}',
})
public customSplashText: string[];
}
8 changes: 8 additions & 0 deletions packages/backend/src/server/api/endpoints/admin/meta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -567,6 +567,13 @@ export const meta = {
type: 'string',
optional: true, nullable: true,
},
customSplashText: {
type: 'array',
optional: false, nullable: false,
items: {
type: 'string',
},
},
},
},
} as const;
Expand Down Expand Up @@ -731,6 +738,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
enableReceivePrerelease: instance.enableReceivePrerelease,
skipVersion: instance.skipVersion,
skipCherryPickVersion: instance.skipCherryPickVersion,
customSplashText: instance.customSplashText,
};
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,9 @@ export const paramDef = {
enableReceivePrerelease: { type: 'boolean' },
skipVersion: { type: 'boolean' },
skipCherryPickVersion: { type: 'string', nullable: true },
customSplashText: { type: 'array', nullable: true, items: {
type: 'string',
}},
},
required: [],
} as const;
Expand Down Expand Up @@ -769,6 +772,10 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
set.skipCherryPickVersion = ps.skipCherryPickVersion;
}

if (Array.isArray(ps.customSplashText)) {
set.customSplashText = ps.customSplashText.filter(Boolean);
}

const before = await this.metaService.fetch(true);

await this.metaService.update(set);
Expand Down
1 change: 1 addition & 0 deletions packages/backend/src/server/web/ClientServerService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ export class ClientServerService {
instanceUrl: this.config.url,
metaJson: htmlSafeJsonStringify(await this.metaEntityService.packDetailed(meta)),
now: Date.now(),
customSplashText: meta.customSplashText[Math.floor(Math.random() * meta.customSplashText.length)],
};
}

Expand Down
15 changes: 13 additions & 2 deletions packages/backend/src/server/web/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ html {
}

#splash {
position: fixed;
position: relative;
z-index: 10000;
top: 0;
left: 0;
Expand Down Expand Up @@ -45,7 +45,7 @@ html {
display: inline-block;
width: 28px;
height: 28px;
transform: translateY(70px);
transform: translateY(80px);
color: var(--accent);
}
#splashSpinner > .spinner {
Expand All @@ -62,6 +62,17 @@ html {
animation: dash 1.2s ease-in-out infinite;
}

#splashText {
position: absolute;
inset: 0;
margin: auto;
display: inline-block;
inline-size: 70%;
block-size: 0;
text-align: center;
padding-block-start: 200px;
}

@keyframes splashSpinner {
0% {
transform: rotate(0deg);
Expand Down
3 changes: 3 additions & 0 deletions packages/backend/src/server/web/views/base.pug
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ html
| JavaScript를 활성화해주세요
div#splash
img#splashIcon(src= icon || '/static-assets/splash.png')
span#splashText
block customSplashText
= customSplashText
div#splashSpinner
<svg class="spinner" viewBox="0 0 50 50" xmlns="http://www.w3.org/2000/svg">
<circle class="path" cx="25" cy="25" r="20" fill="none" stroke-width="6px" style="fill: none; stroke: currentColor; stroke-width: 6px;"></circle>
Expand Down
2 changes: 2 additions & 0 deletions packages/cherrypick-js/src/autogen/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5407,6 +5407,7 @@ export type operations = {
enableReceivePrerelease: boolean;
skipVersion: boolean;
skipCherryPickVersion?: string | null;
customSplashText: string[];
};
};
};
Expand Down Expand Up @@ -10205,6 +10206,7 @@ export type operations = {
enableReceivePrerelease?: boolean;
skipVersion?: boolean;
skipCherryPickVersion?: string | null;
customSplashText?: string[] | null;
};
};
};
Expand Down
8 changes: 8 additions & 0 deletions packages/frontend/src/pages/admin/branding.vue
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@ SPDX-License-Identifier: AGPL-3.0-only
<MkTextarea v-model="manifestJsonOverride">
<template #label>{{ i18n.ts._serverSettings.manifestJsonOverride }}</template>
</MkTextarea>

<MkTextarea v-model="customSplashText">
<template #label>{{ i18n.ts.customSplashText }}</template>
<template #caption>{{ i18n.ts.customSplashTextDescription }}</template>
</MkTextarea>
</div>
</FormSuspense>
</MkSpacer>
Expand Down Expand Up @@ -133,6 +138,7 @@ const notFoundImageUrl = ref<string | null>(null);
const repositoryUrl = ref<string | null>(null);
const feedbackUrl = ref<string | null>(null);
const manifestJsonOverride = ref<string>('{}');
const customSplashText = ref<string>('');

async function init() {
const meta = await misskeyApi('admin/meta');
Expand All @@ -150,6 +156,7 @@ async function init() {
repositoryUrl.value = meta.repositoryUrl;
feedbackUrl.value = meta.feedbackUrl;
manifestJsonOverride.value = meta.manifestJsonOverride === '' ? '{}' : JSON.stringify(JSON.parse(meta.manifestJsonOverride), null, '\t');
customSplashText.value = meta.customSplashText.join('\n');
}

function save() {
Expand All @@ -168,6 +175,7 @@ function save() {
repositoryUrl: repositoryUrl.value === '' ? null : repositoryUrl.value,
feedbackUrl: feedbackUrl.value === '' ? null : feedbackUrl.value,
manifestJsonOverride: manifestJsonOverride.value === '' ? '{}' : JSON.stringify(JSON5.parse(manifestJsonOverride.value)),
customSplashText: customSplashText.value.split('\n'),
}).then(() => {
fetchInstance(true);
});
Expand Down
Loading