GitXplorerGitXplorer
r

statamic-earl

public
9 stars
0 forks
0 issues

Commits

List of commits on branch master.
Unverified
8290bd2e077dac05b0d0108acbd85452504263cd

GitHub markdown changes

rraygesualdo committed 10 years ago
Unverified
bc67fe3274e7819d6e0fe96317734ec50b9b9956

GitHub markdown changes

rraygesualdo committed 10 years ago
Unverified
5b22e013930218d522e573e0d19d04290dac3261

GitHub markdown changes

rraygesualdo committed 10 years ago
Unverified
9bf575447a7cc0c896f435e5dbe38c4f77c8ac63

v1.1 release

rraygesualdo committed 10 years ago
Unverified
30bc79fb6ae22109a8cf36b643c568970e8a8cb3

wrangle Earl

rraygesualdo committed 11 years ago
Unverified
b63ec2aedef5956a7c2f7c7d7f027f4932efc88d

changed download link to latest master

rraygesualdo committed 11 years ago

README

The README file for this repository.

#E.A.R.L.

The External Asset and Resource Linker Plugin for Statamic

UPDATED!!! E.A.R.L. has undergone a full rewrite with new features:

  • Define groups more easily {{ earl:mygroup }}
  • Allow unlimited attributes on genenerated tags
 

EarlHowdy y'all. Muh name's Earl. I do one thang an' one thang only: I help yuh link to external whirlygigs and thingamabobs from yer Statamic site. Have files on a CDN or some such nonsense that you need to link to? That's why yuh got me. I'll help yuh drop in simple tags that point to where you need. Sounds downright handy don't it? Well, that's cause it is.

But since I'm such a nice guy, I'll go the extra mile for yuh. I'll even let you define specific paths and file extensions you can use on demand. No more havin' to remember that really long URL some other knucklehead stores assets in everytime you want to link to a file.

I know yer interested. Keep on readin' down to learn how to use it.

 

##Installation

  1. Download or clone the plugin archive.
  2. Copy _add-ons/earl to _add-ons/earl
  3. Copy _config/add-ons/earl to _config/add-ons/earl

##Use Drop the {{ earl:method }} tag anywhere you want, where method is the config group E.A.R.L. will pull from.

###Parameters

  • src: File name; can include a path; defaults to the current theme name
  • tag: Determines if a tag should be included in output (See the Tag Values Matrix)
  • attr: Attributes to be added to corresponding tag, e.g. {{ earl:img attr="class:thumbnail|alt:This is the alt text" }}

###Tag Values Matrix

Value Output
js
script
scripts
javascript
<script src="https://raw.githubusercontent.com/raygesualdo/statamic-earl/master/"></script>
css
style
styles
stylesheet
<link href="https://raw.githubusercontent.com/raygesualdo/statamic-earl/master/" rel="stylesheet">
img
image
images
<img src="https://raw.githubusercontent.com/raygesualdo/statamic-earl/master/">
true <script src="https://raw.githubusercontent.com/raygesualdo/statamic-earl/master/"></script> or
<link href="https://raw.githubusercontent.com/raygesualdo/statamic-earl/master/" rel="stylesheet"> or
<img src="https://raw.githubusercontent.com/raygesualdo/statamic-earl/master/">

NOTE: Setting tag="true" is for backwards compatibility with theme-style helpers. Passing true will automatically assign the js, css or img methods (and only those methods) to their corresponding tag output e.g. {{ earl:js src="script.js" tag="true" }} outputs <script src="https://raw.githubusercontent.com/raygesualdo/statamic-earl/master/BASEPATH/GROUPPATH/script.js"></script>.

##Config The config file has two sections: general settings and config groups. The general settings section currently consists of only the _earl_base variable. This is where you can set the base URL for all links that E.A.R.L. builds. The base URL should begin with 'http', 'https' or '//'. If none of those strings are present (i.e. a bare URL), '//' will be prepended to the URL.

The config group section is where E.A.R.L. shines. Config groups allow you to set two different variables, one relating to the path and one relating to the extension. Let's take a look at the default settings for the JS group as an example:

_earl_path_js: 'path/to/js/files'
_earl_ext_js: '.js'

Notice how both variables end with _js. This determines the config group to which this variable belongs. You can leverage this to create config groups of your own and use them via the method you use.

I'll show you how this works. Assume you wanted to create a config group for some mp3 files. We would begin by adding the following variables to the config file:

_earl_path_audio: 'really/long/path/to/buried/audio/files'
_earl_ext_audio: '.mp3'

Next, we could use these settings by dropping in {{ earl:audio src="track01" }}. The resulting URL would be EARLBASEPATH/really/long/path/to/buried/audio/files/track01.mp3.

NOTE: Unless the extension of the files within a group will always stay the same (this may be the case e.g. javascript files), do not add an entry for the groups ext variable. Instead, include the extension in the src path.

##API Coming soon!


Many thanks to Adam Koford for graciously allowing me to use his art for the Earl character.