catcombo / go-staticfiles Goto Github PK
View Code? Open in Web Editor NEWCollects assets (css, js, images...) from a different locations and tags file names with a hash for easy versioning and aggressive caching.
License: MIT License
Collects assets (css, js, images...) from a different locations and tags file names with a hash for easy versioning and aggressive caching.
License: MIT License
I think a good plus would be the embedding of files in go with some of these projects: https://github.com/avelino/awesome-go/blob/master/README.md#resource-embedding.
None of those projects has an hashing system/strategy as far as I know.
This project is wonderful and it's something I would have done - sooner or later. So thank you again.
I'm trying to use it but I have some doubts.
You can find a reproduction of my project here: https://github.com/frederikhors/test_go_staticfiles
I'm using the amazing quicktemplate
but you can try it with go templates too.
You can find a Readme.md
in the project.
The branch master
is without go-staticfiles, my doubts are in branch staticfiles
.
You have a comparison here: https://github.com/frederikhors/test_go_staticfiles/compare/staticfiles?expand=1.
If I follow your usage instructions I change my code from this:
<link rel="stylesheet" href="/static/css/base.css"/>
to this:
<link rel="stylesheet" href="{%s StaticFilesPrefix + Storage.Resolve("css/base.css") %}"/>
but the result is:
<link rel="stylesheet" href="/static/"/>
instead of what I expect:
<link rel="stylesheet" href="/static/css/base.934823cbc67ccf0d67aa2a2eeb798f12.css"/>
I understand this is a problem with the generated .json manifest you create.
I need to use this:
<link rel="stylesheet" href="{%s StaticFilesPrefix + Storage.Resolve("web\\static\\css\\base.css") %}"/>
to get something from Storage.Resolve()
.
I think because the content of .json manifest is:
{"paths":{"web\\static\\css\\base.css":"web\\public\\web\\static\\css\\base.934823cbc67ccf0d67aa2a2eeb798f12.css"},"version":1}
Now the final html is:
<link rel="stylesheet" href="/static/web\public\web\static\css\base.934823cbc67ccf0d67aa2a2eeb798f12.css"/>
which is wrong again because my server is serving files from web/public/web/static
folder (and this is ugly itself) but on path http://localhost:3000/static
without the need for useless web\public\web\static\
.
And why the backslashes?
Maybe a problem or maybe it's me.
Thanks again.
This project is amazing.
We can add/suggest this project on sites or aggregators to make it grow in number of stars.
What do you think about?
I do suggest some sites:
I think we can add an env var to enable/disable staticfiles.
Particularly useful for development vs production.
Something like: STATIC_FILES_ENABLED=true/false
.
What do you think?
It would be amazing to change from this one:
favicon.01998662be09f970ca7aa8193a7a460c.ico
to:
favicon.8376ac71.ico
I think we do not need this very long hash. What do you think?
Is there already a way to exclude some files/folder?
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.