mirror of
				https://github.com/cookiengineer/audacity
				synced 2025-10-31 22:23:54 +01:00 
			
		
		
		
	Add a utility overload to open a page from the manual without worrying what it is called (hopefully) in the various copies of the manual
This commit is contained in:
		| @@ -23,6 +23,7 @@ | ||||
| #include <wx/settings.h> | ||||
| #include <wx/statusbr.h> | ||||
|  | ||||
| #include "../FileNames.h" | ||||
| #include "LinkingHtmlWindow.h" | ||||
| #include "../Theme.h" | ||||
| #include "../AllThemeResources.h" | ||||
| @@ -34,6 +35,11 @@ | ||||
| #include "ErrorDialog.h" | ||||
| #include "HelpSystem.h" | ||||
|  | ||||
| const wxString HelpSystem::HelpHostname = wxT("manual.audacityteam.org"); | ||||
| const wxString HelpSystem::HelpServerDir = wxT("/o/man/"); | ||||
| const wxString HelpSystem::HelpAlphaDir = wxT("/man/"); | ||||
| const wxString HelpSystem::ReleaseSuffix = wxT(".html"); | ||||
|  | ||||
| /// Mostly we use this so that we have the code for resizability | ||||
| /// in one place.  Other considerations like screen readers are also | ||||
| /// handled by having the code in one place. | ||||
| @@ -215,3 +221,34 @@ void HelpSystem::ShowHelpDialog(wxWindow *parent, | ||||
|       ShowHtmlText( parent, wxT(""), localFileName, true ); | ||||
|    } | ||||
| } | ||||
|  | ||||
| void HelpSystem::ShowHelpDialog(wxWindow *parent, const wxString &PageName) | ||||
| { | ||||
|    wxString releasePageName(PageName); | ||||
|    wxString localHelpPage; | ||||
|    wxString webHelpPage; | ||||
|    // This bit of code replicates the name transformations performed by the | ||||
|    // clean_filename routine in scripts/mw2html_audacity/mw2html.py: | ||||
|    releasePageName.Replace(wxT("%%"), wxT("_"), true); | ||||
|    releasePageName.Replace(wxT("%25"), wxT("_"), true); | ||||
|    releasePageName.Replace(wxT("%"), wxT("_"), true); | ||||
|    releasePageName.Replace(wxT("-"), wxT("_"), true); | ||||
|    releasePageName.Replace(wxT("__"), wxT("_"), true); | ||||
|    releasePageName.Replace(wxT("_."), wxT("."), true); | ||||
|    releasePageName = releasePageName.Lower()+HelpSystem::ReleaseSuffix; | ||||
|  | ||||
|    localHelpPage = wxFileName(FileNames::HtmlHelpDir()+wxT("/man/"), releasePageName).GetFullPath(); | ||||
| #if IS_ALPHA | ||||
|    webHelpPage = wxT("http://")+HelpSystem::HelpHostname+HelpSystem::HelpAlphaDir+PageName; | ||||
| #else | ||||
|    webHelpPage = wxT("http://")+HelpSystem::HelpHostname+HelpSystem::HelpServerDir+releasePageName; | ||||
| #endif | ||||
|    wxLogMessage(wxT("Help button pressed: PageName %s, releasePageName %s"), | ||||
|               PageName.c_str(), releasePageName.c_str()); | ||||
|    wxLogMessage(wxT("webHelpPage %s, localHelpPage %s"), | ||||
|               webHelpPage.c_str(), localHelpPage.c_str()); | ||||
|    HelpSystem::ShowHelpDialog( | ||||
|       parent,  | ||||
|       localHelpPage, | ||||
|       webHelpPage); | ||||
| } | ||||
|   | ||||
| @@ -46,6 +46,28 @@ public: | ||||
|    static void ShowHelpDialog(wxWindow *parent, | ||||
|                      const wxString &localFileName, | ||||
|                      const wxString &remoteURL); | ||||
|  | ||||
|    /// Displays a page from the Audacity manual  in your browser, if | ||||
|    /// it's available locally, OR else links to the internet. | ||||
|    /// @param PageName The name of the manual page to display as it is in | ||||
|    /// _development version_ of the manual (i.e. in MediaWiki), _not_ the | ||||
|    /// converted file name used for offline and released manuals | ||||
|    static void ShowHelpDialog(wxWindow *parent, | ||||
|                      const wxString &PageName); | ||||
|  | ||||
|    /// Hostname (domain name including subdomain) of the server on which the | ||||
|    /// online help is available | ||||
|    static const wxString HelpHostname; | ||||
|    /// URL path on the help server under which the help pages are located. Must | ||||
|    /// both start and end with '/' characters. | ||||
|    static const wxString HelpServerDir; | ||||
|    /// URL path on the help server under which the development help pages are | ||||
|    /// located. Must both start and end with '/' characters. | ||||
|    static const wxString HelpAlphaDir; | ||||
|    /// The string which is appended to the development manual page name in order | ||||
|    /// obtain the file name in the local and release web copies of the manual | ||||
|    static const wxString ReleaseSuffix; | ||||
|  | ||||
| }; | ||||
|  | ||||
| #endif // __AUDACITY_HELPSYSTEM__ | ||||
|   | ||||
		Reference in New Issue
	
	Block a user