From 7357ee8fb0f42ee7a4f64cd86ab8a6fc5ac8ce2b Mon Sep 17 00:00:00 2001 From: Minnowo <62451415+Minnowo@users.noreply.github.com> Date: Sat, 22 Jul 2023 20:03:47 -0400 Subject: [PATCH 1/3] fixed issue #1360, open help links online if local files does not exist --- hydrus/client/ClientPaths.py | 18 +++++++++ hydrus/client/gui/ClientGUI.py | 2 +- hydrus/client/gui/ClientGUIDownloaders.py | 4 +- hydrus/client/gui/ClientGUILogin.py | 2 +- .../gui/ClientGUIScrolledPanelsReview.py | 4 +- hydrus/client/gui/ClientGUISubscriptions.py | 4 +- .../gui/pages/ClientGUIManagementPanels.py | 2 +- hydrus/client/gui/parsing/ClientGUIParsing.py | 6 +-- .../gui/parsing/ClientGUIParsingFormulae.py | 8 ++-- hydrus/core/HydrusConstants.py | 40 +++++++++++++++++++ 10 files changed, 74 insertions(+), 16 deletions(-) diff --git a/hydrus/client/ClientPaths.py b/hydrus/client/ClientPaths.py index 52e94360..27b621a7 100644 --- a/hydrus/client/ClientPaths.py +++ b/hydrus/client/ClientPaths.py @@ -1,4 +1,5 @@ import webbrowser +import os from hydrus.core import HydrusConstants as HC from hydrus.core import HydrusGlobals as HG @@ -34,3 +35,20 @@ def LaunchURLInWebBrowser( url ): HydrusPaths.LaunchFile( url, launch_path = web_browser_path ) +def OpenDocumentation( documentation_constant : int ): + + local, remote = HC.documentation_path_lookup[documentation_constant] + + local_open = local + + if "#" in local: + + local = local[ :local.find("#") ] + + if os.path.isfile( local ): + + LaunchPathInWebBrowser( local_open ) + + else: + + LaunchURLInWebBrowser( remote ) diff --git a/hydrus/client/gui/ClientGUI.py b/hydrus/client/gui/ClientGUI.py index 79d1867c..48400dcb 100644 --- a/hydrus/client/gui/ClientGUI.py +++ b/hydrus/client/gui/ClientGUI.py @@ -3225,7 +3225,7 @@ class FrameGUI( CAC.ApplicationCommandProcessorMixin, ClientGUITopLevelWindows.M ClientGUIMenus.AppendMenu( menu, links, 'links' ) - ClientGUIMenus.AppendMenuItem( menu, 'changelog', 'Open hydrus\'s local changelog in your web browser.', ClientPaths.LaunchPathInWebBrowser, os.path.join( HC.HELP_DIR, 'changelog.html' ) ) + ClientGUIMenus.AppendMenuItem( menu, 'changelog', 'Open hydrus\'s local changelog in your web browser.', ClientPaths.OpenDocumentation, HC.DOCUMENTATION_CHANGELOG ) ClientGUIMenus.AppendSeparator( menu ) diff --git a/hydrus/client/gui/ClientGUIDownloaders.py b/hydrus/client/gui/ClientGUIDownloaders.py index a168cb4e..507f3ba0 100644 --- a/hydrus/client/gui/ClientGUIDownloaders.py +++ b/hydrus/client/gui/ClientGUIDownloaders.py @@ -564,7 +564,7 @@ class EditGUGsPanel( ClientGUIScrolledPanels.EditPanel ): menu_items = [] - call = HydrusData.Call( ClientPaths.LaunchPathInWebBrowser, os.path.join( HC.HELP_DIR, 'downloader_gugs.html' ) ) + call = HydrusData.Call( ClientPaths.OpenDocumentation, HC.DOCUMENTATION_DOWNLOADER_GUGS ) menu_items.append( ( 'normal', 'open the gugs help', 'Open the help page for gugs in your web browser.', call ) ) @@ -2002,7 +2002,7 @@ class EditURLClassesPanel( ClientGUIScrolledPanels.EditPanel ): menu_items = [] - call = HydrusData.Call( ClientPaths.LaunchPathInWebBrowser, os.path.join( HC.HELP_DIR, 'downloader_url_classes.html' ) ) + call = HydrusData.Call( ClientPaths.OpenDocumentation, HC.DOCUMENTATION_DOWNLOADER_URL_CLASSES ) menu_items.append( ( 'normal', 'open the url classes help', 'Open the help page for url classes in your web browser.', call ) ) diff --git a/hydrus/client/gui/ClientGUILogin.py b/hydrus/client/gui/ClientGUILogin.py index eacdf403..b4bd10b7 100644 --- a/hydrus/client/gui/ClientGUILogin.py +++ b/hydrus/client/gui/ClientGUILogin.py @@ -1305,7 +1305,7 @@ class EditLoginScriptPanel( ClientGUIScrolledPanels.EditPanel ): menu_items = [] - page_func = HydrusData.Call( ClientPaths.LaunchPathInWebBrowser, os.path.join( HC.HELP_DIR, 'downloader_login.html' ) ) + page_func = HydrusData.Call( ClientPaths.OpenDocumentation, HC.DOCUMENTATION_DOWNLOADER_LOGIN ) menu_items.append( ( 'normal', 'open the login scripts help', 'Open the help page for login scripts in your web browser.', page_func ) ) diff --git a/hydrus/client/gui/ClientGUIScrolledPanelsReview.py b/hydrus/client/gui/ClientGUIScrolledPanelsReview.py index 6f120378..6c5ddaf9 100644 --- a/hydrus/client/gui/ClientGUIScrolledPanelsReview.py +++ b/hydrus/client/gui/ClientGUIScrolledPanelsReview.py @@ -142,7 +142,7 @@ class MigrateDatabasePanel( ClientGUIScrolledPanels.ReviewPanel ): menu_items = [] - page_func = HydrusData.Call( ClientPaths.LaunchPathInWebBrowser, os.path.join( HC.HELP_DIR, 'database_migration.html' ) ) + page_func = HydrusData.Call( ClientPaths.OpenDocumentation, HC.DOCUMENTATION_DATABASE_MIGRATION ) menu_items.append( ( 'normal', 'open the html migration help', 'Open the help page for database migration in your web browser.', page_func ) ) @@ -1830,7 +1830,7 @@ class ReviewDownloaderImport( ClientGUIScrolledPanels.ReviewPanel ): menu_items = [] - page_func = HydrusData.Call( ClientPaths.LaunchPathInWebBrowser, os.path.join( HC.HELP_DIR, 'adding_new_downloaders.html' ) ) + page_func = HydrusData.Call( ClientPaths.OpenDocumentation, HC.DOCUMENTATION_ADDING_NEW_DOWNLOADERS ) menu_items.append( ( 'normal', 'open the easy downloader import help', 'Open the help page for easily importing downloaders in your web browser.', page_func ) ) diff --git a/hydrus/client/gui/ClientGUISubscriptions.py b/hydrus/client/gui/ClientGUISubscriptions.py index 2a032078..676d269d 100644 --- a/hydrus/client/gui/ClientGUISubscriptions.py +++ b/hydrus/client/gui/ClientGUISubscriptions.py @@ -132,7 +132,7 @@ class EditSubscriptionPanel( ClientGUIScrolledPanels.EditPanel ): menu_items = [] - page_func = HydrusData.Call( ClientPaths.LaunchPathInWebBrowser, os.path.join( HC.HELP_DIR, 'getting_started_subscriptions.html' ) ) + page_func = HydrusData.Call( ClientPaths.OpenDocumentation, HC.DOCUMENTATION_GETTING_STARTED_SUBSCRIPTIONS ) menu_items.append( ( 'normal', 'open the html subscriptions help', 'Open the help page for subscriptions in your web browser.', page_func ) ) @@ -1325,7 +1325,7 @@ class EditSubscriptionsPanel( ClientGUIScrolledPanels.EditPanel ): menu_items = [] - page_func = HydrusData.Call( ClientPaths.LaunchPathInWebBrowser, os.path.join( HC.HELP_DIR, 'getting_started_subscriptions.html' ) ) + page_func = HydrusData.Call( ClientPaths.OpenDocumentation, HC.DOCUMENTATION_GETTING_STARTED_SUBSCRIPTIONS ) menu_items.append( ( 'normal', 'open the html subscriptions help', 'Open the help page for subscriptions in your web browser.', page_func ) ) diff --git a/hydrus/client/gui/pages/ClientGUIManagementPanels.py b/hydrus/client/gui/pages/ClientGUIManagementPanels.py index b39c1d7a..e261c4f0 100644 --- a/hydrus/client/gui/pages/ClientGUIManagementPanels.py +++ b/hydrus/client/gui/pages/ClientGUIManagementPanels.py @@ -479,7 +479,7 @@ class ManagementPanelDuplicateFilter( ManagementPanel ): menu_items = [] - page_func = HydrusData.Call( ClientPaths.LaunchPathInWebBrowser, os.path.join( HC.HELP_DIR, 'duplicates.html' ) ) + page_func = HydrusData.Call( ClientPaths.OpenDocumentation, HC.DOCUMENTATION_DUPLICATES ) menu_items.append( ( 'normal', 'open the html duplicates help', 'Open the help page for duplicates processing in your web browser.', page_func ) ) diff --git a/hydrus/client/gui/parsing/ClientGUIParsing.py b/hydrus/client/gui/parsing/ClientGUIParsing.py index d2778126..0daf88ec 100644 --- a/hydrus/client/gui/parsing/ClientGUIParsing.py +++ b/hydrus/client/gui/parsing/ClientGUIParsing.py @@ -52,7 +52,7 @@ class DownloaderExportPanel( ClientGUIScrolledPanels.ReviewPanel ): menu_items = [] - page_func = HydrusData.Call( ClientPaths.LaunchPathInWebBrowser, os.path.join( HC.HELP_DIR, 'downloader_sharing.html' ) ) + page_func = HydrusData.Call( ClientPaths.OpenDocumentation, HC.DOCUMENTATION_DOWNLOADER_SHARING ) menu_items.append( ( 'normal', 'open the downloader sharing help', 'Open the help page for sharing downloaders in your web browser.', page_func ) ) @@ -498,7 +498,7 @@ class EditContentParserPanel( ClientGUIScrolledPanels.EditPanel ): menu_items = [] - page_func = HydrusData.Call( ClientPaths.LaunchPathInWebBrowser, os.path.join( HC.HELP_DIR, 'downloader_parsers_content_parsers.html#content_parsers' ) ) + page_func = HydrusData.Call( ClientPaths.OpenDocumentation, HC.DOCUMENTATION_DOWNLOADER_PARSERS_CONTENT_PARSERS__CONTENT_PARSERS ) menu_items.append( ( 'normal', 'open the content parsers help', 'Open the help page for content parsers in your web browser.', page_func ) ) @@ -1185,7 +1185,7 @@ class EditPageParserPanel( ClientGUIScrolledPanels.EditPanel ): menu_items = [] - page_func = HydrusData.Call( ClientPaths.LaunchPathInWebBrowser, os.path.join( HC.HELP_DIR, 'downloader_parsers_page_parsers.html#page_parsers' ) ) + page_func = HydrusData.Call( ClientPaths.OpenDocumentation, HC.DOCUMENTATION_DOWNLOADER_PARSERS_PAGE_PARSERS__PAGE_PARSERS ) menu_items.append( ( 'normal', 'open the page parser help', 'Open the help page for page parsers in your web browser.', page_func ) ) diff --git a/hydrus/client/gui/parsing/ClientGUIParsingFormulae.py b/hydrus/client/gui/parsing/ClientGUIParsingFormulae.py index a7a1b043..9759be70 100644 --- a/hydrus/client/gui/parsing/ClientGUIParsingFormulae.py +++ b/hydrus/client/gui/parsing/ClientGUIParsingFormulae.py @@ -49,7 +49,7 @@ class EditCompoundFormulaPanel( EditSpecificFormulaPanel ): menu_items = [] - page_func = HydrusData.Call( ClientPaths.LaunchPathInWebBrowser, os.path.join( HC.HELP_DIR, 'downloader_parsers_formulae.html#compound_formula' ) ) + page_func = HydrusData.Call( ClientPaths.OpenDocumentation, HC.DOCUMENTATION_DOWNLOADER_PARSERS_FORMULAE__COMPOUND_FORMULA ) menu_items.append( ( 'normal', 'open the compound formula help', 'Open the help page for compound formulae in your web browser.', page_func ) ) @@ -283,7 +283,7 @@ class EditContextVariableFormulaPanel( EditSpecificFormulaPanel ): menu_items = [] - page_func = HydrusData.Call( ClientPaths.LaunchPathInWebBrowser, os.path.join( HC.HELP_DIR, 'downloader_parsers_formulae.html#context_variable_formula' ) ) + page_func = HydrusData.Call( ClientPaths.OpenDocumentation, HC.DOCUMENTATION_DOWNLOADER_PARSERS_FORMULAE__CONTEXT_VARIABLE_FORMULA ) menu_items.append( ( 'normal', 'open the context variable formula help', 'Open the help page for context variable formulae in your web browser.', page_func ) ) @@ -748,7 +748,7 @@ class EditHTMLFormulaPanel( EditSpecificFormulaPanel ): menu_items = [] - page_func = HydrusData.Call( ClientPaths.LaunchPathInWebBrowser, os.path.join( HC.HELP_DIR, 'downloader_parsers_formulae.html#html_formula' ) ) + page_func = HydrusData.Call( ClientPaths.OpenDocumentation, HC.DOCUMENTATION_DOWNLOADER_PARSERS_FORMULAE__HTML_FORMULA ) menu_items.append( ( 'normal', 'open the html formula help', 'Open the help page for html formulae in your web browser.', page_func ) ) @@ -1107,7 +1107,7 @@ class EditJSONFormulaPanel( EditSpecificFormulaPanel ): menu_items = [] - page_func = HydrusData.Call( ClientPaths.LaunchPathInWebBrowser, os.path.join( HC.HELP_DIR, 'downloader_parsers_formulae.html#json_formula' ) ) + page_func = HydrusData.Call( ClientPaths.OpenDocumentation, HC.DOCUMENTATION_DOWNLOADER_PARSERS_FORMULAE__JSON_FORMULA ) menu_items.append( ( 'normal', 'open the json formula help', 'Open the help page for json formulae in your web browser.', page_func ) ) diff --git a/hydrus/core/HydrusConstants.py b/hydrus/core/HydrusConstants.py index ca3c9838..dfbebfe5 100644 --- a/hydrus/core/HydrusConstants.py +++ b/hydrus/core/HydrusConstants.py @@ -1094,6 +1094,46 @@ url_type_string_lookup = { URL_TYPE_SUB_GALLERY : 'sub-gallery url (is queued even if creator found no post/file urls)' } + + +REMOTE_DOCS = "https://hydrusnetwork.github.io/hydrus" + +DOCUMENTATION_CHANGELOG = 0 +DOCUMENTATION_DOWNLOADER_GUGS = 1 +DOCUMENTATION_DOWNLOADER_LOGIN = 2 +DOCUMENTATION_ADDING_NEW_DOWNLOADERS = 3 +DOCUMENTATION_DOWNLOADER_URL_CLASSES = 4 +DOCUMENTATION_GETTING_STARTED_SUBSCRIPTIONS = 5 +DOCUMENTATION_DATABASE_MIGRATION = 6 +DOCUMENTATION_DUPLICATES = 7 +DOCUMENTATION_DOWNLOADER_SHARING = 8 +DOCUMENTATION_DOWNLOADER_PARSERS_PAGE_PARSERS__PAGE_PARSERS = 9 +DOCUMENTATION_DOWNLOADER_PARSERS_CONTENT_PARSERS__CONTENT_PARSERS = 10 +DOCUMENTATION_DOWNLOADER_PARSERS_FORMULAE__COMPOUND_FORMULA = 11 +DOCUMENTATION_DOWNLOADER_PARSERS_FORMULAE__CONTEXT_VARIABLE_FORMULA = 12 +DOCUMENTATION_DOWNLOADER_PARSERS_FORMULAE__HTML_FORMULA = 13 +DOCUMENTATION_DOWNLOADER_PARSERS_FORMULAE__JSON_FORMULA = 14 + +documentation_path_lookup = { + DOCUMENTATION_CHANGELOG : (os.path.join( HELP_DIR, 'changelog.html' ), f"{REMOTE_DOCS}/changelog.html#version_{SOFTWARE_VERSION}"), + DOCUMENTATION_DOWNLOADER_GUGS : (os.path.join( HELP_DIR, 'downloader_gugs.html' ), f"{REMOTE_DOCS}/downloader_gugs.html"), + DOCUMENTATION_DOWNLOADER_LOGIN : (os.path.join( HELP_DIR, 'downloader_login.html'), f"{REMOTE_DOCS}/downloader_login.html"), + DOCUMENTATION_ADDING_NEW_DOWNLOADERS : (os.path.join( HELP_DIR, 'adding_new_downloaders.html'), f"{REMOTE_DOCS}/adding_new_downloaders.html"), + DOCUMENTATION_DOWNLOADER_URL_CLASSES : (os.path.join( HELP_DIR, 'downloader_url_classes.html'), f"{REMOTE_DOCS}/downloader_url_classes.html"), + DOCUMENTATION_GETTING_STARTED_SUBSCRIPTIONS: (os.path.join( HELP_DIR, 'getting_started_subscriptions.html'), f"{REMOTE_DOCS}/getting_started_subscriptions.html"), + DOCUMENTATION_DATABASE_MIGRATION : (os.path.join( HELP_DIR, 'database_migration.html'), f"{REMOTE_DOCS}/database_migration.html"), + DOCUMENTATION_DUPLICATES : (os.path.join( HELP_DIR, 'duplicates.html'), f"{REMOTE_DOCS}/duplicates.html"), + DOCUMENTATION_DOWNLOADER_SHARING : (os.path.join( HELP_DIR, 'downloader_sharing.html'), f"{REMOTE_DOCS}/downloader_sharing.html"), + DOCUMENTATION_DOWNLOADER_PARSERS_PAGE_PARSERS__PAGE_PARSERS : (os.path.join( HELP_DIR, 'downloader_parsers_page_parsers.html#page_parsers'), f"{REMOTE_DOCS}/downloader_parsers_page_parsers.html#page_parsers"), + DOCUMENTATION_DOWNLOADER_PARSERS_CONTENT_PARSERS__CONTENT_PARSERS : (os.path.join( HELP_DIR, 'downloader_parsers_content_parsers.html#content_parsers'), f"{REMOTE_DOCS}/downloader_parsers_content_parsers.html#content_parsers"), + DOCUMENTATION_DOWNLOADER_PARSERS_FORMULAE__COMPOUND_FORMULA : (os.path.join( HELP_DIR, 'downloader_parsers_formulae.html#compound_formula'), f"{REMOTE_DOCS}/downloader_parsers_formulae.html#compound_formula"), + DOCUMENTATION_DOWNLOADER_PARSERS_FORMULAE__CONTEXT_VARIABLE_FORMULA: (os.path.join( HELP_DIR, 'downloader_parsers_formulae.html#context_variable_formula'), f"{REMOTE_DOCS}/downloader_parsers_formulae.html#context_variable_formula"), + DOCUMENTATION_DOWNLOADER_PARSERS_FORMULAE__HTML_FORMULA : (os.path.join( HELP_DIR, 'downloader_parsers_formulae.html#html_formula'), f"{REMOTE_DOCS}/downloader_parsers_formulae.html#html_formula"), + DOCUMENTATION_DOWNLOADER_PARSERS_FORMULAE__JSON_FORMULA : (os.path.join( HELP_DIR, 'downloader_parsers_formulae.html#json_formula'), f"{REMOTE_DOCS}/downloader_parsers_formulae.html#json_formula"), +} + + + # default options DEFAULT_SERVER_ADMIN_PORT = 45870 From 82979119959b6d3b9426d3aff75feced66df4dcd Mon Sep 17 00:00:00 2001 From: Minnowo <62451415+Minnowo@users.noreply.github.com> Date: Sat, 22 Jul 2023 20:47:27 -0400 Subject: [PATCH 2/3] updated how the help paths are handled --- hydrus/client/ClientPaths.py | 5 ++-- hydrus/core/HydrusConstants.py | 50 +++++++++++----------------------- 2 files changed, 19 insertions(+), 36 deletions(-) diff --git a/hydrus/client/ClientPaths.py b/hydrus/client/ClientPaths.py index 27b621a7..ec00d0dd 100644 --- a/hydrus/client/ClientPaths.py +++ b/hydrus/client/ClientPaths.py @@ -35,9 +35,10 @@ def LaunchURLInWebBrowser( url ): HydrusPaths.LaunchFile( url, launch_path = web_browser_path ) -def OpenDocumentation( documentation_constant : int ): +def OpenDocumentation( documentation_path : str ): - local, remote = HC.documentation_path_lookup[documentation_constant] + local = os.path.join( HC.HELP_DIR, documentation_path ) + remote = "/".join((HC.REMOTE_HELP.rstrip("/"), documentation_path.lstrip("/"))) local_open = local diff --git a/hydrus/core/HydrusConstants.py b/hydrus/core/HydrusConstants.py index dfbebfe5..e81b57a6 100644 --- a/hydrus/core/HydrusConstants.py +++ b/hydrus/core/HydrusConstants.py @@ -1096,41 +1096,23 @@ url_type_string_lookup = { -REMOTE_DOCS = "https://hydrusnetwork.github.io/hydrus" +REMOTE_HELP = "https://hydrusnetwork.github.io/hydrus" -DOCUMENTATION_CHANGELOG = 0 -DOCUMENTATION_DOWNLOADER_GUGS = 1 -DOCUMENTATION_DOWNLOADER_LOGIN = 2 -DOCUMENTATION_ADDING_NEW_DOWNLOADERS = 3 -DOCUMENTATION_DOWNLOADER_URL_CLASSES = 4 -DOCUMENTATION_GETTING_STARTED_SUBSCRIPTIONS = 5 -DOCUMENTATION_DATABASE_MIGRATION = 6 -DOCUMENTATION_DUPLICATES = 7 -DOCUMENTATION_DOWNLOADER_SHARING = 8 -DOCUMENTATION_DOWNLOADER_PARSERS_PAGE_PARSERS__PAGE_PARSERS = 9 -DOCUMENTATION_DOWNLOADER_PARSERS_CONTENT_PARSERS__CONTENT_PARSERS = 10 -DOCUMENTATION_DOWNLOADER_PARSERS_FORMULAE__COMPOUND_FORMULA = 11 -DOCUMENTATION_DOWNLOADER_PARSERS_FORMULAE__CONTEXT_VARIABLE_FORMULA = 12 -DOCUMENTATION_DOWNLOADER_PARSERS_FORMULAE__HTML_FORMULA = 13 -DOCUMENTATION_DOWNLOADER_PARSERS_FORMULAE__JSON_FORMULA = 14 - -documentation_path_lookup = { - DOCUMENTATION_CHANGELOG : (os.path.join( HELP_DIR, 'changelog.html' ), f"{REMOTE_DOCS}/changelog.html#version_{SOFTWARE_VERSION}"), - DOCUMENTATION_DOWNLOADER_GUGS : (os.path.join( HELP_DIR, 'downloader_gugs.html' ), f"{REMOTE_DOCS}/downloader_gugs.html"), - DOCUMENTATION_DOWNLOADER_LOGIN : (os.path.join( HELP_DIR, 'downloader_login.html'), f"{REMOTE_DOCS}/downloader_login.html"), - DOCUMENTATION_ADDING_NEW_DOWNLOADERS : (os.path.join( HELP_DIR, 'adding_new_downloaders.html'), f"{REMOTE_DOCS}/adding_new_downloaders.html"), - DOCUMENTATION_DOWNLOADER_URL_CLASSES : (os.path.join( HELP_DIR, 'downloader_url_classes.html'), f"{REMOTE_DOCS}/downloader_url_classes.html"), - DOCUMENTATION_GETTING_STARTED_SUBSCRIPTIONS: (os.path.join( HELP_DIR, 'getting_started_subscriptions.html'), f"{REMOTE_DOCS}/getting_started_subscriptions.html"), - DOCUMENTATION_DATABASE_MIGRATION : (os.path.join( HELP_DIR, 'database_migration.html'), f"{REMOTE_DOCS}/database_migration.html"), - DOCUMENTATION_DUPLICATES : (os.path.join( HELP_DIR, 'duplicates.html'), f"{REMOTE_DOCS}/duplicates.html"), - DOCUMENTATION_DOWNLOADER_SHARING : (os.path.join( HELP_DIR, 'downloader_sharing.html'), f"{REMOTE_DOCS}/downloader_sharing.html"), - DOCUMENTATION_DOWNLOADER_PARSERS_PAGE_PARSERS__PAGE_PARSERS : (os.path.join( HELP_DIR, 'downloader_parsers_page_parsers.html#page_parsers'), f"{REMOTE_DOCS}/downloader_parsers_page_parsers.html#page_parsers"), - DOCUMENTATION_DOWNLOADER_PARSERS_CONTENT_PARSERS__CONTENT_PARSERS : (os.path.join( HELP_DIR, 'downloader_parsers_content_parsers.html#content_parsers'), f"{REMOTE_DOCS}/downloader_parsers_content_parsers.html#content_parsers"), - DOCUMENTATION_DOWNLOADER_PARSERS_FORMULAE__COMPOUND_FORMULA : (os.path.join( HELP_DIR, 'downloader_parsers_formulae.html#compound_formula'), f"{REMOTE_DOCS}/downloader_parsers_formulae.html#compound_formula"), - DOCUMENTATION_DOWNLOADER_PARSERS_FORMULAE__CONTEXT_VARIABLE_FORMULA: (os.path.join( HELP_DIR, 'downloader_parsers_formulae.html#context_variable_formula'), f"{REMOTE_DOCS}/downloader_parsers_formulae.html#context_variable_formula"), - DOCUMENTATION_DOWNLOADER_PARSERS_FORMULAE__HTML_FORMULA : (os.path.join( HELP_DIR, 'downloader_parsers_formulae.html#html_formula'), f"{REMOTE_DOCS}/downloader_parsers_formulae.html#html_formula"), - DOCUMENTATION_DOWNLOADER_PARSERS_FORMULAE__JSON_FORMULA : (os.path.join( HELP_DIR, 'downloader_parsers_formulae.html#json_formula'), f"{REMOTE_DOCS}/downloader_parsers_formulae.html#json_formula"), -} +DOCUMENTATION_CHANGELOG = f"changelog.html#version_{SOFTWARE_VERSION}" +DOCUMENTATION_DOWNLOADER_GUGS = "downloader_gugs.html" +DOCUMENTATION_DOWNLOADER_LOGIN = 'downloader_login.html' +DOCUMENTATION_ADDING_NEW_DOWNLOADERS = 'adding_new_downloaders.html' +DOCUMENTATION_DOWNLOADER_URL_CLASSES = 'downloader_url_classes.html' +DOCUMENTATION_GETTING_STARTED_SUBSCRIPTIONS = 'getting_started_subscriptions.html' +DOCUMENTATION_DATABASE_MIGRATION = 'database_migration.html' +DOCUMENTATION_DUPLICATES = 'duplicates.html' +DOCUMENTATION_DOWNLOADER_SHARING = 'downloader_sharing.html' +DOCUMENTATION_DOWNLOADER_PARSERS_PAGE_PARSERS__PAGE_PARSERS = 'downloader_parsers_page_parsers.html#page_parsers' +DOCUMENTATION_DOWNLOADER_PARSERS_CONTENT_PARSERS__CONTENT_PARSERS = 'downloader_parsers_content_parsers.html#content_parsers' +DOCUMENTATION_DOWNLOADER_PARSERS_FORMULAE__COMPOUND_FORMULA = 'downloader_parsers_formulae.html#compound_formula' +DOCUMENTATION_DOWNLOADER_PARSERS_FORMULAE__CONTEXT_VARIABLE_FORMULA = 'downloader_parsers_formulae.html#context_variable_formula' +DOCUMENTATION_DOWNLOADER_PARSERS_FORMULAE__HTML_FORMULA = 'downloader_parsers_formulae.html#html_formula' +DOCUMENTATION_DOWNLOADER_PARSERS_FORMULAE__JSON_FORMULA = 'downloader_parsers_formulae.html#json_formula' From 1d1fb3c12535ec727e32ff2792ddce2c41bd447a Mon Sep 17 00:00:00 2001 From: Minnowo <62451415+Minnowo@users.noreply.github.com> Date: Mon, 24 Jul 2023 01:58:07 -0400 Subject: [PATCH 3/3] added confirmation dialog before opening online help --- hydrus/client/ClientPaths.py | 8 +++++ hydrus/client/gui/ClientGUI.py | 38 ++-------------------- hydrus/client/gui/ClientGUIDialogsQuick.py | 29 ++++++++++++++++- hydrus/core/HydrusConstants.py | 3 +- 4 files changed, 40 insertions(+), 38 deletions(-) diff --git a/hydrus/client/ClientPaths.py b/hydrus/client/ClientPaths.py index ec00d0dd..ce8c5184 100644 --- a/hydrus/client/ClientPaths.py +++ b/hydrus/client/ClientPaths.py @@ -5,6 +5,8 @@ from hydrus.core import HydrusConstants as HC from hydrus.core import HydrusGlobals as HG from hydrus.core import HydrusPaths +from hydrus.client.gui import ClientGUIDialogsQuick + def DeletePath( path, always_delete_fully = False ): delete_to_recycle_bin = HC.options[ 'delete_to_recycle_bin' ] @@ -52,4 +54,10 @@ def OpenDocumentation( documentation_path : str ): else: + remote = ClientGUIDialogsQuick.ConfirmOpenOnlineHelpIfLocalDoesntExist( None, remote ) + + if remote is None: + + return + LaunchURLInWebBrowser( remote ) diff --git a/hydrus/client/gui/ClientGUI.py b/hydrus/client/gui/ClientGUI.py index 48400dcb..e8247a5e 100644 --- a/hydrus/client/gui/ClientGUI.py +++ b/hydrus/client/gui/ClientGUI.py @@ -4963,42 +4963,8 @@ class FrameGUI( CAC.ApplicationCommandProcessorMixin, ClientGUITopLevelWindows.M def _OpenHelp( self ): - - help_path = os.path.join( HC.HELP_DIR, 'index.html' ) - - if os.path.exists( help_path ): - - ClientPaths.LaunchPathInWebBrowser( help_path ) - - else: - - message = 'You do not have a local help! Are you running from source? Would you like to open the online help or see a guide on how to build your own?' - - yes_tuples = [] - - yes_tuples.append( ( 'open online help', 0 ) ) - yes_tuples.append( ( 'open how to build guide', 1 ) ) - - try: - - result = ClientGUIDialogsQuick.GetYesYesNo( self, message, yes_tuples = yes_tuples, no_label = 'forget it' ) - - except HydrusExceptions.CancelledException: - - return - - - if result == 0: - - url = 'https://hydrusnetwork.github.io/hydrus/' - - elif result == 1: - - url = 'https://hydrusnetwork.github.io/hydrus/about_docs.html' - - - ClientPaths.LaunchURLInWebBrowser( url ) - + + ClientPaths.OpenDocumentation( HC.DOCUMENTATION_INDEX ) def _OpenInstallFolder( self ): diff --git a/hydrus/client/gui/ClientGUIDialogsQuick.py b/hydrus/client/gui/ClientGUIDialogsQuick.py index 0678d55c..b3ea2f8d 100644 --- a/hydrus/client/gui/ClientGUIDialogsQuick.py +++ b/hydrus/client/gui/ClientGUIDialogsQuick.py @@ -255,4 +255,31 @@ def SelectServiceKey( service_types = None, service_keys = None, unallowed = Non return None - +def ConfirmOpenOnlineHelpIfLocalDoesntExist( dialog_owner, online_help_link : str ) -> str: + + message = 'You do not have a local help! Are you running from source? Would you like to open the online help or see a guide on how to build your own?' + + yes_tuples = [] + + yes_tuples.append( ( 'open online help', 0 ) ) + yes_tuples.append( ( 'open how to build guide', 1 ) ) + + try: + + result = GetYesYesNo( dialog_owner, message, yes_tuples = yes_tuples, no_label = 'forget it' ) + + except HydrusExceptions.CancelledException: + + return + + + if result == 0: + + url = online_help_link + + elif result == 1: + + url = "/".join( ( HC.REMOTE_HELP.rstrip("/"), HC.DOCUMENTATION_ABOUT_DOCS.lstrip("/") ) ) + + return url + diff --git a/hydrus/core/HydrusConstants.py b/hydrus/core/HydrusConstants.py index e81b57a6..569480ac 100644 --- a/hydrus/core/HydrusConstants.py +++ b/hydrus/core/HydrusConstants.py @@ -1098,6 +1098,7 @@ url_type_string_lookup = { REMOTE_HELP = "https://hydrusnetwork.github.io/hydrus" +DOCUMENTATION_INDEX = "index.html" DOCUMENTATION_CHANGELOG = f"changelog.html#version_{SOFTWARE_VERSION}" DOCUMENTATION_DOWNLOADER_GUGS = "downloader_gugs.html" DOCUMENTATION_DOWNLOADER_LOGIN = 'downloader_login.html' @@ -1113,7 +1114,7 @@ DOCUMENTATION_DOWNLOADER_PARSERS_FORMULAE__COMPOUND_FORMULA = 'downloader_parser DOCUMENTATION_DOWNLOADER_PARSERS_FORMULAE__CONTEXT_VARIABLE_FORMULA = 'downloader_parsers_formulae.html#context_variable_formula' DOCUMENTATION_DOWNLOADER_PARSERS_FORMULAE__HTML_FORMULA = 'downloader_parsers_formulae.html#html_formula' DOCUMENTATION_DOWNLOADER_PARSERS_FORMULAE__JSON_FORMULA = 'downloader_parsers_formulae.html#json_formula' - +DOCUMENTATION_ABOUT_DOCS = "about_docs.html" # default options