Skip to content

Conversation

@Egari
Copy link
Contributor

@Egari Egari commented Apr 13, 2015

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

@ghost
Copy link

ghost commented Apr 13, 2015

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/

@Egari
Copy link
Contributor Author

Egari commented Apr 13, 2015

This contribution may be used under the MIT license.

@karlitschek
Copy link
Contributor

@jancborchardt @DeepDiver1975 What do you think?

@jancborchardt
Copy link
Member

So this fixes #15320?

@krempelweb @FunkyM can you test this?

@jancborchardt
Copy link
Member

@Egari also, is this similar to a fix for #6773 maybe? :)

@Egari
Copy link
Contributor Author

Egari commented Apr 13, 2015

@jancborchardt First of all, thank you for labeling 👍
Second, yes, it will indeed fix #15320.
Regarding #6773, in those cases the app tries to load images using the pure-javascript OC.imagePath and OC.filePath functions, which will not use any images and/or files that might be available in your theme. Since the pure-javascript OC.imagePath function does not actually use serverside code, it's more difficult to check for existing files. A possible change for this is to let apps do an ajax call to a PHP server-side url generator (or OC_Helper in this case).
So in short, unfortunately no.

@MorrisJobke
Copy link
Contributor

@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

@Egari
Copy link
Contributor Author

Egari commented Apr 13, 2015

@MorrisJobke Of course, my apologies. Updated.

@nickvergessen
Copy link
Contributor

@DeepDiver1975 8.1?

@DeepDiver1975
Copy link
Member

@Egari can I ask you to squash the commits? THX

@DeepDiver1975
Copy link
Member

@DeepDiver1975 8.1?

hmm .... better not -> 8.2

@DeepDiver1975 DeepDiver1975 added this to the 8.2-next milestone Apr 17, 2015
@jancborchardt
Copy link
Member

I’d also say 8.2 since it has the potential to break stuff.

@Egari Egari force-pushed the addThemeSupportToMimeIcon branch from 15b9ff5 to cfab63f Compare April 20, 2015 08:22
@Egari
Copy link
Contributor Author

Egari commented Apr 20, 2015

@DeepDiver1975 squashed into single commit, sorry for the delay.

Copy link
Member

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];

Copy link
Contributor Author

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.

Copy link
Member

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. 😄

@Egari Egari force-pushed the addThemeSupportToMimeIcon branch 2 times, most recently from 842d03b to d0c57b2 Compare April 23, 2015 10:03
@RobinMcCorkell
Copy link
Member

👍

@Egari Egari force-pushed the addThemeSupportToMimeIcon branch from d0c57b2 to c02ea96 Compare April 23, 2015 11:32
Copy link
Contributor

Choose a reason for hiding this comment

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

intendation is off

Copy link
Contributor

Choose a reason for hiding this comment

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

intendation is off

Copy link
Contributor

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

@Egari Egari force-pushed the addThemeSupportToMimeIcon branch 2 times, most recently from 48a2c0d to d771952 Compare April 23, 2015 13:39
@Egari
Copy link
Contributor Author

Egari commented Apr 23, 2015

@nickvergessen Darn, I'll .vimrc the thing... I have it set to spaces by default, and I mustve forgotten to noexpandtab... Fixed code.

@nickvergessen
Copy link
Contributor

Thanks, sorry for the troubles

@jancborchardt
Copy link
Member

@vgiannoul Please review this as it probably fixes your #16547

@RobinMcCorkell
Copy link
Member

My 👍 still stands

@vgiannoul
Copy link

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

@Egari
Copy link
Contributor Author

Egari commented Jun 1, 2015

That function is defined not 20 lines below the end of the changed function;
https://github.com/Egari/core/blob/addThemeSupportToMimeIcon/lib/private/helper.php#L327

Did something go wrong applying the patch? Conflicting local changes?

@vgiannoul
Copy link

Sorry for late response,
i continue to get this error message
Fatal error: Class 'OC\Avatar' not found in /Users/vgiannoul/Sites/owncloud/lib/private/helper.php on line 328
after applying the patch on a clean install (version 8.0.3)

@DeepDiver1975
Copy link
Member

This patch can only be applied against master.

@PVince81
Copy link
Contributor

PVince81 commented Jul 3, 2015

@rullzer what do you think ? (in regard to your other changes regarding mimetypes)

@PVince81
Copy link
Contributor

PVince81 commented Jul 3, 2015

@owncloud-bot ok to test

Copy link
Contributor

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..

Copy link
Contributor

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)

Copy link
Contributor

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

Copy link
Contributor Author

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! 👍

Copy link
Contributor

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)

@rullzer rullzer mentioned this pull request Jul 4, 2015
1 task
@Egari Egari force-pushed the addThemeSupportToMimeIcon branch from d771952 to 1fc188f Compare July 7, 2015 12:39
@scrutinizer-notifier
Copy link

A new inspection was created.

@ghost
Copy link

ghost commented Jul 7, 2015

🚀 Test PASSed.🚀
chuck

@rullzer
Copy link
Contributor

rullzer commented Jul 8, 2015

Looking good and working properly for themes.
I still think this function needs to be migrated (#15543). But this theming stuff should be fixed!

👍

@MorrisJobke
Copy link
Contributor

Tested and works 👍

MorrisJobke added a commit that referenced this pull request Jul 9, 2015
Add theme support to mimetypeIcon through imagePath integration
@MorrisJobke MorrisJobke merged commit c86e742 into owncloud:master Jul 9, 2015
@lock lock bot locked as resolved and limited conversation to collaborators Aug 11, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.