2025-01-06 16:05:05 +08:00
|
|
|
import 'package:appflowy/env/cloud_env.dart';
|
|
|
|
import 'package:appflowy/startup/startup.dart';
|
|
|
|
|
2024-10-03 14:31:04 +08:00
|
|
|
class ShareConstants {
|
2025-01-06 16:05:05 +08:00
|
|
|
static const String testBaseWebDomain = 'test.appflowy.com';
|
2025-01-08 15:52:24 +08:00
|
|
|
static const String defaultBaseWebDomain = 'https://appflowy.com';
|
2024-10-03 14:31:04 +08:00
|
|
|
|
|
|
|
static String buildPublishUrl({
|
|
|
|
required String nameSpace,
|
|
|
|
required String publishName,
|
|
|
|
}) {
|
2025-01-06 16:05:05 +08:00
|
|
|
final baseShareDomain =
|
|
|
|
getIt<AppFlowyCloudSharedEnv>().appflowyCloudConfig.base_web_domain;
|
|
|
|
final url = '$baseShareDomain/$nameSpace/$publishName'.addSchemaIfNeeded();
|
|
|
|
return url;
|
2024-10-31 14:38:32 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static String buildNamespaceUrl({
|
|
|
|
required String nameSpace,
|
|
|
|
bool withHttps = false,
|
|
|
|
}) {
|
2025-01-06 16:05:05 +08:00
|
|
|
final baseShareDomain =
|
|
|
|
getIt<AppFlowyCloudSharedEnv>().appflowyCloudConfig.base_web_domain;
|
|
|
|
String url = baseShareDomain.addSchemaIfNeeded();
|
|
|
|
if (!withHttps) {
|
|
|
|
url = url.replaceFirst('https://', '');
|
|
|
|
}
|
|
|
|
return '$url/app/$nameSpace';
|
2024-10-03 14:31:04 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static String buildShareUrl({
|
|
|
|
required String workspaceId,
|
|
|
|
required String viewId,
|
|
|
|
String? blockId,
|
|
|
|
}) {
|
2025-01-06 16:05:05 +08:00
|
|
|
final baseShareDomain =
|
|
|
|
getIt<AppFlowyCloudSharedEnv>().appflowyCloudConfig.base_web_domain;
|
|
|
|
final url = '$baseShareDomain/app/$workspaceId/$viewId'.addSchemaIfNeeded();
|
2024-10-03 14:31:04 +08:00
|
|
|
if (blockId == null || blockId.isEmpty) {
|
|
|
|
return url;
|
|
|
|
}
|
|
|
|
return '$url?blockId=$blockId';
|
|
|
|
}
|
|
|
|
}
|
2025-01-06 16:05:05 +08:00
|
|
|
|
|
|
|
extension on String {
|
|
|
|
String addSchemaIfNeeded() {
|
|
|
|
final schema = Uri.parse(this).scheme;
|
|
|
|
// if the schema is empty, add https schema by default
|
|
|
|
if (schema.isEmpty) {
|
|
|
|
return 'https://$this';
|
|
|
|
}
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
}
|