diff --git a/.builds/test.yml b/.builds/test.yml index daa11ab..7575a17 100644 --- a/.builds/test.yml +++ b/.builds/test.yml @@ -6,7 +6,7 @@ packages: - libffi-dev - openssl-dev sources: - - https://git.sr.ht/~fmartingr/jeeves + - https://code.fmartingr.com/fmartingr/jeeves tasks: - setup: | pip install poetry diff --git a/docs/contributing.rst b/docs/contributing.rst index 92fb264..265c9a6 100644 --- a/docs/contributing.rst +++ b/docs/contributing.rst @@ -9,7 +9,7 @@ source code and be able to run it in your local machine. .. code-block:: bash - git clone git@git.sr.ht:~fmartingr/jeeves + git clone git@code.fmartingr.com:fmartingr/jeeves In this project we use Poetry_ to manage diff --git a/docs/installation.rst b/docs/installation.rst index 3048a2b..2af6c1f 100644 --- a/docs/installation.rst +++ b/docs/installation.rst @@ -9,7 +9,7 @@ need to clone the repository or download a release manually. .. code-block:: - git clone git@git.sr.ht:~fmartingr/jeeves + git clone git@code.fmartingr.com:fmartingr/jeeves cd jeeves poetry install poetry run jeeves --help diff --git a/jeeves/server/__main__.py b/jeeves/server/__main__.py new file mode 100644 index 0000000..a5764ff --- /dev/null +++ b/jeeves/server/__main__.py @@ -0,0 +1,5 @@ +from jeeves.server.app import app + + +if __name__ == "__main__": + app.run(debug=True) diff --git a/jeeves/server/app.py b/jeeves/server/app.py new file mode 100644 index 0000000..1bae3d0 --- /dev/null +++ b/jeeves/server/app.py @@ -0,0 +1,41 @@ +import os + +from quart import Quart, redirect, request, jsonify +import jinja2 + +from jeeves.core.parsers import FlowParser + +app = Quart(__name__) +jinja2_env = jinja2.Environment(loader=jinja2.FileSystemLoader("/home/fmartingr/Code/jeeves/jeeves/server/frontend/templates")) + + +FLOWS = [] +DATA_FOLDER = "~/Code/jeeves/_data" +for rootname, dirnames, filenames in os.walk(DATA_FOLDER): + for filename in filenames: + _zz, extension = os.path.splitext(os.path.join(rootname, filename)) + if extension == '.yaml': + FLOWS.append(FlowParser.from_yaml(open(os.path.join(rootname, filename), "rb").read())) + + +@app.route("/healthz") +async def healthz_view(): + return "ok" + + +@app.route("/") +async def home(): + return redirect("/flows") + + +@app.route("/flows") +async def list_flows(): + template = jinja2_env.get_template("flows/list.j2") + return template.render(flows=FLOWS) + + +@app.route("/flows/") +async def flow_detail(flow_id): + flow = list(filter(lambda flow: flow.id == flow_id, FLOWS))[0] + template = jinja2_env.get_template("flows/task-list.j2") + return template.render(flow=flow) diff --git a/jeevesfiles/example.yaml b/jeevesfiles/example.yaml new file mode 100644 index 0000000..eaf9282 --- /dev/null +++ b/jeevesfiles/example.yaml @@ -0,0 +1,17 @@ +name: Build Synology-Drive AUR package +id: 123 +tasks: +- name: Perform a curl command + type: contrib/script + parameters: + script: curl fmartingr.com + +- name: Generate an output file (use `-a` flag with execute command) + type: contrib/template + parameters: + src: template.j2 + dest: output.txt + +arguments: +- name: variable + required: true diff --git a/jeevesfiles/template.j2 b/jeevesfiles/template.j2 new file mode 100644 index 0000000..ba8232d --- /dev/null +++ b/jeevesfiles/template.j2 @@ -0,0 +1 @@ +Hello {{ variable }}