@abraca/junis 2.80.0 → 2.82.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 +20 -9
- package/dist/module.json +1 -1
- package/dist/module.mjs +47 -18
- package/dist/runtime/assets/css/jun.css +1 -1
- package/dist/runtime/components/JunSettings.client.d.vue.ts +3 -0
- package/dist/runtime/components/JunSettings.client.vue +195 -0
- package/dist/runtime/components/JunSettings.client.vue.d.ts +3 -0
- package/dist/runtime/components/JunStudioBar.client.vue +11 -23
- package/dist/runtime/components/renderers/JunConfigRenderer.d.vue.ts +13 -0
- package/dist/runtime/components/renderers/JunConfigRenderer.vue +54 -21
- package/dist/runtime/components/renderers/JunConfigRenderer.vue.d.ts +13 -0
- package/dist/runtime/components/renderers/JunStatsRenderer.vue +280 -74
- package/dist/runtime/composables/useJunCommands.js +15 -12
- package/dist/runtime/composables/useJunDocPage.d.ts +8 -1
- package/dist/runtime/composables/useJunDocPage.js +6 -4
- package/dist/runtime/composables/useJunRename.js +6 -5
- package/dist/runtime/composables/useJunSettings.d.ts +24 -0
- package/dist/runtime/composables/useJunSettings.js +48 -0
- package/dist/runtime/composables/useJunSiteConfig.d.ts +69 -27
- package/dist/runtime/composables/useJunSiteConfig.js +62 -53
- package/dist/runtime/composables/useJunViewingAccent.d.ts +0 -1
- package/dist/runtime/composables/useJunViewingAccent.js +1 -1
- package/dist/runtime/layouts/jun.vue +18 -2
- package/dist/runtime/pages/index.vue +18 -8
- package/dist/runtime/plugins/jun-site-config.d.ts +17 -0
- package/dist/runtime/plugins/jun-site-config.js +26 -0
- package/dist/runtime/server/api/resolve/[...slug].get.d.ts +15 -1
- package/dist/runtime/server/api/resolve/[...slug].get.js +24 -2
- package/dist/runtime/server/api/stats.get.d.ts +27 -0
- package/dist/runtime/server/api/stats.get.js +35 -8
- package/dist/runtime/server/plugins/jun-bootstrap.js +40 -12
- package/dist/runtime/server/plugins/jun-doc-cache.js +44 -3
- package/dist/runtime/server/tasks/jun-register-tree.d.ts +16 -0
- package/dist/runtime/server/tasks/jun-register-tree.js +22 -0
- package/dist/runtime/server/utils/junActivity.d.ts +15 -0
- package/dist/runtime/server/utils/junActivity.js +71 -0
- package/dist/runtime/server/utils/junActivityMath.d.ts +61 -0
- package/dist/runtime/server/utils/junActivityMath.js +31 -0
- package/dist/runtime/server/utils/junCache.d.ts +30 -12
- package/dist/runtime/server/utils/junCache.js +13 -2
- package/dist/runtime/server/utils/junRegisterTree.d.ts +59 -0
- package/dist/runtime/server/utils/junRegisterTree.js +76 -0
- package/dist/runtime/server/utils/junServiceFetch.js +1 -1
- package/dist/runtime/server/utils/junSlugAlias.d.ts +42 -0
- package/dist/runtime/server/utils/junSlugAlias.js +14 -0
- package/dist/runtime/types.d.ts +1 -1
- package/package.json +2 -1
- package/dist/runtime/components/renderers/JunWindowRenderer.d.vue.ts +0 -10
- package/dist/runtime/components/renderers/JunWindowRenderer.vue +0 -516
- package/dist/runtime/components/renderers/JunWindowRenderer.vue.d.ts +0 -10
|
@@ -7,11 +7,10 @@ import {
|
|
|
7
7
|
junCampfireLabel,
|
|
8
8
|
junCampfireReactions,
|
|
9
9
|
useAbracadabra,
|
|
10
|
-
useChildTree,
|
|
11
|
-
useDocTree,
|
|
12
10
|
useJunBackdrop,
|
|
13
11
|
useJunBackgroundImage,
|
|
14
12
|
useJunOptions,
|
|
13
|
+
useJunSiteConfig,
|
|
15
14
|
useJunStudio,
|
|
16
15
|
useJunUpload
|
|
17
16
|
} from "#imports";
|
|
@@ -20,19 +19,16 @@ const props = defineProps({
|
|
|
20
19
|
docLabel: { type: String, required: false },
|
|
21
20
|
docMeta: { type: Object, required: false },
|
|
22
21
|
childProvider: { type: null, required: false },
|
|
23
|
-
editable: { type: Boolean, required: false }
|
|
22
|
+
editable: { type: Boolean, required: false },
|
|
23
|
+
section: { type: String, required: false },
|
|
24
|
+
bare: { type: Boolean, required: false }
|
|
24
25
|
});
|
|
25
26
|
const route = useRoute();
|
|
26
27
|
const abra = useAbracadabra();
|
|
27
|
-
const tree = useChildTree(abra.doc, props.docId);
|
|
28
|
-
const { getEntry } = useDocTree();
|
|
29
28
|
const { editing, canEdit } = useJunStudio();
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
function set(patch) {
|
|
34
|
-
tree.updateMeta(props.docId, patch);
|
|
35
|
-
}
|
|
29
|
+
const site = useJunSiteConfig();
|
|
30
|
+
const config = site.config;
|
|
31
|
+
const set = site.set;
|
|
36
32
|
function setText(key, e) {
|
|
37
33
|
const value = e.target.value.trim();
|
|
38
34
|
set({ [key]: value || void 0 });
|
|
@@ -495,6 +491,9 @@ const campfireNoPanels = computed(
|
|
|
495
491
|
const cardBase = "group flex flex-col items-center justify-center gap-1.5 rounded-lg px-2 py-3 text-center ring-1 transition-all duration-150 select-none w-full disabled:opacity-50 disabled:pointer-events-none";
|
|
496
492
|
const cardOff = "ring-black/10 dark:ring-white/10 hover:ring-black/25 dark:hover:ring-white/25 hover:bg-black/[0.03] dark:hover:bg-white/[0.04] cursor-pointer";
|
|
497
493
|
const cardOn = "ring-2 ring-black dark:ring-white bg-black/[0.04] dark:bg-white/[0.06]";
|
|
494
|
+
function shows(id) {
|
|
495
|
+
return !props.section || props.section === id;
|
|
496
|
+
}
|
|
498
497
|
</script>
|
|
499
498
|
|
|
500
499
|
<template>
|
|
@@ -505,9 +504,11 @@ const cardOn = "ring-2 ring-black dark:ring-white bg-black/[0.04] dark:bg-white/
|
|
|
505
504
|
|
|
506
505
|
<div
|
|
507
506
|
v-else
|
|
508
|
-
class="
|
|
507
|
+
class="w-full"
|
|
508
|
+
:class="bare ? '' : 'mx-auto max-w-3xl px-4 pb-24 sm:px-6'"
|
|
509
509
|
>
|
|
510
510
|
<JunPageHero
|
|
511
|
+
v-if="!bare"
|
|
511
512
|
title="Site settings"
|
|
512
513
|
subtitle="How this site presents itself. Every change is a CRDT write — live on every open tab, yours and every visitor's."
|
|
513
514
|
>
|
|
@@ -525,9 +526,13 @@ const cardOn = "ring-2 ring-black dark:ring-white bg-black/[0.04] dark:bg-white/
|
|
|
525
526
|
</template>
|
|
526
527
|
</JunPageHero>
|
|
527
528
|
|
|
528
|
-
<div class="mt-10 space-y-8">
|
|
529
|
+
<div :class="bare ? 'space-y-8' : 'mt-10 space-y-8'">
|
|
529
530
|
<!-- Identity -->
|
|
530
|
-
<section
|
|
531
|
+
<section
|
|
532
|
+
v-if="shows('identity')"
|
|
533
|
+
class="space-y-5"
|
|
534
|
+
:class="bare ? '' : 'jun-card rounded-2xl p-6'"
|
|
535
|
+
>
|
|
531
536
|
<header class="flex items-start gap-3">
|
|
532
537
|
<span class="flex size-9 flex-none items-center justify-center rounded-lg bg-black/5 dark:bg-white/10">
|
|
533
538
|
<UIcon
|
|
@@ -594,7 +599,11 @@ const cardOn = "ring-2 ring-black dark:ring-white bg-black/[0.04] dark:bg-white/
|
|
|
594
599
|
</section>
|
|
595
600
|
|
|
596
601
|
<!-- Navigation -->
|
|
597
|
-
<section
|
|
602
|
+
<section
|
|
603
|
+
v-if="shows('navigation')"
|
|
604
|
+
class="space-y-5"
|
|
605
|
+
:class="bare ? '' : 'jun-card rounded-2xl p-6'"
|
|
606
|
+
>
|
|
598
607
|
<header class="flex items-start gap-3">
|
|
599
608
|
<span class="flex size-9 flex-none items-center justify-center rounded-lg bg-black/5 dark:bg-white/10">
|
|
600
609
|
<UIcon
|
|
@@ -955,7 +964,11 @@ const cardOn = "ring-2 ring-black dark:ring-white bg-black/[0.04] dark:bg-white/
|
|
|
955
964
|
</section>
|
|
956
965
|
|
|
957
966
|
<!-- Brand mark -->
|
|
958
|
-
<section
|
|
967
|
+
<section
|
|
968
|
+
v-if="shows('mark')"
|
|
969
|
+
class="space-y-5"
|
|
970
|
+
:class="bare ? '' : 'jun-card rounded-2xl p-6'"
|
|
971
|
+
>
|
|
959
972
|
<header class="flex items-start gap-3">
|
|
960
973
|
<span class="flex size-9 flex-none items-center justify-center rounded-lg bg-black/5 dark:bg-white/10">
|
|
961
974
|
<UIcon
|
|
@@ -1020,7 +1033,11 @@ const cardOn = "ring-2 ring-black dark:ring-white bg-black/[0.04] dark:bg-white/
|
|
|
1020
1033
|
</section>
|
|
1021
1034
|
|
|
1022
1035
|
<!-- Theme -->
|
|
1023
|
-
<section
|
|
1036
|
+
<section
|
|
1037
|
+
v-if="shows('theme')"
|
|
1038
|
+
class="space-y-5"
|
|
1039
|
+
:class="bare ? '' : 'jun-card rounded-2xl p-6'"
|
|
1040
|
+
>
|
|
1024
1041
|
<header class="flex items-start gap-3">
|
|
1025
1042
|
<span class="flex size-9 flex-none items-center justify-center rounded-lg bg-black/5 dark:bg-white/10">
|
|
1026
1043
|
<UIcon
|
|
@@ -1418,7 +1435,11 @@ const cardOn = "ring-2 ring-black dark:ring-white bg-black/[0.04] dark:bg-white/
|
|
|
1418
1435
|
</section>
|
|
1419
1436
|
|
|
1420
1437
|
<!-- Announcement -->
|
|
1421
|
-
<section
|
|
1438
|
+
<section
|
|
1439
|
+
v-if="shows('announcement')"
|
|
1440
|
+
class="space-y-5"
|
|
1441
|
+
:class="bare ? '' : 'jun-card rounded-2xl p-6'"
|
|
1442
|
+
>
|
|
1422
1443
|
<header class="flex items-start gap-3">
|
|
1423
1444
|
<span class="flex size-9 flex-none items-center justify-center rounded-lg bg-black/5 dark:bg-white/10">
|
|
1424
1445
|
<UIcon
|
|
@@ -1469,7 +1490,11 @@ const cardOn = "ring-2 ring-black dark:ring-white bg-black/[0.04] dark:bg-white/
|
|
|
1469
1490
|
</section>
|
|
1470
1491
|
|
|
1471
1492
|
<!-- User Center -->
|
|
1472
|
-
<section
|
|
1493
|
+
<section
|
|
1494
|
+
v-if="shows('campfire')"
|
|
1495
|
+
class="space-y-5"
|
|
1496
|
+
:class="bare ? '' : 'jun-card rounded-2xl p-6'"
|
|
1497
|
+
>
|
|
1473
1498
|
<header class="flex items-start gap-3">
|
|
1474
1499
|
<!-- The section wears the site's own name and mark for it: this is
|
|
1475
1500
|
the one place both are edited, so it doubles as their preview. -->
|
|
@@ -1898,7 +1923,11 @@ const cardOn = "ring-2 ring-black dark:ring-white bg-black/[0.04] dark:bg-white/
|
|
|
1898
1923
|
</section>
|
|
1899
1924
|
|
|
1900
1925
|
<!-- Footer -->
|
|
1901
|
-
<section
|
|
1926
|
+
<section
|
|
1927
|
+
v-if="shows('footer')"
|
|
1928
|
+
class="space-y-5"
|
|
1929
|
+
:class="bare ? '' : 'jun-card rounded-2xl p-6'"
|
|
1930
|
+
>
|
|
1902
1931
|
<header class="flex items-start gap-3">
|
|
1903
1932
|
<span class="flex size-9 flex-none items-center justify-center rounded-lg bg-black/5 dark:bg-white/10">
|
|
1904
1933
|
<UIcon
|
|
@@ -1944,7 +1973,11 @@ const cardOn = "ring-2 ring-black dark:ring-white bg-black/[0.04] dark:bg-white/
|
|
|
1944
1973
|
</section>
|
|
1945
1974
|
|
|
1946
1975
|
<!-- Visitors -->
|
|
1947
|
-
<section
|
|
1976
|
+
<section
|
|
1977
|
+
v-if="shows('visitors')"
|
|
1978
|
+
class="space-y-5"
|
|
1979
|
+
:class="bare ? '' : 'jun-card rounded-2xl p-6'"
|
|
1980
|
+
>
|
|
1948
1981
|
<header class="flex items-start gap-3">
|
|
1949
1982
|
<span class="flex size-9 flex-none items-center justify-center rounded-lg bg-black/5 dark:bg-white/10">
|
|
1950
1983
|
<UIcon
|
|
@@ -1,9 +1,22 @@
|
|
|
1
|
+
import type { JunSettingsSection } from '../../composables/useJunSettings.js';
|
|
1
2
|
type __VLS_Props = {
|
|
2
3
|
docId: string;
|
|
3
4
|
docLabel?: string;
|
|
4
5
|
docMeta?: Record<string, unknown>;
|
|
5
6
|
childProvider?: unknown;
|
|
6
7
|
editable?: boolean;
|
|
8
|
+
/**
|
|
9
|
+
* Render ONE section instead of the whole page.
|
|
10
|
+
*
|
|
11
|
+
* `<JunSettings>` mounts this inside a modal and drives the section from its
|
|
12
|
+
* rail; the page form (a legacy `jun-config` document, still routable) leaves
|
|
13
|
+
* it unset and stacks all eight as before. Two surfaces, one source — the
|
|
14
|
+
* alternative was eight section components and a second copy of the
|
|
15
|
+
* vocabularies, the two-way state and the upload handling that feed them.
|
|
16
|
+
*/
|
|
17
|
+
section?: JunSettingsSection;
|
|
18
|
+
/** Suppress the page hero. The modal supplies its own header. */
|
|
19
|
+
bare?: boolean;
|
|
7
20
|
};
|
|
8
21
|
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
9
22
|
declare const _default: typeof __VLS_export;
|
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
useChildTree,
|
|
8
8
|
useDocTree,
|
|
9
9
|
useJunOptions,
|
|
10
|
+
useJunPageType,
|
|
10
11
|
useJunRename,
|
|
11
12
|
useJunStudio,
|
|
12
13
|
useJunTravellers
|
|
@@ -26,11 +27,14 @@ const { entries, getEntry } = useDocTree();
|
|
|
26
27
|
const { editing } = useJunStudio();
|
|
27
28
|
const { renameDoc } = useJunRename();
|
|
28
29
|
const { travellers } = useJunTravellers();
|
|
30
|
+
const { labelForType } = useJunPageType();
|
|
29
31
|
const types = computed(() => opts.typeIds);
|
|
30
32
|
const pageTitle = computed(() => getEntry(props.docId)?.label ?? props.docLabel ?? "Pulse");
|
|
33
|
+
const pageMeta = computed(
|
|
34
|
+
() => getEntry(props.docId)?.meta ?? props.docMeta ?? {}
|
|
35
|
+
);
|
|
31
36
|
const subtitle = computed(() => {
|
|
32
|
-
const
|
|
33
|
-
const ex = meta?.excerpt ?? props.docMeta?.excerpt;
|
|
37
|
+
const ex = pageMeta.value.excerpt;
|
|
34
38
|
return typeof ex === "string" && ex.trim() ? ex : void 0;
|
|
35
39
|
});
|
|
36
40
|
function renamePage(t) {
|
|
@@ -54,9 +58,11 @@ const treeLive = computed(() => liveEntries.value.length > 0);
|
|
|
54
58
|
const byId = computed(() => new Map(
|
|
55
59
|
(entries.value ?? []).map((e) => [e.id, e])
|
|
56
60
|
));
|
|
61
|
+
const WEEK = 7 * 864e5;
|
|
57
62
|
const live = computed(() => {
|
|
58
63
|
if (!treeLive.value) return null;
|
|
59
64
|
const t = types.value;
|
|
65
|
+
const weekAgo = Date.now() - WEEK;
|
|
60
66
|
let pages = 0;
|
|
61
67
|
let journalEntries = 0;
|
|
62
68
|
let livePosts = 0;
|
|
@@ -64,10 +70,14 @@ const live = computed(() => {
|
|
|
64
70
|
let signatures = 0;
|
|
65
71
|
let appreciations = 0;
|
|
66
72
|
let newestEdit = 0;
|
|
73
|
+
let oldestPage = 0;
|
|
74
|
+
let pagesThisWeek = 0;
|
|
75
|
+
const byType = {};
|
|
67
76
|
for (const e of liveEntries.value) {
|
|
68
77
|
pages++;
|
|
69
78
|
if (t.entry && e.type === t.entry) journalEntries++;
|
|
70
79
|
if (t.now && e.type === t.now) livePosts++;
|
|
80
|
+
if (e.type) byType[e.type] = (byType[e.type] ?? 0) + 1;
|
|
71
81
|
const parent = e.parentId ? byId.value.get(e.parentId) : void 0;
|
|
72
82
|
if (t.wall && parent?.type === t.wall && e.meta?.coverUploadId) photos++;
|
|
73
83
|
if (t.guestbook && parent?.type === t.guestbook && typeof e.meta?.message === "string") {
|
|
@@ -75,8 +85,22 @@ const live = computed(() => {
|
|
|
75
85
|
}
|
|
76
86
|
if (Array.isArray(e.meta?.appreciatedBy)) appreciations += e.meta.appreciatedBy.length;
|
|
77
87
|
if ((e.updatedAt ?? 0) > newestEdit) newestEdit = e.updatedAt ?? 0;
|
|
88
|
+
const created = e.createdAt ?? 0;
|
|
89
|
+
if (created > 0 && (oldestPage === 0 || created < oldestPage)) oldestPage = created;
|
|
90
|
+
if (created > weekAgo) pagesThisWeek++;
|
|
78
91
|
}
|
|
79
|
-
return {
|
|
92
|
+
return {
|
|
93
|
+
pages,
|
|
94
|
+
journalEntries,
|
|
95
|
+
livePosts,
|
|
96
|
+
photos,
|
|
97
|
+
signatures,
|
|
98
|
+
appreciations,
|
|
99
|
+
newestEdit,
|
|
100
|
+
oldestPage,
|
|
101
|
+
pagesThisWeek,
|
|
102
|
+
byType
|
|
103
|
+
};
|
|
80
104
|
});
|
|
81
105
|
const stats = computed(() => ({
|
|
82
106
|
pages: live.value?.pages ?? ssrStats.value?.pages ?? 0,
|
|
@@ -86,10 +110,11 @@ const stats = computed(() => ({
|
|
|
86
110
|
signatures: live.value?.signatures ?? ssrStats.value?.signatures ?? 0,
|
|
87
111
|
appreciations: live.value?.appreciations ?? ssrStats.value?.appreciations ?? 0,
|
|
88
112
|
words: ssrStats.value?.words ?? 0,
|
|
89
|
-
newestEdit: live.value?.newestEdit ?? ssrStats.value?.newestEdit ?? 0
|
|
113
|
+
newestEdit: live.value?.newestEdit ?? ssrStats.value?.newestEdit ?? 0,
|
|
114
|
+
oldestPage: live.value?.oldestPage ?? ssrStats.value?.oldestPage ?? 0,
|
|
115
|
+
pagesThisWeek: live.value?.pagesThisWeek ?? 0
|
|
90
116
|
}));
|
|
91
117
|
const readingNow = computed(() => travellers.value.length + 1);
|
|
92
|
-
const DAY = 864e5;
|
|
93
118
|
const now = ref(Date.now());
|
|
94
119
|
let tick = null;
|
|
95
120
|
onMounted(() => {
|
|
@@ -100,44 +125,139 @@ onMounted(() => {
|
|
|
100
125
|
onUnmounted(() => {
|
|
101
126
|
if (tick) clearInterval(tick);
|
|
102
127
|
});
|
|
103
|
-
const sparkBuckets = computed(() => {
|
|
104
|
-
const buckets = Array.from({ length: 30 }, () => 0);
|
|
105
|
-
if (!treeLive.value) return buckets;
|
|
106
|
-
for (const e of liveEntries.value) {
|
|
107
|
-
const t = e.updatedAt ?? 0;
|
|
108
|
-
if (!t) continue;
|
|
109
|
-
const idx = 29 - Math.floor((now.value - t) / DAY);
|
|
110
|
-
if (idx >= 0 && idx < 30) buckets[idx]++;
|
|
111
|
-
}
|
|
112
|
-
return buckets;
|
|
113
|
-
});
|
|
114
|
-
const sparkMax = computed(() => Math.max(1, ...sparkBuckets.value));
|
|
115
128
|
const nf = new Intl.NumberFormat(void 0);
|
|
116
129
|
const rtf = new Intl.RelativeTimeFormat(void 0, { numeric: "auto" });
|
|
130
|
+
const df = new Intl.DateTimeFormat(void 0, { month: "short", day: "numeric" });
|
|
117
131
|
const fmt = (n) => nf.format(n);
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
const min = Math.floor(Math.max(0, now.value - stats.value.newestEdit) / 6e4);
|
|
132
|
+
function relative(ts) {
|
|
133
|
+
const min = Math.floor(Math.max(0, now.value - ts) / 6e4);
|
|
121
134
|
if (min < 1) return "just now";
|
|
122
135
|
if (min < 60) return rtf.format(-min, "minute");
|
|
123
136
|
const h = Math.floor(min / 60);
|
|
124
137
|
if (h < 24) return rtf.format(-h, "hour");
|
|
125
|
-
|
|
138
|
+
const d = Math.floor(h / 24);
|
|
139
|
+
if (d < 30) return rtf.format(-d, "day");
|
|
140
|
+
const mo = Math.floor(d / 30);
|
|
141
|
+
if (mo < 12) return rtf.format(-mo, "month");
|
|
142
|
+
return rtf.format(-Math.floor(mo / 12), "year");
|
|
143
|
+
}
|
|
144
|
+
const lastEditAt = computed(
|
|
145
|
+
() => Math.max(stats.value.newestEdit, ssrStats.value?.lastActivityAt ?? 0)
|
|
146
|
+
);
|
|
147
|
+
const lastEditLabel = computed(
|
|
148
|
+
() => lastEditAt.value ? relative(lastEditAt.value) : "\u2014"
|
|
149
|
+
);
|
|
150
|
+
const ageLabel = computed(() => {
|
|
151
|
+
if (!stats.value.oldestPage) return "\u2014";
|
|
152
|
+
const days = Math.floor((now.value - stats.value.oldestPage) / 864e5);
|
|
153
|
+
if (days < 1) return "today";
|
|
154
|
+
if (days < 60) return `${days} days`;
|
|
155
|
+
const months = Math.floor(days / 30);
|
|
156
|
+
if (months < 24) return `${months} months`;
|
|
157
|
+
return `${Math.floor(days / 365)} years`;
|
|
126
158
|
});
|
|
127
|
-
const
|
|
159
|
+
const activity = computed(() => ssrStats.value?.activity ?? []);
|
|
160
|
+
const activityReady = computed(() => ssrStats.value?.activityReady === true);
|
|
161
|
+
const activityMax = computed(() => Math.max(1, ...activity.value.map((p) => p.edits)));
|
|
162
|
+
const editsThisWeek = computed(
|
|
163
|
+
() => activity.value.slice(-7).reduce((n, p) => n + p.edits, 0)
|
|
164
|
+
);
|
|
165
|
+
const wordsThisWeek = computed(
|
|
166
|
+
() => activity.value.slice(-7).reduce((n, p) => n + p.words, 0)
|
|
167
|
+
);
|
|
168
|
+
const hovered = ref(null);
|
|
169
|
+
const hoveredPoint = computed(
|
|
170
|
+
() => hovered.value === null ? null : activity.value[hovered.value] ?? null
|
|
171
|
+
);
|
|
172
|
+
function dayLabel(iso) {
|
|
173
|
+
return df.format(/* @__PURE__ */ new Date(`${iso}T12:00:00Z`));
|
|
174
|
+
}
|
|
175
|
+
const typeBreakdown = computed(() => {
|
|
176
|
+
const source = live.value?.byType ?? ssrStats.value?.byType ?? {};
|
|
177
|
+
const rows = Object.entries(source).map(([type, count]) => ({
|
|
178
|
+
type,
|
|
179
|
+
count,
|
|
180
|
+
// A type the site does not register still gets a row — a corpus being
|
|
181
|
+
// adopted is full of them, and dropping them would make the totals
|
|
182
|
+
// disagree with the "Pages" tile for no visible reason.
|
|
183
|
+
label: labelForType(type) ?? type
|
|
184
|
+
})).sort((a, b) => b.count - a.count || a.label.localeCompare(b.label));
|
|
185
|
+
return rows.slice(0, 8);
|
|
186
|
+
});
|
|
187
|
+
const typeMax = computed(() => Math.max(1, ...typeBreakdown.value.map((r) => r.count)));
|
|
188
|
+
const allTiles = computed(() => {
|
|
128
189
|
const t = types.value;
|
|
129
190
|
const out = [
|
|
130
|
-
{
|
|
131
|
-
|
|
191
|
+
{
|
|
192
|
+
key: "pages",
|
|
193
|
+
label: "Pages",
|
|
194
|
+
value: fmt(stats.value.pages),
|
|
195
|
+
icon: "i-lucide-file-text",
|
|
196
|
+
delta: stats.value.pagesThisWeek ? `+${stats.value.pagesThisWeek} this week` : void 0
|
|
197
|
+
},
|
|
198
|
+
{
|
|
199
|
+
key: "words",
|
|
200
|
+
label: "Words written",
|
|
201
|
+
value: fmt(stats.value.words),
|
|
202
|
+
icon: "i-lucide-type",
|
|
203
|
+
delta: wordsThisWeek.value ? `${wordsThisWeek.value > 0 ? "+" : ""}${fmt(wordsThisWeek.value)} this week` : void 0,
|
|
204
|
+
snapshot: true
|
|
205
|
+
}
|
|
132
206
|
];
|
|
133
|
-
if (t.entry) out.push({ label: "Entries", value: fmt(stats.value.journalEntries), icon: "i-lucide-feather" });
|
|
134
|
-
if (t.now) out.push({ label: "Posts", value: fmt(stats.value.livePosts), icon: "i-lucide-radio" });
|
|
135
|
-
if (t.wall) out.push({ label: "Photos", value: fmt(stats.value.photos), icon: "i-lucide-images" });
|
|
136
|
-
if (t.guestbook) out.push({ label: "Signatures", value: fmt(stats.value.signatures), icon: "i-lucide-pen-line" });
|
|
137
|
-
out.push({ label: "Appreciations", value: fmt(stats.value.appreciations), icon: "i-lucide-heart" });
|
|
138
|
-
out.push({
|
|
207
|
+
if (t.entry) out.push({ key: "entries", label: "Entries", value: fmt(stats.value.journalEntries), icon: "i-lucide-feather" });
|
|
208
|
+
if (t.now) out.push({ key: "posts", label: "Posts", value: fmt(stats.value.livePosts), icon: "i-lucide-radio" });
|
|
209
|
+
if (t.wall) out.push({ key: "photos", label: "Photos", value: fmt(stats.value.photos), icon: "i-lucide-images" });
|
|
210
|
+
if (t.guestbook) out.push({ key: "signatures", label: "Signatures", value: fmt(stats.value.signatures), icon: "i-lucide-pen-line" });
|
|
211
|
+
out.push({ key: "appreciations", label: "Appreciations", value: fmt(stats.value.appreciations), icon: "i-lucide-heart" });
|
|
212
|
+
out.push({
|
|
213
|
+
key: "lastEdit",
|
|
214
|
+
label: "Last edit",
|
|
215
|
+
value: lastEditLabel.value,
|
|
216
|
+
icon: "i-lucide-history"
|
|
217
|
+
});
|
|
218
|
+
out.push({ key: "age", label: "Site age", value: ageLabel.value, icon: "i-lucide-calendar-days" });
|
|
139
219
|
return out;
|
|
140
220
|
});
|
|
221
|
+
const chosenKeys = computed(() => {
|
|
222
|
+
const raw = pageMeta.value.statsTiles;
|
|
223
|
+
if (!Array.isArray(raw)) return null;
|
|
224
|
+
const keys = raw.filter((k) => typeof k === "string");
|
|
225
|
+
return keys.length ? keys : [];
|
|
226
|
+
});
|
|
227
|
+
const tiles = computed(() => {
|
|
228
|
+
const chosen = chosenKeys.value;
|
|
229
|
+
if (!chosen) return allTiles.value;
|
|
230
|
+
const byKey = new Map(allTiles.value.map((t) => [t.key, t]));
|
|
231
|
+
return chosen.map((k) => byKey.get(k)).filter((t) => !!t);
|
|
232
|
+
});
|
|
233
|
+
function toggleTile(key) {
|
|
234
|
+
const current = chosenKeys.value ?? allTiles.value.map((t) => t.key);
|
|
235
|
+
const next = current.includes(key) ? current.filter((k) => k !== key) : [...current, key];
|
|
236
|
+
tree.updateMeta(props.docId, { statsTiles: next });
|
|
237
|
+
}
|
|
238
|
+
function resetTiles() {
|
|
239
|
+
tree.updateMeta(props.docId, { statsTiles: void 0 });
|
|
240
|
+
}
|
|
241
|
+
const tileMenuItems = computed(() => {
|
|
242
|
+
const shown = new Set(tiles.value.map((t) => t.key));
|
|
243
|
+
return [
|
|
244
|
+
allTiles.value.map((t) => ({
|
|
245
|
+
label: t.label,
|
|
246
|
+
icon: t.icon,
|
|
247
|
+
type: "checkbox",
|
|
248
|
+
checked: shown.has(t.key),
|
|
249
|
+
onSelect: (e) => {
|
|
250
|
+
e.preventDefault();
|
|
251
|
+
toggleTile(t.key);
|
|
252
|
+
}
|
|
253
|
+
})),
|
|
254
|
+
[{
|
|
255
|
+
label: "Show all",
|
|
256
|
+
icon: "i-lucide-rotate-ccw",
|
|
257
|
+
onSelect: () => resetTiles()
|
|
258
|
+
}]
|
|
259
|
+
];
|
|
260
|
+
});
|
|
141
261
|
</script>
|
|
142
262
|
|
|
143
263
|
<template>
|
|
@@ -150,30 +270,43 @@ const tiles = computed(() => {
|
|
|
150
270
|
@rename-subtitle="renameSubtitle"
|
|
151
271
|
/>
|
|
152
272
|
|
|
153
|
-
<
|
|
154
|
-
<
|
|
273
|
+
<div class="jun-card mb-6 flex items-center gap-3 rounded-2xl px-5 py-4">
|
|
274
|
+
<span
|
|
275
|
+
class="relative flex size-2.5 flex-none"
|
|
276
|
+
aria-hidden="true"
|
|
277
|
+
>
|
|
278
|
+
<span class="absolute inline-flex h-full w-full animate-ping rounded-full bg-current opacity-30" />
|
|
279
|
+
<span class="relative inline-flex size-2.5 rounded-full bg-current opacity-70" />
|
|
280
|
+
</span>
|
|
281
|
+
<p class="text-sm text-toned">
|
|
282
|
+
<span class="font-semibold tabular-nums">{{ readingNow }}</span>
|
|
283
|
+
{{ readingNow === 1 ? "person is" : "people are" }} reading right now
|
|
155
284
|
<span
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
>
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
285
|
+
v-if="readingNow === 1"
|
|
286
|
+
class="text-dimmed"
|
|
287
|
+
>(that's you)</span>
|
|
288
|
+
</p>
|
|
289
|
+
|
|
290
|
+
<UDropdownMenu
|
|
291
|
+
v-if="editing"
|
|
292
|
+
:items="tileMenuItems"
|
|
293
|
+
:content="{ align: 'end' }"
|
|
294
|
+
class="ml-auto"
|
|
295
|
+
>
|
|
296
|
+
<UButton
|
|
297
|
+
icon="i-lucide-layout-grid"
|
|
298
|
+
color="neutral"
|
|
299
|
+
variant="ghost"
|
|
300
|
+
size="xs"
|
|
301
|
+
label="Tiles"
|
|
302
|
+
/>
|
|
303
|
+
</UDropdownMenu>
|
|
304
|
+
</div>
|
|
172
305
|
|
|
173
306
|
<div class="grid grid-cols-2 gap-3 sm:grid-cols-4">
|
|
174
307
|
<div
|
|
175
308
|
v-for="(tile, i) in tiles"
|
|
176
|
-
:key="tile.
|
|
309
|
+
:key="tile.key"
|
|
177
310
|
v-motion="junMotion(junStagger(i, { delayMs: 40 }))"
|
|
178
311
|
class="jun-card rounded-2xl p-4"
|
|
179
312
|
>
|
|
@@ -188,43 +321,116 @@ const tiles = computed(() => {
|
|
|
188
321
|
<p class="mt-0.5 text-[11px] tracking-wider text-dimmed uppercase">
|
|
189
322
|
{{ tile.label }}
|
|
190
323
|
</p>
|
|
324
|
+
<p
|
|
325
|
+
v-if="tile.delta"
|
|
326
|
+
class="mt-1 text-[11px] text-muted tabular-nums"
|
|
327
|
+
>
|
|
328
|
+
{{ tile.delta }}
|
|
329
|
+
</p>
|
|
191
330
|
</div>
|
|
192
331
|
</div>
|
|
193
332
|
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
333
|
+
<!-- Activity. Server-only and a HISTORY: the tree cannot answer it. -->
|
|
334
|
+
<div class="jun-card mt-3 rounded-2xl p-5">
|
|
335
|
+
<div class="mb-3 flex flex-wrap items-baseline justify-between gap-x-4 gap-y-1">
|
|
336
|
+
<p class="text-[11px] tracking-wider text-dimmed uppercase">
|
|
337
|
+
Activity · last 30 days
|
|
338
|
+
</p>
|
|
339
|
+
<p class="text-[11px] text-dimmed">
|
|
340
|
+
<template v-if="hoveredPoint">
|
|
341
|
+
<span class="text-toned">{{ dayLabel(hoveredPoint.date) }}</span>
|
|
342
|
+
· {{ hoveredPoint.edits }} {{ hoveredPoint.edits === 1 ? "edit" : "edits" }}
|
|
343
|
+
<template v-if="hoveredPoint.words">
|
|
344
|
+
· {{ hoveredPoint.words > 0 ? "+" : "" }}{{ fmt(hoveredPoint.words) }} words
|
|
345
|
+
</template>
|
|
346
|
+
</template>
|
|
347
|
+
<template v-else-if="activityReady">
|
|
348
|
+
{{ editsThisWeek }} in the last 7 days
|
|
349
|
+
</template>
|
|
350
|
+
<template v-else>
|
|
351
|
+
still measuring
|
|
352
|
+
</template>
|
|
353
|
+
</p>
|
|
354
|
+
</div>
|
|
355
|
+
|
|
356
|
+
<svg
|
|
357
|
+
v-if="activityReady"
|
|
358
|
+
viewBox="0 0 300 48"
|
|
359
|
+
class="h-12 w-full text-black/60 dark:text-white/60"
|
|
360
|
+
preserveAspectRatio="none"
|
|
361
|
+
role="img"
|
|
362
|
+
aria-label="Documents edited per day over the last 30 days"
|
|
363
|
+
@pointerleave="hovered = null"
|
|
364
|
+
>
|
|
365
|
+
<g
|
|
366
|
+
v-for="(point, i) in activity"
|
|
367
|
+
:key="point.date"
|
|
368
|
+
@pointerenter="hovered = i"
|
|
210
369
|
>
|
|
370
|
+
<!-- A full-height hit target: a 2px bar is not something anyone can
|
|
371
|
+
point at, and the readout is the only place the exact figure and
|
|
372
|
+
the date appear. -->
|
|
373
|
+
<rect
|
|
374
|
+
:x="i * 10"
|
|
375
|
+
y="0"
|
|
376
|
+
width="10"
|
|
377
|
+
height="48"
|
|
378
|
+
fill="transparent"
|
|
379
|
+
/>
|
|
211
380
|
<rect
|
|
212
|
-
v-for="(v, i) in sparkBuckets"
|
|
213
|
-
:key="i"
|
|
214
381
|
:x="i * 10 + 2"
|
|
215
|
-
:y="48 -
|
|
382
|
+
:y="48 - point.edits / activityMax * 44 - 2"
|
|
216
383
|
width="6"
|
|
217
|
-
:height="Math.max(2,
|
|
384
|
+
:height="Math.max(2, point.edits / activityMax * 44)"
|
|
218
385
|
rx="1.5"
|
|
219
386
|
fill="currentColor"
|
|
220
|
-
:opacity="
|
|
387
|
+
:opacity="hovered === i ? 1 : point.edits ? 0.9 : 0.15"
|
|
221
388
|
/>
|
|
222
|
-
</
|
|
223
|
-
</
|
|
224
|
-
|
|
389
|
+
</g>
|
|
390
|
+
</svg>
|
|
391
|
+
<p
|
|
392
|
+
v-else
|
|
393
|
+
class="py-3 text-[11px] text-dimmed"
|
|
394
|
+
>
|
|
395
|
+
The ledger takes its baseline shortly after the server starts, then books
|
|
396
|
+
one point per sweep. History appears from the next sweep onwards.
|
|
397
|
+
</p>
|
|
398
|
+
|
|
399
|
+
<p class="mt-3 text-[11px] leading-relaxed text-dimmed">
|
|
400
|
+
A bar counts documents whose text CHANGED between two checks of the
|
|
401
|
+
site's cache — near enough an editing session, and not a count of
|
|
402
|
+
keystrokes.
|
|
403
|
+
</p>
|
|
404
|
+
</div>
|
|
405
|
+
|
|
406
|
+
<!-- What the site is MADE of. Live: the tree can answer this one. -->
|
|
407
|
+
<div
|
|
408
|
+
v-if="typeBreakdown.length > 1"
|
|
409
|
+
class="jun-card mt-3 rounded-2xl p-5"
|
|
410
|
+
>
|
|
411
|
+
<p class="mb-3 text-[11px] tracking-wider text-dimmed uppercase">
|
|
412
|
+
Pages by type
|
|
413
|
+
</p>
|
|
414
|
+
<ul class="space-y-1.5">
|
|
415
|
+
<li
|
|
416
|
+
v-for="row in typeBreakdown"
|
|
417
|
+
:key="row.type"
|
|
418
|
+
class="flex items-center gap-3"
|
|
419
|
+
>
|
|
420
|
+
<span class="w-28 flex-none truncate text-xs text-toned">{{ row.label }}</span>
|
|
421
|
+
<span class="h-1.5 flex-1 overflow-hidden rounded-full bg-black/5 dark:bg-white/10">
|
|
422
|
+
<span
|
|
423
|
+
class="block h-full rounded-full bg-current opacity-50"
|
|
424
|
+
:style="{ width: `${row.count / typeMax * 100}%` }"
|
|
425
|
+
/>
|
|
426
|
+
</span>
|
|
427
|
+
<span class="w-8 flex-none text-right text-xs text-dimmed tabular-nums">{{ row.count }}</span>
|
|
428
|
+
</li>
|
|
429
|
+
</ul>
|
|
430
|
+
</div>
|
|
225
431
|
|
|
226
432
|
<p class="mt-6 text-center text-[11px] text-dimmed">
|
|
227
|
-
Every
|
|
433
|
+
Every count here is a live view over this site's document tree.
|
|
228
434
|
</p>
|
|
229
435
|
</div>
|
|
230
436
|
</template>
|