summaryrefslogtreecommitdiffstats
path: root/helpers/url.go
AgeCommit message (Collapse)Author
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
2017-12-29commands: Make sure all language homes are always re-rendered in fast render ↵Bjørn Erik Pedersen
mode Fixes #4125
2017-03-27output: Rename HTMLType etc. to HTMLFormatBjørn Erik Pedersen
2017-03-27Remove the now superflous defaultExtensionBjørn Erik Pedersen
And some other unsed fields and methods.
2017-03-27Add custom protocol support in PermalinkBjørn Erik Pedersen
2017-03-27hugolib: Refactor/-work the permalink/target path logicBjørn Erik Pedersen
This is a pretty fundamental change in Hugo, but absolutely needed if we should have any hope of getting "multiple outputs" done. This commit's goal is to say: * Every file target path is created by `createTargetPath`, i.e. one function for all. * That function takes every page and site parameter into account, to avoid fragile string parsing to uglify etc. later on. * The path creation logic has full test coverage. * All permalinks, paginator URLs etc. are then built on top of that same logic. Fixes #1252 Fixes #2110 Closes #2374 Fixes #1885 Fixes #3102 Fixes #3179 Fixes #1641 Fixes #1989
2017-03-02helpers: Return partially cleaned URL in case of error in URLPrep anywayBjørn Erik Pedersen
Closes #2987
2017-02-17all: Refactor to nonglobal Viper, i18n etc.Bjørn Erik Pedersen
This is a final rewrite that removes all the global state in Hugo, which also enables the use if `t.Parallel` in tests. Updates #2701 Fixes #3016
2017-01-02commands, helpers: Fix docsbogem
2016-11-27hugolib: Fix regressions with uglyURLsBjørn Erik Pedersen
Fixes #2734
2016-11-22all: Use jww instead of fmt for printingbogem
This is an attempt to unify method for printing.
2016-11-05helpers: Golint fixesBjørn Erik Pedersen
2016-10-24all: Unify case of config variable namesAlbert Nigmatzianov
All config variables starts with low-case and uses camelCase. If there is abbreviation at the beginning of the name, the whole abbreviation will be written in low-case. If there is abbreviation at the end of the name, the whole abbreviation will be written in upper-case. For example, rssURI.
2016-10-24Avoid reading from Viper for path and URL funcsBjørn Erik Pedersen
The gain, given the "real sites benchmark" below, is obvious: ``` benchmark old ns/op new ns/op delta BenchmarkHugo-4 14497594101 13084156335 -9.75% benchmark old allocs new allocs delta BenchmarkHugo-4 57404335 48282002 -15.89% benchmark old bytes new bytes delta BenchmarkHugo-4 9933505624 9721984424 -2.13% ``` Fixes #2495
2016-09-13helpers: Improve the language prefix logicBjørn Erik Pedersen
See #2444
2016-09-13helpers: Avoid adding language prefix if already presentBjørn Erik Pedersen
Fixes #2444
2016-09-06Fix YAML loading of multilingual configBjørn Erik Pedersen
And some other minor fixes from code review. Updates #2309
2016-09-06Render main content language in root by defaultBjørn Erik Pedersen
Fixes #2312
2016-09-06Multilingual TODO-fixes, take 1Bjørn Erik Pedersen
See #2309
2016-09-06Improve language handling in URLsBjørn Erik Pedersen
The current "rendering language" is needed outside of Site. This commit moves the Language type to the helpers package, and then used to get correct correct language configuration in the markdownify template func. This commit also adds two new template funcs: relLangURL and absLangURL. See #2309
2016-09-06Optimize the multilanguage build processBjørn Erik Pedersen
Work In Progress! This commit makes a rework of the build and rebuild process to better suit a multi-site setup. This also includes a complete overhaul of the site tests. Previous these were a messy mix that were testing just small parts of the build chain, some of it testing code-paths not even used in "real life". Now all tests that depends on a built site follows the same and real production code path. See #2309 Closes #2211 Closes #477 Closes #1744
2016-08-18docs: Correct all erroneous swaps of "it's" and "its"Mark D. Blackwell
2016-04-27helpers: Use net/url for URL parsing in AbsURLCameron Moore
Fixes #2112
2016-03-24helpers: Apply GoLint rulesdigitalcraftsman
2016-03-10Make absURL properly handle baseURL with path componentMarek Janda
2016-01-04Fix /.xml RSSLink when uglyurls are enabledJohn McFarlane
Prior to this commit the root url with uglyurls enabled is "/.xml". This commit relates to #175.
2015-12-07Fix copyright headers in source filesBjørn Erik Pedersen
Still need to add some missing headers and an AUTHORS file. See #1646
2015-11-23Change the license to Apache 2.0Steve Francia
2015-11-22Fix missing word in code comment (my own fault)Anthony Fok
2015-10-15Rename prettiyPath to prettifyPathBjørn Erik Pedersen
2015-10-14Unexport internal path helperBjørn Erik Pedersen
2015-09-01Add config option "disablePathToLower"chrongzhang
Enabling this prevents lowercasing of the path/url. Fixes #557
2015-08-26Unexport FileAndExtBjørn Erik Pedersen
If needed outside helpers, create an exported file path (FilePathAndExt?) and/or a url version.
2015-05-25Unexport filepath/path bridge typesbep
They are of no use outside the helpers package. See #1160
2015-05-11Add relURL template funcbep
Fixes #1126
2015-05-11Add absURL template funcbep
Fixes #1106
2015-05-05Do not add trailing slash to baseURLbep
Fixes #1105
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-07helpers: apply some Golint rulesbep
2015-02-28Keep trailing slash when baseUrl contains a sub pathbep
Before this commit, .Site.BaseUrl ended up as: http://mysite.com/ => http://mysite.com/ http://mysite.com/sub/ => http://mysite.com/sub Now it becomes: http://mysite.com/ => http://mysite.com/ http://mysite.com/sub/ => http://mysite.com/sub/ Fixed #931
2015-02-17Adapt to relative path bug fix in purellAnthony Fok
Temporary workaround for the bug fix and resulting behavioral change in purell.NormalizeURLString(): a leading '/' was inadvertently to relative links, but no longer, see #878. I think the real solution is to allow Hugo to make relative URL with relative path, e.g. "../../post/hello-again/", as wished by users in issues #157, #622, etc., without forcing relative URLs to begin with '/'. Once the fixes are in, let's remove this kludge and restore SanitizeUrl() to the way it was. Fixes #878
2015-01-28ignore root path, no need strip traling slashfundon
2015-01-27Introduce FilepathPathBridgebep
This commit introduces the new interface FilepathPathBridge to remove some code that differs only in their use of either the path or filepath package.
2015-01-26Add pagination support for home page, sections and taxonomiesbep
Two new configuration properties, `Paginate` (default `0`) and `PaginatePath` (default `page`) are added. Setting `paginate` to a positive value will split the list pages for the home page, sections and taxonomies into chunks of size of the `paginate` property. A `.Paginator` is provided to help building a pager menu. There are two ways to configure a `.Paginator`: 1. The simplest way is just to call `.Paginator.Pages` from a template. It will contain the pages for "that page" (`.Data.Pages` will (like today) contain all the pages). 2. Select a sub-set of the pages with the available template functions and pass the slice to `.Paginate` : `{{ range (.Paginate (where .Data.Pages "Type" "post")).Pages }}` **NOTE:** For a given Node, it's one of the options above. It's perfectly legitimate to iterate over the same pager more than once, but it's static and cannot change. The `.Paginator` contains enough information to build a full-blown paginator interface. The pages are built on the form (note: BLANK means no value, i.e. home page): ``` [SECTION/TAXONOMY/BLANK]/index.html [SECTION/TAXONOMY/BLANK]/page/1/index.html => redirect to [SECTION/TAXONOMY/BLANK]/index.html [SECTION/TAXONOMY/BLANK]/page/2/index.html .... ``` Fixes #96
2015-01-23Fix RelPermalink() and Urls in menus vs canonifyUrlsbep
canonifyUrls=true, RelPermalink and baseUrl with sub-path did not work. This fixes that by adding a check for canonifyUrl=trues=true in RelPermalink(). So given - baseUrl "http://somehost.com/sub/" - the path "some-path/file.html" For canonifyUrls=false RelPermalink() returns "/sub/some-path/file.html" For canonifyUrls=true RelPermalink() returns "/some-path/file.html" In the last case, the Url will be made absolute and clickable in a later step. This commit also makes the menu urls defined in site config releative. To make them work with canonifying of urls, the context root is prepended if canonifying is turned off. Fixes #519 Fixes #711
2015-01-20Minor polish in path/urlbep
2014-12-26Wrap comments helpers package to fit 80-column widthAnthony Fok
Add an initial space after `//` where appropriate. Minor copyediting.
2014-12-12Commenting helpers packageAhsanul Haque