Commit graph

42 commits

Author SHA1 Message Date
Albert Nigmatzianov
f21e2f25c9 all: Unify case of config variable names
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-24 20:56:00 +02:00
Bjørn Erik Pedersen
a10b2cd372 Avoid reading from Viper for path and URL funcs
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-10-24 13:45:30 +02:00
Bjørn Erik Pedersen
bacc1706cb helpers: Skip TestGetRealPath on Windows when not in CI
`os.Symlink` needs administrator rights on Windows,
and this seems to be the simplest fix while still getting the tests run on Appveyor.

Fixes #2476
2016-09-18 22:04:32 +02:00
Bjørn Erik Pedersen
98c12b7b3d Fail early in TestGetRealPath
See #2476
2016-09-18 19:52:42 +02:00
Bjørn Erik Pedersen
364e69ab7f Handle symlink change event
Hugo 0.16 announced support for symbolic links for the root folders, /content, /static etc., but this got broken pretty fast.

The main problem this commit tries to solve is the matching of file change events to "what changed".

An example:

ContentDir: /mysites/site/content where /mysites/site/content is a symlink to /mycontent

/mycontent:

/mypost1.md
/post/mypost2.md

* A change to mypost1.md (on OS X) will trigger a file change event with name "/mycontent/mypost1.md"
* A change to mypost2.md gives event with name "/mysites/site/content/mypost2.md"

The first change will not trigger a correct update of Hugo before this commit. This commit fixes this by doing a two-step check:

1. Check if "/mysites/site/content/mypost2.md" is within /mysites/site/content
2. Check if  "/mysites/site/content/mypost2.md" is within the real path that /mysites/site/content points to

Fixes #2265
Closes #2273
2016-09-11 20:00:38 +02:00
Bjørn Erik Pedersen
8a60571fd2 helpers: Fix and add Godoc in path* 2016-03-23 10:03:29 +01:00
Bjørn Erik Pedersen
b9127ecca6 helpers: Apply gofmt 2016-03-22 19:43:03 +01:00
Aditya Bhargava
c42982f76b Add '+' as one of the valid characters in urls specified in the front matter
Fixes #1290
2016-03-21 18:48:50 -04:00
Daniel TISCHER
40fccf2251 Fixes #1292 2016-01-01 14:35:58 -05:00
Anthony Fok
8509727fe8 Add copyright header to that source files that don’t have one.
See #1646
2015-12-10 15:19:38 -07:00
Steve Francia
6042fc2b83 move some of the path helper utilities to afero
and provide wrappers in Hugo.
2015-12-08 16:46:43 -05:00
Bjørn Erik Pedersen
831e936846 Improve "watching for ..." logging 2015-11-23 16:32:06 +01:00
Bjørn Erik Pedersen
36adb5fb88 Preserve Unicode marks in MakePath
Fixes #1488
2015-10-18 10:36:27 +02:00
chrongzhang
52d94fa675 Add config option "disablePathToLower"
Enabling this prevents lowercasing of the path/url.

Fixes #557
2015-09-01 15:26:02 +02:00
Bjørn Erik Pedersen
5b90b388cb Unexport FileAndExt
If needed outside helpers, create an exported file path (FilePathAndExt?)  and/or a url version.
2015-08-26 21:29:32 +02:00
Bjørn Erik Pedersen
4b7c1342fd Make removal of accents in taxonomy and section paths optional
And default off.

Fixes #1180
2015-06-16 19:25:48 +02:00
bep
3ea4df35f2 Remove accents in URLs
So the taxonomy `Gérard Depardieu` gives paths on the form `gerard-depardieu`.

Unfortunately this introduces two imports from the `golang.org/`, but Unicode-normalization isn't something we'd want to write from scratch.

See https://blog.golang.org/normalization

See #1180
2015-05-31 20:30:45 +02:00
bep
be964e95a1 Never remove trailing slash in RelPermalink
Fixed #1174
2015-05-27 20:41:43 +02:00
bep
beee679dfb Unexport filepath/path bridge types
They are of no use outside the helpers package.

See #1160
2015-05-25 13:10:40 +02:00
spf13
a584ff207b Stop Viper from leaking across many of the tests (now tests pass regardless of order tested) 2015-05-20 02:21:21 -04:00
bep
beaa8b1bca Add support for URLs relative to context root
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-16 00:11:44 +02:00
bep
bea42218b6 helpers: fix some go vet errors 2015-04-03 21:20:25 +02:00
Dylan MacKenzie
99a18b21fc List directories being watched when server is run
Fixes part of issue 1030. Previously hugo only listed the content
directory as being watched. Now we list all files being watched
according to `commands.getDirList()`. We also introduce a RemoveSubpaths
function and test in the helpers module to reduce noise in the command
line output by not showing subdirectories of ones already being watched.

For example, instead of:
`Watching for changes in $HOME/blog/content`
We get:
`Watching for changes in
$HOME/blog/{data,content,layouts,static,themes/my-theme}`
2015-04-02 12:52:08 +02:00
bep
103ea842f8 Fix errors reported by Go Vet 2015-03-06 15:25:19 +01:00
Cyrill Schumacher
5e2d3d2e10 Merge to stay up to date with current dev
Feature: GetJson and GetJson in short codes or other layout files.
For more details please see: http://cyrillschumacher.com/2014/12/21/dynamic-pages-with-gohugo.io/
2015-02-17 12:14:39 -05:00
bep
e52a76f559 Use runtime.GOOS to identify Windows specific path tests 2015-01-27 23:01:32 +01:00
bep
8ad4fd05d8 Split Windows and Unix specific path tests 2015-01-27 15:09:01 +01:00
bep
b155e8b4cb Temporarily comment out breaking Windows test case 2015-01-27 12:12:35 +01:00
bep
bedc2d8488 Introduce FilepathPathBridge
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-27 11:44:41 +01:00
bep
5f9596e68c Add more tests to helper 2015-01-27 10:15:57 +01:00
bep
9f77f93071 Fix various Windows-issues
File handling was broken on Windows. This commit contains a revision of the path handling with separation of file paths and urls where needed.

There may be remaining issues and there may be better ways to do this, but it is easier to start that refactoring job with a set of passing tests.

Fixes #687
Fixes #660
2014-12-09 09:43:15 -05:00
bep
91e03b9fbc Reinsert deleted test
This test was deleted by mistake in owenwaller's contribution to add more tests.

I haven't looked closer, there may be more missing.
2014-11-13 22:47:06 -05:00
spf13
cafd39eb9b Fixing some tests 2014-11-04 20:28:27 -05:00
spf13
55fb02428d Updating tests to use hugofs 2014-11-04 20:28:07 -05:00
spf13
a40bd3caf1 rewriting guessSection to accurately reflect intent and usage. Update tests. 2014-11-04 20:19:45 -05:00
Owen Waller
e2634752ce First stab at correcting GuessSection tests
Updated the test to correctly test for "" when a non-absolute path
is used.

But the tests still fail for multi-part paths e.g. /contents/blog/
2014-11-04 19:19:27 -05:00
Owen Waller
5906c8652d Fix: remove the unnecessary dot in an extension
Oops minor typo. The new extension passed to ReplaceExtension should
not have a dot in it. The test data bas been updated to reflect this.
2014-11-04 19:19:09 -05:00
Owen Waller
3521e8b1e5 Updated TestReplaceExtensioni, TestFilename and TestFileAndExt
Updated the test cases in TestReplaceExtension to reflect the intent
of ReplaceExtension which is to accept a path and return only the file
name with a new extension. It's intentionally designed to strip out the
path and only provide the filename

Additional test cases have been added to both TestFilename and
TestFileAndExt to clarify behaviour with relative paths.
2014-11-04 19:19:01 -05:00
Owen Waller
980d0f14de WriteToDisk and SafeWriteToDisk test cleaned up
Minor cleanup to randomise the names of the temp directories used by the
tests.
2014-11-04 19:18:54 -05:00
Owen Waller
bf07dc9293 WriteToDisk and SafeWriteToDisk tests now pass
This is the first time that both the WriteToDisk and SafeWriteToDisk
tests pass
2014-11-04 19:18:46 -05:00
Owen Waller
a54ad2bf39 Fix: Test TestSafeWriteToDisk now works
Oops, my bad.
Despite the function intending to test SafeWriteToDisk it was actually
calling WriteToDisk. WriteToDisk does not return the file exists error
that SafeWriteToDisk does, which the test checks for.
2014-11-04 19:18:36 -05:00
Owen Waller
e8bbc44ab0 Added the path modules test files
Added the new path modules test file. This replaces the old
helpers_test.go file.

The currently failing tests are:
TestReplaceExtension
TestFilename
TestFileAndExt
TestGuessSection
TestFindCWD
TestWriteToDisk

In addition the TestSafeWriteToDisk test case is currently disabled.
It will panic if enabled.

In addition there are some minor changes to path.go. They are:
Refactored MakePathToLower to simplify it.
Commented out, pending removal, Sanitize as it appears to be unused.
Fixed the resource leak in UnicodeSanitize

Conflicts:
	helpers/path.go
2014-11-04 19:18:04 -05:00