Refactor: remove desktop/Tauri bundle, add i18n, CI/CD pipeline
Nightly Build / build (push) Failing after 6s
Nightly Build / build (push) Failing after 6s
- Remove desktop (Tauri) bundle: docs/desktop.md, icons/, tauri.conf.json, src/desktop/mod.rs, gen/schemas/ - Remove build.rs (no longer needed) - Add i18n system (crates/core-api, plugin-mobile-connector, web) - Refactor config system (src/config.rs, boot_format.rs) - Add mobile connector features (app, router, device pairing) - Plugin system improvements (skald-core) - Update dependencies (Cargo.lock, Cargo.toml) - CI/CD: Gitea Actions workflows (nightly + release), package.sh, verify-version.sh, builds.skaldagent.net config
This commit is contained in:
@@ -6,10 +6,23 @@
|
||||
// `Plugin::web_pages` contract): they talk only to `/api/plugin/<id>/…` and,
|
||||
// for the user directory used by the reassign dropdown, the host `/api/users`
|
||||
// (the fragment runs with the logged-in admin's full session privileges).
|
||||
//
|
||||
// i18n: the plugin ships its own dictionary (`./i18n.js`) and registers it into
|
||||
// the host's shared strings via `addStrings` (imported from the app root by the
|
||||
// absolute `/lib/i18n.js` specifier — the same module the host app uses, so
|
||||
// `t()` and `locale-changed` are shared). `MobileBase` mixes in `I18nMixin` so
|
||||
// every fragment re-renders on a language switch. Register once, at module load.
|
||||
import { LitElement } from 'lit';
|
||||
import { t, addStrings, I18nMixin } from '/lib/i18n.js';
|
||||
import STRINGS from './i18n.js';
|
||||
|
||||
addStrings(STRINGS);
|
||||
|
||||
export { t };
|
||||
|
||||
/// JSON fetch that throws the server's error text on non-2xx and tolerates an
|
||||
/// empty (204) body.
|
||||
/// empty (204) body. The server's error text is already localized (the backend
|
||||
/// resolves the caller's locale), so it is safe to surface directly.
|
||||
export async function jf(url, opts = {}) {
|
||||
const res = await fetch(url, {
|
||||
headers: { 'Content-Type': 'application/json', ...(opts.headers || {}) },
|
||||
@@ -25,27 +38,27 @@ export async function jf(url, opts = {}) {
|
||||
}
|
||||
|
||||
/// Base for the console fragments: renders into light DOM (so Bootstrap classes
|
||||
/// and the app's theme CSS variables apply) and exposes the plugin's API root
|
||||
/// from the host-set `plugin-id` attribute.
|
||||
export class MobileBase extends LitElement {
|
||||
/// and the app's theme CSS variables apply), re-renders on locale change, and
|
||||
/// exposes the plugin's API root from the host-set `plugin-id` attribute.
|
||||
export class MobileBase extends I18nMixin(LitElement) {
|
||||
createRenderRoot() { return this; }
|
||||
get api() { return `/api/plugin/${this.getAttribute('plugin-id') || 'mobile-connector'}`; }
|
||||
}
|
||||
|
||||
/// Human-friendly "time ago" for a Unix-ms timestamp (or "—" when absent).
|
||||
/// Human-friendly, localized "time ago" for a Unix-ms timestamp (or "—" when absent).
|
||||
export function ago(ms) {
|
||||
if (!ms) return '—';
|
||||
if (!ms) return t('plugin.mobile-connector.time.never');
|
||||
const s = Math.max(0, Math.floor((Date.now() - ms) / 1000));
|
||||
if (s < 60) return `${s}s ago`;
|
||||
if (s < 60) return t('plugin.mobile-connector.time.ago_s', { n: s });
|
||||
const m = Math.floor(s / 60);
|
||||
if (m < 60) return `${m}m ago`;
|
||||
if (m < 60) return t('plugin.mobile-connector.time.ago_m', { n: m });
|
||||
const h = Math.floor(m / 60);
|
||||
if (h < 24) return `${h}h ago`;
|
||||
return `${Math.floor(h / 24)}d ago`;
|
||||
if (h < 24) return t('plugin.mobile-connector.time.ago_h', { n: h });
|
||||
return t('plugin.mobile-connector.time.ago_d', { n: Math.floor(h / 24) });
|
||||
}
|
||||
|
||||
/// Best-effort device label from the `device_info` JSON a phone sends on hello.
|
||||
export function deviceLabel(d) {
|
||||
const info = d.device_info || {};
|
||||
return info.name || info.model || info.device || d.platform || 'Unknown device';
|
||||
return info.name || info.model || info.device || d.platform || t('plugin.mobile-connector.devices.unknown');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user