From f2952a8277095968bdd20d45fc1a1a5f12ab2138 Mon Sep 17 00:00:00 2001 From: Miguel Nistal Date: Mon, 20 May 2019 16:44:42 -0400 Subject: [PATCH 1/3] laid out some directory structure for the webserver and assets --- bazaarci/server/__init__.py | 0 bazaarci/server/assets/css/.gitignore | 5 +++++ bazaarci/server/assets/html/.gitignore | 5 +++++ bazaarci/server/assets/js/.gitignore | 5 +++++ 4 files changed, 15 insertions(+) create mode 100644 bazaarci/server/__init__.py create mode 100644 bazaarci/server/assets/css/.gitignore create mode 100644 bazaarci/server/assets/html/.gitignore create mode 100644 bazaarci/server/assets/js/.gitignore diff --git a/bazaarci/server/__init__.py b/bazaarci/server/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/bazaarci/server/assets/css/.gitignore b/bazaarci/server/assets/css/.gitignore new file mode 100644 index 0000000..982d8e2 --- /dev/null +++ b/bazaarci/server/assets/css/.gitignore @@ -0,0 +1,5 @@ +# Ignore all files that aren't css +* +!.gitignore +!*.css +!*/ diff --git a/bazaarci/server/assets/html/.gitignore b/bazaarci/server/assets/html/.gitignore new file mode 100644 index 0000000..ae1c1ed --- /dev/null +++ b/bazaarci/server/assets/html/.gitignore @@ -0,0 +1,5 @@ +# Ignore all files that aren't css +* +!.gitignore +!*.html +!*/ diff --git a/bazaarci/server/assets/js/.gitignore b/bazaarci/server/assets/js/.gitignore new file mode 100644 index 0000000..7c51dd8 --- /dev/null +++ b/bazaarci/server/assets/js/.gitignore @@ -0,0 +1,5 @@ +# Ignore all files that aren't css +* +!.gitignore +!*.js +!*/ From ed2a66fee56635825886ad556810a3166579fd55 Mon Sep 17 00:00:00 2001 From: Miguel Nistal Date: Mon, 20 May 2019 17:59:49 -0400 Subject: [PATCH 2/3] Basic infrastructure to demo a webserver skeleton that can be run via python3 -m or on-demand --- bazaarci/server/__init__.py | 11 +++ bazaarci/server/__main__.py | 8 ++ bazaarci/server/assets/html/graph.html | 26 ++++++ bazaarci/server/assets/js/gvd3demo.js | 122 +++++++++++++++++++++++++ bazaarci/server/views/__init__.py | 0 bazaarci/server/views/graph.py | 10 ++ 6 files changed, 177 insertions(+) create mode 100644 bazaarci/server/__main__.py create mode 100644 bazaarci/server/assets/html/graph.html create mode 100644 bazaarci/server/assets/js/gvd3demo.js create mode 100644 bazaarci/server/views/__init__.py create mode 100644 bazaarci/server/views/graph.py diff --git a/bazaarci/server/__init__.py b/bazaarci/server/__init__.py index e69de29..7407da6 100644 --- a/bazaarci/server/__init__.py +++ b/bazaarci/server/__init__.py @@ -0,0 +1,11 @@ + +from flask import Flask + +def create_app(config=None): + app = Flask(__name__, template_folder='assets/html', static_folder='assets') + + from .views import graph + app.register_blueprint(graph.bp) + + return app + diff --git a/bazaarci/server/__main__.py b/bazaarci/server/__main__.py new file mode 100644 index 0000000..845764e --- /dev/null +++ b/bazaarci/server/__main__.py @@ -0,0 +1,8 @@ + +from . import create_app + +if __name__ == "__main__": + app = create_app(config="Production/LocalRun/etc") + app.run() + + diff --git a/bazaarci/server/assets/html/graph.html b/bazaarci/server/assets/html/graph.html new file mode 100644 index 0000000..ab76180 --- /dev/null +++ b/bazaarci/server/assets/html/graph.html @@ -0,0 +1,26 @@ + + + + + + + + BazaarCI + + + +
+

BazaarCI

+
+ + +
+ + + + + + + + + diff --git a/bazaarci/server/assets/js/gvd3demo.js b/bazaarci/server/assets/js/gvd3demo.js new file mode 100644 index 0000000..de1e107 --- /dev/null +++ b/bazaarci/server/assets/js/gvd3demo.js @@ -0,0 +1,122 @@ + +var dotIndex = 0; +var graphviz = d3.select("#graph").graphviz() + .transition(function () { + return d3.transition("main") + .ease(d3.easeLinear) + .delay(500) + .duration(1500); + }) + .logEvents(true) + .on("initEnd", render); + +function render() { + var dotLines = dots[dotIndex]; + var dot = dotLines.join(''); + graphviz + .renderDot(dot) + .on("end", function () { + dotIndex = (dotIndex + 1) % dots.length; + render(); + }); +} + +var dots = [ + [ + 'digraph {', + ' node [style="filled"]', + ' a [fillcolor="#d62728"]', + ' b [fillcolor="#1f77b4"]', + ' a -> b', + '}' + ], + [ + 'digraph {', + ' node [style="filled"]', + ' a [fillcolor="#d62728"]', + ' c [fillcolor="#2ca02c"]', + ' b [fillcolor="#1f77b4"]', + ' a -> b', + ' a -> c', + '}' + ], + [ + 'digraph {', + ' node [style="filled"]', + ' a [fillcolor="#d62728"]', + ' b [fillcolor="#1f77b4"]', + ' c [fillcolor="#2ca02c"]', + ' a -> b', + ' a -> c', + '}' + ], + [ + 'digraph {', + ' node [style="filled"]', + ' a [fillcolor="#d62728", shape="box"]', + ' b [fillcolor="#1f77b4", shape="parallelogram"]', + ' c [fillcolor="#2ca02c", shape="pentagon"]', + ' a -> b', + ' a -> c', + ' b -> c', + '}' + ], + [ + 'digraph {', + ' node [style="filled"]', + ' a [fillcolor="yellow", shape="star"]', + ' b [fillcolor="yellow", shape="star"]', + ' c [fillcolor="yellow", shape="star"]', + ' a -> b', + ' a -> c', + ' b -> c', + '}' + ], + [ + 'digraph {', + ' node [style="filled"]', + ' a [fillcolor="#d62728", shape="triangle"]', + ' b [fillcolor="#1f77b4", shape="diamond"]', + ' c [fillcolor="#2ca02c", shape="trapezium"]', + ' a -> b', + ' a -> c', + ' b -> c', + '}' + ], + [ + 'digraph {', + ' node [style="filled"]', + ' a [fillcolor="#d62728", shape="box"]', + ' b [fillcolor="#1f77b4", shape="parallelogram"]', + ' c [fillcolor="#2ca02c", shape="pentagon"]', + ' a -> b', + ' a -> c', + ' b -> c', + '}' + ], + [ + 'digraph {', + ' node [style="filled"]', + ' a [fillcolor="#d62728"]', + ' b [fillcolor="#1f77b4"]', + ' c [fillcolor="#2ca02c"]', + ' a -> b', + ' a -> c', + ' c -> b', + '}' + ], + [ + 'digraph {', + ' node [style="filled"]', + ' b [fillcolor="#1f77b4"]', + ' c [fillcolor="#2ca02c"]', + ' c -> b', + '}' + ], + [ + 'digraph {', + ' node [style="filled"]', + ' b [fillcolor="#1f77b4"]', + '}' + ], +]; \ No newline at end of file diff --git a/bazaarci/server/views/__init__.py b/bazaarci/server/views/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/bazaarci/server/views/graph.py b/bazaarci/server/views/graph.py new file mode 100644 index 0000000..487feb8 --- /dev/null +++ b/bazaarci/server/views/graph.py @@ -0,0 +1,10 @@ + +from flask import Blueprint, render_template, request + +bp = Blueprint('graph', __name__) + +@bp.route('/') +def index(): + return render_template('graph.html') + + From d737b7c7286b5d532a323383741ced8dd770b577 Mon Sep 17 00:00:00 2001 From: Miguel Nistal Date: Mon, 20 May 2019 18:02:53 -0400 Subject: [PATCH 3/3] Added a the server package to the setup.py to try out the -m in virtualenv --- setup.py | 1 + 1 file changed, 1 insertion(+) diff --git a/setup.py b/setup.py index a0a6109..91f18b4 100644 --- a/setup.py +++ b/setup.py @@ -17,5 +17,6 @@ packages=[ 'bazaarci', 'bazaarci.runner', + 'bazaarci.server', ], )