Files
TooraSt-wikijs/create-toora-pages.py

173 lines
8.1 KiB
Python

#!/usr/bin/env python3
"""Create Toora pages in Wiki.js via GraphQL API."""
import json, sys
JWT = sys.argv[1] if len(sys.argv) > 1 else ""
pages = [
{
"title": "Toora Home",
"path": "home",
"tags": ["home", "toora"],
"desc": "Household knowledge base home",
"content": (
'<div class="vf-hero-dark">'
'<div class="eyebrow">Household Knowledge Base</div>'
'<h1 class="display-hero">TOORA</h1>'
'<p class="body-lg">Everything about our home — how things work, what we use, and how to fix it.</p>'
'</div>'
'<div class="vf-band-light">'
'<span class="vf-section-label">Home Notes</span>'
'<div class="vf-grid">'
'<div class="vf-card"><div class="vf-card-title">📺 Entertainment</div><div class="vf-card-desc">TV, streaming, music, and internet services for the home.</div></div>'
'<div class="vf-card"><div class="vf-card-title">💡 Lights</div><div class="vf-card-desc">Lighting controls, switches, and smart bulbs.</div></div>'
'<div class="vf-card"><div class="vf-card-title">🍳 Kitchen</div><div class="vf-card-desc">Composting system, appliances, and kitchen setup.</div></div>'
'<div class="vf-card"><div class="vf-card-title">🌱 Garden</div><div class="vf-card-desc">BBQ, fires, and outdoor living.</div></div>'
'<div class="vf-card"><div class="vf-card-title">🐾 Pets</div><div class="vf-card-desc">Dogs and fish — care routines and setups.</div></div>'
'<div class="vf-card"><div class="vf-card-title">🧺 Laundry</div><div class="vf-card-desc">Washer and drier — usage and maintenance.</div></div>'
'</div></div>'
)
},
{
"title": "Entertainment",
"path": "entertainment",
"tags": ["entertainment", "tv", "music", "internet"],
"desc": "TV, streaming, music and internet",
"content": (
'<div class="vf-band-light">'
'<div class="eyebrow">Section</div>'
'<h1 class="display-xl">ENTERTAINMENT</h1>'
'<p class="body-lg">TV and streaming setup, music systems, and home internet.</p>'
'</div>'
'<div class="vf-band-light">'
'<span class="vf-section-label">Topics</span>'
'<div class="vf-grid-3">'
'<div class="vf-card"><div class="vf-card-title">📺 TV &amp; Streaming</div><div class="vf-card-desc">Television setup, streaming services, subscriptions, and devices.</div></div>'
'<div class="vf-card"><div class="vf-card-title">🎵 Music</div><div class="vf-card-desc">Music systems, speakers, playlists, and audio setup.</div></div>'
'<div class="vf-card"><div class="vf-card-title">🌐 Internet</div><div class="vf-card-desc">Home internet, WiFi, router, and network services.</div></div>'
'</div></div>'
)
},
{
"title": "Lights",
"path": "lights",
"tags": ["lights", "switches"],
"desc": "Lighting controls and switches",
"content": (
'<div class="vf-band-light">'
'<div class="eyebrow">Section</div>'
'<h1 class="display-xl">LIGHTS</h1>'
'<p class="body-lg">Lighting around the home — controls, switches, and smart options.</p>'
'</div>'
'<div class="vf-band-light">'
'<span class="vf-section-label">Topics</span>'
'<div class="vf-grid-3">'
'<div class="vf-card"><div class="vf-card-title">🎛 Controlling</div><div class="vf-card-desc">Smart controls, dimmers, timers, and automation.</div></div>'
'<div class="vf-card"><div class="vf-card-title">🔘 Switches</div><div class="vf-card-desc">Wall switches, smart switches, and wiring notes.</div></div>'
'</div></div>'
)
},
{
"title": "Kitchen",
"path": "kitchen",
"tags": ["kitchen", "compost", "appliances"],
"desc": "Composting and kitchen appliances",
"content": (
'<div class="vf-band-light">'
'<div class="eyebrow">Section</div>'
'<h1 class="display-xl">KITCHEN</h1>'
'<p class="body-lg">Compost system and kitchen appliances.</p>'
'</div>'
'<div class="vf-band-light">'
'<span class="vf-section-label">Topics</span>'
'<div class="vf-grid-3">'
'<div class="vf-card"><div class="vf-card-title">🌿 Compost</div><div class="vf-card-desc">Composting system, what goes in, and maintenance.</div></div>'
'<div class="vf-card"><div class="vf-card-title">🔌 Appliances</div><div class="vf-card-desc">Kitchen appliances, usage, and care.</div></div>'
'</div></div>'
)
},
{
"title": "Garden",
"path": "garden",
"tags": ["garden", "bbq", "fires"],
"desc": "Outdoor living — BBQ and fires",
"content": (
'<div class="vf-band-light">'
'<div class="eyebrow">Section</div>'
'<h1 class="display-xl">GARDEN</h1>'
'<p class="body-lg">Outdoor living — BBQ, fires, and garden setup.</p>'
'</div>'
'<div class="vf-band-light">'
'<span class="vf-section-label">Topics</span>'
'<div class="vf-grid-3">'
'<div class="vf-card"><div class="vf-card-title">🍖 BBQ</div><div class="vf-card-desc">BBQ setup, care, and usage.</div></div>'
'<div class="vf-card"><div class="vf-card-title">🔥 Fires</div><div class="vf-card-desc">Fire pits and outdoor heating.</div></div>'
'</div></div>'
)
},
{
"title": "Pets",
"path": "pets",
"tags": ["pets", "dogs", "fish"],
"desc": "Pet care — dogs and fish",
"content": (
'<div class="vf-band-light">'
'<div class="eyebrow">Section</div>'
'<h1 class="display-xl">PETS</h1>'
'<p class="body-lg">Our pets and how we care for them.</p>'
'</div>'
'<div class="vf-band-light">'
'<span class="vf-section-label">Topics</span>'
'<div class="vf-grid-3">'
'<div class="vf-card"><div class="vf-card-title">🐕 Dogs</div><div class="vf-card-desc">Dog care, feeding, and routines.</div></div>'
'<div class="vf-card"><div class="vf-card-title">🐟 Fish</div><div class="vf-card-desc">Fish tank setup, feeding, and maintenance.</div></div>'
'</div></div>'
)
},
{
"title": "Laundry",
"path": "laundry",
"tags": ["laundry", "washer", "drier"],
"desc": "Washer and drier notes",
"content": (
'<div class="vf-band-light">'
'<div class="eyebrow">Section</div>'
'<h1 class="display-xl">LAUNDRY</h1>'
'<p class="body-lg">Laundry appliances — washer and drier.</p>'
'</div>'
'<div class="vf-band-light">'
'<span class="vf-section-label">Topics</span>'
'<div class="vf-grid-3">'
'<div class="vf-card"><div class="vf-card-title">🌀 Washer</div><div class="vf-card-desc">Washing machine usage, programs, and maintenance.</div></div>'
'<div class="vf-card"><div class="vf-card-title">🌬 Drier</div><div class="vf-card-desc">Drier usage, settings, and lint care.</div></div>'
'</div></div>'
)
}
]
mutations = []
for idx, p in enumerate(pages):
content_escaped = p['content'].replace('\\', '\\\\').replace('"', '\\"').replace('\n', '\\n')
tag_str = json.dumps(p['tags'])
mutation = f''' p{idx}: pages {{
create(
title: "{p['title']}"
path: "{p['path']}"
content: "{content_escaped}"
editor: "wysiwyg"
isPublished: true
isPrivate: false
locale: "en"
tags: {tag_str}
description: "{p['desc']}"
) {{
page {{ id path title }}
responseResult {{ succeeded message }}
}}
}}'''
mutations.append(mutation)
query = 'mutation {\n' + '\n'.join(mutations) + '\n}'
payload = {"query": query}
print(json.dumps(payload))
PYEOF