Skip to content

Commit

Permalink
Merge pull request #1442 from otseng/main
Browse files Browse the repository at this point in the history
Add webSiteTitle and scripts
  • Loading branch information
eliranwong authored Aug 30, 2024
2 parents 20baf07 + e50178d commit 89e2751
Show file tree
Hide file tree
Showing 14 changed files with 56 additions and 29 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -119,3 +119,4 @@ log.txt
google-cloud-key.json
audio/*.onnx
audio/*.json
*.out
2 changes: 1 addition & 1 deletion UniqueBibleAppVersion.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
35.30
35.31
3 changes: 3 additions & 0 deletions api-server.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
nohup python uba.py api-server 7777 > nohup-api-server.out 2>&1 &
echo "Started API Server"
# tail -f nohup-api-server.out
4 changes: 2 additions & 2 deletions docker_requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -77,5 +77,5 @@ webencodings==0.5.1
websocket-client==1.1.0
websockets==10.1
wrapt==1.13.3
yt-dlp==2024.4.9
zipp==3.7.0
yt-dlp==2024.7.7
zipp==3.19.1
2 changes: 2 additions & 0 deletions http-server.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
nohup python uba.py http-server 8088 > nohup-http-server.out 2>&1 &

2 changes: 2 additions & 0 deletions kill-api-server.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ps -ef | grep api-server | grep -v grep | awk '{print $2}' | xargs kill
ps -ef | grep api-server
2 changes: 2 additions & 0 deletions kill-http-server.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ps -ef | grep http-server | grep -v grep | awk '{print $2}' | xargs kill
ps -ef | grep http-server
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
20 changes: 12 additions & 8 deletions patches.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1337,7 +1337,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 +1383,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
2 changes: 2 additions & 0 deletions util/RemoteApiHandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ def processRequest(self, request):
lang = query["lang"][0]
if os.path.exists('marvelData_' + lang):
config.marvelData = 'marvelData_' + lang
if request.startswith("/api"):
request = request[4:]
cmd = request[1:].split("/")
if len(cmd) > 0:
command = cmd[0].lower()
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 89e2751

Please sign in to comment.