-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Add theme support to mimetypeIcon through imagePath integration #15586
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
Conversation
|
Thanks a lot for your contribution! Contributions to the core repo require a signed contributors agreement http://owncloud.org/contribute/agreement/ Alternatively you can add a comment here stating that this contribution is MIT licensed. Some more details about out pull request workflow can be found here: http://owncloud.org/code-reviews-on-github/ |
|
This contribution may be used under the MIT license. |
|
@jancborchardt @DeepDiver1975 What do you think? |
|
So this fixes #15320? @krempelweb @FunkyM can you test this? |
|
@jancborchardt First of all, thank you for labeling 👍 |
|
@Egari Can I ask you to use tabs for intendation? See https://doc.owncloud.org/server/8.1/developer_manual/general/codingguidelines.html#coding This also would make the diff more pretty. Thanks |
|
@MorrisJobke Of course, my apologies. Updated. |
|
@DeepDiver1975 8.1? |
|
@Egari can I ask you to squash the commits? THX |
hmm .... better not -> 8.2 |
|
I’d also say 8.2 since it has the potential to break stuff. |
15b9ff5 to
cfab63f
Compare
|
@DeepDiver1975 squashed into single commit, sorry for the delay. |
lib/private/helper.php
Outdated
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.
This is effectively duplicated code from UrlGenerator (which is where self::imagePath() goes). Instead of doing all the file_exists() stuff here, just call self::imagePath(), then if there is a result it must exist (as per UrlGenerator::imagePath()). Note that imagePath() will throw a RuntimeException if the image can't be found, which provides a nice clean way of implementing this:
try {
// Icon exists?
self::$mimetypeIcons[$mimetype] = self::imagePath(...);
return self::$mimetypeIcons[$mimetype];
} catch (\RuntimeException $e) {
}
try {
// Try only the first part of the filetype
self::$mimetypeIcons[$mimetype] = self::imagePath(...);
return self::$mimetypeIcons[$mimetype];
} catch (\RuntimeException $e) {
}
self::$mimetypeIcons[$mimetype] = self::imagePath(... 'file.png');
return self::$mimetypeIcons[$mimetype];
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.
If Exception-catching (something I'm personally not a fan of) is preferred over code duplication, I will update the pull request when I get the chance.
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.
Code duplication in itself isn't necessarily a bad thing, but when code that has the identical function is split over two files, then it is a recipe for disaster and inconsistency. The exception plumbing is already there in the imagePath() function, and it'd be silly to just ignore it. 😄
842d03b to
d0c57b2
Compare
|
👍 |
d0c57b2 to
c02ea96
Compare
lib/private/helper.php
Outdated
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.
intendation is off
lib/private/helper.php
Outdated
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.
intendation is off
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.
okay actually you use spaces instead of tabs
48a2c0d to
d771952
Compare
|
@nickvergessen Darn, I'll .vimrc the thing... I have it set to spaces by default, and I mustve forgotten to noexpandtab... Fixed code. |
|
Thanks, sorry for the troubles |
|
@vgiannoul Please review this as it probably fixes your #16547 |
|
My 👍 still stands |
|
maybe I'm wrong or this is my fault but I get an error when applying this patch Fatal error: Call to undefined method OC_Helper::userAvatarSet() in owncloud/lib/private/templatelayout.php on line 80 and I have to comment out this line in order to fix it. I have enabled userAvatars in my configuration |
|
That function is defined not 20 lines below the end of the changed function; Did something go wrong applying the patch? Conflicting local changes? |
|
Sorry for late response, |
|
This patch can only be applied against master. |
|
@rullzer what do you think ? (in regard to your other changes regarding mimetypes) |
|
@owncloud-bot ok to test |
lib/private/helper.php
Outdated
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 can't check but moving to SVG here by default might break some browsers..
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.
O and don't use self::imagePath!!! That function is deprecated.
Use \OC::$server->getURLGenerator()->imagePath($app, $image)
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.
This of course hold in the other cases as well
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're quite right, updated to remove the use of self::imagePath and revert the change to use svg by default.
Thanks for the feedback! 👍
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 would love to drop the PNGs... but unfortunatly we can't.... (yet)
d771952 to
1fc188f
Compare
|
A new inspection was created. |
|
Looking good and working properly for themes. 👍 |
|
Tested and works 👍 |
Add theme support to mimetypeIcon through imagePath integration

Added theme support to mimetype icons by using the pre-existing imagePath function