Commit graph

500 commits

Author SHA1 Message Date
Tuomas Siipola 4a3c1568a2
Support anchors without quotes in link checker (#1118)
* Support anchors without quotes in link checker

Not widely used but in many cases quotes in attributes are optional.

* Fix duplicate test
2020-08-07 17:02:02 +02:00
southerntofu b04be90326
Fix benchmarks (#1113)
* Include test_site/static in benchmark sites

* Benches can run again
2020-08-04 12:39:09 +02:00
Vincent Prouillet b4c5e9a34a Update changelog 2020-07-29 20:49:15 +02:00
yanghuidong b9296f7985
Make current_path always start with a slash (#1101)
* Make {section, page}.path always start with a slash

Change tests accordingly

* Fix missing leading/trailing slash in current_path of Taxonomy ("tags") and TaxonomyItem ("some-tag")

* Make {Paginator, Pager}.path always start with a slash

Fix Paginator.path missing trailing slash in from_taxonomy()

Change tests accordingly

* Update documentation regarding current_path now always starting with a slash

* Fix asymptomatic inverted logic in filter() for {section, page}.assets

* Add to 3 integration tests several checks for current_path in different templates

* Add a check for current_path in a paginated index section, "/page/2/"

This requires adding two dummy pages in the content root.

* Fix false passing of test on paginator.last due to URL prefix matching

A string formatting such as {name: value} can help prevent this.
2020-07-29 20:44:09 +02:00
eaon 28523ac9ad
Allow emitting newlines and whitespace in shortcodes and introduce markdown shortcodes (#1085)
* Replace hack for newline support in shortcodes with new hack

* Be a bit more space efficient/accurate with naming

* Boil newline/whitespace shortcode test down to the essentials

* Make sure the new \n and \s chars in old tests are properly represented

* Support markdown templates and shortcodes

* Refactoring .md/.html shortcode behaviour

* Add test for markdown shortcodes

* Add an html output test for markdown based shortcodes

* Add documentation for Markdown based shortcodes
2020-07-29 20:20:43 +02:00
southerntofu 7e7bf2bcd3
Tables in config.extra can be merged with those in theme.extra (#1100)
* Tables in config.extra can be merged with those in theme.extra

* Don't panic with invalid config type, but propagate an error

* Recursively merge config/theme extra sections

Co-authored-by: southerntofu <southerntofu@thunix.net>
2020-07-29 09:37:49 +02:00
Vincent Prouillet 66aaf4e384 Use mod paths 2020-07-25 10:49:07 +02:00
Vincent Prouillet d7b53687a5 Extract some feed logic out of site/lib.rs 2020-07-25 10:30:55 +02:00
Vincent Prouillet 5fe1036a1d Extract some Tera logic out of site/lib.rs 2020-07-24 23:46:27 +02:00
Vincent Prouillet d9123a8ca4 Extract link_checking outside of site/lib.rs 2020-07-24 23:46:27 +02:00
Vincent Prouillet 9be7bc074d Extract sass code out of site/lib.rs 2020-07-24 23:46:27 +02:00
Justin Turpin c3f59bceec
Fix pagination section memory issue (#1097)
* Update sitemap.rs

When paginate_by is zero, set number_pagers to 1 so at least 1 sitemap section is pushed

* paginate_by updates

Introduce section.paginate_by, use value if it exists, removes now
unnecessary filter

Co-authored-by: Justin Turpin <justinturpin@pop-os.localdomain>
2020-07-23 11:03:17 +02:00
Vincent Prouillet 9f20af1521 Update deps 2020-07-22 18:59:21 +02:00
Anna Harren 24d47845f4
Ignore sass directories starting with _ (#1084)
Prior to this change, only sass files starting with _ were ignored by
Zola's sass compiler. This made using sass frameworks incredibly
inconvenient, as Zola attempted to compile every single sass file in the
framework, and inevitably errored due to them not being standalone. For
example, to use the Bulma framework, you had to manually add an
underscore to the beginning of *every* sass file in it so Zola would
stop trying to compile them as standalone css files. Now you can change
the directory name to _bulma and have the same result.
2020-07-22 18:46:22 +02:00
Vincent Prouillet fb994c71d7 Make search index configurable
Closes #961
2020-06-29 20:02:27 +02:00
Vincent Prouillet 7cea0bb432 Clean up config a bit 2020-06-18 23:11:09 +02:00
southerntofu e47deccf43
Make themes more flexible (#1004)
* Site templates can replace theme templates

* Integrate test case within test_site/

* Full backwards-compatibility with testcase in test_site

* Refine test case

* Call parent's block in child template for test case

* Check both templates are applied

* Follow testing advice

* Test for 'include' in themes and shortcodes

* Documentation for themes and how to extend them

Co-authored-by: Vincent Prouillet <balthek@gmail.com>
2020-06-18 22:31:03 +02:00
Vincent Prouillet ade442a487 clippy + fmt + fix toml dates in extra arrays
Closes #1048
2020-06-18 21:12:46 +02:00
Matthias 5e31a32166
Add support for SVG files to get_image_metadata (Fixes #769) (#1063)
* Add support for SVG files to `get_image_metadata`

* Add support for SVG files to `get_image_metadata`

* Update documentation after adding SVG support
2020-06-18 11:36:11 +02:00
Vincent Prouillet 752716f292 Not sure it changes anything but... 2020-06-15 19:14:35 +02:00
Vincent Prouillet 351c9b7ff3 Remove ja/zh in search index 2020-06-15 19:14:35 +02:00
Vincent Prouillet 2e9b7ba522 Enable task lists 2020-06-11 18:29:05 +02:00
Hannu Hartikainen c4154bb8c4
Don't panic on bad date strings (#1051)
* Don't panic on bad date strings

Instead, show a helpful error message explaining only RFC3339 is
supported.

Fixes #993.

* Try to parse the full range of TOML date formats
2020-06-09 22:39:39 +02:00
Hannu Hartikainen 6708f7637c
Implement get_file_hash (#1044)
* Fix get_url(cachebust=true)

The previous implementation looked for static files in the wrong place.
Look in static_path, output_path and content_path. If file can't be
found in any of them, print a warning to stderr and fall back to using
a timestamp.

Add a test to ensure it also works in practice, not just in theory.

* Implement get_file_hash
2020-06-09 22:38:29 +02:00
Vincent Prouillet b87f17570f Remove unneeded build_timestamp on config 2020-05-28 09:21:42 +02:00
Vincent Prouillet b935dc6273 Fix tests 2020-05-27 22:05:56 +02:00
Vincent Prouillet ee594cfc3d Make alias template pass HTML validation 2020-05-27 21:17:12 +02:00
Stan Rozenraukh 8d32f8b3f3
Fix panic in load_data(url=%s) (#1036)
If there is no response from the server, `load_data` would panic
with: `response status`.

This patch removes the `expect` in favor of an error message that we
couldn't get a response from the server for a given url.
2020-05-25 09:25:41 +02:00
Tymoteusz Wiśniewski 974ae167a8
Make path to config.toml independent from root dir (#1023)
fixes #1022
2020-05-23 11:55:45 +02:00
Hannu Hartikainen 36ec33f042
Change get_url(cachebust=true) to use a hash (#1032)
Cache-busting was previously done with a compile-time timestamp. Change
to the SHA-256 hash of the file to avoid refreshing unchanged files.

The implementation could be used to add a new global fn (say,
get_file_hash) for subresource integrity use, but that's for another
commit.

Fixes #519.

Co-authored-by: Vincent Prouillet <balthek@gmail.com>
2020-05-23 11:46:50 +02:00
Vincent Prouillet e1c8c01149 Consistent path for defult index section
Closes #995
2020-05-23 11:43:24 +02:00
hui.liu 32ca1a14ed
Wrap highlight code blocks with <code> (#1026)
* Wrap highlight code blocks with <code>

* Fix tests for highlight code block
2020-05-18 09:41:56 +02:00
Vincent Prouillet fbf431d612 Update syntect, using rust-onig with bindgen temporarily 2020-05-12 20:07:02 +02:00
Vincent Prouillet bc496e6101 Update syntaxes and syntect 2020-04-29 22:35:28 +02:00
southerntofu e3dc8bbab5
Access heading level in anchor-link.html (#1008)
* Add lvl variable in anchor-link context

* Add docs about lvl in anchor-link.html

* Rename lvl => level
2020-04-29 19:40:25 +02:00
Sven-Hendrik Haase e9b47dae59
Remove implicit dependency on openssl-sys (#1001) (#1005) 2020-04-27 09:49:05 +02:00
Vincent Prouillet b96b187eca Fix tests + rustfmt 2020-04-22 10:07:17 +02:00
Andrew Wonnacott d19855e909
Rewrite link_checker to use a Result internally (#928) 2020-04-22 10:04:10 +02:00
Vincent Prouillet c04e6ebaf5 Some tweaks 2020-04-21 19:28:58 +02:00
Vincent Prouillet 0ac70cb242
Merge pull request #994 from chris-morgan/misc
Chris Morgan’s whole bunch of miscellaneous work for landing
2020-04-21 18:21:48 +02:00
Vincent Prouillet 8253adbcc0 Fix tests 2020-04-14 19:15:30 +02:00
Chris Morgan 4653e68715 Add lang, taxonomy and term to feed template
Also a FIXME on the rebuilding part, because it’s presently very wrong.
2020-04-14 17:29:51 +05:30
Chris Morgan eb7751955a WIP: add an 'updated' field to pages
Also change a few other things to use it, as noted in CHANGELOG.md.

TODO:

- Write a couple of tests: updated field, last_updated template variable

One slight open questions: should `updated` default to the value of
`date` rather than to None? Then pages with `date` could safely assume
`updated`.
2020-04-14 17:29:46 +05:30
Chris Morgan 0cc1435f35 Make config.description optional in atom.xml 2020-04-14 17:27:08 +05:30
Chris Morgan 048949ea31 Rename last_build_date to latest_date
The variable name matched the RSS tag it ended up in, but was misleading
about what it actually was—because if you actually want “last build
date”, you should use `now()`. (Due to the potential for edits, I think
that either there should be an official `updated` field on pages, or
that these templates should use `now()`.)
2020-04-14 17:27:08 +05:30
Chris Morgan e25915b231 Support and default to generating Atom feeds
This includes several breaking changes, but they’re easy to adjust for.

Atom 1.0 is superior to RSS 2.0 in a number of ways, both technical and
legal, though information from the last decade is hard to find.
http://www.intertwingly.net/wiki/pie/Rss20AndAtom10Compared
has some info which is probably still mostly correct.

How do RSS and Atom compare in terms of implementation support? The
impression I get is that proper Atom support in normal content websites
has been universal for over twelve years, but that support in podcasts
was not quite so good, but getting there, over twelve years ago. I have
no more recent facts or figures; no one talks about this stuff these
days. I remember investigating this stuff back in 2011–2013 and coming
to the same conclusion. At that time, I went with Atom on websites and
RSS in podcasts. Now I’d just go full Atom and hang any podcast tools
that don’t support Atom, because Atom’s semantics truly are much better.

In light of all this, I make the bold recommendation to default to Atom.

Nonetheless, for compatibility for existing users, and for those that
have Opinions, I’ve retained the RSS template, so that you can escape
the breaking change easily.

I personally prefer to give feeds a basename that doesn’t mention “Atom”
or “RSS”, e.g. “feed.xml”. I’ll be doing that myself, as I’ll be using
my own template with more Atom features anyway, like author information,
taxonomies and making the title field HTML.

Some notes about the Atom feed template:

- I went with atom.xml rather than something like feed.atom (the .atom
  file format being registered for this purpose by RFC4287) due to lack
  of confidence that it’ll be served with the right MIME type. .xml is a
  safer default.

- It might be nice to get Zola’s version number into the <generator>
  tag. Not for any particularly good reason, y’know. Just picture it:

    <generator uri="https://www.getzola.org/" version="0.10.0">
	Zola
    </generator>

- I’d like to get taxonomies into the feed, but this requires exposing a
  little more info than is currently exposed. I think it’d require
  `TaxonomyConfig` to preferably have a new member `permalink` added
  (which should be equivalent to something like `config.base_url ~ "/" ~
  taxonomy.slug ~ "/"`), and for the feed to get all the taxonomies
  passed into it (`taxonomies: HashMap<String, TaxonomyTerm>`).
  Then, the template could be like this, inside the entry:

    {% for taxonomy, terms in page.taxonomies %}
        {% for term in terms %}
            <category scheme="{{ taxonomies[taxonomy].permalink }}"
		term="{{ term.slug }}" label="{{ term.name }}" />
	{% endfor %}
    {% endfor %}

Other remarks:

- I have added a date field `extra.updated` to my posts and include that
  in the feed; I’ve observed others with a similar field. I believe this
  should be included as an official field. I’m inclined to add author to
  at least config.toml, too, for feeds.
- We need to have a link from the docs to the source of the built-in
  templates, to help people that wish to alter it.
2020-04-14 17:27:08 +05:30
Chris Morgan 4a10d0497e Normalise built-in templates
Two main purposes of changes here:

- To make the formatting and indentation of the raw output prettier;
- To simplify the HTML yielded by dropping unnecessary bits.

The 404 changes are a tad more extensive, altering the actual wording to
match conventional stub 404 pages a little more.
2020-04-14 17:27:08 +05:30
Chris Morgan cc01d3f82f Make live reload work with missing </body>
The HTML spec doesn’t require it, and I prefer to omit it. This has been
bothering me for ages, but I hadn’t gotten round to fixing it yet.

This can cause nominally invalid HTML to be emitted, if `</body>` was
omitted but `</html>` was present, but that’s unlikely to happen, and
this is for development purposes only, and the right thing will happen
anyway in all environments (per browser behaviour and spec).

I don’t think this warrants a changelog entry.
2020-04-14 17:27:08 +05:30
Chris Morgan d519cdd0a1 chmod -x a couple of files that needed it 2020-04-14 17:27:08 +05:30
GaaH 41bbaeb970
Add an optionnal lang parameter to get_url (#982)
* get_url takes an optionnal  parameter

* Documentation about the 'lang' parameter of 'get_url'

Co-authored-by: Gaëtan Caillaut <gaetan.caillaut@live.com>
2020-04-12 19:23:17 +02:00