-
-
Notifications
You must be signed in to change notification settings - Fork 4k
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 dynamic icon creation #840
Conversation
@juliushaertl, thanks for your PR! By analyzing the annotation information on this pull request, we identified @bartv2, @rullzer and @LukasReschke to be potential reviewers |
Mmmm I guess we kind of have to at some point. But we should add a big cache and cache buster (changed only when the theme is updated!) to make sure this hits the server as few times as possible. Because we will setup a lot of stuff to server an icon. awesome initiative @juliushaertl! |
I'm still trying to figure out how caching could be implemented. I think having the files on the file system makes the most sense. For now I think I'll just store them into the data/ folder, like it is currently happening with the logo and background image, but this will become a huge mess due to number of icons. |
@juliushaertl no the point is that right now all icons are serverd by the webserver. No PHP is involved etc. We can easily add proper caching headers. Just let me know if you need help. |
3cca71f
to
98346a1
Compare
Awesome @juliushaertl! :) Only thing is that the favicon logo is black whereas the normal logo is white. The favicon should be the same as the chosen logo. :) |
@jancborchardt ah right, I'll remove that. I should have some time later today to finish this. |
98346a1
to
2bc77d0
Compare
9880e58
to
cc88a84
Compare
OK, i'll need some more time, as testing the Imagemagick stuff will be a bit harder. But I'm on it. 😄 |
86bcc4a
to
6fcd411
Compare
d4d7b0d
to
a34091b
Compare
Finally ready for review! @nextcloud/theming @rullzer It would be great if you could have a look if the caching is fine. (apps/theming/lib/Controller/IconController.php) It would also be good if someone could have a look if there are any problems with directory traversal. The route Icon#getThemedIcon accepts paths within the image parameter to allow getting images inside a subdirectory ( like |
Tested and works in Firefox. Opera, Safari, Chrome, Edge, IE11 and IE10 🙌 👍 |
$response->cacheFor(86400); | ||
$response->addHeader('Expires', date(\DateTime::RFC2822, $this->timeFactory->getTime())); | ||
$response->addHeader('Pragma', 'cache'); | ||
return $response; |
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.
You don't store the colored svg anywhere?
If you have a themed instance with 50K users you will still have to do this for 50K users.
Also if you have a file that you server we could use #1121. you could set the ETag. That way if the file did not change the request is fast.
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.
We can easily add proper caching headers.
OK, maybe I misinterpreded your previous answer. I already thought that storing the generated icons in the filesystem would make sense. Do you have any hint how I could implement that?
We can't store it in the user-folders as these are also required for public/login page. I guess we should not just put them inside the data folder. That is why I thought that #136 might be important. Or is it possible to use a simple memory cache for these icons, as the number of those generated icons will stay quite low?
It would be great, if you could point me into the right direction.
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.
Hehe. Well there are 2 things of course.
- We want to cache server side so serving is fast
- We want to cache client side so we don't have to request stuff from the server every time
They are two different optimizations but work towards the same goal of less request => less server load & faster loading
I'll see if we can make #136 happen sooner rather than later. because I don't really feel comfortable just dumping this all in the root data folder.
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.
That would be great. :)
a34091b
to
f4550d0
Compare
Signed-off-by: Julius Haertl <jus@bitgrid.net>
Signed-off-by: Julius Haertl <jus@bitgrid.net>
Signed-off-by: Julius Haertl <jus@bitgrid.net>
Signed-off-by: Julius Haertl <jus@bitgrid.net>
Signed-off-by: Julius Haertl <jus@bitgrid.net>
Signed-off-by: Julius Haertl <jus@bitgrid.net>
Signed-off-by: Julius Haertl <jus@bitgrid.net>
Signed-off-by: Julius Haertl <jus@bitgrid.net>
Signed-off-by: Julius Haertl <jus@bitgrid.net>
Signed-off-by: Julius Haertl <jus@bitgrid.net>
Signed-off-by: Julius Haertl <jus@bitgrid.net>
Signed-off-by: Julius Haertl <jus@bitgrid.net>
Signed-off-by: Julius Haertl <jus@bitgrid.net>
Signed-off-by: Julius Haertl <jus@bitgrid.net>
Signed-off-by: Julius Haertl <jus@bitgrid.net>
56a5f4a
to
2b4bc2e
Compare
Signed-off-by: Julius Haertl <jus@bitgrid.net>
2b4bc2e
to
2ab4d1e
Compare
@rullzer @LukasReschke @nextcloud/theming Changes are in. Ready for another review. |
👍 |
Good stuff @juliushaertl :) as always |
🎉 @jancborchardt Thanks. I'm always glad to help. 😉 |
So this basically addresses #218 and #378. With this change the theming app offers two new endpoints for getting themed icons.
Return a image with logo and colored background:
http://localhost:8080/index.php/apps/theming/favicon/appname
Return a svg icon replacing the default color with the themed one:
http://localhost:8080/index.php/apps/theming/img/appname/filepath
Results: