Needs work
Project:
Libraries API
Version:
7.x-2.x-dev
Component:
Code
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
7 Nov 2010 at 22:57 UTC
Updated:
11 Jan 2019 at 14:29 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
tstoecklerWell, the easy way out would be to define a @version and a @variant placeholder, which could be used in filenames, and which would be automatically replaced by Libraries API.
There's 2 reasons, that's not enough, though:
1. Where does it end? Can filenames differ depending on their location (local and external/hosted versions)? Can they contain a date (e.g. the day that version was released)? In the end we need something pluggable.
2. The above fails already when e.g. the version is 1.4.3, but the filename is example-1-4-3.js
Comment #2
pillarsdotnet commentedI read the above and immediately thought:
But seriously, couldn't you allow a regex to convert the @version and @variant into a filename?
Comment #3
sunComment #4
tstoecklerNow that we have callbacks, this shouldn't be too hard.
This is related to the whole file traversing debate though, see #1224838: Fix the inconsistency between filenames as array keys and array values for example.
I didn't want to go into that here, so I just do
foreach($files as $filename => $options)Comment #5
tstoecklerWrong branch...
Comment #6
tstoecklerSame patch.
Comment #7
sunPer docs, this callback is invoked after the library has been detected. However, to detect a library with version or variant identifiers in its filename in the first place, the filename info needs to be adjusted in the pre-detect callback already.
I'm not sure whether this additional callback and automated replacement makes sense. Do we have a concrete use-case for this?
This issue mentions jQuery, but for that, we invented the pre-detect callback already, I think.
Comment #8
sunFYI: Interesting tidbit; the commit that introduced CDN support for jquery_update module:
http://drupalcode.org/project/jquery_update.git/blobdiff/8a3a09fe9cfd231...
Comment #9
polFYI: You can use external libraries from a CDN using Libraries API CDN that integrates itself with Libraries API.
Comment #10
chris matthews commentedThe 7 year old patch in #6 does not apply to the latest libraries 7.x-2.x-dev and if still applicable needs a reroll.