Active
Project:
Flickr
Version:
7.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
27 Mar 2014 at 07:05 UTC
Updated:
20 May 2015 at 07:48 UTC
Jump to comment: Most recent, Most recent file
There are code pieces in the several sub-modules that are almost similar and probably could be unified in smaller functions of the main module. It is wise to do this before porting the module to D8.
Furthermore some theme functions can be called more directly.
Some examples:
function theme_flickr_photo in flickr.module VS function theme_flickrfield_photo in flickrfield.module
Comments
Comment #1
lolandese commentedThere seems to be no need for the existence of function theme_flickr_filter_photo and function theme_flickr_filter_photoset in flickr_filter.module as they only point to their counterparts in the main module without any additions.
Comment #2
lolandese commentedEven less.
Comment #4
lolandese commentedhttp://drupalcode.org/project/flickr.git/commitdiff/e71282f
More to come.
Comment #5
lolandese commentedAttached patch:
Comment #7
lolandese commentedReroll against latest dev and commit.
http://drupalcode.org/project/flickr.git/commitdiff/2d4ce60
Comment #8
lolandese commentedComment #9
lolandese commentedThere are flickr requests implemented in some sub-modules that could and should make use of flickr.api.inc instead.
Comment #10
lolandese commentedAnother one is the repeating of identical code snippets. We could create functions for this in flickr.inc.
An example:
Comment #12
lolandese commentedTo solve #9.
http://drupalcode.org/project/flickr.git/commitdiff/82c2e8b
Comment #14
lolandese commentedSolved #10.
http://drupalcode.org/project/flickr.git/commitdiff/f80fb11
Comment #15
lolandese commentedComment #16
lolandese commentedSee also https://drupal.org/node/383792#comment-8684683 to unify rendering functions even more and as a bonus offer new features.
Comment #17
lolandese commentedComment #18
lolandese commentedIn #2253641: Extend parameters for group and user IDs. we reduced over 10 functions from flickr_block.module to 3 that moved to flickr.inc because Flickr Filter uses then now as well. The new functions are:
Note that the function names are as before but with _block, _random and _recent being removed.
We could reduce them to just one 'super' function _flickr_album(), using a switch statement that produces an array of queried Flickr media ($response based on ID), filters by tags (and for groups by media type) if found (probably using http://www.php.net/manual/en/function.array-filter.php ?), outputs the images, generates a counter if set and caches the whole bunch with a unique key if the calling function is a Flickr Block (not necessary for Flickr Filter as a node body is cached anyway).
Comment #20
lolandese commented#18 is fixed in http://drupalcode.org/project/flickr.git/commitdiff/a294347.
Comment #21
lolandese commentedComment #22
lolandese commented5 files changed, 86 insertions(+), 134 deletions(-)
Combined 3 filter callbacks into 1.
Comment #24
lolandese commentedNow that we have the function _flickr_album() that generates albums for Flickr Filter and Flickr Block, we could possibly extend this for albums displayed on user profiles as well.
It would solve #2171289: Extend Colorbox/Lightbox support to User Profiles. It can only be done after solving #2096881: Use a pager on a embedded photoset in the body (thus 'postponed') as this functionality is already present on profiles. We might even borrow some code for it from there.
Comment #26
lolandese commentedAttached patch:
Comment #28
lolandese commentedNot to forget #24.
Furthermore some functions have grown too big over time. An example is function _flickr_album() in flickr.inc that consists of almost 1000 lines of code. Some parts of it could be moved into other functions, for example where a link to the Flickr page with the results similar to the album is created.
Each function should perform a specific task. If within that task you find a part that could be a task on itself that might in the future be useful to be called from other function as well, then move it out of the main task (function) and call it from there. It probably facilitates also a D8 port that will likely use classes where appropriate. That follows this principle even more in the form of 'extends' where parent variables can be inherited.
Comment #29
lolandese commentedDone in #2457275: Match Flickr results exactly when linking to Flickr in the album title and footer.
Comment #30
lolandese commentedWe could additionally try to convert some appropriate functions (album and photo constructs) into classes, also as preparation for a D8 port.
Comment #31
lolandese commentedToo much markup in the module now. To do some refactoring to use theme functions and/or templates instead.
Comment #32
lolandese commentedComment #33
lolandese commented