feat: add three sample uploadable mini-apps

Self-contained XHTML bundles (Shift Log, Tool Library, Gratitude Wall) that
mount through the real upload/publish path and use the window.commons SDK.
Published to /api/blob and verified mounting + executing in a real browser.
This commit is contained in:
OmO Orchestrator committed 2026-11-20 02:30:03 -05:00
1 parent 812cec5281
commit 942ceda7e5
3 files changed
+280

No files matched your search

+80
View File
@@ -0,0 +1,80 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<style>
.commons-app { font-family: system-ui, sans-serif; max-width: 560px; margin: 0 auto; padding: 16px; color: #1f2329; }
.commons-app h2 { font-size: 20px; margin: 0 0 4px; }
.commons-app .sub { color: #6b7280; font-size: 13px; margin: 0 0 16px; }
.commons-app .row { display: flex; gap: 8px; margin-bottom: 8px; }
.commons-app input { flex: 1; padding: 10px; border: 1px solid #d0d5dd; border-radius: 8px; font-size: 14px; }
.commons-app #to { max-width: 160px; }
.commons-app button { background: #1677FF; color: #fff; border: 0; border-radius: 8px; padding: 10px 16px; font-size: 14px; cursor: pointer; }
.commons-app button:hover { background: #0f5ed6; }
.commons-app h3 { font-size: 15px; margin: 18px 0 8px; }
.commons-app ul { list-style: none; padding: 0; margin: 0; }
.commons-app li { border-left: 3px solid #1677FF; background: #f7faff; border-radius: 0 8px 8px 0; padding: 10px 12px; margin-bottom: 8px; font-size: 14px; }
.commons-app li .to { color: #1677FF; font-weight: 600; }
.commons-app .empty { color: #9aa1ab; font-size: 13px; padding: 12px 0; }
</style>
</head>
<body>
<div class="commons-app">
<h2>Gratitude Wall</h2>
<p class="sub">Thank a neighbour out loud. Notes are signed events on the shared log - a small ledger of goodwill.</p>
<div class="row">
<input id="to" type="text" placeholder="to (name)" />
<input id="msg" type="text" placeholder="what they did" />
<button id="post-btn" type="button">Post</button>
</div>
<h3>Recent thanks</h3>
<ul id="list"></ul>
<p id="empty" class="empty">No notes yet. Be the first to say thanks.</p>
</div>
<script>
<![CDATA[
(function () {
var api = window.commons;
var listEl = document.getElementById("list");
var emptyEl = document.getElementById("empty");
function render(entries) {
var notes = [];
for (var i = 0; i < entries.length; i++) {
var p = entries[i].payload;
if (p && p.type === "gratitude.note") { notes.push(p); }
}
emptyEl.style.display = notes.length === 0 ? "block" : "none";
listEl.innerHTML = "";
notes.slice().reverse().forEach(function (n) {
var li = document.createElement("li");
var to = document.createElement("span");
to.className = "to";
to.textContent = "To " + (n.to || "a neighbour") + ": ";
var msg = document.createElement("span");
msg.textContent = n.message || "";
li.appendChild(to);
li.appendChild(msg);
listEl.appendChild(li);
});
}
function refresh() {
api.eventlog.readAll().then(render);
}
document.getElementById("post-btn").addEventListener("click", function () {
var to = document.getElementById("to").value.trim();
var message = document.getElementById("msg").value.trim();
if (!message) { return; }
api.eventlog.append({ type: "gratitude.note", to: to, message: message }).then(function () {
document.getElementById("to").value = "";
document.getElementById("msg").value = "";
refresh();
});
});
refresh();
})();
]]>
</script>
</body>
</html>
+100
View File
@@ -0,0 +1,100 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<style>
.commons-app { font-family: system-ui, sans-serif; max-width: 560px; margin: 0 auto; padding: 16px; color: #1f2329; }
.commons-app h2 { font-size: 20px; margin: 0 0 4px; }
.commons-app .sub { color: #6b7280; font-size: 13px; margin: 0 0 16px; }
.commons-app .row { display: flex; gap: 8px; margin-bottom: 8px; }
.commons-app input, .commons-app select { flex: 1; padding: 10px; border: 1px solid #d0d5dd; border-radius: 8px; font-size: 14px; }
.commons-app button { background: #1677FF; color: #fff; border: 0; border-radius: 8px; padding: 10px 16px; font-size: 14px; cursor: pointer; }
.commons-app button:hover { background: #0f5ed6; }
.commons-app .meta { display: flex; justify-content: space-between; align-items: baseline; margin: 18px 0 8px; }
.commons-app .meta h3 { font-size: 15px; margin: 0; }
.commons-app .pill { background: #eef4ff; color: #1677FF; font-size: 12px; padding: 2px 8px; border-radius: 999px; }
.commons-app ul { list-style: none; padding: 0; margin: 0; }
.commons-app li { border: 1px solid #eef0f3; border-radius: 8px; padding: 10px 12px; margin-bottom: 6px; font-size: 14px; }
.commons-app li .who { color: #6b7280; font-size: 12px; }
.commons-app .empty { color: #9aa1ab; font-size: 13px; padding: 12px 0; }
</style>
</head>
<body>
<div class="commons-app">
<h2>Shift Log</h2>
<p class="sub">Log the civic shifts you cover in the Hollow. Every entry is a signed event on your own log.</p>
<div class="row">
<select id="role">
<option value="Pump watch">Pump watch</option>
<option value="Tunnel sweep">Tunnel sweep</option>
<option value="Kitchen">Kitchen</option>
<option value="Clinic desk">Clinic desk</option>
<option value="Night watch">Night watch</option>
</select>
<input id="hours" type="number" min="0" step="0.5" placeholder="hours" />
</div>
<div class="row">
<input id="note" type="text" placeholder="note (e.g. covering the east pump)" />
<button id="log-btn" type="button">Log shift</button>
</div>
<div class="meta">
<h3>Recent shifts</h3>
<span class="pill"><span id="total-hours">0</span> hrs logged</span>
</div>
<ul id="list"></ul>
<p id="empty" class="empty">No shifts logged yet. Log your first above.</p>
</div>
<script>
<![CDATA[
(function () {
var api = window.commons;
var listEl = document.getElementById("list");
var emptyEl = document.getElementById("empty");
var totalEl = document.getElementById("total-hours");
function render(entries) {
var shifts = [];
var total = 0;
for (var i = 0; i < entries.length; i++) {
var p = entries[i].payload;
if (p && p.type === "shiftlog.entry") {
shifts.push(p);
total += Number(p.hours) || 0;
}
}
totalEl.textContent = String(total);
emptyEl.style.display = shifts.length === 0 ? "block" : "none";
listEl.innerHTML = "";
shifts.slice().reverse().forEach(function (s) {
var li = document.createElement("li");
var strong = document.createElement("strong");
strong.textContent = s.role + " - " + (Number(s.hours) || 0) + "h";
var who = document.createElement("div");
who.className = "who";
who.textContent = s.note ? s.note : "no note";
li.appendChild(strong);
li.appendChild(who);
listEl.appendChild(li);
});
}
function refresh() {
api.eventlog.readAll().then(render);
}
document.getElementById("log-btn").addEventListener("click", function () {
var role = document.getElementById("role").value;
var hours = document.getElementById("hours").value;
var note = document.getElementById("note").value;
if (!hours || Number(hours) <= 0) { return; }
api.eventlog.append({ type: "shiftlog.entry", role: role, hours: Number(hours), note: note }).then(function () {
document.getElementById("hours").value = "";
document.getElementById("note").value = "";
refresh();
});
});
refresh();
})();
]]>
</script>
</body>
</html>
+100
View File
@@ -0,0 +1,100 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<style>
.commons-app { font-family: system-ui, sans-serif; max-width: 560px; margin: 0 auto; padding: 16px; color: #1f2329; }
.commons-app h2 { font-size: 20px; margin: 0 0 4px; }
.commons-app .sub { color: #6b7280; font-size: 13px; margin: 0 0 16px; }
.commons-app .row { display: flex; gap: 8px; margin-bottom: 8px; }
.commons-app input { flex: 1; padding: 10px; border: 1px solid #d0d5dd; border-radius: 8px; font-size: 14px; }
.commons-app button { background: #1677FF; color: #fff; border: 0; border-radius: 8px; padding: 10px 16px; font-size: 14px; cursor: pointer; }
.commons-app button:hover { background: #0f5ed6; }
.commons-app h3 { font-size: 15px; margin: 18px 0 8px; }
.commons-app ul { list-style: none; padding: 0; margin: 0; }
.commons-app li { display: flex; justify-content: space-between; align-items: center; border: 1px solid #eef0f3; border-radius: 8px; padding: 10px 12px; margin-bottom: 6px; font-size: 14px; }
.commons-app li.out { background: #fff7ed; border-color: #fed7aa; }
.commons-app li .tag { font-size: 12px; color: #6b7280; }
.commons-app li button { padding: 6px 10px; font-size: 12px; }
.commons-app li.out button { background: #16a34a; }
.commons-app .empty { color: #9aa1ab; font-size: 13px; padding: 12px 0; }
</style>
</head>
<body>
<div class="commons-app">
<h2>Tool Library</h2>
<p class="sub">Shared tools in the Hollow. Borrow one, return it when you are done - every move is a signed event.</p>
<div class="row">
<input id="tool" type="text" placeholder="tool name (e.g. torque wrench)" />
<button id="add-btn" type="button">Check out</button>
</div>
<h3>Tools</h3>
<ul id="list"></ul>
<p id="empty" class="empty">No tools tracked yet. Check one out above.</p>
</div>
<script>
<![CDATA[
(function () {
var api = window.commons;
var listEl = document.getElementById("list");
var emptyEl = document.getElementById("empty");
function statusByTool(entries) {
var state = {};
for (var i = 0; i < entries.length; i++) {
var p = entries[i].payload;
if (!p || !p.tool) { continue; }
if (p.type === "toollibrary.borrow") { state[p.tool] = "out"; }
else if (p.type === "toollibrary.return") { state[p.tool] = "in"; }
}
return state;
}
function move(tool, type) {
api.eventlog.append({ type: type, tool: tool }).then(refresh);
}
function render(entries) {
var state = statusByTool(entries);
var tools = Object.keys(state).sort();
emptyEl.style.display = tools.length === 0 ? "block" : "none";
listEl.innerHTML = "";
tools.forEach(function (tool) {
var isOut = state[tool] === "out";
var li = document.createElement("li");
if (isOut) { li.className = "out"; }
var left = document.createElement("div");
var name = document.createElement("div");
name.textContent = tool;
var tag = document.createElement("div");
tag.className = "tag";
tag.textContent = isOut ? "checked out" : "available";
left.appendChild(name);
left.appendChild(tag);
var btn = document.createElement("button");
btn.type = "button";
btn.textContent = isOut ? "Return" : "Borrow";
btn.addEventListener("click", function () {
move(tool, isOut ? "toollibrary.return" : "toollibrary.borrow");
});
li.appendChild(left);
li.appendChild(btn);
listEl.appendChild(li);
});
}
function refresh() {
api.eventlog.readAll().then(render);
}
document.getElementById("add-btn").addEventListener("click", function () {
var tool = document.getElementById("tool").value.trim();
if (!tool) { return; }
document.getElementById("tool").value = "";
move(tool, "toollibrary.borrow");
});
refresh();
})();
]]>
</script>
</body>
</html>