Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add core extensions: UserCSS, UserJS #6267

Merged
merged 23 commits into from
Jun 5, 2024
Merged

Conversation

hkcomori
Copy link
Contributor

@hkcomori hkcomori commented Apr 6, 2024

Closes FreshRSS/Extensions#227

Changes proposed in this pull request:

  • Add UserCSS, which is based on CustomCSS and changes the file storage location to the user's directory
  • Add UserJS, which is based on CustomJS and changes the file storage location to the user's directory

How to test the feature manually:

  1. Confirmed that extensions can be enabled
  2. Confirmed that CSS and JS can be written from the settings page
  3. Confirmed that the written contents are saved in data/users/extensions/<extension-name>.
  4. Confirmed that the written contents can be read by reopening the settings page
  5. Confirmed that the written CSS and JS are referenced from <head>.

Pull request checklist:

  • clear commit messages
  • code manually tested
  • unit tests written (optional if too hard)
  • documentation updated

Additional information can be found in the documentation.

The name is used for the directory where the configuration
is stored and should not contain spaces.
Since the name was changed, I reset the version number and
changed to semantic versioning.
Changed the location of the configuration file to
the user data directory, because it is not `static`.
That way, the user's configurations are gathered
in the user directory, which makes it easier to backup them.
Remove procedures to install the extension
because it is no longer necessary.
Remove permission error indication because the storage location
is now in the user data directory managed by the application.
@Alkarex
Copy link
Member

Alkarex commented Apr 6, 2024

Thanks! We will first issue FreshRSS 1.24 relatively soon and then address bigger changes such as this one in the edge version towards the next release

@Alkarex Alkarex requested a review from Frenzie April 6, 2024 13:41
@Alkarex Alkarex mentioned this pull request Apr 6, 2024
4 tasks
@Alkarex
Copy link
Member

Alkarex commented Apr 6, 2024

I have done some refactoring. Please double-check.

@Alkarex Alkarex requested a review from aledeg April 6, 2024 16:04

/** Return the user-specific, extension-specific, file content, or null if it does not exist */
protected final function getFile(string $filename): ?string {
$content = @file_get_contents($this->getExtensionUserPath() . '/' . $filename);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the future, we could try to see whether we could reduce the permissions for the extensions, so they can only call inherited functions

Version 0.0.1 will not be merged, so only version 1.0.0 will remain.
@hkcomori
Copy link
Contributor Author

hkcomori commented Apr 7, 2024

I have done some refactoring. Please double-check.

Thanks, nice refactoring.
I found some descriptions that are no longer used and I removed them.

I think it is a good idea to make some functions protected.
But I don't know if all of existing third-party extensions will not be broken.
Can we assume that they are guaranteed by unit tests?

@Alkarex
Copy link
Member

Alkarex commented Apr 7, 2024

Can we assume that they are guaranteed by unit tests

All the extensions of https://github.com/FreshRSS/Extensions are tested automatically, at least

@Alkarex
Copy link
Member

Alkarex commented Apr 7, 2024

I have made a new command to automatically test all known third-party FreshRSS extensions FreshRSS/Extensions#228

lib/Minz/Extension.php Outdated Show resolved Hide resolved
@Alkarex Alkarex merged commit 99b1d55 into FreshRSS:edge Jun 5, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature] Save CustomCSS settings to user data
4 participants