Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 29 additions & 4 deletions app.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,20 @@
/* PostPilot generator page logic */
(() => {
const $ = (id) => document.getElementById(id);

// Sample transcripts by topic - opinionated notes the AI can learn a voice from
const SAMPLES = {
ai: `Everyone wants to bolt AI onto their product, but most of it is theater. I'd rather ship one AI feature that quietly saves users thirty seconds than five that feel like managing a junior intern. The gap between a demo that wows in a meeting and something that survives real users on a stressed Tuesday morning is enormous. If it doesn't move activation, rip it out. No sacred AI cows.`,
economics: `Everyone's watching the Fed like it's the only thing that matters, but the real story is in small business credit. When local businesses can't borrow affordably, hiring freezes long before the headlines catch up. I think we pay too much attention to the stock market and too little to Main Street indicators. GDP numbers hide more than they reveal about how regular people are actually doing.`,
startups: `Most startups don't die from competition, they die from building something nobody asked for. Talk to twenty customers before you write a line of code. I'm also convinced raising too much money too early kills more companies than raising too little - constraints force focus. Revenue is the only validation that matters. Everything else is applause.`,
marketing: `Brand isn't your logo, it's what people say about you when you're not in the room. Most companies pump out content nobody reads instead of making one thing people actually share. I believe boring industries are the biggest branding opportunity - if everyone in your category sounds the same, sounding human is a superpower. Metrics without a story are just noise.`,
careers: `Job descriptions asking for five years of experience in a three-year-old technology tell you everything about broken hiring. I believe skills beat credentials, and portfolios beat resumes. The best career moves I've seen came from people who built things in public instead of quietly applying to hundreds of roles. Networking isn't schmoozing - it's being useful to people before you need them.`,
leadership: `The best managers I've had did less, not more - fewer meetings, clearer priorities, faster decisions. Micromanagement is fear wearing a productivity costume. I think most companies promote their best individual contributors into management and lose twice: a great builder gone, a mediocre manager gained. Trust is the only real productivity hack.`,
finance: `Budgeting apps don't fix spending problems any more than scales fix eating problems - behavior beats tools every time. I think the personal finance industry profits from complexity, when the winning strategy fits on an index card: spend less than you earn, automate savings, buy boring index funds, wait. The hardest part isn't knowledge, it's patience.`,
health: `We treat sleep like a luxury and then wonder why burnout is everywhere. I'm convinced most workplace wellness programs are box-ticking - a meditation app subscription doesn't fix a culture of 9pm emails. Walking meetings, actual lunch breaks, and respecting time off would do more than any perk. Health isn't a productivity hack, it's the foundation everything else sits on.`,
climate: `Sustainability theater drives me crazy - companies celebrating paper straws while their supply chain burns coal. Real climate progress is boring: better insulation, efficient logistics, cleaner grids. I think the biggest lever isn't individual guilt, it's procurement - when big buyers demand cleaner suppliers, whole industries move. Progress beats purity.`,
realestate: `Everyone asks when to buy like there's a magic date, but the honest answer is: when your life needs it and the math works. Rent versus buy isn't a moral question. I think we massively underbuild housing and then act shocked at prices - zoning reform would do more for affordability than any first-time-buyer subsidy. Location risk is the most underpriced factor in real estate.`,
};
const btn = $("generate-btn");
const progress = $("progress");
const progressText = $("progress-text");
Expand Down Expand Up @@ -201,12 +215,24 @@
}, 1200);
}

// Topic dropdown fills the notes box with an editable sample
$("sample-topic").addEventListener("change", () => {
const key = $("sample-topic").value;
if (!key) return;
const box = $("transcript");
if (box.value.trim() &&
!confirm("Replace your current notes with the sample?")) {
$("sample-topic").value = "";
return;
}
box.value = SAMPLES[key] || "";
});

btn.addEventListener("click", async () => {
setError("");
const transcript = $("transcript").value.trim();
const useSample = $("use-sample").checked;
if (!transcript && !useSample) {
setError("Paste a transcript or check “Use built-in sample transcript”.");
if (!transcript) {
setError("Paste some notes, or pick a sample topic from the dropdown.");
return;
}
setBusy(true);
Expand All @@ -217,7 +243,6 @@
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
transcript,
use_sample: useSample,
tone: $("tone").value,
word_min: Math.max(0, Math.min(3000, parseInt($("wordmin").value, 10) || 100)),
word_max: Math.max(0, Math.min(3000, parseInt($("wordmax").value, 10) || 200)),
Expand Down
38 changes: 31 additions & 7 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,21 @@ def _serialize_draft(text, topic, img, draft_id):
return d


def _resolve_url(url):
"""Follow Google News redirect links to the real article URL."""
if not url or "news.google.com" not in url:
return url
try:
r = requests.get(url, timeout=10, allow_redirects=True,
headers={"User-Agent": "Mozilla/5.0"})
final = r.url
if final and "news.google.com" not in final:
return final
except Exception:
pass
return url


def _append_source(text, url):
"""Add the source article link to the post text, just above the hashtags."""
if not url:
Expand All @@ -168,7 +183,7 @@ def _append_source(text, url):
def _rank_topics_for_voice(content, voice, transcript_text, n):
"""Boost the weight of news signals most relevant to the user's
themes/opinions so select_topics() favors them over generic top headlines."""
primaries = [s for s in content if s.kind in ("ai_news", "arxiv")] or list(content)
primaries = [s for s in content if s.kind in ("ai_news", "arxiv", "news")] or list(content)
if len(primaries) <= n:
return
interests = "; ".join((voice.themes or []) + (voice.opinions or []))
Expand Down Expand Up @@ -212,12 +227,20 @@ def _rank_topics_for_voice(content, voice, transcript_text, n):

def _run_job(job_id, settings, transcript_text):
try:
_job_update(job_id, progress="Gathering live AI news...")
content, voice_signals = g.gather_signals(settings, transcript_text)
_job_update(job_id, progress="Reading your notes...")
queries = []
try:
queries = g.derive_search_queries(transcript_text)
except Exception as e:
print(f" [warn] could not derive topics ({e}).")

_job_update(job_id, progress="Gathering live news about your topics...")
content, voice_signals = g.gather_signals(settings, transcript_text,
queries=queries or None)
if not content:
_job_update(job_id, status="error",
error="No news signals found. Check the server's internet "
"connection and that feedparser is installed.")
error="No news found for your topics in this lookback "
"window. Try a longer lookback or broader notes.")
return

_job_update(job_id, progress="Building your voice profile...")
Expand All @@ -235,6 +258,7 @@ def _run_job(job_id, settings, transcript_text):
used_images = set()
for i, topic in enumerate(topics, 1):
_job_update(job_id, progress=f"Writing variant {i} of {len(topics)}...")
topic.primary.url = _resolve_url(topic.primary.url)
text = g.format_post(g.generate_post(topic, voice, settings),
max_chars=getattr(settings, "max_chars", 2900))
text = _append_source(text, topic.primary.url)
Expand Down Expand Up @@ -321,8 +345,8 @@ def _wc(key, default):
lookback = max(1, min(24 * 365 * 10, lb_value * unit_hours[unit]))

transcript = (data.get("transcript") or "").strip()
if data.get("use_sample"):
transcript = g.SAMPLE_TRANSCRIPT
if not transcript:
return jsonify({"error": "Paste a transcript or some notes first."}), 400
settings = g.Settings(tone=tone, length=length_key, variants=variants,
news_lookback_hours=lookback,
max_news_items=12,
Expand Down
29 changes: 22 additions & 7 deletions generator.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Generator — PostPilot</title>
<link rel="icon" href="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Crect width='100' height='100' rx='22' fill='%234f8ff7'/%3E%3Ctext x='50' y='72' font-size='62' font-weight='bold' font-family='Arial' fill='white' text-anchor='middle'%3EP%3C/text%3E%3C/svg%3E">
<link rel="stylesheet" href="/styles.css">
</head>
<body>
Expand All @@ -13,10 +14,11 @@
<div class="nav-links">
<a href="/#features">Features</a>
<a href="/#how">How it works</a>
<a href="/#examples">Examples</a>
<a class="active" href="/app">Generator</a>
<a href="/library">Library</a>
<span id="llm-badge" class="badge">checking…</span>
<button id="li-connect" class="btn btn-ghost btn-sm" style="display:none">Connect LinkedIn</button>
<button id="li-connect" class="btn btn-ghost btn-sm">Connect LinkedIn</button>
</div>
</nav>

Expand All @@ -27,13 +29,26 @@ <h2>Settings</h2>

<div class="field">
<label for="transcript">Your transcript or notes</label>
<textarea id="transcript" placeholder="Paste a meeting transcript, voice memo, or notes written in your own words…"></textarea>
<div class="hint">Used to learn your voice. Leave empty and check the box below to try the built-in sample.</div>
<textarea id="transcript" placeholder="Paste a meeting transcript, voice memo, or notes written in your own words — any topic…"></textarea>
<div class="hint">Used to learn your voice and find news about your topics.</div>
</div>

<div class="checkbox-row">
<input type="checkbox" id="use-sample">
<label for="use-sample">Use built-in sample transcript</label>
<div class="field">
<label for="sample-topic">Or try a sample transcript</label>
<select id="sample-topic">
<option value="" selected>Choose a topic…</option>
<option value="ai">AI &amp; Technology</option>
<option value="economics">Economics &amp; Markets</option>
<option value="startups">Entrepreneurship &amp; Startups</option>
<option value="marketing">Marketing &amp; Branding</option>
<option value="careers">Careers &amp; Hiring</option>
<option value="leadership">Leadership &amp; Management</option>
<option value="finance">Personal Finance</option>
<option value="health">Health &amp; Wellness</option>
<option value="climate">Sustainability &amp; Climate</option>
<option value="realestate">Real Estate</option>
</select>
<div class="hint">Fills the notes box with sample opinions on that topic — edit freely.</div>
</div>

<div class="field">
Expand Down Expand Up @@ -102,7 +117,7 @@ <h2>Settings</h2>

<div id="empty-state" class="panel" style="text-align:center; color:var(--muted);">
Your generated posts will appear here.<br>
Paste a transcript (or use the sample) and hit <strong style="color:var(--text)">Generate posts</strong>.
Paste your notes (or pick a sample topic) and hit <strong style="color:var(--text)">Generate posts</strong>.
</div>
</div>
</div>
Expand Down
Loading
Loading