From 28b113fc942904ea7c125dfef94e9c3dee24973d Mon Sep 17 00:00:00 2001 From: Alexander_Kabui Date: Thu, 12 Sep 2024 21:12:08 +0300 Subject: Integrate gn editor for files. --- gn2/wqflask/templates/facilities.html | 4 ++-- gn2/wqflask/templates/glossary.html | 2 +- gn2/wqflask/templates/links.html | 4 ++-- gn2/wqflask/templates/news.html | 2 +- gn2/wqflask/templates/policies.html | 4 ++-- gn2/wqflask/templates/references.html | 4 ++-- gn2/wqflask/templates/search-syntax.html | 4 ++-- 7 files changed, 12 insertions(+), 12 deletions(-) diff --git a/gn2/wqflask/templates/facilities.html b/gn2/wqflask/templates/facilities.html index 56b127f9..ee4c84db 100644 --- a/gn2/wqflask/templates/facilities.html +++ b/gn2/wqflask/templates/facilities.html @@ -10,7 +10,7 @@
- + Edit Text @@ -21,4 +21,4 @@
-{% endblock %} \ No newline at end of file +{% endblock %} diff --git a/gn2/wqflask/templates/glossary.html b/gn2/wqflask/templates/glossary.html index aaee7c5a..4922d39e 100644 --- a/gn2/wqflask/templates/glossary.html +++ b/gn2/wqflask/templates/glossary.html @@ -10,7 +10,7 @@
- + Edit Text diff --git a/gn2/wqflask/templates/links.html b/gn2/wqflask/templates/links.html index 6e91adae..c5b040e1 100644 --- a/gn2/wqflask/templates/links.html +++ b/gn2/wqflask/templates/links.html @@ -10,7 +10,7 @@
- + Edit Text @@ -21,4 +21,4 @@ {{ rendered_markdown|safe }}
-{% endblock %} \ No newline at end of file +{% endblock %} diff --git a/gn2/wqflask/templates/news.html b/gn2/wqflask/templates/news.html index a615564b..df8e02ef 100644 --- a/gn2/wqflask/templates/news.html +++ b/gn2/wqflask/templates/news.html @@ -10,7 +10,7 @@
- + Edit Text diff --git a/gn2/wqflask/templates/policies.html b/gn2/wqflask/templates/policies.html index e36c9e08..d7b0e3f9 100644 --- a/gn2/wqflask/templates/policies.html +++ b/gn2/wqflask/templates/policies.html @@ -10,7 +10,7 @@
- + Edit Text @@ -20,4 +20,4 @@ {{ rendered_markdown|safe }}
-{% endblock %} \ No newline at end of file +{% endblock %} diff --git a/gn2/wqflask/templates/references.html b/gn2/wqflask/templates/references.html index 04e60361..d858e10f 100644 --- a/gn2/wqflask/templates/references.html +++ b/gn2/wqflask/templates/references.html @@ -6,7 +6,7 @@ {% block content %}
- + Edit Text @@ -16,4 +16,4 @@ {{ rendered_markdown|safe }}
-{% endblock %} \ No newline at end of file +{% endblock %} diff --git a/gn2/wqflask/templates/search-syntax.html b/gn2/wqflask/templates/search-syntax.html index 52538826..e4ab7907 100644 --- a/gn2/wqflask/templates/search-syntax.html +++ b/gn2/wqflask/templates/search-syntax.html @@ -10,7 +10,7 @@
- + Edit Text @@ -21,4 +21,4 @@
-{% endblock %} \ No newline at end of file +{% endblock %} -- cgit v1.2.3 From 7aa23af86c0fbd0edc48fad0c7e9e8d0022a1ea6 Mon Sep 17 00:00:00 2001 From: Alexander_Kabui Date: Thu, 12 Sep 2024 21:48:11 +0300 Subject: Fetch markdown for rendering form gn-docs. --- gn2/wqflask/api/markdown.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/gn2/wqflask/api/markdown.py b/gn2/wqflask/api/markdown.py index aa7dd3c4..0c8ba8f2 100644 --- a/gn2/wqflask/api/markdown.py +++ b/gn2/wqflask/api/markdown.py @@ -29,6 +29,14 @@ xapian_syntax_blueprint = Blueprint("xapian_syntax_blueprint", __name__) blogs_blueprint = Blueprint("blogs_blueprint", __name__) +def render_markdown_from_editor(file_path): + results = requests.get("http://localhost:8091/edit?file_path={file_path}") + results.raise_for_status() + text = results.json()["content"] + return markdown.markdown(text, + extensions=['tables']) + + def render_markdown(file_name, is_remote_file=True): """Try to fetch the file name from Github and if that fails, try to look for it inside the file system """ -- cgit v1.2.3 From e99b3942d1712725dcb3438161da743714b54348 Mon Sep 17 00:00:00 2001 From: Alexander_Kabui Date: Thu, 12 Sep 2024 21:48:33 +0300 Subject: Minor typo fix. --- gn2/wqflask/templates/links.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gn2/wqflask/templates/links.html b/gn2/wqflask/templates/links.html index c5b040e1..4a134c96 100644 --- a/gn2/wqflask/templates/links.html +++ b/gn2/wqflask/templates/links.html @@ -10,7 +10,7 @@
- + Edit Text -- cgit v1.2.3 From f5e0f484b1d555edaeb1e998867a4b9266dea761 Mon Sep 17 00:00:00 2001 From: Alexander_Kabui Date: Thu, 12 Sep 2024 22:07:11 +0300 Subject: Add util functions for fetching and rendering markdown as html. --- gn2/wqflask/api/markdown.py | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/gn2/wqflask/api/markdown.py b/gn2/wqflask/api/markdown.py index 0c8ba8f2..403eef72 100644 --- a/gn2/wqflask/api/markdown.py +++ b/gn2/wqflask/api/markdown.py @@ -29,12 +29,19 @@ xapian_syntax_blueprint = Blueprint("xapian_syntax_blueprint", __name__) blogs_blueprint = Blueprint("blogs_blueprint", __name__) -def render_markdown_from_editor(file_path): - results = requests.get("http://localhost:8091/edit?file_path={file_path}") - results.raise_for_status() - text = results.json()["content"] - return markdown.markdown(text, - extensions=['tables']) +def fetch_raw_markdown(file_path): + """ + This method fetches files from genenetwork:gn docs repo + """ + # todo remove hardcoded file path + response = requests.get(f"http://localhost:8091/edit?file_path={file_path}") + response.raise_for_status() + return response.json() + + +def render_markdown_as_html(content): + """This method converts markdown to html for render""" + return markdown.markdown(content, extensions=["tables"]) def render_markdown(file_name, is_remote_file=True): -- cgit v1.2.3 From 386271aa9acfa6aaece858a8b7b0f8ab4e4e9db4 Mon Sep 17 00:00:00 2001 From: Alexander_Kabui Date: Thu, 12 Sep 2024 22:27:50 +0300 Subject: Render markdown from genenenetwork:gn-docs. --- gn2/wqflask/api/markdown.py | 43 ++++++++++++++++++++++++++++++++----------- 1 file changed, 32 insertions(+), 11 deletions(-) diff --git a/gn2/wqflask/api/markdown.py b/gn2/wqflask/api/markdown.py index 403eef72..062c8f6c 100644 --- a/gn2/wqflask/api/markdown.py +++ b/gn2/wqflask/api/markdown.py @@ -114,30 +114,42 @@ def get_blogs(user: str = "genenetwork", @glossary_blueprint.route('/') def glossary(): + file_data = fetch_raw_markdown(file_path="general/glossary/glossary.md") return render_template( "glossary.html", - rendered_markdown=render_markdown("general/glossary/glossary.md")), 200 - + rendered_markdown=render_markdown_as_html(file_data["content"]), + file_path=file_data["file_path"] + ) @references_blueprint.route('/') def references(): + + file_data = fetch_raw_markdown(file_path="general/references/references.md") return render_template( "references.html", - rendered_markdown=render_markdown("general/references/references.md")), 200 + rendered_markdown=render_markdown_as_html(file_data["content"]), + file_path=file_data["file_path"] + ) @news_blueprint.route('/') def news(): + file_data = fetch_raw_markdown(file_path="general/news/news.md") return render_template( "news.html", - rendered_markdown=render_markdown("general/news/news.md")), 200 + render_markdown=render_markdown_as_html(file_data["content"]), + file_path=file_data["file_path"] + ) @xapian_syntax_blueprint.route('/') def xapian(): + file_data = fetch_raw_markdown(file_path="general/search/xapian_syntax.md") return render_template( "search-syntax.html", - rendered_markdown=render_markdown("general/search/xapian_syntax.md")), 200 + rendered_markdown=render_markdown_as_html(file_data["content"]), + file_path=file_data["file_path"] + ) @environments_blueprint.route("/") @@ -163,12 +175,11 @@ def environments(): 200 ) # Fallback: Fetch file from server + file_data = fetch_raw_markdown(file_path="general/environment/environment.md") return (render_template( "environment.html", svg_data=None, - rendered_markdown=render_markdown( - "general/environments/environments.md")), - 200) + rendered_markdown=render_markdown_as_html(file_data["content"]))) @environments_blueprint.route('/svg-dependency-graph') @@ -180,21 +191,31 @@ def svg_graph(): @links_blueprint.route("/") def links(): + file_data = fetch_raw_markdown(file_path="general/links/links.md") return render_template( "links.html", - rendered_markdown=render_markdown("general/links/links.md")), 200 + rendered_markdown=render_markdown_as_html(file_data["content"]), + file_path=file_data["file_path"] + ) @policies_blueprint.route("/") def policies(): + file_data = fetch_raw_markdown(file_path="general/policies/policies.md") return render_template( "policies.html", - rendered_markdown=render_markdown("general/policies/policies.md")), 200 + rendered_markdown=render_markdown_as_html(file_data["content"]), + file_path=file_data["file_path"] + ) @facilities_blueprint.route("/") def facilities(): - return render_template("facilities.html", rendered_markdown=render_markdown("general/help/facilities.md")), 200 + file_data = fetch_raw_markdown(file_path="general/help/facilities.md") + return render_template("facilities.html", + rendered_markdown=render_markdown_as_html(file_data["content"]), + file_path=file_data["file_path"] + ) @blogs_blueprint.route("/") -- cgit v1.2.3 From 18263411f6d38d3c5972693aa5afa23642099b61 Mon Sep 17 00:00:00 2001 From: Alexander_Kabui Date: Thu, 12 Sep 2024 22:32:51 +0300 Subject: Autopep8 fixes. --- gn2/wqflask/api/markdown.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/gn2/wqflask/api/markdown.py b/gn2/wqflask/api/markdown.py index 062c8f6c..8f153cb7 100644 --- a/gn2/wqflask/api/markdown.py +++ b/gn2/wqflask/api/markdown.py @@ -34,7 +34,8 @@ def fetch_raw_markdown(file_path): This method fetches files from genenetwork:gn docs repo """ # todo remove hardcoded file path - response = requests.get(f"http://localhost:8091/edit?file_path={file_path}") + response = requests.get( + f"http://localhost:8091/edit?file_path={file_path}") response.raise_for_status() return response.json() @@ -121,10 +122,12 @@ def glossary(): file_path=file_data["file_path"] ) + @references_blueprint.route('/') def references(): - file_data = fetch_raw_markdown(file_path="general/references/references.md") + file_data = fetch_raw_markdown( + file_path="general/references/references.md") return render_template( "references.html", rendered_markdown=render_markdown_as_html(file_data["content"]), @@ -175,7 +178,8 @@ def environments(): 200 ) # Fallback: Fetch file from server - file_data = fetch_raw_markdown(file_path="general/environment/environment.md") + file_data = fetch_raw_markdown( + file_path="general/environment/environment.md") return (render_template( "environment.html", svg_data=None, @@ -213,7 +217,8 @@ def policies(): def facilities(): file_data = fetch_raw_markdown(file_path="general/help/facilities.md") return render_template("facilities.html", - rendered_markdown=render_markdown_as_html(file_data["content"]), + rendered_markdown=render_markdown_as_html( + file_data["content"]), file_path=file_data["file_path"] ) -- cgit v1.2.3 From b8d55b7830364d00f8f69ce1f0614f4a945e0fd8 Mon Sep 17 00:00:00 2001 From: Alexander_Kabui Date: Thu, 12 Sep 2024 23:01:38 +0300 Subject: Use generic template for similar templates. --- gn2/wqflask/api/markdown.py | 36 ++++++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/gn2/wqflask/api/markdown.py b/gn2/wqflask/api/markdown.py index 8f153cb7..126d887f 100644 --- a/gn2/wqflask/api/markdown.py +++ b/gn2/wqflask/api/markdown.py @@ -7,6 +7,7 @@ import requests import markdown import os import sys +from pathlib import Path from bs4 import BeautifulSoup # type: ignore @@ -117,9 +118,10 @@ def get_blogs(user: str = "genenetwork", def glossary(): file_data = fetch_raw_markdown(file_path="general/glossary/glossary.md") return render_template( - "glossary.html", + "generic_gn_docs.html", rendered_markdown=render_markdown_as_html(file_data["content"]), - file_path=file_data["file_path"] + file_path=file_data["file_path"], + file_title=Path(file_data["file_path"]).stem ) @@ -129,9 +131,10 @@ def references(): file_data = fetch_raw_markdown( file_path="general/references/references.md") return render_template( - "references.html", + "generic_gn_docs.html", rendered_markdown=render_markdown_as_html(file_data["content"]), - file_path=file_data["file_path"] + file_path=file_data["file_path"], + file_title=Path(file_data["file_path"]).stem ) @@ -139,9 +142,10 @@ def references(): def news(): file_data = fetch_raw_markdown(file_path="general/news/news.md") return render_template( - "news.html", + "generic_gn_docs.html", render_markdown=render_markdown_as_html(file_data["content"]), - file_path=file_data["file_path"] + file_path=file_data["file_path"], + file_title=Path(file_data["file_path"]).stem ) @@ -149,9 +153,10 @@ def news(): def xapian(): file_data = fetch_raw_markdown(file_path="general/search/xapian_syntax.md") return render_template( - "search-syntax.html", + "generic_gn_docs.html", rendered_markdown=render_markdown_as_html(file_data["content"]), - file_path=file_data["file_path"] + file_path=file_data["file_path"], + file_title=Path(file_data["file_path"]).stem ) @@ -197,9 +202,10 @@ def svg_graph(): def links(): file_data = fetch_raw_markdown(file_path="general/links/links.md") return render_template( - "links.html", + "generic_gn_docs.html", rendered_markdown=render_markdown_as_html(file_data["content"]), - file_path=file_data["file_path"] + file_path=file_data["file_path"], + file_title=Path(file_data["file_path"]).stem ) @@ -207,19 +213,21 @@ def links(): def policies(): file_data = fetch_raw_markdown(file_path="general/policies/policies.md") return render_template( - "policies.html", + "generic_gn_docs.html", rendered_markdown=render_markdown_as_html(file_data["content"]), - file_path=file_data["file_path"] + file_path=file_data["file_path"], + file_title=Path(file_data["file_path"]).stem ) @facilities_blueprint.route("/") def facilities(): file_data = fetch_raw_markdown(file_path="general/help/facilities.md") - return render_template("facilities.html", + return render_template("generic_gn_docs.html", rendered_markdown=render_markdown_as_html( file_data["content"]), - file_path=file_data["file_path"] + file_path=file_data["file_path"], + file_title=Path(file_data["file_path"]).stem ) -- cgit v1.2.3 From 5c2664c56e13636f61a87f9ddb39aa55661310e4 Mon Sep 17 00:00:00 2001 From: Alexander_Kabui Date: Thu, 12 Sep 2024 23:03:06 +0300 Subject: Add a generic gn_docs template. --- gn2/wqflask/templates/generic_gn_docs.html | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 gn2/wqflask/templates/generic_gn_docs.html diff --git a/gn2/wqflask/templates/generic_gn_docs.html b/gn2/wqflask/templates/generic_gn_docs.html new file mode 100644 index 00000000..2f591f38 --- /dev/null +++ b/gn2/wqflask/templates/generic_gn_docs.html @@ -0,0 +1,24 @@ +{% extends "base.html" %} + +{% block title %} {{ file_title|capitalize }} {% endblock %} + +{% block css %} + +{% endblock %} + +{% block content %} + + +
+ {{ rendered_markdown|safe }} + +
+ +{% endblock %} -- cgit v1.2.3 From aab7de0af39b6657cccf6bde89a78022efab3397 Mon Sep 17 00:00:00 2001 From: Alexander_Kabui Date: Fri, 13 Sep 2024 13:12:23 +0300 Subject: refactor: urlencode query string. --- gn2/wqflask/views.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gn2/wqflask/views.py b/gn2/wqflask/views.py index f723958a..ec1c2b74 100644 --- a/gn2/wqflask/views.py +++ b/gn2/wqflask/views.py @@ -326,8 +326,8 @@ def gnqna(): @app.route("/editor/edit", methods=["GET"]) @require_oauth2 def edit_gn_doc_file(): - file_path = request.args.get("file-path", "") - response = requests.get(f"http://localhost:8091/edit?file_path={file_path}") + file_path = urllib.parse.urlencode({"file_path": request.args.get("file-path", "")}) + response = requests.get(f"http://localhost:8091/edit?{file_path}") response.raise_for_status() return render_template("gn_editor.html", **response.json()) -- cgit v1.2.3 From d17010dfcd1cdb020619478120eefaeac04ed44d Mon Sep 17 00:00:00 2001 From: Alexander_Kabui Date: Fri, 13 Sep 2024 14:00:15 +0300 Subject: Update data if new changes are made. --- gn2/wqflask/templates/gn_editor.html | 9 +++++---- gn2/wqflask/templates/gn_editor_results_page.html | 17 +++++++++++++---- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/gn2/wqflask/templates/gn_editor.html b/gn2/wqflask/templates/gn_editor.html index e5c649d1..d89aaf0a 100644 --- a/gn2/wqflask/templates/gn_editor.html +++ b/gn2/wqflask/templates/gn_editor.html @@ -157,11 +157,13 @@ let fileExt = (filePath.substring(filePath.lastIndexOf('.')+1, filePath.length) || "md").toLowerCase(); let data = {{ content|tojson }} - localStorage.setItem("gn_editor_sha" ,hash) + localStorage.setItem("gn_editor_sha" ,hash) + htmx.on("#output", "updateDataEvent", function(event){ + data = editor.getValue() + }) htmx.on("#output", "commitEvent", function(event){ htmx.ajax("POST", "/editor/commit", {target: "#output", swap:"innerHTML",values: {'msg':event.detail.payload, 'content': editor.getValue(), "hash": localStorage.getItem("gn_editor_sha"), "file_path": filePath}}) - }) - + }) htmx.on("#output", "diffEvent", function(event){ var fileName = "{{ file_path }}" var diffContent = Diff.createTwoFilesPatch(fileName,fileName, data, editor.getValue()) @@ -186,7 +188,6 @@ htmx.on("#diffBtn","click",function(event){ //dispatch your event here - console.log("Clicked diff btn here") htmx.find("#output").dispatchEvent( new CustomEvent("diffEvent", { bubbles: true, diff --git a/gn2/wqflask/templates/gn_editor_results_page.html b/gn2/wqflask/templates/gn_editor_results_page.html index 666bd432..6eaeb941 100644 --- a/gn2/wqflask/templates/gn_editor_results_page.html +++ b/gn2/wqflask/templates/gn_editor_results_page.html @@ -37,10 +37,19 @@ {% block js %} {% endblock %} -- cgit v1.2.3 From 904957b017179d530c60f4b231a26cc2b8747987 Mon Sep 17 00:00:00 2001 From: Alexander_Kabui Date: Fri, 13 Sep 2024 14:17:19 +0300 Subject: Use urlencode for query strings. --- gn2/wqflask/api/markdown.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/gn2/wqflask/api/markdown.py b/gn2/wqflask/api/markdown.py index 126d887f..f0f94b52 100644 --- a/gn2/wqflask/api/markdown.py +++ b/gn2/wqflask/api/markdown.py @@ -7,6 +7,7 @@ import requests import markdown import os import sys +import urllib.parse from pathlib import Path from bs4 import BeautifulSoup # type: ignore @@ -35,8 +36,9 @@ def fetch_raw_markdown(file_path): This method fetches files from genenetwork:gn docs repo """ # todo remove hardcoded file path + safe_query = urllib.parse.urlencode({"file_path": file_path}) response = requests.get( - f"http://localhost:8091/edit?file_path={file_path}") + f"http://localhost:8091/edit?{safe_query}") response.raise_for_status() return response.json() @@ -184,7 +186,7 @@ def environments(): ) # Fallback: Fetch file from server file_data = fetch_raw_markdown( - file_path="general/environment/environment.md") + file_path="general/environments/environments.md") return (render_template( "environment.html", svg_data=None, -- cgit v1.2.3 From 954993cca85a90a1d2868a9852b685824686952e Mon Sep 17 00:00:00 2001 From: Alexander_Kabui Date: Fri, 13 Sep 2024 15:46:27 +0300 Subject: Define new blueprint for all gn_docs. --- gn2/wqflask/__init__.py | 2 ++ gn2/wqflask/api/markdown.py | 10 ++++++++++ 2 files changed, 12 insertions(+) diff --git a/gn2/wqflask/__init__.py b/gn2/wqflask/__init__.py index 00fe5127..d959598d 100644 --- a/gn2/wqflask/__init__.py +++ b/gn2/wqflask/__init__.py @@ -34,6 +34,7 @@ from gn2.wqflask.api.markdown import facilities_blueprint from gn2.wqflask.api.markdown import blogs_blueprint from gn2.wqflask.api.markdown import news_blueprint from gn2.wqflask.api.markdown import xapian_syntax_blueprint +from gn2.wqflask.api.markdown import gn_docs_blueprint from gn2.wqflask.api.jobs import jobs as jobs_bp from gn2.wqflask.oauth2.routes import oauth2 from gn2.wqflask.oauth2.client import user_logged_in @@ -109,6 +110,7 @@ app.jinja_env.globals.update( # Registering blueprints +app.register_blueprint(gn_docs_blueprint, url_prefix="/gn_docs") app.register_blueprint(glossary_blueprint, url_prefix="/glossary") app.register_blueprint(references_blueprint, url_prefix="/references") app.register_blueprint(links_blueprint, url_prefix="/links") diff --git a/gn2/wqflask/api/markdown.py b/gn2/wqflask/api/markdown.py index f0f94b52..9a43ecdb 100644 --- a/gn2/wqflask/api/markdown.py +++ b/gn2/wqflask/api/markdown.py @@ -29,6 +29,7 @@ news_blueprint = Blueprint("news_blueprint", __name__) xapian_syntax_blueprint = Blueprint("xapian_syntax_blueprint", __name__) blogs_blueprint = Blueprint("blogs_blueprint", __name__) +gn_docs_blueprint = Blueprint("gn_docs_blueprint", __name__) def fetch_raw_markdown(file_path): @@ -243,3 +244,12 @@ def blogs_list(): blogs = get_blogs() return render_template("blogs_list.html", blogs=blogs) + + +@gn_docs_blueprint.errorhandler(requests.exceptions.HTTPError) +def page_not_found(error): + """ Return error 404 """ + return {"Reason": error.response.reason, + "error_status_code": error.response.status_code, + "error_msg": error.response.text + } -- cgit v1.2.3 From 329b01b5a933c89d747eef18a1444928b978be0d Mon Sep 17 00:00:00 2001 From: Alexander_Kabui Date: Fri, 13 Sep 2024 17:56:08 +0300 Subject: Use gn_docs blueprint for doc files. --- gn2/wqflask/api/markdown.py | 27 ++++++++++++++------------- gn2/wqflask/templates/base.html | 16 ++++++++-------- gn2/wqflask/templates/blogs_list.html | 4 ++-- 3 files changed, 24 insertions(+), 23 deletions(-) diff --git a/gn2/wqflask/api/markdown.py b/gn2/wqflask/api/markdown.py index 9a43ecdb..f9e87ee3 100644 --- a/gn2/wqflask/api/markdown.py +++ b/gn2/wqflask/api/markdown.py @@ -49,6 +49,7 @@ def render_markdown_as_html(content): return markdown.markdown(content, extensions=["tables"]) + def render_markdown(file_name, is_remote_file=True): """Try to fetch the file name from Github and if that fails, try to look for it inside the file system """ @@ -117,7 +118,7 @@ def get_blogs(user: str = "genenetwork", return dict(sorted(blogs.items(), key=lambda x: x[0], reverse=True)) -@glossary_blueprint.route('/') +@gn_docs_blueprint.route('/glossary') def glossary(): file_data = fetch_raw_markdown(file_path="general/glossary/glossary.md") return render_template( @@ -128,11 +129,11 @@ def glossary(): ) -@references_blueprint.route('/') +@gn_docs_blueprint.route('/references') def references(): file_data = fetch_raw_markdown( - file_path="general/references/references.md") + file_path="general/references/references.md") return render_template( "generic_gn_docs.html", rendered_markdown=render_markdown_as_html(file_data["content"]), @@ -141,18 +142,18 @@ def references(): ) -@news_blueprint.route('/') +@gn_docs_blueprint.route('/news') def news(): file_data = fetch_raw_markdown(file_path="general/news/news.md") return render_template( "generic_gn_docs.html", - render_markdown=render_markdown_as_html(file_data["content"]), + rendered_markdown=render_markdown_as_html(file_data["content"]), file_path=file_data["file_path"], file_title=Path(file_data["file_path"]).stem ) -@xapian_syntax_blueprint.route('/') +@gn_docs_blueprint.route('/xapian') def xapian(): file_data = fetch_raw_markdown(file_path="general/search/xapian_syntax.md") return render_template( @@ -163,7 +164,7 @@ def xapian(): ) -@environments_blueprint.route("/") +@gn_docs_blueprint.route("/environments") def environments(): md_file = get_file_from_python_search_path("wqflask/DEPENDENCIES.md") @@ -194,14 +195,14 @@ def environments(): rendered_markdown=render_markdown_as_html(file_data["content"]))) -@environments_blueprint.route('/svg-dependency-graph') +@gn_docs_blueprint.route('/svg-dependency-graph') def svg_graph(): directory, file_name, _ = get_file_from_python_search_path( "wqflask/dependency-graph.svg").partition("dependency-graph.svg") return send_from_directory(directory, file_name) -@links_blueprint.route("/") +@gn_docs_blueprint.route("/links") def links(): file_data = fetch_raw_markdown(file_path="general/links/links.md") return render_template( @@ -212,7 +213,7 @@ def links(): ) -@policies_blueprint.route("/") +@gn_docs_blueprint.route("/policies") def policies(): file_data = fetch_raw_markdown(file_path="general/policies/policies.md") return render_template( @@ -223,7 +224,7 @@ def policies(): ) -@facilities_blueprint.route("/") +@gn_docs_blueprint.route("/facilities") def facilities(): file_data = fetch_raw_markdown(file_path="general/help/facilities.md") return render_template("generic_gn_docs.html", @@ -234,12 +235,12 @@ def facilities(): ) -@blogs_blueprint.route("/") +@gn_docs_blueprint.route("/blogs/") def display_blog(blog_path): return render_template("blogs.html", rendered_markdown=render_markdown(blog_path)) -@blogs_blueprint.route("/") +@gn_docs_blueprint.route("/blogs") def blogs_list(): blogs = get_blogs() diff --git a/gn2/wqflask/templates/base.html b/gn2/wqflask/templates/base.html index 9c4ebfdd..7db9aed6 100644 --- a/gn2/wqflask/templates/base.html +++ b/gn2/wqflask/templates/base.html @@ -82,16 +82,16 @@
  • diff --git a/gn2/wqflask/templates/blogs_list.html b/gn2/wqflask/templates/blogs_list.html index 6bad4628..a74d24a2 100644 --- a/gn2/wqflask/templates/blogs_list.html +++ b/gn2/wqflask/templates/blogs_list.html @@ -40,7 +40,7 @@ @@ -49,4 +49,4 @@ {%endfor%}
  • -{% endblock %} \ No newline at end of file +{% endblock %} -- cgit v1.2.3 From 563c2db81f79bfa4cb00483e8a9b23c1db02ef6d Mon Sep 17 00:00:00 2001 From: Alexander_Kabui Date: Mon, 16 Sep 2024 15:07:32 +0300 Subject: fix: fix url for gn-docs glossary. --- gn2/wqflask/templates/index_page.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gn2/wqflask/templates/index_page.html b/gn2/wqflask/templates/index_page.html index f0840425..734cd075 100755 --- a/gn2/wqflask/templates/index_page.html +++ b/gn2/wqflask/templates/index_page.html @@ -257,7 +257,7 @@ Gene Ontology.
  • RIF=diabetes LRS=(9 999 Chr2 100 105) transLRS=(9 999 10) - finds diabetes-associated transcripts with peak + finds diabetes-associated transcripts with peak trans eQTLs on Chr 2 between 100 and 105 Mb with LRS scores between 9 and 999.
  • -- cgit v1.2.3 From 304f3f35bfea61bdf9e6be2286b8f6e83b71edb6 Mon Sep 17 00:00:00 2001 From: Alexander_Kabui Date: Mon, 16 Sep 2024 15:19:07 +0300 Subject: Refactor: run dlint on html files. --- gn2/wqflask/templates/generic_gn_docs.html | 30 ++++++++++------------------- gn2/wqflask/templates/gn_editor_commit.html | 10 ++++++---- 2 files changed, 16 insertions(+), 24 deletions(-) diff --git a/gn2/wqflask/templates/generic_gn_docs.html b/gn2/wqflask/templates/generic_gn_docs.html index 2f591f38..57723f0b 100644 --- a/gn2/wqflask/templates/generic_gn_docs.html +++ b/gn2/wqflask/templates/generic_gn_docs.html @@ -1,24 +1,14 @@ {% extends "base.html" %} - -{% block title %} {{ file_title|capitalize }} {% endblock %} - -{% block css %} - -{% endblock %} - +{% block title %}{{ file_title|capitalize }}{% endblock %} +{% block css %}{% endblock %} {% block content %} - -
    - -
    - {{ rendered_markdown|safe }} - -
    - +
    {{ rendered_markdown|safe }}
    {% endblock %} diff --git a/gn2/wqflask/templates/gn_editor_commit.html b/gn2/wqflask/templates/gn_editor_commit.html index 84ebd818..2eb3e60c 100644 --- a/gn2/wqflask/templates/gn_editor_commit.html +++ b/gn2/wqflask/templates/gn_editor_commit.html @@ -23,15 +23,17 @@

    - - + +

    {% block js %} - + {% endblock %} -- cgit v1.2.3