umer-wasim commited on
Commit
4d76eb9
·
verified ·
1 Parent(s): 96f5313

0.3.1: course mode, AI drafts, coach, demo

Browse files
CLASSROOM.md CHANGED
@@ -18,7 +18,15 @@ A guide for trainers using Ora in a marketing course, for example a three-day "D
18
 
19
  **Trainer's laptop** (for the demos): download the **Fast** video model in **Models** the day before (6.5 GB), and set up n8n for the Day 3 demo (see below).
20
 
21
- ## The three days in Ora
 
 
 
 
 
 
 
 
22
 
23
  | Course | In Ora | Exercise output |
24
  |---|---|---|
 
18
 
19
  **Trainer's laptop** (for the demos): download the **Fast** video model in **Models** the day before (6.5 GB), and set up n8n for the Day 3 demo (see below).
20
 
21
+ ## How the Plan tab teaches
22
+
23
+ **Plan** follows the course: steps grouped by **Day 1, 2 and 3** on the left, each marked done (✓) when its checks pass, and a progress bar. Every step opens with a **lesson card**: what it is, why it matters, a good example, the exercise, and key words with short explanations (hover the "?").
24
+
25
+ - **✨ Draft with AI** (brand, personas, campaign, content plan): from the brand name and what it offers, Ora drafts the rest. Drafted fields carry an **AI draft** label until the participant edits them or presses **Keep**, so it is always clear what is theirs. A good exercise: let AI draft, then improve it and explain why.
26
+ - **Check my work**: the coach shows the step's checklist and, with Cloudflare, written feedback on the participant's own words (what is good, two or three concrete improvements, a score out of 5).
27
+ - **Open the demo**: a finished example, the café **Bean & Bloom**, with every step done, pictures made in Ora, a filled calendar with captions, results and an ad. Show it on Day 1 so everyone sees the goal; participants can open it any time to compare. **Back to my plan** returns to their own work; the demo never changes it.
28
+
29
+
30
 
31
  | Course | In Ora | Exercise output |
32
  |---|---|---|
README.md CHANGED
@@ -19,7 +19,7 @@ Ora is a free desktop app for **marketing content made with open AI models, on y
19
  - **Finished ads:** the Ad maker joins your shots into a 15 or 30 s ad with headline, offer and end card, background music composed on your computer and an optional voice-over, and saves it for Reels/TikTok (9:16), feeds and LinkedIn (4:5, 1:1) and YouTube (16:9).
20
  - **Enhance:** Sharper (upscale to HD) and Smoother (twice the frames) for any video.
21
  - **Helpers:** 9 ready-made templates, a brand kit, versions to choose from and ✨ Improve prompt.
22
- - **Plan (new in 0.3):** the whole campaign, step by step: brand identity (with a one-page Brand Identity Summary), customer personas, campaign and funnel with success metrics, a 30-day content calendar (CSV and calendar export), results with engagement rate against targets, and a one-click PDF presentation. Five example businesses to practise with.
23
  - **Post:** captions for Instagram, Facebook and LinkedIn in your brand's tone, a "Ready to post" folder, and a ready-made [n8n](https://n8n.io) workflow (`app/n8n/ora-social-posting.json`) that waits until the post time and posts to LinkedIn or a Facebook Page.
24
 
25
  Nothing is uploaded unless you choose an online service, and no account is needed. The app downloads the models once (pinned revisions, SHA-256 checked) and then works offline.
 
19
  - **Finished ads:** the Ad maker joins your shots into a 15 or 30 s ad with headline, offer and end card, background music composed on your computer and an optional voice-over, and saves it for Reels/TikTok (9:16), feeds and LinkedIn (4:5, 1:1) and YouTube (16:9).
20
  - **Enhance:** Sharper (upscale to HD) and Smoother (twice the frames) for any video.
21
  - **Helpers:** 9 ready-made templates, a brand kit, versions to choose from and ✨ Improve prompt.
22
+ - **Plan (new in 0.3):** the whole campaign, step by step: brand identity (with a one-page Brand Identity Summary), customer personas, campaign and funnel with success metrics, a 30-day content calendar (CSV and calendar export), results with engagement rate against targets, and a one-click PDF presentation. Five example businesses to practise with. **Course mode** (0.3.1): the steps by course day with lessons, ✨ Draft with AI, a coach (Check my work) and a finished demo café, Bean & Bloom.
23
  - **Post:** captions for Instagram, Facebook and LinkedIn in your brand's tone, a "Ready to post" folder, and a ready-made [n8n](https://n8n.io) workflow (`app/n8n/ora-social-posting.json`) that waits until the post time and posts to LinkedIn or a Facebook Page.
24
 
25
  Nothing is uploaded unless you choose an online service, and no account is needed. The app downloads the models once (pinned revisions, SHA-256 checked) and then works offline.
app/main.cjs CHANGED
@@ -949,15 +949,85 @@ app.whenReady().then(() => {
949
  return meta;
950
  });
951
 
952
- // Plan tab: read and write the whole plan (the renderer owns its shape; main only bounds its size)
953
- ipcMain.handle('plan:get', async () => { try { return JSON.parse(await fsp.readFile(PLAN, 'utf8')); } catch { return {}; } });
954
- ipcMain.handle('plan:set', async (_e, plan) => {
 
 
955
  const text = JSON.stringify(plan && typeof plan === 'object' ? plan : {});
956
- if (text.length > 2e6) throw new Error('The plan is too big to save.');
957
  await fsp.mkdir(DATA, { recursive: true });
958
- await fsp.writeFile(`${PLAN}.tmp`, text); await fsp.rename(`${PLAN}.tmp`, PLAN);
 
959
  return true;
960
  });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
961
  // exported PNG/PDF pages (Brand Identity Summary, presentation) go to Documents/Ora
962
  ipcMain.handle('plan:export', async (_e, name, bytes, ext) => {
963
  if (!['png', 'pdf', 'csv', 'ics', 'txt', 'json', 'pptx'].includes(ext) || !bytes || bytes.byteLength > 80e6) throw new Error('bad export');
 
949
  return meta;
950
  });
951
 
952
+ // Plan tab: read and write the whole plan (the renderer owns its shape; main only bounds its size).
953
+ // slot "demo" is the worked example (plan-demo.json), kept apart from the person's own plan.
954
+ const planFile = slot => slot === 'demo' ? path.join(DATA, 'plan-demo.json') : PLAN;
955
+ ipcMain.handle('plan:get', async (_e, slot) => { try { return JSON.parse(await fsp.readFile(planFile(slot), 'utf8')); } catch { return {}; } });
956
+ ipcMain.handle('plan:set', async (_e, plan, slot) => {
957
  const text = JSON.stringify(plan && typeof plan === 'object' ? plan : {});
958
+ if (text.length > 4e6) throw new Error('The plan is too big to save.');
959
  await fsp.mkdir(DATA, { recursive: true });
960
+ const f = planFile(slot);
961
+ await fsp.writeFile(`${f}.tmp`, text); await fsp.rename(`${f}.tmp`, f);
962
  return true;
963
  });
964
+ // The demo (Plan › Open the demo): pictures made with Ora for the café Bean & Bloom, bundled in renderer/demo.
965
+ // They become ordinary Library items (marked demo) and copies in Pictures/Ora so they can be posted like any other.
966
+ const DEMO = [
967
+ ['latte', 'Latte with heart latte art on a wooden table, warm morning light', 512, 640, null],
968
+ ['cakes', 'Homemade cakes on a wooden café counter, warm light', 512, 640, { title: 'Autumn Cake Week', sub: 'A new homemade cake every day', details: 'Free cake with your second coffee', cta: 'Visit us today', layout: 'band', font: 'serif', accent: '#7b4a2a', format: 'insta' }],
969
+ ['carousel', 'Café pictures for a tips carousel', 512, 640, { carousel: true, title: '3 ways to enjoy your coffee break', sub: 'Bean & Bloom', slides: ['3 ways to enjoy your coffee break', 'Slow down: sit, sip, look out of the window', 'Pair it right: latte with carrot cake', 'Bring a friend: second coffee, free cake'], cta: 'Visit us today', layout: 'card', font: 'serif', accent: '#7b4a2a', format: 'insta' }, ['latte', 'barista', 'interior', 'cakes']],
970
+ ['interior', 'Cosy small café interior with plants and morning sunlight', 640, 368, null],
971
+ ['sofia', 'Portrait of Sofia, 34, remote designer', 512, 512, null],
972
+ ['jean', 'Portrait of Jean, 67, retired teacher', 512, 512, null],
973
+ ];
974
+ ipcMain.handle('demo:install', async () => {
975
+ const src = path.join(__dirname, 'renderer', 'demo');
976
+ const out = {};
977
+ const picDir = path.join(IMAGE_DIR, 'Ora demo - Bean & Bloom');
978
+ for (const [i, [name, prompt, w, h, posterSpec, files]] of DEMO.entries()) {
979
+ const id = `demo-${name}`, dir = path.join(VIDEOS, id);
980
+ out[name] = id;
981
+ if (fs.existsSync(path.join(dir, 'meta.json'))) continue;
982
+ await fsp.mkdir(dir, { recursive: true }); await fsp.mkdir(picDir, { recursive: true });
983
+ const list = files || [name], images = [], saved = [];
984
+ for (const [k, f] of list.entries()) {
985
+ const file = `img_${String(k).padStart(2, '0')}.jpg`;
986
+ // read + write (not copyFile): the source is inside app.asar in the packaged app
987
+ const bytes = await fsp.readFile(path.join(src, `${f}.jpg`));
988
+ await fsp.writeFile(path.join(dir, file), bytes);
989
+ const copy = path.join(picDir, `${String(i + 1).padStart(2, '0')} ${name}${list.length > 1 ? ` ${k + 1}` : ''}.jpg`);
990
+ await fsp.writeFile(copy, bytes);
991
+ images.push(file); saved.push(copy);
992
+ }
993
+ await fsp.copyFile(path.join(dir, images[0]), path.join(dir, 'poster.png'));
994
+ const meta = { id, kind: 'image', demo: true, created: new Date(Date.UTC(2026, 0, 5 + i)).toISOString(), status: 'done', prompt, model: 'zimage', modelLabel: 'Z-Image-Turbo (demo)',
995
+ images, savedFiles: saved, savedTo: saved[0], width: w, height: h, count: images.length, seed: 1234,
996
+ project: { folder: 'Ora demo - Bean & Bloom', index: i + 1, total: DEMO.length, title: prompt.split(',')[0] }, poster: posterSpec || undefined };
997
+ await writeMeta(dir, meta);
998
+ }
999
+ return out;
1000
+ });
1001
+
1002
+ // AI drafts and coaching for the Plan (Cloudflare, the 70B model). Answers are JSON; main checks and trims them.
1003
+ const PERSONALITY = ['Friendly', 'Premium', 'Playful', 'Bold', 'Calm', 'Expert', 'Warm', 'Modern', 'Natural', 'Trustworthy', 'Creative', 'Energetic'];
1004
+ const ONLINE = ['Instagram', 'Facebook', 'LinkedIn', 'TikTok', 'YouTube', 'Google', 'Email', 'WhatsApp'];
1005
+ const CHANNELS = ['Instagram', 'Facebook', 'LinkedIn', 'TikTok', 'Google Business', 'Website', 'Email', 'Paid ads'];
1006
+ const jsonOf = t => { const m = String(t).match(/[[{][\s\S]*[\]}]/); if (!m) throw new Error('unreadable'); try { return JSON.parse(m[0]); } catch { throw new Error('unreadable'); } };
1007
+ const str = (v, n) => typeof v === 'string' ? v.replace(/\s+/g, ' ').trim().slice(0, n) : '';
1008
+ const pick = (arr, allowed, n) => (Array.isArray(arr) ? arr : []).map(x => allowed.find(a => a.toLowerCase() === String(x).toLowerCase())).filter(Boolean).filter((x, i, a) => a.indexOf(x) === i).slice(0, n);
1009
+ const AI_TASKS = {
1010
+ brand: [`You are a marketing coach helping a beginner define a small business brand. From the facts, draft the brand identity. Reply with JSON only: {"mission": one sentence of 15-30 words saying who the brand serves, what it does and why, "values": 3 to 4 comma-separated words, "personality": 3 items chosen only from ${JSON.stringify(PERSONALITY)}, "tone": a short description of the tone of voice, "tagline": at most 7 words}. Use only the facts given; do not invent prices or awards.`, 500,
1011
+ o => ({ mission: str(o.mission, 400), values: str(Array.isArray(o.values) ? o.values.join(', ') : o.values, 160), personality: pick(o.personality, PERSONALITY, 3), tone: str(o.tone, 160), tagline: str(o.tagline, 80) })],
1012
+ personas: [`You are a marketing coach. From the brand facts, write two different customer personas a beginner can use. Reply with JSON only: an array of 2 objects {"name": a first name, "age": a number as text, "job": job or situation (max 8 words), "needs": max 20 words, "pains": frustrations, max 20 words, "motivations": what makes them choose a brand, max 15 words, "where": 2 or 3 items chosen only from ${JSON.stringify(ONLINE)}, "quote": a short sentence in their words}. Make them realistic for the brand's place and offer.`, 700,
1013
+ o => (Array.isArray(o) ? o : o.personas || []).slice(0, 2).map(p => ({ name: str(p.name, 40), age: str(String(p.age || ''), 20), job: str(p.job, 80), needs: str(p.needs, 300), pains: str(p.pains, 300), motivations: str(p.motivations, 200), where: pick(p.where, ONLINE, 4), quote: str(p.quote, 140).replace(/^["“]|["”]$/g, '') }))],
1014
+ campaign: [`You are a marketing coach helping a beginner plan one campaign for a small business. From the facts, draft it. Reply with JSON only: {"name": at most 4 words, "goal": one of "awareness","engagement","leads","sales","visits", "message": one sentence of at most 14 words, "value": why choose this brand, max 15 words, "offer": a simple offer or "", "cta": a call to action of at most 4 words, "channels": 2 or 3 items chosen only from ${JSON.stringify(CHANNELS)}, "funnel": {"awareness": one sentence, "engagement": one sentence, "conversion": one sentence} each describing one concrete piece of content for that step, "metrics": exactly 3 objects {"id": one of "reach","impressions","er","followers","clicks", "target": a realistic number for a small local business in one month (er is a percentage)}}. Use only the facts given.`, 700,
1015
+ o => ({ name: str(o.name, 70), goal: ['awareness', 'engagement', 'leads', 'sales', 'visits'].includes(o.goal) ? o.goal : 'awareness', message: str(o.message, 200), value: str(o.value, 160), offer: str(o.offer, 80), cta: str(o.cta, 40), channels: pick(o.channels, CHANNELS, 4),
1016
+ funnel: Object.fromEntries(['awareness', 'engagement', 'conversion'].map(k => [k, { what: str((o.funnel || {})[k], 300) }])),
1017
+ metrics: (Array.isArray(o.metrics) ? o.metrics : []).filter(m => ['reach', 'impressions', 'er', 'followers', 'clicks'].includes(m.id)).slice(0, 3).map(m => ({ id: m.id, target: String(Math.max(0, +m.target || 0) || '') })) })],
1018
+ coach: [`You are a friendly, honest marketing trainer giving feedback to a beginner on one exercise of a digital marketing course. Judge the work against the criteria given. Reply with JSON only: {"good": one sentence on what is already good, "improve": 2 or 3 short, concrete suggestions (each max 25 words, quoting the part to change), "score": a whole number from 1 to 5}. Be specific to their words; no generic advice.`, 450,
1019
+ o => ({ good: str(o.good, 300), improve: (Array.isArray(o.improve) ? o.improve : [o.improve]).map(x => str(x, 220)).filter(Boolean).slice(0, 3), score: Math.max(1, Math.min(5, Math.round(+o.score) || 3)) })],
1020
+ };
1021
+ ipcMain.handle('plan:ai', async (_e, task, facts) => {
1022
+ const t = AI_TASKS[task];
1023
+ if (!t) throw new Error('bad task');
1024
+ if (!remote.status().cloudflare.connected) throw new Error('offline');
1025
+ const text = String(facts || '').slice(0, 6000);
1026
+ if (text.trim().length < 3) throw new Error('Fill in the basics first.');
1027
+ const raw = await remote.cfText(t[0], text, { big: true, maxTokens: t[1] });
1028
+ if (refused(raw)) throw new Error('declined');
1029
+ return t[2](jsonOf(raw));
1030
+ });
1031
  // exported PNG/PDF pages (Brand Identity Summary, presentation) go to Documents/Ora
1032
  ipcMain.handle('plan:export', async (_e, name, bytes, ext) => {
1033
  if (!['png', 'pdf', 'csv', 'ics', 'txt', 'json', 'pptx'].includes(ext) || !bytes || bytes.byteLength > 80e6) throw new Error('bad export');
app/package.json CHANGED
@@ -1,7 +1,7 @@
1
  {
2
  "name": "devseis-ora",
3
  "productName": "Ora",
4
- "version": "0.3.0",
5
  "description": "Make videos from a prompt on your own computer with Wan2.1 1.3B and Wan2.2 5B.",
6
  "author": {
7
  "name": "Devseis",
 
1
  {
2
  "name": "devseis-ora",
3
  "productName": "Ora",
4
+ "version": "0.3.1",
5
  "description": "Make videos from a prompt on your own computer with Wan2.1 1.3B and Wan2.2 5B.",
6
  "author": {
7
  "name": "Devseis",
app/preload.cjs CHANGED
@@ -19,8 +19,10 @@ contextBridge.exposeInMainWorld('ora', {
19
  enhanceInterpolate: id => ipcRenderer.invoke('enhance:interpolate', id),
20
  enhanceCancel: id => ipcRenderer.invoke('enhance:cancel', id),
21
  enhanceImage: (id, index, bytes) => ipcRenderer.invoke('enhance:image', id, index, bytes),
22
- planGet: () => ipcRenderer.invoke('plan:get'),
23
- planSet: plan => ipcRenderer.invoke('plan:set', plan),
 
 
24
  planPdf: (name, html, page) => ipcRenderer.invoke('plan:pdf', name, html, page),
25
  planExport: (name, bytes, ext) => ipcRenderer.invoke('plan:export', name, bytes, ext),
26
  writeCaption: (ctx, platform) => ipcRenderer.invoke('caption:write', ctx, platform),
 
19
  enhanceInterpolate: id => ipcRenderer.invoke('enhance:interpolate', id),
20
  enhanceCancel: id => ipcRenderer.invoke('enhance:cancel', id),
21
  enhanceImage: (id, index, bytes) => ipcRenderer.invoke('enhance:image', id, index, bytes),
22
+ planGet: slot => ipcRenderer.invoke('plan:get', slot),
23
+ planSet: (plan, slot) => ipcRenderer.invoke('plan:set', plan, slot),
24
+ planAi: (task, facts) => ipcRenderer.invoke('plan:ai', task, facts),
25
+ demoInstall: () => ipcRenderer.invoke('demo:install'),
26
  planPdf: (name, html, page) => ipcRenderer.invoke('plan:pdf', name, html, page),
27
  planExport: (name, bytes, ext) => ipcRenderer.invoke('plan:export', name, bytes, ext),
28
  writeCaption: (ctx, platform) => ipcRenderer.invoke('caption:write', ctx, platform),
app/remote.cjs CHANGED
@@ -243,10 +243,14 @@ function createRemote(dataDir) {
243
  function disconnect(which) { const c = read(); delete c[which]; write(c); return status(); }
244
 
245
  // Prompt helper: a small text model on Workers AI rewrites keywords into one clean prompt (a few Neurons).
246
- async function cfText(system, user) {
247
- const r = await cfCall('/ai/run/@cf/meta/llama-3.1-8b-instruct', {
248
- messages: [{ role: 'system', content: system }, { role: 'user', content: user }], max_tokens: 220, temperature: 0.6,
249
- });
 
 
 
 
250
  return String((r && r.response) || '').trim();
251
  }
252
  return { status, connectColab, connectKaggle, connectCloudflare, runColab, runKaggle, runCloudflare, cfText, cfNeurons, download, disconnect, workerUrl: WORKER_URL };
 
243
  function disconnect(which) { const c = read(); delete c[which]; write(c); return status(); }
244
 
245
  // Prompt helper: a small text model on Workers AI rewrites keywords into one clean prompt (a few Neurons).
246
+ // big: Llama 3.3 70B (planning, drafts, coaching: better writing, more Neurons); falls back to the 8B model
247
+ async function cfText(system, user, { big = false, maxTokens = 220 } = {}) {
248
+ const body = { messages: [{ role: 'system', content: system }, { role: 'user', content: user }], max_tokens: maxTokens, temperature: 0.6 };
249
+ if (big) {
250
+ try { const r = await cfCall('/ai/run/@cf/meta/llama-3.3-70b-instruct-fp8-fast', body); return String((r && r.response) || '').trim(); }
251
+ catch (e) { if (/allowance|token|permission|safety/i.test(e.message)) throw e; }
252
+ }
253
+ const r = await cfCall('/ai/run/@cf/meta/llama-3.1-8b-instruct', body);
254
  return String((r && r.response) || '').trim();
255
  }
256
  return { status, connectColab, connectKaggle, connectCloudflare, runColab, runKaggle, runCloudflare, cfText, cfNeurons, download, disconnect, workerUrl: WORKER_URL };
app/renderer/calendar.js CHANGED
@@ -1,6 +1,6 @@
1
  'use strict';
2
  /* global $, S, store, plan, savePlan, loadPlan, showView, setMode, imgForm, poster, renderPosterFields, renderImgShapes, shots, renderShots,
3
- formNote, openPost, filesOf, itemContext, cleanErr, hexName, defaultStep, offlineCaption, loadImg */
4
  // Plan › 3 Calendar: content ideas (the course's content types), a 30-day calendar filled from them, each day linked
5
  // to something made in Ora and posted with Post… (Ready to post / n8n). Plan › 4 Presentation: a 16:9 PDF deck.
6
 
@@ -395,16 +395,36 @@ footer { position: absolute; left: 0.75in; bottom: 0.25in; font-size: 10pt; colo
395
  .month .c.out { background: transparent; border: 0 } .month .d { font-size: 9pt; color: #6b6478; font-weight: 700 } .month .t { font-size: 8.5pt; line-height: 1.25 }
396
  .funnelS { display: flex; flex-direction: column; gap: 0.15in; margin-top: 0.2in } .fs { background: ${c1}; color: ${onC1}; border-radius: 14px; padding: 0.18in 0.25in; display: flex; flex-direction: column; gap: 4px } .fs b { font-size: 15pt } .fs span { font-size: 12pt; opacity: .92 }
397
  .metricsS { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.3in; margin: 0.2in 0 0.3in } .metricsS div { background: #fff; border-radius: 16px; padding: 0.3in; border-top: 8px solid ${c1}; display: flex; flex-direction: column; gap: 6px } .metricsS .k { font-size: 13pt; text-transform: uppercase; letter-spacing: .05em; color: #6b6478 } .metricsS .v { font-size: 40pt; font-weight: 700 } .metricsS .t { font-size: 12pt; color: #6b6478 }
398
- .gallery { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.25in } figure { margin: 0 } figure img { width: 100%; height: 2.2in; object-fit: cover; border-radius: 12px; display: block } figcaption { font-size: 11pt; color: #6b6478; margin-top: 4px }
399
  </style></head><body>${out.join('\n')}</body></html>`;
400
  }
401
- // examples for the deck: ads (from the Ad maker) first, then the calendar's linked items, then the latest made
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
402
  function galleryItems() {
 
403
  const out = (plan.ads || []).slice(0, 2).map(a => ({ src: a.thumb, label: `Ad · ${a.title}${a.formats > 1 ? ` · ${a.formats} sizes` : ''}` }));
404
  const linked = Object.values(cal().days).filter(x => x.item).map(x => S.videos.find(v => v.id === x.item.id)).filter(Boolean);
405
  for (const m of [...new Set([...linked, ...S.videos])]) {
406
  if (out.length >= 6) break;
407
- out.push({ src: `ora://video/${encodeURIComponent(m.id)}/${m.kind === 'image' ? ((m.hdImages || [])[0] || m.images[0]) : 'poster.png'}`,
408
  label: `${m.kind === 'image' ? (m.poster ? (m.poster.carousel ? 'Carousel' : 'Poster') : 'Image') : 'Video'} · ${((m.poster && m.poster.title) || (m.project ? m.project.title : m.prompt || '')).slice(0, 48)}` });
409
  }
410
  return out;
@@ -506,7 +526,12 @@ async function buildPptx() {
506
  for (const [i, g] of gal.entries()) {
507
  const x = 0.75 + (i % 3) * 4.05, yy = 1.45 + Math.floor(i / 3) * 2.75;
508
  const d = await dataUrl(g.src).catch(() => null);
509
- if (d) { const [iw, ih] = await imgSize(d); s.addImage({ data: d, x, y: yy, w: 3.8, h: 2.2, sizing: { type: iw / ih > 3.8 / 2.2 ? 'cover' : 'contain', w: 3.8, h: 2.2 } }); }
 
 
 
 
 
510
  s.addText(g.label, { x, y: yy + 2.22, w: 3.8, h: 0.3, fontSize: 10.5, color: '6B6478' });
511
  }
512
  }
@@ -533,8 +558,11 @@ async function buildPptx() {
533
  $('presentPptx').addEventListener('click', async e => {
534
  const btn = e.currentTarget; btn.disabled = true; $('presentNote').textContent = 'Making the PowerPoint…';
535
  try {
 
536
  const bytes = await buildPptx();
 
537
  const f = await window.ora.planExport(`${plan.brand.name || 'Ora'} - campaign presentation`, bytes, 'pptx');
 
538
  $('presentNote').textContent = `Saved ${f.split(/[\\/]/).pop()} in Documents/Ora: open it in PowerPoint, Keynote or Google Slides to edit.`;
539
  } catch (err) { $('presentNote').textContent = `Could not make the PowerPoint: ${cleanErr(err)}`; }
540
  finally { btn.disabled = false; }
@@ -542,7 +570,10 @@ $('presentPptx').addEventListener('click', async e => {
542
  $('presentMake').addEventListener('click', async e => {
543
  const b = e.currentTarget; b.disabled = true; $('presentNote').textContent = 'Making the slides…';
544
  try {
545
- const f = await window.ora.planPdf(`${plan.brand.name || 'Ora'} - campaign presentation`, slidesHtml());
 
 
 
546
  $('presentNote').textContent = `Saved ${f.split(/[\\/]/).pop()} in Documents/Ora.`;
547
  } catch (err) { $('presentNote').textContent = cleanErr(err); }
548
  finally { b.disabled = false; }
 
1
  'use strict';
2
  /* global $, S, store, plan, savePlan, loadPlan, showView, setMode, imgForm, poster, renderPosterFields, renderImgShapes, shots, renderShots,
3
+ formNote, openPost, filesOf, itemContext, cleanErr, hexName, defaultStep, offlineCaption, loadImg, drawPoster, slideSpec */
4
  // Plan › 3 Calendar: content ideas (the course's content types), a 30-day calendar filled from them, each day linked
5
  // to something made in Ora and posted with Post… (Ready to post / n8n). Plan › 4 Presentation: a 16:9 PDF deck.
6
 
 
395
  .month .c.out { background: transparent; border: 0 } .month .d { font-size: 9pt; color: #6b6478; font-weight: 700 } .month .t { font-size: 8.5pt; line-height: 1.25 }
396
  .funnelS { display: flex; flex-direction: column; gap: 0.15in; margin-top: 0.2in } .fs { background: ${c1}; color: ${onC1}; border-radius: 14px; padding: 0.18in 0.25in; display: flex; flex-direction: column; gap: 4px } .fs b { font-size: 15pt } .fs span { font-size: 12pt; opacity: .92 }
397
  .metricsS { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.3in; margin: 0.2in 0 0.3in } .metricsS div { background: #fff; border-radius: 16px; padding: 0.3in; border-top: 8px solid ${c1}; display: flex; flex-direction: column; gap: 6px } .metricsS .k { font-size: 13pt; text-transform: uppercase; letter-spacing: .05em; color: #6b6478 } .metricsS .v { font-size: 40pt; font-weight: 700 } .metricsS .t { font-size: 12pt; color: #6b6478 }
398
+ .gallery { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.25in } figure { margin: 0 } figure img { width: 100%; height: 2.2in; object-fit: contain; background: ${c2}; border-radius: 12px; display: block } figcaption { font-size: 11pt; color: #6b6478; margin-top: 4px }
399
  </style></head><body>${out.join('\n')}</body></html>`;
400
  }
401
+ // examples for the deck: ads (from the Ad maker) first, then the calendar's linked items, then the latest made.
402
+ // Posters and carousels are drawn with their text (prepareGallery), so the slide shows the finished post.
403
+ let galleryCache = null;
404
+ async function prepareGallery() {
405
+ const list = galleryItems();
406
+ for (const g of list) {
407
+ if (!g.meta || !g.meta.poster) continue;
408
+ try {
409
+ const img = await loadImg(`ora://video/${encodeURIComponent(g.meta.id)}/${(g.meta.hdImages || [])[0] || g.meta.images[0]}`);
410
+ const cv = document.createElement('canvas');
411
+ await drawPoster(cv, img, slideSpec({ ...g.meta.poster }, 0, g.meta.images.length), null);
412
+ const k = 640 / Math.max(cv.width, cv.height), sm = document.createElement('canvas');
413
+ sm.width = Math.round(cv.width * k); sm.height = Math.round(cv.height * k);
414
+ sm.getContext('2d').drawImage(cv, 0, 0, sm.width, sm.height);
415
+ g.src = sm.toDataURL('image/jpeg', 0.86);
416
+ } catch { }
417
+ }
418
+ galleryCache = list;
419
+ return list;
420
+ }
421
  function galleryItems() {
422
+ if (galleryCache) return galleryCache;
423
  const out = (plan.ads || []).slice(0, 2).map(a => ({ src: a.thumb, label: `Ad · ${a.title}${a.formats > 1 ? ` · ${a.formats} sizes` : ''}` }));
424
  const linked = Object.values(cal().days).filter(x => x.item).map(x => S.videos.find(v => v.id === x.item.id)).filter(Boolean);
425
  for (const m of [...new Set([...linked, ...S.videos])]) {
426
  if (out.length >= 6) break;
427
+ out.push({ meta: m, src: `ora://video/${encodeURIComponent(m.id)}/${m.kind === 'image' ? ((m.hdImages || [])[0] || m.images[0]) : 'poster.png'}`,
428
  label: `${m.kind === 'image' ? (m.poster ? (m.poster.carousel ? 'Carousel' : 'Poster') : 'Image') : 'Video'} · ${((m.poster && m.poster.title) || (m.project ? m.project.title : m.prompt || '')).slice(0, 48)}` });
429
  }
430
  return out;
 
526
  for (const [i, g] of gal.entries()) {
527
  const x = 0.75 + (i % 3) * 4.05, yy = 1.45 + Math.floor(i / 3) * 2.75;
528
  const d = await dataUrl(g.src).catch(() => null);
529
+ if (d) {
530
+ // fit the picture inside the box, centred (tall posters and ads are not cropped)
531
+ const [iw, ih] = await imgSize(d), k = Math.min(3.8 / iw, 2.2 / ih), w = iw * k, h = ih * k;
532
+ s.addShape(deck.ShapeType.rect, { x, y: yy, w: 3.8, h: 2.2, fill: { color: c2 }, line: { color: c2 } });
533
+ s.addImage({ data: d, x: x + (3.8 - w) / 2, y: yy + (2.2 - h) / 2, w, h });
534
+ }
535
  s.addText(g.label, { x, y: yy + 2.22, w: 3.8, h: 0.3, fontSize: 10.5, color: '6B6478' });
536
  }
537
  }
 
558
  $('presentPptx').addEventListener('click', async e => {
559
  const btn = e.currentTarget; btn.disabled = true; $('presentNote').textContent = 'Making the PowerPoint…';
560
  try {
561
+ galleryCache = null; await prepareGallery();
562
  const bytes = await buildPptx();
563
+ galleryCache = null;
564
  const f = await window.ora.planExport(`${plan.brand.name || 'Ora'} - campaign presentation`, bytes, 'pptx');
565
+ plan.presentedAt = new Date().toISOString(); savePlan();
566
  $('presentNote').textContent = `Saved ${f.split(/[\\/]/).pop()} in Documents/Ora: open it in PowerPoint, Keynote or Google Slides to edit.`;
567
  } catch (err) { $('presentNote').textContent = `Could not make the PowerPoint: ${cleanErr(err)}`; }
568
  finally { btn.disabled = false; }
 
570
  $('presentMake').addEventListener('click', async e => {
571
  const b = e.currentTarget; b.disabled = true; $('presentNote').textContent = 'Making the slides…';
572
  try {
573
+ galleryCache = null; await prepareGallery();
574
+ const html = slidesHtml(); galleryCache = null;
575
+ const f = await window.ora.planPdf(`${plan.brand.name || 'Ora'} - campaign presentation`, html);
576
+ plan.presentedAt = new Date().toISOString(); savePlan();
577
  $('presentNote').textContent = `Saved ${f.split(/[\\/]/).pop()} in Documents/Ora.`;
578
  } catch (err) { $('presentNote').textContent = cleanErr(err); }
579
  finally { b.disabled = false; }
app/renderer/course.js ADDED
@@ -0,0 +1,300 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 'use strict';
2
+ /* global $, S, store, plan, planTab, savePlan, loadPlan, renderPlan, planSlot, applyBrand, cleanErr, newPersona, cal, camp, results,
3
+ CONTENT_TYPES, ymd, resetPlanLoaded, DEMO_VERSION, demoPlan */
4
+ // Course mode for the Plan tab: a step list by course day, a lesson card per step (what, why, example, exercise,
5
+ // key words), checks that mark a step done, ✨ Draft with AI (Cloudflare, 70B), the coach (Check my work), and the demo.
6
+
7
+ const words = t => String(t || '').trim().split(/\s+/).filter(Boolean).length;
8
+ const STEPS = [
9
+ { id: 'brand', day: 1, title: 'Brand identity', lesson: {
10
+ what: 'Your brand is how people recognise you and how they feel about you: what you offer, why you exist, how you sound and how you look.',
11
+ why: 'A clear brand makes every post feel like it comes from the same place, so people remember you.',
12
+ example: 'Bean & Bloom · “Your daily cup of calm.” A warm corner where neighbours meet over great coffee and cakes baked every morning.',
13
+ exercise: 'Fill in your brand and save your Brand Identity Summary.',
14
+ terms: [['Mission', 'One sentence: who you serve, what you do and why.'], ['Tone of voice', 'How your brand sounds in writing, e.g. warm and chatty, or calm and expert.'], ['Tagline', 'A short line people remember: seven words or fewer.']] },
15
+ checks: () => { const b = plan.brand || {}; return [
16
+ ['Brand name and what you offer', !!(b.name && b.offer)],
17
+ ['Mission of 10 to 45 words: who you help and what you do', words(b.mission) >= 10 && words(b.mission) <= 45],
18
+ ['At least 3 values', String(b.values || '').split(',').filter(x => x.trim()).length >= 3],
19
+ ['Personality: 1 to 3 picked', (b.personality || []).length >= 1],
20
+ ['Tone of voice described', words(b.tone) >= 2],
21
+ ['Tagline of 7 words or fewer', words(b.tagline) >= 2 && words(b.tagline) <= 8],
22
+ ['Two or more brand colours', (b.colors || []).length >= 2],
23
+ ]; } },
24
+ { id: 'personas', day: 1, title: 'Customer personas', lesson: {
25
+ what: 'A persona is a short, realistic picture of one typical customer: who they are, what they need, what annoys them and where they spend time online.',
26
+ why: 'Writing for one real-feeling person makes posts more personal, and shows you which channels to use.',
27
+ example: 'Sofia, 34, remote designer · needs a calm place to work for a few hours · dislikes noisy chains · finds places on Instagram and Google.',
28
+ exercise: 'Create two personas and mark the main one. Give each a picture.',
29
+ terms: [['Persona', 'A made-up but realistic customer that stands for a group of real ones.'], ['Pain point', 'A problem or frustration your customer has that you can solve.']] },
30
+ checks: () => { const ps = (plan.personas || []).filter(p => p.name); return [
31
+ ['Two personas', ps.length >= 2],
32
+ ['Each has an age and a job or situation', ps.length >= 2 && ps.every(p => p.age && p.job)],
33
+ ['Each has needs and frustrations', ps.length >= 2 && ps.every(p => words(p.needs) >= 4 && words(p.pains) >= 2)],
34
+ ['Each says where they are online', ps.length >= 2 && ps.every(p => (p.where || []).length)],
35
+ ['One is marked Main', ps.some(p => p.main)],
36
+ ]; } },
37
+ { id: 'campaign', day: 2, title: 'Campaign and funnel', lesson: {
38
+ what: 'A campaign is a set of posts with one goal, one message and a start and end date. The funnel shows how people move from first seeing you to buying.',
39
+ why: 'One goal and one message keep your posts focused; the funnel makes sure you also plan the posts that bring sales.',
40
+ example: 'Autumn Cake Week · goal: shop visits · “A new homemade cake every day this week.” · offer: free cake with your second coffee.',
41
+ exercise: 'Name your campaign, choose a goal, write the key message, sketch the funnel and pick three success metrics with targets.',
42
+ terms: [['Funnel', 'Awareness (they see you) → Engagement (they interact) → Conversion (they buy or visit).'], ['Value proposition', 'Why someone should choose you over others, in one line.'], ['Call to action', 'What you ask people to do next: Order now, Book a table…'], ['Metric', 'A number that shows success, like reach or engagement rate, with a target.']] },
43
+ checks: () => { const c = plan.campaign || {}; return [
44
+ ['Campaign name and goal', !!(c.name && c.goal)],
45
+ ['Key message of 20 words or fewer', words(c.message) >= 3 && words(c.message) <= 20],
46
+ ['Why choose us', words(c.value) >= 3],
47
+ ['Call to action', !!c.cta],
48
+ ['At least one channel', (c.channels || []).length > 0],
49
+ ['All three funnel steps written', ['awareness', 'engagement', 'conversion'].every(k => words(((c.funnel || {})[k] || {}).what) >= 3)],
50
+ ['Three metrics, each with a target', (c.metrics || []).length === 3 && c.metrics.every(m => +m.target > 0)],
51
+ ]; } },
52
+ { id: 'calendar', day: 2, title: 'Content plan', lesson: {
53
+ what: 'A good content plan mixes kinds of posts: educational, storytelling, behind the scenes, community and lifestyle, plus a few offers.',
54
+ why: 'Variety keeps followers interested, and a calendar keeps you posting regularly instead of when you remember.',
55
+ example: 'Monday: 3 quick tips · Wednesday: why we started · Friday: behind the scenes in the kitchen.',
56
+ exercise: 'Write at least 10 content ideas, fill a 30-day calendar, make two posts and write their captions.',
57
+ terms: [['Content mix', 'The share of each kind of post in your plan.'], ['Caption', 'The text under a post: a hook, a few lines, a call to action and hashtags.']] },
58
+ checks: () => { const k = plan.calendar || { ideas: [], days: {} }, d = Object.values(k.days || {}).filter(x => x.text); return [
59
+ ['10 or more content ideas', (k.ideas || []).length >= 10],
60
+ ['4 or more kinds of content', new Set((k.ideas || []).map(i => i.type)).size >= 4],
61
+ ['8 or more posts in the calendar', d.length >= 8],
62
+ ['Content made for at least two days', d.filter(x => x.item).length >= 2],
63
+ ['Captions written for at least two days', d.filter(x => Object.values(x.captions || {}).some(c => words(c) > 3)).length >= 2],
64
+ ]; } },
65
+ { id: 'results', day: 3, title: 'Results', lesson: {
66
+ what: 'Results show what worked. Reach is how many people saw a post; engagement rate is likes + comments + shares + saves, divided by reach.',
67
+ why: 'Numbers tell you what to do more of, and what to drop, next month.',
68
+ example: 'Reach 6,500 (target 5,000) · engagement rate 7.1% · storytelling posts work best.',
69
+ exercise: 'Track the numbers of your posts and compare them with your three targets.',
70
+ terms: [['Reach', 'How many different people saw a post.'], ['Impressions', 'How many times it was seen (one person can see it twice).'], ['Engagement rate', '(likes + comments + shares + saves) ÷ reach × 100.']] },
71
+ checks: () => { const rows = ((plan.results || {}).rows || []); return [
72
+ ['3 or more posts with their reach', rows.filter(r => +r.reach > 0).length >= 3],
73
+ ['Interactions typed in (likes, comments…)', rows.filter(r => (+r.likes || 0) + (+r.comments || 0) > 0).length >= 3],
74
+ ['Targets set in the campaign', ((plan.campaign || {}).metrics || []).some(m => +m.target > 0)],
75
+ ]; } },
76
+ { id: 'present', day: 3, title: 'Presentation', lesson: {
77
+ what: 'Bring everything together in a short presentation: brand, audience, campaign, content plan and results.',
78
+ why: 'Presenting your plan is how you get feedback, and it is the last exercise of the course.',
79
+ example: 'Ten slides, five minutes: who we are, who we talk to, what we will post, how we will know it worked.',
80
+ exercise: 'Make your presentation (PDF or PowerPoint) and present it in five minutes.',
81
+ terms: [] },
82
+ checks: () => [['Presenter name', !!plan.presentedBy], ['Presentation made', !!plan.presentedAt]] },
83
+ ];
84
+ const stepOf = id => STEPS.find(s => s.id === id) || STEPS[0];
85
+ const done = st => st.checks().every(c => c[1]);
86
+
87
+ // --- steps list and lesson card ------------------------------------------------------------------------------------------
88
+
89
+ function renderCourseSteps() {
90
+ const nav = $('planSteps');
91
+ nav.innerHTML = '';
92
+ let day = 0;
93
+ for (const st of STEPS) {
94
+ if (st.day !== day) { day = st.day; const h = document.createElement('div'); h.className = 'step-day'; h.textContent = `Day ${day}`; nav.appendChild(h); }
95
+ const ch = st.checks(), ok = ch.filter(c => c[1]).length;
96
+ const b = document.createElement('button');
97
+ b.type = 'button'; b.className = 'step'; b.setAttribute('aria-current', String(planTab === st.id));
98
+ b.innerHTML = '<span class="step-n"></span><span class="step-t"></span><span class="step-s"></span>';
99
+ b.querySelector('.step-n').textContent = ok === ch.length ? '✓' : String(STEPS.indexOf(st) + 1);
100
+ b.querySelector('.step-n').classList.toggle('ok', ok === ch.length);
101
+ b.querySelector('.step-t').textContent = st.title;
102
+ b.querySelector('.step-s').textContent = `${ok}/${ch.length}`;
103
+ b.addEventListener('click', () => goStep(st.id));
104
+ nav.appendChild(b);
105
+ }
106
+ const total = STEPS.length, fin = STEPS.filter(done).length;
107
+ const p = document.createElement('div'); p.className = 'step-progress';
108
+ p.innerHTML = `<span>${fin} of ${total} steps done</span><span class="bar"><span style="width:${fin / total * 100}%"></span></span>`;
109
+ nav.appendChild(p);
110
+ const i = STEPS.findIndex(s => s.id === planTab);
111
+ $('planPrev').hidden = i <= 0;
112
+ $('planNext').textContent = i >= STEPS.length - 1 ? 'Finish' : `Next: ${STEPS[i + 1].title} →`;
113
+ }
114
+ function renderCourse() {
115
+ renderCourseSteps();
116
+ const st = stepOf(planTab), L = st.lesson, open = store('ora.lessonOpen') !== false;
117
+ const card = $('lessonCard');
118
+ card.innerHTML = `<div class="lesson-head"><span class="lesson-day">Day ${st.day} · Step ${STEPS.indexOf(st) + 1}</span><h2></h2><span class="spacer"></span><button class="link" data-a="toggle" type="button"></button></div>
119
+ <div class="lesson-body"${open ? '' : ' hidden'}><div class="lesson-cols"><div><b>What</b><p data-k="what"></p><b>Why it matters</b><p data-k="why"></p></div><div><b>A good example</b><p class="lesson-ex" data-k="example"></p><b>Your exercise</b><p data-k="exercise"></p></div></div>
120
+ <div class="lesson-terms"></div></div>
121
+ <div class="lesson-actions"><button class="primary" data-a="draft" type="button">✨ Draft with AI</button><button class="ghost" data-a="coach" type="button">Check my work</button><span class="muted small" data-k="note"></span></div>`;
122
+ card.querySelector('h2').textContent = st.title;
123
+ for (const k of ['what', 'why', 'example', 'exercise']) card.querySelector(`[data-k=${k}]`).textContent = L[k];
124
+ const terms = card.querySelector('.lesson-terms');
125
+ for (const [t, d] of L.terms) { const x = document.createElement('span'); x.className = 'term'; x.tabIndex = 0; x.textContent = t; x.title = d; x.setAttribute('aria-label', `${t}: ${d}`); terms.appendChild(x); }
126
+ card.querySelector('[data-a=toggle]').textContent = open ? 'Hide the lesson' : 'Show the lesson';
127
+ card.querySelector('[data-a=toggle]').addEventListener('click', () => { store('ora.lessonOpen', !open); renderCourse(); });
128
+ const draft = card.querySelector('[data-a=draft]');
129
+ draft.hidden = !['brand', 'personas', 'campaign', 'calendar'].includes(st.id);
130
+ draft.addEventListener('click', e => draftStep(st.id, e.currentTarget));
131
+ card.querySelector('[data-a=coach]').addEventListener('click', e => coach(st, e.currentTarget));
132
+ $('coachBox').hidden = true;
133
+ decorateAi();
134
+ }
135
+ function goStep(id) { planTab = id; renderPlan(); document.querySelector('main').scrollTop = 0; }
136
+ $('planPrev').addEventListener('click', () => { const i = STEPS.findIndex(s => s.id === planTab); if (i > 0) goStep(STEPS[i - 1].id); });
137
+ $('planNext').addEventListener('click', () => { const i = STEPS.findIndex(s => s.id === planTab); if (i < STEPS.length - 1) goStep(STEPS[i + 1].id); else goStep('present'); });
138
+
139
+ // --- ✨ Draft with AI ------------------------------------------------------------------------------------------------------
140
+
141
+ // fields Ora drafted and the person has not touched yet: shown with an "AI draft" label
142
+ const AI_FIELDS = { 'brand.mission': 'bMission', 'brand.values': 'bValues', 'brand.tone': 'bTone', 'brand.tagline': 'bTagline', 'brand.personality': 'bPersonality',
143
+ 'campaign.name': 'cName', 'campaign.message': 'cMessage', 'campaign.value': 'cValue', 'campaign.offer': 'cOffer', 'campaign.cta': 'cCta', 'campaign.channels': 'cChannels', 'campaign.funnel': 'cFunnel', 'campaign.metrics': 'cMetrics' };
144
+ function decorateAi() {
145
+ plan.ai = plan.ai || {};
146
+ for (const b of document.querySelectorAll('.ai-badge')) b.remove();
147
+ for (const [key, id] of Object.entries(AI_FIELDS)) {
148
+ if (!plan.ai[key]) continue;
149
+ const el = $(id); if (!el) continue;
150
+ const host = el.closest('.field') ? el.closest('.field').querySelector('.label') : el.closest('.plan-card').querySelector('h3');
151
+ if (!host) continue;
152
+ const b = document.createElement('span'); b.className = 'ai-badge'; b.innerHTML = 'AI draft <button type="button">Keep</button>';
153
+ b.title = 'Ora drafted this. Read it, make it yours, or press Keep.';
154
+ b.querySelector('button').addEventListener('click', () => { delete plan.ai[key]; savePlan(); b.remove(); });
155
+ host.appendChild(b);
156
+ }
157
+ for (const card of document.querySelectorAll('#personaGrid .persona')) {
158
+ const i = [...card.parentNode.children].indexOf(card), p = plan.personas[i];
159
+ if (p && p.ai && !card.querySelector('.ai-badge')) { const b = document.createElement('span'); b.className = 'ai-badge'; b.innerHTML = 'AI draft <button type="button">Keep</button>'; b.querySelector('button').addEventListener('click', () => { delete p.ai; savePlan(); b.remove(); }); card.querySelector('.persona-foot').prepend(b); }
160
+ }
161
+ }
162
+ // typing in a drafted field makes it the person's own
163
+ document.addEventListener('input', e => {
164
+ if (!plan.ai || !e.target.id) return;
165
+ for (const [key, id] of Object.entries(AI_FIELDS)) if (id === e.target.id && plan.ai[key]) { delete plan.ai[key]; savePlan(); decorateAi(); }
166
+ }, true);
167
+
168
+ function brandFactsText() {
169
+ const b = plan.brand || {};
170
+ return [`Brand name: ${b.name}`, `What it offers and where: ${b.offer}`, b.mission && `Mission so far: ${b.mission}`, b.values && `Values so far: ${b.values}`].filter(Boolean).join('\n');
171
+ }
172
+ function planFactsText() {
173
+ const b = plan.brand || {};
174
+ return [brandFactsText(), b.personality && b.personality.length && `Personality: ${b.personality.join(', ')}`, b.tone && `Tone: ${b.tone}`, b.tagline && `Tagline: ${b.tagline}`,
175
+ ...(plan.personas || []).filter(p => p.name).map(p => `Customer: ${p.name}, ${p.age}, ${p.job}; needs ${p.needs}; online on ${(p.where || []).join(', ')}`)].filter(Boolean).join('\n');
176
+ }
177
+ // Ora's own drafts when Cloudflare is not connected: simple, honest starting points built from the person's words
178
+ function offlineDraft(kind) {
179
+ const b = plan.brand || {}, what = String(b.offer || 'what we make').split(/\s+(in|for|near|at)\s+/i)[0], whatL = what.charAt(0).toLowerCase() + what.slice(1);
180
+ const where = (String(b.offer || '').match(/\s(in|near|at)\s+(.+)$/i) || [])[2] || 'our area';
181
+ if (kind === 'brand') return { mission: `${b.name || 'We'} offers ${whatL} in ${where}, with honest advice and a personal touch, for people who want quality without the hassle.`, values: 'quality, friendly service, local, honest', personality: ['Friendly', 'Warm', 'Trustworthy'], tone: 'friendly, clear and simple', tagline: `${b.name || 'We'}: made for you.` };
182
+ if (kind === 'personas') return [
183
+ { name: 'Anna', age: '32', job: `Busy professional in ${where}`, needs: `Good ${whatL} that fits a busy day`, pains: 'Little time; disappointed by average quality', motivations: 'Quality, convenience, friendly service', where: ['Instagram', 'Google'], quote: 'I want something good without the hassle.' },
184
+ { name: 'Paul', age: '55', job: 'Local resident and regular customer', needs: `A place he trusts for ${whatL}`, pains: 'Feels ignored by big chains', motivations: 'Personal welcome, fair prices', where: ['Facebook', 'Google'], quote: 'I come back where they know my name.' },
185
+ ];
186
+ if (kind === 'campaign') {
187
+ const month = new Date(Date.now() + 7 * 864e5).toLocaleDateString('en', { month: 'long' });
188
+ return { name: `${month} at ${b.name || 'our place'}`, goal: 'visits', message: `Discover our ${whatL} this ${month}.`, value: b.values ? `We are ${b.values.split(',').slice(0, 2).join(' and ').trim()}` : 'Made with care, close to you', offer: 'A small welcome gift for first-time customers', cta: 'Visit us', channels: ['Instagram', 'Facebook'],
189
+ funnel: { awareness: { what: `A short video showing our ${whatL} to new people nearby.` }, engagement: { what: 'A carousel of tips and a question in stories to start conversations.' }, conversion: { what: 'A poster with the welcome offer and how to find us.' } },
190
+ metrics: [{ id: 'reach', target: '2000' }, { id: 'er', target: '4' }, { id: 'followers', target: '50' }] };
191
+ }
192
+ return null;
193
+ }
194
+ async function draftStep(kind, btn) {
195
+ const note = btn.parentNode.querySelector('[data-k=note]');
196
+ const b = plan.brand || {};
197
+ if (!b.name || !b.offer) {
198
+ goStep('brand');
199
+ // the lesson card was redrawn: put the hint on the new one
200
+ $('lessonCard').querySelector('[data-k=note]').textContent = 'First write your brand name and what you offer (and where): Ora drafts the rest from them.';
201
+ setTimeout(() => $(b.name ? 'bOffer' : 'bName').focus(), 100); return;
202
+ }
203
+ if (kind === 'calendar') { $('ideaSuggest').click(); setTimeout(() => $('calFill').click(), 2500); note.textContent = 'Suggesting ideas, then filling the month…'; return; }
204
+ const label = btn.textContent; btn.disabled = true; btn.textContent = 'Drafting…';
205
+ let out = null, online = true;
206
+ try { out = await window.ora.planAi(kind, kind === 'brand' ? brandFactsText() : planFactsText()); }
207
+ catch (e) { online = false; out = offlineDraft(kind); var why = cleanErr(e); }
208
+ btn.disabled = false; btn.textContent = label;
209
+ if (!out) return;
210
+ plan.ai = plan.ai || {};
211
+ if (kind === 'brand') {
212
+ for (const k of ['mission', 'values', 'tone', 'tagline']) if (out[k] && (!b[k] || plan.ai[`brand.${k}`])) { b[k] = out[k]; plan.ai[`brand.${k}`] = true; }
213
+ if (out.personality && out.personality.length && (!(b.personality || []).length || plan.ai['brand.personality'])) { b.personality = out.personality; plan.ai['brand.personality'] = true; }
214
+ } else if (kind === 'personas') {
215
+ const keep = (plan.personas || []).filter(p => p.name && !p.ai);
216
+ const fresh = out.slice(0, Math.max(0, 2 - keep.length) || 2).map((p, i) => ({ ...newPersona(), id: `p${Date.now()}${i}`, ...p, ai: true }));
217
+ plan.personas = [...keep, ...fresh].slice(0, 3);
218
+ if (!plan.personas.some(p => p.main) && plan.personas[0]) plan.personas[0].main = true;
219
+ } else if (kind === 'campaign') {
220
+ const c = camp();
221
+ for (const k of ['name', 'message', 'value', 'offer', 'cta']) if (out[k] && (!c[k] || plan.ai[`campaign.${k}`])) { c[k] = out[k]; plan.ai[`campaign.${k}`] = true; }
222
+ if (out.goal && (!c.name || plan.ai['campaign.name'])) c.goal = out.goal;
223
+ if (out.channels && out.channels.length && (!c.channels.length || plan.ai['campaign.channels'])) { c.channels = out.channels; plan.ai['campaign.channels'] = true; }
224
+ if (out.funnel && (!Object.values(c.funnel || {}).some(f => f && f.what) || plan.ai['campaign.funnel'])) { c.funnel = out.funnel; plan.ai['campaign.funnel'] = true; }
225
+ if (out.metrics && out.metrics.length === 3 && (!c.metrics.some(m => +m.target > 0) || plan.ai['campaign.metrics'])) { c.metrics = out.metrics; plan.ai['campaign.metrics'] = true; }
226
+ }
227
+ savePlan(); renderPlan();
228
+ setTimeout(() => {
229
+ const n = $('lessonCard').querySelector('[data-k=note]');
230
+ if (n) n.textContent = online ? 'Drafted with AI (Cloudflare). Read every line: keep what fits, change what does not. Empty fields only; your own words were kept.'
231
+ : /offline/.test(why) ? 'Connect Cloudflare (free, in Online) for real AI drafts. Here is a simple starting point built from your words; make it yours.'
232
+ : 'The AI did not give a usable answer this time (try again in a moment). Here is a simple starting point built from your words.';
233
+ }, 50);
234
+ }
235
+
236
+ // --- coach: Check my work -------------------------------------------------------------------------------------------------
237
+
238
+ function stepWork(id) {
239
+ const b = plan.brand || {}, c = plan.campaign || {};
240
+ if (id === 'brand') return `Brand: ${b.name}\nOffer: ${b.offer}\nMission: ${b.mission}\nValues: ${b.values}\nPersonality: ${(b.personality || []).join(', ')}\nTone: ${b.tone}\nTagline: ${b.tagline}\nColours: ${(b.colors || []).join(', ')}`;
241
+ if (id === 'personas') return (plan.personas || []).filter(p => p.name).map(p => `${p.name}, ${p.age}, ${p.job}. Needs: ${p.needs}. Frustrations: ${p.pains}. Chooses a brand for: ${p.motivations}. Online: ${(p.where || []).join(', ')}. Quote: ${p.quote}`).join('\n') || '(no personas yet)';
242
+ if (id === 'campaign') return `Name: ${c.name}\nGoal: ${c.goal}\nMessage: ${c.message}\nWhy choose us: ${c.value}\nOffer: ${c.offer}\nCall to action: ${c.cta}\nChannels: ${(c.channels || []).join(', ')}\nFunnel: ${['awareness', 'engagement', 'conversion'].map(k => `${k}: ${((c.funnel || {})[k] || {}).what || ''}`).join(' | ')}\nMetrics: ${(c.metrics || []).map(m => `${m.id} target ${m.target}`).join(', ')}`;
243
+ if (id === 'calendar') { const k = plan.calendar || { ideas: [], days: {} }; return `Ideas: ${(k.ideas || []).map(i => `${i.type}: ${i.text}`).join('; ')}\nPosts in the calendar: ${Object.values(k.days || {}).filter(d => d.text).length}, made: ${Object.values(k.days || {}).filter(d => d.item).length}`; }
244
+ if (id === 'results') { const rows = ((plan.results || {}).rows || []); return rows.map(r => `${r.date} ${r.platform} "${r.title}": reach ${r.reach}, likes ${r.likes}, comments ${r.comments}, followers ${r.followers}`).join('\n') || '(no results yet)'; }
245
+ return `Presented by: ${plan.presentedBy || ''}`;
246
+ }
247
+ async function coach(st, btn) {
248
+ const box = $('coachBox'), ch = st.checks();
249
+ box.hidden = false;
250
+ box.innerHTML = '<h3>Coach</h3><p class="muted small">Looking at your work…</p>';
251
+ const label = btn.textContent; btn.disabled = true;
252
+ let ai = null;
253
+ try { ai = await window.ora.planAi('coach', `Exercise: ${st.lesson.exercise}\nCriteria:\n${ch.map(c => `- ${c[0]}`).join('\n')}\n\nTheir work:\n${stepWork(st.id)}`); } catch { ai = null; }
254
+ btn.disabled = false; btn.textContent = label;
255
+ const ok = ch.filter(c => c[1]), miss = ch.filter(c => !c[1]);
256
+ box.innerHTML = '<h3>Coach</h3>';
257
+ const list = document.createElement('ul'); list.className = 'coach-checks';
258
+ for (const [t, good] of ch) { const li = document.createElement('li'); li.className = good ? 'ok' : 'miss'; li.textContent = `${good ? '✓' : '○'} ${t}`; list.appendChild(li); }
259
+ box.appendChild(list);
260
+ const fb = document.createElement('div'); fb.className = 'coach-ai';
261
+ if (ai) {
262
+ fb.innerHTML = '<p class="good"></p><ul></ul><p class="muted small"></p>';
263
+ fb.querySelector('.good').textContent = `👍 ${ai.good}`;
264
+ for (const t of ai.improve) { const li = document.createElement('li'); li.textContent = t; fb.querySelector('ul').appendChild(li); }
265
+ fb.querySelector('.muted').textContent = `Coach's score: ${'★'.repeat(ai.score)}${'☆'.repeat(5 - ai.score)} · written by AI (Cloudflare): use your own judgement too.`;
266
+ } else {
267
+ fb.innerHTML = '<p></p><p class="muted small">Connect Cloudflare (free, in Online) for written feedback on your words.</p>';
268
+ fb.querySelector('p').textContent = !miss.length ? 'All checks passed: this step is done. Ask a classmate to read it, then move on.' : `${ok.length} of ${ch.length} checks passed. Next: ${miss[0][0].charAt(0).toLowerCase()}${miss[0][0].slice(1)}.`;
269
+ }
270
+ box.appendChild(fb);
271
+ renderCourseSteps();
272
+ box.scrollIntoView({ behavior: 'smooth', block: 'nearest' });
273
+ }
274
+
275
+ // --- the demo: a finished plan for the café Bean & Bloom --------------------------------------------------------------------
276
+
277
+ async function openDemo() {
278
+ $('demoOpen').disabled = true; $('demoOpen').textContent = 'Opening…';
279
+ try {
280
+ const items = await window.ora.demoInstall();
281
+ S.videos = (await window.ora.state()).videos;
282
+ store('ora.planSlot', 'demo');
283
+ const existing = await window.ora.planGet('demo');
284
+ if (!existing || existing.demoVersion !== DEMO_VERSION) await window.ora.planSet(await demoPlan(items), 'demo');
285
+ planReload();
286
+ } catch (e) { alert(`Could not open the demo: ${cleanErr(e)}`); }
287
+ finally { $('demoOpen').disabled = false; $('demoOpen').textContent = 'Open the demo'; }
288
+ }
289
+ function closeDemo() { store('ora.planSlot', 'mine'); planReload(); applyBrand(); }
290
+ function planReload() {
291
+ resetPlanLoaded(); planTab = 'brand'; renderPlan(); renderDemoBar();
292
+ }
293
+ function renderDemoBar() {
294
+ const demo = planSlot() === 'demo';
295
+ $('demoTag').hidden = !demo; $('demoClose').hidden = !demo; $('demoOpen').hidden = demo;
296
+ $('planView').classList.toggle('is-demo', demo);
297
+ }
298
+ $('demoOpen').addEventListener('click', openDemo);
299
+ $('demoClose').addEventListener('click', closeDemo);
300
+ renderDemoBar();
app/renderer/demo.js ADDED
@@ -0,0 +1,75 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 'use strict';
2
+ /* global S, ymd, drawPoster, loadImg */
3
+ // The worked example behind Plan › Open the demo: the café Bean & Bloom, every step done, with pictures made in Ora
4
+ // (renderer/demo, installed into the Library by main's demo:install). Stored in plan-demo.json, apart from the person's plan.
5
+
6
+ const DEMO_VERSION = 1;
7
+
8
+ async function demoPlan(items) {
9
+ const pic = name => ({ id: items[name], file: 'img_00.jpg' });
10
+ // the month starts next Monday
11
+ const start = new Date(); start.setDate(start.getDate() + ((8 - start.getDay()) % 7 || 7)); start.setHours(0, 0, 0, 0);
12
+ const day = n => { const d = new Date(start); d.setDate(start.getDate() + n); return ymd(d); };
13
+ const ideas = [
14
+ ['educational', '3 quick tips for a better coffee at home'], ['educational', 'Latte, flat white or cappuccino? The difference'], ['educational', 'Why we bake with butter, not margarine'],
15
+ ['storytelling', 'Why we opened Bean & Bloom'], ['storytelling', 'Jean\'s Tuesday table: a regular\'s story'],
16
+ ['behind-the-scenes', '6 a.m.: baking the day\'s cakes'], ['behind-the-scenes', 'How our barista pours latte art'],
17
+ ['community', 'Guess this week\'s cake and win a coffee'], ['community', 'Customer of the week'],
18
+ ['lifestyle', 'Your calm hour: laptop, latte and a window seat'], ['lifestyle', 'Sunday mood at Bean & Bloom'],
19
+ ['promotion', 'Autumn Cake Week: free cake with your second coffee'],
20
+ ].map(([type, text], i) => ({ id: `di${i}`, type, text }));
21
+ const cap = (ig, fb, li) => ({ instagram: ig, facebook: fb, linkedin: li });
22
+ const plan_ = [
23
+ [0, 'promotion', 'Autumn Cake Week: free cake with your second coffee', 'cakes', 'posted', cap('Autumn Cake Week starts today ☕🍰\n\nA new homemade cake every day, and your second coffee comes with a free slice.\n\n👉 Visit us in Esch this week!\n\n#BeanAndBloom #AutumnCakeWeek #EschSurAlzette #Homemade #CoffeeAndCake #Luxembourg', 'Autumn Cake Week starts today! A new homemade cake every day, and a free slice with your second coffee. See you at Bean & Bloom in Esch.\n\n#BeanAndBloom #AutumnCakeWeek', '')],
24
+ [2, 'storytelling', 'Why we opened Bean & Bloom', 'interior', 'posted', cap('We wanted a place where neighbours meet. ☕\n\nThree years ago we opened a small corner in Esch for great coffee and cakes baked every morning.\n\n👉 Come and say hello.\n\n#BeanAndBloom #OurStory #LocalCafe #Esch', '', '')],
25
+ [4, 'behind-the-scenes', 'How our barista pours latte art', 'carousel', 'posted', cap('Ever wondered how the heart gets in your latte? ❤️\n\nSwipe for three tips from our barista.\n\n👉 Order one and watch it happen.\n\n#LatteArt #BehindTheScenes #BeanAndBloom', '', '')],
26
+ [7, 'educational', '3 quick tips for a better coffee at home', 'latte', 'posted', cap('', 'Three quick tips for a better coffee at home: fresh beans, the right grind and water just off the boil. Or let us make it for you!\n\n#CoffeeTips #BeanAndBloom', '3 small habits that make a big difference to your coffee break — from a café that serves 300 cups a day.\n\nFresh beans · the right grind · water just off the boil.\n\n#CoffeeTips #SmallBusiness #Luxembourg')],
27
+ [9, 'community', 'Guess this week\'s cake and win a coffee', 'cakes', 'posted', cap('Guess the cake 🍰 Comment your answer: the first right guess wins a free coffee!\n\n#BeanAndBloom #GuessTheCake', '', '')],
28
+ [11, 'lifestyle', 'Your calm hour: laptop, latte and a window seat', 'interior', 'scheduled', {}],
29
+ [14, 'educational', 'Latte, flat white or cappuccino? The difference', 'latte', 'made', {}],
30
+ [16, 'storytelling', 'Jean\'s Tuesday table: a regular\'s story', 'jean', 'idea', {}],
31
+ [18, 'behind-the-scenes', '6 a.m.: baking the day\'s cakes', null, 'idea', {}],
32
+ [21, 'community', 'Customer of the week', null, 'idea', {}],
33
+ [23, 'lifestyle', 'Sunday mood at Bean & Bloom', null, 'idea', {}],
34
+ [25, 'educational', 'Why we bake with butter, not margarine', null, 'idea', {}],
35
+ [28, 'promotion', 'Autumn Cake Week: last days for your free slice', null, 'idea', {}],
36
+ ];
37
+ const days = {};
38
+ for (const [n, type, text, item, status, captions] of plan_) {
39
+ days[day(n)] = { type, text, platforms: n === 7 ? ['facebook', 'linkedin'] : n === 0 ? ['instagram', 'facebook'] : ['instagram'], status, item: item ? { id: items[item] } : null, captions };
40
+ }
41
+ const rows = [
42
+ [0, 'Instagram', 'Autumn Cake Week: free cake with your second coffee', 'promotion', 1450, 1890, 96, 14, 9, 21, 33, 18],
43
+ [0, 'Facebook', 'Autumn Cake Week: free cake with your second coffee', 'promotion', 820, 1010, 41, 6, 7, 0, 25, 4],
44
+ [2, 'Instagram', 'Why we opened Bean & Bloom', 'storytelling', 1980, 2460, 188, 31, 17, 40, 21, 26],
45
+ [4, 'Instagram', 'How our barista pours latte art', 'behind-the-scenes', 2310, 3050, 201, 22, 25, 63, 19, 31],
46
+ [7, 'LinkedIn', '3 quick tips for a better coffee at home', 'educational', 640, 900, 28, 5, 3, 0, 12, 7],
47
+ [9, 'Instagram', 'Guess this week\'s cake and win a coffee', 'community', 1210, 1500, 77, 64, 6, 8, 9, 12],
48
+ ].map(([n, platform, title, type, reach, impressions, likes, comments, shares, saves, clicks, followers], i) => ({ id: `dr${i}`, date: day(n), platform, title, type, reach: String(reach), impressions: String(impressions), likes: String(likes), comments: String(comments), shares: String(shares), saves: String(saves), clicks: String(clicks), followers: String(followers) }));
49
+ // the ad's picture for the presentation: the cakes with the headline, drawn the way the Ad maker would
50
+ let ads = [];
51
+ try {
52
+ const img = await loadImg(`ora://video/${encodeURIComponent(items.cakes)}/img_00.jpg`);
53
+ const cv = document.createElement('canvas');
54
+ await drawPoster(cv, img, { title: 'A new cake every day', sub: 'Autumn Cake Week', details: '', cta: 'Visit us today', layout: 'top', font: 'serif', accent: '#7b4a2a', format: 'portrait' }, null);
55
+ const small = document.createElement('canvas'); small.width = 270; small.height = 480; small.getContext('2d').drawImage(cv, 0, 0, 270, 480);
56
+ ads = [{ title: 'Autumn Cake Week', files: [], formats: 3, thumb: small.toDataURL('image/jpeg', 0.85), ratio: '9:16', created: new Date().toISOString() }];
57
+ } catch { }
58
+ return {
59
+ demoVersion: DEMO_VERSION,
60
+ brand: { name: 'Bean & Bloom', offer: 'Specialty coffee and homemade cakes in Esch-sur-Alzette', mission: 'A warm corner where neighbours meet over great coffee and cakes baked every morning, for everyone who needs a calm break in their day.',
61
+ values: 'local, homemade, welcoming, fair trade', personality: ['Warm', 'Friendly', 'Natural'], tone: 'warm and chatty, like a friendly barista; short sentences', tagline: 'Your daily cup of calm.',
62
+ avoid: 'paper cups piled up, crowded tables', colors: ['#7b4a2a', '#f5efe0', '#d4a72c'], font: 'serif', logo: null, use: true },
63
+ personas: [
64
+ { id: 'dp1', name: 'Sofia', age: '34', job: 'Remote designer', needs: 'A calm place to work for a few hours, with good coffee and wifi', pains: 'Noisy chains, rushed service, nowhere to plug in', motivations: 'Atmosphere, good coffee, friendly staff', where: ['Instagram', 'Google'], quote: 'I just need a quiet table and a good latte.', portrait: pic('sofia'), main: true },
65
+ { id: 'dp2', name: 'Jean', age: '67', job: 'Retired teacher', needs: 'Somewhere to meet friends in the afternoon', pains: 'Modern places feel cold and loud', motivations: 'Homemade cakes and a personal welcome', where: ['Facebook', 'Google'], quote: 'I come back where they know my name.', portrait: pic('jean'), main: false },
66
+ ],
67
+ campaign: { name: 'Autumn Cake Week', goal: 'visits', start: day(0), end: day(13), message: 'A new homemade cake every day this week.', value: 'Baked in our kitchen every morning, with local butter and fruit', offer: 'Free cake with your second coffee', cta: 'Visit us today', channels: ['Instagram', 'Facebook', 'Google Business'],
68
+ funnel: { awareness: { what: 'A 15-second video ad of the cakes coming out of the oven, shown to people within 5 km on Instagram.' }, engagement: { what: 'A carousel of coffee-break tips and a "guess the cake" post to get comments.' }, conversion: { what: 'An offer poster: free cake with your second coffee, with the address and opening hours.' } },
69
+ metrics: [{ id: 'reach', target: '6000' }, { id: 'er', target: '6' }, { id: 'followers', target: '80' }] },
70
+ calendar: { start: day(0), perWeek: 3, time: '08:30', ideas, days },
71
+ results: { rows },
72
+ ads,
73
+ presentedBy: 'The Bean & Bloom team',
74
+ };
75
+ }
app/renderer/demo/barista.jpg ADDED
app/renderer/demo/cakes.jpg ADDED
app/renderer/demo/interior.jpg ADDED
app/renderer/demo/jean.jpg ADDED
app/renderer/demo/latte.jpg ADDED
app/renderer/demo/sofia.jpg ADDED
app/renderer/index.html CHANGED
@@ -297,18 +297,14 @@
297
  <!-- plan: the marketing plan, in the order of the course: brand, personas, campaign, calendar, results -->
298
  <section id="planView" class="page page-plan" hidden>
299
  <div class="page-head">
300
- <div><h1>Plan</h1><p class="muted small">Your marketing plan, step by step. Everything you write here shapes what Ora makes: prompts, posters, ads and captions.</p></div>
301
  <div class="spacer"></div>
302
- <div class="seg plan-tabs" id="planTabs" role="tablist">
303
- <button type="button" data-tab="brand" aria-checked="true">1 · Brand</button>
304
- <button type="button" data-tab="personas" aria-checked="false">2 · Personas</button>
305
- <button type="button" data-tab="campaign" aria-checked="false">3 · Campaign</button>
306
- <button type="button" data-tab="calendar" aria-checked="false">4 · Calendar</button>
307
- <button type="button" data-tab="results" aria-checked="false">5 · Results</button>
308
- <button type="button" data-tab="present" aria-checked="false">6 · Presentation</button>
309
- </div>
310
  </div>
311
-
 
 
 
312
  <div class="plan-pane" id="paneBrand">
313
  <div class="plan-grid">
314
  <div class="panel plan-card">
@@ -429,6 +425,10 @@
429
  <label class="field"><span class="label">Presented by <small class="muted">(optional)</small></span><input id="presentBy" maxlength="80" placeholder="Your name"></label>
430
  <div class="ad-row"><button class="primary" id="presentMake" type="button">Make the presentation (PDF)</button><button class="ghost" id="presentPptx" type="button">PowerPoint (.pptx)</button><span class="muted small" id="presentNote"></span></div>
431
  </div>
 
 
 
 
432
  </div>
433
  </section>
434
 
@@ -618,5 +618,7 @@
618
  <script src="plan.js"></script>
619
  <script src="calendar.js"></script>
620
  <script src="campaign.js"></script>
 
 
621
  </body>
622
  </html>
 
297
  <!-- plan: the marketing plan, in the order of the course: brand, personas, campaign, calendar, results -->
298
  <section id="planView" class="page page-plan" hidden>
299
  <div class="page-head">
300
+ <div><h1>Plan</h1><p class="muted small">Your marketing plan, step by step, in the order of the course. Everything you write here shapes what Ora makes.</p></div>
301
  <div class="spacer"></div>
302
+ <div class="demo-bar" id="demoBar"><span class="demo-tag" id="demoTag" hidden>Demo · Bean &amp; Bloom</span><button class="ghost" id="demoOpen" type="button">Open the demo</button><button class="primary" id="demoClose" type="button" hidden>Back to my plan</button></div>
 
 
 
 
 
 
 
303
  </div>
304
+ <div class="plan-shell">
305
+ <nav class="plan-steps" id="planSteps" aria-label="Plan steps"></nav>
306
+ <div class="plan-main">
307
+ <div class="lesson" id="lessonCard"></div>
308
  <div class="plan-pane" id="paneBrand">
309
  <div class="plan-grid">
310
  <div class="panel plan-card">
 
425
  <label class="field"><span class="label">Presented by <small class="muted">(optional)</small></span><input id="presentBy" maxlength="80" placeholder="Your name"></label>
426
  <div class="ad-row"><button class="primary" id="presentMake" type="button">Make the presentation (PDF)</button><button class="ghost" id="presentPptx" type="button">PowerPoint (.pptx)</button><span class="muted small" id="presentNote"></span></div>
427
  </div>
428
+ </div>
429
+ <div class="coach" id="coachBox" hidden></div>
430
+ <div class="plan-nav"><button class="ghost" id="planPrev" type="button">← Back</button><span class="spacer"></span><button class="primary" id="planNext" type="button">Next step →</button></div>
431
+ </div>
432
  </div>
433
  </section>
434
 
 
618
  <script src="plan.js"></script>
619
  <script src="calendar.js"></script>
620
  <script src="campaign.js"></script>
621
+ <script src="demo.js"></script>
622
+ <script src="course.js"></script>
623
  </body>
624
  </html>
app/renderer/plan.js CHANGED
@@ -1,6 +1,6 @@
1
  'use strict';
2
  /* global $, S, store, brand, poster, renderBrand, renderMoreSummary, renderPosterFields, showView, setMode, imgForm, cleanErr,
3
- POSTER_FONTS, wrapLines, roundRect, luminance, loadImg, formNote, renderCalendar, renderPresent, renderCampaign, renderResults */
4
  // Plan tab (course order): 1 Brand, 2 Personas, 3 Campaign and 5 Results (renderer/campaign.js), 4 Calendar and
5
  // 6 Presentation (renderer/calendar.js). The plan lives in userData/plan.json; "Use this brand in Create"
6
  // feeds the brand kit (prompts), the poster and ad defaults (colour, logo, font) and the captions (tone, audience).
@@ -14,7 +14,9 @@ const COLOR_NAMES = [['black', '#111111'], ['charcoal', '#36454f'], ['grey', '#8
14
  ['navy blue', '#1a2a5a'], ['purple', '#6a1b9a'], ['lavender', '#c7b8ea'], ['burgundy', '#7b1f3a']];
15
 
16
  let plan = { brand: {}, personas: [] };
 
17
  let planLoaded = false, planTab = 'brand';
 
18
 
19
  function hexName(hex) {
20
  const n = h => [1, 3, 5].map(i => parseInt(h.slice(i, i + 2), 16));
@@ -28,7 +30,7 @@ function hexName(hex) {
28
 
29
  async function loadPlan() {
30
  if (planLoaded) return;
31
- try { plan = { brand: {}, personas: [], ...(await window.ora.planGet()) }; } catch { }
32
  plan.brand = { name: '', offer: '', mission: '', values: '', personality: [], tone: '', tagline: '', avoid: '', colors: ['#1c6b4f', '#f5efe0'], font: 'modern', logo: null, use: true, ...plan.brand };
33
  plan.personas = Array.isArray(plan.personas) ? plan.personas : [];
34
  planLoaded = true;
@@ -37,8 +39,9 @@ let saveTimer = null;
37
  function savePlan() {
38
  clearTimeout(saveTimer);
39
  saveTimer = setTimeout(async () => {
40
- try { await window.ora.planSet(plan); $('bSaved').textContent = 'Saved on this computer.'; } catch (e) { $('bSaved').textContent = cleanErr(e); }
41
- applyBrand();
 
42
  }, 400);
43
  }
44
 
@@ -76,7 +79,7 @@ function mainPersona() { return personaDesc(plan.personas.find(x => x.main) || p
76
 
77
  function renderPlan() {
78
  loadPlan().then(() => {
79
- for (const b of $('planTabs').children) b.setAttribute('aria-checked', String(b.dataset.tab === planTab));
80
  for (const [tab, id] of [['brand', 'paneBrand'], ['personas', 'panePersonas'], ['campaign', 'paneCampaign'], ['calendar', 'paneCalendar'], ['results', 'paneResults'], ['present', 'panePresent']]) $(id).hidden = planTab !== tab;
81
  ({ brand: renderBrandPane, personas: renderPersonas, campaign: renderCampaign, calendar: renderCalendar, results: renderResults, present: renderPresent })[planTab]();
82
  });
@@ -223,7 +226,7 @@ function makePortrait(p) {
223
  formNote(`Portrait prompt for ${p.name || 'your persona'} is ready: press Make image. Then in Plan › Personas, press Picture… and pick it.`);
224
  }
225
  $('addPersona').addEventListener('click', () => { plan.personas.push(newPersona()); renderPersonas(); savePlan(); });
226
- for (const b of $('planTabs').children) b.addEventListener('click', () => { planTab = b.dataset.tab; renderPlan(); });
227
 
228
  // --- Brand Identity Summary (A4 PNG) ---------------------------------------------------------------------------------
229
 
@@ -311,7 +314,7 @@ $('pExport').addEventListener('click', async e => {
311
  try { await exportSummary(); b.textContent = 'Saved ✓ (Documents/Ora)'; } catch (err) { b.textContent = cleanErr(err); }
312
  setTimeout(() => { b.textContent = label; }, 4000);
313
  });
314
- loadPlan().then(applyBrand);
315
 
316
  // --- classroom pack: example businesses, and the plan as a file -----------------------------------------------------
317
 
@@ -364,7 +367,7 @@ $('planFile').addEventListener('change', async e => {
364
  if (p.brand.logo && !here(p.brand.logo.id)) p.brand.logo = null;
365
  for (const x of p.personas || []) if (x.portrait && !here(x.portrait.id)) x.portrait = null;
366
  plan = { brand: {}, personas: [], ...p };
367
- planLoaded = false; await window.ora.planSet(plan); await loadPlan(); savePlan(); renderPlan();
368
  $('planFileNote').textContent = `Opened the plan for ${plan.brand.name || 'your brand'}.`;
369
  } catch (err) { $('planFileNote').textContent = cleanErr(err); }
370
  });
 
1
  'use strict';
2
  /* global $, S, store, brand, poster, renderBrand, renderMoreSummary, renderPosterFields, showView, setMode, imgForm, cleanErr,
3
+ POSTER_FONTS, wrapLines, roundRect, luminance, loadImg, formNote, renderCalendar, renderPresent, renderCampaign, renderResults, renderCourse, renderCourseSteps */
4
  // Plan tab (course order): 1 Brand, 2 Personas, 3 Campaign and 5 Results (renderer/campaign.js), 4 Calendar and
5
  // 6 Presentation (renderer/calendar.js). The plan lives in userData/plan.json; "Use this brand in Create"
6
  // feeds the brand kit (prompts), the poster and ad defaults (colour, logo, font) and the captions (tone, audience).
 
14
  ['navy blue', '#1a2a5a'], ['purple', '#6a1b9a'], ['lavender', '#c7b8ea'], ['burgundy', '#7b1f3a']];
15
 
16
  let plan = { brand: {}, personas: [] };
17
+ const planSlot = () => (store('ora.planSlot') === 'demo' ? 'demo' : 'mine');
18
  let planLoaded = false, planTab = 'brand';
19
+ function resetPlanLoaded() { planLoaded = false; }
20
 
21
  function hexName(hex) {
22
  const n = h => [1, 3, 5].map(i => parseInt(h.slice(i, i + 2), 16));
 
30
 
31
  async function loadPlan() {
32
  if (planLoaded) return;
33
+ try { plan = { brand: {}, personas: [], ...(await window.ora.planGet(planSlot())) }; } catch { }
34
  plan.brand = { name: '', offer: '', mission: '', values: '', personality: [], tone: '', tagline: '', avoid: '', colors: ['#1c6b4f', '#f5efe0'], font: 'modern', logo: null, use: true, ...plan.brand };
35
  plan.personas = Array.isArray(plan.personas) ? plan.personas : [];
36
  planLoaded = true;
 
39
  function savePlan() {
40
  clearTimeout(saveTimer);
41
  saveTimer = setTimeout(async () => {
42
+ try { await window.ora.planSet(plan, planSlot()); $('bSaved').textContent = 'Saved on this computer.'; } catch (e) { $('bSaved').textContent = cleanErr(e); }
43
+ if (planSlot() !== 'demo') applyBrand(); // the demo never changes the person's Create settings
44
+ if (typeof renderCourse === 'function' && !$('planView').hidden) renderCourseSteps();
45
  }, 400);
46
  }
47
 
 
79
 
80
  function renderPlan() {
81
  loadPlan().then(() => {
82
+ renderCourse();
83
  for (const [tab, id] of [['brand', 'paneBrand'], ['personas', 'panePersonas'], ['campaign', 'paneCampaign'], ['calendar', 'paneCalendar'], ['results', 'paneResults'], ['present', 'panePresent']]) $(id).hidden = planTab !== tab;
84
  ({ brand: renderBrandPane, personas: renderPersonas, campaign: renderCampaign, calendar: renderCalendar, results: renderResults, present: renderPresent })[planTab]();
85
  });
 
226
  formNote(`Portrait prompt for ${p.name || 'your persona'} is ready: press Make image. Then in Plan › Personas, press Picture… and pick it.`);
227
  }
228
  $('addPersona').addEventListener('click', () => { plan.personas.push(newPersona()); renderPersonas(); savePlan(); });
229
+
230
 
231
  // --- Brand Identity Summary (A4 PNG) ---------------------------------------------------------------------------------
232
 
 
314
  try { await exportSummary(); b.textContent = 'Saved ✓ (Documents/Ora)'; } catch (err) { b.textContent = cleanErr(err); }
315
  setTimeout(() => { b.textContent = label; }, 4000);
316
  });
317
+ loadPlan().then(() => { if (planSlot() !== 'demo') applyBrand(); });
318
 
319
  // --- classroom pack: example businesses, and the plan as a file -----------------------------------------------------
320
 
 
367
  if (p.brand.logo && !here(p.brand.logo.id)) p.brand.logo = null;
368
  for (const x of p.personas || []) if (x.portrait && !here(x.portrait.id)) x.portrait = null;
369
  plan = { brand: {}, personas: [], ...p };
370
+ planLoaded = false; await window.ora.planSet(plan, planSlot()); await loadPlan(); savePlan(); renderPlan();
371
  $('planFileNote').textContent = `Opened the plan for ${plan.brand.name || 'your brand'}.`;
372
  } catch (err) { $('planFileNote').textContent = cleanErr(err); }
373
  });
app/renderer/styles.css CHANGED
@@ -500,3 +500,45 @@ body { background-image: none; }
500
  .rtable select { min-width: 112px; }
501
  .rtable input[type=date] { width: 132px; }
502
  .starter-card { margin-top: 16px; }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
500
  .rtable select { min-width: 112px; }
501
  .rtable input[type=date] { width: 132px; }
502
  .starter-card { margin-top: 16px; }
503
+
504
+ /* course mode (Plan) */
505
+ .plan-shell { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 20px; align-items: start; }
506
+ .plan-steps { position: sticky; top: 12px; display: flex; flex-direction: column; gap: 4px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 12px; }
507
+ .step-day { font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 8px 6px 2px; }
508
+ .step-day:first-child { margin-top: 0; }
509
+ .step { display: grid; grid-template-columns: 26px 1fr auto; align-items: center; gap: 8px; border: 0; background: none; text-align: left; padding: 7px 8px; border-radius: 10px; cursor: pointer; font: inherit; color: var(--text); }
510
+ .step:hover { background: var(--panel-2); }
511
+ .step[aria-current="true"] { background: #1c1530; color: #fff; }
512
+ .step[aria-current="true"] .step-s { color: rgba(255,255,255,.7); }
513
+ .step-n { width: 24px; height: 24px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; background: var(--panel-2); color: var(--text); }
514
+ .step-n.ok { background: #008300; color: #fff; }
515
+ .step-t { font-size: 13.5px; font-weight: 600; }
516
+ .step-s { font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
517
+ .step-progress { margin-top: 10px; padding: 8px 6px 0; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: var(--muted); }
518
+ .step-progress .bar { height: 6px; background: var(--panel-2); border-radius: 99px; overflow: hidden; }
519
+ .step-progress .bar span { display: block; height: 100%; background: #008300; border-radius: 99px; }
520
+ .lesson { background: var(--panel); border: 1px solid var(--line); border-left: 5px solid #1c1530; border-radius: 14px; padding: 16px 18px; margin-bottom: 16px; }
521
+ .lesson-head { display: flex; align-items: baseline; gap: 10px; }
522
+ .lesson-head h2 { margin: 0; font-size: 20px; }
523
+ .lesson-day { font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
524
+ .lesson-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-top: 10px; }
525
+ .lesson-cols b { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
526
+ .lesson-cols p { margin: 3px 0 10px; font-size: 14px; line-height: 1.45; }
527
+ .lesson-ex { font-style: italic; }
528
+ .lesson-terms { display: flex; gap: 8px; flex-wrap: wrap; }
529
+ .term { font-size: 12.5px; border-bottom: 1px dashed var(--muted); cursor: help; padding: 1px 2px; }
530
+ .term::before { content: '? '; color: var(--muted); }
531
+ .lesson-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 12px; }
532
+ .ai-badge { display: inline-flex; align-items: center; gap: 6px; margin-left: 8px; font-size: 11px; font-weight: 700; letter-spacing: .02em; text-transform: none; color: #6250d6; background: rgba(98, 80, 214, .1); border-radius: 999px; padding: 2px 4px 2px 9px; }
533
+ .ai-badge button { border: 0; background: #6250d6; color: #fff; border-radius: 999px; font-size: 11px; padding: 2px 8px; cursor: pointer; }
534
+ .coach { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 16px 18px; margin-top: 16px; }
535
+ .coach h3 { margin: 0 0 8px; font-size: 15px; }
536
+ .coach-checks { list-style: none; margin: 0 0 10px; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 4px 16px; font-size: 13px; }
537
+ .coach-checks .ok { color: #006300; } .coach-checks .miss { color: var(--muted); }
538
+ .coach-ai .good { font-weight: 600; }
539
+ .coach-ai ul { margin: 6px 0; padding-left: 20px; font-size: 13.5px; }
540
+ .plan-nav { display: flex; align-items: center; gap: 10px; margin-top: 18px; }
541
+ .demo-bar { display: flex; align-items: center; gap: 10px; }
542
+ .demo-tag { font-size: 12px; font-weight: 700; background: #d4a72c; color: #1c1530; border-radius: 999px; padding: 4px 12px; }
543
+ .page-plan.is-demo .lesson { border-left-color: #d4a72c; }
544
+ @media (max-width: 1000px) { .plan-shell { grid-template-columns: 1fr; } .plan-steps { position: static; } .lesson-cols { grid-template-columns: 1fr; } }
index.html CHANGED
@@ -37,7 +37,7 @@
37
  <!-- hero -->
38
  <section class="hero">
39
  <div class="hero-copy">
40
- <a class="pill" href="#how"><span class="dot"></span>New in 0.3: plan your whole campaign (brand, personas, calendar, results) and post through n8n</a>
41
  <h1>Turn words into <span class="grad">scroll-stopping</span> videos, images and ads.</h1>
42
  <p class="sub">Make video shots, product images, posters and carousels with your exact text, then join them into a finished ad with music and voice-over for Reels, TikTok, LinkedIn and YouTube. All on your own computer: no account, no upload, no monthly fee.</p>
43
  <div class="hero-install" id="heroInstall">
 
37
  <!-- hero -->
38
  <section class="hero">
39
  <div class="hero-copy">
40
+ <a class="pill" href="#how"><span class="dot"></span>New in 0.3.1: learn marketing step by step, with AI drafts, a coach and a finished demo</a>
41
  <h1>Turn words into <span class="grad">scroll-stopping</span> videos, images and ads.</h1>
42
  <p class="sub">Make video shots, product images, posters and carousels with your exact text, then join them into a finished ad with music and voice-over for Reels, TikTok, LinkedIn and YouTube. All on your own computer: no account, no upload, no monthly fee.</p>
43
  <div class="hero-install" id="heroInstall">
worker/ora_worker.py CHANGED
@@ -12,7 +12,7 @@ only requests carrying that code's secret are accepted. Standard library only.
12
  import argparse, base64, hashlib, json, os, re, secrets, shutil, subprocess, sys, tarfile, threading, time, urllib.request
13
  from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer
14
 
15
- VERSION = '0.3.0'
16
  SITE = 'https://devseis-ora.static.hf.space'
17
  RELEASES = 'https://huggingface.co/datasets/Devseis/ora-releases/resolve/main'
18
  ENGINE_FILE = 'ora-engine-linux-cuda.tar.gz'
 
12
  import argparse, base64, hashlib, json, os, re, secrets, shutil, subprocess, sys, tarfile, threading, time, urllib.request
13
  from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer
14
 
15
+ VERSION = '0.3.1'
16
  SITE = 'https://devseis-ora.static.hf.space'
17
  RELEASES = 'https://huggingface.co/datasets/Devseis/ora-releases/resolve/main'
18
  ENGINE_FILE = 'ora-engine-linux-cuda.tar.gz'