Skip to content

Commit

Permalink
Update (#298)
Browse files Browse the repository at this point in the history
* Add webSiteTitle

* Update TextCommandParser.py
  • Loading branch information
otseng authored Aug 30, 2024
1 parent fcc1281 commit 74bdef1
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 28 deletions.
2 changes: 1 addition & 1 deletion UniqueBibleAppVersion.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
35.30
35.31
4 changes: 4 additions & 0 deletions latest_changes.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
Changes in 35.31:
* Add webSiteTitle to config
* Add scripts to start/stop http and api server

Changes in 35.30:
* Support Piper TTS on Linux

Expand Down
21 changes: 12 additions & 9 deletions patches.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1213,7 +1213,6 @@
(33.07, "file", "util/uba_command_prompt_key_bindings.py")
(33.16, "file", "plugins/startup/customise_terminal_mode_commands.py")
(33.20, "file", "util/PromptValidator.py")
(33.25, "file", "util/LexicalData.py")
(33.48, "file", "gui/CentralWidget.py")
(33.50, "file", "gui/MiniControl.py")
(33.50, "file", "gui/NoteEditor.py")
Expand Down Expand Up @@ -1337,7 +1336,6 @@
(34.81, "file", "gui/SearchLauncher.py")
(34.85, "file", "db/AGBTSData.py")
(34.87, "file", "util/AGBsubheadings.py")
(34.88, "file", "util/RemoteHttpHandler.py")
(34.89, "file", "util/AGBparagraphs_expanded.py")
(34.89, "file", "marvelData/AGBTS_data.sqlite")
(34.98, "file", "plugins/chatGPT/integrate google searches.py")
Expand Down Expand Up @@ -1384,16 +1382,21 @@
(35.26, "file", "util/terminal_mode_dialogs.py")
(35.26, "file", "util/terminal_system_command_prompt.py")
(35.27, "file", "db/BiblesSqlite.py")
(35.28, "file", ".gitignore")
(35.28, "file", "gui/MainWindow.py")
(35.28, "file", "util/DatafileLocation.py")
(35.29, "file", "util/RemoteApiHandler.py")
(35.30, "file", "gui/ConfigFlagsWindow.py")
(35.30, "file", "util/checkup.py")
(35.30, "file", "util/ConfigUtil.py")
(35.30, "file", "util/text_editor_checkup.py")
(35.30, "file", "util/TextCommandParser.py")
(35.30, "file", "util/TextEditorUtility.py")
(35.30, "file", "latest_changes.txt")
(35.30, "file", "UniqueBibleAppVersion.txt")
(35.30, "file", "patches.txt")
(35.31, "file", "api-server.sh")
(35.31, "file", "http-server.sh")
(35.31, "file", "kill-api-server.sh")
(35.31, "file", "kill-http-server.sh")
(35.31, "file", "util/ConfigUtil.py")
(35.31, "file", "util/RemoteApiHandler.py")
(35.31, "file", "util/RemoteHttpHandler.py")
(35.31, "file", "util/TextCommandParser.py")
(35.31, "file", ".gitignore")
(35.31, "file", "UniqueBibleAppVersion.txt")
(35.31, "file", "latest_changes.txt")
(35.31, "file", "patches.txt")
3 changes: 3 additions & 0 deletions util/ConfigUtil.py
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,9 @@ def getCurrentVenvDir():
setConfig("webAdminPassword", """
# Web admin password.""",
"UBA123")
setConfig("webSiteTitle", """
# Site title for remote http server.""",
"UniqueBible.app")
setConfig("referenceTranslation", """
# Specify a translation as a reference for making other translations. This option is created for development purpose.""",
"en_US")
Expand Down
26 changes: 14 additions & 12 deletions util/RemoteHttpHandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ def addIpToBlackList(self, clientIP):
file.close()

def loadLastVerseHtml(self):
return """<!DOCTYPE html><html><head><link rel="icon" href="icons/{0}"><title>UniqueBible.app</title>
return """<!DOCTYPE html><html><head><link rel="icon" href="icons/{0}"><title>{4}</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
Expand All @@ -405,7 +405,7 @@ def loadLastVerseHtml(self):
<script>
location.assign("{2}?cmd=.bible");
</script>
</body>""".format(config.webUBAIcon, config.thisTranslation["loading"], config.webHomePage, config.theme)
</body>""".format(config.webUBAIcon, config.thisTranslation["loading"], config.webHomePage, config.theme, config.webSiteTitle)

def loadLastVerse(self):
self.commonHeader()
Expand Down Expand Up @@ -566,7 +566,7 @@ def loadContent(self):
self.textCommandParser.parent.addHistoryRecord(view, self.command)

if ('tab_title' in infoDict.keys() and infoDict['tab_title'] == "Map"):
content = content.replace("<title>Google Maps - gmplot</title>", """<title>UniqueBible.app</title>
content = content.replace("<title>Google Maps - gmplot</title>", """<title>{2}</title>
<script src='js/http_server.js?v=1.065'></script>
<script>
var target = document.querySelector('title');
Expand All @@ -579,7 +579,7 @@ def loadContent(self):
childList: true,
{1};
observer.observe(target, config);
</script>""".format("{", "}"))
</script>""".format("{", "}", config.webSiteTitle))
#print(content)
else:
content = self.wrapHtml(content)
Expand Down Expand Up @@ -616,7 +616,7 @@ def indexPage(self):
<html>
<head>
<link rel="icon" href="icons/{20}">
<title>UniqueBible.app</title>
<title>{21}</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
Expand Down Expand Up @@ -803,14 +803,14 @@ def indexPage(self):
<div class="modal2-content">
<div class="modal2-header">
<span class="close2">&times;</span>
<span id="myMessageHeader"><h2>UniqueBible.app</h2></span>
<span id="myMessageHeader"><h2>{21}</h2></span>
</div>
<div class="modal2-body">
<span id="myMessage"><p>UniqueBible.app</p></span>
<span id="myMessage"><p>{21}</p></span>
</div>
<!--
<div class="modal2-footer">
<span id="myMessageFooter"><h3>UniqueBible.app</h3></span>
<span id="myMessageFooter"><h3>{21}</h3></span>
</div>
-->
</div>
Expand Down Expand Up @@ -901,6 +901,7 @@ def indexPage(self):
self.getBibleNavigationMenu(),
config.webHomePage,
config.webUBAIcon,
config.webSiteTitle
)
self.wfile.write(bytes(html, "utf8"))

Expand Down Expand Up @@ -1099,7 +1100,7 @@ def wrapHtml(self, content, view="", book=False):
fontSize = "{0}px".format(config.overwriteBookFontSize)
bcv = (config.studyText, config.studyB, config.studyC, config.studyV) if view == "study" else (config.mainText, config.mainB, config.mainC, config.mainV)
activeBCVsettings = "<script>var activeText = '{0}'; var activeB = {1}; var activeC = {2}; var activeV = {3};</script>".format(*bcv)
html = ("""<!DOCTYPE html><html><head><link rel="icon" href="icons/{9}"><title>UniqueBible.app</title>
html = ("""<!DOCTYPE html><html><head><link rel="icon" href="icons/{9}"><title>{12}</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
Expand Down Expand Up @@ -1145,6 +1146,7 @@ def wrapHtml(self, content, view="", book=False):
config.webUBAIcon,
config.widgetBackgroundColor,
config.widgetForegroundColor,
config.webSiteTitle
)
return html

Expand Down Expand Up @@ -1376,10 +1378,10 @@ def displayMessage(self, message):
<html>
<head>
<link rel="icon" href="icons/{1}">
<title>UniqueBible.app</title>
<title>{2}</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head><body>{0}</body></html>""".format(message, config.webUBAIcon)
</head><body>{0}</body></html>""".format(message, config.webUBAIcon, config.webSiteTitle)

def historyContent(self):
view, content, *_ = self.textCommandParser.parser("_history:::main", "http")
Expand Down Expand Up @@ -1739,7 +1741,7 @@ def setVerseNoClickActionContent(self, double=False):
def setWebUBAIconContent(self):
files = glob.glob(os.path.join("htmlResources", "icons", "UniqueBibleApp*.png"))
files = [file[20:] for file in files]
content = "<h2>Select UniqueBible.app Icon:</h2>"
content = "<h2>Select {0} Icon:</h2>".format(config.webSiteTitle)
content += " ".join(["""<ref onclick ="document.title = '_setconfig:::webUBAIcon:::\\'{0}\\''"><img src="icons/{0}"></ref>""".format(file) for file in files])
return content

Expand Down
3 changes: 2 additions & 1 deletion util/TextCommandParser.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# coding=utf-8
import glob, pprint, traceback, pydoc, threading, asyncio, shutil
import os, re, webbrowser, platform, zipfile, subprocess, config
import os, re, webbrowser, platform, zipfile, subprocess, config, logging
from prompt_toolkit.input import create_input
from prompt_toolkit.keys import Keys
from datetime import date
Expand Down Expand Up @@ -63,6 +63,7 @@ class TextCommandParser:

def __init__(self, parent):
self.parent = parent
self.logger = logging.getLogger('uba')
self.lastKeyword = None
self.cliTtsProcess = None
self.qtTtsEngine = None
Expand Down
11 changes: 6 additions & 5 deletions util/UpdateUtil.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,12 @@ def updatePatchFileWithChanges(ver, sha1, sha2):
f = open("patches.txt", "r")
lines = f.readlines()
for line in lines:
try:
ver, contentType, filePath = literal_eval(line)
except Exception as e:
print(f"{e} in '{line}'")
patches[filePath] = "{0}".format(ver)
if len(line) > 1:
try:
ver, contentType, filePath = literal_eval(line)
except Exception as e:
print(f"{e} in '{line}'")
patches[filePath] = "{0}".format(ver)
f.close()
lines = UpdateUtil.getFilesChanged(sha1, sha2)
patch = open("patches.txt", "a")
Expand Down

0 comments on commit 74bdef1

Please sign in to comment.