Skip to content

Commit

Permalink
code: per page artifacts
Browse files Browse the repository at this point in the history
  • Loading branch information
matiusz committed Feb 2, 2024
1 parent 8f6475d commit b3e6de2
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 6 deletions.
17 changes: 16 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion .github/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 7 additions & 1 deletion src/flask/flask_app.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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("/<category>/<song>.html")
def start(category = None, song = None):
Expand Down
2 changes: 1 addition & 1 deletion src/flask/static/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@
display: block;
cursor: pointer;
position: absolute;
right: 15px;
right: 7vw;
top: 15px;
z-index: 10 !important;
padding: 3px;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"]);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/flask/templates/page.html
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
<div style="text-align: center;"><br>
Author: Mateusz Szwed<br>
Source: <a href="https://github.com/matiusz/songbook">https://github.com/matiusz/songbook</a><br>
Current PDF: <a href="/static/artifacts.html"><i class="fa fa-file"></i></a>
Current PDF: <a href="/artifacts.html"><i class="fa fa-file"></i></a>
</div>
</div>
{% autoescape false %}
Expand Down

0 comments on commit b3e6de2

Please sign in to comment.