All Projects → aelvan → Stamp-Craft

aelvan / Stamp-Craft

Licence: MIT License
Plugin for adding timestamp to filenames.

Programming Languages

PHP
23972 projects - #3 most used programming language

Projects that are alternatives of or similar to Stamp-Craft

Inlin-Craft
Plugin for inlining files in templates.
Stars: ✭ 64 (+128.57%)
Mutual labels:  craftcms, craftcms-plugin, craft3, craft2
craft-commerce-widgets
Insightful widgets for Craft CMS Commerce stores
Stars: ✭ 33 (+17.86%)
Mutual labels:  craftcms, craftcms-plugin, craft3, craft2
molecule
⚛️ Grab Twig components, CSS and JS files outside the primary template folder
Stars: ✭ 20 (-28.57%)
Mutual labels:  craftcms, craftcms-plugin, craft3
craft-entry-instructions
A simple fieldtype to add instructions.
Stars: ✭ 16 (-42.86%)
Mutual labels:  craftcms, craftcms-plugin, craft3
query
Run SQL queries as an admin from the Craft CMS control panel.
Stars: ✭ 14 (-50%)
Mutual labels:  craftcms, craft3, craft2
Form-Builder
Craft CMS plugin that lets you create and manage forms for your front-end.
Stars: ✭ 16 (-42.86%)
Mutual labels:  craftcms, craftcms-plugin, craft2
craft-audit
Audit log for Craft 3
Stars: ✭ 18 (-35.71%)
Mutual labels:  craftcms, craftcms-plugin, craft3
craft-react
Client and Server-side React rendering for CraftCMS
Stars: ✭ 40 (+42.86%)
Mutual labels:  craftcms, craftcms-plugin, craft3
store-hours
Manage business hours with Craft CMS.
Stars: ✭ 60 (+114.29%)
Mutual labels:  craftcms, craft3, craft2
craft3-fallback-site
Failing requests in a multi-site install can fall back to other sites, to prevent 404 errors from missing or disabled entries.
Stars: ✭ 14 (-50%)
Mutual labels:  craftcms, craftcms-plugin, craft3
Similar-Craft
Find similar elements
Stars: ✭ 32 (+14.29%)
Mutual labels:  craftcms, craftcms-plugin, craft2
craft-router
A Craft CMS plugin for using URL segments as filtering criteria on an entry query.
Stars: ✭ 21 (-25%)
Mutual labels:  craftcms, craft3, craft2
VarnishPurge-Craft
Craft plugin for purging Varnish when elements are saved.
Stars: ✭ 33 (+17.86%)
Mutual labels:  craftcms, craftcms-plugin, craft2
SecureAssetDownload
Craft CMS plugin for secure asset download URLs
Stars: ✭ 22 (-21.43%)
Mutual labels:  assets, craftcms, craftcms-plugin
craft3-collections
Clean up those complex templates with Laravel Collections
Stars: ✭ 24 (-14.29%)
Mutual labels:  craftcms, craftcms-plugin, craft3
anchors
Add anchor links to headings in your Craft CMS website content.
Stars: ✭ 47 (+67.86%)
Mutual labels:  craftcms, craft3, craft2
tags
A tag manager for Craft 3
Stars: ✭ 23 (-17.86%)
Mutual labels:  craftcms, craftcms-plugin, craft3
tablemaker
A user-definable table field type for Craft CMS
Stars: ✭ 39 (+39.29%)
Mutual labels:  craftcms, craftcms-plugin, craft3
visor
🕶 A simple admin overlay to get to the relevant areas of the Craft CMS control panel.
Stars: ✭ 25 (-10.71%)
Mutual labels:  craftcms, craftcms-plugin, craft3
seomate
SEO, mate! It's important. That's why SEOMate provides the tools you need to craft all the meta tags, sitemaps and JSON-LD microdata you need - in one highly configurable, open and friendly package - with a super-light footprint.
Stars: ✭ 31 (+10.71%)
Mutual labels:  craftcms, craft3

Stamp for Craft

A tiny plugin for adding timestamp to filenames.

This is the Craft 3.x version of Stamp, for the Craft 2.x version see the master branch.

Requirements

This plugin requires Craft CMS 3.0.0 or later.

Installation

To install the plugin, follow these instructions.

  1. Open your terminal and go to your Craft project:

     cd /path/to/project
    
  2. Then tell Composer to load the plugin:

     composer require aelvan/stamp
    
  3. In the Control Panel, go to Settings → Plugins and click the “Install” button for Stamp.

Usage

Use it like this:

<script src="{{ craft.stamp.er('/assets/build/js/scripts.js') }}"></script> 

Which results in:

<script src="https://github.com/assets/build/js/scripts.1399647655.js"></script>

The er() method takes a second parameter for setting the format of the output. Possible values are file (default), folder, query and tsonly.

Example with folder:

<script src="{{ craft.stamp.er('/assets/build/js/scripts.js', 'folder') }}"></script> 

Result:

<script src="https://github.com/assets/build/js/1399647655/scripts.js"></script>

Example with query:

<script src="{{ craft.stamp.er('/assets/build/js/scripts.js', 'query') }}"></script> 

Result:

<script src="https://github.com/assets/build/js/scripts.js?ts=1399647655"></script>

Example with only:

Timestamp is: {{ craft.stamp.er('/assets/build/js/scripts.js', 'only') }} 

Result:

Timestamp is: 1399647655

Hashing option

The craft.stamp.er() method takes a third parameter for setting the algorithm of the output. Possible values are ts (default), and hash.

ts stands for timestamp and behaves as shown above. hash gets the CRC32 checksum of the file instead of the timestamp. It's useful for cases when you need your cache busting to be fully deterministic.

For example:

<script src="{{ craft.stamp.er('/assets/build/js/scripts.js', 'file', 'hash') }}"></script>

Result:

<script src="https://github.com/assets/build/js/scripts.2031312059.js"></script>

URL rewriting

For methods file and folder you probably want to do some url rewriting. Below are some examples of how this can be done, adjust as needed for your server and project setup.

Apache:

# Rewrites asset versioning, ie styles.1399647655.css to styles.css.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.+)\.(\d{10})\.(js|css)$ $1.$3 [L]  # /assets/build/js/scripts.1399647655.js
# RewriteRule ^(.+)/(\d{10})/(.+)\.(js|css)$ $1/$3.$4 [L]  # /assets/build/js/1399647655/scripts.js

nginx:

location @assetversioning {
    rewrite ^(.+)\.[0-9]+\.(css|js)$ $1.$2 last;  # /assets/build/js/scripts.1399647655.js
    # rewrite ^(.+)/([0-9]+)/(.+)\.(js|css)$ $1/$3.$4 last;  # /assets/build/js/1399647655/scripts.js
}    

location ~* ^/assets/.*\.(?:css|js)$ {
    try_files $uri @assetversioning;
    expires max;
    add_header Pragma public;
    add_header Cache-Control "public, must-revalidate, proxy-revalidate";
}

Configuration

Stamp needs to know the public document root to know where your files are located. By default Stamp will use @webroot, but on some server configurations this is not the correct path. You can configure the path by creating a config file called stamp.php in your config folder, and adding the publicRoot setting.

Example

'publicRoot' => '/path/to/website/public/',

Changelog

See CHANGELOG.md.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].