joomlatools / joomlatools-framework-files

Files System Component for Joomlatools Framework.
https://www.joomlatools.com/developer/framework/
GNU General Public License v3.0
1 stars 0 forks source link

Allow route overrides for direct linking through template filtering #50

Open amazeika opened 7 years ago

amazeika commented 7 years ago

The idea is to have a mechanism to override routes of direct file URLs served by files, e.g. thumbnails. This allows each app running files to override how this paths are constructed at render time.

An implementation example is rendering thumbnails link on FILEman on Joomla vs Platform. Platform requires the web part of the path to be stripped as it's part of the document root.

NOTE

This filter is to replace this utility method https://github.com/joomlatools/joomlatools-framework-files/blob/master/filter/path.php#L117-L128

Make sure to remove this code and places where this is being used after implementation.

johanjanssens commented 6 years ago

Proposed solution

Handle routing at render time by making use of the assets template filter. For inspiration check the code for the assets filter. It does the following:

'base://' => rtrim($this->getObject('request')->getBaseUrl()->getPath(), '/').'/'

See: https://github.com/joomlatools/joomlatools-framework/blob/master/code/libraries/joomlatools/component/koowa/template/filter/asset.php#L37

To create your own asset you can just use the core filter with the base:// scheme or another option could be to add an additional filter in com:files and introduce a file:// scheme, which would allow you to do additional processing.

You could do things like

file://container/path

Where file will be replaced by the url path, container by the container path and the path would be pre-pended. This would move the responsibility to create the url for the file to the filter, the cool thing about this is that it would make moving files into a CDN very simple, you just extend the filter to rewrite the paths differently.

amazeika commented 6 years ago

For reference:

https://github.com/joomlatools/joomlatools-framework-files/commit/3371499f7c9d517885f86bd60e3ff2881f4b8702