Commit graph

941 commits

Author SHA1 Message Date
Tatsushi Demachi 0d17ee7ed4 Add operator argument to where template function
It allows to use `where` template function like SQL `where` clause.
For example,

    {{ range where .Data.Pages "Type" "!=" "post" }}
        {{ .Content }}
    {{ end }}

Now these operators are implemented:

    =, ==, eq, !=, <>, ne, >=, ge, >, gt, <=, le, <, lt, in, not in

It also fixes `TestWhere` more readable
2015-01-04 12:15:17 +01:00
Austin Ziegler ae9c25afc0 Implement apply.
- apply seq fn args…
2015-01-02 11:50:22 +01:00
Austin Ziegler 6033abe1e7 Add a chomp function.
- Mostly useful in pipelines.
2015-01-02 11:50:22 +01:00
Austin Ziegler 14e93de8a1 Initialize funcMap in an init function. 2015-01-02 11:50:22 +01:00
Austin Ziegler 6a98d269b5 Hygiene: Reduce copy-pasted code. 2015-01-02 11:50:22 +01:00
Nathan Youngman c6f4b09f65 always use http scheme for localhost
fixes #758
2015-01-01 23:57:29 +01:00
Bjørn Erik Pedersen dd1001ceda Merge pull request #762 from bjornerik/fix/revert-revert-menutest
Revert "Temporarily disable failing menu test"
2015-01-01 23:53:24 +01:00
bep 076a475d16 Revert "Temporarily disable failing menu test"
This reverts commit e4a22255cc.
2015-01-01 23:40:14 +01:00
spf13 fb1b795d59 Bumping Travis to test go 1.3 & 1.4 2014-12-30 14:58:48 -05:00
Tom Helmer Hansen d3c3676161 Fix EOF 2014-12-30 12:28:19 -07:00
Tom Helmer Hansen ec2566fa95 Add www.thehome.dk to showcase 2014-12-30 12:28:19 -07:00
Tatsushi Demachi 975f4cf126 Refactor tpl codes
- Use indirect function instead of the same code copies
- Fix missing arguments of some test codes
2014-12-29 15:47:50 +01:00
Tatsushi Demachi fa8ac87d5e Make 'where' template function accepts dot chaining key argument
'where' template function used to accept only each element's struct
field name, method name and map key name as its second argument. This
extends it to accept dot chaining key like 'Params.foo.bar' as the
argument. It evaluates sub elements of each array elements and checks it
matches the third argument value.

Typical use case would be for filtering Pages by user defined front
matter value. For example, to filter pages which have 'Params.foo.bar'
and its value is 'baz', it is used like

    {{ range where .Data.Pages "Params.foo.bar" "baz" }}
        {{ .Content }}
    {{ end }}

It ignores all leading and trailing dots so it can also be used with
".Params.foo.bar"
2014-12-29 12:53:41 +01:00
Anthony Fok dd5bc0345b [Docs] Mention support for the Ace HTML Template Engine 2014-12-27 00:58:50 -07:00
Anthony Fok ddf4190114 Docs copyediting: Add more external URLs; add backticks, etc. 2014-12-27 00:50:08 -07:00
Anthony Fok 5792cc3a1a [Docs] Go 1.4+ required for building on Windows
See Issue #688 for more information.
2014-12-26 13:00:14 -07:00
bep afe5add86e Add anchor ref to Blackfriday doc 2014-12-26 18:11:05 +01:00
Austin Ziegler 5e0a16ea21 Fix a crash for ref page#anchor.
- Remove an improperly shadowed variable.
- Fixes #741.
2014-12-26 18:06:21 +01:00
Bjørn Erik Pedersen 029a3ae79e Merge pull request #742 from bjornerik/doc/blackfriday
Add doc for Blackfriday configuration
2014-12-26 16:56:06 +01:00
Ryan Martinsen 7dacc999f8 Add ability to canonify URLs in rendered XML output. 2014-12-26 16:24:28 +01:00
Anthony Fok f5a3fb149f Wrap comments helpers package to fit 80-column width
Add an initial space after `//` where appropriate.
Minor copyediting.
2014-12-26 08:07:03 -07:00
bep a0fe117002 Add doc for Blackfriday configuration
See #686
2014-12-26 16:04:49 +01:00
bep fbf8bcacc4 Add configurable support for angled quotes
The flag `HTML_SMARTYPANTS_ANGLED_QUOTES` was added to Blackfriday on Black Friday. This configures rendering of double quotes as angled left and right quotes (&laquo;
&raquo;).

Typical use cases would be either or, or combined, but never in the same
document. As an example would be a person from Norway; he has a blog in both
English and Norwegian (his native tongue); he would then configure Blackfriday
to use angled quotes for the Norwegian section, but keep them as reqular
double quotes for the English.

This commit adds configuration support for this new flag, configuration that can be set in the site configuration, but overridden in page front matter.

Fixes #605
2014-12-26 14:31:55 +01:00
bep bb37698226 Fix unicode menu URLs
Menu urls like /categories/новости-проекта would turn into /categories/d0bdd0bed0b2d0bed181d182d0b8-d0bfd180d0bed0b5d0bad182d0b0, which is illegal, while the directory under the categories/ is created with the original name. It results in 404 not found error.

This commit fixes that by make sure that SanitizeUrl() is called last.

Fixes #719
2014-12-26 13:30:46 +01:00
bep e4a22255cc Temporarily disable failing menu test 2014-12-26 13:14:06 +01:00
Anthony Fok 0cfdb2e51b Revise README.md: buildDate expects timezone; copyediting
Since commit 3a8c12418a dated 2014-12-09,
commands.buildDate expects `date +%FT%T%z` rather than `date +%FT%T`.
Update README.md accordingly.

Also did a little copyediting.
2014-12-25 21:46:43 -07:00
Anthony Fok 8042e77488 Typo fix: "simple" → "simply" in templates/views.md
Thanks to @paulsullivan for catching that typo!
2014-12-24 16:58:28 -07:00
Anthony Fok 68cea07072 Minor copyediting, no new content added. 2014-12-24 04:59:53 -07:00
Anthony Fok e3433e6afb Fix long descriptions of benchmark and serve commands 2014-12-24 04:40:48 -07:00
bep 331043b98e Remove noisy Println in test 2014-12-19 14:21:05 +01:00
Derek Perkins 717f702e2f Added delimit & sort template functions, tests and docs 2014-12-18 22:28:12 -05:00
Derek Perkins 8f6f871f53 Added AuthorList, Author, AuthorSocial, SiteSocial, Image and Video structs
Added Page.Author(s) functions
Added schema, opengraph, twitter_cards, google_news metadata templates
Added "" template
2014-12-18 22:26:10 -05:00
Austin Ziegler fd33e5d202 Documentation for ref and relref.
- Rejigged the weight of the extras/ content for the new crossreferences
  page.
- Used the new {{</*…*/>}} format for documenting highlighting and to
  prevent a warning about the missing `fig` shortcode.
2014-12-18 22:18:37 -05:00
Austin Ziegler 112c3c5c04 Provide (relative) reference funcs & shortcodes.
-   `.Ref` and `.RelRef` take a reference (the logical filename for a
    page, including extension and/or a document fragment ID) and return
    a permalink (or relative permalink) to the referenced document.

    -   If the reference is a page name (such as `about.md`), the page
        will be discovered and the permalink will be returned: `/about/`
    -   If the reference is a page name with a fragment (such as
        `about.md#who`), the page will be discovered and used to add the
        `page.UniqueID()` to the resulting fragment and permalink:
        `/about/#who:deadbeef`.
    -   If the reference is a fragment and `.*Ref` has been called from
        a `Node` or `SiteInfo`, it will be returned as is: `#who`.
    -   If the reference is a fragment and `.*Ref` has been called from
        a `Page`, it will be returned with the page’s unique ID:
        `#who:deadbeef`.

-   `.*Ref` can be called from either `Node`, `SiteInfo` (e.g.,
    `Node.Site`), `Page` objects, or `ShortcodeWithPage` objects in
    templates.

-   `.*Ref` cannot be used in content, so two shortcodes have been
    created to provide the functionality to content: `ref` and `relref`.
    These are intended to be used within markup, like `[Who]({{% ref
    about.md#who %}})` or `<a href="{{% ref about.md#who %}}">Who</a>`.

-   There are also `ref` and `relref` template functions (used to create
    the shortcodes) that expect a `Page` or `Node` object and the
    reference string (e.g., `{{ relref . "about.md" }}` or `{{
    "about.md" | ref . }}`). It actually looks for `.*Ref` as defined on
    `Node` or `Page` objects.

-   Shortcode handling had to use a *differently unique* wrapper in
    `createShortcodePlaceholder` because of the way that the `ref` and
    `relref` are intended to be used in content.
2014-12-18 22:18:36 -05:00
Ahsanul Haque 14bce119b6 Commented helpers package 2014-12-18 22:18:36 -05:00
Tatsushi Demachi 7436829b82 Use current working dir as WorkingDir instead of hugo executable's dir 2014-12-12 11:33:52 -05:00
Austin Ziegler ec4b6c03a8 Trigger an editor after hugo new.
- Trigger permanently with NewContentEditor in config.{toml,yaml,json}.
- Trigger on an individual basis with --editor.
2014-12-12 11:33:52 -05:00
Ahsanul Haque 2c8e9a7931 Commenting helpers package 2014-12-12 02:57:25 +06:00
Ahsanul Haque b11838da3f Commented commands package 2014-12-12 00:05:02 +06:00
bep 9b04c27998 Revert "Make Urls in menus respect CanonifyUrls"
This reverts commit 3ccb397902.
2014-12-11 05:33:40 +01:00
bep 3ccb397902 Make Urls in menus respect CanonifyUrls
Fixes #519
2014-12-10 20:32:39 +01:00
bep e6541c45ab ERROR-log on symbolic links
filepath.Walk does not follow symbolic links.
There's no easy fix for that outside of Go, so the best we can do for now is to give notice to the end user by ERROR log statements.

This commit also fixes a related panic situation in GenerateTemplateNameFrom when the layout dir was a symbolic link.

Fixes #283
2014-12-10 20:32:39 +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 3a8c12418a Add timezone to buildDate 2014-12-09 11:42:07 +01:00
Austin Ziegler be3d563a13 Add an install target to Makefile. 2014-12-09 11:12:40 +01:00
bep 9f0f73f452 Fix front matter for 'Creating a New Theme'
There seems to be an issue with TOML and certain menu structures. Current workaround: YAML.
2014-12-08 23:08:54 +01:00
Anthony Fok a6d3862b87 Docs: Minor copyediting/proofreading
- Correct some typos
- Add backticks and commas where necessary
- Use fenced code blocks specifying "bash" as the language
  to avoid weird highlighting
- Place commas outside of quotation marks surroundingn codes
  to avoid possible confusion
- Suggest users to use the discussion forum rather than the
  mailing list
2014-12-08 22:44:30 +01:00
Anthony Fok 736dd4b521 Docs: Quote <!--more--> in <code> instead of italicizing it
Also replace "--" with "&#x2d;&#x2d;" prevent "--" from
being interpreted as en-dash.

Note: A simple `<!--more-->` does not work.
2014-12-08 22:44:30 +01:00
Anthony Fok 010f6057ff Correct URL of the favicon in the documentation
img/favicon.png does not seem to exist,
so follow the example in docs/layouts/index.html
and use /favicon.ico instead.
2014-12-08 22:34:00 +01:00
bep 11cdb81501 Remove Println that panics in test 2014-12-08 22:06:37 +01:00