From 207c9186dfc649c3139c79dd987db125db0d99bc Mon Sep 17 00:00:00 2001 From: Evan Paterakis Date: Sun, 28 Apr 2024 06:49:08 +0300 Subject: [PATCH 1/5] feat: branding support --- branding.conf | 24 ++++++++++++++++++++++++ meson.build | 21 ++++++++++++--------- src/Build.vala.in | 1 + 3 files changed, 37 insertions(+), 9 deletions(-) create mode 100644 branding.conf diff --git a/branding.conf b/branding.conf new file mode 100644 index 000000000..c599bb341 --- /dev/null +++ b/branding.conf @@ -0,0 +1,24 @@ +# Branding +# +# You are kindly asked to replace all links if you are +# distributing a build with custom branding. +# +# Support will not be provided to your users without +# prior agreement. +# +# You may not make your builds publicly available +# without modifying the app ID and all relevant files, +# as it won't be able to co-exist with Tuba. +# +# This is mostly aimed at organizations for internal +# usage, limited to their instances. +NAME=Tuba +WEBSITE=https://github.com/GeopJr/Tuba +ISSUES_WEBSITE=https://github.com/GeopJr/Tuba/issues +SUPPORT_WEBSITE=https://matrix.to/%23/%23tuba:gnome.org +DONATE_WEBSITE=https://geopjr.dev/donate +TRANSLATE_WEBSITE=https://hosted.weblate.org/engage/tuba/ +WIKI_WEBSITE= +# New accounts will only be able to login to this +# instance. e.g. faraway.town +LIMIT_TO_INSTANCE= diff --git a/meson.build b/meson.build index a1eb75b46..5fc462f84 100644 --- a/meson.build +++ b/meson.build @@ -19,23 +19,26 @@ endif devel = get_option('devel') distro = get_option('distro') +branding = import('keyval').load('branding.conf') + # Setup configuration file config = configuration_data() config.set('EXEC_NAME', meson.project_name()) config.set('GETTEXT_PACKAGE', meson.project_name()) config.set('LOCALEDIR', join_paths(get_option('prefix'), get_option('localedir'))) config.set('DOMAIN', meson.project_name ()) -config.set('G_LOG_DOMAIN', 'Tuba') +config.set('G_LOG_DOMAIN', branding.get('NAME', 'Tuba')) config.set('RESOURCES', '/' + '/'.join(meson.project_name().split('.')) + '/') config.set('VERSION', meson.project_version()) config.set('PREFIX', get_option('prefix')) -config.set('NAME', 'Tuba') -config.set('WEBSITE', 'https://github.com/GeopJr/Tuba') -config.set('ISSUES_WEBSITE', 'https://github.com/GeopJr/Tuba/issues') -config.set('SUPPORT_WEBSITE', 'https://matrix.to/#/#tuba:gnome.org') -config.set('DONATE_WEBSITE', 'https://geopjr.dev/donate') -config.set('TRANSLATE_WEBSITE', 'https://hosted.weblate.org/engage/tuba/') -config.set('WIKI_WEBSITE', 'https://github.com/GeopJr/Tuba/wiki') +config.set('NAME', branding.get('NAME', 'Tuba')) +config.set('WEBSITE', branding.get('WEBSITE', 'https://github.com/GeopJr/Tuba')) +config.set('ISSUES_WEBSITE', branding.get('ISSUES_WEBSITE', 'https://github.com/GeopJr/Tuba/issues')) +config.set('SUPPORT_WEBSITE', branding.get('SUPPORT_WEBSITE', 'https://matrix.to/#/#tuba:gnome.org')) +config.set('DONATE_WEBSITE', branding.get('DONATE_WEBSITE', 'https://geopjr.dev/donate')) +config.set('TRANSLATE_WEBSITE', branding.get('TRANSLATE_WEBSITE', 'https://hosted.weblate.org/engage/tuba/')) +config.set('WIKI_WEBSITE', branding.get('WIKI_WEBSITE', 'https://github.com/GeopJr/Tuba/wiki')) +config.set('LIMIT_TO_INSTANCE', branding.get('LIMIT_TO_INSTANCE', '')) config.set('PROFILE', devel ? 'development' : 'production') if devel @@ -63,7 +66,7 @@ endif add_project_arguments(['--vapidir=' + meson.project_source_root() / 'vapi'], language: 'vala') add_project_arguments ( '-DGETTEXT_PACKAGE="@0@"'.format(meson.project_name()), - '-DG_LOG_DOMAIN="Tuba"', + '-DG_LOG_DOMAIN="@0@"'.format(config.get('G_LOG_DOMAIN')), language: 'c' ) diff --git a/src/Build.vala.in b/src/Build.vala.in index ebe7548f0..02e3c2e20 100644 --- a/src/Build.vala.in +++ b/src/Build.vala.in @@ -4,6 +4,7 @@ namespace Build { public const string DOMAIN = "@DOMAIN@"; public const string RESOURCES = "@RESOURCES@"; public const string PROFILE = "@PROFILE@"; + public const string LIMIT_TO_INSTANCE = "@LIMIT_TO_INSTANCE@"; public const string GETTEXT_PACKAGE = "@GETTEXT_PACKAGE@"; public const string LOCALEDIR = "@LOCALEDIR@"; From dad9144bbe43ecb290f6b25411334f186d13f954 Mon Sep 17 00:00:00 2001 From: Evan Paterakis Date: Tue, 30 Apr 2024 04:21:51 +0300 Subject: [PATCH 2/5] feat: LIMIT_TO_INSTANCE => DEFAULT_INSTANCE --- branding.conf | 10 ++++++---- meson.build | 2 +- src/Build.vala.in | 2 +- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/branding.conf b/branding.conf index c599bb341..e1438bf00 100644 --- a/branding.conf +++ b/branding.conf @@ -18,7 +18,9 @@ ISSUES_WEBSITE=https://github.com/GeopJr/Tuba/issues SUPPORT_WEBSITE=https://matrix.to/%23/%23tuba:gnome.org DONATE_WEBSITE=https://geopjr.dev/donate TRANSLATE_WEBSITE=https://hosted.weblate.org/engage/tuba/ -WIKI_WEBSITE= -# New accounts will only be able to login to this -# instance. e.g. faraway.town -LIMIT_TO_INSTANCE= +WIKI_WEBSITE=https://github.com/GeopJr/Tuba/wiki +# Prefilled instance when logging in. +# This does not limit your users from +# logging in to other instances. +# e.g. faraway.town +DEFAULT_INSTANCE= diff --git a/meson.build b/meson.build index 5fc462f84..1aef1346f 100644 --- a/meson.build +++ b/meson.build @@ -38,7 +38,7 @@ config.set('SUPPORT_WEBSITE', branding.get('SUPPORT_WEBSITE', 'https://matrix.to config.set('DONATE_WEBSITE', branding.get('DONATE_WEBSITE', 'https://geopjr.dev/donate')) config.set('TRANSLATE_WEBSITE', branding.get('TRANSLATE_WEBSITE', 'https://hosted.weblate.org/engage/tuba/')) config.set('WIKI_WEBSITE', branding.get('WIKI_WEBSITE', 'https://github.com/GeopJr/Tuba/wiki')) -config.set('LIMIT_TO_INSTANCE', branding.get('LIMIT_TO_INSTANCE', '')) +config.set('DEFAULT_INSTANCE', branding.get('DEFAULT_INSTANCE', '')) config.set('PROFILE', devel ? 'development' : 'production') if devel diff --git a/src/Build.vala.in b/src/Build.vala.in index 02e3c2e20..64f1e5dfa 100644 --- a/src/Build.vala.in +++ b/src/Build.vala.in @@ -4,7 +4,7 @@ namespace Build { public const string DOMAIN = "@DOMAIN@"; public const string RESOURCES = "@RESOURCES@"; public const string PROFILE = "@PROFILE@"; - public const string LIMIT_TO_INSTANCE = "@LIMIT_TO_INSTANCE@"; + public const string DEFAULT_INSTANCE = "@DEFAULT_INSTANCE@"; public const string GETTEXT_PACKAGE = "@GETTEXT_PACKAGE@"; public const string LOCALEDIR = "@LOCALEDIR@"; From 85fc29c9b0d4065a9ecd9f31dc6a848febcdfb14 Mon Sep 17 00:00:00 2001 From: Evan Paterakis Date: Tue, 30 Apr 2024 04:22:40 +0300 Subject: [PATCH 3/5] feat(meson): check if name is empty and abort the only one that cannot be empty --- meson.build | 1 + 1 file changed, 1 insertion(+) diff --git a/meson.build b/meson.build index 1aef1346f..f90823bd7 100644 --- a/meson.build +++ b/meson.build @@ -20,6 +20,7 @@ devel = get_option('devel') distro = get_option('distro') branding = import('keyval').load('branding.conf') +assert(branding.get('NAME') != '', 'Branding: Name cannot be empty.') # Setup configuration file config = configuration_data() From 2f006132a20d4307e15637ce979de1684c32c905 Mon Sep 17 00:00:00 2001 From: Evan Paterakis Date: Tue, 30 Apr 2024 04:38:36 +0300 Subject: [PATCH 4/5] feat: hide fields that use branding when empty --- src/Application.vala | 10 ++++++---- src/Dialogs/NewAccount.vala | 7 +++++-- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/Application.vala b/src/Application.vala index 8804e5398..0763a6fbf 100644 --- a/src/Application.vala +++ b/src/Application.vala @@ -481,10 +481,12 @@ namespace Tuba { }; // translators: Wiki pages / Guides - dialog.add_link (_("Wiki"), Build.WIKI_WEBSITE); - - dialog.add_link (_("Translate"), Build.TRANSLATE_WEBSITE); - dialog.add_link (_("Donate"), Build.DONATE_WEBSITE); + if (Build.WIKI_WEBSITE != "") + dialog.add_link (_("Wiki"), Build.WIKI_WEBSITE); + if (Build.TRANSLATE_WEBSITE != "") + dialog.add_link (_("Translate"), Build.TRANSLATE_WEBSITE); + if (Build.DONATE_WEBSITE != "") + dialog.add_link (_("Donate"), Build.DONATE_WEBSITE); // For some obscure reason, const arrays produce duplicates in the credits. // Static functions seem to avoid this peculiar behavior. diff --git a/src/Dialogs/NewAccount.vala b/src/Dialogs/NewAccount.vala index d0dc77cd5..42a9aa55a 100644 --- a/src/Dialogs/NewAccount.vala +++ b/src/Dialogs/NewAccount.vala @@ -130,8 +130,11 @@ public class Tuba.Dialogs.NewAccount: Adw.Window { .with_account (account) .with_form_data ("client_name", Build.NAME) .with_form_data ("redirect_uris", redirect_uri = setup_redirect_uri ()) - .with_form_data ("scopes", SCOPES) - .with_form_data ("website", Build.WEBSITE); + .with_form_data ("scopes", SCOPES); + + if (Build.WEBSITE != "") + msg.with_form_data ("website", Build.WEBSITE); + yield msg.await (); var parser = Network.get_parser_from_inputstream (msg.response_body); From d174585895f5255e5b9e984b23960a8ebbb5fa78 Mon Sep 17 00:00:00 2001 From: Evan Paterakis Date: Tue, 30 Apr 2024 04:39:07 +0300 Subject: [PATCH 5/5] feat(newaccount): default instance branding --- src/Dialogs/NewAccount.vala | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Dialogs/NewAccount.vala b/src/Dialogs/NewAccount.vala index 42a9aa55a..9678c2b1c 100644 --- a/src/Dialogs/NewAccount.vala +++ b/src/Dialogs/NewAccount.vala @@ -47,6 +47,9 @@ public class Tuba.Dialogs.NewAccount: Adw.Window { reset (); present (); instance_entry.grab_focus (); + + if (Build.DEFAULT_INSTANCE != "") + instance_entry.text = Build.DEFAULT_INSTANCE; } public bool on_manual_auth (string url) {