Skip to content

Commit

Permalink
added .resources command to web API
Browse files Browse the repository at this point in the history
  • Loading branch information
eliranwong committed Oct 31, 2024
1 parent 3f4cbd3 commit 799dec6
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 13 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
12 changes: 3 additions & 9 deletions uniquebible/README.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down
8 changes: 8 additions & 0 deletions uniquebible/latest_changes.txt
Original file line number Diff line number Diff line change
@@ -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
Expand Down
23 changes: 23 additions & 0 deletions uniquebible/util/CrossPlatform.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
Expand Down
13 changes: 10 additions & 3 deletions uniquebible/util/RemoteHttpHandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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:
Expand Down

0 comments on commit 799dec6

Please sign in to comment.