Commit graph

399 commits

Author SHA1 Message Date
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
Joel Scoble 2c51bba0c3 converted path 2 filepath 2014-11-13 22:38:21 -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
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 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
spf13 3616d16701 Better error messages for show_plan_test 2014-11-04 00:32:55 -05:00
spf13 07f2ef9c5e Page Group functions now work even when an uppercase field / method is provided. 2014-11-04 00:31:57 -05:00
spf13 2cb89a523a Update menu test to work with revised source struct 2014-11-03 10:14:10 -05:00
Austin Ziegler 8cc7684a91 Change the type of .Site.Author from…
…`map[string]string` to `map[string]interface{}`.

This allows values other than `string` values to be saved to Author,
such as:

    ```toml
    # config.toml
    …
    [Author]
      name = "Austin Ziegler"
      social-site = [ "Facebook", "Twitter", "GitHub" ]
    ```

My specific use-case is that I’m trying to make something work similar
whether it’s specified in `.Params.Author` or in `.Site.Author` without
introducing `.Site.Params.Author`.
2014-11-02 00:45:33 -04:00
Austin Ziegler c1942e915a Change permalink validation and substitution. 2014-11-02 00:43:01 -04:00
Tatsushi Demachi af47e5a2cf Extend template's mod and modBool functions to accept any int types
Fixes #575
2014-11-01 23:00:46 -04:00
Tatsushi Demachi 5e28606b84 Add sort and grouping functions for publish date and param of Page
`GroupBy` is modified to allow it to receive a method name argument for
example `Type` as its first argument. It is only allowed to call with
a method which takes no arguments and returns a result or a pair of
a result and an error.

The functions discussed at #443 are also added

- `ByPublishDate`: Order contents by `PublishDate` front matter variable
- `GroupByPublishDate(format, order)`: Group contents by `PublishDate`
  front matter variable formatted in string like `GroupByDate`
- `GroupByParam(key, order)`: Group contents by `Param` front matter
  variable specified by `key` argument
- `GroupByParamDate(key, format, order)`: Group contents by `Param`
  front matter variable specified by `key` argument and formatted in
  string like `GroupByDate`. It's effective against `time.Time` type
  front matter variable
2014-11-01 22:41:04 -04:00
bep d013edb7f8 Implement HasMenuCurrent and IsMenuCurrent for Nodes
Prior to this commit, `HasMenuCurrent` and `IsMenuCurrent` on `Node` always returned false.

This made it hard (if possible at all) to mark the currently selected menu item/group for non-Page content (home page, category pages etc.), i.e. for menus defined in the site configuration.

This commit provides an implementation of these two methods.

Notable design choices:

* These menu items have a loose coupling to the the resources they navigate to; the `Url` is the best common identificator. To facilitate a consistent matching, and to get it in line with the menu items connected to `Page`, relative Urls (Urls starting with '/') for menu items in the site configuration are converted to permaLinks using the same rules used for others’.
* `IsMenuCurrent` only looks at the children of the current node; this is in line with the implementation on `Page`.
* Due to this loose coupling, `IsMenuCurrent` have to search downards in the tree to make sure that the node is inside the current menu. This could have been made simpler if it could answer `yes` to any match of any menu item matching the current resource.

This commit also adds a set of unit tests for the menu system.

Fixes #367
2014-11-01 22:34:49 -04:00
spf13 c5f1031e45 Handler WIP 2014-11-01 12:05:37 -04:00
spf13 141f3e19e0 Migrating Hugo to Afero for filesystem calls. 2014-11-01 11:57:29 -04:00
spf13 dfb8482569 Handlers WIP - Convert now working 2014-10-20 20:15:33 -04:00
spf13 30d4a26ba0 Handlers WIP (builds) 2014-10-20 17:51:53 -04:00
spf13 93f3d604c6 Handlers WIP 2014-10-20 17:42:16 -04:00
spf13 8bd0ffba43 Initial Handler Architecture WIP 2014-10-17 16:57:48 -04:00
spf13 5dfc1dedb8 Big refactor of how source files are used. Also added default destination extension option. 2014-10-16 20:20:09 -04:00
bep da5d98e958 Make First accept any int
TOML and YAML handles integers differently, creating issues when using integer values from configuration or front matter in the First template function.

This currently works in YAML (parses into int), but not in TOML (parses into int64).

This commit modifies First so it accepts any int.

Fixes #551
2014-10-15 12:39:09 -04:00
bep 16330cea91 Add nil-check to Intersect
The Intersect template-method would fail if one or both of the lists were nil (post vs page; post has tags, page has not).

This commit adds a nil-check and returns an empty result if any of the inputs are nil.

See #537
2014-10-15 12:31:22 -04:00
Raphael Estrada 3da97656ea add 'width' parameter to 'figure' shortcode 2014-10-15 12:09:26 -04:00
Joel Scoble 4b9e4c90d9 #462 fix, remove leading and trailing dashes from urlized slug. includes test changes 2014-10-07 17:05:11 -04:00
Joel Scoble f52e662890 Feed the titleized taxonomy key through string replace to replace '-' with ' ' for proper display of the taxonmy title 2014-10-07 17:01:39 -04:00
Will Stevens 938733f48f added In and Intersect template functions 2014-10-07 16:52:12 -04:00
Austin Ziegler 9cdd2e54c2 Use md5 against the file path for uniqueness. 2014-10-07 16:45:23 -04:00
Austin Ziegler 603b24a163 Make each generated page’s footnotes unique.
If content pages are fully rendered in a list page, footnotes that use
the same reference (`[^fn]`) will have duplicated anchors. This change
builds on #526 to put the page filename (`Page.File.Name`) as part of
the anchor for a footnote.

This would fix discussion [116](http://discuss.gohugo.io/t/footnote-references-are-duplicated-on-list-pages/116).
2014-10-07 16:44:28 -04:00
Austin Ziegler e68e7ef96f Configure footnote rendering.
- The config file can provide FootnoteAnchorPrefix, which will be used
  by blackfriday when rendering to HTML. A value of `q:` has the effect
  of making the anchor for a footnote `[^footie]` be `fn:q:footie`. The
  default is `""`.

- The config file can provide FootnoteReturnLinkContents, which will be
  used by blackfriday when rendering to HTML. A value of `^` has the
  effect of making the return link be `^` instead of `[return]`.
2014-10-07 16:43:33 -04:00
Kartik Singhal 879e90dca7 Switch to new hompage 2014-10-02 13:39:59 -04:00
spf13 e3d4d40d32 better error messages for template errors 2014-10-02 13:37:38 -04:00
Nate Finch 3f59abe885 add some information to rendering errors so it's easier to tell what's failing. 2014-09-29 09:19:39 -04:00
Tatsushi Demachi 5d565c34e5 Extend template's basic math functions to accept float, uint and string values 2014-09-22 09:01:40 -04:00
Nate Finch b590de6917 limit the number of goroutines used in taxonomy rendering to gomaxprocs*4 2014-09-14 07:23:03 -04:00
Nate Finch 49045b1cbc limit the number of goroutines we use for page rendering to gomaxprocs*4 2014-09-14 07:01:40 -04:00
Nate Finch cf3e748bd9 remove unused field 2014-09-12 07:25:45 -04:00
Nate Finch a72ca38c07 make the value of the BuildDrafts flag available to templates.This can be useful for if you only want to show some specific information on your local machine and/or when showing drafts. 2014-09-11 17:24:10 -04:00
Nate Finch 7142374332 Sort by title if dates are the same 2014-09-11 17:23:01 -04:00
Joel Scoble becd4fe337 refactor handling of amber to AddTemplateFile as the TODO note stated. Used switch statement to make it easier to add other template support 2014-09-11 17:09:16 -04:00
Joel Scoble 4e9b04086a fix tags not being in lowercase, #491 2014-09-11 17:03:31 -04:00
Nate Finch 0099b5a3cb Change all uses of sort.Sort to sort.Stable.Using sort.Stable ensures that even if the sort keys are the same, the order of the sort will not randomly change. Using the old sort.Sort, if you had pages with no date, the lists of those pages would randomly reorder every time you regenerate the list, causing spurious changes to the output. Now they'll always get ordered in the same way. 2014-09-09 09:22:16 -04:00
Nate Finch acf9561a31 fix zero date 2014-09-08 11:55:54 -04:00
Nate Finch 2ca615c551 Add Node.Site.Pages to all nodes and ensure all pages from the site exist in the list before processing shortcodes.
Node.Site.Recent is not really just recent pages, but all pages, so I figured it was better to add a new parameter with a more informative name.

I also changed the code slightly so that all pages are added to the list of pages before we start rendering shortcodes... this way you can use a shortcode to refer to another page.  Previosuly, this had been broken, because the list ofg pages would not be fully populated while the shortcodes were being processed.  The code that does this is not reading from disk or doing any rendering, so it shouldn't take any more time to do.
2014-09-08 11:50:09 -04:00
Nate Finch b97c6c7082 add Name to File, which is the filename minus the extension 2014-09-08 11:44:50 -04:00
spf13 4bb5e326db Taxonomies can now be provided as a single string value if there is only one in frontmatter (tag = "val" vs tag = ["val"]) 2014-09-05 09:29:01 -04:00
spf13 1b7f18e391 Making partials context optional for compatibility with template.
If not provided, context is nil.
2014-09-03 11:30:08 -04:00
Dave Johnston 13a317b975 Enable header id blackfriday extension 2014-08-30 14:12:53 -04:00
spf13 242d6b4e6b Adjusting the number of go routines to build the pages in to 4*GOMAXPROCS (from 2) for faster rendering. 2014-08-30 01:15:20 -04:00
Nate Finch 47c91a4ca2 Fix CreatePages
This fixes #450.  There are two problems:

1.) We're creating a new goroutine for every page.
2.) We're calling s.Pages = append(s.Pages, page) inside each goroutine.

1 is a problem if in that if you have a ton of pages, that's a ton of goroutines.  It's not really useful to have more than a few goroutines at a time, and lots can actually make your code much slower, and, evidently, crash.

2 is a problem in that append is not thread safe. Sometimes it returns a new slice with a larger capacity, when the original slice isn't large enough.  This can cause problems if two goroutines do this at the same time.

The solution for 1 is to use a limited number of workers (I chose 2*GOMAXPROCS as a nice guess).
The solution for 2 is to serialize access to s.Pages, which I did by doing it in a single goroutine.
2014-08-30 01:02:35 -04:00
spf13 7e19fa40e7 Making direction optional (and setting defaults) for GroupBy Pages functionality. 2014-08-29 23:51:29 -04:00
spf13 b15eb889e8 Adding .Reverse() to PagesGroup 2014-08-29 23:50:25 -04:00
spf13 41b28462e8 Switch .Data to .Pages in the PageGroup functionality for increased consistency. 2014-08-29 23:48:24 -04:00
spf13 70dc370c08 Making the term "Term" more consistent with Taxonomy usage. 2014-08-29 23:44:39 -04:00
spf13 01caaeba7a Making the Pages Sorting methods available within a taxonomy term. 2014-08-29 23:43:38 -04:00
spf13 53b7d5b8a1 Inner Shortcodes now treated as markdown. fixed #185 2014-08-28 12:48:31 -04:00
spf13 1b5f59b071 go fmt site.go 2014-08-25 13:13:11 -04:00
spf13 30af267b32 Fix #302. Links now have trailing slashes. 2014-08-25 12:45:47 -04:00
Nate Finch a31edb3388 Support subdir in baseurl.
Mainly this was a change to helpers.MakePermalink, but to get the local server to run correctly,
we needed to redirect the path of the request from /foo to /.  In addition, I added tests for the
server's code for fixing up the base url with different config file & CLI options.
2014-08-25 11:51:51 -04:00
Joel Scoble 4c735a7878 preserve alias case while lowercasing taxonomy 2014-08-25 10:16:59 -04:00
Chase Adams 348e123c9f Update 404 to be compiled to .html instead of directory 2014-08-25 09:38:08 -04:00
Tatsushi Demachi 50a8c50726 Add page grouping functions 2014-08-25 09:18:52 -04:00
Joel Scoble c750a95e22 support for futre/draft summary info output 2014-08-20 14:21:15 -04:00
spf13 aae1ff3c92 Adding IsNode & IsPage functions to Page & Node 2014-08-19 21:27:13 -04:00
Tatsushi Demachi 002a5b6756 Add 'where' template function 2014-08-18 11:31:17 -04:00
Billie H. Cleek aa42f4309c allow site to be built with empty content
Build the site even if there isn't anything in the content directory.
2014-06-30 15:28:18 -04:00
Nicholas Whittier 78962a14f8 Allows 404 templates from themes/THEME directories. 2014-06-30 15:22:52 -04:00
Nicholas Whittier ac99ceccac Add shortcode template loading from themes directory. 2014-06-30 15:22:18 -04:00
Kristoffer Grönlund 35d04671d3 Add PluralizeListTitles option (default true) to allow disabling use of the inflect package 2014-06-30 15:21:09 -04:00
Andrew Jones 5969315c8f switch back to master blackfriday; enable footnotes 2014-06-30 15:14:42 -04:00
spf13 4483a6655a Centralizing the template execution logic in one place 2014-06-06 17:27:31 -04:00
spf13 c297d7451f Adding 'partial' template function to add theme / local awareness to the partials directory. 2014-06-06 16:15:19 -04:00
spf13 4e99d6b54c Adding proper error message when view is not found.. fixing #303 2014-06-04 12:33:27 -04:00
spf13 640ab3c72e fixed #303. Adding theme support to views 2014-06-03 17:53:00 -04:00
Jake Mitchell e0ea6b9955 Support embedding <script> tags in markdown pages 2014-06-03 15:14:38 -04:00
spf13 c502f078bc Add handling for publishDates (which will be ignored if in the future). Fixed #260 2014-05-29 00:48:40 -04:00
Rinat Abdullin 4ebaec8906 Include Section Taxonomy into SiteInfo
This allows to build more complex pages, like :
http://martinfowler.com/tags/
2014-05-28 19:31:50 -04:00
spf13 35a605976e SiteInfo is now a pointer on the Node 2014-05-28 19:11:54 -04:00
spf13 4076d77029 Simplifying the siteInfo handling 2014-05-28 18:37:59 -04:00
Phil Pennock 280df4e380 Fix Viperized .Site.Params
git bisect identified 62dd1d4 as the breaking commit; when
github.com/spf13/viper was introduced, the Params field was always
empty.

Given a map in YAML in Viper, the return type is
`map[interface{}]interface{}`, _not_ `map[string]interface{}`, even if
`.SetDefault()` has been called with an item of
`map[string]interface{}{}` so the cast assertion on the `.Get("Params")`
always failed.
2014-05-28 18:15:23 -04:00
Lorenzo Bolla e98f0014f2 Allow to use filename in permalinks 2014-05-28 17:59:49 -04:00
spf13 57ad3abe7b Pre and Post in Menu are type HTML 2014-05-27 18:34:29 -04:00
spf13 be1ee22032 Proper integration of live reload with automatic injection 2014-05-16 17:49:27 -04:00
spf13 a4a1e39a51 Fixing issue when two menu items have the same name. 2014-05-14 18:08:11 -04:00
spf13 4f75ec985d Homepage renders with _default/list.html or then _default/single.html when index.html is not present. 2014-05-13 17:07:50 -04:00
Dato Simó 025a37df2f Fix permalink functionality, which was broken in 62dd1d4.
Viper stores Permalinks as a map[string]interface{}, so the type assertion
to PermalinkOverrides (map[string]PathPattern) will always fail.

We can, however, get Permalinks as a map[string]string, and convert each
value to a PathPattern.
2014-05-12 15:47:52 -04:00
Dato Simó 05b76dcb6f Add a blank line after the front matter when writing back a page.
Could also be done in parser.InterfaceToFrontMatter(), but logically the
extra blank line belongs to the page, not the front matter itself.
2014-05-12 15:46:58 -04:00
Vincent Batoufflet 73cbefdbc8 Make template comparison functions handle floats 2014-05-10 15:38:18 -04:00
Vincent Batoufflet 667a047cea Fix date issue with home page in Sitemap 2014-05-10 15:33:18 -04:00
Vincent Batoufflet 35926dcf37 Add Sitemap testing 2014-05-09 23:11:42 -04:00
Vincent Batoufflet 2a902bbca6 Add Sitemaps config values handling 2014-05-09 23:11:33 -04:00
Vincent Batoufflet f8e675d064 Add base Sitemap support 2014-05-09 23:11:27 -04:00
Vincent Batoufflet 179225449c Add template comparison functions (Go 1.1 compat) 2014-05-09 22:42:28 -04:00
spf13 08c30b6e44 Using new helpers in page.go 2014-05-02 01:04:48 -04:00