This uses two files saved on my Mac as
– 3-1-2025-get_random_post.php
AND
– 3-1-2025-tomeri-random-posts.html
These are saved in the folder Claude-File-backups
The Claude-generated summary of the work is as follows:
Blog Sampler Page for tomeri.org – Implementation Summary
Overview
Created a web page that displays random excerpts from four WordPress blogs (journal, essays, notes, and words) in a 2×2 grid layout. The page includes both client-side JavaScript and a PHP backend script to fetch and format content.
Files Created
1. Frontend (HTML/CSS/JavaScript)
- File:
tomeri-random-posts.html
- Purpose: Main web page that displays the blog excerpts in a grid
2. Backend (PHP)
- File:
get_random_post.php
- Purpose: API endpoint that fetches random content from WordPress blogs
Key Features
Visual Design
- 2×2 grid layout (2 columns on desktop, 1 column on mobile)
- Blog headers with blue background matching button color
- Excerpt content with properly formatted text and headers
- “Read full post” button styled as a compact, left-aligned button
- “Refresh Sample” button that updates individual blog cards
- Responsive design for different screen sizes
Excerpt Content Rules
- Shows excerpts limited to either 125 words or 12 lines, whichever comes first
- Displays headers in a special format with spacing above and below
- Removes date information and any “Thomas Erickson” mentions
- Shows “views” lines with special formatting
- Adds ellipsis (…) to indicate truncated content
Technical Implementation
- Uses WordPress REST API to fetch random posts and pages
- Fetches content from the last 2 years only
- Shows post creation date or page modification date with appropriate labeling
- Displays thumbnails when available
- Handles error states with appropriate messaging
Implementation Notes
- The PHP script handles:
- Validating blog selection (journal, essays, notes, words)
- Filtering content by date (last 2 years)
- Extracting and formatting excerpts according to content rules
- Fetching and providing thumbnail images
- Returning properly formatted JSON responses
- The JavaScript handles:
- Creating the 2×2 grid layout
- Making AJAX requests to the PHP endpoint
- Displaying formatted content with proper styling
- Managing refresh functionality for each blog card
- Handling loading states and error conditions
- The CSS provides:
- Consistent color scheme using CSS variables
- Card-based layout with subtle animations
- Special styling for headers and content elements
- Responsive design breakpoints for mobile
- Button styling with hover and active states
This implementation ensures users can discover random content from across tomeri’s blogs in a clean, readable format, with the ability to refresh samples and click through to read full posts.
Views: 0