Skip to content

Commit 85b712e

Browse files
committed
Clean up repo
1 parent a8c1e02 commit 85b712e

11 files changed

Lines changed: 59 additions & 40 deletions

File tree

.cursor/rules/library-of-time-core.mdc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ alwaysApply: true
88
- **Tech constraints**
99
- Use only vanilla HTML, JavaScript, and CSS.
1010
- Do not introduce build tools, frameworks, or dependencies.
11-
- Do not add new external scripts, CDNs, or APIs beyond the existing `masonry.pkgd.min.js` file.
11+
- Do not add new external scripts, CDNs, or APIs beyond the existing `UserInterface/masonry.pkgd.min.js` file.
1212
- The site must continue to work when `index.html` is opened directly from disk.
1313

1414
- **Deployment model**

.cursor/skills/add-calendar-system/SKILL.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,13 @@ Each step below is required unless explicitly skipped by the user.
4646
- **Accuracy** (stub section).
4747
- **Source** (stub section).
4848
- Keep all sections present even if their bodies are just short placeholder sentences, and add **no detailed content** unless the user explicitly requested text (respect the project’s `Docs/` rule).
49-
3. Ensure the new file is referenced in `Docs/src/SUMMARY.md` under the right section, so `buildNodeData.js` will include it.
49+
3. Ensure the new file is referenced in `Docs/src/SUMMARY.md` under the right section, so `actions/buildNodeData.js` will include it.
5050

5151
### Reference tables in `#### Info` (months, weekdays, alignment)
5252

5353
When adding **month names**, **weekday names**, or similar reference material:
5454

55-
- Use **markdown tables** with a **header row** (required for mdBook and `buildNodeData.js` table conversion).
55+
- Use **markdown tables** with a **header row** (required for mdBook and `actions/buildNodeData.js` table conversion).
5656
- **Months:** Include month order/number, **days per month** (or an explicit rule when lengths vary), and **names**. If names are given in a **non-Latin script**, include a **Latin transliteration** column (or Latin-letter names) beside the native script so readers can parse the table without the script.
5757
- **Weekdays:** Include order (e.g. Sunday first) and names; state in the header if the week **starts on a different day** than Sunday.
5858
- **Approximate Gregorian alignment:** Add a column, footnote row, or small separate table **only when** the calendar maps in a stable, documentable way to Gregorian months or seasons. When there is **no** meaningful fixed mapping (e.g. a **drifting** 365-day solar year, or a lunar/lunisolar calendar unrelated to Gregorian months), use a one-row table or single cell with **Not applicable** (or an em dash)—**do not** invent long explanatory prose unless the user explicitly asks for body copy.
@@ -64,7 +64,7 @@ When adding **month names**, **weekday names**, or similar reference material:
6464

6565
1. Run the build pipeline to regenerate `Content/nodeData.js` and the mdBook output, typically via:
6666
- `bash build.sh`
67-
- or directly `node buildNodeData.js` if only `Content/nodeData.js` is needed.
67+
- or directly `node actions/buildNodeData.js` if only `Content/nodeData.js` is needed.
6868
2. **Do not edit** `Content/nodeData.js` by hand; it is generated.
6969
3. After the build, locate the new node entry in `Content/nodeData.js`:
7070
- Search by the doc filename or title.
@@ -154,7 +154,7 @@ The main grid and `nodeUpdate.js` are not enough for the **Calendar View** side
154154
Before considering a new calendar/time system “hooked up”, confirm:
155155

156156
- [ ] A Docs stub exists in `Docs/src/...` with title/outline and is referenced from `Docs/src/SUMMARY.md`.
157-
- [ ] `Content/nodeData.js` has been regenerated (via `build.sh` or `buildNodeData.js`), and the node id is known.
157+
- [ ] `Content/nodeData.js` has been regenerated (via `build.sh` or `actions/buildNodeData.js`), and the node id is known.
158158
- [ ] A main implementation function exists in the correct `CalendarAPI/...` file, following existing patterns and conventions.
159159
- [ ] `nodeUpdate.js` calls `setTimeValue` for this node id using the main function.
160160
- [ ] **`calendarView.js`:** `buildNodeValueGetters` includes an entry for the node’s short `id` (so Calendar View cells and month shading work when that system is selected).

README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
# The Library of Time
22

3-
![Library Animated SVG](The%20Library.svg)
3+
![Library Animated SVG](actions/The%20Library.svg)
44

55
The mission of this website is to create a collection of every calendar with a verifiable date at a specific point in time, as well as other methods of timekeeping. It is to be a celebration of time as counted by humans from all walks of life, displaying all of the unique ways different people chose to satisfy one of humanity's earliest and most universal curiosities.
66

77
https://libraryoftime.xyz
88

9-
<!-- Badges: colors in readmeBadges.json; entries & test coverage from buildNodeData.js; size from release.py -->
109
![Library Entries](https://img.shields.io/badge/Library%20Entries-148-blue)
1110
![Library Size](https://img.shields.io/badge/Library%20Size-1.6%20MB-orange)
1211
![Test Coverage](https://img.shields.io/badge/Test%20Coverage-72%25-brightgreen)
@@ -27,7 +26,7 @@ This command should be run from the Docs directory. It will generate the HTML fi
2726

2827
The Library of Time is written entirely in vanilla HTML/JS/CSS. There must not be any imported packages nor external API.
2928

30-
*Currently there is one exception (masonry.pkgd.min.js) purely to make the calendar groups more pleasing to look at. The website does not need it to function and should eventually be phased out.*
29+
*Currently there is one exception (`UserInterface/masonry.pkgd.min.js`) purely to make the calendar groups more pleasing to look at. The website does not need it to function and should eventually be phased out.*
3130

3231
Calendars should be rigorously tested to ensure accuracy. These tests can be found in /Tests, and they can be run by uncommenting the following line located in runTests.js
3332

actions/README.md

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,18 @@
1-
# Bundler
2-
The `release.py` compresses the Library of Time project into a single .html file. The file can then be ran on client side without the need for a web server or even an internet connection. Specifically:
1+
# Build scripts
2+
3+
## `buildNodeData.js`
4+
5+
Generates `Content/nodeData.js` from markdown in `Docs/src`, and updates the Library Entries and Test Coverage badges in the root `README.md`. Run from the repo root via `bash build.sh` (Step 1) or:
6+
7+
```bash
8+
node actions/buildNodeData.js
9+
```
10+
11+
Badge colors are set by environment variables exported from `build.sh`.
12+
13+
## `release.py`
14+
15+
The bundler compresses the Library of Time project into a single .html file. The file can then be ran on client side without the need for a web server or even an internet connection. Specifically:
316

417
- JS files are compressed into a single string and embeded in a `<script>` tag at the bottom of the page
518
- CSS files are copied into a single `<style>` tag in the page he ader
File renamed without changes.
Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
const fs = require('fs');
1010
const path = require('path');
1111

12+
const REPO_ROOT = path.join(__dirname, '..');
13+
1214
// Map directory names to node types
1315
const directoryToType = {
1416
'StandardTime': 'Standard Time',
@@ -554,7 +556,7 @@ const typeToVariableName = {
554556

555557
// Parse SUMMARY.md to get the ordered list of files
556558
function parseSummaryForFileOrder() {
557-
const summaryPath = path.join(__dirname, 'Docs/src/SUMMARY.md');
559+
const summaryPath = path.join(REPO_ROOT, 'Docs/src/SUMMARY.md');
558560
const summaryContent = fs.readFileSync(summaryPath, 'utf8');
559561
const lines = summaryContent.split('\n');
560562

@@ -619,8 +621,20 @@ function formatNodeDataArray(nodeDataArray, variableName) {
619621
}
620622

621623
function loadReadmeBadgeConfig() {
622-
const configPath = path.join(__dirname, 'readmeBadges.json');
623-
return JSON.parse(fs.readFileSync(configPath, 'utf8'));
624+
return {
625+
libraryEntries: {
626+
altText: 'Library Entries',
627+
shieldsColor: process.env.LOT_README_BADGE_LIBRARY_ENTRIES_COLOR || 'blue',
628+
},
629+
librarySize: {
630+
altText: 'Library Size',
631+
shieldsColor: process.env.LOT_README_BADGE_LIBRARY_SIZE_COLOR || 'orange',
632+
},
633+
testCoverage: {
634+
altText: 'Test Coverage',
635+
shieldsColor: process.env.LOT_README_BADGE_TEST_COVERAGE_COLOR || 'brightgreen',
636+
},
637+
};
624638
}
625639

626640
function readmeBadgeRegex(altText) {
@@ -630,7 +644,7 @@ function readmeBadgeRegex(altText) {
630644

631645
function updateReadmeEntriesBadge(nodeCount) {
632646
const { altText, shieldsColor } = loadReadmeBadgeConfig().libraryEntries;
633-
const readmePath = path.join(__dirname, 'README.md');
647+
const readmePath = path.join(REPO_ROOT, 'README.md');
634648
const badgeUrl = `https://img.shields.io/badge/${encodeURIComponent(altText)}-${nodeCount}-${shieldsColor}`;
635649
const newLine = `![${altText}](${badgeUrl})`;
636650
const badgeRe = readmeBadgeRegex(altText);
@@ -646,7 +660,7 @@ function updateReadmeEntriesBadge(nodeCount) {
646660
}
647661

648662
function countTestSuiteFunctions() {
649-
const testsDir = path.join(__dirname, 'Tests');
663+
const testsDir = path.join(REPO_ROOT, 'Tests');
650664
const skipFiles = new Set(['runTests.js', 'runCalendarDevTests.js']);
651665
let total = 0;
652666

@@ -670,7 +684,7 @@ function updateReadmeTestCoverageBadge(testCount, entryCount) {
670684
const { altText, shieldsColor } = loadReadmeBadgeConfig().testCoverage;
671685
const percent = entryCount > 0 ? Math.round((testCount / entryCount) * 100) : 0;
672686
const badgeValue = `${percent}%`;
673-
const readmePath = path.join(__dirname, 'README.md');
687+
const readmePath = path.join(REPO_ROOT, 'README.md');
674688
const badgeUrl = `https://img.shields.io/badge/${encodeURIComponent(altText)}-${encodeURIComponent(badgeValue)}-${shieldsColor}`;
675689
const newLine = `![${altText}](${badgeUrl})`;
676690
const badgeRe = readmeBadgeRegex(altText);
@@ -687,8 +701,8 @@ function updateReadmeTestCoverageBadge(testCount, entryCount) {
687701

688702
// Main build function
689703
function build() {
690-
const docsSrcPath = path.join(__dirname, 'Docs/src');
691-
const outputPath = path.join(__dirname, 'Content', 'nodeData.js');
704+
const docsSrcPath = path.join(REPO_ROOT, 'Docs/src');
705+
const outputPath = path.join(REPO_ROOT, 'Content', 'nodeData.js');
692706

693707
console.log('Parsing SUMMARY.md for file order...');
694708
const fileOrder = parseSummaryForFileOrder();

actions/release.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,18 @@
55
import io
66
import re
77
import os
8-
import json
98
from urllib.parse import quote
109

1110
OUTPUT_DIR = 'dist'
1211

1312

1413
def load_readme_badge_config():
15-
config_path = os.path.normpath(os.path.join(os.path.dirname(__file__), '..', 'readmeBadges.json'))
16-
with open(config_path, 'r', encoding='utf-8') as config_file:
17-
return json.load(config_file)
14+
return {
15+
'librarySize': {
16+
'altText': 'Library Size',
17+
'shieldsColor': os.environ.get('LOT_README_BADGE_LIBRARY_SIZE_COLOR', 'orange'),
18+
},
19+
}
1820

1921

2022
def readme_badge_regex(alt_text):

build.sh

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
#!/bin/bash
22
# Unified build script
3-
# Runs buildNodeData.js, mdbook build, and (optionally) the single-file HTML bundler
3+
# Runs actions/buildNodeData.js, mdbook build, and (optionally) the single-file HTML bundler
44

55
set -e # Exit on error
66

77
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
88

9+
# README shields.io badge colors (names or hex without #)
10+
export LOT_README_BADGE_LIBRARY_ENTRIES_COLOR=blue
11+
export LOT_README_BADGE_LIBRARY_SIZE_COLOR=orange
12+
export LOT_README_BADGE_TEST_COVERAGE_COLOR=brightgreen
13+
914
echo "=========================================="
1015
echo " Library of Time - Build Script"
1116
echo "=========================================="
@@ -14,10 +19,10 @@ echo ""
1419
# Step 1: Build nodeData.js from markdown files
1520
echo "Step 1: Building nodeData.js from markdown files..."
1621
echo "---------------------------------------------------"
17-
node "$SCRIPT_DIR/buildNodeData.js"
22+
node "$SCRIPT_DIR/actions/buildNodeData.js"
1823

1924
if [ $? -ne 0 ]; then
20-
echo "Error: buildNodeData.js failed!"
25+
echo "Error: actions/buildNodeData.js failed!"
2126
exit 1
2227
fi
2328

index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -442,6 +442,6 @@ <h2 class="modal-panel-title">Glossary of Terms</h2>
442442
<script src="Content/nodeData.js"></script>
443443
<script src="nodeUpdate.js"></script>
444444
<script src="script.js"></script>
445-
<script src="masonry.pkgd.min.js"></script>
445+
<script src="UserInterface/masonry.pkgd.min.js"></script>
446446
</body>
447447
</html>

0 commit comments

Comments
 (0)