From 799dec683b1c44cf1b1c2e57949bae81f58dfe82 Mon Sep 17 00:00:00 2001 From: eliranwong Date: Thu, 31 Oct 2024 12:48:41 +0000 Subject: [PATCH] added .resources command to web API --- setup.py | 2 +- uniquebible/README.md | 12 +++--------- uniquebible/latest_changes.txt | 8 ++++++++ uniquebible/util/CrossPlatform.py | 23 +++++++++++++++++++++++ uniquebible/util/RemoteHttpHandler.py | 13 ++++++++++--- 5 files changed, 45 insertions(+), 13 deletions(-) diff --git a/setup.py b/setup.py index 864445685..2d69e5d8f 100644 --- a/setup.py +++ b/setup.py @@ -47,7 +47,7 @@ # https://packaging.python.org/en/latest/guides/distributing-packages-using-setuptools/ setup( name=package, - version="0.1.41", + version="0.1.43", python_requires=">=3.8, <3.13", description=f"UniqueBible App is a cross-platform & offline bible application, integrated with high-quality resources and unique features. Developers: Eliran Wong and Oliver Tseng", long_description=long_description, diff --git a/uniquebible/README.md b/uniquebible/README.md index e2d8cf36c..8a8663c51 100644 --- a/uniquebible/README.md +++ b/uniquebible/README.md @@ -1,14 +1,8 @@ -# Migration to pip package in progress +# Migration to PIP Package -We are migrating the distribution of UniqueBible App via pip package. Something may not work as usual. Please kindly report issues at https://github.com/eliranwong/UniqueBible/issues +We've recently published pip packages for distributing UniqueBible App. -To install: - -> pip install --upgrade uniquebible - -To run: - -> uniquebible +Read latest instructions for installation at: https://github.com/eliranwong/UniqueBible/wiki/installation#latest-updates # UniqueBible diff --git a/uniquebible/latest_changes.txt b/uniquebible/latest_changes.txt index f44c2f476..e20e66650 100755 --- a/uniquebible/latest_changes.txt +++ b/uniquebible/latest_changes.txt @@ -1,11 +1,19 @@ PIP package: +0.1.42 + +* added command `.resources` to web API to retrieve available resources + +* Read web api documentation at https://github.com/eliranwong/UniqueBibleAPI + 0.1.38-0.1.41 * improved raw output with API endpoints * output command suggestions +* added command `.suggestions` to web API to retrieve command suggestions + 0.1.37 * support user plugins, stored in ~/UniqueBible/plugins diff --git a/uniquebible/util/CrossPlatform.py b/uniquebible/util/CrossPlatform.py index fb647034c..4b7aa2a2a 100755 --- a/uniquebible/util/CrossPlatform.py +++ b/uniquebible/util/CrossPlatform.py @@ -115,6 +115,29 @@ def setupResourceLists(self): "WLC (Hebrew; slow; verse-by-verse)": ("WLC", "eliranwong/MP3_WLC_slow", "default"), } + self.resources = {} + self.resources["bibleListAbb"] = self.textList + self.resources["strongBibleListAbb"] = self.strongBibles + self.resources["bibleList"] = self.textFullNameList + self.resources["commentaryListAbb"] = self.commentaryList + self.resources["commentaryList"] = self.commentaryFullNameList + self.resources["referenceBookList"] = self.referenceBookList + self.resources["topicListAbb"] = self.topicListAbb + self.resources["topicList"] = self.topicList + self.resources["lexiconList"] = self.lexiconList + self.resources["dictionaryListAbb"] = self.dictionaryListAbb + self.resources["dictionaryList"] = self.dictionaryList + self.resources["encyclopediaListAbb"] = self.encyclopediaListAbb + self.resources["encyclopediaList"] = self.encyclopediaList + self.resources["thirdPartyDictionaryList"] = self.thirdPartyDictionaryList + self.resources["pdfList"] = self.pdfList + self.resources["epubList"] = self.epubList + self.resources["docxList"] = self.docxList + self.resources["bibleAudioModules"] = self.bibleAudioModules + self.resources["dataList"] = self.dataList + self.resources["searchToolList"] = self.searchToolList + #self.resources["verseByVerseAudio"] = self.verseByVerseAudio + # Check if a third party dictionary exists: def isThridPartyDictionary(self, module): bibleBentoPlusLexicon = os.path.join("thirdParty", "dictionaries", "{0}{1}".format(module, ".dic.bbp")) diff --git a/uniquebible/util/RemoteHttpHandler.py b/uniquebible/util/RemoteHttpHandler.py index 49a9620c3..292b528f9 100644 --- a/uniquebible/util/RemoteHttpHandler.py +++ b/uniquebible/util/RemoteHttpHandler.py @@ -360,7 +360,12 @@ def do_GET(self): content = LocalCliHandler(allowPrivateData=allowPrivateData).getCommandCompleterSuggestions(textCommandSuggestion=textCommandSuggestion) config.terminalUseLighterCompleter = terminalUseLighterCompleter self.wfile.write(bytes(json.dumps(content), "utf8")) - return + return None + elif self.command == ".resources": + self.commonHeader() + content = self.textCommandParser.parent.resources + self.wfile.write(bytes(json.dumps(content), "utf8")) + return None else: self.command = "John 3:16-16" # tweak configs @@ -377,12 +382,14 @@ def do_GET(self): content = TextUtil.htmlToPlainText(content).strip() if api == "json": output = {} + if not ":::" in self.command: + self.command = f"bible:::{self.command}" for index, item in enumerate(self.command.split(":::")): if index == 0: output["keyword"] = item.strip() else: output[f"parameter_{index}"] = item.strip() - output["content"] = content + output["content"] = content.strip() content = json.dumps(output) self.wfile.write(bytes(content, "utf8")) # restore user config @@ -391,7 +398,7 @@ def do_GET(self): elif self.ignoreCommand(self.path): print(f"Ignoring command: {self.path}") self.blankPage() - return + return None elif self.path == "" or self.path == "/" or self.path.startswith("/index.html") or config.displayLanguage != "en_GB": if self.primaryUser or not config.webPresentationMode: if 'cmd' in query_components: