Commit graph

765 commits

Author SHA1 Message Date
ls6
bcaf33418f Update shortcodes.md
A typo resulting in a broken link.
2014-11-18 10:15:05 -05:00
bep
a6a9df3955 Fix failing shortcode tests on Travis
Some newly added shortcode tests compared maps in assertions.

This failed on Travis, as iteration order isn't guaranteed for maps since Go 1.

This commit fixes that by do a sort of the keys in the shortcode String() function.
2014-11-18 10:14:12 -05:00
Kartik Singhal
596d679386 Various fixes in RSS feed generation
- Prevent `.xml` generation for root section
- Remove redundant check for DisableRSS
- Fix permalinks for rel="alternate"
- Rename generated xml file to <type>/index.xml
- Add required description element in default template
- Make default RSS template validate on w3c (timezone format is still an issue)

Conflicts:
	hugolib/site.go
2014-11-17 18:55:40 -05:00
Danillo Souza
a07dd5650e fixing typo 2014-11-17 18:44:34 -05:00
Chase Adams
b716dbec1d Fix template checking order in site.go
- Change order of HasPrefix to match correct order
- Remove theme concatenation to _internal in last loop of
  appendthemetemplates so it looks in the right place for internal
templates

Conflicts:
	hugolib/site.go
2014-11-17 18:42:36 -05:00
bep
55fcd2f30f Shortcode rewrite, take 2
This commit contains a restructuring and partial rewrite of the shortcode handling.

Prior to this commit rendering of the page content was mingled with handling of the shortcodes. This led to several oddities.

The new flow is:

1. Shortcodes are extracted from page and replaced with placeholders.
2. Shortcodes are processed and rendered
3. Page is processed
4. The placeholders are replaced with the rendered shortcodes

The handling of summaries is also made simpler by this.

This commit also introduces some other chenges:

1. distinction between shortcodes that need further processing and those who do not:

* `{{< >}}`: Typically raw HTML. Will not be processed.
* `{{% %}}`: Will be processed by the page's markup engine (Markdown or (infuture) Asciidoctor)

The above also involves a new shortcode-parser, with lexical scanning inspired by Rob Pike's talk called "Lexical Scanning in Go",
which should be easier to understand, give better error messages and perform better.

2. If you want to exclude a shortcode from being processed (for documentation etc.), the inner part of the shorcode must be commented out, i.e. `{{%/* movie 47238zzb */%}}`. See the updated shortcode section in the documentation for further examples.

The new parser supports nested shortcodes. This isn't new, but has two related design choices worth mentioning:

* The shortcodes will be rendered individually, so If both `{{< >}}` and `{{% %}}` are used in the nested hierarchy, one will be passed through the page's markdown processor, the other not.
* To avoid potential costly overhead of always looking far ahead for a possible closing tag, this implementation looks at the template itself, and is branded as a container with inner content if it contains a reference to `.Inner`

Fixes #565
Fixes #480
Fixes #461

And probably some others.
2014-11-17 18:32:06 -05:00
spf13
c8904756f0 Removing dependency on go-html-transform (fixing the build). 2014-11-17 18:21:31 -05:00
Tatsushi Demachi
7e692544f0 Fix GroupBy function issues
Following issues are fixed

1. Can't access fields and methods specified in GroupBy call
2. PagesGroup doesn't contain Pages. It's always empty.
3. When GroupBy is called with Section key, it doesn't work as expected
2014-11-13 22:48:58 -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
Michael Henderson
6bf6a810ee Update creating-a-new-theme.md 2014-11-13 22:44:31 -05:00
Michael Henderson
88881de2d4 Update creating-a-new-theme.md 2014-11-13 22:44:31 -05:00
Michael Henderson
e9917bfe16 Update creating-a-new-theme.md
Update heading levels to confirm to the other tutorials. Create a similar front-matter using YAML, since I couldn't figure out how to get the menu:main:parent working as TOML.
2014-11-13 22:44:30 -05:00
Joel Scoble
ca4e4ce2f9 converted helpers usage of path 2 filepath 2014-11-13 22:41:59 -05:00
Joel Scoble
99463f6adf converted path 2 filepath 2014-11-13 22:39:07 -05:00
Joel Scoble
2c51bba0c3 converted path 2 filepath 2014-11-13 22:38:21 -05:00
Joel Scoble
7fd348cf79 convert path 2 filepath 2014-11-13 22:37:14 -05:00
Joel Scoble
4f2dfe7015 converted path 2 filepath 2014-11-13 22:36:28 -05:00
Joel Scoble
7badd2eb0c change path usage to filepath 2014-11-13 22:33:39 -05:00
Joel Scoble
05300fde1d add support for fsync's noTime flag 2014-11-13 22:32:27 -05:00
Joel Scoble
f037ae7b4f update README.md with info on adding compile information to version 2014-11-13 22:22:15 -05:00
Ryan Kimber
fc20d0b444 Fixed launchcode5.md description 2014-11-13 22:08:30 -05:00
Ryan Kimber
52ae1c750a Added launchcode-tn.jpg to docs/static/img 2014-11-13 22:08:29 -05:00
Ryan Kimber
15dae3ccde Create launchcode5.md 2014-11-13 22:08:29 -05:00
bep
8ad9c0a7dd Make Where template-method accept methodname as key
This is necessary to make constructs like `{{ range first 1 (where .Data.Pages "Type" "post") }}` -- as Type and Section is methods not fields.
2014-11-13 12:42:26 -05:00
bep
fdae09070b Params map has string as key
Related to issue #540 and commit 3c22ca7c84456b19f2a017719b1533902594e672
2014-11-13 12:41:00 -05:00
Brian Payne
e127a5cb7d Added better error message for poorly formed frontmatters in archtypes 2014-11-13 12:36:47 -05:00
bep
3cec04e0d2 Add Git directory deployment flow to tutorial 2014-11-13 12:33:14 -05:00
Austin Ziegler
d467ec0aab Fix a bug with taxonomy rendering.
- In `layouts/_default/taxonomy.html`, the `.Data` result does not
  provide the same information that `layouts/_default/terms.html` does
  for being able to identify the plural value of the term.
- This change adds `.Data.Singular` and `.Data.Plural` to provide
  similar capabilities.
- This *may* be incompatible with templates that check for `{{ if ne
  $taxonomy "Pages" }}` if the `page.Params` has either the singular or
  plural values as keys.
2014-11-13 12:32:10 -05:00
Austin Ziegler
d7e6e490c2 Allow partial without .html
`partial "header" .` means the same thing as `partial "header.html" .`.
2014-11-13 12:30:45 -05:00
bep
266511b6d3 Fix missing space before 'width'
The newly introduced width-param on figure did not work in combo with alt or caption due to space-issues.

This fixes that.
2014-11-13 12:29: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
f81f9ceb40 Fix: rewrite FileAndExt
FileAndExt has now be completely rewritten and now works as may
reasonably be expected. The test cases for:

ReplaceExtension
Filename
FileAndExt

now all pass.

The problem was the way path.Base was being used.
Firstly Base returns "." if the directory is empty, but it can also
return "." for the current directory, or ".." for the parent directory,
if these are the last elements in the path. Simply detecting the
presence of a "." in the returned string and truncating before the "."
does not therefore always result in a valid filename.
Secondly, Base strips any trailing slashes making is more difficult to
detect when the path does not end in a filename but in a directory name
i.e. a no filename case. Not detecting this incorrectly results in the
last directory name being returned as the filename.

The code has been updated to take account of of both situations so that:
1) An empty string for both the filename and extension is returned if the
path does not contain a filename (plus an optional extension). This
includes both the empty path case, and the ends in a directory case.
2) If the path represents a filename with an extension then both the
filename and the extension (minus any dots) are returned as non empty
strings.
3) If the path represents a filename without an extension then filename
will be returned as a non empty string (minus any dot) and the extension
will be returned as an empty string.
2014-11-04 19:19:19 -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
Owen Waller
6b619d2cd6 Added the url modules test files.
Added the new url module test file. This replaces the original
helpers_test.go file.

The TestUrlPrep test currently fails.

The only minor change to url.go is to add some trace printf's to
UrlPrep.
2014-11-04 19:16:07 -05:00
Owen Waller
57cd953997 Added the general modules test files
Added the new general module's test file, general_test.go. This replaces the
helpers_test.go file.

There is also a minor defect fix in general.go's StripHTML function.
The correct xhtml tag for a break is <br /> not </br>. I've also removed
the unnecessary spaces before the replacement "\n".

The new test module also reflects this change.

Conflicts:
	helpers/general.go
2014-11-04 11:13:41 -05:00
Owen Waller
b87402e8cd Remove the helpers_test.go file
The helpers_test.go file has been split into three new
test files, one each for the path, url and general modules.

Conflicts:
	helpers/helpers_test.go
2014-11-04 11:10:55 -05:00
spf13
8a5dd06ad0 Use page.Markup to determine which PageHandler to use if it's set. 2014-11-04 00:44:30 -05:00
spf13
ade2ca6072 Adding an html file handler 2014-11-04 00:43:09 -05:00
spf13
7fba250023 Adding a proper css file handler (with automatic minification) 2014-11-04 00:42:36 -05:00
spf13
4dcf734acd Updating tests to use new Targets & Writers and switch to using Afero.MemMapFs for more accurate tests. 2014-11-04 00:41:47 -05:00
spf13
7b960ac121 New targets & new renderers and write methods [WIP] 2014-11-04 00:39:37 -05:00
spf13
e02dc6742a Cleanup file conversion handling 2014-11-04 00:36:05 -05:00