From ac86f811920f0f2dd4a9e8a4c79c270457b4a745 Mon Sep 17 00:00:00 2001 From: Brendan Golden Date: Mon, 20 May 2024 02:44:50 +0100 Subject: [PATCH] feat: new script to generate PDF's for the budget --- .gitlab-ci.yml | 34 ++- .../2023-2024/Budget/10._Guest_Speakers.md | 3 + Committee/2023-2024/Budget/Points.md | 50 ++-- Committee/_Templates/Budget/Logo_2024.svg | 230 ++++++++++++++++++ Committee/_Templates/Budget/_template.md | 13 + Committee/_Templates/Budget/general.html | 38 +++ Committee/_Templates/Budget/main.css | 120 +++++++++ _scripts/format_budget.sh | 108 ++++++++ _scripts/format_handovers.sh | 21 +- _scripts/md_toml/_Budget.md.toml | 46 ++++ flake.nix | 9 + 11 files changed, 631 insertions(+), 41 deletions(-) create mode 100644 Committee/2023-2024/Budget/10._Guest_Speakers.md create mode 100644 Committee/_Templates/Budget/Logo_2024.svg create mode 100644 Committee/_Templates/Budget/_template.md create mode 100644 Committee/_Templates/Budget/general.html create mode 100644 Committee/_Templates/Budget/main.css create mode 100755 _scripts/format_budget.sh create mode 100644 _scripts/md_toml/_Budget.md.toml diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index ea5eafe..a6c4882 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -18,11 +18,11 @@ stages: stage: build # when it runs - rules: - - if: '$CI_PROJECT_NAMESPACE == "compsoc1/compsoc" && $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH' - changes: - - Committee/**/Handovers/* - - Minutes/**/* +# rules: +# - if: '$CI_PROJECT_NAMESPACE == "compsoc1/compsoc" && $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH' +# changes: +# - Committee/**/Handovers/* +# - Minutes/**/* handovers: <<: *pdf_base @@ -35,7 +35,10 @@ handovers: paths: - Handovers_pdf/ - errors.log - + rules: + - if: '$CI_PROJECT_NAMESPACE == "compsoc1/compsoc" && $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH' + changes: + - Committee/**/Handovers/* minutes: <<: *pdf_base @@ -47,3 +50,22 @@ minutes: paths: - Minutes_pdf/ - errors.log + rules: + - if: '$CI_PROJECT_NAMESPACE == "compsoc1/compsoc" && $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH' + changes: + - Minutes/**/* + +budget: + <<: *pdf_base + script: + - attic watch-store skynet-cache & + - nix --extra-experimental-features 'nix-command flakes' run .#budget + artifacts: + name: "Minutes" + paths: + - Budget_pdf/ + - errors.log + rules: + - if: '$CI_PROJECT_NAMESPACE == "compsoc1/compsoc" && $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH' + changes: + - Committee/**/Budget/* \ No newline at end of file diff --git a/Committee/2023-2024/Budget/10._Guest_Speakers.md b/Committee/2023-2024/Budget/10._Guest_Speakers.md new file mode 100644 index 0000000..dc4a1ef --- /dev/null +++ b/Committee/2023-2024/Budget/10._Guest_Speakers.md @@ -0,0 +1,3 @@ +## Guest speakers + + diff --git a/Committee/2023-2024/Budget/Points.md b/Committee/2023-2024/Budget/Points.md index d0ccdd8..2d6aa43 100644 --- a/Committee/2023-2024/Budget/Points.md +++ b/Committee/2023-2024/Budget/Points.md @@ -1,12 +1,12 @@ -# Points for Budget +## Points for Budget This file is to organise the written part of the [points][0] for the budget. See [last years submission][1] for more details [0]: https://cp.ulwolves.ie/budget/points/2023 [1]: https://cp.ulwolves.ie/budget/points/2022 -## 7. Committee Development -### Instructions +### 7. Committee Development +#### Instructions > * 5 Points - Based on Computer Society having a minimum of 5 core committee members: Chairperson, Secretary, Treasurer, PRO, and Health & Safety Officer (this will be checked online so be sure that your Committee details are up-to-date) > Societies are deemed to be low risk and therefore they can double up their H&S officer responsibilities with another core committe members, i.e. they must have a minimum of 4 core committee members @@ -15,7 +15,7 @@ See [last years submission][1] for more details > * 3 Points - For evidence of managing your Financial affairs (for Bank Statements use the BANK BALANCES page) > * 1 Point - For providing information to the C&S Office if required or asked to do so throughout the Academic Year -### Notes +#### Notes * For most committee this relates to handovers. * Handovers PDFs can be found [browse][3] [download][4] * Minutes PDFs can be found [browse][5] [download][6] @@ -26,11 +26,11 @@ See [last years submission][1] for more details [5]: https://gitlab.skynet.ie/compsoc1/compsoc/open-goverance/-/jobs/artifacts/main/browse?job=minutes [6]: https://gitlab.skynet.ie/api/v4/projects/57/jobs/artifacts/main/download?job=minutes -### Details +#### Details {Add text here} -## 8. Performance -### Instructions +### 8. Performance +#### Instructions > * 2 Points - If Computer Society have no creditors outstanding (any outstanding debts have been cleared prior to budget submission) > * 3 Points - If Computer Society has had no grievances throughout the year (if you have had a grievance and have dealt with it in a a good and fair manner the office will deliberate on points to be awarded) @@ -38,17 +38,17 @@ See [last years submission][1] for more details > * 3 Points - Attendance at Council over a 3 year period as a percentage of total meetings (assessed based on sign-in records) -### Notes +#### Notes * This is mostly for Treasurer to ensure no outstanding debts. * Aside from this it relates to our actions over the past year/3 years * See [Last years section][1] for guidelines -### Details +#### Details {Add text here} -## 9. Publicity -### Instructions +### 9. Publicity +#### Instructions > * 5 Points - Collective Platform: Regular updates on ulwolves.ie (NEWS / EVENTS / ACTIVITIES / FIXTURES - these must have been entered at the time and can't be backdated) > * 4 Points - Computer Society Individual Publicity (Computer Society's own social media, text groups, email groups, posters) @@ -57,19 +57,19 @@ See [last years submission][1] for more details > > Evidence of all must be attached -### Notes +#### Notes * This is for PRO's. * Its an important reason to add the event on time to Wolves on a weekly basis. * Have links to posters (can link to this repo by using ``https://gitlab.skynet.ie/compsoc1/compsoc/open-goverance/-/tree/main/Events/2023-2024`` as a base), * Photos of emails/discord. * See [Last years section][1] for guidelines -### Details +#### Details {Add text here} -## 10. Guest Speakers +### 10. Guest Speakers -### Instructions +#### Instructions > Any speaker such as local councillors, local activists that do not satisfy the criteria of a profile speaker > > This speaker must be respected either inside or outside their field of expertise @@ -80,15 +80,15 @@ See [last years submission][1] for more details > * Accredited Academic - within UL and/or are considered one of the most eminent experts within their field > * High Profile Industry/field of speciality -### Notes +#### Notes * See [Last years section][1] for guidelines -### Details +#### Details {Add text here} -## 11. Profile Speakers -### Instructions +### 11. Profile Speakers +#### Instructions > This speaker must be respected either inside or outside their field of expertise > > Computer Society must provide a biography of the speaker detailing their achievements to date and explaining why they are a profile speaker @@ -101,16 +101,16 @@ See [last years submission][1] for more details > Any other speaker such as local councillors, local activists that do not satisfy the above would be regarded as ordinary speakers -### Notes +#### Notes * We can use SISTEM/PyCon for this * See [Last years section][1] for guidelines -### Details +#### Details {Add text here} -## 13. Showcases -### Instructions +### 13. Showcases +#### Instructions > A Showcase Event is assessed to be "SHOWCASE" if it will bring with it an increased workload and planning beyond the normal levels of the Society > @@ -125,12 +125,12 @@ See [last years submission][1] for more details > * Campus Based event -### Notes +#### Notes * We can use the joint Computer/GamesDev/Games event for this ([event details][2]) * See [Last years section][1] for guidelines [2]: https://gitlab.skynet.ie/compsoc1/compsoc/open-goverance/-/blob/main/Events/2023-2024/Semester-2_Week-12.md?ref_type=heads -### Details +#### Details {Add text here} \ No newline at end of file diff --git a/Committee/_Templates/Budget/Logo_2024.svg b/Committee/_Templates/Budget/Logo_2024.svg new file mode 100644 index 0000000..0cf5682 --- /dev/null +++ b/Committee/_Templates/Budget/Logo_2024.svg @@ -0,0 +1,230 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + COMP SOC + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Committee/_Templates/Budget/_template.md b/Committee/_Templates/Budget/_template.md new file mode 100644 index 0000000..cfeb9aa --- /dev/null +++ b/Committee/_Templates/Budget/_template.md @@ -0,0 +1,13 @@ +## {Role} +#### {Name} + +The purpose of this document is to assist the incoming CompSoc {Role} for the upcoming year {Next year, format like 2023/24}. + +### Duties +{List duties} + +### Guide +{Useful things to know about the role} + +### Summary +{Add summary} \ No newline at end of file diff --git a/Committee/_Templates/Budget/general.html b/Committee/_Templates/Budget/general.html new file mode 100644 index 0000000..4920d8d --- /dev/null +++ b/Committee/_Templates/Budget/general.html @@ -0,0 +1,38 @@ + + + + + + + {title} + + + + + + + + + + +
+ +

University of Limerick Computer Society

+ +{body} +
+ + + + + \ No newline at end of file diff --git a/Committee/_Templates/Budget/main.css b/Committee/_Templates/Budget/main.css new file mode 100644 index 0000000..80bbf67 --- /dev/null +++ b/Committee/_Templates/Budget/main.css @@ -0,0 +1,120 @@ + +/* Basic stuff */ +body { + max-width: 100ch; + margin: 0 auto; + padding: 8px; + line-height: 1.2; +} +/* To make sure the header text is always bigger than a normal h1*/ +header h1 { + font-size: 300%; +} + + +/* get these to play nicely with teh max width */ +header, main, footer, img{ + max-width: 100ch; +} + +a:link{ + color:#5bf +} +a:visited{ + color:#5bf +} + +table { + border-collapse: collapse; +} + +td, th { + border: 1px solid #999; + padding: 0.5rem; + text-align: left; +} + +li p { + margin-block-start: 0; + margin-block-end: 0; +} + +p code { + background-color: rgba(173, 173, 173, 0.26); + border-radius: 0.3em; + padding: 4px 5px 6px; +} + +pre { + max-width: 95vw; + display: block; + overflow: auto; +} + +/* navbar */ +.links ul, .breadcrumb ul { + list-style-type: none; + display: flex; + padding-left: 0; +} + +/* sticky footer */ +main { + min-height: calc(95vh - 150px); +} +footer { + min-height: 50px; +} + +/* spoilers + using https://starbeamrainbowlabs.com/blog/article.php?article=posts%2F415-pure-css-spoiler.html + as a base then using it for on hover instead of target. + Seems to work well enough for mobile as well +*/ + +.md-spoiler { + background: #333333; + border-radius: 0.2em; + color: transparent; +} +/* hover is for desktop, active for mobile*/ +.md-spoiler:hover, .md-spoiler:active { + background: transparent; + color: inherit; +} + +/* every page gets a scrollbar to stop it shifting around */ +html { + overflow-y: scroll; +} + +label, input, select { + display: table-cell; + margin-bottom: 10px; +} +/* Make hidden great again */ +[hidden] { + display: none !important; +} + + +/* Specific to handovers */ + +h1 { + color: #087581; +} + +h2 { + color: white; + background: #087581; +} + +h3 { + background: #B8F4FA; +} + +#logo { + background: white; + float: right; + margin: 0 0 0 1px; +} \ No newline at end of file diff --git a/_scripts/format_budget.sh b/_scripts/format_budget.sh new file mode 100755 index 0000000..62ffe07 --- /dev/null +++ b/_scripts/format_budget.sh @@ -0,0 +1,108 @@ +#!/usr/bin/env bash + +root="$PWD" + +folder="Budget" +folder_html="Budget_html" +folder_pdf="Budget_pdf" + +function build_html() { + # used to match ** + shopt -s globstar + + # cleanup the last run (if there was one) + rm -rf "$folder_html" + mkdir "$folder_html" + + cd Committee + + root_html="$PWD" + + # loop through each year worth of data + # the globbing is to only get ones that have a handover folder + for year in **/$folder; do + # skip symlinks + [ -L "''${year%/}" ] && continue + + if ! [[ $year =~ [0-9]{4}-[0-9]{4} ]]; then + continue + fi + + year_string=$(echo "$year" | cut -f1 -d"/") + + cd "$year_string" + + # copy in teh config for this folder + cp "../../_scripts/md_toml/_${folder}.md.toml" ./.md.toml + + # convert teh handovers + cargo-bfom + + # copy in teh relevent files + cp -R ../_Templates/$folder/* "./$folder_html" + # no need to have the template in the output + rm -f ./$folder_html/_template.md + rm -f ./$folder_html/general.html + rm -f .md.toml + + # make the final folder + mkdir -p "$root/$folder_html/$year_string" + + # copy everything to teh final folder + cp -R ./$folder_html/* "$root/$folder_html/$year_string" + + # remove teh temp folder + rm -rf "./$folder_html" + + # return to root + cd "$root_html" + done + + # undo the globbing + shopt -u globstar + + + # back to root + cd $root +} + + +function build_pdf() { + # used to match ** + shopt -s globstar + + # wipe and reset past runs + rm -rf "$folder_pdf" + mkdir "$folder_pdf" + + cd "$folder_html" + + for file in **/*.html; do + # only deal with files + if [ -f "$file" ]; then + + # .html => .pdf + output="../$folder_pdf/${file/.html/".pdf"}" + + echo $output + + # have someplace for it to go + mkdir -p $(dirname $output) + + wkhtmltopdf -q --enable-local-file-access --no-stop-slow-scripts "$file" "$output" 2>>../errors.log & + fi + done + + shopt -u globstar + cd $root + + # wait for background tasks to complete + wait $(jobs -p) +} + +if [[ $1 == "html" ]]; then + build_html +else + build_html + build_pdf +fi \ No newline at end of file diff --git a/_scripts/format_handovers.sh b/_scripts/format_handovers.sh index a79dd97..aadfe24 100755 --- a/_scripts/format_handovers.sh +++ b/_scripts/format_handovers.sh @@ -2,8 +2,9 @@ root="$PWD" -folder_html="Handovers_html" -folder_pdf="Handovers_pdf" +folder="Handovers" +folder_html="${folder}_html" +folder_pdf="${folder}_pdf" function build_html() { # used to match ** @@ -19,7 +20,7 @@ function build_html() { # loop through each year worth of data # the globbing is to only get ones that have a handover folder - for year in **/Handovers; do + for year in **/$folder; do # skip symlinks [ -L "''${year%/}" ] && continue @@ -27,31 +28,31 @@ function build_html() { continue fi - year_string="${year/\/Handovers/""}" + year_string=$(echo "$year" | cut -f1 -d"/") cd "$year_string" # copy in teh config for this folder - cp ../../_scripts/md_toml/_Handovers.md.toml ./.md.toml + cp "../../_scripts/md_toml/_${folder}.md.toml" ./.md.toml # convert teh handovers cargo-bfom # copy in teh relevent files - cp -R ../_Templates/Handovers/* ./Handovers_html + cp -R ../_Templates/$folder/* "./$folder_html" # no need to have the template in the output - rm -f ./Handovers_html/_template.md - rm -f ./Handovers_html/general.html + rm -f ./$folder_html/_template.md + rm -f ./$folder_html/general.html rm -f .md.toml # make the final folder mkdir -p "$root/$folder_html/$year_string" # copy everything to teh final folder - cp -R ./Handovers_html/* "$root/$folder_html/$year_string" + cp -R ./$folder_html/* "$root/$folder_html/$year_string" # remove teh temp folder - rm -rf ./Handovers_html + rm -rf "./$folder_html" # return to root cd "$root_html" diff --git a/_scripts/md_toml/_Budget.md.toml b/_scripts/md_toml/_Budget.md.toml new file mode 100644 index 0000000..560089f --- /dev/null +++ b/_scripts/md_toml/_Budget.md.toml @@ -0,0 +1,46 @@ + + +# How many spaces of indentation do you want? +# Defaults to 2 +# Optional +indentation = 2 + +# Optional +src = "./Budget" + +# Optional +dest= "./Budget_html" + +# html blocks you dont want to include in teh finished page +# Optional +html_void = [] + +[template] +# Templates are hjtml files that teh generated markdown is insereted into. +# There are several options on how this is carried out. + +# enable templating +# Optional +enable = true +# Set a base template +# Optional +general = "../_Templates/Budget/general.html" + +# Priority of the _templates to use, first one to match a markdown file is used. +# An Empty array below is also valid + +# general: use the general file specified above, if it exists. + +# ajacent: check if there is a template file with the same name as the markdown file ajacent to the markdown file. +# ./src/exasmple.md +# ./src/example.html + +# folder: a html file with the same name of the folder that the md resides in. +# ./src/blog/blog.html +# ./src/blog/post1.md + +# default: use an inbuilt html5 template + + +# Optional +order = ["ajacent", "general", "folder", "default"] diff --git a/flake.nix b/flake.nix index 83a7d1b..3d4abe8 100644 --- a/flake.nix +++ b/flake.nix @@ -65,6 +65,15 @@ export PATH=${pkgs.lib.makeBinPath [pkgs.wkhtmltopdf bfom.defaultPackage.x86_64-linux]}:$PATH ${./_scripts/format_minutes.sh} html ''; + + budget = pkgs.writeShellScriptBin "format_budget" '' + export PATH=${pkgs.lib.makeBinPath [pkgs.wkhtmltopdf bfom.defaultPackage.x86_64-linux]}:$PATH + ${./_scripts/format_budget.sh} + ''; + budget_html = pkgs.writeShellScriptBin "format_budget_html" '' + export PATH=${pkgs.lib.makeBinPath [pkgs.wkhtmltopdf bfom.defaultPackage.x86_64-linux]}:$PATH + ${./_scripts/format_budget.sh} html + ''; }; }); }