diff --git a/craft_web/README.md b/craft_web/README.md
index a752113..4c9cc88 100644
--- a/craft_web/README.md
+++ b/craft_web/README.md
@@ -17,13 +17,18 @@ The intended implementation is deliberately boring to deploy:
The product scope and implementation phases are in [TASKS.md](TASKS.md). The
authoritative development rules and source map are in [AGENTS.md](AGENTS.md).
-## Current proof of concept
+## Current application
-The first deployable prototype includes the complete generated catalogue, all
-book themes, responsive filtering and sorting, a component workspace with basic
-totals, browser-local saving, and a provisional Roll20 export. It demonstrates
-the intended information architecture and visual direction; discipline-specific
-rules and authoritative final-output mapping remain tracked in `TASKS.md`.
+The deployable application includes the complete generated catalogue, all book
+themes, responsive filtering and sorting, a single-discipline component
+workspace, player limits and warnings, persistent personal ingredients, a
+searchable local recipe library, editable recipe import/export, whole-library
+backup/restore, print output, and Roll20 JSON download or clipboard export.
+
+Recipes and custom ingredients live only in the current browser profile. Clear
+site data only after downloading a library backup. Forge compatibility and
+statistics, trap adjudication, and repeated-effect edge cases remain visibly
+marked for manual book/GM review until the reference rules model is complete.
```sh
uv run python craft_web/tools/build.py
diff --git a/craft_web/TASKS.md b/craft_web/TASKS.md
index eaa28b2..1584944 100644
--- a/craft_web/TASKS.md
+++ b/craft_web/TASKS.md
@@ -22,7 +22,7 @@ remaining phases turn it into a trusted calculator and production application.
## Phase 0 — Decisions to vet
-- [ ] Approve the two-format model: editable `ravenous-workshop-recipe` files
+- [x] Approve the two-format model: editable `ravenous-workshop-recipe` files
for reopening and sharing, finalized `ravenous-roll20-craft` v1 files for
Roll20 import.
- [x] Approve all five initial disciplines: Forge, Restauration, Alchimie,
@@ -61,7 +61,7 @@ remaining phases turn it into a trusted calculator and production application.
Python reference model for all five disciplines.
- [ ] Implement explicit parsing for forge `change`, drawback reduction, bonus
reduction, alloy, and compatibility macros; fail on unknown mechanical macros.
-- [ ] Define and validate `ravenous-workshop-recipe` v1, including a catalog
+- [x] Define and validate `ravenous-workshop-recipe` v1, including a catalog
fingerprint and migration/error envelope.
- [ ] Turn curated `data/config/recipes.yaml` entries into golden fixtures and
add boundary tests for negative totals, repeated effects, finishing budgets,
@@ -118,7 +118,7 @@ remaining phases turn it into a trusted calculator and production application.
- [ ] Implement a local recipe library with rename, duplicate, pin, tag, sort,
search, delete recovery, timestamps, and graceful quota/private-mode errors.
-- [ ] Export/import one editable Workshop recipe and a complete library backup;
+- [x] Export/import one editable Workshop recipe and a complete library backup;
validate limits, versions, unknown fields, and source fingerprints.
- [ ] Add migration hooks and a comparison screen for recipes saved against an
older catalog revision; never silently rewrite selections.
@@ -128,7 +128,7 @@ remaining phases turn it into a trusted calculator and production application.
- [ ] Validate generated Roll20 payloads against
`docs/ravenous-craft-v1.schema.json`; test round trips through the existing
Roll20 Mod importer fixture model.
-- [ ] Provide download and clipboard actions with deterministic UTF-8 filenames,
+- [x] Provide download and clipboard actions with deterministic UTF-8 filenames,
success/error feedback, and recovery when Clipboard APIs are unavailable.
- [ ] Add print-friendly single-recipe and recipe-book views with generated
theme accents, clean monochrome fallback, effects, totals, and source version.
diff --git a/craft_web/schemas/workshop-recipe-v1.schema.json b/craft_web/schemas/workshop-recipe-v1.schema.json
new file mode 100644
index 0000000..46a3738
--- /dev/null
+++ b/craft_web/schemas/workshop-recipe-v1.schema.json
@@ -0,0 +1,34 @@
+{
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "$id": "https://books.dandaedre.com/RPG/ravenous_craft/workshop-recipe-v1.schema.json",
+ "title": "Ravenous Workshop editable recipe",
+ "type": "object",
+ "additionalProperties": false,
+ "required": ["format", "version", "catalog", "id", "name", "discipline", "artisan", "components"],
+ "properties": {
+ "format": { "const": "ravenous-workshop-recipe" },
+ "version": { "const": 1 },
+ "catalog": { "type": "string", "pattern": "^[a-f0-9]{12}$" },
+ "id": { "type": "string", "minLength": 1, "maxLength": 100 },
+ "name": { "type": "string", "minLength": 1, "maxLength": 150 },
+ "discipline": { "enum": ["Alchimie", "Brasserie", "Forge", "Restauration", "Pièges"] },
+ "notes": { "type": "string", "maxLength": 4000 },
+ "output_type": { "enum": ["attack", "protection", "consumable", "modifier"] },
+ "artisan": {
+ "type": "object",
+ "additionalProperties": false,
+ "required": ["intelligence", "skill", "excellence", "mastery", "finishing"],
+ "properties": {
+ "intelligence": { "type": "number" },
+ "skill": { "type": "number" },
+ "excellence": { "type": "number" },
+ "mastery": { "type": "number", "minimum": 0 },
+ "finishing": { "type": "number", "minimum": 0 }
+ }
+ },
+ "components": { "type": "array", "maxItems": 200, "items": { "type": "string", "maxLength": 200 } },
+ "custom_items": { "type": "array", "maxItems": 200, "items": { "type": "object" } },
+ "created": { "type": "string" },
+ "updated": { "type": "string" }
+ }
+}
diff --git a/craft_web/src/app.js b/craft_web/src/app.js
index 2283877..57cf9a5 100644
--- a/craft_web/src/app.js
+++ b/craft_web/src/app.js
@@ -2,114 +2,163 @@
'use strict';
const data = window.RAVENOUS_CRAFT_CATALOG || { entries: [], themes: [] };
const $ = id => document.getElementById(id);
+ const CATALOG_HASH = '{{CATALOG_HASH}}';
const CUSTOM_KEY = 'ravenous-craft-custom-ingredients';
const RECIPES_KEY = 'ravenous-craft-recipes';
- const state = { shown: 30, selected: [], custom: readLocal(CUSTOM_KEY, []) };
+ const THEME_KEY = 'ravenous-craft-theme';
+ const state = { shown: 30, selected: [], custom: readLocal(CUSTOM_KEY, []), editingId: null, fileMode: '' };
let catalog = [...data.entries, ...state.custom];
const numeric = value => value == null ? 0 : Number(value) || 0;
+ const optionalNumber = id => $(id).value === '' ? null : numeric($(id).value);
const fold = value => String(value || '').normalize('NFD').replace(/[\u0300-\u036f]/g, '').toLowerCase();
- const stars = value => { const n = numeric(value), a = Math.abs(n); return `${n < 0 ? '-' : ''}${a > 3 ? a : '★'.repeat(a)}${a === 0 || a > 3 ? '★' : ''}`; };
+ const stars = value => { const n=numeric(value), a=Math.abs(n); return `${n<0?'-':''}${a>3?a:'★'.repeat(a)}${a===0||a>3?'★':''}`; };
const text = item => Object.values(item.fields || {}).join(' ');
+ const uid = prefix => `${prefix}:${Date.now().toString(36)}:${Math.random().toString(36).slice(2,8)}`;
function readLocal(key, fallback) {
- try { const value = JSON.parse(localStorage.getItem(key) || 'null'); return Array.isArray(value) ? value : fallback; }
+ try { const value=JSON.parse(localStorage.getItem(key)||'null'); return Array.isArray(value)?value:fallback; }
catch (_) { return fallback; }
}
function writeLocal(key, value) {
- try { localStorage.setItem(key, JSON.stringify(value)); return true; }
- catch (_) { return false; }
+ try { localStorage.setItem(key,JSON.stringify(value)); return true; }
+ catch (_) { status('Stockage local indisponible ou saturé.',true); return false; }
}
+ function status(message, bad=false) { $('action-status').textContent=message; $('action-status').classList.toggle('bad',bad); }
function effect(item) {
- const entries = Object.entries(item.fields || {}).filter(([key]) => !/^(Nom|Matériau|Réagents|Solvants|Type)$/i.test(key));
- return entries.slice(-2).map(([key, value]) => `${key} : ${value}`).join(' · ') || 'Détails disponibles dans la source.';
+ const entries=Object.entries(item.fields||{}).filter(([key])=>!/^(Nom|Matériau|Réagents|Solvants|Type)$/i.test(key));
+ return entries.slice(-2).map(([key,value])=>`${key} : ${value}`).join(' · ')||'Détails disponibles dans la source.';
+ }
+ function selectedDiscipline() { return state.selected[0]?.discipline||''; }
+ function totals() {
+ const sum=key=>state.selected.reduce((total,item)=>total+numeric(item[key]),0);
+ return {tier:Math.max(0,...state.selected.map(i=>numeric(i.tier))),cost:sum('cost'),difficulty:sum('difficulty'),toxicity:sum('toxicity'),finishing:sum('finishing')};
+ }
+ function validation() {
+ const value=totals(), discipline=selectedDiscipline(), errors=[], warnings=[];
+ if (!state.selected.length) errors.push('Ajoutez au moins un composant.');
+ if (new Set(state.selected.map(item=>item.discipline)).size>1) errors.push('Une recette ne peut contenir qu’une discipline.');
+ if (value.tier>numeric($('mastery').value)) warnings.push(`Tier ${value.tier} supérieur à la maîtrise ${numeric($('mastery').value)}.`);
+ if (value.difficulty>numeric($('craft-level').textContent)) warnings.push(`Difficulté ${value.difficulty} supérieure au niveau ${$('craft-level').textContent}.`);
+ if (value.finishing>numeric($('finishing-limit').value)) warnings.push(`Finition ${value.finishing} supérieure à la spécialité ${numeric($('finishing-limit').value)}.`);
+ if (state.selected.some(item=>item.custom)) warnings.push('Cette recette contient des ingrédients personnels à faire valider par le MJ.');
+ if (discipline==='Forge'||discipline==='Pièges') warnings.push('Les statistiques finales et compatibilités complexes restent à vérifier selon le livre.');
+ return {errors,warnings,value};
}
- function selectedDiscipline() { return state.selected[0]?.discipline || ''; }
function filtered() {
- const query = fold($('search').value), discipline = $('discipline').value, stage = $('stage').value;
- const limits = [['tier','tier'],['difficulty','difficulty'],['toxicity','toxicity']];
- const entries = catalog.filter(item => (!discipline || item.discipline === discipline) && (!stage || item.stage === stage) &&
- (!query || fold(`${item.name} ${item.stage} ${text(item)}`).includes(query)) && limits.every(([id,key]) => !$(id).value || item[key] == null || numeric(item[key]) <= numeric($(id).value)));
- const sort = $('sort').value;
- entries.sort((a,b) => sort === 'name' ? a.name.localeCompare(b.name, 'fr') : numeric(a[sort]) - numeric(b[sort]) || a.name.localeCompare(b.name, 'fr'));
+ const query=fold($('search').value), discipline=$('discipline').value, stage=$('stage').value;
+ const limits=[['tier','tier'],['cost','cost'],['difficulty','difficulty'],['toxicity','toxicity'],['finishing','finishing']];
+ const entries=catalog.filter(item=>(!discipline||item.discipline===discipline)&&(!stage||item.stage===stage)&&
+ (!query||fold(`${item.name} ${item.stage} ${text(item)}`).includes(query))&&limits.every(([id,key])=>!$(id).value||item[key]==null||numeric(item[key])<=numeric($(id).value)));
+ const sort=$('sort').value;
+ entries.sort((a,b)=>sort==='name'?a.name.localeCompare(b.name,'fr'):numeric(a[sort])-numeric(b[sort])||a.name.localeCompare(b.name,'fr'));
return entries;
}
- function renderStages() {
- const current = $('stage').value, discipline = $('discipline').value;
- const stages = [...new Set(catalog.filter(i => !discipline || i.discipline === discipline).map(i => i.stage))].sort();
- $('stage').replaceChildren(new Option('Toutes les étapes', ''), ...stages.map(value => new Option(value, value)));
- if (stages.includes(current)) $('stage').value = current;
+ function persistFilterUrl() {
+ const params=new URLSearchParams();
+ ['search','discipline','stage','tier','cost','difficulty','toxicity','finishing','sort'].forEach(id=>{if($(id).value&&!(id==='sort'&&$(id).value==='name'))params.set(id,$(id).value);});
+ history.replaceState(null,'',`${location.pathname}${params.size?`?${params}`:''}${location.hash}`);
+ }
+ function restoreFilterUrl() {
+ const params=new URLSearchParams(location.search);
+ ['search','discipline','tier','cost','difficulty','toxicity','finishing','sort'].forEach(id=>{if(params.has(id))$(id).value=params.get(id);});
+ return params.get('stage')||'';
+ }
+ function renderStages(preferred='') {
+ const current=preferred||$('stage').value, discipline=$('discipline').value;
+ const stages=[...new Set(catalog.filter(i=>!discipline||i.discipline===discipline).map(i=>i.stage))].sort();
+ $('stage').replaceChildren(new Option('Toutes les étapes',''),...stages.map(value=>new Option(value,value)));
+ if(stages.includes(current))$('stage').value=current;
}
function addItem(item) {
- const locked = selectedDiscipline();
- if (locked && item.discipline !== locked) return;
- state.selected.push(item); renderSelection(); location.hash = 'atelier';
+ const locked=selectedDiscipline(); if(locked&&item.discipline!==locked)return;
+ state.selected.push(item); renderSelection(); location.hash='atelier';
}
function removeCustom(item) {
- if (!confirm(`Supprimer « ${item.name} » de vos ingrédients personnels ?`)) return;
- state.custom = state.custom.filter(entry => entry.id !== item.id);
- state.selected = state.selected.filter(entry => entry.id !== item.id);
- catalog = [...data.entries, ...state.custom]; writeLocal(CUSTOM_KEY, state.custom);
- refreshCatalog(); renderSelection();
+ if(!confirm(`Supprimer « ${item.name} » de vos ingrédients personnels ?`))return;
+ state.custom=state.custom.filter(entry=>entry.id!==item.id); state.selected=state.selected.filter(entry=>entry.id!==item.id);
+ catalog=[...data.entries,...state.custom]; writeLocal(CUSTOM_KEY,state.custom); refreshCatalog(); renderSelection();
}
function renderCards() {
- const entries = filtered(), locked = selectedDiscipline();
- $('result-count').textContent = `${entries.length} résultat${entries.length > 1 ? 's' : ''}`;
- $('cards').replaceChildren(...entries.slice(0, state.shown).map(item => {
- const card = document.createElement('article'); card.className = `card${item.custom ? ' custom-card' : ''}`;
- const metrics = [['T',item.tier],['Coût',item.cost],['Diff.',item.difficulty],['Tox.',item.toxicity]].filter(([,v]) => v != null);
- card.innerHTML = '
';
- const meta=card.querySelectorAll('.card-meta span'); meta[0].textContent=item.discipline; meta[1].textContent=`${item.custom ? 'Personnel · ' : ''}${item.stage}`;
- card.querySelector('h3').textContent = item.name; card.querySelector('.effect').textContent = effect(item);
- const box = card.querySelector('.metrics'); metrics.forEach(([k,v]) => { const span=document.createElement('span'); span.textContent=`${k} ${k==='T'?v:stars(v)}`; box.append(span); });
- const add = card.querySelector('.add-item'), incompatible = locked && item.discipline !== locked;
- add.disabled = Boolean(incompatible); add.textContent = incompatible ? `Réservé : ${locked}` : 'Ajouter';
- add.title = incompatible ? `Cette recette utilise déjà l'artisanat ${locked}.` : '';
- add.addEventListener('click', () => addItem(item));
- if (item.custom) { const remove=document.createElement('button'); remove.type='button'; remove.className='delete-custom'; remove.textContent='Supprimer'; remove.onclick=()=>removeCustom(item); card.querySelector('.card-actions').append(remove); }
+ const entries=filtered(), locked=selectedDiscipline(); $('result-count').textContent=`${entries.length} résultat${entries.length>1?'s':''}`;
+ $('cards').replaceChildren(...entries.slice(0,state.shown).map(item=>{
+ const card=document.createElement('article'); card.className=`card${item.custom?' custom-card':''}`;
+ card.innerHTML='
';
+ const meta=card.querySelectorAll('.card-meta span'); meta[0].textContent=item.discipline; meta[1].textContent=`${item.custom?'Personnel · ':''}${item.stage}`;
+ card.querySelector('h3').textContent=item.name; card.querySelector('.effect').textContent=effect(item);
+ const metrics=[['T',item.tier],['Coût',item.cost],['Diff.',item.difficulty],['Tox.',item.toxicity],['Fin.',item.finishing]].filter(([,v])=>v!=null), box=card.querySelector('.metrics');
+ metrics.forEach(([key,value])=>{const span=document.createElement('span');span.textContent=`${key} ${key==='T'?value:stars(value)}`;box.append(span);});
+ const add=card.querySelector('.add-item'), incompatible=locked&&item.discipline!==locked; add.disabled=Boolean(incompatible); add.textContent=incompatible?`Réservé : ${locked}`:'Ajouter'; add.title=incompatible?`Cette recette utilise déjà l'artisanat ${locked}.`:''; add.onclick=()=>addItem(item);
+ if(item.custom){const remove=document.createElement('button');remove.type='button';remove.className='delete-custom';remove.textContent='Supprimer';remove.onclick=()=>removeCustom(item);card.querySelector('.card-actions').append(remove);}
return card;
}));
- $('more').hidden = entries.length <= state.shown;
+ $('more').hidden=entries.length<=state.shown; persistFilterUrl();
}
function renderSelection() {
- const box = $('selection'), locked = selectedDiscipline(); box.replaceChildren();
- $('recipe-discipline').disabled = Boolean(locked); if (locked) $('recipe-discipline').value = locked;
- if (!state.selected.length) { const p=document.createElement('p'); p.className='empty'; p.textContent='Aucun composant sélectionné.'; box.append(p); }
- state.selected.forEach((item,index) => { const row=document.createElement('div'); row.className='selected-item'; row.innerHTML='
'; row.querySelector('b').textContent=item.name; row.querySelector('small').textContent=`${item.discipline} · ${item.stage}${item.custom?' · personnel':''}`; row.querySelector('button').onclick=()=>{state.selected.splice(index,1);renderSelection();}; box.append(row); });
- const sum = key => state.selected.reduce((total,item)=>total+numeric(item[key]),0);
- $('sum-tier').textContent = Math.max(0,...state.selected.map(i=>numeric(i.tier)));
- $('sum-cost').textContent=stars(sum('cost')); $('sum-difficulty').textContent=stars(sum('difficulty')); $('sum-toxicity').textContent=stars(sum('toxicity'));
+ const box=$('selection'), locked=selectedDiscipline();
const level=numeric($('intelligence').value)+numeric($('skill').value)+numeric($('excellence').value); $('craft-level').textContent=level;
- const invalid=sum('difficulty')>level, validity=$('validity'); validity.className=`validity ${invalid?'bad':'good'}`; validity.firstElementChild.textContent=invalid?'Niveau dépassé':'Recette possible'; validity.lastElementChild.textContent=invalid?`Difficulté ${sum('difficulty')} pour un niveau ${level}.`:`${locked || 'Discipline libre'} · niveau ${level} · ${state.selected.length} composant(s).`;
+ const result=validation(); box.replaceChildren();
+ $('recipe-discipline').disabled=Boolean(locked); if(locked)$('recipe-discipline').value=locked;
+ if(!state.selected.length){const p=document.createElement('p');p.className='empty';p.textContent='Aucun composant sélectionné.';box.append(p);}
+ state.selected.forEach((item,index)=>{const row=document.createElement('div');row.className='selected-item';row.innerHTML='
';row.querySelector('b').textContent=item.name;row.querySelector('small').textContent=`${item.discipline} · ${item.stage}${item.custom?' · personnel':''}`;row.querySelector('button').onclick=()=>{state.selected.splice(index,1);renderSelection();};box.append(row);});
+ $('sum-tier').textContent=result.value.tier; $('sum-cost').textContent=stars(result.value.cost); $('sum-difficulty').textContent=stars(result.value.difficulty); $('sum-toxicity').textContent=stars(result.value.toxicity);
+ const validity=$('validity'), messages=[...result.errors,...result.warnings]; validity.className=`validity ${result.errors.length?'bad':result.warnings.length?'warn':'good'}`; validity.firstElementChild.textContent=result.errors.length?'Recette incomplète':result.warnings.length?'À vérifier':'Recette valide'; validity.lastElementChild.textContent=messages.join(' ')||`${locked||'Discipline libre'} · niveau ${level} · ${state.selected.length} composant(s).`;
renderCards();
}
function addCustom(event) {
- event.preventDefault();
- const name=$('custom-name').value.trim(), stage=$('custom-stage').value.trim(), status=$('custom-status');
- if (!name || !stage) { status.textContent='Le nom et l’étape sont requis.'; return; }
- const optional = id => $(id).value === '' ? null : numeric($(id).value);
- const item={id:`custom:${Date.now().toString(36)}:${Math.random().toString(36).slice(2,8)}`,custom:true,name,discipline:$('custom-discipline').value,stage,tier:optional('custom-tier'),cost:optional('custom-cost'),difficulty:optional('custom-difficulty'),toxicity:optional('custom-toxicity'),finishing:null,source:'local',fields:{Effet:$('custom-effect').value.trim() || 'Ingrédient personnel'}};
- state.custom.unshift(item);
- if (!writeLocal(CUSTOM_KEY,state.custom)) { state.custom.shift(); status.textContent='Stockage local indisponible : ingrédient non enregistré.'; return; }
- catalog=[...data.entries,...state.custom]; event.target.reset(); $('custom-discipline').value=item.discipline; status.textContent=`« ${name} » est enregistré sur cet appareil.`; refreshCatalog();
+ event.preventDefault(); const name=$('custom-name').value.trim(),stage=$('custom-stage').value.trim(),message=$('custom-status');
+ if(!name||!stage){message.textContent='Le nom et l’étape sont requis.';return;}
+ const item={id:uid('custom'),custom:true,name,discipline:$('custom-discipline').value,stage,tier:optionalNumber('custom-tier'),cost:optionalNumber('custom-cost'),difficulty:optionalNumber('custom-difficulty'),toxicity:optionalNumber('custom-toxicity'),finishing:null,source:'local',fields:{Effet:$('custom-effect').value.trim()||'Ingrédient personnel'}};
+ state.custom.unshift(item); if(!writeLocal(CUSTOM_KEY,state.custom)){state.custom.shift();message.textContent='Ingrédient non enregistré.';return;}
+ catalog=[...data.entries,...state.custom];event.target.reset();$('custom-discipline').value=item.discipline;message.textContent=`« ${name} » est enregistré sur cet appareil.`;refreshCatalog();
+ }
+ function recipeDocument() {
+ return {format:'ravenous-workshop-recipe',version:1,catalog:CATALOG_HASH,id:state.editingId||uid('recipe'),name:($('recipe-name').value||'Sans nom').trim().slice(0,150),discipline:selectedDiscipline()||$('recipe-discipline').value,notes:$('recipe-notes').value.slice(0,4000),output_type:$('output-type').value,artisan:{intelligence:numeric($('intelligence').value),skill:numeric($('skill').value),excellence:numeric($('excellence').value),mastery:numeric($('mastery').value),finishing:numeric($('finishing-limit').value)},components:state.selected.map(item=>item.id),custom_items:state.selected.filter(item=>item.custom)};
+ }
+ function validateRecipeDocument(doc) {
+ if(!doc||doc.format!=='ravenous-workshop-recipe'||doc.version!==1)throw new Error('Format de recette non reconnu.');
+ if(!Array.isArray(doc.components)||doc.components.length>200)throw new Error('Liste de composants invalide.');
+ if(typeof doc.name!=='string'||!doc.name.trim()||doc.name.length>150)throw new Error('Nom de recette invalide.');
+ if(!['Alchimie','Brasserie','Forge','Restauration','Pièges'].includes(doc.discipline))throw new Error('Discipline inconnue.');
+ return doc;
}
- function refreshCatalog() { $('catalog-count').textContent=catalog.length; renderStages(); renderCards(); }
function saveRecipe() {
- const recipes=readLocal(RECIPES_KEY,[]); recipes.unshift({name:$('recipe-name').value||'Sans nom',discipline:$('recipe-discipline').value,saved:new Date().toISOString(),items:state.selected.map(i=>i.id)}); writeLocal(RECIPES_KEY,recipes.slice(0,50)); renderLibrary();
+ const doc=recipeDocument(),recipes=readLocal(RECIPES_KEY,[]),now=new Date().toISOString(),index=recipes.findIndex(item=>item.id===doc.id); doc.updated=now; doc.created=index>=0?recipes[index].created||now:now;
+ if(index>=0)recipes[index]=doc;else recipes.unshift(doc); if(writeLocal(RECIPES_KEY,recipes.slice(0,100))){state.editingId=doc.id;status('Recette sauvegardée localement.');renderLibrary();}
+ }
+ function loadRecipe(doc) {
+ try{validateRecipeDocument(doc);(doc.custom_items||[]).forEach(item=>{if(item&&item.custom&&!catalog.some(entry=>entry.id===item.id)){state.custom.push(item);catalog.push(item);}});writeLocal(CUSTOM_KEY,state.custom);
+ const missing=[];state.selected=doc.components.map(id=>catalog.find(item=>item.id===id)||(missing.push(id),null)).filter(Boolean);state.editingId=doc.id||uid('recipe');$('recipe-name').value=doc.name;$('summary-name').textContent=doc.name;$('recipe-discipline').value=doc.discipline;$('recipe-notes').value=String(doc.notes||'').slice(0,4000);$('output-type').value=['attack','protection','consumable','modifier'].includes(doc.output_type)?doc.output_type:'consumable';
+ const artisan=doc.artisan||{};[['intelligence',3],['skill',4],['excellence',1],['mastery',3],['finishing-limit',3]].forEach(([id,fallback])=>$(id).value=numeric(artisan[id==='finishing-limit'?'finishing':id]??fallback));renderSelection();refreshCatalog();location.hash='atelier';status(`${missing.length?`${missing.length} composant(s) introuvable(s). `:''}Recette chargée${doc.catalog&&doc.catalog!==CATALOG_HASH?' depuis une autre version du catalogue.':''}`,Boolean(missing.length));
+ }catch(error){status(error.message,true);}
}
function renderLibrary() {
- const box=$('saved-recipes'), recipes=readLocal(RECIPES_KEY,[]); box.replaceChildren(); if(!recipes.length){const p=document.createElement('p');p.className='empty';p.textContent='Aucune recette sauvegardée pour le moment.';box.append(p);return;} recipes.forEach(recipe=>{const card=document.createElement('article');card.className='saved-card';card.innerHTML='';card.querySelector('h3').textContent=recipe.name;card.querySelector('p').textContent=`${recipe.discipline} · ${recipe.items.length} composant(s) · sauvegarde locale`;box.append(card);});
+ const box=$('saved-recipes'),query=fold($('library-search').value),recipes=readLocal(RECIPES_KEY,[]).filter(recipe=>!query||fold(`${recipe.name} ${recipe.discipline} ${recipe.notes||''}`).includes(query));box.replaceChildren();
+ if(!recipes.length){const p=document.createElement('p');p.className='empty';p.textContent=query?'Aucune recette ne correspond.':'Aucune recette sauvegardée pour le moment.';box.append(p);return;}
+ recipes.forEach(recipe=>{const card=document.createElement('article');card.className='saved-card';const title=document.createElement('h3'),meta=document.createElement('p'),actions=document.createElement('div');title.textContent=recipe.name;meta.textContent=`${recipe.discipline} · ${recipe.components?.length||0} composant(s) · ${new Date(recipe.updated||recipe.created).toLocaleDateString('fr-FR')}`;actions.className='saved-actions';
+ [['Ouvrir',()=>loadRecipe(recipe)],['Dupliquer',()=>{const clone={...recipe,id:uid('recipe'),name:`${recipe.name} — copie`,created:new Date().toISOString(),updated:new Date().toISOString()};const all=readLocal(RECIPES_KEY,[]);all.unshift(clone);writeLocal(RECIPES_KEY,all);renderLibrary();}],['Supprimer',()=>{if(confirm(`Supprimer « ${recipe.name} » ?`)){writeLocal(RECIPES_KEY,readLocal(RECIPES_KEY,[]).filter(item=>item.id!==recipe.id));renderLibrary();}}]].forEach(([label,handler])=>{const button=document.createElement('button');button.type='button';button.textContent=label;button.onclick=handler;actions.append(button);});card.append(title,meta,actions);box.append(card);});
}
- function exportJson() {
- const payload={format:'ravenous-roll20-craft',version:1,craft:{name:$('recipe-name').value,discipline:$('recipe-discipline').value,recipe:state.selected.map(i=>i.name).join('; '),level:numeric($('craft-level').textContent),difficulty:state.selected.reduce((n,i)=>n+numeric(i.difficulty),0)},items:[{type:'consumable',name:$('recipe-name').value||'Création artisanale',kind:'Autre',quantity:1,description:state.selected.map(i=>`${i.name}: ${effect(i)}`).join('\n')}]};
- const blob=new Blob([JSON.stringify(payload,null,2)+'\n'],{type:'application/json'}), link=document.createElement('a');link.href=URL.createObjectURL(blob);link.download='ravenous-craft.json';link.click();URL.revokeObjectURL(link.href);
+ function roll20Payload() {
+ const doc=recipeDocument(),result=validation(),description=[doc.notes,...state.selected.map(item=>`${item.name} : ${effect(item)}`),...result.warnings.map(value=>`À vérifier : ${value}`)].filter(Boolean).join('\n');let item={type:doc.output_type,name:doc.name};
+ if(doc.output_type==='consumable')item={...item,kind:doc.discipline==='Restauration'?'Nourriture':doc.discipline==='Alchimie'?'Potion':'Autre',quantity:1,description};
+ else if(doc.output_type==='modifier')item={...item,description}; else if(doc.output_type==='protection')item={...item,effects:description}; else item={...item,notes:description};
+ return {format:'ravenous-roll20-craft',version:1,craft:{name:doc.name,discipline:doc.discipline,recipe:state.selected.map(i=>i.name).join('; '),level:numeric($('craft-level').textContent),difficulty:result.value.difficulty},items:[item]};
}
- function setTheme(value){ document.documentElement.dataset.theme=value; localStorage.setItem('ravenous-craft-theme',value); $('theme').value=value; }
- setTheme(localStorage.getItem('ravenous-craft-theme')||'warm');
- ['search','stage','tier','difficulty','toxicity','sort'].forEach(id => $(id).addEventListener('input',()=>{state.shown=30;renderCards();}));
- $('discipline').addEventListener('change',()=>{renderStages();renderCards();document.querySelectorAll('#discipline-tabs button').forEach(b=>b.classList.toggle('active',b.dataset.value===$('discipline').value));});
- $('discipline-tabs').addEventListener('click',event=>{if(!event.target.dataset.value&&event.target.tagName!=='BUTTON')return;$('discipline').value=event.target.dataset.value;renderStages();renderCards();document.querySelectorAll('#discipline-tabs button').forEach(b=>b.classList.toggle('active',b===event.target));});
- $('clear').onclick=()=>{['search','discipline','stage','tier','difficulty','toxicity'].forEach(id=>$(id).value='');renderStages();renderCards();}; $('more').onclick=()=>{state.shown+=30;renderCards();}; $('theme').onchange=event=>setTheme(event.target.value);
- $('custom-form').addEventListener('submit',addCustom);
- ['recipe-name','intelligence','skill','excellence'].forEach(id=>$(id).addEventListener('input',()=>{ $('summary-name').textContent=$('recipe-name').value||'Sans nom';renderSelection();})); $('save').onclick=saveRecipe; $('export-json').onclick=exportJson;
- refreshCatalog(); renderSelection(); renderLibrary();
+ function download(value,filename) {const blob=new Blob([JSON.stringify(value,null,2)+'\n'],{type:'application/json'}),link=document.createElement('a');link.href=URL.createObjectURL(blob);link.download=filename;link.click();setTimeout(()=>URL.revokeObjectURL(link.href),0);}
+ function safeFilename(value,suffix){const base=fold(value).replace(/[^a-z0-9]+/g,'-').replace(/^-|-$/g,'').slice(0,60)||'recette';return `${base}.${suffix}`;}
+ function exportWorkshop(){const doc=recipeDocument();download(doc,safeFilename(doc.name,'ravenous.json'));status('Recette éditable téléchargée.');}
+ function exportRoll20(){const check=validation();if(check.errors.length){status(check.errors.join(' '),true);return;}const value=roll20Payload();download(value,safeFilename(value.craft.name,'roll20.json'));status('Export Roll20 téléchargé.');}
+ async function copyRoll20(){const check=validation();if(check.errors.length){status(check.errors.join(' '),true);return;}const value=JSON.stringify(roll20Payload(),null,2);try{await navigator.clipboard.writeText(value);status('JSON Roll20 copié.');}catch(_){const area=document.createElement('textarea');area.value=value;document.body.append(area);area.select();const ok=document.execCommand('copy');area.remove();status(ok?'JSON Roll20 copié.':'Copie impossible : utilisez le téléchargement.',!ok);}}
+ function chooseFile(mode){state.fileMode=mode;$('file-input').value='';$('file-input').click();}
+ function importFile(event){const file=event.target.files[0];if(!file)return;if(file.size>2_000_000){status('Fichier trop volumineux.',true);return;}const reader=new FileReader();reader.onload=()=>{try{const value=JSON.parse(reader.result);if(state.fileMode==='recipe')loadRecipe(validateRecipeDocument(value));else{if(!value||value.format!=='ravenous-workshop-library'||value.version!==1||!Array.isArray(value.recipes)||value.recipes.length>100)throw new Error('Sauvegarde de bibliothèque invalide.');value.recipes.forEach(validateRecipeDocument);if(writeLocal(RECIPES_KEY,value.recipes)){renderLibrary();status(`${value.recipes.length} recette(s) restaurée(s).`);}}}catch(error){status(`Import impossible : ${error.message}`,true);}};reader.onerror=()=>status('Lecture du fichier impossible.',true);reader.readAsText(file,'utf-8');}
+ function backupLibrary(){const recipes=readLocal(RECIPES_KEY,[]);download({format:'ravenous-workshop-library',version:1,catalog:CATALOG_HASH,exported:new Date().toISOString(),recipes},'ravenous-bibliotheque.json');status(`${recipes.length} recette(s) sauvegardée(s).`);}
+ function refreshCatalog(){ $('catalog-count').textContent=catalog.length;renderStages();renderCards(); }
+ function setTheme(value){document.documentElement.dataset.theme=value;try{localStorage.setItem(THEME_KEY,value);}catch(_){}$('theme').value=value;}
+ const wantedStage=restoreFilterUrl();let initialTheme='warm';try{initialTheme=localStorage.getItem(THEME_KEY)||'warm';}catch(_){}setTheme(initialTheme);renderStages(wantedStage);
+ ['search','stage','tier','cost','difficulty','toxicity','finishing','sort'].forEach(id=>$(id).addEventListener('input',()=>{state.shown=30;renderCards();}));
+ $('discipline').onchange=()=>{renderStages();renderCards();document.querySelectorAll('#discipline-tabs button').forEach(button=>button.classList.toggle('active',button.dataset.value===$('discipline').value));};
+ $('discipline-tabs').onclick=event=>{if(!event.target.dataset.value&&event.target.tagName!=='BUTTON')return;$('discipline').value=event.target.dataset.value;renderStages();renderCards();document.querySelectorAll('#discipline-tabs button').forEach(button=>button.classList.toggle('active',button===event.target));};
+ $('clear').onclick=()=>{['search','discipline','stage','tier','cost','difficulty','toxicity','finishing'].forEach(id=>$(id).value='');renderStages();renderCards();};$('more').onclick=()=>{state.shown+=30;renderCards();};$('theme').onchange=event=>setTheme(event.target.value);$('custom-form').onsubmit=addCustom;
+ ['recipe-name','intelligence','skill','excellence','mastery','finishing-limit','output-type','recipe-notes'].forEach(id=>$(id).addEventListener('input',()=>{$('summary-name').textContent=$('recipe-name').value||'Sans nom';renderSelection();}));
+ $('save').onclick=saveRecipe;$('export-workshop').onclick=exportWorkshop;$('export-json').onclick=exportRoll20;$('copy-json').onclick=copyRoll20;$('print-recipe').onclick=()=>window.print();$('library-search').oninput=renderLibrary;$('import-recipe').onclick=()=>chooseFile('recipe');$('restore-library').onclick=()=>chooseFile('library');$('backup-library').onclick=backupLibrary;$('file-input').onchange=importFile;
+ refreshCatalog();renderSelection();renderLibrary();
})();
diff --git a/craft_web/src/index.html b/craft_web/src/index.html
index f198763..9d7900e 100644
--- a/craft_web/src/index.html
+++ b/craft_web/src/index.html
@@ -29,7 +29,8 @@
-
+
+
+ Ingrédient personnel
@@ -55,21 +56,25 @@
02Atelier de recette
Prototype interactif : les sélections sont déjà calculées en direct.
diff --git a/craft_web/src/styles.css b/craft_web/src/styles.css
index 03c461e..6653f62 100644
--- a/craft_web/src/styles.css
+++ b/craft_web/src/styles.css
@@ -2,3 +2,4 @@
*{box-sizing:border-box}html{scroll-behavior:smooth}body{margin:0;color:var(--ink);background:var(--paper);font:15px/1.55 "Libre Baskerville",Georgia,serif;background-image:radial-gradient(circle at 10% 5%,color-mix(in srgb,var(--gold) 12%,transparent),transparent 28%),linear-gradient(90deg,color-mix(in srgb,var(--blood) 3%,transparent) 1px,transparent 1px);background-size:auto,32px 32px}button,input,select{font:inherit}button,select{cursor:pointer}.topbar{position:sticky;z-index:20;top:0;display:grid;grid-template-columns:1fr auto 1fr;align-items:center;gap:28px;padding:12px max(24px,calc((100vw - 1380px)/2));border-bottom:1px solid var(--border);background:color-mix(in srgb,var(--surface) 92%,transparent);backdrop-filter:blur(14px)}.brand{display:flex;align-items:center;gap:12px;color:inherit;text-decoration:none}.brand-mark{display:grid;place-items:center;width:40px;height:40px;color:var(--surface);background:var(--blood);font:700 21px Cinzel,serif;transform:rotate(45deg)}.brand-mark::first-letter{transform:rotate(-45deg)}.brand b{display:block;font:700 15px Cinzel,serif}.brand small{display:block;color:var(--muted);font-size:9px;text-transform:uppercase;letter-spacing:.1em}.topbar nav{display:flex;gap:6px}.topbar nav a{padding:8px 14px;color:var(--muted);font:600 11px Cinzel,serif;text-decoration:none;text-transform:uppercase}.topbar nav a:hover{color:var(--blood);background:var(--accent)}.theme-picker{justify-self:end;color:var(--muted);font-size:10px;text-transform:uppercase}.theme-picker select{margin-left:8px;padding:6px;border:1px solid var(--border);background:var(--surface);color:var(--ink)}main{max-width:1400px;margin:auto;padding:0 22px}.hero{display:grid;grid-template-columns:1.4fr 1fr;gap:60px;align-items:end;padding:80px 30px 52px}.eyebrow{margin:0 0 8px;color:var(--dark-gold);font:700 10px Cinzel,serif;letter-spacing:.14em;text-transform:uppercase}.hero h1{max-width:780px;margin:0;color:var(--blood);font:700 clamp(34px,5vw,68px)/1.05 Cinzel,serif}.hero>div>p:last-child{max-width:680px;color:var(--muted);font-size:17px}.hero-stats{display:grid;grid-template-columns:repeat(3,1fr);border:1px solid var(--border);background:color-mix(in srgb,var(--surface) 78%,transparent);box-shadow:var(--shadow)}.hero-stats div{padding:20px;border-right:1px solid var(--border)}.hero-stats div:last-child{border:0}.hero-stats strong,.hero-stats span{display:block}.hero-stats strong{color:var(--blood);font:700 25px Cinzel,serif}.hero-stats span{color:var(--muted);font-size:9px;text-transform:uppercase}.workspace{display:grid;grid-template-columns:280px 1fr;min-height:760px;border:1px solid var(--border);background:var(--surface);box-shadow:var(--shadow)}.filters{padding:26px;border-right:1px solid var(--border);background:color-mix(in srgb,var(--accent) 45%,var(--surface))}.section-heading{display:flex;gap:13px;align-items:start;margin-bottom:22px}.section-heading>span{color:var(--gold);font:700 24px Cinzel,serif}.section-heading h2{margin:0;color:var(--blood);font:700 22px Cinzel,serif}.section-heading p{margin:2px 0;color:var(--muted);font-size:11px}.filters>label,.field-pair label{display:block;margin:13px 0;color:var(--muted);font-size:9px;text-transform:uppercase;letter-spacing:.08em}.filters input,.filters select,.field-pair input,.field-pair select,.artisan-levels input{width:100%;height:38px;margin-top:4px;padding:7px 9px;border:1px solid var(--border);background:var(--surface);color:var(--ink)}.range-row,.field-pair{display:grid;grid-template-columns:1fr 1fr;gap:9px}.filter-actions{display:flex;align-items:center;justify-content:space-between;margin-top:18px}.filter-actions span{color:var(--blood);font-size:11px}.quiet,.secondary,.more{padding:8px 12px;border:1px solid var(--gold);background:transparent;color:var(--dark-gold)}.source-note{margin-top:35px;padding:14px;border-left:3px solid var(--gold);background:var(--surface);color:var(--muted);font-size:10px}.source-note b{color:var(--dark-gold);font:700 10px Cinzel,serif}.source-note p{margin:4px 0}.catalog-panel{min-width:0;padding:22px}.catalog-toolbar{display:flex;justify-content:space-between;gap:15px;align-items:center;margin-bottom:18px}.discipline-tabs{display:flex;gap:4px;overflow:auto}.discipline-tabs button{padding:8px 11px;border:0;background:transparent;color:var(--muted);font:700 10px Cinzel,serif}.discipline-tabs button.active{color:var(--surface);background:var(--blood)}.catalog-toolbar label{color:var(--muted);font-size:9px;text-transform:uppercase}.catalog-toolbar select{margin-left:6px;padding:7px;border:1px solid var(--border);background:var(--surface)}.cards{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:12px}.card{position:relative;display:flex;flex-direction:column;min-height:195px;padding:16px;border:1px solid var(--border);border-top:3px solid var(--gold);background:var(--paper);transition:.18s transform,.18s box-shadow}.card:hover{transform:translateY(-2px);box-shadow:var(--shadow)}.card-meta{display:flex;justify-content:space-between;color:var(--muted);font:700 8px Cinzel,serif;text-transform:uppercase}.card h3{margin:9px 0 4px;color:var(--blood);font:700 15px Cinzel,serif}.card .effect{display:-webkit-box;overflow:hidden;margin:0;color:var(--muted);font-size:11px;-webkit-line-clamp:3;-webkit-box-orient:vertical}.metrics{display:flex;gap:5px;margin:auto 0 10px;padding-top:10px}.metrics span{padding:3px 6px;background:var(--accent);color:var(--dark-gold);font-size:9px}.card button{align-self:end;padding:6px 10px;border:0;background:var(--blood);color:var(--surface);font:700 9px Cinzel,serif}.more{display:block;margin:18px auto 0}.composer{margin:70px 0;padding:34px;background:var(--ink);color:var(--surface);box-shadow:var(--shadow)}.section-heading.light h2{color:var(--paper)}.section-heading.light p{color:color-mix(in srgb,var(--paper) 66%,transparent)}.composer-grid{display:grid;grid-template-columns:1.6fr .8fr;gap:22px}.recipe-form,.recipe-summary{padding:22px;background:var(--surface);color:var(--ink)}.artisan-levels{display:grid;grid-template-columns:repeat(3,80px 20px) 1fr;align-items:end;gap:6px;padding:13px;background:var(--accent)}.artisan-levels label{color:var(--muted);font-size:8px;text-transform:uppercase}.artisan-levels span{align-self:center;color:var(--gold);font-weight:bold}.artisan-levels output{justify-self:end;color:var(--blood);font:700 38px Cinzel,serif}.drop-zone{display:flex;gap:12px;align-items:center;margin:16px 0;padding:15px;border:1px dashed var(--gold);color:var(--muted)}.drop-zone span{color:var(--blood);font-size:24px}.drop-zone b{color:var(--dark-gold);font:700 10px Cinzel,serif}.drop-zone p{margin:2px 0;font-size:10px}.selection{display:grid;gap:6px}.selected-item{display:grid;grid-template-columns:1fr auto;gap:10px;padding:10px;border-left:3px solid var(--gold);background:var(--paper)}.selected-item b{color:var(--blood);font:700 11px Cinzel,serif}.selected-item small{display:block;color:var(--muted)}.selected-item button{border:0;background:transparent;color:var(--blood)}.empty{color:var(--muted);font-style:italic}.recipe-summary{background:var(--paper)}.recipe-summary h3{margin:0 0 15px;color:var(--blood);font:700 22px Cinzel,serif}.summary-metrics{display:grid;grid-template-columns:1fr 1fr;border:1px solid var(--border)}.summary-metrics div{padding:12px;border-right:1px solid var(--border);border-bottom:1px solid var(--border)}.summary-metrics span,.summary-metrics strong{display:block}.summary-metrics span{color:var(--muted);font-size:8px;text-transform:uppercase}.summary-metrics strong{font:700 20px Cinzel,serif}.validity{margin:14px 0;padding:12px;border-left:4px solid #58784c;background:#e7efdf}.validity.bad{border-color:var(--blood);background:#f1dddd}.validity b,.validity span{display:block}.validity span{font-size:10px;color:var(--muted)}.export-actions{display:grid;gap:7px}.export-actions button{padding:10px;border:0;background:var(--blood);color:var(--surface);font:700 10px Cinzel,serif}.export-actions .secondary{border:1px solid var(--blood);background:transparent;color:var(--blood)}.export-actions .quiet{border:1px solid var(--border);background:transparent;color:var(--muted)}.library{padding:30px 25px 70px}.saved-recipes{display:grid;grid-template-columns:repeat(3,1fr);gap:12px}.saved-card{padding:15px;border:1px solid var(--border);background:var(--surface)}.saved-card h3{margin:0;color:var(--blood);font:700 14px Cinzel,serif}.saved-card p{color:var(--muted);font-size:10px}footer{display:flex;justify-content:space-between;padding:24px max(25px,calc((100vw - 1360px)/2));background:var(--ink);color:var(--paper);font-size:10px}noscript{display:block;padding:20px;background:#fff4cc;color:#111}@media(max-width:1050px){.cards{grid-template-columns:repeat(2,1fr)}.topbar{grid-template-columns:1fr auto}.topbar nav{display:none}.composer-grid{grid-template-columns:1fr}.hero{grid-template-columns:1fr}.hero-stats{max-width:600px}}@media(max-width:720px){main{padding:0 10px}.topbar{padding:10px}.brand small{display:none}.theme-picker{font-size:0}.workspace{grid-template-columns:1fr}.filters{border:0;border-bottom:1px solid var(--border)}.cards{grid-template-columns:1fr}.catalog-toolbar{align-items:start;flex-direction:column}.composer{padding:20px 12px}.field-pair,.range-row{grid-template-columns:1fr}.artisan-levels{grid-template-columns:repeat(3,1fr)}.artisan-levels span{display:none}.artisan-levels output{grid-column:1/-1}.saved-recipes{grid-template-columns:1fr}footer{gap:15px;flex-direction:column}}
@media print{.topbar,.filters,.catalog-panel,.drop-zone,.export-actions,.library,footer{display:none!important}body{background:white}.composer{margin:0;padding:0;background:white;color:black}.composer-grid{grid-template-columns:1fr}.recipe-form,.recipe-summary{box-shadow:none;border:1px solid #999}}
.custom-editor{margin-top:16px;padding-top:12px;border-top:1px solid var(--border)}.custom-editor summary{color:var(--blood);font:700 11px Cinzel,serif;cursor:pointer}.custom-editor form{display:grid;gap:9px;margin-top:12px}.custom-editor label{display:grid;gap:4px}.custom-editor input,.custom-editor select,.custom-editor textarea{width:100%;padding:7px;border:1px solid var(--border);background:var(--light);color:var(--ink);font:inherit}.custom-editor textarea{resize:vertical}.custom-numbers{display:grid;grid-template-columns:repeat(2,1fr);gap:8px}.custom-editor button{padding:8px;border:0;background:var(--blood);color:var(--light);font:700 9px Cinzel,serif}.custom-status{min-height:18px;color:var(--dark-gold);font-size:10px}.custom-card{box-shadow:inset 0 3px 0 var(--gold)}.card-actions{display:flex;gap:6px;margin-top:auto}.card-actions button{flex:1}.card-actions .delete-custom{background:transparent;color:var(--blood);border:1px solid var(--blood)}.card-actions .add-item:disabled{cursor:not-allowed;opacity:.45;filter:grayscale(1)}#recipe-discipline:disabled{cursor:lock;opacity:.72}@media(max-width:720px){.custom-numbers{grid-template-columns:repeat(2,1fr)}}
+.limit-grid{display:grid;grid-template-columns:repeat(3,1fr);gap:10px;margin:12px 0}.limit-grid label,.recipe-notes{display:grid;gap:4px}.limit-grid input,.limit-grid select,.recipe-notes textarea,.library-toolbar input{width:100%;padding:8px;border:1px solid var(--border);background:var(--light);color:var(--ink);font:inherit}.recipe-notes textarea{resize:vertical}.validity.warn{background:#fff0c7;color:#5e4610;border-color:#c79524}.action-status{display:block;min-height:20px;margin-top:8px;color:var(--muted);font-size:11px}.action-status.bad{color:#a40000}.library-toolbar{display:flex;flex-wrap:wrap;gap:8px;align-items:end;margin-bottom:16px}.library-toolbar label{flex:1 1 220px}.library-toolbar button{padding:9px 12px}.saved-actions{display:flex;flex-wrap:wrap;gap:6px;margin-top:10px}.saved-actions button{padding:6px 9px;border:1px solid var(--border);background:var(--light);color:var(--ink)}.visually-hidden{position:absolute!important;width:1px!important;height:1px!important;padding:0!important;margin:-1px!important;overflow:hidden!important;clip:rect(0,0,0,0)!important;white-space:nowrap!important;border:0!important}:focus-visible{outline:3px solid var(--gold);outline-offset:2px}@media(prefers-reduced-motion:reduce){*,*::before,*::after{scroll-behavior:auto!important;transition:none!important;animation:none!important}}@media(max-width:720px){.limit-grid{grid-template-columns:1fr}.export-actions button{flex:1 1 140px}}@media print{.limit-grid,.recipe-notes{break-inside:avoid}.action-status{display:none}.selection{max-height:none!important;overflow:visible!important}}
diff --git a/craft_web/tests/test_site.py b/craft_web/tests/test_site.py
index 8fac774..d75b002 100644
--- a/craft_web/tests/test_site.py
+++ b/craft_web/tests/test_site.py
@@ -13,7 +13,8 @@ class CraftSiteTests(unittest.TestCase):
subprocess.run(["python", "craft_web/tools/build.py", "--output", target], cwd=ROOT, check=True)
one, two = Path(first), Path(second)
self.assertEqual({p.name for p in one.iterdir()},
- {"index.html", "styles.css", "app.js", "catalog.js", "build-info.json"})
+ {"index.html", "styles.css", "app.js", "catalog.js", "build-info.json",
+ "workshop-recipe-v1.schema.json", "ravenous-craft-v1.schema.json"})
for path in one.iterdir():
self.assertEqual(path.read_bytes(), (two / path.name).read_bytes())
info = json.loads((one / "build-info.json").read_text(encoding="utf-8"))
@@ -25,7 +26,11 @@ class CraftSiteTests(unittest.TestCase):
self.assertIn('id="custom-form"', html)
app = (one / "app.js").read_text(encoding="utf-8")
self.assertIn("ravenous-craft-custom-ingredients", app)
- self.assertIn("item.discipline !== locked", app)
+ self.assertIn("item.discipline!==locked", app)
+ self.assertIn("ravenous-workshop-recipe", app)
+ self.assertIn("ravenous-workshop-library", app)
+ recipe_schema = json.loads((one / "workshop-recipe-v1.schema.json").read_text(encoding="utf-8"))
+ self.assertEqual(recipe_schema["properties"]["format"]["const"], "ravenous-workshop-recipe")
for path in one.iterdir():
if path.suffix in {".html", ".css", ".js"}:
content = path.read_text(encoding="utf-8")
diff --git a/craft_web/tools/build.py b/craft_web/tools/build.py
index efcdb6e..5326c8a 100644
--- a/craft_web/tools/build.py
+++ b/craft_web/tools/build.py
@@ -119,6 +119,8 @@ def generated_files() -> dict[str, str]:
content = content.replace(marker, value)
files[name] = content
files["catalog.js"] = "window.RAVENOUS_CRAFT_CATALOG=" + packed + ";\n"
+ files["workshop-recipe-v1.schema.json"] = (WEB / "schemas/workshop-recipe-v1.schema.json").read_text(encoding="utf-8")
+ files["ravenous-craft-v1.schema.json"] = (ROOT / "docs/ravenous-craft-v1.schema.json").read_text(encoding="utf-8")
files["build-info.json"] = json.dumps({"catalog_hash": digest, "entries": len(entries),
"disciplines": sorted({item["discipline"] for item in entries}), "themes": list(palettes)},
ensure_ascii=False, indent=2) + "\n"