summaryrefslogtreecommitdiffstats
path: root/transform
AgeCommit message (Collapse)Author
2015-05-25Apply gofmt -sbep
2015-05-16Add support for URLs relative to context rootbep
Setting `RelativeURLs` to `true` will make all relative URLs in the site *really* relative. And will do so with speed. So: In `/post/myblogpost.html`: `/mycss.css` becomes `../mycss.css` The same in `/index.html` will become: `./mycss.css` etc. Note that absolute URLs will not be touched (either external resources, or URLs constructed with `BaseURL`). The speediness is about the same as before: ``` benchmark old ns/op new ns/op delta BenchmarkAbsURL 17462 18164 +4.02% BenchmarkAbsURLSrcset 18842 19632 +4.19% BenchmarkXMLAbsURLSrcset 18643 19313 +3.59% BenchmarkXMLAbsURL 9283 9656 +4.02% benchmark old allocs new allocs delta BenchmarkAbsURL 24 28 +16.67% BenchmarkAbsURLSrcset 29 32 +10.34% BenchmarkXMLAbsURLSrcset 27 30 +11.11% BenchmarkXMLAbsURL 12 14 +16.67% benchmark old bytes new bytes delta BenchmarkAbsURL 3154 3404 +7.93% BenchmarkAbsURLSrcset 2376 2573 +8.29% BenchmarkXMLAbsURLSrcset 2569 2763 +7.55% BenchmarkXMLAbsURL 1888 1998 +5.83% ``` Fixes #1104 Fixes #622 Fixes #937 Fixes #157
2015-05-12Add data-no-instant to livereload script tagbep
To support instantclick. Fixes #1135
2015-05-04Polish absurlreplacerbep
2015-05-04Rename field i to the more descriptive idxbep
2015-05-03absurlreplacer: remove superfluous code, take 2bep
``` benchmark old ns/op new ns/op delta BenchmarkAbsURL 17946 17454 -2.74% BenchmarkAbsURLSrcset 19236 18979 -1.34% BenchmarkXMLAbsURLSrcset 19046 18688 -1.88% BenchmarkXMLAbsURL 9561 9432 -1.35% benchmark old allocs new allocs delta BenchmarkAbsURL 24 24 +0.00% BenchmarkAbsURLSrcset 29 29 +0.00% BenchmarkXMLAbsURLSrcset 27 27 +0.00% BenchmarkXMLAbsURL 12 12 +0.00% benchmark old bytes new bytes delta BenchmarkAbsURL 3139 3139 +0.00% BenchmarkAbsURLSrcset 2374 2369 -0.21% BenchmarkXMLAbsURLSrcset 2574 2572 -0.08% BenchmarkXMLAbsURL 1871 1871 +0.00% ``` See #1059
2015-05-03absurlreplacer: remove superfluous codebep
``` benchmark old ns/op new ns/op delta BenchmarkAbsURL 18381 17946 -2.37% BenchmarkAbsURLSrcset 19531 19236 -1.51% BenchmarkXMLAbsURLSrcset 19316 19046 -1.40% BenchmarkXMLAbsURL 9818 9561 -2.62% benchmark old allocs new allocs delta BenchmarkAbsURL 24 24 +0.00% BenchmarkAbsURLSrcset 29 29 +0.00% BenchmarkXMLAbsURLSrcset 27 27 +0.00% BenchmarkXMLAbsURL 12 12 +0.00% benchmark old bytes new bytes delta BenchmarkAbsURL 3139 3139 +0.00% BenchmarkAbsURLSrcset 2354 2374 +0.85% BenchmarkXMLAbsURLSrcset 2584 2574 -0.39% BenchmarkXMLAbsURL 1864 1871 +0.38% ``` See #1059
2015-05-03Add benchmark tests for srcset handlingbep
See #1059
2015-05-03Fix testdata: srcset items should be comma separated, according to specbep
See #1059
2015-05-03canonifyurls in srcsetbep
Speed is about the same as before, uses slightly less memory: ``` benchmark old ns/op new ns/op delta BenchmarkAbsURL 17302 17713 +2.38% BenchmarkXMLAbsURL 9463 9470 +0.07% benchmark old allocs new allocs delta BenchmarkAbsURL 28 24 -14.29% BenchmarkXMLAbsURL 14 12 -14.29% benchmark old bytes new bytes delta BenchmarkAbsURL 3422 3144 -8.12% BenchmarkXMLAbsURL 1985 1864 -6.10% ``` Fixes #1059
2015-05-01absurl: export a base url var for testingbep
2015-04-01Make contentTransformer names consistentbep
2015-03-19Format docsbep
2015-03-19Rename interface contentRewriter to contentTransformerbep
Is is a much better name.
2015-03-18transform: remove some superfluous int conversionsbep
2015-03-18Remove URL param from exported AbsURL methodsbep
This is to make it clear that there is only one URL in play, the BaseURL.
2015-03-18Un-export ContentReWriterbep
2015-03-18Write to rotating ContentReWriter in transformer chainbep
This commit adds the interface ContentReWriter in the tranformer chain. This is backed by two pooled byte buffers, alternating between being the reader or the writer. This keeps the performance characteristic of the old implementation, but in a thread safe way. Fixes #911 Benchmark old vs new: benchmark old ns/op new ns/op delta BenchmarkAbsURL 17614 17384 -1.31% BenchmarkXMLAbsURL 9431 9248 -1.94% benchmark old allocs new allocs delta BenchmarkAbsURL 24 28 +16.67% BenchmarkXMLAbsURL 12 14 +16.67% benchmark old bytes new bytes delta BenchmarkAbsURL 3295 3424 +3.92% BenchmarkXMLAbsURL 1954 1987 +1.69%
2015-03-18More initialism corrections (golint)Anthony Fok
Thanks to @bep's new, brilliant helpers.Deprecated() function, the following functions or variables are transitioned to their new names, preserving backward compatibility for v0.14 and warning the user of upcoming obsolescence in v0.15: * .Url → .URL (for node, menu and paginator) * .Site.BaseUrl → .Site.BaseURL * .Site.Indexes → .Site.Taxonomies * .Site.Recent → .Site.Pages * getJson → getJSON * getCsv → getCSV * safeHtml → safeHTML * safeCss → safeCSS * safeUrl → safeURL Also fix related initialisms in strings and comments. Continued effort in fixing #959.
2015-03-11Correct initialisms as suggested by golintAnthony Fok
First step to use initialisms that golint suggests, for example: Line 116: func GetHtmlRenderer should be GetHTMLRenderer as see on http://goreportcard.com/report/spf13/hugo Thanks to @bep for the idea! Note that command-line flags (cobra and pflag) as well as struct fields like .BaseUrl and .Url that are used in Go HTML templates need more work to maintain backward-compatibility, and thus are NOT yet dealt with in this commit. First step in fixing #959.
2015-03-10absurlreplacer: write replacements directly to the byte bufferbep
The extra step isn't needed and this makes the code simpler. And slightly faster: benchmark old ns/op new ns/op delta BenchmarkAbsUrl 19987 17498 -12.45% BenchmarkXmlAbsUrl 10606 9503 -10.40% benchmark old allocs new allocs delta BenchmarkAbsUrl 28 24 -14.29% BenchmarkXmlAbsUrl 14 12 -14.29% benchmark old bytes new bytes delta BenchmarkAbsUrl 3512 3297 -6.12% BenchmarkXmlAbsUrl 2059 1963 -4.66%
2015-02-18Return unmodified content if panic in LiveReloadInjectbep
2015-02-18Add revocer in LiveReloadInjectbep
The panic cannot be reproduced, but add this as protection. Fixes #911
2015-02-17Fix canonifyurl vs schemaless linksbep
And looks even faster: Compared to previous attempt: benchmark old ns/op new ns/op delta BenchmarkAbsUrl 30902 27206 -11.96% BenchmarkXmlAbsUrl 15389 14216 -7.62% benchmark old allocs new allocs delta BenchmarkAbsUrl 33 28 -15.15% BenchmarkXmlAbsUrl 16 14 -12.50% benchmark old bytes new bytes delta BenchmarkAbsUrl 4167 3504 -15.91% BenchmarkXmlAbsUrl 2057 2048 -0.44% Compared to before I started all of this: benchmark old ns/op new ns/op delta BenchmarkAbsUrl 36219 27206 -24.88% BenchmarkXmlAbsUrl 23903 14216 -40.53% benchmark old allocs new allocs delta BenchmarkAbsUrl 60 28 -53.33% BenchmarkXmlAbsUrl 30 14 -53.33% benchmark old bytes new bytes delta BenchmarkAbsUrl 5842 3504 -40.02% BenchmarkXmlAbsUrl 3754 2048 -45.44% Fixes #816
2015-02-16Improve abs url replacement speedbep
This commit replaces the multuple `bytes.Containts` and `bytes.Replace` with a custom replacer that does one pass through the document and exploits the fact that there are two common prefixes we search for, `src=` and `href=`. This is both faster and consumes less memory. There may be even better algos to use here, but we must leave some room for improvements for future versions. This should also make it possible to solve #816. ``` benchmark old ns/op new ns/op delta BenchmarkAbsUrl 25795 22597 -12.40% BenchmarkXmlAbsUrl 17187 11166 -35.03% benchmark old allocs new allocs delta BenchmarkAbsUrl 60 33 -45.00% BenchmarkXmlAbsUrl 30 16 -46.67% benchmark old bytes new bytes delta BenchmarkAbsUrl 5844 4167 -28.70% BenchmarkXmlAbsUrl 3754 2069 -44.89% ``` Fixes #894
2015-02-16Add benchmark for AbsUrlInXmlbep
And a general test cleanup in /transform. See #894
2015-01-30transform chain using BBPspf13
2014-12-26Add ability to canonify URLs in rendered XML output.Ryan Martinsen
2014-11-17Removing dependency on go-html-transform (fixing the build).spf13
2014-05-28Fixed #301. LiveReload works on any port now.spf13
2014-05-16Proper integration of live reload with automatic injectionspf13
2014-01-13Add `canonifyurls` config option.Phil Pennock
Be able to inhibit AbsURL canonicalization of content, on a site configuration basis. Advantages of being able to inhibit this include making it easier to rendering on other hostnames, and being able to include resources on http or https depending on how this page was retrieved, avoiding mixed-mode client complaints without adding latency for plain http.
2013-12-16GofmtCaleb Spare
Command: `gofmt -l -s -w .`
2013-11-09Handle schema-less urls when apply absurlNoah Campbell
Fixes #114
2013-11-09fixing double slash during absurlifyspf13
2013-11-05Remove the hugo-nav functionNoah Campbell
Remove the hugo-nav since it relied on a slow library. The current build reimplements the absurl functionality based on string replace. Discovered that my prior implementation missed the requirement for making absolute paths (/path) absolute with the host, whereas a relative path is left untouched. Updated the test cases to support this if this is reimplemented.
2013-11-01Improve rendering timeNoah Campbell
50% speedup. Fix #91 to run the benchmark: go test -test.run=NONE -bench=".*" -test.benchmem=true ./transform/ > new.txt to compare the results: /usr/local/go/misc/benchcmp baseline.txt new.txt Speedup and memory improvements benchmark old ns/op new ns/op delta BenchmarkChain 101219 50453 -50.15% BenchmarkTransform 51625 45531 -11.80% benchmark old allocs new allocs delta BenchmarkChain 222 103 -53.60% BenchmarkTransform 135 106 -21.48% benchmark old bytes new bytes delta BenchmarkChain 23919 10998 -54.02% BenchmarkTransform 11858 10665 -10.06%
2013-11-01Adding benchmark for transformation module.Noah Campbell
2013-10-08Code cleanupNoah Campbell
2013-10-08Change the order of Apply to be more UnixyNoah Campbell
Typically the destination is on the left and the src is on the right.
2013-10-08Chain transformers and test casesNoah Campbell
Transformers can now be chained together, working on the output of the previous run.
2013-10-08Move AbsURL into seperate fileNoah Campbell
2013-10-08Rename Transform to AbsURLNoah Campbell
2013-10-08Set the name of the Nav attribute to selectNoah Campbell
2013-09-28Add the ability to set navbar li class to activeNoah Campbell
First cut at doing post html processing. This utility can be used to mark pages as active.
2013-09-18Fix fragments being AbsUrlified in final htmlNoah Campbell
Found that fragments were getting the BaseURL applied creating a proper anchor url and redirecting off the page.
2013-09-18Fix parsing edge case of frontmatterNoah Campbell
When the frontmatter contains a - (or other delimiter) close to the closing frontmatter delimiter, frontmatter detection would fail.
2013-09-17Move AbUrlify to post content transformationNoah Campbell
Currently the a@href and script@src elements will have BaseUrl applied to their elements prior to being written to disk.
2013-09-17Add a transform stepNoah Campbell
This allows for the manipulation of the DOM. This is expected to be applied after the templates are rendered.