Yourls plugin to expand urls prefixed with a certain keyword
http://short.url/prefix-foo-bar
could be turned intohttp://my.long.url/whatever/foo-bar
http://short.url/date-161231
could be turned intohttp://my.long.url/events/2016-12-31
http://short.url/just-a-title
could be turned intohttp://my.long.url/just/?next=a&word=title
All configuration takes place in the plugin.yaml file.
Processing will take part in four stages:
- The url keyword will be passed through a number of definable text replacements. These can be found in the
replacements
section in plugin.yaml. Each element in the list there takes two configurations:find
andreplace
. - The correct configuration will be determined by matching the start of the url keyword to one of the
prefix
definitions underprefixes
in plugin.yaml. The prefix will then be cut off from the keyword. - The rest of the keyword will be processed according to the further configuration for this prefix:
- If the prefix has a
split
configuration set, the delimiter defined there will be used to split the keywords into parts. - If the prefix has a
subparts
section, all elements listed there will be used asstart: length
parameters for PHP'ssubstr()
function and a list of parts will be created accordingly. - If nothing like the above is defined, the keyword will remain one single part.
- A long url will be constructed by inserting the above keyword or its parts into the prefix's
url
through PHP'ssprintf()
function.
Have a look at the enclosed plugin.yaml for some examples.
Christoph Fischer (@potofcoffee, [email protected]) for Volksmission Freudenstadt (@VolksmissionFreudenstadt, http://www.volksmission-freudenstadt.de)