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
4 changes: 2 additions & 2 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ always work. Proxmox tools: `therepos/proxmox`; MCP servers: `therepos/mcp`; Cla
(knowledge-base stages `kbprofile`, `kbrcm`, `kbbundle`; plan in `apps/kbplan.md`).
- `scripts/` (repo helpers, never run by users): `sync-blocks.sh` shared blocks, `lint.sh` checks and safe
fixes, `docgen-pages.py` the script page (therepos.github.io/windows, built and deployed by CI).
- Script page: title `Windows Scripts`, one row per script (name, purpose, button: `Copy command` or `Download .<ext>`,
one width), repo link in the footer.
- Script page: title `Windows Scripts`, one row per script (name, purpose, icon buttons: copy command for
bootstrap scripts, download for every script; hover text `Copy command` / `Download .<ext>`), GitHub icon link in the footer.
Each script needs a display name in `NAMES` in `docgen-pages.py` (lint checks): Title Case words split at
word boundaries, acronyms in caps (`KB RCM`, `SMB Cache`, `Add-in Setup`).

Expand Down
63 changes: 43 additions & 20 deletions scripts/docgen-pages.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,28 @@
'zipper': 'Zipper',
}

# Inline icons (Lucide copy/download/check, GitHub mark), stroke/fill from currentColor
ICON_COPY = '<svg viewBox="0 0 24 24" aria-hidden="true"><rect width="14" height="14" x="8" y="8" rx="2"/><path d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"/></svg>'
ICON_DOWNLOAD = '<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="7 10 12 15 17 10"/><line x1="12" x2="12" y1="15" y2="3"/></svg>'
ICON_CHECK = '<svg viewBox="0 0 24 24" aria-hidden="true"><polyline points="20 6 9 17 4 12"/></svg>'
ICON_GITHUB = ('<svg class="gh" viewBox="0 0 16 16" aria-hidden="true"><path d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59'
'.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53'
'.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15'
'-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92'
'.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38'
'A8.013 8.013 0 0016 8c0-4.42-3.58-8-8-8z"/></svg>')

def actions(filename, cmd):
# the file is served from the page itself, so the browser downloads it instead of showing text
os.makedirs(os.path.join(OUT_DIR, 'apps'), exist_ok=True)
shutil.copy(os.path.join('apps', filename), os.path.join(OUT_DIR, 'apps', filename))
copy = ('<button class="ic" data-cmd="{}" title="Copy command" aria-label="Copy command">{}</button>'.format(
html.escape(cmd, quote=True), ICON_COPY) if cmd else '<span class="ic blank"></span>')
label = 'Download ' + os.path.splitext(filename)[1]
download = '<a class="ic" href="apps/{0}" download title="{1}" aria-label="{1}">{2}</a>'.format(
html.escape(filename, quote=True), label, ICON_DOWNLOAD)
return '<div class="act">{}{}</div>'.format(copy, download)

def scripts():
return [f for f in sorted(os.listdir('apps')) if os.path.splitext(f)[1] in KINDS]

Expand All @@ -69,13 +91,7 @@ def html_rows(run_by_command):
is_cmd = l1.startswith('# irm ')
if is_cmd != run_by_command:
continue
if is_cmd:
button = '<button data-cmd="{}">Copy command</button>'.format(html.escape(l1[2:], quote=True))
else:
# served from the page itself, so the browser downloads it instead of showing text
os.makedirs(os.path.join(OUT_DIR, 'apps'), exist_ok=True)
shutil.copy(os.path.join('apps', filename), os.path.join(OUT_DIR, 'apps', filename))
button = '<a class="btn" href="apps/{}" download>Download {}</a>'.format(html.escape(filename, quote=True), ext)
button = actions(filename, l1[2:] if is_cmd else '')
rows.append(row(name, purpose, button))
return '\n'.join(rows)

Expand All @@ -95,16 +111,22 @@ def html_rows(run_by_command):
.hint{color:var(--muted);margin:0 0 1rem}
input{width:100%;box-sizing:border-box;padding:10px 12px;border:1px solid var(--line);border-radius:8px;background:var(--card);color:var(--text);font-size:15px}
.list{background:var(--card);border:1px solid var(--line);border-radius:12px;overflow:hidden}
.row{display:grid;grid-template-columns:180px 1fr 140px;gap:4px 16px;align-items:center;padding:10px 14px;border-top:1px solid var(--line)}
.row{display:grid;grid-template-columns:180px 1fr auto;gap:4px 16px;align-items:center;padding:10px 14px;border-top:1px solid var(--line)}
.row:first-child{border-top:0}
.row b{font-weight:600}
.row p{margin:0;color:var(--muted);font-size:14px}
button,.btn{box-sizing:border-box;width:100%;padding:7px;text-align:center;text-decoration:none;display:block;border:1px solid var(--line);border-radius:8px;background:transparent;color:var(--text);font-size:14px;cursor:pointer}
button:hover,.btn:hover{background:var(--bg)}
button.done{color:var(--ok);border-color:var(--ok)}
footer{margin-top:2.5rem;padding-top:1rem;border-top:1px solid var(--line);color:var(--muted);font-size:14px}
footer a{color:inherit}
@media (max-width:640px){.row{grid-template-columns:1fr 140px}.row p{grid-column:1/-1;grid-row:2}}
.act{display:flex;gap:6px}
.ic{box-sizing:border-box;width:36px;height:36px;display:grid;place-items:center;padding:0;border:1px solid var(--line);border-radius:8px;background:transparent;color:var(--text);cursor:pointer}
.ic:hover{background:var(--bg)}
.ic.blank{border:0;cursor:default}
.ic.done{color:var(--ok);border-color:var(--ok)}
.ic svg,.hint svg{width:18px;height:18px;fill:none;stroke:currentColor;stroke-width:2;stroke-linecap:round;stroke-linejoin:round}
.hint svg{width:15px;height:15px;vertical-align:-2px}
footer{margin-top:2.5rem;padding-top:1rem;border-top:1px solid var(--line);display:flex;justify-content:center}
footer a{display:inline-flex;align-items:center;gap:8px;color:var(--muted);text-decoration:none;font-size:14px}
footer a:hover{color:var(--text)}
.gh{width:18px;height:18px;fill:currentColor}
@media (max-width:640px){.row{grid-template-columns:1fr auto}.row p{grid-column:1/-1;grid-row:2}}
</style>
</head>
<body>
Expand All @@ -113,7 +135,7 @@ def html_rows(run_by_command):
<p class="hint">{hint}</p>
<input id="q" type="search" placeholder="Search scripts" aria-label="Search scripts">
{sections}
<footer><a href="{repo}">{repo_label}</a></footer>
<footer><a href="{repo}">{github} GitHub</a></footer>
</main>
<script>
function copy(text){
Expand All @@ -123,9 +145,10 @@ def html_rows(run_by_command):
}
document.querySelectorAll('button[data-cmd]').forEach(function(b){
b.addEventListener('click',function(){
if (b.classList.contains('done')) return;
copy(b.dataset.cmd).then(function(){
b.textContent='Copied'; b.classList.add('done');
setTimeout(function(){ b.textContent='Copy command'; b.classList.remove('done'); },1800);
var icon=b.innerHTML; b.innerHTML='{check}'; b.classList.add('done');
setTimeout(function(){ b.innerHTML=icon; b.classList.remove('done'); },1800);
});
});
});
Expand All @@ -150,11 +173,11 @@ def section(title, rows):

def generate_html():
page = (PAGE.replace('{title}', 'Windows Scripts')
.replace('{hint}', 'Copy command: paste into PowerShell and press Enter. '
'Download: double-click the file (Python files need Python 3).')
.replace('{hint}', ICON_COPY + ' Copy the command, paste it into PowerShell and press Enter. '
+ ICON_DOWNLOAD + ' Or download the file and double-click it (.py needs Python 3).')
.replace('{sections}', section('Run in PowerShell', html_rows(True)) + '\n'
+ section('Download and Run', html_rows(False)))
.replace('{repo_label}', REPO_URL.split('//', 1)[1])
.replace('{github}', ICON_GITHUB).replace('{check}', ICON_CHECK)
.replace('{repo}', REPO_URL))
with open(OUTPUT_HTML, 'w') as out:
out.write(page)
Expand Down
Loading