@a83/orbiter-admin 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +115 -0
- package/package.json +33 -0
- package/public/admin-utils.js +302 -0
- package/public/build.html +129 -0
- package/public/collections.html +100 -0
- package/public/dashboard.html +478 -0
- package/public/editor.html +1569 -0
- package/public/entries.html +367 -0
- package/public/favicon.svg +6 -0
- package/public/import.html +514 -0
- package/public/login.html +76 -0
- package/public/media.html +233 -0
- package/public/router.js +142 -0
- package/public/schema.html +366 -0
- package/public/search.js +209 -0
- package/public/settings.html +688 -0
- package/public/sidebar.js +90 -0
- package/public/style.css +1020 -0
- package/public/theme.js +63 -0
- package/public/users.html +192 -0
- package/src/index.js +4 -0
- package/src/middleware/auth.js +20 -0
- package/src/routes/account.js +41 -0
- package/src/routes/auth.js +55 -0
- package/src/routes/build.js +25 -0
- package/src/routes/collections.js +65 -0
- package/src/routes/entries.js +103 -0
- package/src/routes/github.js +133 -0
- package/src/routes/import.js +120 -0
- package/src/routes/info.js +19 -0
- package/src/routes/media.js +95 -0
- package/src/routes/meta.js +54 -0
- package/src/routes/search.js +62 -0
- package/src/routes/users.js +46 -0
- package/src/server.js +85 -0
- package/src/wp-importer.js +299 -0
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* sidebar.js — dynamically populates collection links + pod footer in every page.
|
|
3
|
+
* Supports parent/child hierarchy (matching SidebarCollections.astro in the original).
|
|
4
|
+
*/
|
|
5
|
+
(function () {
|
|
6
|
+
document.addEventListener('DOMContentLoaded', function () {
|
|
7
|
+
var params = new URLSearchParams(location.search);
|
|
8
|
+
var activeCol = params.get('col') || params.get('collection');
|
|
9
|
+
var page = location.pathname.split('/').pop().replace('.html', '');
|
|
10
|
+
|
|
11
|
+
fetch('/api/info', { credentials: 'include' })
|
|
12
|
+
.then(function (r) { return r.ok ? r.json() : null; })
|
|
13
|
+
.then(function (info) {
|
|
14
|
+
if (!info) return;
|
|
15
|
+
|
|
16
|
+
var sidebar = document.querySelector('.sidebar');
|
|
17
|
+
if (!sidebar) return;
|
|
18
|
+
|
|
19
|
+
// Find "Assets" nav-section to insert before it
|
|
20
|
+
var sections = sidebar.querySelectorAll('.nav-section');
|
|
21
|
+
var assetsSection = null;
|
|
22
|
+
for (var i = 0; i < sections.length; i++) {
|
|
23
|
+
if (sections[i].textContent.trim() === 'Assets') {
|
|
24
|
+
assetsSection = sections[i];
|
|
25
|
+
break;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
if (!assetsSection) return;
|
|
29
|
+
|
|
30
|
+
var collections = info.collections || [];
|
|
31
|
+
|
|
32
|
+
// Build parent→children map
|
|
33
|
+
var topLevel = collections.filter(function (c) { return !c.parent; });
|
|
34
|
+
var childMap = {};
|
|
35
|
+
collections.filter(function (c) { return c.parent; }).forEach(function (c) {
|
|
36
|
+
if (!childMap[c.parent]) childMap[c.parent] = [];
|
|
37
|
+
childMap[c.parent].push(c);
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
var frag = document.createDocumentFragment();
|
|
41
|
+
|
|
42
|
+
topLevel.forEach(function (col) {
|
|
43
|
+
var isActive = (page === 'entries') && activeCol === col.id;
|
|
44
|
+
var a = document.createElement('a');
|
|
45
|
+
a.className = 'nav-item' + (isActive ? ' active' : '');
|
|
46
|
+
a.href = '/entries.html?col=' + encodeURIComponent(col.id) + '&label=' + encodeURIComponent(col.label);
|
|
47
|
+
a.innerHTML =
|
|
48
|
+
'<span class="nav-icon">▤</span>' +
|
|
49
|
+
'<span class="nav-label">' + col.label + '</span>' +
|
|
50
|
+
'<span class="nav-badge">' + col.total + '</span>';
|
|
51
|
+
frag.appendChild(a);
|
|
52
|
+
|
|
53
|
+
// Children
|
|
54
|
+
var kids = childMap[col.id] || [];
|
|
55
|
+
if (kids.length > 0) {
|
|
56
|
+
var children = document.createElement('div');
|
|
57
|
+
children.className = 'nav-children';
|
|
58
|
+
kids.forEach(function (kid) {
|
|
59
|
+
var isKidActive = (page === 'entries') && activeCol === kid.id;
|
|
60
|
+
var ka = document.createElement('a');
|
|
61
|
+
ka.className = 'nav-item nav-child' + (isKidActive ? ' active' : '');
|
|
62
|
+
ka.href = '/entries.html?col=' + encodeURIComponent(kid.id) + '&label=' + encodeURIComponent(kid.label);
|
|
63
|
+
ka.innerHTML =
|
|
64
|
+
'<span class="nav-icon">◦</span>' +
|
|
65
|
+
'<span class="nav-label">' + kid.label + '</span>' +
|
|
66
|
+
'<span class="nav-badge">' + kid.total + '</span>';
|
|
67
|
+
children.appendChild(ka);
|
|
68
|
+
});
|
|
69
|
+
frag.appendChild(children);
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
assetsSection.parentNode.insertBefore(frag, assetsSection);
|
|
74
|
+
|
|
75
|
+
// Update sidebar footer: pod filename
|
|
76
|
+
var podNameEl = sidebar.querySelector('#pod-name');
|
|
77
|
+
if (podNameEl && info.podPath) {
|
|
78
|
+
podNameEl.textContent = info.podPath.split('/').pop();
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// pod-info line
|
|
82
|
+
var podInfoEl = sidebar.querySelector('#pod-info');
|
|
83
|
+
if (podInfoEl) {
|
|
84
|
+
var total = collections.reduce(function (s, c) { return s + c.total; }, 0);
|
|
85
|
+
podInfoEl.textContent = collections.length + ' collections · ' + total + ' entries';
|
|
86
|
+
}
|
|
87
|
+
})
|
|
88
|
+
.catch(function () {});
|
|
89
|
+
});
|
|
90
|
+
})();
|