diff --git a/CHANGELOG.md b/CHANGELOG.md index ad52a3d8..f6145f8a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ What changed for forums running Jtech Tools. Newest first. **New** +- JTech theme: logos on @handles. A mention of @claude, @chatgpt, @microsoft, @jtechforums, @groupme, @24six, @zing, @naki and the rest of the list (22 in all) is a chip with that brand's logo after the name, like a mention of an account, in posts and the composer's preview, whether or not the account exists. Setting: `handle_logos`. - Dumbcourse: what staff can do on the full site. A topic's Options has everything in Discourse's topic admin menu (pin in its category or globally until a date, banner, private message or public topic, topic timers, change timestamp, reset bump date, topic slow mode, delete permanently, alongside close, archive, unlist and delete), changing the category and tags, publishing a shared draft, nested or flat replies, and Moderator tools' footer message, reply approval, staff note and reply checklist. Select posts moves them to a new or existing topic or message, merges, changes owner or deletes. A post's actions have Discourse's post admin menu (staff colour, notice, unhide, change owner, grant badge, lock, wiki, rebuild HTML, delete permanently, publish as a page, pin in nested replies), whispers (staff only, or to a member, group or badge's holders), pin to the bottom, and its edit history for anyone, with revert and hiding an edit for staff. A Moderate button on a member's profile has the admin user page's actions: suspend, silence, slow mode, warning, trust level, roles, title, username, email, approval, activation, staff notes, badges, groups and primary group, IP lookup and deleting the other accounts on it, logs, penalty history, bounce score, sign-in accounts, impersonation, merge, anonymize and delete. The review queue gets every filter the full site has, claiming, flag details, reviewer notes, history, DSA classification, editing a queued post, the post's fate with a suspension, and flag reason priorities for admins, and shows each item's actions again. Each shows where Discourse shows it, with times picked from a short list or typed as a date. - Moderator tools: slow mode for one user. From a user's admin page, staff can let them post one reply or new topic every so often (1 minute to a week apart), for a day, a week, a month, until a date or until lifted, with a reason. The user gets a message saying so, and their composer says how often they can post and how long until the next one; a post that's too soon is turned away with how long to wait, on the full site and in Dumbcourse. Personal messages and edits aren't limited, and a post waiting for approval holds them until it's reviewed. Staff can't be put in slow mode. Settings: `mod_user_slow_mode_enabled`, `mod_user_slow_mode_moderators`. - Mod elections: the results post shows the whole count, so anyone can see it was honest: everyone's first-choice votes and share as a bar chart, what each stage did, where everyone finished, how ties were settled, and every stage in numbers. Never who ranked whom. Elections already published get it too: their results post is updated in place without bumping the topic, or added if there's none. diff --git a/docs/development/jtech-theme.md b/docs/development/jtech-theme.md index f9454175..6b0c6279 100644 --- a/docs/development/jtech-theme.md +++ b/docs/development/jtech-theme.md @@ -148,6 +148,7 @@ Paths are inside `themes/jtech/`; the TypeScript is under `javascripts/discourse | `stylesheets/jt-gate.scss` (right-to-left) | the browse arrow's hover nudge is a `translate` (core mirrors the arrow with a transform in right-to-left), with an `html.rtl` override since the right-to-left stylesheet doesn't flip `translate` | | `stylesheets/jt-tabs.scss` | the selected tab everywhere core's nav style is used: core's underline at 1px (`--d-nav-underline-height` in jt-tokens) with a glow, and a faint radial light behind the label, both mixed from the text colour; jtech-tools' REQ-PM tabs (`.reqpm-tabs`) take the same nav colours, weight and line, and their strip scrolls without a scrollbar, fading at whichever edge is cut off (jt-topic-list's `jt-tabs-fade` scroll-driven animation, its duration held at `auto` against blanket `animation-duration: 0s !important` rules such as the test suite's); a tab's focus ring is drawn inside it, since the scrolling strip clips. The strips' fades (this and the list's tabs) take their direction from `--jt-tabs-fade-to`, `to left` under `html.rtl`: core's right-to-left stylesheet doesn't turn gradients round | | `stylesheets/jt-topic-list.scss` + `api-initializers/jt-compact-nav.ts` | desktop list controls: the tabs are one dropdown (core's `navigation-bar-dropdown-mode`, as Discourse's Compact Nav component sets), sharing a line with New Topic; when the row doesn't fit the filters move up a line; New Topic icon-only below 66rem | +| `lib/jt-handle-logos.ts` + `api-initializers/jt-handle-logos.ts` + `stylesheets/jt-handles.scss` + `assets/handles/` | a logo after mentions of the listed handles (setting `handle_logos`, `decorateCookedElement`): core's `a.mention` (an account; the name from its `/u/` path, as core can put a status emoji in its text) and `span.mention` (no account) get a `.jt-handle-logo` with `data-jt-handle` after the name, where core puts a status emoji, and the span gets core's `a.mention` chip; the stylesheet gives each its asset (`$handle-`, registered in `about.json`). Each logo is a 24 by 24 SVG: the brand's colour and mark (Simple Icons, LobeHub's icons for ChatGPT, the brands' own icons for JTech, GroupMe, 24six, Zing and Naki), drawn round. A new handle goes in all four | | `api-initializers/jt-external-links.ts` | ↗ on outbound links in posts (`decorateCookedElement`) | | `stylesheets/jt-topic-list.scss` (tabs) | every `.nav-pills` tab, link or button (the search page's Posts / Categories & tags / Users are buttons), at weight 500 with its focus ring drawn inside, since tab rows scroll and clip | | `stylesheets/jt-leaderboard.scss`, `jt-components.scss` | restyles for gamification, Gated Topics, Category Boxes, admin | diff --git a/docs/features/jtech-theme.md b/docs/features/jtech-theme.md index 8593071d..bec90b6f 100644 --- a/docs/features/jtech-theme.md +++ b/docs/features/jtech-theme.md @@ -15,6 +15,7 @@ What it adds on top of a restyle: - The **tags page** as chips with their counts, instead of columns of "name x 190". - **Reactions in a row** (with the Reactions plugin, setting `reaction_rollout`): the heart likes a post when clicked, and pointing at it rolls the reactions out sideways in the post's menu, pushing what's beside it along, instead of a box over the post. It slides open to as many whole reactions as there's room for, and slides shut again when the pointer leaves. A row that doesn't fit scrolls (the mouse wheel glides along it, and while pointing at the row never scrolls the page, even at its ends) and fades at an edge with more to scroll to. On phones a button beside the heart opens it with a tap; while it's open the menu's other buttons but Reply step aside. Under a Discourse palette the plugin's own picker shows, as in stock Discourse. - **A post's buttons on one line on phones**: what doesn't fit beside the reactions goes into ⋯, which opens a list of them, named, from the bottom of the screen. +- **Logos on @handles** (setting `handle_logos`): a mention of @claude, @chatgpt, @anthropic, @microsoft, @apple, @meta, @samsung, @nvidia, @intel, @tesla, @spacex, @jtechforums, @groupme, @github, @discourse, @linux, @android, @24six, @zing, @naki, @cloudflare, @python is a chip with that brand's logo after the name, in posts and the preview, like a mention of an account. The account doesn't have to exist; make one with that username if the mention should link somewhere. - An overlay page scrollbar, a back-to-top button, reading progress, language labels on code blocks, category icons on the categories page. Each of those has its own switch in the theme's settings. diff --git a/spec/system/jtech_theme_part3_spec.rb b/spec/system/jtech_theme_part3_spec.rb index 63b44957..1a092f1a 100644 --- a/spec/system/jtech_theme_part3_spec.rb +++ b/spec/system/jtech_theme_part3_spec.rb @@ -1252,6 +1252,28 @@ def header_glyphs(skip: ".current-user") expect(page).to have_no_css(".post-action-menu__jt-print") end + it "puts a brand's logo before a mention of its handle" do + Fabricate(:user, username: "claude") + post = + Fabricate(:post, topic: topic, user: member, raw: "Asked @claude, @groupme and @somebody.") + visit("#{topic.relative_url}/#{post.post_number}") + at = "#post_#{post.post_number} .cooked" + expect(page).to have_css("#{at} a.mention.jt-handle .jt-handle-logo[data-jt-handle='claude']") + expect(page).to have_css( + "#{at} span.mention.jt-handle .jt-handle-logo[data-jt-handle='groupme']", + ) + expect(page).to have_css("#{at} .mention:not(.jt-handle)", text: "@somebody") + image = page.evaluate_script(<<~JS) + getComputedStyle(document.querySelector("#{at} .jt-handle-logo")).backgroundImage + JS + expect(image).to start_with("url(") + chip = page.evaluate_script(<<~JS) + getComputedStyle(document.querySelector("#{at} span.mention.jt-handle")).display + JS + expect(chip).to eq("inline-block") + expect_no_theme_errors + end + it "shows the listed badges after a poster's name" do badge = Fabricate(:badge, name: "Phone Distributor", icon: "certificate") BadgeGranter.grant(badge, member) diff --git a/themes/jtech/about.json b/themes/jtech/about.json index 0ad983d0..514d6273 100644 --- a/themes/jtech/about.json +++ b/themes/jtech/about.json @@ -10,7 +10,29 @@ "assets": { "geist": "assets/Geist-Variable.woff2", "geist-mono": "assets/GeistMono-Variable.woff2", - "icons-sprite": "assets/icons-sprite.svg" + "icons-sprite": "assets/icons-sprite.svg", + "handle-claude": "assets/handles/claude.svg", + "handle-chatgpt": "assets/handles/chatgpt.svg", + "handle-anthropic": "assets/handles/anthropic.svg", + "handle-microsoft": "assets/handles/microsoft.svg", + "handle-apple": "assets/handles/apple.svg", + "handle-meta": "assets/handles/meta.svg", + "handle-samsung": "assets/handles/samsung.svg", + "handle-nvidia": "assets/handles/nvidia.svg", + "handle-intel": "assets/handles/intel.svg", + "handle-tesla": "assets/handles/tesla.svg", + "handle-spacex": "assets/handles/spacex.svg", + "handle-jtechforums": "assets/handles/jtechforums.svg", + "handle-groupme": "assets/handles/groupme.svg", + "handle-github": "assets/handles/github.svg", + "handle-discourse": "assets/handles/discourse.svg", + "handle-linux": "assets/handles/linux.svg", + "handle-android": "assets/handles/android.svg", + "handle-24six": "assets/handles/24six.svg", + "handle-zing": "assets/handles/zing.svg", + "handle-naki": "assets/handles/naki.svg", + "handle-cloudflare": "assets/handles/cloudflare.svg", + "handle-python": "assets/handles/python.svg" }, "color_schemes": { "JTech Light": { diff --git a/themes/jtech/assets/handles/24six.svg b/themes/jtech/assets/handles/24six.svg new file mode 100644 index 00000000..e4749c57 --- /dev/null +++ b/themes/jtech/assets/handles/24six.svg @@ -0,0 +1 @@ + diff --git a/themes/jtech/assets/handles/android.svg b/themes/jtech/assets/handles/android.svg new file mode 100644 index 00000000..6c01cda9 --- /dev/null +++ b/themes/jtech/assets/handles/android.svg @@ -0,0 +1 @@ + diff --git a/themes/jtech/assets/handles/anthropic.svg b/themes/jtech/assets/handles/anthropic.svg new file mode 100644 index 00000000..28050f42 --- /dev/null +++ b/themes/jtech/assets/handles/anthropic.svg @@ -0,0 +1 @@ + diff --git a/themes/jtech/assets/handles/apple.svg b/themes/jtech/assets/handles/apple.svg new file mode 100644 index 00000000..665f6170 --- /dev/null +++ b/themes/jtech/assets/handles/apple.svg @@ -0,0 +1 @@ + diff --git a/themes/jtech/assets/handles/chatgpt.svg b/themes/jtech/assets/handles/chatgpt.svg new file mode 100644 index 00000000..010fc7fc --- /dev/null +++ b/themes/jtech/assets/handles/chatgpt.svg @@ -0,0 +1 @@ + diff --git a/themes/jtech/assets/handles/claude.svg b/themes/jtech/assets/handles/claude.svg new file mode 100644 index 00000000..cd0c6a78 --- /dev/null +++ b/themes/jtech/assets/handles/claude.svg @@ -0,0 +1 @@ + diff --git a/themes/jtech/assets/handles/cloudflare.svg b/themes/jtech/assets/handles/cloudflare.svg new file mode 100644 index 00000000..27e918d5 --- /dev/null +++ b/themes/jtech/assets/handles/cloudflare.svg @@ -0,0 +1 @@ + diff --git a/themes/jtech/assets/handles/discourse.svg b/themes/jtech/assets/handles/discourse.svg new file mode 100644 index 00000000..ffb9bbc0 --- /dev/null +++ b/themes/jtech/assets/handles/discourse.svg @@ -0,0 +1 @@ + diff --git a/themes/jtech/assets/handles/github.svg b/themes/jtech/assets/handles/github.svg new file mode 100644 index 00000000..c461e07e --- /dev/null +++ b/themes/jtech/assets/handles/github.svg @@ -0,0 +1 @@ + diff --git a/themes/jtech/assets/handles/groupme.svg b/themes/jtech/assets/handles/groupme.svg new file mode 100644 index 00000000..bf38b33f --- /dev/null +++ b/themes/jtech/assets/handles/groupme.svg @@ -0,0 +1 @@ + diff --git a/themes/jtech/assets/handles/intel.svg b/themes/jtech/assets/handles/intel.svg new file mode 100644 index 00000000..c288d041 --- /dev/null +++ b/themes/jtech/assets/handles/intel.svg @@ -0,0 +1 @@ + diff --git a/themes/jtech/assets/handles/jtechforums.svg b/themes/jtech/assets/handles/jtechforums.svg new file mode 100644 index 00000000..7940d7da --- /dev/null +++ b/themes/jtech/assets/handles/jtechforums.svg @@ -0,0 +1 @@ + diff --git a/themes/jtech/assets/handles/linux.svg b/themes/jtech/assets/handles/linux.svg new file mode 100644 index 00000000..fef05afa --- /dev/null +++ b/themes/jtech/assets/handles/linux.svg @@ -0,0 +1 @@ + diff --git a/themes/jtech/assets/handles/meta.svg b/themes/jtech/assets/handles/meta.svg new file mode 100644 index 00000000..2869bcb8 --- /dev/null +++ b/themes/jtech/assets/handles/meta.svg @@ -0,0 +1 @@ + diff --git a/themes/jtech/assets/handles/microsoft.svg b/themes/jtech/assets/handles/microsoft.svg new file mode 100644 index 00000000..8ff5d772 --- /dev/null +++ b/themes/jtech/assets/handles/microsoft.svg @@ -0,0 +1 @@ + diff --git a/themes/jtech/assets/handles/naki.svg b/themes/jtech/assets/handles/naki.svg new file mode 100644 index 00000000..320be619 --- /dev/null +++ b/themes/jtech/assets/handles/naki.svg @@ -0,0 +1 @@ + diff --git a/themes/jtech/assets/handles/nvidia.svg b/themes/jtech/assets/handles/nvidia.svg new file mode 100644 index 00000000..e47c6559 --- /dev/null +++ b/themes/jtech/assets/handles/nvidia.svg @@ -0,0 +1 @@ + diff --git a/themes/jtech/assets/handles/python.svg b/themes/jtech/assets/handles/python.svg new file mode 100644 index 00000000..ac5cc79e --- /dev/null +++ b/themes/jtech/assets/handles/python.svg @@ -0,0 +1 @@ + diff --git a/themes/jtech/assets/handles/samsung.svg b/themes/jtech/assets/handles/samsung.svg new file mode 100644 index 00000000..64d3b2df --- /dev/null +++ b/themes/jtech/assets/handles/samsung.svg @@ -0,0 +1 @@ + diff --git a/themes/jtech/assets/handles/spacex.svg b/themes/jtech/assets/handles/spacex.svg new file mode 100644 index 00000000..b28b906c --- /dev/null +++ b/themes/jtech/assets/handles/spacex.svg @@ -0,0 +1 @@ + diff --git a/themes/jtech/assets/handles/tesla.svg b/themes/jtech/assets/handles/tesla.svg new file mode 100644 index 00000000..a0d74bfb --- /dev/null +++ b/themes/jtech/assets/handles/tesla.svg @@ -0,0 +1 @@ + diff --git a/themes/jtech/assets/handles/zing.svg b/themes/jtech/assets/handles/zing.svg new file mode 100644 index 00000000..1801b8d9 --- /dev/null +++ b/themes/jtech/assets/handles/zing.svg @@ -0,0 +1 @@ + diff --git a/themes/jtech/common/common.scss b/themes/jtech/common/common.scss index c3abbabb..f7b093d0 100644 --- a/themes/jtech/common/common.scss +++ b/themes/jtech/common/common.scss @@ -29,6 +29,7 @@ @import "jt-review"; @import "jt-search"; @import "jt-posts"; +@import "jt-handles"; @import "jt-post-blocks"; @import "jt-topic-footer"; @import "jt-post-chrome"; diff --git a/themes/jtech/javascripts/discourse/api-initializers/jt-handle-logos.ts b/themes/jtech/javascripts/discourse/api-initializers/jt-handle-logos.ts new file mode 100644 index 00000000..745924d7 --- /dev/null +++ b/themes/jtech/javascripts/discourse/api-initializers/jt-handle-logos.ts @@ -0,0 +1,46 @@ +import { settings } from "virtual:theme"; +import { apiInitializer } from "discourse/lib/api"; +import { HANDLE_LOGOS } from "../lib/jt-handle-logos.ts"; + +// A logo after a mention of one of lib/jt-handle-logos' handles (setting +// handle_logos), in posts and the composer's preview. Core cooks a mention +// of an account as a link to /u/ and of a name nobody has as a span; +// both get it, so it works whether or not the account exists. The link's +// path gives the name, since core can add a status emoji to its text. +function handleOf(mention: HTMLElement): string { + const fromPath = + mention instanceof HTMLAnchorElement + ? /\/u\/([^/?#]+)/.exec(mention.pathname)?.[1] + : undefined; + const name = fromPath + ? decodeURIComponent(fromPath) + : (mention.textContent ?? "").trim().replace(/^@/, ""); + return name.toLowerCase(); +} + +export default apiInitializer((api) => { + if (!settings.handle_logos) { + return; + } + + api.decorateCookedElement( + (element: HTMLElement) => { + for (const mention of element.querySelectorAll(".mention")) { + const handle = handleOf(mention); + if ( + !HANDLE_LOGOS.has(handle) || + mention.querySelector(".jt-handle-logo") + ) { + continue; + } + const logo = document.createElement("span"); + logo.className = "jt-handle-logo"; + logo.dataset.jtHandle = handle; + logo.setAttribute("aria-hidden", "true"); + mention.append(logo); + mention.classList.add("jt-handle"); + } + }, + { id: "jt-handle-logos" } + ); +}); diff --git a/themes/jtech/javascripts/discourse/lib/jt-handle-logos.ts b/themes/jtech/javascripts/discourse/lib/jt-handle-logos.ts new file mode 100644 index 00000000..b9ada9eb --- /dev/null +++ b/themes/jtech/javascripts/discourse/lib/jt-handle-logos.ts @@ -0,0 +1,27 @@ +// Handles that get their logo before a mention (setting handle_logos). +// Each one also needs assets/handles/.svg, an about.json asset +// named handle- and a line in stylesheets/jt-handles.scss. +export const HANDLE_LOGOS: ReadonlySet = new Set([ + "claude", + "chatgpt", + "anthropic", + "microsoft", + "apple", + "meta", + "samsung", + "nvidia", + "intel", + "tesla", + "spacex", + "jtechforums", + "groupme", + "github", + "discourse", + "linux", + "android", + "24six", + "zing", + "naki", + "cloudflare", + "python", +]); diff --git a/themes/jtech/locales/en.yml b/themes/jtech/locales/en.yml index b7575de5..745931f3 100644 --- a/themes/jtech/locales/en.yml +++ b/themes/jtech/locales/en.yml @@ -167,6 +167,7 @@ en: quick_look: "Add a Quick look button to topic cards that previews the first post in a dialog. Signed-in members only, so it can't get round a login gate." reading_progress: "Thin bar under the header showing how far through a topic you are." external_link_icon: "Mark links in posts that go to other sites with a small arrow." + handle_logos: "Show mentions of these handles in posts and the composer's preview as a chip with the brand's logo after the name, like a mention of an account: @claude, @chatgpt, @anthropic, @microsoft, @apple, @meta, @samsung, @nvidia, @intel, @tesla, @spacex, @jtechforums, @groupme, @github, @discourse, @linux, @android, @24six, @zing, @naki, @cloudflare, @python. Works whether or not an account with that username exists; create one if the mention should link to a profile. Logos are the companies' trademarks." internal_hosts: "Hosts that count as this forum (no arrow). Matched exactly; the current host always counts." category_banners: "Show a header with the category's icon, name, description and counts on category pages." tag_banners: "Show a header with the tag's name and description on tag pages." diff --git a/themes/jtech/settings.yml b/themes/jtech/settings.yml index 9c77f588..88e63785 100644 --- a/themes/jtech/settings.yml +++ b/themes/jtech/settings.yml @@ -121,6 +121,9 @@ tag_banners: external_link_icon: type: bool default: true +handle_logos: + type: bool + default: true header_home_url: type: string default: "" diff --git a/themes/jtech/stylesheets/jt-handles.scss b/themes/jtech/stylesheets/jt-handles.scss new file mode 100644 index 00000000..2de79100 --- /dev/null +++ b/themes/jtech/stylesheets/jt-handles.scss @@ -0,0 +1,60 @@ +// Mentions of the handles in lib/jt-handle-logos (setting handle_logos). +// Each logo is a theme asset, assets/handles/.svg: the brand's mark +// on its own colour, drawn round here. + +// A mention of a name nobody has is plain text in core (span.mention); a +// handle's is the chip core draws for an account (a.mention), so it looks +// the same whether or not the account exists. Core's values, repeated. +span.mention.jt-handle { + display: inline-block; + font-size: 0.93em; + color: var(--primary); + padding: 0.2em 0.34em; + background: var(--mention-background-color); + border-radius: 0.6em; + text-wrap: nowrap; + line-height: 1; + unicode-bidi: plaintext; +} + +// After the name, where core puts an account's status emoji, at its size +.jt-handle-logo { + display: inline-block; + inline-size: 0.93em; + block-size: 0.93em; + margin-inline-start: 0.3em; + vertical-align: -0.1em; + border-radius: 50%; + background: center / cover no-repeat; +} + +$jt-handle-logos: ( + "claude": $handle-claude, + "chatgpt": $handle-chatgpt, + "anthropic": $handle-anthropic, + "microsoft": $handle-microsoft, + "apple": $handle-apple, + "meta": $handle-meta, + "samsung": $handle-samsung, + "nvidia": $handle-nvidia, + "intel": $handle-intel, + "tesla": $handle-tesla, + "spacex": $handle-spacex, + "jtechforums": $handle-jtechforums, + "groupme": $handle-groupme, + "github": $handle-github, + "discourse": $handle-discourse, + "linux": $handle-linux, + "android": $handle-android, + "24six": $handle-24six, + "zing": $handle-zing, + "naki": $handle-naki, + "cloudflare": $handle-cloudflare, + "python": $handle-python, +); + +@each $handle, $url in $jt-handle-logos { + .jt-handle-logo[data-jt-handle="#{$handle}"] { + background-image: url($url); + } +} diff --git a/types/jtech-theme.d.ts b/types/jtech-theme.d.ts index 03a73325..1dbd377a 100644 --- a/types/jtech-theme.d.ts +++ b/types/jtech-theme.d.ts @@ -32,6 +32,7 @@ declare module "virtual:theme" { category_banners: boolean; tag_banners: boolean; external_link_icon: boolean; + handle_logos: boolean; header_home_url: string; color_mode_toggle: boolean; header_color_toggle: boolean;