-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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 ability to override client assets : logo - favicon - PWA icons - PWA manifest name and description #2897
Conversation
@rigelk @Chocobozzz I can also split this PR into several, like 3 more, one for the manifest update, one for the cache, one for the front admin panel. Do you have an idea where |
server/controllers/client.ts
Outdated
|
||
for (const staticClientImage of staticClientImages) { | ||
let imagePhysicalPath = join(CONFIG.STORAGE.ASSETS_DIR, 'images', staticClientImage) | ||
clientsRouter.use(`/client/assets/images/${staticClientImage}`, asyncMiddleware(async (req: express.Request, res: express.Response, next: express.NextFunction) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please split the use and definition of the middleware.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not use express.static
here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought it was better to only serve files we need, do you think we should be able to serve all the assets directory ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The assets directory only has the files we need to serve, so yes 🙂
It has the advantage to be pretty rich when it comes to built-ins: https://expressjs.com/en/4x/api.html#express.static
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The assets directory only has the files we need to serve, so yes
There are all assets of the theme, there is more than we want to serve, no ?
Or you means for the icons
? I think favicon and logo should serve alone.
@kimsible unless you need tests running, please open WIP PRs as WIP. |
A lot of work for something that is trivial to do manually, especially since it is usually done once. I would much rather see a script in the tools, at least to begin with. |
Yes, you're right, it's really asked we should keep it in mind for further PeerTube versions, changing the logo is a common habit when it comes to animate a community for a special event. And for PWAs icons, it's now in the PeerTube Core, generating them is very useful when all the tools are included to do it automatically but in my opinion (I may be wrong), the webmanifest and icons should have been a plugin and not included by default in the client assets build. The first big issue is the ability to update logo and favicon without doing tricky code with shell or a plugin for each restart or update of PeerTube. Really, there is not so much PeerTube instances with a custom logo for all these reasons, developing a theme is not reachable by anybody. So, I delete this step =) Do you think we have to create another PR for the manifest or use this one ? |
Ok, you meant as a draft ? |
Yes, as draft, sorry ^^' |
Sorry, some things need to be discussed. |
Having another storage directory that implicitly override client assets is not something I think I like. Another proposal:
Not sure if it's a better solution than the one implemented in this PR. I prefer the plugin solution, because we don't add implicit things ( |
Hi @Chocobozzz , thanks for your participation.
I proposed to only override
Serving the JSON manifest dynamically is a very good idea and seems implementable with not so much efforts, but I partially agree for the others assets : The problem with the plugin is that the system does not allow to simply upload files for the moment, (I actually add some input file in the manifest plugin https://github.com/kimsible/peertube-plugin-webapp-manifest, and it's a real pain to to hook the client, plus sending files via plugins routes is not really secure, the router plugin should be able to upload only in one directory isolated from the app and available only for admins). What we need new with plugins :
You mean the logo ? I see another problem with the plugin API, edit the logo and the favicon are really one of the most basic feature we could expect from a self-hosted webapp, the upload input file should be in the admin panel in the config Appearance part. So, yes this solution is interesting but force us to implement / extend the plugin API support and put a basic feature into a plugin that should be in the PeerTube Core (I mean for the favicon and the logo, I don't think the manifest is a standard outside android ?). I'm really not against this solution but the plugin API should have all the features I mentioned and the plugin itself should be an official plugin. What do you think? |
@Chocobozzz I have an (intermediate) solution :
EDIT:
storage:
tmp: 'storage/tmp/' # Use to download data (imports etc), store uploaded files before processing...
...
logo: 'storage/logo.svg'
favicon: 'storage/favicon.png'
pwa_icons: 'storage/pwa_icons' |
Okay then. I prefer your first solution than the intermediate one, but with a more explicit name. Something like:
I think your check is still important, for security reasons.
How do you plan to handle cache naming?
Try to update the proxy file: https://github.com/Chocobozzz/PeerTube/blob/develop/client/proxy.config.json |
Thanks
EDIT: Later it could be included to the admin panel or in a plugin with the ability to update this global hash without restarting PeerTube Thanks for the tips too about the proxy ! |
I think a comment would be enough 👍
But how do you update the client to inject this querystring/hash to the logo URL? Currently, webpack does the job: updating the filename and the client HTML. If peertube automatically updates the filename on admin upload or peertube restart, we still miss the step where we inject this new logo name in the client no? |
Some assets need to be updated during
I'm not sure I understand well your question, maybe, we could fix a naming convention and extension for the assets to override them? (btw overriding always follows the same naming convention ?) Naming with a querystring
EDIT: Ok, I understood the whole point @Chocobozzz , I try to propose something in the CSS |
5248fe4
to
8176e4a
Compare
48204a2
to
176000e
Compare
I didn't find how to cancel the route overriding of webpack dev server with the proxy file. So the simplest way to test is with the client bundles |
@rigelk did you review this PR? |
@Chocobozzz no, since I thought you didn't agree with the design. |
Is there any documentation (other than the comment in production.yaml file) for this PR? Should logo.svg and favicon.png be in /var/www/peertube/storage/client-overrides/ or /var/www/peertube/storage/client-overrides/assets/images/ ? |
I tried both, and it is not working. |
@JohnXLivingston you need to restart PeerTube to update the client cache. This is an experimental feature that will be extend : #2752 (comment) |
Hum, I can't make it work... Don't know why. |
@JohnXLivingston do you use nginx ? docker ? |
nginx |
This PR allows to customize main assets like logo, favicon and PWA icons, PWA manifest name and description :
background-image
from CSS bundle to<style>
tag header inindex.html
;?[fileContentHash]
;description
,name
,short_name
with instance config ;Add ability in the admin panel to upload a SVG / PNG logo and generate favicon - PWA icons.To test it the client must be built with
npm run clean:client
andnpm run dev:server