aelvan / stamp-craft Goto Github PK
View Code? Open in Web Editor NEWPlugin for adding timestamp to filenames.
License: MIT License
Plugin for adding timestamp to filenames.
License: MIT License
Just curious if this plugin is compatible with Craft 4 or if there are plans to update it?
So this plugin seems awesome and exactly what I need it for. It works perfectly in my local build. But as soon as I push everything to the server. My CSS and JS breaks and I get 404s on the files. I tried adding the stuff in the .htaccess but no luck - still gives me 404 errors on those versioned files and also gives me 404 errors on other files that don't even use craft.stamp.er.
HTML
<link rel="stylesheet" href="{{ craft.stamp.er('/assets/css/style.css') }}">
OUTPUT
<link rel="stylesheet" href="/assets/css/style.1559499637.css">
OPEN STYLESHEET IN NEW TAB
Error 404 page
HTACCESS
<IfModule mod_expires.c>
# 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
</IfModule>
Hi,
I did not try your code, but looking at it helped me for my project (thanks). I am wondering if the hash function wouldnt make more sense to always return 10 digits. Sometimes it returns 9 or 11:
https://github.com/aelvan/Stamp-Craft/blob/craft3/src/variables/StampVariable.php#L76
This is my current solution to this:
private function num_hash_file($filePath)
{
$crc = implode(unpack('C*', hash_file('crc32b', $filePath, true)));
return substr(str_pad($crc, 10, '0', STR_PAD_LEFT), 0, 10);
}
My English site works perfectly, but my new French section does not.
None of the CSS or JS files are found.
The only hack I could figure out is to add this ../ before my stylesheet for FR assets because my url for french is www.website.com/fr/
Can you explain more in-depth the stamp.php and the publicRoot. I tried it but didn't seem to work. It actually broke both the EN and FR site.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.