Skip to content

Conversation

@solomonshalom
Copy link

Summary

This PR adds the ability to publish freewrite entries directly to Bublr.life as blog posts. Users can now share their writing with the world without leaving the app.

What's New

  • "Publish" button added to the bottom navigation bar
  • One-time API key setup - users get their key from bublr.life/docs and paste it in
  • Two publishing options: "Publish Now" (public post) or "Save as Draft" (private)
  • Post preview showing extracted title and word count before publishing
  • Direct link to view the published post at bublr.life/@username/slug

User Flow

  1. First time setup: Click Publish → Enter API key → Save
  2. Publishing: Click Publish → Review title/word count → Choose "Publish Now" or "Save as Draft"
  3. Success: See checkmark and "View Post" button to open in browser
  4. Errors: Clear error messages with "Try Again" option

Screenshots

The UI matches the existing app design:

  • Same button style as other nav items
  • Same popover pattern as the "Chat" menu
  • Same hover effects and color scheme

Technical Details

API Integration:

  • GET /api/v1/profile - Fetches username for post URLs
  • POST /api/v1/posts - Creates the blog post

Validation:

  • API key must start with bublr_sk_
  • Title auto-extracted from first line (max 200 chars)
  • Excerpt auto-generated (first 500 chars)
  • Content limit: 500KB

Error Handling:

HTTP Code User Message
401 Invalid API key
404 User profile not found
429 Rate limited
400 Validation error (shown from API)
500+ Server error

Storage:

  • API key stored in UserDefaults (sandboxed, persists across sessions)
  • Username cached to avoid repeated profile fetches

Code Changes

  • freewrite/ContentView.swift: +453 lines
    • Added PublishStatus enum and Bublr API structs
    • Added 5 new @State variables for publish flow
    • Added "Publish" button with popover
    • Added publishPopoverContent() and publishIdleView() view builders
    • Added fetchBublrUsername() and publishToBublr() network functions
    • Added extractBlogTitle() helper

justice-rest and others added 2 commits December 9, 2025 22:14
Add the ability to publish freewrite entries directly to Bublr.life as blog posts.

## Features

- **Publish button** in bottom nav bar (between "New Entry" and theme toggle)
- **API key management**: Users enter their Bublr API key once, stored securely in UserDefaults
- **Publish options**: "Publish Now" (public) or "Save as Draft" (private)
- **Post URL**: Opens published posts at bublr.life/@username/slug

## User Flow

1. Click "Publish" → Enter API key (get from bublr.life/docs) → Save
2. Click "Publish" → See title preview & word count → Choose publish option
3. Success → "View Post" button opens the published blog post

## Technical Details

- API key validation (must start with `bublr_sk_`)
- Username fetched from /api/v1/profile and cached
- POST to /api/v1/posts with title, content, excerpt, published flag
- Full error handling: 401 (invalid key), 404 (user not found), 429 (rate limit), 400 (validation), 500+ (server error)
- Content validation: 200 char title limit, 500 char excerpt, 500KB content max
- Matches existing UI patterns (hover effects, popover style, colors)

## Files Changed

- freewrite/ContentView.swift: +453 lines

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
feat: Add Bublr blog publishing integration
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants