diff options
-rw-r--r-- | backend/endpoints/__pycache__/get_plist.cpython-39.pyc | bin | 1816 -> 2540 bytes | |||
-rw-r--r-- | backend/endpoints/get_plist.py | 30 | ||||
-rw-r--r-- | frontend/script.js | 3 | ||||
-rw-r--r-- | frontend/style.css | 1 |
4 files changed, 33 insertions, 1 deletions
diff --git a/backend/endpoints/__pycache__/get_plist.cpython-39.pyc b/backend/endpoints/__pycache__/get_plist.cpython-39.pyc Binary files differindex 1363a33..f74f5a0 100644 --- a/backend/endpoints/__pycache__/get_plist.cpython-39.pyc +++ b/backend/endpoints/__pycache__/get_plist.cpython-39.pyc diff --git a/backend/endpoints/get_plist.py b/backend/endpoints/get_plist.py index 07d7b3a..ac7366e 100644 --- a/backend/endpoints/get_plist.py +++ b/backend/endpoints/get_plist.py @@ -10,6 +10,21 @@ from config import Config class Get_Plist: output = dict() + + def find_index(path): + if os.path.isfile(os.path.join(path, "index.html")): + return os.path.join(path, "index.html") + + with os.scandir(path) as it: + for entry in it: + if entry.name == "." or entry.name == "..": + continue + if(os.DirEntry.is_dir(entry)): + return Get_Plist.find_index(os.path.join(path, entry.name)) + + return False + + def find_plist(path): with os.scandir(path) as it: for entry in it: @@ -18,6 +33,15 @@ class Get_Plist: if(os.path.isfile(plist_path)): if(Get_Plist.parse_plist(plist_path)): Get_Plist.output["docsets"][-1]["docset_root"] = docset_root + Get_Plist.output["docsets"][-1]["docset_index"] = os.path.join(docset_root, Get_Plist.output["docsets"][-1]["docset_index"]) + if not os.path.isfile(Get_Plist.output["docsets"][-1]["docset_index"]): + index_loc = Get_Plist.find_index(Get_Plist.output["docsets"][-1]["docset_index"]) + if not index_loc: + del Get_Plist.output["docsets"][-1]["docset_index"] + else: + Get_Plist.output["docsets"][-1]["docset_index"] = index_loc + + for f in ["icon.png", "icon@2x.png"]: if os.path.isfile(os.path.join(docset_root, f)): Get_Plist.output["docsets"][-1][f] = os.path.join(docset_root, f) @@ -37,9 +61,15 @@ class Get_Plist: return False Get_Plist.output["docsets"].append({}) + for f in fields: Get_Plist.output["docsets"][-1][f] = pl[f] + # Find the index page + Get_Plist.output["docsets"][-1]["docset_index"] = os.path.join("Contents", "Resources", "Documents") + if "dashIndexFilePath" in pl: + Get_Plist.output["docsets"][-1]["docset_index"] = os.path.join(Get_Plist.output["docsets"][-1]["docset_index"], pl["dashIndexFilePath"]) + return True diff --git a/frontend/script.js b/frontend/script.js index 6f4775e..20f5b08 100644 --- a/frontend/script.js +++ b/frontend/script.js @@ -9,7 +9,8 @@ function populateSearchBar(docset_json) { // Add to docset-table document.getElementById("docset-table").getElementsByTagName("tbody")[0].innerHTML += "<tr>" + "<td scope=\"row\">" + - "<button id=\"docset-" + docset_json["CFBundleIdentifier"] + "-parent\" class=\"docset-parent\" onclick=\"set_embed_page('" + docset_json["docset_root"] + "')\">" + + "<button id=\"docset-" + docset_json["CFBundleIdentifier"] + "-parent\" class=\"docset-parent\" onclick=\"set_embed_page('" + docset_json["docset_index"] + "')\">" + + "<img class=\"docset-icon\" src=\"" + docset_json["icon.png"] + "\"/>" + docset_json["CFBundleName"] + "</button>" + "</td>" + diff --git a/frontend/style.css b/frontend/style.css index d3fa92c..dbaf66b 100644 --- a/frontend/style.css +++ b/frontend/style.css @@ -7,6 +7,7 @@ input { } .docset-parent { + text-align: left; width: 100%; } |