summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLouie Shprung <lshprung@scu.edu>2023-04-01 17:14:09 -0700
committerLouie Shprung <lshprung@scu.edu>2023-04-01 17:14:09 -0700
commit18774e2e797f64cf951b3ba1ea8051ea6ad525f4 (patch)
treed600833a04fb7209ac48f3078fbfab4afa0bf7cc
First commit
-rw-r--r--backend/__pycache__/config.cpython-39.pycbin0 -> 413 bytes
-rw-r--r--backend/config.py5
-rw-r--r--backend/endpoints/get_plist.py40
-rw-r--r--backend/server.py26
-rw-r--r--frontend/index.html33
-rw-r--r--frontend/script.js14
-rw-r--r--frontend/style.css32
-rw-r--r--frontend/test.html10
8 files changed, 160 insertions, 0 deletions
diff --git a/backend/__pycache__/config.cpython-39.pyc b/backend/__pycache__/config.cpython-39.pyc
new file mode 100644
index 0000000..92c0291
--- /dev/null
+++ b/backend/__pycache__/config.cpython-39.pyc
Binary files differ
diff --git a/backend/config.py b/backend/config.py
new file mode 100644
index 0000000..6ad1178
--- /dev/null
+++ b/backend/config.py
@@ -0,0 +1,5 @@
+class Config:
+ hostName = "localhost"
+ serverPort = 8080
+
+ docset_base = "/home/louie/.local/share/Zeal/Zeal/docsets"
diff --git a/backend/endpoints/get_plist.py b/backend/endpoints/get_plist.py
new file mode 100644
index 0000000..76275b7
--- /dev/null
+++ b/backend/endpoints/get_plist.py
@@ -0,0 +1,40 @@
+import json
+import logging
+import os
+import plistlib
+
+from ..config import Config
+
+output = dict()
+output["paths"] = []
+
+def find_plist(path):
+ with os.scandir(path) as it:
+ for entry in it:
+ if entry.name == "." or entry.name == "..":
+ continue
+ if(os.DirEntry.is_dir(entry)):
+ find_plist(path + "/" + entry.name)
+ elif(entry.name == "Info.plist"):
+ #parse_plist(path + "/" + entry.name)
+ output["paths"] += path + "/" + entry.name
+
+def parse_plist(path):
+ with open(path, "rb") as fp:
+ pl = plistlib.load(fp)
+ print(pl["CFBundleIdentifier"])
+ print(pl["CFBundleName"])
+
+
+
+if not os.path.isdir(Config.docset_base):
+ e = "Invalid DOCSET_BASE \"" + Config.docset_base + "\""
+ logging.error(e);
+ output["success"] = False
+ output["message"] = e
+
+else:
+ find_plist(Config.docset_base);
+ output["success"] = True
+
+print(json.dumps(output))
diff --git a/backend/server.py b/backend/server.py
new file mode 100644
index 0000000..b8e1091
--- /dev/null
+++ b/backend/server.py
@@ -0,0 +1,26 @@
+import http.server
+
+from config import *
+
+class MyServer(http.server.BaseHTTPRequestHandler):
+ def do_GET(self):
+ self.send_response(200)
+ self.send_header("Content-type", "application/json")
+ self.send_header("Access-Control-Allow-Origin", "*")
+ self.send_header("Access-Control-Allow-Headers", "content-type")
+ self.end_headers()
+ output = exec(open("." + self.path).read())
+ self.wfile.write(output.encode())
+
+
+if __name__ == "__main__":
+ webServer = http.server.HTTPServer((Config.hostName, Config.serverPort), MyServer)
+ print("Server started http://%s:%s" % (Config.hostName, Config.serverPort))
+
+ try:
+ webServer.serve_forever()
+ except KeyboardInterrupt:
+ pass
+
+ webServer.server_close()
+ print("Server stopped.")
diff --git a/frontend/index.html b/frontend/index.html
new file mode 100644
index 0000000..4036645
--- /dev/null
+++ b/frontend/index.html
@@ -0,0 +1,33 @@
+<!DOCTYPE html>
+<html lang="en">
+ <head>
+ <title>Dash Docset Viewer</title>
+ <link href="./style.css" rel="stylesheet"/>
+ </head>
+
+ <body>
+ <div id="header">
+ <h1>Dash Docset Viewer</h1>
+ </div>
+ <span id="main-body">
+ <table id="searchbar">
+ <tr>
+ <td scope="col">
+ <input type="search"></input>
+ </td>
+ </tr>
+ <tr>
+ <td scope="row">
+ <button id="docset-example-parent" class="docset-parent">
+ example.com
+ </button>
+ </td>
+ </tr>
+ </table>
+ <embed id="docset-page" type="text/html" src="./test.html">
+ </span>
+
+ <script src="./script.js">
+ </script>
+ </body>
+</html>
diff --git a/frontend/script.js b/frontend/script.js
new file mode 100644
index 0000000..05468dc
--- /dev/null
+++ b/frontend/script.js
@@ -0,0 +1,14 @@
+const endpoint = "http://127.0.0.1:8080/endpoints"
+
+console.log("hello");
+
+document.getElementById("docset-example-parent").onclick = function(){
+ document.getElementById("docset-page").src = "https://example.com";
+}
+
+let xhttp = new XMLHttpRequest();
+xhttp.open("GET", endpoint + "/get_plist.py");
+xhttp.onload = function(){
+ console.log(this.response);
+}
+xhttp.send();
diff --git a/frontend/style.css b/frontend/style.css
new file mode 100644
index 0000000..117e5f6
--- /dev/null
+++ b/frontend/style.css
@@ -0,0 +1,32 @@
+body {
+ margin: 0;
+}
+
+input {
+ width: 100%;
+}
+
+.docset-parent {
+ width: 100%;
+}
+
+#docset-page {
+ border: solid;
+ flex-grow: 4;
+ max-height: 100vh;
+}
+
+#header {
+ display: none;
+ text-align: center;
+}
+
+#main-body {
+ display: flex;
+ height: 100vh;
+}
+
+#searchbar {
+ border: solid;
+ display: inline-block;
+}
diff --git a/frontend/test.html b/frontend/test.html
new file mode 100644
index 0000000..3cf6612
--- /dev/null
+++ b/frontend/test.html
@@ -0,0 +1,10 @@
+<!DOCTYPE html>
+<html lang="en">
+ <head>
+ <title>Test</title>
+ </head>
+
+ <body>
+ <h1>Test</h1>
+ </body>
+</html>