diff --git a/plugins/help/doc.cs b/plugins/help/doc.cs index f163cb7..2d539e2 100644 --- a/plugins/help/doc.cs +++ b/plugins/help/doc.cs @@ -4,6 +4,6 @@
- +
diff --git a/plugins/help/help.py b/plugins/help/help.py index e0e8b74..05b6337 100644 --- a/plugins/help/help.py +++ b/plugins/help/help.py @@ -7,16 +7,35 @@ class help(cryptobox.plugins.base.CryptoBoxPlugin): requestAuth = False rank = 80 + default_lang = 'en' + default_page = "CryptoBoxUser" + def doAction(self, page=""): '''prints the offline wikipage ''' - import re - ## check for invalid characters - if page and not re.search(u'\W', page): - self.hdf[self.hdf_prefix + "Page"] = page + import re,os + ## check for invalid characters and if the page exists in the default language + if page and \ + not re.search(u'\W', page) and \ + os.path.isfile(os.path.join(self.cbox.prefs["Locations"]["DocDir"], self.efault_lang, page + '.html')): + ## everything is ok + pass else: ## display this page as default help page - self.hdf[self.hdf_prefix + "Page"] ="CryptoBoxUser" + page = self.default_page + if page: + ## issue warning + self.cbox.log.info("could not find the selected documentation page: %s" % str(page)) + ## store the name of the page + self.hdf[self.hdf_prefix + "Page"] = page + ## choose the right language + for l in self.site.langOrder: + if os.path.isfile(os.path.join(self.cbox.prefs["Locations"]["DocDir"], l, page + '.html')): + lang = l + break + else: + lang = self.default_lang + self.hdf[self.hdf_prefix + "Language"] = lang return "doc"