summaryrefslogtreecommitdiffstats
path: root/resource
AgeCommit message (Collapse)Author
2018-05-26Enhance Page and Resource String()Vas Sudanagunta
2018-04-19Add language merge support for Pages in resource.ResourcesBjørn Erik Pedersen
Fixes #4644
2018-04-15resource: Implement Resource.ContentBjørn Erik Pedersen
Fixes #4622
2018-04-02Add support for a content dir set per languageBjørn Erik Pedersen
A sample config: ```toml defaultContentLanguage = "en" defaultContentLanguageInSubdir = true [Languages] [Languages.en] weight = 10 title = "In English" languageName = "English" contentDir = "content/english" [Languages.nn] weight = 20 title = "På Norsk" languageName = "Norsk" contentDir = "content/norwegian" ``` The value of `contentDir` can be any valid path, even absolute path references. The only restriction is that the content dirs cannot overlap. The content files will be assigned a language by 1. The placement: `content/norwegian/post/my-post.md` will be read as Norwegian content. 2. The filename: `content/english/post/my-post.nn.md` will be read as Norwegian even if it lives in the English content folder. The content directories will be merged into a big virtual filesystem with one simple rule: The most specific language file will win. This means that if both `content/norwegian/post/my-post.md` and `content/english/post/my-post.nn.md` exists, they will be considered duplicates and the version inside `content/norwegian` will win. Note that translations will be automatically assigned by Hugo by the content file's relative placement, so `content/norwegian/post/my-post.md` will be a translation of `content/english/post/my-post.md`. If this does not work for you, you can connect the translations together by setting a `translationKey` in the content files' front matter. Fixes #4523 Fixes #4552 Fixes #4553
2018-03-20Bump some deprecationsBjørn Erik Pedersen
2018-03-14resource: Fix path duplication/flattening in processed imagesBjørn Erik Pedersen
Fixes #4502 Closes #4501
2018-02-27resource: Fix SVG and similar resource handlingBjørn Erik Pedersen
The validation of if we could process the image (resize etc.) was moved up in Hugo 0.37, which meant SVG and other "non-processable" images would fail. This commit fixes that by creating a regular resource for these image formats. They will not have `.Resize` or any of the other image methods. Fixes #4455
2018-02-26resource: Use Floyd-Steinberg dithering for PNGsBjørn Erik Pedersen
Fixes #4453
2018-02-21Run gofmt -s with Go 1.10Bjørn Erik Pedersen
See #4434
2018-02-19resource: Preserve color palette for PNG imagesBjørn Erik Pedersen
This commit will force a reprocessing of PNG images with new names, so it is adviced to run a `hugo --gc` to remove stale files. Fixes #4416
2018-02-14resource: Fix multi-threaded image processing issueBjørn Erik Pedersen
When doing something like this with the same image from a partial used in, say, both the home page and the single page: ```bash {{ with $img }} {{ $big := .Fill "1024x512 top" }} {{ $small := $big.Resize "512x" }} {{ end }} ``` There would be timing issues making Hugo in some cases try to process the same image with the same instructions in parallel. You would experience errors of type: ```bash png: invalid format: not enough pixel data ``` This commit works around that by adding a mutex per image. This should also improve the performance, sligthly, as it avoids duplicate work. The current workaround before this fix is to always operate on the original: ```bash {{ with $img }} {{ $big := .Fill "1024x512 top" }} {{ $small := .Fill "512x256 top" }} {{ end }} ``` Fixes #4404
2018-02-13resource: Improve error processing error messageBjørn Erik Pedersen
2018-02-05resource: Add smart croppingBjørn Erik Pedersen
This commit `smart` as a new and default anchor in `Fill`. So: ```html {{ $image.Fill "200x200" }} ``` Is, with default configuration, the same as: ```html {{ $image.Fill "200x200" "smart" }} ``` You can change this default in your `config.toml`: ```toml [imaging] [imaging] resampleFilter = "box" quality = 68 anchor = "Smart" ``` Fixes #4375
2018-01-29resource: Make resource counters for name and title independentBjørn Erik Pedersen
This is the most flexible with the current syntax, and probably what most people would expcect. Updates #4335
2018-01-27resource: Start Resources :counter first time they're usedBjørn Erik Pedersen
This is less surprising and more flexible than the original implementation. Given: ```toml [[resources]] src = "documents/photo_specs.pdf" title = "Photo Specifications" [[resources]] src = "**.pdf" name = "pdf-file-:counter" ``` Every `pdf` in the bundle will have an unique counter, but the `photo_specs.pdf` is still allowed to have its specific `title`. If you change the above example to: ```toml [[resources]] src = "documents/*specs.pdf" title = "Photo Specifications #:conter" [[resources]] src = "**.pdf" name = "pdf-file-:counter" ``` We are talking about two different groups of documents, each with its own counters starting at 1. Fixes #4335
2018-01-24resource: Fix typo in commentAlexey Grachov
2018-01-23Merge matching resources params mapsBjørn Erik Pedersen
This allows setting default params values in the more general resource matchers. I also allows override with more specific values if needed. ```toml [[resources]] src = "documents/photo_specs.pdf" title = "Photo Specifications" [resources.params] ref = 90564687 icon = "photo" [[resources]] src = "documents/guide.pdf" title = "Instruction Guide" [resources.params] ref = 90564568 [[resources]] src = "documents/checklist.pdf" title = "Document Checklist" [resources.params] ref = 90564572 [[resources]] src = "documents/payment.docx" title = "Proof of Payment" [[resources]] src = "documents/*.pdf" title = "PDF file" [resources.params] icon = "pdf" [[resources]] src = "documents/*.docx" title = "Word document" [resources.params] icon = "word" ``` In the above `TOML` example, `photo_specs.pdf` will get the `photo` icon, the other pdf files will get the default `pdf` icon. Note that in the example above, the order matters: It will take the first value for a given params key, title or name that it finds. Fixes #4315
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