wiki-plugin-servertoggle 0.0.0-stage → 0.1.2
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/client/servertoggle.js +14 -0
- package/client/servertoggle.js.map +7 -0
- package/factory.json +1 -0
- package/package.json +17 -4
- package/pages/about-servertoggle-plugin +87 -0
- package/pages/server-toggle +106 -0
- package/README.md +0 -3
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
(()=>{var x=["https://toggle.pi5.private.fish","https://toggle.mini.private.fish"],y={pi5:"the Pi5",mini:"the MacMini"},$=e=>{let n=[];for(let i of String(e||"").split(`
|
|
2
|
+
`)){let s=i.trim().match(/^API:?\s+(https:\/\/[a-z0-9.-]+)\/?$/i);s&&n.push(s[1].toLowerCase())}return{apis:n.length?n:x}},c=e=>String(e).replace(/[&<>"']/g,n=>({"&":"&","<":"<",">":">",'"':""","'":"'"})[n]),v=e=>String(e||"").toLowerCase().includes("sweet")?"sweet":"node",f=async()=>{let e=await fetch("/system/sitemap.json",{method:"HEAD",cache:"no-store"});return v(e.headers.get("server"))},S=async(e,n)=>{for(let i of e)try{let s=await fetch(`${i}/api/site?name=${encodeURIComponent(n)}`,{credentials:"include",cache:"no-store",signal:AbortSignal.timeout(8e3)});if(!s.ok)continue;let p=await s.json();if(p.known)return{api:i,...p}}catch{}return null},k=`
|
|
3
|
+
.st-box { border: 1px solid #ddd; border-radius: 8px; padding: 10px 12px; background: #fafafa }
|
|
4
|
+
.st-box .st-line { margin: 0 0 8px }
|
|
5
|
+
.st-box .st-go { font: inherit; font-weight: bold; padding: 4px 12px; border-radius: 6px;
|
|
6
|
+
border: 1px solid #b58b00; background: #fff3c4; cursor: pointer }
|
|
7
|
+
.st-box .st-go.to-node { border-color: #888; background: #fff }
|
|
8
|
+
.st-box .st-go[disabled] { opacity: .5; cursor: wait }
|
|
9
|
+
.st-box .st-note { margin: 8px 0 0; font-size: 85%; color: #666 }
|
|
10
|
+
.st-box .st-note.err { color: #a00 }`,T=(e,n)=>{if(!document.getElementById("servertoggle-style")){let i=document.createElement("style");i.id="servertoggle-style",i.textContent=k,document.head.appendChild(i)}e.html(`<div class="st-box">
|
|
11
|
+
<p class="st-line">Checking which server serves <b>${c(location.hostname)}</b>\u2026</p>
|
|
12
|
+
<div class="st-act"></div>
|
|
13
|
+
<p class="st-note"></p></div>`)},C=(e,n)=>{let{apis:i}=$(n.text),s=location.hostname,p=e.find(".st-line"),g=e.find(".st-act"),u=e.find(".st-note"),l=(t,o=!1)=>u.toggleClass("err",o).html(t),w=async()=>{let t;try{t=await f()}catch{t=null}let o=await S(i,s);if(!o)return p.html(`<b>${c(s)}</b> is served by <b>${t||"an unknown server"}</b>.`),g.empty(),l(s.endsWith(".private.fish")?"No toggle panel knows this site, or none answered.":"The toggle works on private.fish names, from the tailnet.",!0);let r=t||o.probe,a=r==="sweet"?"node":"sweet",d=y[o.host]||o.host;p.html(`<b>${c(s)}</b> is served by <b>${r==="sweet"?"Sweet":"node"}</b>, on ${c(d)}.`),g.html(`<button class="st-go to-${a}">${a==="sweet"?"Serve from Sweet":"Back to node"}</button>`),l(o.routed!==r?`The routing says ${c(o.routed)} but ${c(r)} answered: reload in a moment.`:"Sweet pages have pale yellow paper. The page reloads after a switch."),g.find(".st-go").on("click",h=>m(h.currentTarget,o.api,a))},b=t=>`${t}/auth/login?next=${encodeURIComponent(location.href)}`,m=async(t,o,r)=>{t.disabled=!0,l(`Switching to ${r}\u2026`);let a;try{a=await fetch(`${o}/api/toggle`,{method:"POST",credentials:"include",cache:"no-store",headers:{"Content-Type":"application/json"},body:JSON.stringify({site:s,to:r})})}catch{return t.disabled=!1,l(`The toggle panel at ${c(o)} did not answer.`,!0)}if(a.status===401)return t.disabled=!1,l(`<a href="${c(b(o))}">Sign in to the toggle panel</a> first: it brings you back here.`,!0);if(!a.ok){t.disabled=!1;let d=await a.json().catch(()=>({}));return l(c(d.error||`The switch failed (${a.status}).`),!0)}l(`Switched. Waiting for ${r==="sweet"?"Sweet":"node"} to answer\u2026`);for(let d=0;d<20;d++){await new Promise(h=>setTimeout(h,500));try{if(await f()===r)break}catch{}}location.reload()};w()};typeof window<"u"&&(window.plugins=window.plugins||{},window.plugins.servertoggle={emit:T,bind:C});})();
|
|
14
|
+
//# sourceMappingURL=servertoggle.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/client/servertoggle.js"],
|
|
4
|
+
"sourcesContent": ["// wiki-plugin-servertoggle \u2014 say which server serves the site you are on\n// (the node wiki or the Rust Sweet Server) and flip it with one button.\n//\n// The button drives the Sweet Toggle API on the machine that hosts the site\n// (toggle.pi5.private.fish, toggle.mini.private.fish): routing only, both\n// servers keep running over the same site folders. Item text may list the\n// APIs to ask, one per line, as `API https://toggle.<machine>.private.fish`.\n\nconst DEFAULT_APIS = ['https://toggle.pi5.private.fish', 'https://toggle.mini.private.fish']\nconst MACHINE = { pi5: 'the Pi5', mini: 'the MacMini' }\n\nexport const parse = text => {\n const apis = []\n for (const line of String(text || '').split('\\n')) {\n const m = line.trim().match(/^API:?\\s+(https:\\/\\/[a-z0-9.-]+)\\/?$/i)\n if (m) apis.push(m[1].toLowerCase())\n }\n return { apis: apis.length ? apis : DEFAULT_APIS }\n}\n\nconst esc = s => String(s).replace(/[&<>\"']/g, c => ({ '&': '&', '<': '<', '>': '>', '\"': '"', \"'\": ''' })[c])\n\n// The site itself says who answered: Sweet stamps `Server: sweet-server`.\nexport const serverFromHeader = h => (String(h || '').toLowerCase().includes('sweet') ? 'sweet' : 'node')\n\nconst liveServer = async () => {\n const r = await fetch('/system/sitemap.json', { method: 'HEAD', cache: 'no-store' })\n return serverFromHeader(r.headers.get('server'))\n}\n\nconst findSite = async (apis, host) => {\n for (const api of apis) {\n try {\n const r = await fetch(`${api}/api/site?name=${encodeURIComponent(host)}`, {\n credentials: 'include', cache: 'no-store', signal: AbortSignal.timeout(8000),\n })\n if (!r.ok) continue\n const s = await r.json()\n if (s.known) return { api, ...s }\n } catch (_) { /* that machine is unreachable: try the next */ }\n }\n return null\n}\n\nconst STYLE = `\n.st-box { border: 1px solid #ddd; border-radius: 8px; padding: 10px 12px; background: #fafafa }\n.st-box .st-line { margin: 0 0 8px }\n.st-box .st-go { font: inherit; font-weight: bold; padding: 4px 12px; border-radius: 6px;\n border: 1px solid #b58b00; background: #fff3c4; cursor: pointer }\n.st-box .st-go.to-node { border-color: #888; background: #fff }\n.st-box .st-go[disabled] { opacity: .5; cursor: wait }\n.st-box .st-note { margin: 8px 0 0; font-size: 85%; color: #666 }\n.st-box .st-note.err { color: #a00 }`\n// no dark-mode rules: wiki pages stay white paper whatever the OS theme\n\nexport const emit = (div, item) => {\n if (!document.getElementById('servertoggle-style')) {\n const s = document.createElement('style')\n s.id = 'servertoggle-style'\n s.textContent = STYLE\n document.head.appendChild(s)\n }\n div.html(`<div class=\"st-box\">\n <p class=\"st-line\">Checking which server serves <b>${esc(location.hostname)}</b>\u2026</p>\n <div class=\"st-act\"></div>\n <p class=\"st-note\"></p></div>`)\n}\n\nexport const bind = (div, item) => {\n const { apis } = parse(item.text)\n const host = location.hostname\n const $line = div.find('.st-line')\n const $act = div.find('.st-act')\n const $note = div.find('.st-note')\n const note = (html, err = false) => $note.toggleClass('err', err).html(html)\n\n const draw = async () => {\n let live\n try { live = await liveServer() } catch (_) { live = null }\n const site = await findSite(apis, host)\n if (!site) {\n $line.html(`<b>${esc(host)}</b> is served by <b>${live || 'an unknown server'}</b>.`)\n $act.empty()\n return note(host.endsWith('.private.fish')\n ? 'No toggle panel knows this site, or none answered.'\n : 'The toggle works on private.fish names, from the tailnet.', true)\n }\n const on = live || site.probe\n const to = on === 'sweet' ? 'node' : 'sweet'\n const where = MACHINE[site.host] || site.host\n $line.html(`<b>${esc(host)}</b> is served by <b>${on === 'sweet' ? 'Sweet' : 'node'}</b>, on ${esc(where)}.`)\n $act.html(`<button class=\"st-go to-${to}\">${to === 'sweet' ? 'Serve from Sweet' : 'Back to node'}</button>`)\n note(site.routed !== on\n ? `The routing says ${esc(site.routed)} but ${esc(on)} answered: reload in a moment.`\n : 'Sweet pages have pale yellow paper. The page reloads after a switch.')\n $act.find('.st-go').on('click', e => flip(e.currentTarget, site.api, to))\n }\n\n const signIn = api => `${api}/auth/login?next=${encodeURIComponent(location.href)}`\n\n const flip = async (btn, api, to) => {\n btn.disabled = true\n note(`Switching to ${to}\u2026`)\n let r\n try {\n r = await fetch(`${api}/api/toggle`, {\n method: 'POST', credentials: 'include', cache: 'no-store',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({ site: host, to }),\n })\n } catch (_) {\n btn.disabled = false\n return note(`The toggle panel at ${esc(api)} did not answer.`, true)\n }\n if (r.status === 401) {\n btn.disabled = false\n return note(`<a href=\"${esc(signIn(api))}\">Sign in to the toggle panel</a> first: it brings you back here.`, true)\n }\n if (!r.ok) {\n btn.disabled = false\n const e = await r.json().catch(() => ({}))\n return note(esc(e.error || `The switch failed (${r.status}).`), true)\n }\n // Caddy reloads in a second or two: wait until the site answers from\n // the other server, then reload so the whole page comes from it\n note(`Switched. Waiting for ${to === 'sweet' ? 'Sweet' : 'node'} to answer\u2026`)\n for (let i = 0; i < 20; i++) {\n await new Promise(res => setTimeout(res, 500))\n try { if (await liveServer() === to) break } catch (_) {}\n }\n location.reload()\n }\n\n draw()\n}\n\nif (typeof window !== 'undefined') {\n window.plugins = window.plugins || {}\n window.plugins.servertoggle = { emit, bind }\n}\n"],
|
|
5
|
+
"mappings": "MAQA,IAAMA,EAAe,CAAC,kCAAmC,kCAAkC,EACrFC,EAAU,CAAE,IAAK,UAAW,KAAM,aAAc,EAEzCC,EAAQC,GAAQ,CAC3B,IAAMC,EAAO,CAAC,EACd,QAAWC,KAAQ,OAAOF,GAAQ,EAAE,EAAE,MAAM;AAAA,CAAI,EAAG,CACjD,IAAMG,EAAID,EAAK,KAAK,EAAE,MAAM,uCAAuC,EAC/DC,GAAGF,EAAK,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", "host", "api", "STYLE", "emit", "div", "item", "bind", "$line", "$act", "$note", "note", "html", "err", "draw", "live", "site", "on", "to", "where", "e", "flip", "signIn", "btn", "i", "res"]
|
|
7
|
+
}
|
package/factory.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"name": "Servertoggle", "title": "Server Toggle — serve this site from node or the Sweet Server", "category": "other", "pages": ["Server Toggle"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wiki-plugin-servertoggle",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.2",
|
|
4
|
+
"description": "Federated Wiki - Server Toggle Plugin: say whether the site you are on is served by the node wiki or the Sweet Server, and flip it with one button through the Sweet Toggle API",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "client/servertoggle.js",
|
|
7
|
+
"files": ["client", "pages", "factory.json"],
|
|
8
|
+
"scripts": {
|
|
9
|
+
"build": "node scripts/build.js",
|
|
10
|
+
"test": "node --test test/*.test.js"
|
|
11
|
+
},
|
|
12
|
+
"keywords": ["wiki", "federated wiki", "plugin", "sweet", "toggle"],
|
|
13
|
+
"devDependencies": { "esbuild": "^0.25.0" },
|
|
14
|
+
"author": "David Bovill",
|
|
15
|
+
"license": "MIT",
|
|
16
|
+
"repository": { "type": "git", "url": "git+https://github.com/Hitchhikers-Guide-to-the-Galaxy/wiki-plugin-servertoggle.git" },
|
|
17
|
+
"bugs": { "url": "https://github.com/Hitchhikers-Guide-to-the-Galaxy/wiki-plugin-servertoggle/issues" },
|
|
18
|
+
"homepage": "https://github.com/Hitchhikers-Guide-to-the-Galaxy/wiki-plugin-servertoggle#readme"
|
|
19
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
{
|
|
2
|
+
"title": "About Servertoggle Plugin",
|
|
3
|
+
"story": [
|
|
4
|
+
{
|
|
5
|
+
"type": "markdown",
|
|
6
|
+
"id": "e0ac3d51bce53e42",
|
|
7
|
+
"text": "The Server Toggle plugin shows whether the site you are on is served by the node wiki or the Sweet Server, and switches it with one button. Open it from \u2630 as [[Server Toggle]]."
|
|
8
|
+
},
|
|
9
|
+
{
|
|
10
|
+
"type": "servertoggle",
|
|
11
|
+
"id": "3ec4d65891714c77",
|
|
12
|
+
"text": "API https://toggle.pi5.private.fish\nAPI https://toggle.mini.private.fish"
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
"type": "markdown",
|
|
16
|
+
"id": "25899c4413fcf775",
|
|
17
|
+
"text": "# Item Text\n> Which panels to ask."
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
"type": "markdown",
|
|
21
|
+
"id": "ccc4867fbf67ac1b",
|
|
22
|
+
"text": "Each line `API https://toggle.<machine>.private.fish` names a Sweet Toggle panel to ask about this site; the first that knows the site does the switching. With no API lines the item asks the Pi5 and then the MacMini."
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
"type": "markdown",
|
|
26
|
+
"id": "297d7af88411ae2e",
|
|
27
|
+
"text": "# How It Works\n> Ask, then switch, then reload."
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
"type": "markdown",
|
|
31
|
+
"id": "cbc845b16e7e45e2",
|
|
32
|
+
"text": "The item reads the `Server` header of the site's own sitemap: `sweet-server` means Sweet, anything else means node. It asks each panel's `/api/site` which machine hosts the site and how that machine routes it, and the button posts to `/api/toggle` with your panel sign-in. It then waits until the site answers from the other server and reloads the page."
|
|
33
|
+
}
|
|
34
|
+
],
|
|
35
|
+
"journal": [
|
|
36
|
+
{
|
|
37
|
+
"type": "create",
|
|
38
|
+
"item": {
|
|
39
|
+
"title": "About Servertoggle Plugin",
|
|
40
|
+
"story": [
|
|
41
|
+
{
|
|
42
|
+
"type": "markdown",
|
|
43
|
+
"id": "e0ac3d51bce53e42",
|
|
44
|
+
"text": "The Server Toggle plugin shows whether the site you are on is served by the node wiki or the Sweet Server, and switches it with one button. Open it from \u2630 as [[Server Toggle]]."
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
"type": "servertoggle",
|
|
48
|
+
"id": "3ec4d65891714c77",
|
|
49
|
+
"text": "API https://toggle.pi5.private.fish\nAPI https://toggle.mini.private.fish"
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
"type": "markdown",
|
|
53
|
+
"id": "25899c4413fcf775",
|
|
54
|
+
"text": "# Item Text\n> Which panels to ask."
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
"type": "markdown",
|
|
58
|
+
"id": "ccc4867fbf67ac1b",
|
|
59
|
+
"text": "Each line `API https://toggle.<machine>.private.fish` names a Sweet Toggle panel to ask about this site; the first that knows the site does the switching. With no API lines the item asks the Pi5 and then the MacMini."
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
"type": "markdown",
|
|
63
|
+
"id": "297d7af88411ae2e",
|
|
64
|
+
"text": "# How It Works\n> Ask, then switch, then reload."
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
"type": "markdown",
|
|
68
|
+
"id": "cbc845b16e7e45e2",
|
|
69
|
+
"text": "The item reads the `Server` header of the site's own sitemap: `sweet-server` means Sweet, anything else means node. It asks each panel's `/api/site` which machine hosts the site and how that machine routes it, and the button posts to `/api/toggle` with your panel sign-in. It then waits until the site answers from the other server and reloads the page."
|
|
70
|
+
}
|
|
71
|
+
]
|
|
72
|
+
},
|
|
73
|
+
"date": 1793148404491,
|
|
74
|
+
"provenance": "Authored by an AI agent \u2014 Claude Code via the [[fedwiki-create-plugin]] skill, in dialogue with David Bovill. [https://claude.com/claude-code Claude Code]",
|
|
75
|
+
"meta": {
|
|
76
|
+
"v": 1,
|
|
77
|
+
"agent": {
|
|
78
|
+
"kind": "ai",
|
|
79
|
+
"name": "Claude Code",
|
|
80
|
+
"session": "4be3ebed-063b-4668-b5b5-91bd1a099c42"
|
|
81
|
+
},
|
|
82
|
+
"act": "create"
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
],
|
|
86
|
+
"plugin": "servertoggle"
|
|
87
|
+
}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
{
|
|
2
|
+
"title": "Server Toggle",
|
|
3
|
+
"story": [
|
|
4
|
+
{
|
|
5
|
+
"type": "markdown",
|
|
6
|
+
"id": "e9d5917152a9d2e7",
|
|
7
|
+
"text": "Serve the site you are on from the node wiki or the Sweet Server, and switch back, with one button."
|
|
8
|
+
},
|
|
9
|
+
{
|
|
10
|
+
"type": "servertoggle",
|
|
11
|
+
"id": "62809afb40ba8a37",
|
|
12
|
+
"text": "API https://toggle.pi5.private.fish\nAPI https://toggle.mini.private.fish"
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
"type": "markdown",
|
|
16
|
+
"id": "aebc2f0e175e0cdd",
|
|
17
|
+
"text": "The line above says which server answered this page. Press the button to switch; the first time, it asks you to sign in to the toggle panel and brings you back. The page reloads from the other server, and Sweet pages have pale yellow paper."
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
"type": "markdown",
|
|
21
|
+
"id": "caa91d77700c7baf",
|
|
22
|
+
"text": "# Where Things Go\n> Routing only."
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
"type": "markdown",
|
|
26
|
+
"id": "7df025991b4cfa03",
|
|
27
|
+
"text": "A switch adds or removes this site in one Caddy routing file on the machine that hosts it, and reloads Caddy. Both servers keep running over the same site folders, so no page, journal or asset is copied or moved."
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
"type": "markdown",
|
|
31
|
+
"id": "0baf09ee21045020",
|
|
32
|
+
"text": "# Privacy\n> Tailnet only, signed in."
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
"type": "markdown",
|
|
36
|
+
"id": "8026805aa3a38eb6",
|
|
37
|
+
"text": "The button talks to the Sweet Toggle panel on the Pi5 or the MacMini, which answers only on the tailnet. Seeing where a site is served needs no sign-in; switching needs a Keycloak sign-in with your wiki login. On Sweet a site asks you to sign in again through the padlock, because Sweet keeps its own session."
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
"type": "markdown",
|
|
41
|
+
"id": "210ee10890959538",
|
|
42
|
+
"text": "More in [[About Servertoggle Plugin]]."
|
|
43
|
+
}
|
|
44
|
+
],
|
|
45
|
+
"journal": [
|
|
46
|
+
{
|
|
47
|
+
"type": "create",
|
|
48
|
+
"item": {
|
|
49
|
+
"title": "Server Toggle",
|
|
50
|
+
"story": [
|
|
51
|
+
{
|
|
52
|
+
"type": "markdown",
|
|
53
|
+
"id": "e9d5917152a9d2e7",
|
|
54
|
+
"text": "Serve the site you are on from the node wiki or the Sweet Server, and switch back, with one button."
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
"type": "servertoggle",
|
|
58
|
+
"id": "62809afb40ba8a37",
|
|
59
|
+
"text": "API https://toggle.pi5.private.fish\nAPI https://toggle.mini.private.fish"
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
"type": "markdown",
|
|
63
|
+
"id": "aebc2f0e175e0cdd",
|
|
64
|
+
"text": "The line above says which server answered this page. Press the button to switch; the first time, it asks you to sign in to the toggle panel and brings you back. The page reloads from the other server, and Sweet pages have pale yellow paper."
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
"type": "markdown",
|
|
68
|
+
"id": "caa91d77700c7baf",
|
|
69
|
+
"text": "# Where Things Go\n> Routing only."
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
"type": "markdown",
|
|
73
|
+
"id": "7df025991b4cfa03",
|
|
74
|
+
"text": "A switch adds or removes this site in one Caddy routing file on the machine that hosts it, and reloads Caddy. Both servers keep running over the same site folders, so no page, journal or asset is copied or moved."
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
"type": "markdown",
|
|
78
|
+
"id": "0baf09ee21045020",
|
|
79
|
+
"text": "# Privacy\n> Tailnet only, signed in."
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
"type": "markdown",
|
|
83
|
+
"id": "8026805aa3a38eb6",
|
|
84
|
+
"text": "The button talks to the Sweet Toggle panel on the Pi5 or the MacMini, which answers only on the tailnet. Seeing where a site is served needs no sign-in; switching needs a Keycloak sign-in with your wiki login. On Sweet a site asks you to sign in again through the padlock, because Sweet keeps its own session."
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
"type": "markdown",
|
|
88
|
+
"id": "210ee10890959538",
|
|
89
|
+
"text": "More in [[About Servertoggle Plugin]]."
|
|
90
|
+
}
|
|
91
|
+
]
|
|
92
|
+
},
|
|
93
|
+
"date": 1793148404491,
|
|
94
|
+
"provenance": "Authored by an AI agent \u2014 Claude Code via the [[fedwiki-create-plugin]] skill, in dialogue with David Bovill. [https://claude.com/claude-code Claude Code]",
|
|
95
|
+
"meta": {
|
|
96
|
+
"v": 1,
|
|
97
|
+
"agent": {
|
|
98
|
+
"kind": "ai",
|
|
99
|
+
"name": "Claude Code",
|
|
100
|
+
"session": "4be3ebed-063b-4668-b5b5-91bd1a099c42"
|
|
101
|
+
},
|
|
102
|
+
"act": "create"
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
]
|
|
106
|
+
}
|
package/README.md
DELETED