Commit Graph

6637 Commits

Author SHA1 Message Date
342e9208b3 FIX: Upload#update_secure_status not updating s3 access control (#33232)
This commit is a follow-up to b02bc707dec12c607511d4a95c7d791f63131b49
where `Upload#update_secure_status` does not call
`FileStore::S3Store#update_upload_access_control` if
`s3_use_acls` is disabled. This is no longer correct as an upload's
access control on S3 can now be based on tags if the
`s3_enable_access_control_tags` site setting is
enabled.

To fix this, this commit removes the `s3_use_acls` check in
`Upload#update_secure_status` and updates
`FileStore::S3Store#default_s3_options`
to not set the `acl` option if the `s3_use_acls` site setting is
disabled.
2025-06-17 16:28:36 +08:00
da1de52a06 FIX: Wrong argument error in FileStore::S3Store#update_access_control (#33231)
This commit is a follow up to b02bc707dec12c607511d4a95c7d791f63131b49.
When the `s3_enable_access_control_tags` site setting is enabled,
calling `FileStore::S3Store#update_access_control` will result in a
argument error.
2025-06-17 15:18:14 +08:00
1a2b003d35 FIX: import Horizon system theme (#33229)
System themes were introduced here -
https://github.com/discourse/discourse/pull/32681

In this PR, Horizon is imported.
2025-06-17 14:03:38 +08:00
6c049af5c4 FIX: ignore SiteSetting.max_image_size_kb for theme screenshots (#33215)
Theme screenshots have their validations:
https://github.com/discourse/discourse/blob/main/lib/theme_screenshots_handler.rb#L4

Therefore, validations in `UploadCreator` can be ignored. Currently, the
import of system themes is crashing when the value is too low for
`SiteSetting.max_image_size_kb` .
2025-06-17 08:58:37 +08:00
b02bc707de DEV: Add setting to tag s3 objects enabling tag based access control policies (#32988)
This commit introduces a `s3_enable_access_control_tags` site setting
which,
when enabled, adds a `discourse:acl` tag with values `public` or
`private` to
S3 objects created by the application. The presence of the tags on S3
objects
enables bucket administrators to implement tag-based access control
policies, providing an alternative to
object ACLs which AWS now discourages.

The `discourse:acl` tag can be customized via the
`s3_access_control_tag_key ` site setting.
Values for `public` and `private` can also be customized via the
`s3_access_control_tag_public_value` and
`s3_access_control_tag_private_value ` site settings respectively.

### Reviewer Notes

To test it locally, run the following commands in your working discourse
directory:

1. `script/install_minio_binaries.rb`
2. Start a local minio server by running: `bundle exec rails runner
script/local_minio_s3.rb`
3. bundle exec rails runner "SiteSetting.enable_s3_uploads = true"
5. Start your development rails server with the following environment
variables: `DISCOURSE_ENABLE_S3_UPLOADS=true
DISCOURSE_S3_ENABLE_ACCESS_CONTROL_TAGS=true
DISCOURSE_BACKUP_LOCATION=s3`
2025-06-16 13:26:18 +08:00
862116a176 FEATURE: Add description to invites (#33207)
Add the ability to attach a description to an invite for easier organization.
2025-06-16 11:31:07 +08:00
19c1932144 Revert "FIX: import Horizon system theme" (#33196)
Reverts discourse/discourse#33193
2025-06-13 14:32:45 +01:00
7562bc2b15 FIX: import Horizon system theme (#33193)
System themes were introduced here -
https://github.com/discourse/discourse/pull/32681

In this PR, Horizon is imported.
2025-06-13 12:30:34 +08:00
2536768a43 FEATURE: system themes (#32681)
Introduction of system themes.  System themes are local themes which:
- Cannot be deleted;
- Cannot have “custom code” added, components only;
- Cannot have uploads;
- Cannot edit color palettes;
- Are updated on deploy, like core plugins.

This PR added the Foundation system theme, which is an empty theme like
Default. The Foundation theme will be added in the next PR.

In a development environment, when system theme files are
changed/added/deleted, the theme is reuploaded and the page is reloaded
to make it a good experience for the engineer working on improvements.

System themes are not visible until
`SiteSetting.experimental_system_theme` is enabled.
2025-06-13 10:36:31 +08:00
4d380a28e7 FEATURE: Add post language on creating a new post (#33160)
This is a second attempt at:
https://github.com/discourse/discourse/pull/33001

We had to [revert the
commit](https://github.com/discourse/discourse/pull/33157) because it
was performing a site-setting check at boot time, which is prone to
issues and not allowed.

This PR:
- re-introduces the changes in the original PR
- a fix by not performing a site-setting check at boot time (verified
by: `SKIP_DB_AND_REDIS=1 DISCOURSE_DEV_DB="nonexist" bin/rails runner
"puts 'booted'"` locally and should be caught by the new CI check
introduced here: https://github.com/discourse/discourse/pull/33158)
- adds a fix to the translation editor to not show the original post
locale in the dropdown, as well as adding an indicator of what the
original post locale is in a small badge in the header:
- ![Screenshot 2025-06-11 at 08 42
36](https://github.com/user-attachments/assets/5f0944c5-ec4d-40b3-b97f-25b1fcab8329)
2025-06-11 10:39:01 -07:00
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