From b3e6de2ce15af9f1cfd89a1368130a9cd6000384 Mon Sep 17 00:00:00 2001 From: matiusz Date: Fri, 2 Feb 2024 12:06:46 +0100 Subject: [PATCH] code: per page artifacts --- .circleci/config.yml | 17 ++++++++++++++++- .github/README.md | 2 +- src/flask/flask_app.py | 8 +++++++- src/flask/static/style.css | 2 +- src/flask/{static => templates}/artifacts.html | 2 +- src/flask/templates/page.html | 2 +- 6 files changed, 27 insertions(+), 6 deletions(-) rename src/flask/{static => templates}/artifacts.html (91%) diff --git a/.circleci/config.yml b/.circleci/config.yml index 5a10701..02df002 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -8,12 +8,27 @@ jobs: steps: - checkout - run: - name: Generate PDF + name: Generate HK PDF command: python3 -m apps.create_pdf + environment: + SONGBOOK_DATA_DIR: hk-songbook - store_artifacts: path: songbook.pdf + destination: hk-songbook.pdf - store_artifacts: path: songbook-py.log + destination: hk-songbook.log + - run: + name: Generate 111 ADH PDF + command: python3 -m apps.create_pdf + environment: + SONGBOOK_DATA_DIR: spiewnik111adh + - store_artifacts: + path: songbook.pdf + destination: spiewnik111adh.pdf + - store_artifacts: + path: songbook-py.log + destination: spiewnik111adh.log workflows: build-and-test: diff --git a/.github/README.md b/.github/README.md index 68807c6..a3dcee6 100644 --- a/.github/README.md +++ b/.github/README.md @@ -2,7 +2,7 @@ [![CircleCI](https://circleci.com/gh/matiusz/songbook/tree/hk-songbook.svg?style=svg)](https://circleci.com/gh/matiusz/songbook/tree/hk-songbook) -[Current PDF](https://hk-songbook.onrender.com/static/artifacts.html) +[Current PDF](https://hk-songbook.onrender.com/artifacts.html) ## songbook diff --git a/src/flask/flask_app.py b/src/flask/flask_app.py index 6c644a2..06240c7 100644 --- a/src/flask/flask_app.py +++ b/src/flask/flask_app.py @@ -1,5 +1,6 @@ -from flask import Flask, render_template, make_response +from flask import Flask, render_template, make_response, redirect +from src.obj.Config import config from src.obj.Songbook import Songbook from src.obj.Song import Song import json @@ -30,6 +31,11 @@ def serve_js(): response.headers['Content-Type'] = 'text/javascript' return response +@app.route(f"/artifacts.html") +def get_pdf(): + name = config.dataFolder.split("/")[1] + return render_template("artifacts.html", name = name) + @app.route("/") @app.route("//.html") def start(category = None, song = None): diff --git a/src/flask/static/style.css b/src/flask/static/style.css index 104c737..e1fca59 100644 --- a/src/flask/static/style.css +++ b/src/flask/static/style.css @@ -128,7 +128,7 @@ display: block; cursor: pointer; position: absolute; - right: 15px; + right: 7vw; top: 15px; z-index: 10 !important; padding: 3px; diff --git a/src/flask/static/artifacts.html b/src/flask/templates/artifacts.html similarity index 91% rename from src/flask/static/artifacts.html rename to src/flask/templates/artifacts.html index 371790a..4ffbc0f 100644 --- a/src/flask/static/artifacts.html +++ b/src/flask/templates/artifacts.html @@ -6,7 +6,7 @@ function getArtifact() { jQuery.getJSON("https://circleci.com/api/v1.1/project/github/matiusz/songbook/latest/artifacts", function(data) { for (const element of data) { - if (element["path"] == "songbook.pdf") { + if (element["path"] == "{{ name }}.pdf") { window.location.replace(element["url"]); } } diff --git a/src/flask/templates/page.html b/src/flask/templates/page.html index dfe3647..40e1410 100644 --- a/src/flask/templates/page.html +++ b/src/flask/templates/page.html @@ -54,7 +54,7 @@

Author: Mateusz Szwed
Source: https://github.com/matiusz/songbook
- Current PDF: + Current PDF:
{% autoescape false %}