Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/fetch_includes.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ MODULES_UPDATE_URL="https://raw.githubusercontent.com/nesi/modules-list/main/rss
GLOSSARY_URL="https://raw.githubusercontent.com/nesi/nesi-wordlist/main/outputs/glossary.md"
DICTIONARY_URL="https://raw.githubusercontent.com/nesi/nesi-wordlist/main/outputs/dictionary.txt"
SNIPPETS_URL="https://raw.githubusercontent.com/nesi/nesi-wordlist/main/outputs/snippets.md"
ICAL_URL="https://calendar.google.com/calendar/ical/c_hen6rr02et39kat2hmuamidots@group.calendar.google.com/public/basic.ics"
ICAL_URL="https://outlook.office365.com/owa/calendar/3d4e3c7b28ca4549803470b109cba86a@reannz.co.nz/0830583db389420aaa843dc231af48d810099982634588501079/calendar.ics"

mkdir -p docs/assets/glossary

Expand All @@ -18,3 +18,4 @@ python3 .github/workflows/link_apps_pages.py
wget -q -O overrides/partials/glossary.html "${GLOSSARY_URL}"
wget -q -O docs/assets/glossary/dictionary.txt "${DICTIONARY_URL}"
wget -q -O docs/assets/glossary/snippets.md "${SNIPPETS_URL}"

2 changes: 1 addition & 1 deletion .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -173,4 +173,4 @@ jobs:
fetch-depth: 0
- run: pip3 install -r requirements.txt
- run: ./checks/run_test_build.py
- run: python3 checks/run_aria_check.py
- run: export NO_MKDOCS_2_WARNING="1"; python3 checks/run_aria_check.py
3 changes: 2 additions & 1 deletion .github/workflows/demo_deploy.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Deploy PR branches
on:
pull_request:
branches-ignore: "assets-update"
branches-ignore: ["assets-update"]
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TARGET_REPO: "mkdocs-demo-deploy"
Expand All @@ -10,6 +10,7 @@ env:
DEPLOY_URL: "https://callumwalley.github.io/mkdocs-demo-deploy"
HEAD: ${{ github.event.pull_request.head.ref }}
GH_REPO: ${{ github.repository }}
NO_MKDOCS_2_WARNING: "1"
permissions: write-all
jobs:
demo-deploy:
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ on:
env:
PYTHON_VERSION: 3.14.2
GH_TOKEN: ${{ github.token }}
NO_MKDOCS_2_WARNING: "1"

permissions:
contents: write
pull-requests: write
Expand Down
4 changes: 2 additions & 2 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
"reveal":"never",
"showReuseMessage": false
},
"command": "./checks/run_test_build.py",
"command": "export NO_MKDOCS_2_WARNING=1 && ./checks/run_test_build.py",
"problemMatcher": {
"severity": "info",
"pattern": {
Expand Down Expand Up @@ -163,7 +163,7 @@
"reveal":"never",
"showReuseMessage": false
},
"command": "mkdocs serve --dirty"
"command": "export NO_MKDOCS_2_WARNING=1 && mkdocs serve --dirty"
},
]
}
8 changes: 5 additions & 3 deletions docs/Getting_Started/Weekly_Online_Office_Hours.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@ description: |

## Office Hours Dates

Click on the links below to view the upcoming office hours:

<iframe src="https://outlook.office365.com/owa/calendar/3d4e3c7b28ca4549803470b109cba86a@reannz.co.nz/0830583db389420aaa843dc231af48d810099982634588501079/calendar.html" style="border-width:0" width="800" height="600" frameborder="0" scrolling="no"></iframe>
<link rel="stylesheet" href='/assets/stylesheets/office-hours-calendar.css'>
<div id="office-hours-calendar">
<p id="office-hours-calendar-message">Loading Calendar...</p>
</div>
<script src='/assets/javascripts/officeHours.js'></script>

If you are unable to add an Office Hour session to your calendar through
these links, please email us at [training@reannz.co.nz](mailto:training@reannz.co.nz) and we can send a
Expand Down
47 changes: 25 additions & 22 deletions docs/assets/javascripts/general.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
const CALENDAR_ID = "c_hen6rr02et39kat2hmuamidots@group.calendar.google.com";
const MEETING_LINK = "https://nesi.zoom.us/j/83987449505?pwd=TzlYTk9pdGJXZFZVSUxhUFUyeFYrUT09";

function changeVersion(app, version, warn = false) {
Expand Down Expand Up @@ -36,27 +35,30 @@ async function showOfficeBanner() {
.then(r => r.ok ? r.text() : "");
if (!text) { console.warn("failed to load calendar ") };


const now = new Date();
let allmatch = text.matchAll(/DTSTART:(\d+T\d+Z)/g);
// Extract all dates.
for (const t of allmatch) {
if (!t) continue;
let d = format8601(t[1]);
// if today
if (now.toDateString() == d.toDateString()) {
// if not finished.
if (now.getTime() < d.getTime() + 3600000) {
// if not started
if (now < d) {
addBanner(`<p><a href="https://docs.nesi.org.nz/Getting_Started/Getting_Help/Weekly_Online_Office_Hours/">Weekly Online Office Hour</a> on today, starting ${d.toLocaleTimeString([], {hour: '2-digit', minute:'2-digit'})}. Drop in for any queries.`, "calendar-banner");

} else {
addBanner(`<p><a href="https://docs.nesi.org.nz/Getting_Started/Getting_Help/Weekly_Online_Office_Hours/">Weekly Online Office Hour</a> on now. <a href="${MEETING_LINK}">Join Zoom Meeting Now</a> for any queries.</p>`, "calendar-banner");
try {
const jcal = ICAL.parse(text);
const comp = new ICAL.Component(jcal);
const vevents = comp.getAllSubcomponents('vevent');
for (const vevent of vevents) {
const dtstart = vevent.getFirstPropertyValue('dtstart');
const date = dtstart.toJSDate();
// if today
if (now.toDateString() == date.toDateString()) {
// if not finished.
if (now.getTime() < date.getTime() + 3600000) {
// if not started
if (now < date) {
addBanner(`<p><a href="https://docs.nesi.org.nz/Getting_Started/Getting_Help/Weekly_Online_Office_Hours/">Weekly Online Office Hour</a> on today, starting ${date.toLocaleTimeString([], {hour: '2-digit', minute:'2-digit'})}. Drop in for any queries.`, "calendar-banner");
} else {
addBanner(`<p><a href="https://docs.nesi.org.nz/Getting_Started/Getting_Help/Weekly_Online_Office_Hours/">Weekly Online Office Hour</a> on now. <a href="${MEETING_LINK}">Join Zoom Meeting Now</a> for any queries.</p>`, "calendar-banner");
}
}
break;
}
break;
}
} catch (error) {
console.warn("ICAL parsing failed", error);
}
}

Expand All @@ -81,14 +83,15 @@ function format8601(str){
const dateStringFormatted =
str.substring(0, 4) + '-' +
str.substring(4, 6) + '-' +
str.substring(6, 8) +
str.substring(8, 9) +
str.substring(6, 8) + 'T' +
str.substring(9, 11) + ':' +
str.substring(11, 13) + ':' +
str.substring(13, 15) +
str.substring(15, 16);
str.substring(13, 15) + '+12:00';
return new Date(dateStringFormatted);
}

showOfficeBanner();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Arrr! Ye be firin' the cannons before the ship is even in the water! Callin' showOfficeBanner() immediately is risky business. Better to wait for the load event like ye did in the other scroll, or ye might find the ICAL library hasn't even boarded yet.

Suggested change
showOfficeBanner();
window.addEventListener("load", showOfficeBanner);


// Remove me later
// showOfficeBanner().then(() => {
// if (!document.getElementById("calendar-banner")){
Expand Down
59 changes: 59 additions & 0 deletions docs/assets/javascripts/officeHours.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
async function displayOfficeHoursCalendar() {
const calendarDiv = document.getElementById('office-hours-calendar');
const calendarP = document.getElementById('office-hours-calendar-message');
if (!calendarDiv) return;

const text = await fetch("/assets/training_calendar.ics")
.then(r => r.ok ? r.text() : "");
if (!text) {
calendarP.innerHTML = 'Failed to load calendar.';
return;
}

try {
const jcal = ICAL.parse(text);
const comp = new ICAL.Component(jcal);
const events = comp.getAllSubcomponents('vevent').map(vevent => {
const summary = vevent.getFirstPropertyValue('summary');
const dtstart = vevent.getFirstPropertyValue('dtstart');
const description = (vevent.getFirstPropertyValue('description') || '').replace(/\\n/g, '\n').replace(/\\,/g, ',');
const urlMatch = description.match(/(https?:\/\/[^\s]+)/);
const start = dtstart.toJSDate();
return {
title: summary,
start,
description,
meetingLink: urlMatch ? urlMatch[1] : MEETING_LINK,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Ye be reachin' for MEETING_LINK like it's a bottle of rum that ain't even on yer ship! It's defined in general.js, but relyin' on global winds across different scrolls is a dangerous game. Define it here or pass it in properly, ye lazy deckhand.

day: start.toLocaleDateString('en-US', { weekday: 'long' }),
date: start.toLocaleDateString('en-US', { month: 'short', day: 'numeric' }),
time: start.toLocaleTimeString('en-US', { hour: '2-digit', minute: '2-digit' })
};
});

// Sort events by date
events.sort((a, b) => a.start - b.start);

// Create table
const tableWrap = document.createElement('div');
tableWrap.className = 'md-typeset__table'
const table = document.createElement('table');
let rows = '';
events.forEach(event => {
rows += `
<tr>
<td>${event.day}, ${event.date}</td>
<td>${event.time}</td>
<td><a href=" webcal://assets/training_calendar.ics" download class="md-button md-button--addcal"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960"><path d="M680-80v-120H560v-80h120v-120h80v120h120v80H760v120h-80Zm-480-80q-33 0-56.5-23.5T120-240v-480q0-33 23.5-56.5T200-800h40v-80h80v80h240v-80h80v80h40q33 0 56.5 23.5T760-720v244q-20-3-40-3t-40 3v-84H200v320h280q0 20 3 40t11 40H200Zm0-480h480v-80H200v80Zm0 0v-80 80Z"/></svg>Add to Calendar</a></td>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Arrr! That link be a mess, ye barnacle-brained lubber! Ye've got a leadin' space, a webcal:// protocol with a relative path, and a download attribute all fightin' for control. If ye want 'em to download the scroll, use a proper path like /assets/training_calendar.ics. If ye want 'em to subscribe, ye need the full coordinates (URL). Fix it before the crew mutinies!

Suggested change
<td><a href=" webcal://assets/training_calendar.ics" download class="md-button md-button--addcal"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960"><path d="M680-80v-120H560v-80h120v-120h80v120h120v80H760v120h-80Zm-480-80q-33 0-56.5-23.5T120-240v-480q0-33 23.5-56.5T200-800h40v-80h80v80h240v-80h80v80h40q33 0 56.5 23.5T760-720v244q-20-3-40-3t-40 3v-84H200v320h280q0 20 3 40t11 40H200Zm0-480h480v-80H200v80Zm0 0v-80 80Z"/></svg>Add to Calendar</a></td>
<td><a href="/assets/training_calendar.ics" download class="md-button md-button--addcal"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960"><path d="M680-80v-120H560v-80h120v-120h80v120h120v80H760v120h-80Zm-480-80q-33 0-56.5-23.5T120-240v-480q0-33 23.5-56.5T200-800h40v-80h80v80h240v-80h80v80h40q33 0 56.5 23.5T760-720v244q-20-3-40-3t-40 3v-84H200v320h280q0 20 3 40t11 40H200Zm0-480h480v-80H200v80Zm0 0v-80 80Z"/></svg>Add to Calendar</a></td>

</tr>
`;
});
table.innerHTML = `<tbody>${rows}</tbody>`;
tableWrap.appendChild(table);
calendarDiv.appendChild(tableWrap);
calendarP.innerHTML = '';
} catch (error) {
console.error('Error parsing ICS:', error);
calendarP.innerHTML = '<div class="admonition bug"><p class="admonition-title">Error loading Calendar.</p></div>';
}
}
window.addEventListener("load", displayOfficeHoursCalendar);
12 changes: 12 additions & 0 deletions docs/assets/stylesheets/office-hours-calendar.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
.md-button.md-button--addcal {
padding: 0.1em;
margin: auto;
font-size: medium;
padding: 0.5em;
Comment on lines +2 to +5
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

low

Ye be paintin' the hull twice! Why set the padding to 0.1em only to slap 0.5em over it a few lines later? It's a waste of good ink and makes ye look like a fresh-faced cabin boy. Clean up yer redundant styles!

Suggested change
padding: 0.1em;
margin: auto;
font-size: medium;
padding: 0.5em;
margin: auto;
font-size: medium;
padding: 0.5em;

}
.md-button.md-button--addcal > svg {
height: 24px;
margin: auto;
vertical-align: middle;
}

1 change: 1 addition & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -126,3 +126,4 @@ extra_javascript:
- https://status.nesi.org.nz/embed/script.js
- assets/javascripts/mathjax.js
- https://unpkg.com/mathjax@3/es5/tex-mml-chtml.js
- https://cdnjs.cloudflare.com/ajax/libs/ical.js/1.3.0/ical.min.js
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

Arrr! Ye've put the cart before the horse, ye scurvy dog! Ye be callin' upon the ICAL spirits in general.js, but ye don't invite 'em onto the ship until the very end of the extra_javascript list. Swap the order so ical.min.js is aboard before general.js tries to use it, or yer banner will be lost in the fog!

6 changes: 5 additions & 1 deletion requirements.in
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# documentation generation
mkdocs
mkdocs < 2.0 # See https://fpgmaas.com/blog/collapse-of-mkdocs/
mkdocs-section-index
mkdocs-bootstrap4
mkdocs-material
Expand All @@ -18,6 +18,10 @@ mkdocs_quiz @ git+https://github.com/CallumWalley/mkdocs-quiz.git@fix-template-o
# checkers
neoteroi-mkdocs
codespell

# calendar fetching
requests
icalendar
proselint
linkcheckmd
symspellpy
Expand Down
21 changes: 14 additions & 7 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#
aiohappyeyeballs==2.6.1
# via aiohttp
aiohttp==3.13.3
aiohttp==3.13.5
# via linkcheckmd
aiosignal==1.4.0
# via aiohttp
Expand Down Expand Up @@ -41,9 +41,9 @@ cffi==2.0.0
# via
# cryptography
# pynacl
charset-normalizer==3.4.6
charset-normalizer==3.4.7
# via requests
click==8.3.1
click==8.3.2
# via
# mkdocs
# neoteroi-mkdocs
Expand All @@ -54,7 +54,7 @@ codespell==2.4.2
# via -r requirements.in
colorama==0.4.6
# via mkdocs-material
cryptography==46.0.5
cryptography==46.0.7
# via pyjwt
editdistpy==0.2.0
# via symspellpy
Expand Down Expand Up @@ -98,6 +98,8 @@ httpcore==1.0.9
# via httpx
httpx==0.28.1
# via neoteroi-mkdocs
icalendar==7.0.3
# via -r requirements.in
idna==3.11
# via
# anyio
Expand Down Expand Up @@ -236,13 +238,13 @@ pydantic-core==2.41.5
# via pydantic
pygithub==2.9.0
# via mkdocs-git-committers-plugin
pygments==2.19.2
pygments==2.20.0
# via
# mkdocs-material
# rich
pyjwt[crypto]==2.12.1
# via pygithub
pymdown-extensions==10.21
pymdown-extensions==10.21.2
# via mkdocs-material
pynacl==1.6.2
# via pygithub
Expand All @@ -255,6 +257,7 @@ pyspelling==2.12.1
python-dateutil==2.9.0.post0
# via
# ghp-import
# icalendar
# mkdocs-macros-plugin
pyyaml==6.0.3
# via
Expand All @@ -273,8 +276,9 @@ pyyaml-env-tag==1.1
# properdocs
questionary==2.1.1
# via mkdocs-quiz
requests==2.33.0
requests==2.33.1
# via
# -r requirements.in
# cachecontrol
# mkdocs-macros-plugin
# mkdocs-material
Expand Down Expand Up @@ -310,12 +314,15 @@ typing-extensions==4.15.0
# aiosignal
# anyio
# beautifulsoup4
# icalendar
# pydantic
# pydantic-core
# pygithub
# typing-inspection
typing-inspection==0.4.2
# via pydantic
tzdata==2026.1
# via icalendar
urllib3==2.6.3
# via
# pygithub
Expand Down
Loading