Compare commits

...

7 Commits

Author SHA1 Message Date
Linca 390482f494 Merge branch 'feat/pwa-use-site-ico' into 'develop'
Draft: feat: Generate PWA icons from the server logo (Catodon issue 7)

Co-authored-by: Lhcfl <Lhcfl@outlook.com>

See merge request firefish/firefish!10783
2024-05-07 02:09:51 +00:00
naskya 82c98ae72f
ci: modify buildah args 2024-05-07 07:26:33 +09:00
naskya 5b3f93457b
dev: add renovate 2024-05-07 06:58:00 +09:00
naskya 4d9c0f8e7b
ci: fix syntax 2024-05-07 06:11:31 +09:00
naskya bf2b624bc9
ci: build OCI container image on develop 2024-05-07 05:52:43 +09:00
naskya 5261eb24b6
ci: restrict project path 2024-05-07 05:26:05 +09:00
Lhcfl bfa8bc5f7d feat: use instance iconUrl as PWA icon 2024-04-30 11:35:06 +08:00
3 changed files with 109 additions and 7 deletions

View File

@ -6,6 +6,14 @@ services:
- name: docker.io/redis:7-alpine
alias: redis
workflow:
rules:
- if: $CI_PROJECT_PATH == 'firefish/firefish'
when: always
- if: $CI_MERGE_REQUEST_PROJECT_PATH == 'firefish/firefish'
when: always
- when: never
cache:
paths:
- node_modules
@ -16,6 +24,8 @@ cache:
stages:
- test
- build
- dependency
variables:
POSTGRES_DB: 'firefish_db'
@ -29,7 +39,6 @@ variables:
default:
before_script:
- mkdir -p "${CARGO_HOME}"
- apt-get update && apt-get -y upgrade
- apt-get -y --no-install-recommends install curl
- curl -fsSL 'https://deb.nodesource.com/setup_18.x' | bash -
@ -48,7 +57,21 @@ build_test:
- pnpm run build:debug
- pnpm run migrate
build_and_cargo_unit_test:
container_image_build:
stage: build
image: docker.io/debian:bookworm-slim
services: []
before_script: []
rules:
- if: $CI_COMMIT_BRANCH == 'develop'
script:
- apt-get update && apt-get -y upgrade
- apt-get install -y --no-install-recommends buildah ca-certificates
- buildah login --username "${CI_REGISTRY_USER}" --password "${CI_REGISTRY_PASSWORD}" "${CI_REGISTRY}"
- buildah build --security-opt seccomp=unconfined --cap-add all --tag "${CI_REGISTRY}/${CI_PROJECT_PATH}/develop:not-for-production" --platform linux/amd64 .
- buildah push "${CI_REGISTRY}/${CI_PROJECT_PATH}/develop:not-for-production" "docker://${CI_REGISTRY}/${CI_PROJECT_PATH}/develop:not-for-production"
cargo_unit_test:
stage: test
rules:
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
@ -69,7 +92,7 @@ build_and_cargo_unit_test:
- pnpm --filter='!backend-rs' run build:debug
- cargo test
clippy:
cargo_clippy:
stage: test
rules:
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
@ -83,3 +106,15 @@ clippy:
when: never
script:
- cargo clippy -- -D warnings
renovate:
stage: dependency
image:
name: docker.io/renovate/renovate:37-slim
entrypoint: [""]
rules:
- if: $RENOVATE && $CI_PIPELINE_SOURCE == 'schedule'
services: []
before_script: []
script:
- renovate --platform gitlab --token "${API_TOKEN}" --endpoint "${CI_SERVER_URL}/api/v4" "${CI_PROJECT_PATH}"

View File

@ -3,19 +3,71 @@ import { fetchMeta } from "backend-rs";
import { config } from "@/config.js";
import manifest from "./manifest.json" assert { type: "json" };
interface Manifest {
short_name: string;
name: string;
description: string;
start_url: string;
scope: string;
display: string;
background_color: string;
theme_color: string;
orientation: string;
icons: {
src: string;
sizes?: string;
type?: string;
purpose?: "any" | "maskable" | "monochrome";
}[];
share_target: {
action: "/share/";
params: {
title: "title";
text: "text";
url: "url";
};
};
screenshots: {
src: string;
sizes: string;
type: string;
platform: string;
label: string;
}[];
shortcuts: {
name: string;
short_name?: string;
url: string;
}[];
categories: string[];
}
export const manifestHandler = async (ctx: Koa.Context) => {
// TODO
//const res = structuredClone(manifest);
const res = JSON.parse(JSON.stringify(manifest));
const res: Manifest = JSON.parse(JSON.stringify(manifest));
const instance = await fetchMeta(false);
res.short_name = instance.name || "Firefish";
res.name = instance.name || "Firefish";
if (instance.themeColor) res.theme_color = instance.themeColor;
for (const icon of res.icons) {
icon.src = `${icon.src}?v=${config.version.replace(/[^0-9]/g, "")}`;
if (instance.iconUrl) {
res.icons = [
{
src: instance.iconUrl,
sizes: "48x48 72x72 96x96 128x128 192x192 256x256",
purpose: "any",
},
];
} else {
for (const icon of res.icons) {
icon.src = `${icon.src}?v=${config.version.replace(/[^0-9]/g, "")}`;
}
}
if (instance.themeColor) res.theme_color = instance.themeColor;
for (const screenshot of res.screenshots) {
screenshot.src = `${screenshot.src}?v=${config.version.replace(
/[^0-9]/g,

15
renovate.json Normal file
View File

@ -0,0 +1,15 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": ["config:base"],
"rangeStrategy": "bump",
"branchConcurrentLimit": 5,
"enabledManagers": ["npm", "cargo"],
"baseBranches": ["develop"],
"lockFileMaintenance": {
"enabled": true,
"recreateWhen": "always",
"rebaseStalePrs": true,
"branchTopic": "lock-file-maintenance",
"commitMessageAction": "Lock file maintenance"
}
}