summaryrefslogtreecommitdiffstats
path: root/resource
AgeCommit message (Collapse)Author
2018-01-22resource: Avoid some strings.ToLower in globbingBjørn Erik Pedersen
See #4301
2018-01-22resource: Add Match and GetMatchBjørn Erik Pedersen
These methods takes a glob pattern as argument: * by default matching from the bundle root * matching is case insensitive and the separator is Unix style slashes: "/" * the bundle root does (by default) not start with a leading slash * if you renames the `Name` for the rsource in front matter (`src=...`), then that is the value used in `Match`. * double asterisk matches beyond directory borders, so "**.jpg" will match any JPEG image in the bundle See https://github.com/gobwas/glob This commit also deprecates `ByPrefix` and `GetByPrefix`. This should also be more effective, given a fair amount of reuse of the glob patterns: ```bash BenchmarkResourcesByPrefix-4 300000 4284 ns/op 1130 B/op 7 allocs/op BenchmarkResourcesMatch-4 300000 5220 ns/op 505 B/op 3 allocs/op ``` Fixes #4301
2018-01-17resource: Use path.Match instead of filepath.MatchBjørn Erik Pedersen
They behave similar, but it is a path we're matching. See #4244
2018-01-17resource: Add front matter metadata to ResourceBjørn Erik Pedersen
This commit expands the Resource interface with 3 new methods: * Name * Title * Params All of these can be set in the Page front matter. `Name` will get its default value from the base filename, and is the value used in the ByPrefix and GetByPrefix lookup methods. Fixes #4244
2018-01-15resource: Fix handling of very long image file namesBjørn Erik Pedersen
Fixes #4261
2018-01-13resource: Add some GoDocBjørn Erik Pedersen
2018-01-12resource: Implement Resources.ByPrefixBjørn Erik Pedersen
Fixes #4266
2018-01-12resource: Make GetByPrefix work for Page resourcesBjørn Erik Pedersen
Fixes #4264
2018-01-11resource: Make .Resources.GetByPrefix case insensitiveBjørn Erik Pedersen
Fixes #4258
2018-01-11resource: Remove superflous commentBjørn Erik Pedersen
2018-01-10Fix non-ASCII path handling for Page resourcesBjørn Erik Pedersen
Fixes #4241
2018-01-07resource: Avoid processing and storing same image for each languageBjørn Erik Pedersen
Fixes #4231
2018-01-07resource: Resources.ByType should return ResourcesBjørn Erik Pedersen
Currently it returns []Resource. This way the invocations can be nested. Fixes #4234
2018-01-06Fix URLs for bundle resources in multihost modeBjørn Erik Pedersen
Fixes #4217
2018-01-06Fix sub-folder baseURL handling for Page resourcesBjørn Erik Pedersen
I.e. images etc. Fixes #4228
2018-01-03resource: Handle publish to /public on fresh buildBjørn Erik Pedersen
Fixes #4213
2018-01-01resource: Use the correct Destination FSBjørn Erik Pedersen
Source and destination will be the same when this happens, but it should be correct. See #4202
2018-01-01resource: Create target dir if not existsBjørn Erik Pedersen
This is the case where image processing is triggered from shortcodes, i.e. before the target page's folder in /public is created. Fixes #4202
2017-12-28resource: Avoid potential case issue in image namesBjørn Erik Pedersen
2017-12-28helpers: Avoid writing the last MD5 buff part twiceBjørn Erik Pedersen
2017-12-28resource: Use MD5 to identify image filesBjørn Erik Pedersen
But only a set of byte chunks spread around in the image file to calculate the fingerprint, which is much faster than reading the whole file: ```bash BenchmarkMD5FromFileFast/full=false-4 300000 4356 ns/op 240 B/op 5 allocs/op BenchmarkMD5FromFileFast/full=true-4 30000 42899 ns/op 32944 B/op 5 allocs/op ``` Fixes #4186
2017-12-27:sparkles: Implement Page bundling and image handlingBjørn Erik Pedersen
This commit is not the smallest in Hugo's history. Some hightlights include: * Page bundles (for complete articles, keeping images and content together etc.). * Bundled images can be processed in as many versions/sizes as you need with the three methods `Resize`, `Fill` and `Fit`. * Processed images are cached inside `resources/_gen/images` (default) in your project. * Symbolic links (both files and dirs) are now allowed anywhere inside /content * A new table based build summary * The "Total in nn ms" now reports the total including the handling of the files inside /static. So if it now reports more than you're used to, it is just **more real** and probably faster than before (see below). A site building benchmark run compared to `v0.31.1` shows that this should be slightly faster and use less memory: ```bash ▶ ./benchSite.sh "TOML,num_langs=.*,num_root_sections=5,num_pages=(500|1000),tags_per_page=5,shortcodes,render" benchmark old ns/op new ns/op delta BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 101785785 78067944 -23.30% BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 185481057 149159919 -19.58% BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 103149918 85679409 -16.94% BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 203515478 169208775 -16.86% benchmark old allocs new allocs delta BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 532464 391539 -26.47% BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 1056549 772702 -26.87% BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 555974 406630 -26.86% BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 1086545 789922 -27.30% benchmark old bytes new bytes delta BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 53243246 43598155 -18.12% BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 105811617 86087116 -18.64% BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4 54558852 44545097 -18.35% BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4 106903858 86978413 -18.64% ``` Fixes #3651 Closes #3158 Fixes #1014 Closes #2021 Fixes #1240 Updates #3757