ernestdefoe / postcards
Postcards: the discussion list as cards. The first picture or video of each discussion on the front, the author's avatar over it, an excerpt and the counts below. Grid, masonry or wide, per tag, with uploaded tag covers and a built-in view counter.
Package info
github.com/ernestdefoe/postcards
Type:flarum-extension
pkg:composer/ernestdefoe/postcards
Fund package maintenance!
Requires
- php: ^8.3
- flarum/core: ^2.0
- intervention/image: ^3.0
Requires (Dev)
- ernestdefoe/marquee: ^1.20
- ernestdefoe/spoiler-shield: ^1.1
- flarum/approval: ^2.0
- flarum/markdown: ^2.0
- flarum/phpstan: ^2.0
- flarum/tags: ^2.0
- flarum/testing: ^2.0
- fof/upload: ^2.0
- laravel/pint: ^1.32
- phpstan/phpstan-strict-rules: ^2.0
Suggests
- ernestdefoe/broadsheet: Postcards steps aside on Broadsheet, which draws its own front page.
- ernestdefoe/cascade: Postcards steps aside on Cascade, which draws its own feed.
- ernestdefoe/marquee: A discussion linked to a movie, show, game, book or album shows the title's poster or backdrop on its card.
- ernestdefoe/scribe: Videos embedded with Scribe show their thumbnail.
- ernestdefoe/studio: Postcards steps aside on Studio, which draws its own gallery.
- ernestdefoe/tag-covers: A tag's Tag Covers banner is used for its discussions when Postcards has no cover for that tag.
- ernestdefoe/warren: Postcards steps aside on Warren, which draws its own rows.
- flarum/tags: Cards per tag, tag colours on cards without a picture, and an uploaded cover image per tag.
- fof/discussion-views: Cards show its view count instead of Postcards' own.
- fof/upload: Pictures uploaded with fof/upload become covers.
- michaelbelgium/flarum-discussion-views: Cards show its view count instead of Postcards' own.
Provides
None
Conflicts
- ernestdefoe/marquee: <1.26.4
Replaces
None
README
The discussion list as cards. Each discussion's first picture or video is on the front, with the author's avatar sitting on its edge. Below it are the title, tags, a short excerpt, and the reply and view counts.
Free, MIT, for Flarum 2.
What it does
- Three layouts:
- Masonry (the default) keeps each picture's own shape.
- Grid gives every card the same shape.
- Wide puts one card on each row, with the picture on the left.
- Phones always get one column with compact covers.
- The cover is the first picture or video of the first post:
- a picture in the post, or one uploaded with fof/upload;
- a YouTube video shows its thumbnail and a play badge. Nothing is fetched to make it.
- a discussion linked to a movie, show, game, book or album with Marquee shows that title's poster (or its wide backdrop on phones, Grid and Wide), ahead of a picture in the post.
- A picture inside a spoiler is never used, and neither is spoiler text in the excerpt.
- Tag covers: upload a cover for any tag. Choose whether it's used only when a discussion has no picture or video of its own, or always, instead of the post's.
- There's also a forum-wide default cover.
- If there's no cover at all, the card shows its tag's color and the first letter of the title. A card never shows a broken image.
- Per tag: turn cards on or off for a tag, and pick its layout.
- Members choose: a button above the list switches between cards and the classic list. The choice is remembered for each member. Admins can turn the button off.
- View counts built in. Each viewer counts once per discussion per half hour, crawlers and the author don't count, and no IP address is stored.
- If FoF Discussion Views or michaelbelgium's Discussion Views is enabled, cards show its count and Postcards' own counter stops.
- Admin → Tools can import their totals.
- A lead card, if you want one: the first sticky discussion, or simply the first, spans the full width.
- Works with themes and other extensions:
- Cards follow your colors and dark mode.
- Badges, tags and what other extensions add to the list (best answer, polls…) show on the cards.
- Postcards steps aside on themes that draw their own list (Cascade, Studio, Broadsheet and Warren).
How it stays light
- The cover and excerpt are picked once, when the first post is saved, and stored. Reading the list parses nothing and costs one extra query per page, whatever the number of discussions.
- There are no image copies to generate and nothing to regenerate after you install it. Pictures load lazily at their real size.
- The forum script is about 3.5 KB gzipped.
Install
composer require ernestdefoe/postcards php flarum migrate php flarum cache:clear
Enable it in the admin panel. Existing discussions get their covers in the background, 200 at a time.
On a big board, you can also run:
php flarum postcards:rebuild
The view counter forgets who viewed what after an hour, with a scheduled task. Make sure Flarum's scheduler runs (a cron entry for php flarum schedule:run).
Support
Questions and bug reports: ernestdefoe.online.
If Postcards is useful to you, you can buy me a coffee.
