Repository navigation
Add book:generate rake task for print-ready 'Why Ruby?' PDF - #145
Merged
Merged
Conversation
Generates a 176×246mm hardcover-format HTML/PDF from all published testimonials, laid out 1:1 with the home carousel: red bordered quote box with a downward speech-bubble tail centered on the avatar below, gem-shaped avatars, iPad-portrait content flow. Cover shows "Why / [heart icon] / Ruby?" stacked vertically; back page credits rubycommunity.org. Renders via headless Chrome (auto-detected on macOS/Linux) — no Node/Puppeteer dependency. Featured order: Matz → DHH → Dave Thomas → Amanda Perino, then default. Excludes 'rubyon' at generation time. Also tightens the AI testimonial validator to reject profile blurbs, résumés, project lists, and off-topic pitches (the pattern that let rubyon's user-bio slip through as a "testimonial"). Gemfile.lock bump: brakeman 8.0.4 → 8.0.5 to satisfy pre-commit hook.
- .ruby-version: 4.0.1 → 4.0.3 - db/schema.rb: adds rails_error_dashboard_* tables from the gem's install migrations (applications, cascade_patterns, and related). - lib/tasks/production_data.rake: pass `aliases: true` to YAML.safe_load* — required now that Psych flags YAML aliases by default; needed to load config/deploy.yml and config/database.yml.
Chrome's PDF ships embedded font subsets that Affinity Publisher
can't reconstruct on import — glyphs come in as broken shapes. Fix
this at generation time by outlining all text to curves via
Ghostscript's -dNoOutputFonts (no fonts in the file = no font
problems downstream), and while we're there, satisfy the rest of
the printshop spec:
• RGB → CMYK via Fogra39-family output intent when the ECI
ICC profile is under vendor/icc/, else gs's default_cmyk.icc
• PDF/X-1a:2001 subtype with proper OutputIntent
• /prepress preset keeps images at 300 DPI
• Even page count (blank leaf inserted before the back cover
when the total comes out odd)
• Near-black body/subhead colors switched to #000 so they land
on K100 after CMYK conversion (grays and the red heading are
intentional and stay 4-color)
Bleeds and trim (170×240 + 3mm → 176×246 mm) were already right in
the CSS. Falls back to the raw Chrome PDF with a warning when
Ghostscript isn't installed.
Also bumps brakeman 8.0.5 → 8.0.6 to satisfy the pre-commit hook.
Fogra51 is ECI's current recommended default (models optical-brightener paper stocks accurately, per ISO 12647-2:2013). Fogra39 stays as a fallback for shops that still calibrate against ISO Coated v2. Also derive the PDF/X-1a OutputConditionIdentifier and Info strings from the actual embedded profile so metadata stays consistent (an embedded Fogra51 profile no longer gets tagged as FOGRA39). Drops both ECI profiles into vendor/icc/ so the pipeline is reproducible without a manual download. Both are redistributable under their respective ECI licenses.
The default order sorted non-featured entries in reverse creation order, which made the back half of the book skew towards whichever month people signed up. Shuffle them so readers get a mix instead. Featured testimonials (Matz → DHH → Dave Thomas → Amanda Perino) still lead the sequence in their fixed order.
GitHub's GraphQL API returns "" (not nil) for users without a bio, so `profile_data[:bio] || user.bio` was overwriting existing bios with empty strings. Use `.presence` to fall back on blank values in both the OAuth and batch GraphQL sync paths.
The same model_id exists once per provider (gpt-4.1-nano is present as both azure and openai), so `Model.find_by(model_id:)` returned whichever row came first. When that was the unconfigured azure row, every call raised RubyLLM::ConfigurationError at request time — silently breaking post summaries and testimonial generation in development. Add `Model.resolve`, which prefers a provider that is actually configured and falls back to the plain lookup, and use it at the AI call sites.
Three published testimonials were advertising rather than saying why their author loves Ruby: two carried links and a call to action, one was a profile bio. The book generator had grown a hardcoded EXCLUDED_USERNAMES entry to paper over the third. Add Testimonial::Screenable, a deterministic check that runs as a validation before any AI call, rejecting links, bare domains, emails, @Handles and pitch phrasing with feedback the author sees on the form. Checked against all 225 existing quotes it flags exactly those three and nothing else. Behind it, the LLM validator prompt gains explicit rules and few-shot examples in both directions, so a short but genuine quote still gets published. Stop truncating quotes. `maxlength: 320` on the textarea meant a longer paste was silently cut in the browser and the server never saw the missing words, so no validation error could fire — four stored quotes sit at exactly 320 characters, three of them ending mid-sentence. The 140-320 range now lives only in the model, where going over is a visible error with the text intact. System writes are exempt so a faithful translation is never trimmed or padded to fit, and the book steps quote type down at 360/460/560 characters rather than overflowing the page. Add Testimonial::AiTranslatable so a quote written in another language is translated to English before the heading and body are generated from it. The author's own words are kept in quote_original alongside quote_language; nothing is overwritten. Also stop the generator naming the author in the third person — eleven bodies had drifted into "Michael's journey" and "developers like Joe" while the other 110 stayed impersonal. New rake tasks for running this against a live database: testimonials:screen list published quotes that trip the screen testimonials:reject[username,reason] unpublish and tell the author why testimonials:publish[username] undo testimonials:translate[username] backfill translations, keeping originals testimonials:regenerate[username] rewrite AI fields from the current quote testimonials:rewrite[username,quote] replace a quote and regenerate
CARTO now requires an API key for raster basemaps. Keyless tiles still return HTTP 200, but come back with an "API KEY REQUIRED" watermark rendered into the PNG, which is what shows on the community map today. Store the key as a setting rather than a credential so it can be rotated from /madmin/settings without a deploy, and append it to the tile URL as ?key= (CARTO ignores ?api_key= silently, watermark and all). The map degrades to the current watermarked behaviour when no key is set, so this is safe to deploy before the key is entered. Claude-Session: https://claude.ai/code/session_01WEn1AgMSTixg1FMwtavvpV
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
book:generate— renders all published testimonials into a 176×246 mm hardcover-format single-file HTML attmp/why_ruby_book.html, then prints it totmp/why_ruby_book.pdfvia headless Chrome (auto-detected on macOS/Linux, no Node/Puppeteer). Layout is a 1:1 port of the home carousel: red bordered quote box with a downward speech-bubble tail centered on the avatar below, gem-shaped avatars, iPad-portrait content flow. Cover showsWhy / [heart icon] / Ruby?stacked vertically; back page creditsrubycommunity.org. Featured order: Matz → DHH → Dave Thomas → Amanda Perino, then default;rubyonis excluded at generation time (kept in DB so the author can still edit and resubmit on the site).Testimonial::AiValidatable) to reject profile blurbs, résumés, project lists, and off-topic pitches — the pattern that let rubyon's user-bio slip through as a "testimonial"..ruby-version4.0.1 → 4.0.3;db/schema.rbgains therails_error_dashboard_*install tables;production_data.rakepassesaliases: truetoYAML.safe_load*(required by the newer Psych default).Gemfile.lockbump forbrakeman8.0.4 → 8.0.5 (pre-commit hook requires latest).Test plan
bundle exec rake book:generatesucceeds and produces bothtmp/why_ruby_book.htmlandtmp/why_ruby_book.pdf.Why / ❤️ / Ruby?; pages 3–6 are Matz → DHH → Dave Thomas → Amanda Perino in that order.rubyonappears anywhere in the book.namefall back tousername).rubycommunity.org.reject_reason: "quote"and feedback that asks for a real testimonial.