Commit graph

854 commits

Author SHA1 Message Date
BezPowell
35359fb312
Add generic template fallbacks to taxonomies (#1651)
* Split checking for theme template off into separate function

Allows to check for fallbacks elsewhere in the code, without attempting to actually render the template.

* Add template fallback checking to taxonomy pages.

* Add template fallback checking to paginated taxonomies

Requires passing additional arguments to Paginator::from_taxonomy, which may not be desirable.

* Update documentation to reflect taxonomy template fallbacks.

* Update generic taxonomy template names.

* Make check_template_fallbacks() return &str.

* Add tests for check_template_fallbacks
2021-11-29 09:54:16 +01:00
Vincent Prouillet
19125e8dd2
Back to pest (#1665) 2021-11-23 22:58:51 +01:00
Vincent Prouillet
637b00547a
Shortcodes (#1640)
* Next version

* Added tests for shortcode insertion

* Added TOC tests

* Added test for #1475 and #1355

* Basic internal / external links tests

* Added integration test

* Added pseudocode and started on logos

* Logos parsing for shortcodes

* Fixed string literal parsing

Moved string literal parsing to a new lexer in order to have greater
control of control characters which are parsed. This fixes the bug that
was present in the `string_from_quoted` function and also moves the
`QuoteType` to be in the `ArgValueToken`.

* Moved string literal logic to seperate module

* Added square bracket notation for variables

* Error handling rewritten

Remove the Result from the `fetch_shortcodes` function. Added proper
messages within the internal parsing.

* Reorganized and documented the shortcode submodule

* Added all logic for ShortcodeContext spans

* Added working insertion code for MD files

* Made functions generic over Markdown or HTML

* Add check for embedding bodies

* Structure of main function clear

* Added test for `new_with_transforms` function

* It runs!

* Added the code for handling p-ed html shortcodes

* Removed placeholders in markdown function

* Adjusted integration tests

* fetch_shortcodes now also returns a string

* Start of HTML insertion

* Kinda working everything

* Loading of shortcodes and builtins

* Fix tests

* Some missed fixes

* Tweaks + fmt

* Remove string literal handling

* Fix benches

* Grab shortcode def only once per site

* Fix benches

* Rewrite of parser

* Fix tests

* Add test for #1655

* Re-enable integration test

* Add test for #1601

* Add test for #1600

* Add test for #1500

* Add test for #1320

* Fix test on windows?

Co-authored-by: Gijs Burghoorn <g.burghoorn@gmail.com>
2021-11-19 20:31:42 +01:00
Peter Kos
1434eebea4
Add check for export highlight theme CSS in Config (#1650)
* Add check for export themes

* Remove parens

* Add tests
2021-11-09 19:36:01 +01:00
scria1000
7fa58ef45b
Fix get_url resolving asset path to invalid url on Windows (#1632)
* Fix get_url resolving asset path to invalid url on Windows

* Make unit test available for all targets
2021-10-05 19:57:16 +02:00
Miguel de Moura
aaa25cee2a
Fix clippy warnings (#1618)
Fixes clippy warnings for the `needless_borrow` lint.
https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow

Removes the unused `starts_with_schema` function
(dead code since 4086b075).
2021-10-02 11:07:04 +02:00
Vincent Prouillet
2e884e06cb Remove duplicate call to load syntax/themes 2021-09-13 21:13:51 +02:00
David
23064f57c8
Support custom syntax highlighting themes (#1499)
Related to #419

Gruvbox tmTheme added to test_site, it is taken from
https://github.com/Colorsublime/Colorsublime-Themes (MIT licensed)
2021-09-13 21:08:48 +02:00
acheronfail
b503d5cc86
feat: add required argument to taxonomy functions (#1598) 2021-09-04 08:25:03 +02:00
Tim Schumacher
4086b0755a
Support colocating subfolders (#1582)
* Support colocating subfolders

* Adjust tests
2021-09-04 08:23:03 +02:00
southerntofu
84b75f9725
[feature] Shortcodes and anchor-link.html can access lang context (#1609)
* Pass lang to shortcodes context

* Add tests for lang in shortcodes

* Lang is passed to anchor-link.html template

* Document passing lang to shortcodes/anchor-link.html
Add a test to make sure lang can be overriden by passing an explicit argument to the shortcode,
for usage in the markdown filter where the language context is not available.

* Update docs for more information on shortcodes+i18n+markdown() filter

Co-authored-by: southerntofu <southerntofu@thunix.net>
2021-09-04 08:10:33 +02:00
southerntofu
2be1b417d1 config.default_language is exposed to templates 2021-09-01 18:12:35 +02:00
Vincent Prouillet
f7a4ef2617 Add draft to section variable in templates
Closes #1592
2021-08-20 19:47:41 +02:00
Koen Bolhuis
5ca2b29c49
Fix cachebust for files in the output path (#1586)
* Consider the site's output path in search_for_file

The search_for_file helper function now accepts an optional
output path. If passed, the file will also be searched there.
This is used in the get_url function to search in the
Site::output_path.

In practice, this means cachebust works for files in the
output path.

* Make output_dir required in search_for_file

* Update docs for file searching logic

* Add test for new file searching behavior
2021-08-19 07:55:40 +02:00
liushuyu
c658d171f8
cargo/manifests: allow user to use native-tls if ring is unsupported (#1587)
* cargo/manifests: allow user to use native-tls ...

... if `ring` can't be used on the user's platform (e.g. mips/ppc/riscv)

* CI: test for native tls build
2021-08-18 15:32:34 +02:00
Sam Vente
56dcfecce2
make clippy a bit happier (#1588) 2021-08-18 09:36:51 +02:00
Vincent Prouillet
8b43667a94 Ensure code block contents are always escaped
Closes #1581
2021-08-18 09:05:00 +02:00
Vincent Prouillet
88e5c6e167 Update deps 2021-08-12 08:54:55 +02:00
Vincent Prouillet
85f68f87cc Update minify and respect HTML spec 2021-08-09 20:28:17 +02:00
Vincent Prouillet
4a87689cfb Add class based syntax higlighting + line numbers (#1531)
* Add class based syntax higlighting + line numbers

* Use fork of syntect for now

* Fix tests

* Fix diff background on inline highlighter

Co-authored-by: evan-brass <evan-brass@protonmail.com>
2021-07-10 08:53:19 +02:00
Bert JW Regeer
57705aa82e
Add permalink to Taxonomy (#1516)
* Add permalink to Taxonomy

* Document permalink addition to TaxonomyConfig
2021-07-10 08:43:22 +02:00
David Ed Mellum
98b110ba14
Add support for Norwegian search (#1547) 2021-07-07 19:44:10 +02:00
Vojtech Kral
6f22132b8d
imgproc: Don't upscale images in the Fit op, fix a bug in comment in #1542 (#1545)
* imgproc: Don't upscale images in the Fit op, fix  #1542

* imgproc: Remove FIXMEs that have been addressed
2021-07-07 11:15:37 +02:00
Vincent Prouillet
3e1a934604 Fix tests and add note about translations 2021-06-25 10:12:05 +02:00
Vincent Prouillet
06bee578a0 Revert "Exclude self from translation list for page/section"
This reverts commit 0a7692ad85.
2021-06-25 10:09:55 +02:00
Marshall Bowers
93900fb623
Add num_format filter (#1460)
* Add `num_format` filter for displaying formatted numbers

* Register the filter

* Update docs

* Make `locale` argument required

* Revert "Make `locale` argument required"

This reverts commit 9cdbf28591.

* Pull the default locale from the site config

* Add note about defaults to the docs

* Add missing borrow
2021-06-25 10:07:52 +02:00
Vincent Prouillet
0a7692ad85 Exclude self from translation list for page/section
Closes #1410
2021-06-24 23:28:49 +02:00
Vincent Prouillet
545e766818 Allow functions to look into current theme static folder
Closes #1416
2021-06-24 23:12:05 +02:00
Vincent Prouillet
e62664b4ff Unify {page,section}.assets
Closes #1510
2021-06-24 22:22:50 +02:00
Vincent Prouillet
a8acf2cab7 Cache get_image_metadata result 2021-06-14 20:06:57 +02:00
Vincent Prouillet
1bf5cd7bf8 Update docs + sandbox files 2021-06-11 21:14:45 +02:00
Vincent Prouillet
0975b674c5 Hash imageproc on unified path 2021-06-10 10:26:12 +02:00
Vincent Prouillet
38ddb1c4d1 cargo fmt 2021-06-10 10:26:12 +02:00
Vojtech Kral
9145af6b3e imageproc things for paths refactor (#1484)
* Move image loading code used by get_image_metadata from templates to imageproc

* resize_image: Compute image resize op beforehand and return metadata to caller

* get_image_metdata: Use a serializable response struct

* imageproc: Add integration tests

* imageproc: Assume webp is lossy

* get_image_metadata: Use webp crate for decoding WebP, image is still not very good at it

* imageproc: Test read_image_dimensions in integration tests

* imageproc: Rename read_image_dimensions() as read_image_metadata()

* imageproc: Fix a regression in hash computation

* imageproc: Don't hardcode hashes in integration tests, pattern match them instead

* imageproc: Style fixes

* imageproc: Fix integration tests on Windows (hopefully)
2021-06-10 10:26:12 +02:00
Vincent Prouillet
009d105210 Automatically trim / on Tera fn calls dealing with files 2021-06-10 10:26:12 +02:00
Vincent Prouillet
ae916eb6c5 Some more tweaks 2021-06-10 10:26:12 +02:00
Vincent Prouillet
a736d33afb Fix tests on Windows 2021-06-10 10:26:12 +02:00
Vincent Prouillet
9e0cac6d4d Cleanup of get_url and get_file_hash 2021-06-10 10:26:12 +02:00
Vincent Prouillet
7154e90542 Update load_data 2021-06-10 10:26:12 +02:00
Vincent Prouillet
7fb99eaa44 Revamp the images template functions 2021-06-10 10:26:12 +02:00
Vincent Prouillet
b0937fa5b7 Some more cleanup 2021-06-10 10:26:12 +02:00
Vincent Prouillet
a97779567e Split Tera functions in several files 2021-06-10 10:26:12 +02:00
Vincent Prouillet
2289b2f55a Fix config loading
Closes #1512
2021-06-02 21:46:20 +02:00
Tim Schumacher
16c123aa20
Include path in the search index with include_path (#1509) 2021-06-02 09:18:39 +02:00
Avinash Sonawane
4c22996e11
Fix typos (#1505) 2021-05-31 09:20:39 +02:00
Vincent Prouillet
c38d9e56c8 Do not clone ancestors when serializing 2021-05-23 18:19:18 +02:00
Vincent Prouillet
fe79798b0f Remove unused code + rustfmt 2021-05-23 18:13:28 +02:00
Eric Scouten
22c29fe936
Fix race condition in generating next/previous page references when using transparent mode. (#1456) 2021-05-17 22:05:22 +02:00
Waffle Lapkin
f8c6ea2b00
Add new sorting: UpdateDate that sorts by meta.updated. (#1452)
* Add new sorting: UpdateDate that sorts by `meta.updated`.

* Use `max(created, updated)` for sort-by-update-date

This prevents created but never updated articles from appearing at the end/not
appearing at all.
2021-05-15 20:16:55 +02:00
François
b244bcdfbb
Hide lines in code block (#1453)
* hide lines

* test hide ines

* add documentation

* fix test

* factor shared code with hl_lines
2021-05-14 20:25:13 +02:00
Vincent Prouillet
dec5a8563c Fix language in rss.xml
Closes #1442
2021-05-09 23:19:56 +02:00
Vincent Prouillet
1fab9c664d Update slotmap + handle in memory XML content type in zola serve
Second part of #1308
2021-05-09 15:57:46 +02:00
Vincent Prouillet
fecc3cf148 Strip footnotes link from summaries
Closes #1282
2021-05-08 23:27:23 +02:00
Vincent Prouillet
80843cdeff u16 for anchor levels
Closes #1436
2021-04-26 09:24:27 +02:00
Vincent Prouillet
4f6528cf37 Allow whitespace on the same line as closing front-matter chars 2021-04-26 09:23:57 +02:00
Vincent Prouillet
e92e4f1003 Tweaks to load_data + update deps 2021-04-21 21:43:02 +02:00
Marco Tolk
1bd777f0e5
Add HTTP POST capability to load_data() (#1400)
* Fixed failing tests on windows when user is not VssAdministrator.

* Fixed windows specific testcases related to \r

* Added the ability to perform POST requests to load_data

* make tests on windows deal with both \r being there on windows, and \r not being generated as on my personal windows system.

* undo earlier commit eaaa8c3ddd

because it fails on azure buildserver

* added new arguments to the hash for the cache function.

So caching now works as it should

* added new arguments to the hash for the cache function.

* improved documentation of load_data POST with better example.

* added basic derive traits

* changed load_data param contenttype to content_type

* fixed caching issues that went missing?

* format

* made code more idiomatic as suggested by keats
2021-04-21 21:29:47 +02:00
Stanislas
47b920777a
link_checking: prevent rate-limiting (#1421)
* link_checking: prevent rate-limiting

Fix for https://github.com/getzola/zola/issues/1056.

- assign all links for a domain to the same thread
- reduce number of threads from 32 to 8
- add sleep between HTTP calls

* Add get_link_domain(), use for loops

* Do not sleep after last link for domain

* Avoid quadratic complexity

* remove prints
2021-04-21 21:13:38 +02:00
Luca Bruno
3346439a32
rendering: keep track of all internal links (#1424)
This updates rendered markdown structures in order to keep track
of all internal links, not anymore limiting to only those targeting
an explicit anchor fragment.
The goal of this rework is to allow building other features, such
as backlinks, on top of the existing collection of internal links.
2021-04-21 21:13:11 +02:00
Songmin Li
4f7b960985
Fix can not build with indexing-zh (#1433)
* fix can not build zola with search/indexing-zh feature

* fix can not build components/utils after enabled indexing-zh feature

error[E0252]: the name `Deserialize` is defined multiple times
 --> components/utils/src/de.rs:2:5
  |
1 | use serde::{Deserialize, Deserializer};
  |             ----------- previous import of the macro `Deserialize` here
2 | use serde_derive::Deserialize;
  |     ^^^^^^^^^^^^^^^^^^^^^^^^^ `Deserialize` reimported here
  |
  = note: `Deserialize` must be defined only once in the macro namespace of this module
2021-04-19 10:33:12 +02:00
Jason Miller
421a2512f7
Hash collision using the same quality level and incorrect quality for WebP (#1431)
* fix: webp quality level mismatch

* fix: hash collision using the same image ops

Using the same image operations, but for different formats, e.g. `.jpg` and
`.webp`, produced the same hash.

To differentiate between these, the image extension is added to the hash.
2021-04-18 11:07:10 +02:00
Vincent Prouillet
fc808f2aa8 Some clippy fixes 2021-04-07 22:13:15 +02:00
Vincent Prouillet
0afd31d660 cargo fmt 2021-04-07 22:13:15 +02:00
Vincent Prouillet
d3caa56da2 Nest translations in languages options 2021-04-07 22:13:15 +02:00
Vincent Prouillet
32433e7d6c Lang aware search indices settings 2021-04-07 22:13:15 +02:00
Vincent Prouillet
187bc30f00 Serializing lang aware configs 2021-04-07 22:13:15 +02:00
Vincent Prouillet
0812b603a6 Remove deprecated config options 2021-04-07 22:13:15 +02:00
Vincent Prouillet
86b42fc1ab Move taxonomies to language options dict 2021-04-07 22:13:15 +02:00
Vincent Prouillet
7484138a91 Add a LanguageOption for the default language if there is none 2021-04-07 22:13:15 +02:00
Vincent Prouillet
975800eb5b Enforce unic valid language codes 2021-04-07 22:13:15 +02:00
Vincent Prouillet
341ac3bfbd
Southerntofu bugfix index translations (#1417)
* Translations are also generated for the index page (fix #1332)

* More tests for translations

* Even better error message

* Update page count for test

* Patch to fix Windows tests

By @mtolk

Co-authored-by: southerntofu <southerntofu@thunix.net>
2021-03-22 20:56:11 +01:00
Bert JW Regeer
5bf9ebc43a
Feature: allow spaces between dashes in filename for page (#1323)
* Allow optional whitespace around dash/underscore in filename

Allow file names that are as follows:

    2021-01-01 - test.md

To be parsed the same as if they were

    2021-01-01-test.md

The slug for both will now just be "test" instead of previously the
first example would have become "2021-01-01-test".

* Add documentation for optional whitespace in filename

* Test that updated regex does not take space after dash
2021-03-22 20:00:25 +01:00
Bert JW Regeer
5b005b48aa
Allow frontmatter to have optional newline if no content (#1408)
Without content it should be possible to create a file that contains no
newlines after the frontmatter at all, rather than forcing a newline
after the frontmatter.
2021-03-15 08:52:10 +01:00
Vincent Prouillet
25ef603990 Error on invalid file/section 2021-03-06 23:00:56 +01:00
snake66
67f9b9499b
Fix language specific non-internal urls for get_url. (#1381)
* Fix language specific non-internal urls for get_url.

* get_url: PathBuf for URL's don't work on Windows.
2021-03-06 22:49:04 +01:00
Vincent Prouillet
2a46e07e74 Add path to TaxonomyTerm
Closes #1336
2021-02-22 21:27:52 +01:00
Vincent Prouillet
7fc7ef4720 Add tests for slug strategy in filenames with dates 2021-02-22 20:39:31 +01:00
Vincent Prouillet
2bbd3bd424 Fix compute_hash 2021-02-21 09:09:02 +01:00
Vincent Prouillet
3262f69bb0 Single compute_hash fn + cargo fmt 2021-02-20 14:07:36 +01:00
Skyper
d3ab3936de
[WIP] Add support for base64-encoded hash values to 'get_file_hash' (#1339)
* Add support for base64-encoded hash values

The global template function 'get_file_hash' can now return a
base64-encoded hash value when its 'base64' parameter is set to true.

See discussion in #519.

* Fix integrity attribute's value in test site

SRI hash values must be base64-encoded.

* Update documentation about 'get_file_hash'

* Fix 'can_get_hash_for_static_files' unit test
2021-02-20 13:31:37 +01:00
Hanno Braun
6d6df45f23
Make shortcodes work in markdown filter (#1358)
* Move `load_tera` to `templates`

I don't know if this is a good place for it, conceptually. I'm moving it
there because I need to use it from `templates`, and `templates` can't
depend on `site`, because there's already a dependency in the opposite
direction.

* Load templates in `markdown` filter

This enables the `markdown` filter to handle shortcodes, as long as
those shortcodes don't access any context variables.

Addresses #1350

* Update documentation of `markdown` filter

* Only load templates for `markdown` filter once

* Clarify `markdown` filter documentation

This is a lightly edited version of what @southerntofu suggested.
2021-02-19 20:51:08 +01:00
Philip Kristoffersen
8eac5a5994
WebP support in resize_image (#1360)
* Removing unused webpl

* Adding clarification comment

* Updating documentation

* Adding webp
2021-02-18 22:30:10 +01:00
Chiu-Hsiang Hsu
3cb61c3bcd
Support embed YouTube playlist (#1342) 2021-02-07 17:13:03 +01:00
Matt Riggott
a65a2d52c7
Update minify-html dependency to version 0.4.2 (#1340)
* Update minify-html dependency to version 0.4.2

Fixes https://github.com/getzola/zola/issues/1300. See also https://github.com/wilsonzlin/minify-html/issues/21

* Update minify-html dependency in Cargo.lock

* Add test to check pre whitespace isn't collapsed
2021-02-06 16:41:10 +01:00
southerntofu
53456bd052
Don't panic for missing highlight theme (close #1299) (#1307)
* No panic when markdown.highlight_theme is missing

* Better error message for missing theme

* Better error messages

Co-authored-by: southerntofu <southerntofu@thunix.net>
2021-02-04 09:54:12 +01:00
Vincent Prouillet
aa57541c21 Force newline after front-matter
Closes #1287
2021-02-02 21:53:37 +01:00
Vincent Prouillet
024144ba78 cargo fmt 2021-02-02 20:49:57 +01:00
Vincent Prouillet
34989a8ef6 Fix panic in loading Page
Closes #1327
2021-02-02 20:48:32 +01:00
Vincent Prouillet
8e6c3f4fef Update changelog + deps 2021-02-02 20:25:27 +01:00
southerntofu
15e0ae6699
load_data() template function takes a required boolean flag (closes #1209) (#1306)
* load_data() template function takes a `required` boolean flag

* Update tests for load_data()

* Add test to make sure invalid data always fails in load_data

* Better documentation, fixing a few typos

Co-authored-by: southerntofu <southerntofu@thunix.net>
2021-02-02 20:19:44 +01:00
David James
92b5b4b3a5
Add sort_by title (#1315)
* Add sort_by=title

* Remove old comment.

* Remove println! debugging

* Minor: text spacing

* Use lexical_sort crate for sort_by title

Co-authored-by: David James <davidcjames@gmail.com>
2021-01-20 15:35:25 +01:00
southerntofu
6950759eda
Internal links are supported in markdown filter (#1318)
* Internal links are resolved in tera markdown filter (close #1296 #1316)

* Add a test for internal links in markdown filter

Co-authored-by: southerntofu <southerntofu@thunix.net>
2021-01-20 09:24:55 +01:00
southerntofu
14366dafc6
Fix fallback to syntax highlighting theme (closes #1309) (#1312)
* Highlight fallback from extra syntaxes to the theme (close #1309)

* Warning when codeblock language is unknown and cannot be highlighted

* page/section path in codeblock language missing warning

Co-authored-by: southerntofu <southerntofu@thunix.net>
2021-01-18 09:35:17 +01:00
Vincent Prouillet
96fb798a4a Update test-case 2021-01-17 09:41:33 +01:00
Musee Ullah
0a5181d621
Ensure minified HTML is truncated before converting to String
Closes #1304
2021-01-12 21:03:49 -06:00
Vincent Prouillet
779a15a500 Pass lang to 404
Closes #1281
2021-01-09 10:21:50 +01:00
Vincent Prouillet
819cfc8ec2 Cargo update 2021-01-09 10:16:50 +01:00
Vincent Prouillet
1a36c20bd2 Fix html minification
Closes #1292
2021-01-07 19:04:17 +01:00
Vincent Prouillet
aa03a7fec5 Fix highlighting
Closes #1291
2021-01-07 11:34:48 +01:00
Vincent Prouillet
877f441422 Update reqwest 2021-01-05 22:11:15 +01:00
Vincent Prouillet
6622078038 DRY things a bit 2021-01-05 21:48:35 +01:00
Sam Vente
369fb40dfe
move translation population and path collision checking to insert stage (#1272) 2021-01-05 21:39:25 +01:00
Vincent Prouillet
b9b4ef9f04 Add data-lang on code blocks 2021-01-02 09:29:28 +01:00
Vincent Prouillet
7540ecd58e Prefer custom syntax before built-in ones 2020-12-29 10:36:40 +01:00
Vincent Prouillet
2362cf2415 Move syntaxes around to make packing a two step process
Closes #1268
2020-12-28 17:39:54 +01:00
Vincent Prouillet
657905ed6e Remove watch-only 2020-12-22 21:35:15 +01:00
Vincent Prouillet
39870d8675 Move extra_syntax to markup.rs 2020-12-21 08:54:43 +01:00
Vincent Prouillet
96439df0e2 Add some debug log time 2020-12-21 08:54:35 +01:00
Vincent Prouillet
fc8b4066f2 Update syntaxes + replace js lang in rendering
Closes #1241, #1211
2020-12-15 10:42:35 +01:00
Vincent Prouillet
68cdfcbbe7 Fix panic with misnamed index section
Closes #1244
2020-12-14 22:51:30 +01:00
Nathanael Lane
a210abc5a3 Add shortcode 'invocation' variable to allow a shortcode to track how… (#1236)
* add shortcode 'invocation' variable to allow a shortcode to track how many times it has been invoked in a given Markdown file

* use closure (implicit struct) instead of explicit struct for invocation tracking

* update variable name to "nth"
2020-12-14 20:43:32 +01:00
Sylvain Kerkour
a93063ba4a search: Update elasticlunr.min.js to 0.9.6 (#1260) (#1261) 2020-12-14 20:43:32 +01:00
Rostislav
679af5b8c8 add Allow: / to default robots.txt template (#1258)
Also update the documentation about it.
2020-12-14 20:43:32 +01:00
Kevin Ottens
4754cb5792 Yaml frontmatter (#990)
* Accept dates presented as strings

Still, if we find a string we involve the TOML parser to make sure the
content of said string would be a correct TOML date. In a pure TOML
world this isn't exactly relevant, but this will come in handy when
using a YAML deserializer.

Signed-off-by: Kevin Ottens <ervin@ipsquad.net>

* Add serde_yaml and test-case dependencies

This will be necessary for the YAML frontmatter handling and
corresponding unit tests.

Signed-off-by: Kevin Ottens <ervin@ipsquad.net>

* Add YAML front matter handling

Signed-off-by: Kevin Ottens <ervin@ipsquad.net>

* Switch RawFrontMatter enum to wrap &str instead of String

Signed-off-by: Kevin Ottens <ervin@ipsquad.net>

* Update the documentation to mention YAML frontmatter

This is just a light update on purpose. There would be no point in
pushing YAML too much, this is mainly here to help people with a backlog
of posts to transition.

Signed-off-by: Kevin Ottens <ervin@ipsquad.net>
2020-12-14 20:43:31 +01:00
Vincent Prouillet
f20c52b872 Re-use markdown parser for markdown filter 2020-12-14 20:43:31 +01:00
Vincent Prouillet
59d3d8a3da Enable smart punctuation
Closes #740
2020-12-14 20:43:31 +01:00
Vincent Prouillet
e58c2d6b6c More details on fs errors 2020-12-14 20:43:31 +01:00
Vincent Prouillet
2c681f3439 Add some external link markdown tweaking options
Closes #681, #695
2020-12-14 20:43:31 +01:00
Vincent Prouillet
047ce32efd Clippy 2020-12-14 20:43:31 +01:00
Vincent Prouillet
94634fe87d Move markdown config to its own section in config.toml 2020-12-14 20:43:31 +01:00
Renato Caldas
2673466998 Add bibtex support to load_data() (#1190)
* Add support for loading Bibtex data.

* Add load_data() documentation for the bibtex format

* Force bibtex tags to be lower case.

Bibtex tags are case-insensitive, and this works around tera's case-sensitiveness.

* Improve the load_data() documentation for the bibtex format
2020-12-14 20:43:31 +01:00
Vincent Prouillet
92282608fe Update changelog 2020-12-14 20:43:31 +01:00
Basix
944cba030e Allow to specify default language in filenames (#1233)
* Use default language if code is same as default

* Add test for specifying default locale

* Update docs to mention default languages
2020-12-14 20:43:31 +01:00
Vladislav Nikonov
b1091bbb45 Implemented emoji aliases support in markdown files (#1194)
* Implemented emoji aliases support in markdown files

* Added emoji aliases rendering unit tests

* Added bench for emoji
2020-12-14 20:43:31 +01:00
Vincent Prouillet
a26422d401 Update changelog 2020-12-14 20:43:31 +01:00
Sam Vente
c40fb91ba8 Make sections draftable (#1218)
* make sections draftable

* add documentation paragraph about drafting sections
2020-12-14 20:43:31 +01:00
Cthulhux
da37db1258 Enable YouTube privacy mode (#1201)
* Update themes gallery

* Enable YouTube privacy mode

As recommended: https://www.ghacks.net/2018/05/23/why-you-should-always-use-youtubes-privacy-enhanced-mode/

* Adjusted tests for privacy mode

Co-authored-by: GitHub Action <action@github.com>
Co-authored-by: Vincent Prouillet <balthek@gmail.com>
2020-12-14 20:43:27 +01:00
areille
6a31ccff99 Enable html minification (#1208)
* Next version

* Remove lines forcing minify_html to false

* Update documentation about minify_html

* Update changelog

Co-authored-by: Vincent Prouillet <balthek@gmail.com>
2020-12-14 20:42:55 +01:00
Christoph Grabo
6ef81940b8 Add language class to code tag
class attribute is only added if a language is available.
It uses the format "language-xxx" as per commonmark spec:
https://spec.commonmark.org/0.29/#example-112 ff.
2020-12-14 20:42:55 +01:00
Takayuki Nakata
575c38f9c8 Support output_dir in config.toml 2020-12-14 20:42:55 +01:00
Vladislav Nikonov
4f5d9bd8b0 Fixed site benches compilation 2020-12-14 20:42:55 +01:00
Vincent Prouillet
664cb14ffd Add test for continue reading after shortcode 2020-09-24 20:02:43 +02:00
Vincent Prouillet
59d9d26f0e Fix shortcodes issues with newlines
Closes #1172
2020-09-24 20:02:43 +02:00
Vincent Prouillet
b313c97ceb Fix slugified taxonomies rendering
Closes #1177
2020-09-22 09:46:22 +02:00
John-John Tedro
f9ae897190 Use platform-neutral path comparison for in-memory serving (fixes #1169) (#1175)
This introduces `relative-path`, a crate I've written for the specific
purpose of providing platform-neutral operations over paths the same way
they are used in URLs.

This means that `///hello///` == `/hello`, which should do the same as
the existing stripping minus the platform-specific path separators
causing the [bug being referenced](#1169).
2020-09-22 09:46:22 +02:00
Thomas Etter
f7cd28c8d2 Fix a crash when --output_dir is used with serve (#1164) 2020-09-22 09:46:22 +02:00
bemyak
d9396213de Allow site path to contain underscores (#1162)
* Allow site path to contain underscores

Fixes site.css is not being generated if any part of the path contains
underscores

* Add tests for path with underscores
2020-09-22 09:46:22 +02:00
areille
5a61139719 Add better errors for minifying and upgrade crate 2020-09-22 09:46:22 +02:00
Alice Ryhl
826e701b4f Add line highlighting to code blocks (#1131)
* Add line highlighting to code blocks

* Fix highlighting of lines

Apparently every line to be highlighted is provided in one chunk.

* Add more documentation to codeblock.rs

* Turn FenceIter into an Iterator

* Move Range to fence.rs

* Add tests
2020-09-22 09:46:22 +02:00
Vincent Prouillet
f786783299 Update pulldown_cmark 2020-09-03 21:22:20 +02:00
Sam Vente
2ac1d79f8f
fix get_taxonomy_url to handle merged taxonomies properly (#1155) 2020-09-02 11:40:06 +02:00
Vincent Prouillet
6c2300f916 Disable minify_html for now 2020-09-01 21:07:18 +02:00
Sam Vente
c143d95c4e
Reverse pagination (#1147)
* mention code block output change

* Update snap

* Update themes gallery (#1082)

Co-authored-by: GitHub Action <action@github.com>

* Deployment guide for Vercel

* Change wording a bit

* Update themes gallery (#1122)

Co-authored-by: GitHub Action <action@github.com>

* Add feed autodiscovery documentation (#1123)

* Add feed autodiscovery documentation

* Fix link in template

* Docs/configuration update (#1126)

* Update configuration documentation

- Attempt to split the configuration file into sections to make it more readable and
  avoid configuration mistakes (#1056).
- Move translation instructions to the right part.
- Add a bit more explanations to the extra section.

* Take into account @Keats feedbacks

* Remove short notice about translation usage

- A i18n page should be created to better explain it.

* add fix for (#1135) Taxonomies with identical slugs now get merged (#1136)

* add test and implementation for reverse pagination

* incorporate review changes

Co-authored-by: Michael Plotke <bdjnks@gmail.com>
Co-authored-by: Vincent Prouillet <balthek@gmail.com>
Co-authored-by: GitHub Action <action@github.com>
Co-authored-by: Samyak Bakliwal <w3bcode@gmail.com>
Co-authored-by: René Ribaud <uggla@free.fr>
2020-09-01 21:00:21 +02:00
areille
0df3631b3d
Add minify support (#1146)
* Doc add a missing arg to `get_taxonomy_url` (#1139)

This feature is already exist, but not in the doc yet

Related #766

* Add minify support

* Add documentation

* Code review

* Fix error in documentation

* Update minify-html to 0.3.6

* Move minify into write_content function

* Fix multiple calls to minify()

* Add test for minified output

* Fix breaking test

Co-authored-by: Ken <2770219+ken0x0a@users.noreply.github.com>
2020-08-28 19:39:19 +02:00
Yaroslav
d571dea8c3
Per section/subsection feeds (#1128)
* Per section/subsection feeds

* Added `generate_feed` variable to section front matter.
* Generate atom/rss feeds for sections/subsections that have the
`generate_feed` variable set to true (false by default); this works
independent of the `generate_feed` variable in the root `config.toml`
file, however, the name (and template) of the feed file for each section
is the same as `feed_filename` in `config.toml`, just located in the
root of each section.
* Slightly edited `atom.xml` and `rss.xml` so that they include the
section title (if any), and the url of a section, if it's a section
feed.

* Section feeds: tests

* Changed a couple of sections' front matter in order to generate feeds
for them for the test.
* Changed the can_build_feed test in site package to can_build_feeds and
included some assertions to make sure that section feeds are generated
when requested.

* Section feeds: documentation

* Added information about the section front matter variable
`generate_feed` in the section content page.
* Added information about section feeds in the feeds template page.

* Section feeds fix: use section.path for feed path
2020-08-27 20:21:37 +02:00
Sam Vente
6e16dfdc29
A Fix for the permalinks in #1136 (#1142)
* add fix for (#1135) Taxonomies with identical slugs now get merged (#1136)

* update templates so they propperly render taxonomy names

* squash! add fix for (#1135) Taxonomies with identical slugs now get merged (#1136)

reimplement taxonomy deduping

* revert unwanted changes to templates

* add tests for unic in permalinks

* add tests for unic in permalinks
2020-08-26 19:36:02 +02:00
Nathan West
af0dd5ef32
Fixed unsound errors (#1143) 2020-08-20 19:51:17 +02:00
Nathan West
51a2213fcf
Replaced all impl Default with derive(Default), where possible (#1141) 2020-08-19 12:25:54 +02:00
Nathan West
159ce0f672
Fix toml parse error line number (kind of) (#1138)
- Minor change to how frontmatter is detected so that toml issues
correct line numbers
- split_content now returns (&str, &str)
2020-08-18 13:14:27 +02:00
Sam Vente
05646ab573
add fix for (#1135) Taxonomies with identical slugs now get merged (#1136) 2020-08-18 12:59:33 +02:00
Vincent Prouillet
ffaf5e04b8 Do not unwrap on invalid utf8 in link checker
Closes #1134
2020-08-17 18:58:08 +02:00
Vincent Prouillet
278cc82fc7
Change zola serve to load HTML from memory instead of disk (#1114)
* Change zola serve to load HTML from memory instead of disk

* Be smart about assets copying

* Be a tiny bit smarter on template changes

* Add zola serve --fast
2020-08-16 18:39:04 +02:00
Peter H. Ezetta
623817120c
Updating filetime to v0.2.12 for OpenBSD support (#1120) 2020-08-11 20:28:14 +02:00
liushuyu
6af7959fce
Making Chinese and Japanese search indexing optional... (#1115)
* This can shave ~80 MB off the binary size while allowing users
  speaking these two languages to easily switch them back on
2020-08-07 17:03:51 +02:00
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
Vincent Prouillet
b2eb00a374 Ensure lang is always set on default sections 2020-04-12 19:17:29 +02:00
Vincent Prouillet
56e25132a9 Update deps + fix some misleading doc 2020-04-12 17:21:04 +02:00
Yusuke Tanaka
e3cb4ff0ea
Preserve timestamps when copying files (#974) (#983)
* Preserve timestamps when copying files (#974)

* Do not copy files with the same modification timestamps

* Clean temp dbg!

* Add filesize comparison
2020-04-04 11:05:24 +02:00
Gaëtan Caillaut
16a22e76fa Fail if a language is set both in config.default_languages and config.languages 2020-03-31 02:15:58 +02:00
Vincent Prouillet
01597adfd2 Pass lang to taxonomy list template
Closes #963
2020-03-25 20:05:10 +01:00
Vincent Prouillet
91bf91a88b Fix link checker not checking for capital id/name
Closes #948
2020-03-25 19:54:24 +01:00
Vincent Prouillet
2eb8dcdf87 Revert "Fix RSS template (#969)"
This reverts commit 4b0339377f.
2020-03-12 20:44:41 +01:00
Andrew Barchuk
4b0339377f
Fix RSS template (#969)
Remove a link tag mistakenly imported from Atom XML namespace. The tag
was used to specify the link to the feed itself which is not supported
by RSS 2.0:
https://cyber.harvard.edu/rss/rss.html

Fixes #967
2020-03-12 20:31:29 +01:00
Vincent Prouillet
457996046c Update deps and changelog 2020-03-12 18:44:31 +01:00
Vincent Prouillet
2eaa791349 Enable strikethrough in markdown filter 2020-02-28 08:17:01 +01:00
Luke Hsiao
661bd9c0fa Set default user agent for external requests
Many servers will return errors (e.g. 400/403) to requests that do not
set a User-Agent header. This results in issues in both the link_checker
and load_data components. With the link_checker these are false positive
dead links. In load_data, remote data fails to be fetched. To mitigate
this issue, this sets a default User-Agent of

    $CARGO_PKG_NAME/$CARGO_PKG_VERSION

Note that the root cause of this regression from zola v0.9.0 is that
reqwest 0.10 changed their default behavior and no longer sets a
User-Agent by default:

    https://github.com/seanmonstar/reqwest/pull/751

Fixes #950.
2020-02-17 17:40:06 -08:00
Vincent Prouillet
15a3ab1a51 One last deps update 2020-02-16 19:17:41 +01:00
Vincent Prouillet
855d2376df Fix some theme extension
Closes #937
2020-02-10 23:09:22 +01:00
Vincent Prouillet
0d5fefd446 Update image to 0.23 2020-02-10 20:48:52 +01:00
Vincent Prouillet
a903473a87 Use rustls reqwest feature 2020-02-07 21:16:44 +01:00
Aphek
cc67bf0c88
Change continue-reading to use a span with id instead of a named anchor in a paragraph (#941)
* Change continue-reading to use a span element instead of named anchor

* Fix all tests
2020-02-07 21:07:10 +01:00
Vincent Prouillet
ac3ced828b
Multiple slugification strategies (#929) 2020-02-05 09:13:14 +01:00
Vincent Prouillet
8c1faac761 Update deps + fix tera fn error msg 2020-02-02 17:48:43 -08:00
Travis Cross
983e021d5b Fix warning when building site tests (#936)
For the site integration tests, we have a file of common code which is
used by multiple files in `tests/`.  However, not all functions in
this file are used by all files in `tests/`.

As Cargo compiles each `tests/*.rs` file as a separate crate, this
means that some of these crates end up with unused code.  Rust notices
this and prints a warning.

Let's tell Rust that we don't care about dead code in this file so
that the warning is not printed.
2020-02-02 17:48:43 -08:00
ethereal
94445ae745 Add --root global argument. Fixes #899. (#932) 2020-02-02 17:48:43 -08:00
Sepehr Torab Parhiz
2fa442cead Add Markdown strikethrough rendering (#924)
Fixes #921
2020-02-02 17:48:43 -08:00
Rostislav
145671ed20 Detect empty links on markdown rendering and issue an error (#884)
* Detect empty links on markdown rendering and issue an error

* Add a test for empty links stopping rendering with an error

* Assert error message is the expected one

When testing for empty links detection compare the error message
to make sure it's the correct error that stopped the process
and not some unrelated issue.
2020-02-02 17:48:43 -08:00
Sam Ford
0c93e15b1f Update tokio and re-enable check_site test (#915)
The issue with the check_site test hanging and timing out seems to
be related to a similar reqwest issue, which was ultimately due to
an upstream bug in tokio and may be fixed in tokio 0.2.7 onward.
2020-02-02 17:48:43 -08:00
djugei
046213ce28 fixed warning (#912) 2020-02-02 17:48:43 -08:00
Vincent Prouillet
44a07a4a55 Disable check_site test for now 2020-02-02 17:48:43 -08:00
Vincent Prouillet
622b0f2965 Serialize toc level 2020-02-02 17:48:43 -08:00
Sam Ford
d7bad732f1 Update reqwest to v0.10 (#892) 2020-02-02 17:48:43 -08:00
Sam Ford
3ef62036ef Fix benchmarks (#901)
* Restore #![feature(test)] and extern crate test; statements, which
were mistakenly removed as part of the Rust 2018 edition migration.

* Fix rendering benchmark's usage of RenderContext. 6 parameters were
provided when 5 were expected.
2020-02-02 17:48:43 -08:00
Sam Ford
6b5768fd76 Treat 304 as valid, add mock tests, fix mock issue (#900)
* Treat 304 (Not Modified) requests as valid.

* Add tests for 301-to-200 links, 301-to-404 links, and 500 links.
This helps to test redirections and the previously-added
response.status() checking for non-success status codes in check_url().

* Make names for HTTP mock paths unique, to avoid weird behavior. It
seems like mocks with the same path can potentially bleed between
tests, so you may end up with an unexpected response which causes the
test to sometimes pass and sometimes fail.

* Fix Clippy warnings about String::from(format!()).
2020-02-02 17:48:43 -08:00
Sam Ford
11f7a6d114 Mock HTTP requests in tests (#898)
Certain tests involving HTTP requests were sometimes hanging
indefinitely, so this uses Mockito for HTTP mocking. This seemingly
resolves the issue and makes these tests more reliable.

The existing can_fail_404_links test has been renamed to
can_fail_unresolved_links, to represent what actually occurs in the
test. The can_fail_404_links test now deals with a proper 404
response.

Just to be clear, the check_site test in the site component will
still create outgoing HTTP requests (due to the URLs used in the
test_site), so this commit only uses HTTP mocking where possible.
2020-02-02 17:48:43 -08:00
Sam Ford
2f1b592ab4 link_checker: Handle non-success status codes (#897)
The can_fail_404_links() test doesn't encounter a 404 response in
actuality, since the google.comys domain doesn't resolve. When the
test is updated such that the response's status code is a 404, the
test fails because the check_url() function doesn't handle
non-success responses how the test's assertions expect. This commit
updates check_url() to handle non-success responses, treating them
much like errors.
2020-02-02 17:48:43 -08:00
Sam Ford
b63c563622 Format code using cargo fmt (#896) 2020-02-02 17:48:43 -08:00
Sam Ford
e804f907b2 Use Rust 2018 edition (#885) 2020-02-02 17:48:43 -08:00
Vincent Prouillet
ceb9bc8ed7 Optionally do not slugify paths (#875)
* maybe_slugify() only does simple sanitation if config.slugify is false

* slugify is disabled by default, turn on for backwards-compatibility

* First docs changes for optional slugification

* Remove # from slugs but not &

* Add/fix tests for utf8 slugs

* Fix test sites for i18n slugs

* fix templates tests for i18n slugs

* Rename slugify setting to slugify_paths

* Default slugify_paths

* Update documentation for slugify_paths

* quasi_slugify removes ?, /, # and newlines

* Remove forbidden NTFS chars in quasi_slugify()

* Slugification forbidden chars can be configured

* Remove trailing dot/space in quasi_slugify

* Fix NTFS path sanitation

* Revert configurable slugification charset

* Remove \r for windows newlines and \t tabulations in quasi_slugify()

* Update docs for output paths

* Replace slugify with slugify_paths

* Fix test

* Default to not slugifying

* Move slugs utils to utils crate

* Use slugify_paths for anchors as well
2020-02-02 17:48:43 -08:00
Sam Ford
0a0b6a3ad4 Fix Clippy warnings (#886)
This addresses the following Clippy warnings:

* clippy::option_and_then_some
* clippy::useless_format
2020-02-02 17:48:43 -08:00
Vincent Prouillet
8e3f1f59f6 Update Tera 2020-02-02 17:48:43 -08:00
Philipp Oppermann
72373bea9b Add path to TranslatedContent (#863)
* Add path to `TranslatedContent`

This makes it possible to retrieve the translated page through the `get_page` function.

* Use TranslatedContent::path field in test_site_i18n

Use it with the `get_page` function to get a reference to the page object.
2020-02-02 17:48:43 -08:00
Vincent Prouillet
73ea4b3b16 Finish path collision & fix paginate_path when empty
Closes #866
2020-02-02 17:48:43 -08:00
Vincent Prouillet
5532f62c2d Check for paths collisions
Closes #366
2020-02-02 17:48:43 -08:00
Vincent Prouillet
6153d20047 Link to issues for regression tests 2020-02-02 17:48:43 -08:00
Philipp Oppermann
3362df4a48 Compute canonical path before adjusting parent path (#856)
* Compute canonical path before adjusting parent path

* Don't use adjusted `parent` to recalculate `canonical` in `find_language`

* Add regression tests

- Test for correct canonical field when calling `new_page`
- Test for correct canonical field after calling `find_language`
2020-02-02 17:48:43 -08:00
Stan Rozenraukh
a89b30073c Section extra -> SitemapEntry (#850) 2020-02-02 17:48:42 -08:00
Tjeu Kayim
75570d041a Skip link checking for URL with prefix in config (#846) 2020-02-02 17:47:01 -08:00
Morgan
e8dc33ad08 fixes #844 duplicate entries in doc (#845) 2020-02-02 17:47:01 -08:00
Laurent Arnoud
aaaed31f9c Add title and body to alias page (#830) 2020-02-02 17:45:16 -08:00
Vincent Prouillet
d624f7ec8b Update base64 2020-02-02 17:45:16 -08:00