Commit Graph

6627 Commits

Author SHA1 Message Date
d5b72a54ae Revert "FEATURE: Add post language on creating a new post (#33001)" (#33157)
This reverts commit b55af383f779d01d983a3ccf1149438aee9c6725.
2025-06-11 08:01:56 -07:00
b55af383f7 FEATURE: Add post language on creating a new post (#33001)
## 🔍 Overview
Previously we added the ability to translate existing posts in different
languages: https://github.com/discourse/discourse/pull/32564. In this
update we add the ability to set a post language upon initially creating
a post.

Internally, we also clean-up/improve a few things, like:
- adding a `PostLanguageSelector` component
- Adding a `available_content_localization_locales` onto `SiteSetting`
so it's available in the service (without needing to parse the JSON to
access it)
- fix issues with the translation-editor not working due to some
regressions from here: https://github.com/discourse/discourse/pull/32869
- ensure everything works for replies/drafts/edits

## 📷 Screenshots
![Screenshot 2025-06-05 at 12 03
24](https://github.com/user-attachments/assets/ff334575-ba30-4c52-9e9a-4054f69795ec)
2025-06-11 07:29:05 -07:00
a2b0c193df DEV: Switch to type="module" for translation files (#33126)
We will be moving towards `type="module"` for all of Discourse's JS
bundles in the near future. This commit makes a start by applying the
change to translation bundles.

This was previously merged, but the lack of `apply_cdn_headers` on the
locales controller led to CORS errors on sites with CDNs.
2025-06-09 13:13:42 +01:00
c28353b0dd Revert "DEV: Switch to type="module" for translation files (#33107)" (#33125)
This reverts commit 33dc48b0daa0f6f75e6c0533edbe3f5df991c694.
2025-06-09 18:06:31 +08:00
33dc48b0da DEV: Switch to type="module" for translation files (#33107)
We will be moving towards `type="module"` for all of Discourse's JS
bundles in the near future. This commit makes a start by applying the
change to translation bundles.
2025-06-09 10:30:16 +01:00
aa6d0bb685 SECURITY: Respect max length in bot-human PMs
…and work around long-url parsing issue.
2025-06-09 12:04:11 +08:00
623cde985b FIX: Wrap theme translations in IIFE (#33108)
Without this wrapper, `data` is defined in the global scope and clashes
when there are multiple themes with translations.

Followup to 033cccdf17a56b43f9f243bb549abe0a41a0de63

We can remove the wrapper once we land
https://github.com/discourse/discourse/pull/33107
2025-06-06 16:40:07 +01:00
033cccdf17 DEV: Simplify theme translation JS generation (#33104)
Theme translations are very simple JS, and do not need to be run through
the theme transpiler. This brings their format in-line with core/plugin
translations.

Extracted from https://github.com/discourse/discourse/pull/33103
2025-06-06 16:00:49 +01:00
7fce724089 FEATURE: Theme-owned color palettes (#32795)
This commit removes the color palette dropdown from the theme page and replaces it with a new "Colors" tab where the theme's color palette can be edited directly in that tab on the theme page. With this change, a theme's color palette is strongly tied to its theme and can't be linked to other themes and it can't be selected by users without using the theme as well.

All of the changes are behind a feature flag. To enable it, turn on the `use_overhauled_theme_color_palette` setting.

Co-authored-by: Ella <ella.estigoy@gmail.com>
2025-06-04 07:47:58 +03:00
599404de31 DEV: Add a ReviewableNote model, and tie it into the Reviewable model. (#33047)
As part of the review queue refresh, we'll be adding the ability for moderators to make notes on individual reviewable items. As a first step, this change adds the new model and associated backend code.
2025-06-04 09:33:02 +10:00
6912025564 FIX: restore category text color field (#32915)
Restores the category text/foreground color field that was removed in
#32015.

We are also retaining the auto text color selection that was introduced
and applying on background color change rather than when the form is
saved. The text color algorithm has been changed from color brightness
to use color difference instead, which appears to be more reliable.

Algorithm for color difference:
https://www.w3.org/TR/AERT/#color-contrast

---------

Co-authored-by: Joffrey JAFFEUX <j.jaffeux@gmail.com>
2025-06-02 12:16:38 +04:00
be3b557882 DEV: Correct typo in script-tag-discourse-plugin deprecation (#32990) 2025-05-29 15:35:55 +01:00
435088f62c DEV: Add locale column to categories (#32962)
Previously we had omitted determining the locale of categories, as
unlike posts, categories are usually single words and are usually only
translated once.

Since there is no locale, a category called "Staff" would also have an
English translation. With LLMs that perform poorly, we see that
translating "Staff" to English may result in something entirely
different (like "Personnelle" or "Personal").

Thus adding locale support to categories can mitigate this issue due to
the uncertainty.
2025-05-28 13:49:26 +08:00
6d42d95341 DEV: update composer similar topics limit (#32934)
Updates the composer similar topics tips to return a maximum of 3 topic
results. We are phasing out the site setting in an effort to improve the
UX in the composer.

We will handle the migration to remove the site setting value from the
database in a follow up PR.
2025-05-27 14:06:31 +04:00
b485e04e4f FEATURE: Also localize banners (#32908)
Banners take a different route and are retrieved separately.
2025-05-26 13:16:22 +08:00
11a0ad933a DEV: do not convert (tm) and (TM) to emoji (#32713)
This regressed because with recent emojis changes, the base name is now
`trade_mark` and not `tm`. `tm` is just an alias emoji.
2025-05-22 10:26:23 +02:00
94e653af08 FEATURE: Also localize topic excerpts (#32839)
Currently, topic excerpts are not localized.

This commit adds the excerpt column into topic_localization and displays the
localized excerpt if present.
2025-05-21 17:49:27 +08:00
b8d733045f FIX: Catch postcss errors correctly for theme fields (#32800) 2025-05-19 13:19:49 +01:00
5cf6ebf70c DEV: Deprecate inline script tags for templates & initializers (#32773)
https://meta.discourse.org/t/366482
2025-05-19 10:55:52 +01:00
76e1373b04 FIX: N+1 in admin themes page (#32763)
`strict_loading` was added to prevent it happening in the future. Few
adjustments had to be made:
- include color_scheme and color_scheme_colors, also for parent and
child themes;
- internal translations were using preload_fields, but it was too deep
to correctly use preloaded tables. I had to pass
`preloaded_locale_fields` manually;
- include theme in color_scheme.

Before:
<img width="663" alt="Screenshot 2025-05-15 at 3 43 47 pm"
src="https://github.com/user-attachments/assets/b55ce11e-80cb-43eb-8e31-940b0e9859f3"
/>

After:
<img width="665" alt="Screenshot 2025-05-16 at 11 29 00 am"
src="https://github.com/user-attachments/assets/f00bac19-f64b-4048-b220-4d0a9d90a929"
/>
2025-05-19 11:05:23 +08:00
51ebe7064c FEATURE: Show localized posts and topics based on user's locale (#32618)
Related:
- https://github.com/discourse/discourse-translator/pull/205
- https://github.com/discourse/discourse-translator/pull/274
- https://github.com/discourse/discourse-translator/pull/294

With this PR, we will start showing localized posts (if available) based
on the user's locale.

This work had been done in discourse-translator, but is now moving to
core.
2025-05-15 19:11:06 +08:00
5072615290 FEATURE: Add the group show endpoint to search groups by id instead of only the slug name (#32442)
**Description**
As part of a customer request, we have added the option to search groups
by ID when doing API calls. However, in doing so we have decided to
correct the confusion around the group's routes. Previously the route
would look like `g/:id` while taking the `name` of the group as the
param. For example, when getting a group the route would be like this:

```
GET /g/admins
```

This would make the code in the controller seem as if it was handling
the group IDs instead of names. With these changes, this should be
addressed.
2025-05-13 14:22:06 -05:00
e564ab5f63 PERF: Improve performance of the new themes listing page (#32641)
The new themes listing page at `/admin/config/customize/themes`
currently has poor performance compared to the components page
(`/admin/config/customize/components`) due to various N+1 issues,
loading all themes and components from the server when only themes are
needed, and serializing data/attributes that aren't needed for rendering
the themes grid.

This commit improves the performance by eliminating all N+1 that are
currently present, excluding components from the page payload, and
reducing the amount of data transmitted for each theme when loading the
page.
2025-05-08 19:18:07 +03:00
4d9bc4fef4 DEV: More helper methods for topic localization (#32643)
This adds more methods on `Topic` so it can be used in a later PR that
will localize topics.
2025-05-08 16:12:28 +08:00
6455e75da1 DEV: Add locale for topics (#32619)
Similar to https://github.com/discourse/discourse/pull/32526.

Reviewer note: There had been some deliberation if we should just take
the `topic.first_post.locale` instead of having a `topic.locale`.
Ultimately, titles may be of a different language of the post itself,
and secondarily in some cases it could be faster without having to load
the first_post at all.
2025-05-07 22:25:58 +08:00
dcc0eff0c7 DEV: remove theme_download_screenshots site setting (#32612)
Enable theme screenshots to everyone

![Screenshot 2025-05-07 at 10 21
48 am](https://github.com/user-attachments/assets/263cc256-c6c6-49ed-bb9b-0ddff9bb1ecb)
2025-05-07 12:09:20 +08:00
3a8c8dfddb FIX: Don't enforce strict loading on anon user main record (#32590)
Chat is currently broken in local development if anonymous mode is enabled in site settings. This is happening after #32416. One of the strict_loading directives in ChannelFetcher is trickling down to an anonymous user check.

We don't need to enforce strict_loading on this 1-to-1 association that's only used in a few code paths, so mark it as strict_loading: false on the User model.
2025-05-07 09:46:07 +08:00
25e4bc597e DEV: Helper methods for post localization (#32529)
Adding helper methods for post localization within `Post` model for fluency.
2025-05-06 14:13:43 +08:00
Sam
c8d6dd2a92 FIX: key optimized images on format (#32575)
Previous to this change when we used to specify format it could get an
image
in the incorrect format.

Also... allows image magick to decode svg

---

There remains a bug where the crop / resize information is not stored in
optimized images
this means that sometimes when asking for a cropped image you may get a
resized one.
2025-05-06 14:40:51 +10:00
4d0a817f40 DEV: Compile 'common' CSS into own assets (#31416)
Previously we were compiling core and theme CSS into two targets:
Desktop and Mobile. The majority of both files was the 'common' css.
This commit splits those common styles into their own targets so that
there is less duplication. This should improve compilation times + cache
reuse, as well as opening the door for experiments with
media-query-based mobile-modes.

The only functional change is that we can no longer use `@extend` to
copy 'common' rules in core to mobile/desktop. This is probably for the
best. Duplication and/or mixins are a more native-css pattern for this.

Plugins already have a common / mobile / desktop pattern, so are
unchanged by this commit.
2025-05-01 10:44:49 +01:00
13acf58b27 UX: Append '+' to link count if above threshold in topic map (#32093)
Meta:
https://meta.discourse.org/t/suggestion-for-fixing-the-inaccurate-link-counter-value/359527

The link count in the topic map summary is limited to 50 on the backend.
However, the frontend displays exactly 50, even when more links exist. 
This can be misleading as users might assume there are no additional
links.

This PR updates the logic by fetching one extra link from the database
and appending a `+` to the count when there are more than 50 links.

Before:

![image](https://github.com/user-attachments/assets/a741d984-1eb0-41f0-9f58-1a52574fc9bc)

After:

![image](https://github.com/user-attachments/assets/8b1e589a-f85f-4c06-a2ac-dd2b34a41b46)
2025-04-30 12:41:43 -04:00
7d8a1df6cd DEV: Add locale to post table (#32526)
Adding a `locale` column to the post table, so that we can localize
posts.
2025-04-30 16:35:32 +08:00
ed1e0e30f2 DEV: Remove full_page_login setting (#32189)
We are making this the only option for our login/signup
pages on April 29th, 2025, per

https://meta.discourse.org/t/introducing-our-new-fullscreen-signup-and-login-pages/340401.

This commit removes the `full_page_login` setting and any logic
around it, as well as deleting the old login and signup modals,
and removing leftover problem checks and settings from the database.
2025-04-29 10:40:40 +02:00
621e095739 FIX: Also cater for fixed category positions when localizing categories (#32486)
When ordering categories,

af8e48c1e0/app/models/category_list.rb (L61-L68)

Only one of the flows do `.group("categories.id")`.

This was causing sites with `SiteSetting.fixed_category_positions=true`
to 500 when another site setting
`SiteSetting.experimental_content_localization` was enabled. (Related:
https://github.com/discourse/discourse/pull/32464).

This commit fixes the issue by also grouping on the other case.
2025-04-28 15:34:31 +08:00
3146142c2e DEV: Create topic and post localization resources (#32440)
This commit adds

- `topic_localization` containing its topic, a locale, title, and
fancy_title
- `post_localization` containing its post, a locale, raw, cooked, the
associated post's version
- and also APIs to add them

Reviewer note: We may ask ourselves "why create separate models instead
of one that is generic?" but the different localizable models may be
vastly different. For example in posts we only have raw that we need to
translate, and topics we have only title, but for categories we have
name and description. Then, we may ask ourselves "why not create a
polymorphic one that takes in model and column name?" and then we end up
with the same thing as what we have currently which is custom fields
(which is a mess in itself). Also, when replacing the untranslated
content to the translated one, we may find it easier to just `join` +
`coalesce` on the dedicated table - it would be a much simpler query
than polymorphism.
2025-04-28 12:16:14 +08:00
cdb047ca29 FEATURE: Show localized categories route (#32464)
Earlier on in https://github.com/discourse/discourse/pull/32380 we
started showing localized categories on /latest and in the sidebar, but
it missed out /categories as it takes a different route.

This PR updates our CategoryList to also query for localizations and use
them if they exist.

<img width="1377" alt="Screenshot 2025-04-25 at 5 43 49 PM"
src="https://github.com/user-attachments/assets/d1049ec7-3909-40b2-92f6-b810f4366356"
/>

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-04-28 11:57:46 +08:00
5e2edce3ad FIX: Also show localized categories for users who are not logged in (#32465)
A rework of https://github.com/discourse/discourse/pull/32460.

In the earlier PR that had to be reverted, we were directly deleting
cache (redis) and it was causing our image build to fail (see dev chat).

In this commit, we will rely on the existing method of invalid the keys
(which essentially will cause the next request to get the new site json
since the seq is not the same).
2025-04-28 11:19:58 +08:00
b85654e425 Revert "FIX: Also show localized categories for users who are not logged in (#32463)
Related #32460

This reverts commit 5a4f3b3ab8c81282e17430784bc90d73a3bbce72.
2025-04-25 16:49:44 +08:00
5a4f3b3ab8 FIX: Also show localized categories for users who are not logged in (#32460)
In https://github.com/discourse/discourse/pull/32380, we started showing
localized categories. However we missed out anon users.

This commit ensures the site cache is also localized.
2025-04-25 15:40:35 +08:00
10c817fab5 FEATURE: Set category localizations in category settings (#32412)
This update is a follow-up to b0ab1b2321, where we now allow localizations for a category to be set in the category settings UI.
2025-04-24 10:48:35 +08:00
e19e43f1bd FIX: Delegate silenced_till from anonymous user to main user account (#32416)
When a user is silenced they can, given they have the permissions, enter anonymous mode and keep posting, essentially bypassing the silence that way.

This change delegates the silenced_till attribute to the main user record if the user is anonymous.
2025-04-23 16:34:51 +08:00
b0ab1b2321 FEATURE: Show translated category names from localizations table if they exist for the user locale (#32380)
This PR adds category localization support to core.

- Depends on https://github.com/discourse/discourse/pull/32378
- Creates the required table `category_localizations`
- Makes use of the site category cache to display localized categories
- Supports name and description
- This does not yet include /categories page. (coming in a next PR)

## Before

<img width="1089" alt="Screenshot 2025-04-21 at 4 31 43 PM"
src="https://github.com/user-attachments/assets/9e49b21b-b16a-43d2-9b16-0fd0324a21ca"
/>

## After

<img width="1085" alt="Screenshot 2025-04-21 at 4 32 42 PM"
src="https://github.com/user-attachments/assets/7bfa21a2-6df2-4cdf-a00a-d044c3526a40"
/>
2025-04-22 15:13:19 +08:00
d5b2b186b4 DEV: Cache categories by locale (#32378)
Our category cache is currently specific to the site locale.

Expanding the key to take in `I18n.locale` as well to accommodate for
category translations in core.
2025-04-22 13:10:53 +08:00
e8997b6202 DEV: Add Settings tab to admin Badges page (#32251)
This change does two things:

Modernizes the admin badges UI implementation. (Routes + controllers → components + services.)
Adds a Settings tab to the new badges page.
For all intents and purposes, this change is a lift-and-shift modernization. The addition of the settings tab is trivial once that is covered.
2025-04-21 09:41:29 +08:00
02c5dd439b DEV: Add a post_owner_changed event (#32312)
This allows plugins to hook onto this event when post owner changes.
2025-04-15 22:26:44 +08:00
996a3493fe PERF: Prevent N+1 queries when loading theme/component descriptions (#32305)
Theme/component description is fetched via the `locale_fields` and
`theme_translation_overrides` associations on the `Theme` model. We're
currently not preloading these associations when serializing
themes/components, which causes an N+1 performance issue when accessing
the themes/components listing pages.
2025-04-15 16:02:41 +03:00
f0057c7353 DEV: Drop legacy topic-list and raw-handlebars compilation system (#32081) 2025-04-14 10:42:40 +01:00
414419b43d DEV: Add Settings tab to admin Users page (#32255)
This PR adds a Settings tab to the admin Users page, grouping relevant site settings.
2025-04-11 11:10:53 +08:00
db214a38a2 DEV: Add Content admin config page (#32194)
This PR adds a dedicated page for Content related site settings. It has four different site setting tabs.
2025-04-10 11:20:22 +08:00
7f851c416d DEV: Add Dashboard settings tab to Reports page (#32235)
This change adds a Dashboard settings tab to the Reports page.
2025-04-10 10:41:12 +08:00