aboutsummaryrefslogtreecommitdiff
path: root/src/hydrilla
diff options
context:
space:
mode:
Diffstat (limited to 'src/hydrilla')
-rw-r--r--src/hydrilla/locales/en_US/LC_MESSAGES/messages.po172
-rw-r--r--src/hydrilla/proxy/state.py2
-rw-r--r--src/hydrilla/proxy/state_impl/concrete_state.py102
-rw-r--r--src/hydrilla/proxy/tables.sql3
-rw-r--r--src/hydrilla/proxy/web_ui/items.py1
-rw-r--r--src/hydrilla/proxy/web_ui/options.py10
-rw-r--r--src/hydrilla/proxy/web_ui/root.py6
-rw-r--r--src/hydrilla/proxy/web_ui/templates/base.html.jinja21
-rw-r--r--src/hydrilla/proxy/web_ui/templates/items/item_viewversion.html.jinja91
-rw-r--r--src/hydrilla/proxy/web_ui/templates/items/library_viewversion.html.jinja32
-rw-r--r--src/hydrilla/proxy/web_ui/templates/items/package_viewversion.html.jinja38
-rw-r--r--src/hydrilla/proxy/web_ui/templates/options.html.jinja26
-rw-r--r--src/hydrilla/proxy/web_ui/templates/repos/show_single.html.jinja21
13 files changed, 284 insertions, 241 deletions
diff --git a/src/hydrilla/locales/en_US/LC_MESSAGES/messages.po b/src/hydrilla/locales/en_US/LC_MESSAGES/messages.po
index 4e2af8e..277678e 100644
--- a/src/hydrilla/locales/en_US/LC_MESSAGES/messages.po
+++ b/src/hydrilla/locales/en_US/LC_MESSAGES/messages.po
@@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: hydrilla 2.0\n"
"Report-Msgid-Bugs-To: koszko@koszko.org\n"
-"POT-Creation-Date: 2022-09-26 19:35+0200\n"
+"POT-Creation-Date: 2022-09-27 10:53+0200\n"
"PO-Revision-Date: 2022-02-12 00:00+0000\n"
"Last-Translator: Wojtek Kosior <koszko@koszko.org>\n"
"Language: en_US\n"
@@ -205,47 +205,47 @@ msgstr "Requested file could not be found."
msgid "api.resource_not_enabled_for_access"
msgstr "Requested resource is not enabled for access."
-#: src/hydrilla/proxy/state_impl/concrete_state.py:122
+#: src/hydrilla/proxy/state_impl/concrete_state.py:92
msgid "err.proxy.unknown_db_schema"
msgstr ""
"Haketilo's data files have been altered, possibly by a newer version of "
"Haketilo."
-#: src/hydrilla/proxy/state_impl/concrete_state.py:126
+#: src/hydrilla/proxy/state_impl/concrete_state.py:96
msgid "err.proxy.no_sqlite_foreign_keys"
msgstr ""
"This installation of Haketilo uses an SQLite version which does not "
"support foreign key constraints."
-#: src/hydrilla/proxy/web_ui/templates/base.html.jinja:69
+#: src/hydrilla/proxy/web_ui/templates/base.html.jinja:71
msgid "web_ui.base.title.haketilo_proxy"
msgstr "Haketilo"
-#: src/hydrilla/proxy/web_ui/templates/base.html.jinja:239
+#: src/hydrilla/proxy/web_ui/templates/base.html.jinja:241
msgid "web_ui.base.nav.home"
msgstr "Home"
-#: src/hydrilla/proxy/web_ui/templates/base.html.jinja:240
+#: src/hydrilla/proxy/web_ui/templates/base.html.jinja:242
msgid "web_ui.base.nav.options"
msgstr "Options"
-#: src/hydrilla/proxy/web_ui/templates/base.html.jinja:241
+#: src/hydrilla/proxy/web_ui/templates/base.html.jinja:243
msgid "web_ui.base.nav.rules"
msgstr "Script blocking"
-#: src/hydrilla/proxy/web_ui/templates/base.html.jinja:242
+#: src/hydrilla/proxy/web_ui/templates/base.html.jinja:244
msgid "web_ui.base.nav.packages"
msgstr "Packages"
-#: src/hydrilla/proxy/web_ui/templates/base.html.jinja:243
+#: src/hydrilla/proxy/web_ui/templates/base.html.jinja:245
msgid "web_ui.base.nav.libraries"
msgstr "Libraries"
-#: src/hydrilla/proxy/web_ui/templates/base.html.jinja:244
+#: src/hydrilla/proxy/web_ui/templates/base.html.jinja:246
msgid "web_ui.base.nav.repos"
msgstr "Repositories"
-#: src/hydrilla/proxy/web_ui/templates/base.html.jinja:245
+#: src/hydrilla/proxy/web_ui/templates/base.html.jinja:247
msgid "web_ui.base.nav.load"
msgstr "Import from file"
@@ -295,19 +295,19 @@ msgstr "Couldn't communicate with repository."
msgid "web_ui.items.single_version.version_{}"
msgstr "Version '{}'."
-#: src/hydrilla/proxy/web_ui/templates/items/item_viewversion.html.jinja:76
+#: src/hydrilla/proxy/web_ui/templates/items/item_viewversion.html.jinja:64
msgid "web_ui.items.single_version.retry_install_button"
msgstr "Retry installation"
-#: src/hydrilla/proxy/web_ui/templates/items/item_viewversion.html.jinja:80
+#: src/hydrilla/proxy/web_ui/templates/items/item_viewversion.html.jinja:68
msgid "web_ui.items.single_version.leave_uninstalled_button"
msgstr "Leave uninstalled"
-#: src/hydrilla/proxy/web_ui/templates/items/item_viewversion.html.jinja:84
+#: src/hydrilla/proxy/web_ui/templates/items/item_viewversion.html.jinja:72
msgid "web_ui.items.single_version.install_button"
msgstr "Install"
-#: src/hydrilla/proxy/web_ui/templates/items/item_viewversion.html.jinja:85
+#: src/hydrilla/proxy/web_ui/templates/items/item_viewversion.html.jinja:74
msgid "web_ui.items.single_version.uninstall_button"
msgstr "Uninstall"
@@ -344,33 +344,31 @@ msgid "web_ui.items.single_version.library.heading.name_{}"
msgstr "Library '{}'"
#: src/hydrilla/proxy/web_ui/templates/items/library_viewversion.html.jinja:42
-msgid "web_ui.items.single_version.library.item_required"
-msgstr ""
-"This library version is required by an enabled package. It cannot be "
-"uninstalled."
+msgid "web_ui.items.single_version.library.install_failed"
+msgstr "Couldn't install this library version."
#: src/hydrilla/proxy/web_ui/templates/items/library_viewversion.html.jinja:46
-msgid "web_ui.items.single_version.library.item_auto_activated"
-msgstr ""
-"This library version is used by some package. The package has not been "
-"explicitly configured by the user but is going to be activated "
-"automatically."
+msgid "web_ui.items.single_version.library.version_list_heading"
+msgstr "Other available versions of the library"
+
+#: src/hydrilla/proxy/web_ui/templates/items/library_viewversion.html.jinja:58
+msgid "web_ui.items.single_version.library.item_required"
+msgstr "This library version is required by an enabled package."
-#: src/hydrilla/proxy/web_ui/templates/items/library_viewversion.html.jinja:50
+#: src/hydrilla/proxy/web_ui/templates/items/library_viewversion.html.jinja:63
msgid "web_ui.items.single_version.library.item_not_activated"
msgstr "This library version is not used by any package enabled by the user."
-#: src/hydrilla/proxy/web_ui/templates/items/library_viewversion.html.jinja:54
+#: src/hydrilla/proxy/web_ui/templates/items/library_viewversion.html.jinja:65
msgid "web_ui.items.single_version.library.item_will_be_asked_about"
msgstr "This library version is not used by any package enabled by the user."
-#: src/hydrilla/proxy/web_ui/templates/items/library_viewversion.html.jinja:58
-msgid "web_ui.items.single_version.library.install_failed"
-msgstr "Couldn't install this library version."
-
-#: src/hydrilla/proxy/web_ui/templates/items/library_viewversion.html.jinja:62
-msgid "web_ui.items.single_version.library.version_list_heading"
-msgstr "Other available versions of the library"
+#: src/hydrilla/proxy/web_ui/templates/items/library_viewversion.html.jinja:68
+msgid "web_ui.items.single_version.library.item_auto_activated"
+msgstr ""
+"This library version is used by some package. The package has not been "
+"explicitly configured by the user but is going to be activated "
+"automatically."
#: src/hydrilla/proxy/web_ui/templates/items/load_from_disk.html.jinja:23
msgid "web_ui.load_from_disk.title"
@@ -421,108 +419,100 @@ msgid "web_ui.items.single_version.package.heading.name_{}"
msgstr "Package '{}'"
#: src/hydrilla/proxy/web_ui/templates/items/package_viewversion.html.jinja:42
-msgid "web_ui.items.single_version.package.item_required"
-msgstr "This package version is required. It cannot be uninstalled."
-
-#: src/hydrilla/proxy/web_ui/templates/items/package_viewversion.html.jinja:46
-msgid "web_ui.items.single_version.package.item_auto_activated"
-msgstr ""
-"This package version has not been explicitly enabled but it is going to "
-"be used automatically."
-
-#: src/hydrilla/proxy/web_ui/templates/items/package_viewversion.html.jinja:50
-msgid "web_ui.items.single_version.package.item_not_activated"
-msgstr "This package version is not enabled."
-
-#: src/hydrilla/proxy/web_ui/templates/items/package_viewversion.html.jinja:54
-msgid "web_ui.items.single_version.package.item_will_be_asked_about"
-msgstr ""
-"This package version is not currently enabled. You will be asked whether "
-"to enable it when you visit a website where it can be used."
-
-#: src/hydrilla/proxy/web_ui/templates/items/package_viewversion.html.jinja:58
msgid "web_ui.items.single_version.package.install_failed"
msgstr "Couldn't install this package version."
-#: src/hydrilla/proxy/web_ui/templates/items/package_viewversion.html.jinja:62
+#: src/hydrilla/proxy/web_ui/templates/items/package_viewversion.html.jinja:46
msgid "web_ui.items.single_version.package.version_list_heading"
msgstr "Other available versions of the package"
-#: src/hydrilla/proxy/web_ui/templates/items/package_viewversion.html.jinja:76
+#: src/hydrilla/proxy/web_ui/templates/items/package_viewversion.html.jinja:60
msgid "web_ui.items.single_version.unenable_button"
msgstr "Forget"
-#: src/hydrilla/proxy/web_ui/templates/items/package_viewversion.html.jinja:77
+#: src/hydrilla/proxy/web_ui/templates/items/package_viewversion.html.jinja:61
msgid "web_ui.items.single_version.disable_button"
msgstr "Disable"
-#: src/hydrilla/proxy/web_ui/templates/items/package_viewversion.html.jinja:78
+#: src/hydrilla/proxy/web_ui/templates/items/package_viewversion.html.jinja:62
msgid "web_ui.items.single_version.enable_button"
msgstr "Enable"
-#: src/hydrilla/proxy/web_ui/templates/items/package_viewversion.html.jinja:83
-msgid "web_ui.items.single_version.item_not_marked"
-msgstr "The package isn't enabled."
+#: src/hydrilla/proxy/web_ui/templates/items/package_viewversion.html.jinja:71
+msgid "web_ui.items.single_version.package.item_not_activated"
+msgstr "This package version is not enabled and won't be used."
+
+#: src/hydrilla/proxy/web_ui/templates/items/package_viewversion.html.jinja:73
+msgid "web_ui.items.single_version.package.item_will_be_asked_about"
+msgstr ""
+"This package version is not currently enabled. You will be asked whether "
+"to enable it when you visit a website where it can be used."
+
+#: src/hydrilla/proxy/web_ui/templates/items/package_viewversion.html.jinja:76
+msgid "web_ui.items.single_version.package.item_auto_activated"
+msgstr ""
+"This package version has not been explicitly enabled but it is going to "
+"be used automatically."
-#: src/hydrilla/proxy/web_ui/templates/items/package_viewversion.html.jinja:86
-msgid "web_ui.items.single_version.item_disabled"
+#: src/hydrilla/proxy/web_ui/templates/items/package_viewversion.html.jinja:80
+msgid "web_ui.items.single_version.package.item_disabled"
msgstr "All versions of the package have been explicitly disabled by the user."
-#: src/hydrilla/proxy/web_ui/templates/items/package_viewversion.html.jinja:90
-msgid "web_ui.items.single_version.item_enabled"
+#: src/hydrilla/proxy/web_ui/templates/items/package_viewversion.html.jinja:84
+msgid "web_ui.items.single_version.package.item_enabled"
msgstr "The package has been enabled by the user."
-#: src/hydrilla/proxy/web_ui/templates/items/package_viewversion.html.jinja:109
+#: src/hydrilla/proxy/web_ui/templates/items/package_viewversion.html.jinja:103
msgid "web_ui.items.single_version.unpin_button"
msgstr "Unpin"
-#: src/hydrilla/proxy/web_ui/templates/items/package_viewversion.html.jinja:114
+#: src/hydrilla/proxy/web_ui/templates/items/package_viewversion.html.jinja:108
msgid "web_ui.items.single_version.not_pinned"
msgstr "The package is not pinned to any version."
-#: src/hydrilla/proxy/web_ui/templates/items/package_viewversion.html.jinja:119
+#: src/hydrilla/proxy/web_ui/templates/items/package_viewversion.html.jinja:113
msgid "web_ui.items.single_version.pinned_repo_local"
msgstr "The package is pinned to only use locally installed versions."
-#: src/hydrilla/proxy/web_ui/templates/items/package_viewversion.html.jinja:122
+#: src/hydrilla/proxy/web_ui/templates/items/package_viewversion.html.jinja:116
msgid "web_ui.items.single_version.pinned_repo_{}"
msgstr "The package is pinned to only use versions from repository '{}'."
-#: src/hydrilla/proxy/web_ui/templates/items/package_viewversion.html.jinja:133
+#: src/hydrilla/proxy/web_ui/templates/items/package_viewversion.html.jinja:127
msgid "web_ui.items.single_version.pin_local_repo_button"
msgstr "Pin to local packages"
-#: src/hydrilla/proxy/web_ui/templates/items/package_viewversion.html.jinja:138
-#: src/hydrilla/proxy/web_ui/templates/items/package_viewversion.html.jinja:151
+#: src/hydrilla/proxy/web_ui/templates/items/package_viewversion.html.jinja:132
+#: src/hydrilla/proxy/web_ui/templates/items/package_viewversion.html.jinja:145
msgid "web_ui.items.single_version.pin_repo_button"
msgstr "Pin to repository"
-#: src/hydrilla/proxy/web_ui/templates/items/package_viewversion.html.jinja:145
+#: src/hydrilla/proxy/web_ui/templates/items/package_viewversion.html.jinja:139
msgid "web_ui.items.single_version.repin_repo_button"
msgstr "Pin to this repository"
-#: src/hydrilla/proxy/web_ui/templates/items/package_viewversion.html.jinja:159
-#: src/hydrilla/proxy/web_ui/templates/items/package_viewversion.html.jinja:170
+#: src/hydrilla/proxy/web_ui/templates/items/package_viewversion.html.jinja:153
+#: src/hydrilla/proxy/web_ui/templates/items/package_viewversion.html.jinja:164
msgid "web_ui.items.single_version.pin_ver_button"
msgstr "Pin to this version"
-#: src/hydrilla/proxy/web_ui/templates/items/package_viewversion.html.jinja:162
+#: src/hydrilla/proxy/web_ui/templates/items/package_viewversion.html.jinja:156
msgid "web_ui.items.single_version.pinned_ver"
msgstr "The package is pinned to this version."
-#: src/hydrilla/proxy/web_ui/templates/items/package_viewversion.html.jinja:165
+#: src/hydrilla/proxy/web_ui/templates/items/package_viewversion.html.jinja:159
msgid "web_ui.items.single_version.repin_ver_button"
msgstr "Pin to this version"
-#: src/hydrilla/proxy/web_ui/templates/items/package_viewversion.html.jinja:167
+#: src/hydrilla/proxy/web_ui/templates/items/package_viewversion.html.jinja:161
msgid "web_ui.items.single_version.pinned_other_ver"
msgstr "The package is pinned to a different version."
-#: src/hydrilla/proxy/web_ui/templates/items/package_viewversion.html.jinja:175
+#: src/hydrilla/proxy/web_ui/templates/items/package_viewversion.html.jinja:169
msgid "web_ui.items.single_version.active_ver_is_this_one"
msgstr "This is the currently active version."
-#: src/hydrilla/proxy/web_ui/templates/items/package_viewversion.html.jinja:179
+#: src/hydrilla/proxy/web_ui/templates/items/package_viewversion.html.jinja:173
msgid "web_ui.items.single_version.active_ver_is_{}"
msgstr "Currently active version is '{}'."
@@ -596,6 +586,22 @@ msgstr "Allow scripts"
msgid "web_ui.options.block_scripts_button"
msgstr "Block scripts"
+#: src/hydrilla/proxy/web_ui/templates/options.html.jinja:95
+msgid "web_ui.options.user_is_advanced_user"
+msgstr "Interface features for advanced users are currently enabled."
+
+#: src/hydrilla/proxy/web_ui/templates/options.html.jinja:98
+msgid "web_ui.options.user_is_simple_user"
+msgstr "Interface features for advanced users are currently disabled."
+
+#: src/hydrilla/proxy/web_ui/templates/options.html.jinja:105
+msgid "web_ui.options.user_make_advanced_button"
+msgstr "Enable"
+
+#: src/hydrilla/proxy/web_ui/templates/options.html.jinja:108
+msgid "web_ui.options.user_make_simple_button"
+msgstr "Disable"
+
#: src/hydrilla/proxy/web_ui/templates/prompts/auto_install_error.html.jinja:24
msgid "web_ui.prompts.auto_install_error.title"
msgstr "Installation failure"
@@ -773,11 +779,15 @@ msgstr "Last refreshed on {}."
msgid "web_ui.repos.single.refresh_now_button"
msgstr "Refresh"
-#: src/hydrilla/proxy/web_ui/templates/repos/show_single.html.jinja:163
+#: src/hydrilla/proxy/web_ui/templates/repos/show_single.html.jinja:164
msgid "web_ui.repos.item_count_{mappings}_{resources}"
msgstr "packages: {mappings}; libraries: {resources}"
-#: src/hydrilla/proxy/web_ui/templates/repos/show_single.html.jinja:174
+#: src/hydrilla/proxy/web_ui/templates/repos/show_single.html.jinja:172
+msgid "web_ui.repos.item_count_{mappings}"
+msgstr "packages: {mappings}"
+
+#: src/hydrilla/proxy/web_ui/templates/repos/show_single.html.jinja:181
msgid "web_ui.repos.single.remove_button"
msgstr "Remove repository"
diff --git a/src/hydrilla/proxy/state.py b/src/hydrilla/proxy/state.py
index ae80dfb..a94cd75 100644
--- a/src/hydrilla/proxy/state.py
+++ b/src/hydrilla/proxy/state.py
@@ -468,6 +468,7 @@ class HaketiloGlobalSettings:
"""...."""
mapping_use_mode: MappingUseMode
default_allow_scripts: bool
+ advanced_user: bool
repo_refresh_seconds: int
@@ -526,6 +527,7 @@ class HaketiloState(ABC):
*,
mapping_use_mode: t.Optional[MappingUseMode] = None,
default_allow_scripts: t.Optional[bool] = None,
+ advanced_user: t.Optional[bool] = None,
repo_refresh_seconds: t.Optional[int] = None
) -> None:
"""...."""
diff --git a/src/hydrilla/proxy/state_impl/concrete_state.py b/src/hydrilla/proxy/state_impl/concrete_state.py
index d08a821..04bb67f 100644
--- a/src/hydrilla/proxy/state_impl/concrete_state.py
+++ b/src/hydrilla/proxy/state_impl/concrete_state.py
@@ -58,21 +58,67 @@ from . import _operations
here = Path(__file__).resolve().parent
+def _prepare_database(connection: sqlite3.Connection) -> None:
+ cursor = connection.cursor()
+
+ try:
+ cursor.execute(
+ '''
+ SELECT
+ COUNT(name)
+ FROM
+ sqlite_master
+ WHERE
+ name = 'general' AND type = 'table';
+ '''
+ )
+
+ (db_initialized,), = cursor.fetchall()
+
+ if not db_initialized:
+ cursor.executescript((here.parent / 'tables.sql').read_text())
+ else:
+ cursor.execute(
+ '''
+ SELECT
+ haketilo_version
+ FROM
+ general;
+ '''
+ )
+
+ (db_haketilo_version,) = cursor.fetchone()
+ if db_haketilo_version != '3.0b1':
+ raise HaketiloException(_('err.proxy.unknown_db_schema'))
+
+ cursor.execute('PRAGMA FOREIGN_KEYS;')
+ if cursor.fetchall() == []:
+ raise HaketiloException(_('err.proxy.no_sqlite_foreign_keys'))
+
+ cursor.execute('PRAGMA FOREIGN_KEYS=ON;')
+ finally:
+ cursor.close()
+
+
def load_settings(cursor: sqlite3.Cursor) -> st.HaketiloGlobalSettings:
cursor.execute(
'''
SELECT
- default_allow_scripts, repo_refresh_seconds, mapping_use_mode
+ default_allow_scripts,
+ advanced_user,
+ repo_refresh_seconds,
+ mapping_use_mode
FROM
general
'''
)
- (default_allow_scripts, repo_refresh_seconds,
+ (default_allow_scripts, advanced_user, repo_refresh_seconds,
mapping_use_mode), = cursor.fetchall()
return st.HaketiloGlobalSettings(
default_allow_scripts = default_allow_scripts,
+ advanced_user = advanced_user,
repo_refresh_seconds = repo_refresh_seconds,
mapping_use_mode = st.MappingUseMode(mapping_use_mode)
)
@@ -80,55 +126,8 @@ def load_settings(cursor: sqlite3.Cursor) -> st.HaketiloGlobalSettings:
@dc.dataclass
class ConcreteHaketiloState(base.HaketiloStateWithFields):
def __post_init__(self) -> None:
- sqlite3.enable_callback_tracebacks(True)
-
- self._prepare_database()
-
self.rebuild_structures()
- def _prepare_database(self) -> None:
- """...."""
- cursor = self.connection.cursor()
-
- try:
- cursor.execute(
- '''
- SELECT
- COUNT(name)
- FROM
- sqlite_master
- WHERE
- name = 'general' AND type = 'table';
- '''
- )
-
- (db_initialized,), = cursor.fetchall()
-
- if not db_initialized:
- cursor.executescript((here.parent / 'tables.sql').read_text())
-
- else:
- cursor.execute(
- '''
- SELECT
- haketilo_version
- FROM
- general;
- '''
- )
-
- (db_haketilo_version,) = cursor.fetchone()
- if db_haketilo_version != '3.0b1':
- raise HaketiloException(_('err.proxy.unknown_db_schema'))
-
- cursor.execute('PRAGMA FOREIGN_KEYS;')
- if cursor.fetchall() == []:
- raise HaketiloException(_('err.proxy.no_sqlite_foreign_keys'))
-
- cursor.execute('PRAGMA FOREIGN_KEYS=ON;')
- finally:
- cursor.close()
-
def import_items(self, malcontent_path: Path, repo_id: int = 1) -> None:
with self.cursor(transaction=(repo_id == 1)) as cursor:
# This method without the repo_id argument exposed is part of the
@@ -305,6 +304,7 @@ class ConcreteHaketiloState(base.HaketiloStateWithFields):
*,
mapping_use_mode: t.Optional[st.MappingUseMode] = None,
default_allow_scripts: t.Optional[bool] = None,
+ advanced_user: t.Optional[bool] = None,
repo_refresh_seconds: t.Optional[int] = None
) -> None:
with self.cursor(transaction=True) as cursor:
@@ -315,6 +315,8 @@ class ConcreteHaketiloState(base.HaketiloStateWithFields):
set_opt('mapping_use_mode', mapping_use_mode.value)
if default_allow_scripts is not None:
set_opt('default_allow_scripts', default_allow_scripts)
+ if advanced_user is not None:
+ set_opt('advanced_user', advanced_user)
if repo_refresh_seconds is not None:
set_opt('repo_refresh_seconds', repo_refresh_seconds)
@@ -328,6 +330,8 @@ class ConcreteHaketiloState(base.HaketiloStateWithFields):
check_same_thread = False
)
+ _prepare_database(connection)
+
global_settings = load_settings(connection.cursor())
return ConcreteHaketiloState(
diff --git a/src/hydrilla/proxy/tables.sql b/src/hydrilla/proxy/tables.sql
index 4465a05..6ceea25 100644
--- a/src/hydrilla/proxy/tables.sql
+++ b/src/hydrilla/proxy/tables.sql
@@ -30,6 +30,7 @@ BEGIN TRANSACTION;
CREATE TABLE general(
haketilo_version VARCHAR NOT NULL,
default_allow_scripts BOOLEAN NOT NULL,
+ advanced_user BOOLEAN NOT NULL,
repo_refresh_seconds INTEGER NOT NULL,
-- "mapping_use_mode" determines whether current mode is AUTO,
-- WHEN_ENABLED or QUESTION.
@@ -44,6 +45,7 @@ INSERT INTO general(
rowid,
haketilo_version,
default_allow_scripts,
+ advanced_user,
repo_refresh_seconds,
mapping_use_mode
)
@@ -51,6 +53,7 @@ VALUES(
1,
'3.0b1',
FALSE,
+ FALSE,
24 * 60 * 60,
'Q'
);
diff --git a/src/hydrilla/proxy/web_ui/items.py b/src/hydrilla/proxy/web_ui/items.py
index ec394ee..6195107 100644
--- a/src/hydrilla/proxy/web_ui/items.py
+++ b/src/hydrilla/proxy/web_ui/items.py
@@ -177,7 +177,6 @@ def show_item_version(
f'items/{item_type.alt_name}_viewversion.html.jinja',
display_info = display_info,
version_display_info = this_info,
- settings = state.get_settings(),
**errors
)
return flask.make_response(html, 200)
diff --git a/src/hydrilla/proxy/web_ui/options.py b/src/hydrilla/proxy/web_ui/options.py
index 9be1ae0..7d59375 100644
--- a/src/hydrilla/proxy/web_ui/options.py
+++ b/src/hydrilla/proxy/web_ui/options.py
@@ -41,11 +41,7 @@ bp = flask.Blueprint('options', __package__)
@bp.route('/options', methods=['GET'])
def options(errors: t.Mapping[str, bool] = {}) -> werkzeug.Response:
- html = flask.render_template(
- 'options.html.jinja',
- settings = _app.get_haketilo_state().get_settings(),
- **errors
- )
+ html = flask.render_template('options.html.jinja', **errors)
return flask.make_response(html, 200)
@bp.route('/options', methods=['POST'])
@@ -64,6 +60,10 @@ def options_post() -> werkzeug.Response:
state.update_settings(default_allow_scripts=True)
elif action == 'block_scripts':
state.update_settings(default_allow_scripts=False)
+ elif action == 'user_make_advanced':
+ state.update_settings(advanced_user=True)
+ elif action == 'user_make_simple':
+ state.update_settings(advanced_user=False)
else:
raise ValueError()
diff --git a/src/hydrilla/proxy/web_ui/root.py b/src/hydrilla/proxy/web_ui/root.py
index ed030d2..21c491b 100644
--- a/src/hydrilla/proxy/web_ui/root.py
+++ b/src/hydrilla/proxy/web_ui/root.py
@@ -64,11 +64,14 @@ def authenticate_by_referrer() -> t.Optional[werkzeug.Response]:
flask.abort(403)
-def get_current_endpoint() -> t.Optional[str]:
+def get_current_endpoint() -> str:
endpoint = flask.request.endpoint
assert endpoint is not None
return endpoint
+def get_settings() -> st.HaketiloGlobalSettings:
+ return _app.get_haketilo_state().get_settings()
+
class WebUIAppImpl(_app.WebUIApp):
def __init__(self):
@@ -87,6 +90,7 @@ class WebUIAppImpl(_app.WebUIApp):
}
self.jinja_env.globals['get_current_endpoint'] = get_current_endpoint
+ self.jinja_env.globals['get_settings'] = get_settings
self.jinja_env.globals['EnabledStatus'] = st.EnabledStatus
self.jinja_env.globals['FrozenStatus'] = st.FrozenStatus
self.jinja_env.globals['InstalledStatus'] = st.InstalledStatus
diff --git a/src/hydrilla/proxy/web_ui/templates/base.html.jinja b/src/hydrilla/proxy/web_ui/templates/base.html.jinja
index ff9fd71..493398a 100644
--- a/src/hydrilla/proxy/web_ui/templates/base.html.jinja
+++ b/src/hydrilla/proxy/web_ui/templates/base.html.jinja
@@ -20,6 +20,8 @@ code in a proprietary work, I am not going to enforce this in court.
-#}
<!DOCTYPE html>
+{% set settings = get_settings() %}
+
{% macro button_row(buttons_data, common_fields={}) %}
<div class="flex-row">
{% for classes, text, extra_fields in buttons_data %}
@@ -236,17 +238,20 @@ code in a proprietary work, I am not going to enforce this in court.
{% set active_endpoint = get_current_endpoint() %}
{%
set navigation_bar = [
- ('home', _('web_ui.base.nav.home')),
- ('options.options', _('web_ui.base.nav.options')),
- ('rules.rules', _('web_ui.base.nav.rules')),
- ('items.packages', _('web_ui.base.nav.packages')),
- ('items.libraries', _('web_ui.base.nav.libraries')),
- ('repos.repos', _('web_ui.base.nav.repos')),
- ('items.load_from_disk', _('web_ui.base.nav.load'))
+ ('home', _('web_ui.base.nav.home'), false),
+ ('options.options', _('web_ui.base.nav.options'), false),
+ ('rules.rules', _('web_ui.base.nav.rules'), false),
+ ('items.packages', _('web_ui.base.nav.packages'), false),
+ ('items.libraries', _('web_ui.base.nav.libraries'), true),
+ ('repos.repos', _('web_ui.base.nav.repos'), false),
+ ('items.load_from_disk', _('web_ui.base.nav.load'), false)
]
%}
<ul id="nav">
- {% for endpoint, label in navigation_bar %}
+ {%
+ for endpoint, label, advanced_user_only in navigation_bar
+ if not advanced_user_only or settings.advanced_user
+ %}
{% if not loop.first %}
{% set sep_classes = ['nav-separator'] %}
{% if loop.last %}
diff --git a/src/hydrilla/proxy/web_ui/templates/items/item_viewversion.html.jinja b/src/hydrilla/proxy/web_ui/templates/items/item_viewversion.html.jinja
index 952c6b7..a1056b1 100644
--- a/src/hydrilla/proxy/web_ui/templates/items/item_viewversion.html.jinja
+++ b/src/hydrilla/proxy/web_ui/templates/items/item_viewversion.html.jinja
@@ -48,62 +48,53 @@ code in a proprietary work, I am not going to enforce this in court.
<p>
TODO: add more info...
</p>
+ {% endblock %}
+ {%
+ if settings.advanced_user and
+ version_display_info.active != ActiveStatus.REQUIRED
+ %}
<div class="horizontal-separator"></div>
- {% endblock %}
- <p>
- {% if version_display_info.active == ActiveStatus.REQUIRED %}
- {% block item_required_msg required %}{% endblock %}
- {%
- elif version_display_info.active == ActiveStatus.NOT_ACTIVE or
- settings.mapping_use_mode == MappingUseMode.WHEN_ENABLED
- %}
- {% block item_not_activated_msg required %}{% endblock %}
- {% elif settings.mapping_use_mode == MappingUseMode.QUESTION %}
- {% block item_will_be_asked_about_msg required %}{% endblock %}
+ {% set install_but_classes = ['green-button'] %}
+ {% set uninstall_but_classes = ['green-button'] %}
+ {% if version_display_info.installed == InstalledStatus.FAILED_TO_INSTALL %}
+ {%
+ set install_text =
+ _('web_ui.items.single_version.retry_install_button')
+ %}
+ {%
+ set uninstall_text =
+ _('web_ui.items.single_version.leave_uninstalled_button')
+ %}
+ <div>{% block item_install_failed_msg required %}{% endblock %}</div>
{% else %}
- {# settings.mapping_use_mode == MappingUseMode.AUTO #}
- {% block item_auto_activated_msg required %}{% endblock %}
- {% endif %}
- </p>
-
- {% set install_but_classes = ['green-button'] %}
- {% set uninstall_but_classes = ['green-button'] %}
- {% if version_display_info.installed == InstalledStatus.FAILED_TO_INSTALL %}
- {%
- set install_text =
- _('web_ui.items.single_version.retry_install_button')
- %}
- {%
- set uninstall_text =
- _('web_ui.items.single_version.leave_uninstalled_button')
- %}
- <div>{% block item_install_failed_msg required %}{% endblock %}</div>
- {% else %}
- {% set install_text = _('web_ui.items.single_version.install_button') %}
- {% set uninstall_text = _('web_ui.items.single_version.uninstall_button') %}
- {% if version_display_info.installed == InstalledStatus.INSTALLED %}
- {% do install_but_classes.append('disabled-button') %}
+ {% set install_text = _('web_ui.items.single_version.install_button') %}
{%
- if uninstall_disallowed is defined or
- version_display_info.active == ActiveStatus.REQUIRED
+ set uninstall_text = _('web_ui.items.single_version.uninstall_button')
%}
+ {% if version_display_info.installed == InstalledStatus.INSTALLED %}
+ {% do install_but_classes.append('disabled-button') %}
+ {%
+ if uninstall_disallowed is defined or
+ version_display_info.active == ActiveStatus.REQUIRED
+ %}
+ {% do uninstall_but_classes.append('disabled-button') %}
+ {% endif %}
+ {% else %}
+ {# version_display_info.installed == InstalledStatus.NOT_INSTALLED #}
{% do uninstall_but_classes.append('disabled-button') %}
{% endif %}
- {% else %}
- {# version_display_info.installed == InstalledStatus.NOT_INSTALLED #}
- {% do uninstall_but_classes.append('disabled-button') %}
- {% endif %}
- {% endif %}{# else/ version_display_info.installed == InstalledStatus.FA... #}
-
- {% set uninstall_fields = {'action': 'uninstall_item_version'} %}
- {% set install_fields = {'action': 'install_item_version'} %}
-
- {{
- button_row([
- (uninstall_but_classes, uninstall_text, uninstall_fields),
- (install_but_classes, install_text, install_fields)
- ])
- }}
+ {% endif %}{# else/ version_display_info.installed == InstalledStatus.... #}
+
+ {% set uninstall_fields = {'action': 'uninstall_item_version'} %}
+ {% set install_fields = {'action': 'install_item_version'} %}
+
+ {{
+ button_row([
+ (uninstall_but_classes, uninstall_text, uninstall_fields),
+ (install_but_classes, install_text, install_fields)
+ ])
+ }}
+ {% endif %}{# settings.advanced_user #}
{% endblock main_info %}
diff --git a/src/hydrilla/proxy/web_ui/templates/items/library_viewversion.html.jinja b/src/hydrilla/proxy/web_ui/templates/items/library_viewversion.html.jinja
index f1d1b74..13ee41a 100644
--- a/src/hydrilla/proxy/web_ui/templates/items/library_viewversion.html.jinja
+++ b/src/hydrilla/proxy/web_ui/templates/items/library_viewversion.html.jinja
@@ -38,22 +38,6 @@ code in a proprietary work, I am not going to enforce this in court.
{% endif %}
{% endblock %}
-{% block item_required_msg %}
- {{ _('web_ui.items.single_version.library.item_required') }}
-{% endblock %}
-
-{% block item_auto_activated_msg %}
- {{ _('web_ui.items.single_version.library.item_auto_activated') }}
-{% endblock %}
-
-{% block item_not_activated_msg %}
- {{ _('web_ui.items.single_version.library.item_not_activated') }}
-{% endblock %}
-
-{% block item_will_be_asked_about_msg %}
- {{ _('web_ui.items.single_version.library.item_will_be_asked_about') }}
-{% endblock %}
-
{% block item_install_failed_msg %}
{{ _('web_ui.items.single_version.library.install_failed') }}
{% endblock %}
@@ -68,4 +52,20 @@ code in a proprietary work, I am not going to enforce this in court.
</p>
<div class="horizontal-separator"></div>
+
+ <p>
+ {% if version_display_info.active == ActiveStatus.REQUIRED %}
+ {{ _('web_ui.items.single_version.library.item_required') }}
+ {%
+ elif version_display_info.active == ActiveStatus.NOT_ACTIVE or
+ settings.mapping_use_mode == MappingUseMode.WHEN_ENABLED
+ %}
+ {{ _('web_ui.items.single_version.library.item_not_activated') }}
+ {% elif settings.mapping_use_mode == MappingUseMode.QUESTION %}
+ {{ _('web_ui.items.single_version.library.item_will_be_asked_about') }}
+ {% else %}
+ {# settings.mapping_use_mode == MappingUseMode.AUTO #}
+ {{ _('web_ui.items.single_version.library.item_auto_activated') }}
+ {% endif %}
+ </p>
{% endblock %}
diff --git a/src/hydrilla/proxy/web_ui/templates/items/package_viewversion.html.jinja b/src/hydrilla/proxy/web_ui/templates/items/package_viewversion.html.jinja
index 04caf8c..31f5e2e 100644
--- a/src/hydrilla/proxy/web_ui/templates/items/package_viewversion.html.jinja
+++ b/src/hydrilla/proxy/web_ui/templates/items/package_viewversion.html.jinja
@@ -38,22 +38,6 @@ code in a proprietary work, I am not going to enforce this in court.
{% endif %}
{% endblock %}
-{% block item_required_msg %}
- {{ _('web_ui.items.single_version.package.item_required') }}
-{% endblock %}
-
-{% block item_auto_activated_msg %}
- {{ _('web_ui.items.single_version.package.item_auto_activated') }}
-{% endblock %}
-
-{% block item_not_activated_msg %}
- {{ _('web_ui.items.single_version.package.item_not_activated') }}
-{% endblock %}
-
-{% block item_will_be_asked_about_msg %}
- {{ _('web_ui.items.single_version.package.item_will_be_asked_about') }}
-{% endblock %}
-
{% block item_install_failed_msg %}
{{ _('web_ui.items.single_version.package.install_failed') }}
{% endblock %}
@@ -80,14 +64,24 @@ code in a proprietary work, I am not going to enforce this in court.
<p>
{% if display_info.enabled == EnabledStatus.NO_MARK %}
{% do unenable_but_classes.append('disabled-button') %}
- {{ _('web_ui.items.single_version.item_not_marked') }}
+ {%
+ if version_display_info.active == ActiveStatus.NOT_ACTIVE or
+ settings.mapping_use_mode == MappingUseMode.WHEN_ENABLED
+ %}
+ {{ _('web_ui.items.single_version.package.item_not_activated') }}
+ {% elif settings.mapping_use_mode == MappingUseMode.QUESTION %}
+ {{ _('web_ui.items.single_version.package.item_will_be_asked_about') }}
+ {% else %}
+ {# settings.mapping_use_mode == MappingUseMode.AUTO #}
+ {{ _('web_ui.items.single_version.package.item_auto_activated') }}
+ {% endif %}
{% elif display_info.enabled == EnabledStatus.DISABLED %}
{% do disable_but_classes.append('disabled-button') %}
- {{ _('web_ui.items.single_version.item_disabled') }}
+ {{ _('web_ui.items.single_version.package.item_disabled') }}
{% else %}
{# display_info.enabled == EnabledStatus.ENABLED #}
{% do enable_but_classes.append('disabled-button') %}
- {{ _('web_ui.items.single_version.item_enabled') }}
+ {{ _('web_ui.items.single_version.package.item_enabled') }}
{% endif %}
</p>
@@ -99,9 +93,9 @@ code in a proprietary work, I am not going to enforce this in court.
])
}}
- <div class="horizontal-separator"></div>
-
{% if display_info.enabled == EnabledStatus.ENABLED %}
+ <div class="horizontal-separator"></div>
+
{% set unpin_but_classes = ['green-button'] %}
{% set pin_repo_but_classes = ['green-button'] %}
{% set pin_ver_but_classes = ['green-button'] %}
@@ -191,7 +185,5 @@ code in a proprietary work, I am not going to enforce this in court.
(pin_ver_but_classes, pin_ver_text, {'action': 'freeze_to_version'})
])
}}
-
- <div class="horizontal-separator"></div>
{% endif %}{# display_info.enabled == EnabledStatus.ENABLED #}
{% endblock main_info_bulk %}
diff --git a/src/hydrilla/proxy/web_ui/templates/options.html.jinja b/src/hydrilla/proxy/web_ui/templates/options.html.jinja
index a7e6d7d..26519c4 100644
--- a/src/hydrilla/proxy/web_ui/templates/options.html.jinja
+++ b/src/hydrilla/proxy/web_ui/templates/options.html.jinja
@@ -83,4 +83,30 @@ code in a proprietary work, I am not going to enforce this in court.
(block_but_classes, block_but_text, {'action': 'block_scripts'})
])
}}
+
+ <div class="horizontal-separator"></div>
+
+ {% set advanced_user_but_classes = ['red-button'] %}
+ {% set simple_user_but_classes = ['green-button'] %}
+
+ <p>
+ {% if settings.advanced_user %}
+ {% do advanced_user_but_classes.append('disabled-button') %}
+ {{ _('web_ui.options.user_is_advanced_user') }}
+ {% else %}
+ {% do simple_user_but_classes.append('disabled-button') %}
+ {{ _('web_ui.options.user_is_simple_user') }}
+ {% endif %}
+ </p>
+
+ {{
+ button_row([
+ (advanced_user_but_classes,
+ _('web_ui.options.user_make_advanced_button'),
+ {'action': 'user_make_advanced'}),
+ (simple_user_but_classes,
+ _('web_ui.options.user_make_simple_button'),
+ {'action': 'user_make_simple'})
+ ])
+ }}
{% endblock %}
diff --git a/src/hydrilla/proxy/web_ui/templates/repos/show_single.html.jinja b/src/hydrilla/proxy/web_ui/templates/repos/show_single.html.jinja
index 25015ae..d2c85df 100644
--- a/src/hydrilla/proxy/web_ui/templates/repos/show_single.html.jinja
+++ b/src/hydrilla/proxy/web_ui/templates/repos/show_single.html.jinja
@@ -159,13 +159,20 @@ code in a proprietary work, I am not going to enforce this in court.
<div class="horizontal-separator"></div>
{% endif %}{# not display_info.deleted (elif) #}
<p>
- {{
- _('web_ui.repos.item_count_{mappings}_{resources}')
- .format(
- mappings = display_info.mapping_count,
- resources = display_info.resource_count
- )
- }}
+ {% if settings.advanced_user %}
+ {{
+ _('web_ui.repos.item_count_{mappings}_{resources}')
+ .format(
+ mappings = display_info.mapping_count,
+ resources = display_info.resource_count
+ )
+ }}
+ {% else %}
+ {{
+ _('web_ui.repos.item_count_{mappings}')
+ .format(mappings = display_info.mapping_count)
+ }}
+ {% endif %}
</p>
{% if not display_info.is_local_semirepo and not display_info.deleted %}