From 64bfeadac33e6d22297714544cd96ef16677fe16 Mon Sep 17 00:00:00 2001 From: BonfaceKilz Date: Thu, 3 Dec 2020 23:59:14 +0300 Subject: Display d3js chord dependency diagram of gn2 dependenices * wqflask/wqflask/markdown_routes.py: Add new bs4 import. (references): Filter out javascript from the guix-generated d3js html file and pass it to the jinja template. * wqflask/wqflask/static/new/css/markdown.css: New styles for the graph content. * wqflask/wqflask/templates/environment.html: New graph content. --- wqflask/wqflask/markdown_routes.py | 14 +++ wqflask/wqflask/static/new/css/markdown.css | 14 +++ wqflask/wqflask/templates/environment.html | 134 ++++++++++++++++++++++++++++ 3 files changed, 162 insertions(+) diff --git a/wqflask/wqflask/markdown_routes.py b/wqflask/wqflask/markdown_routes.py index 59a465e7..183f4caa 100644 --- a/wqflask/wqflask/markdown_routes.py +++ b/wqflask/wqflask/markdown_routes.py @@ -7,6 +7,8 @@ import markdown import os import sys +from bs4 import BeautifulSoup + from flask import Blueprint from flask import render_template @@ -68,10 +70,21 @@ def references(): @environments_blueprint.route("/") def environments(): + md_file = get_file_from_python_search_path("wqflask/DEPENDENCIES.md") + svg_file = get_file_from_python_search_path( + "wqflask/dependency-graph.html") + svg_data = None + if svg_file: + with open(svg_file, 'r') as f: + svg_data = "".join( + BeautifulSoup(f.read(), + 'lxml').body.script.contents) + if md_file is not None: return ( render_template("environment.html", + svg_data=svg_data, rendered_markdown=render_markdown( md_file, is_remote_file=False)), @@ -80,6 +93,7 @@ def environments(): # Fallback: Fetch file from server return (render_template( "environment.html", + svg_data=None, rendered_markdown=render_markdown( "general/environments/environments.md")), 200) diff --git a/wqflask/wqflask/static/new/css/markdown.css b/wqflask/wqflask/static/new/css/markdown.css index 0c0309fb..38d664e2 100644 --- a/wqflask/wqflask/static/new/css/markdown.css +++ b/wqflask/wqflask/static/new/css/markdown.css @@ -57,6 +57,20 @@ word-spacing: 0.2em; } +.graph-legend h1 { + text-align: center; +} + +.graph-legend, +#guix-graph { + width: 90%; + margin: 10px auto; +} + +#guix-graph { + border: solid 2px black; +} + #markdown table { width: 100%; } diff --git a/wqflask/wqflask/templates/environment.html b/wqflask/wqflask/templates/environment.html index cd30e768..5fe01dad 100644 --- a/wqflask/wqflask/templates/environment.html +++ b/wqflask/wqflask/templates/environment.html @@ -13,4 +13,138 @@
{{ rendered_markdown|safe }}
+{% if svg_data %} + +
+

Chord dependency Graph of Genenetwork2

+ Graph generated from genenetwork.scm. You can zoom in and out within the bounding box. +
+ +
+{% endif %} + +{% endblock %} + +{% block js %} + +{% if svg_data %} + + +{% endif %} + {% endblock %} -- cgit v1.2.3