Link the server's terms of service from the about page

This commit is contained in:
Roland Geider
2026-08-22 21:24:58 +02:00
parent 185e5341ba
commit a7e3b5cfdc
8 changed files with 63 additions and 0 deletions

View File

@@ -195,6 +195,11 @@ const WEBLATE_URL = 'https://hosted.weblate.org/engage/wger';
const BUY_ME_A_COFFEE_URL = 'https://buymeacoffee.com/wger';
const LIBERAPAY_URL = 'https://liberapay.com/wger';
/// Terms of service and privacy policy, served by every instance. What it says
/// is up to whoever runs the server, upstream ships a placeholder. The Health
/// Connect entry points in MainActivity.kt use wger.de's copy of this page.
const TERMS_OF_SERVICE_PATH = 'software/terms-of-service';
/// Factor to multiply / divide in the charts when converting dates to milliseconds
/// from epoch since fl_charts does not support real time series charts and using
/// the milliseconds themselves can cause the application to crash since it runs

View File

@@ -90,6 +90,23 @@ Uri makeUri(
return uri;
}
/// Builds the URL of a page the server renders itself, e.g. its terms of
/// service. Unlike [makeUri] the path is used as given, without the API prefix
/// and without a trailing slash.
Uri makePageUri(String serverUrl, String path) {
final server = Uri.parse(serverUrl);
final basePath = server.path.endsWith('/')
? server.path.substring(0, server.path.length - 1)
: server.path;
return Uri(
scheme: server.scheme,
host: server.host,
port: server.port,
path: '$basePath/$path',
);
}
/// Builds a URL for the `allauth.headless` `app` client API at
/// `/allauth/app/v1/<path>`. Used by the auth notifier for login,
/// signup, MFA, refresh, etc. The headless API does not use a trailing

View File

@@ -23,6 +23,7 @@ import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:wger/core/consts.dart';
import 'package:wger/core/errors.dart' show buildGithubIssueUrl;
import 'package:wger/core/helpers.dart' show makePageUri;
import 'package:wger/core/logs.dart';
import 'package:wger/core/misc.dart';
import 'package:wger/core/network/auth_notifier.dart';
@@ -60,6 +61,10 @@ class AboutPage extends ConsumerWidget {
final i18n = AppLocalizations.of(context);
final today = DateTime.now();
// The terms are the server operator's, not ours, so point at the instance
// the user is actually connected to
final serverUrl = authState?.serverUrl;
return Scaffold(
appBar: AppBar(title: Text(i18n.aboutPageTitle)),
body: WidescreenWrapper(
@@ -257,6 +262,15 @@ class AboutPage extends ConsumerWidget {
contentPadding: EdgeInsets.zero,
onTap: () => launchURL(READTHEDOCS_URL, context),
),
if (serverUrl != null)
ListTile(
leading: const Icon(Icons.privacy_tip),
trailing: const Icon(Icons.arrow_outward),
title: Text(i18n.aboutPrivacyPolicyTitle),
contentPadding: EdgeInsets.zero,
onTap: () =>
launchURL(makePageUri(serverUrl, TERMS_OF_SERVICE_PATH).toString(), context),
),
],
),
),

View File

@@ -1086,6 +1086,7 @@
"carbohydratesSugar": "Zucker (Kohlenhydrate)",
"aboutViewDocsTitle": "Dokumentation öffnen",
"aboutViewLicensesTitle": "Lizenzen anzeigen",
"aboutPrivacyPolicyTitle": "Nutzungsbedingungen und Datenschutz",
"powerSyncUnreachableTitle": "Sync-Dienst nicht erreichbar",
"powerSyncUnreachableContent": "Dein wger-Server ist erreichbar, aber der (separate) Dienst für die Offline-Synchronisierung antwortet nicht. Wenn du wger selbst hostest, überprüfe deine Konfiguration und stelle sicher, dass der PowerSync-Dienst korrekt läuft.",
"serverUnreachableRetry": "Erneut versuchen",

View File

@@ -1085,6 +1085,7 @@
"aboutDiscordTitle": "Discord",
"aboutViewDocsTitle": "Open documentation",
"aboutViewLicensesTitle": "View licenses",
"aboutPrivacyPolicyTitle": "Terms and privacy policy",
"others": "Others",
"calendar": "Calendar",
"@calendar": {},

View File

@@ -1120,6 +1120,7 @@
"carbohydratesSugar": "Azúcar (carbohidratos)",
"aboutViewDocsTitle": "Abrir la documentación",
"aboutViewLicensesTitle": "Ver licencias",
"aboutPrivacyPolicyTitle": "Términos y política de privacidad",
"enterMaxCharacters": "Introduce como máximo {max} caracteres",
"powerSyncUnreachableTitle": "Servicio de sincronización no disponible",
"powerSyncUnreachableContent": "Tu servidor de wger es accesible, pero el servicio (independiente) que gestiona la sincronización sin conexión no responde. Si alojas wger por tu cuenta, revisa tu configuración y asegúrate de que el servicio PowerSync funcione correctamente.",

View File

@@ -1091,6 +1091,7 @@
"carbohydratesSugar": "Sucre (glucides)",
"aboutViewDocsTitle": "Ouvrir la documentation",
"aboutViewLicensesTitle": "Voir les licences",
"aboutPrivacyPolicyTitle": "Conditions et politique de confidentialité",
"enterMaxCharacters": "Veuillez saisir au maximum {max} caractères",
"powerSyncUnreachableTitle": "Service de synchronisation inaccessible",
"powerSyncUnreachableContent": "Votre serveur wger est accessible, mais le service (distinct) qui gère la synchronisation hors ligne ne répond pas. Si vous hébergez wger vous-même, vérifiez votre configuration et assurez-vous que le service PowerSync fonctionne correctement.",

View File

@@ -181,6 +181,29 @@ void main() {
});
});
group('makePageUri', () {
test('builds the page URL on the server itself', () {
expect(
makePageUri('https://wger.de', 'software/terms-of-service').toString(),
'https://wger.de/software/terms-of-service',
);
});
test('handles a trailing slash on the server URL', () {
expect(
makePageUri('https://wger.de/', 'software/terms-of-service').toString(),
'https://wger.de/software/terms-of-service',
);
});
test('keeps a subpath and a non-default port (self-hosted setups)', () {
expect(
makePageUri('http://localhost:8000/wger', 'software/terms-of-service').toString(),
'http://localhost:8000/wger/software/terms-of-service',
);
});
});
group('findLivePowerSyncUrl', () {
const serverUrl = 'https://wger.example.com';