Commit graph

422 commits

Author SHA1 Message Date
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
Geobert Quach 3f166285de Paginator total pages (#829)
* feat(pagination): Add `total_pages` in paginator object

* feat(pagination): Added doc for `total_pages`

* feat(pagination): Added test for `total_pages`
2020-02-02 17:45:16 -08:00
Jochen Kupperschmidt 587d7396b3 Properly escape & in injected live-reload script tag (#825)
"[…] `&` normally indicates the start of a character entity reference or
numeric character reference; writing it as `&` […] allows `&` to be
included in the content of an element or in the value of an attribute."

From: https://en.wikipedia.org/wiki/HTML#Character_and_entity_references
2020-02-02 17:45:16 -08:00
Jochen Kupperschmidt b3bc8a8896 Do not attempt to serve on "well-known" ports (#824) 2020-02-02 17:45:16 -08:00
Vincent Prouillet 243702e2c2 Update tera 2020-02-02 17:45:16 -08:00
Tjeu Kayim 6149fd17e1 Skip anchor checking for URL with prefix in config (#812)
* cargo fmt & clippy

* Skip anchor checking for URL with prefix in config
2020-02-02 17:45:16 -08:00
Bob 4aa2ba84fc Let toc is visable through Page & Section variables in templates (#818)
* Let toc is visable through Page & Section variables in templates

* Removed the current toc variable from page & section
2020-02-02 17:44:38 -08:00
Michael Macias b1ceb3e80e rendering: Avoid prepending URL prefix to links that start with a scheme (#817)
Links that start with a scheme (e.g., `tel:18008675309`) inadvertently
had a URL prefix prepended. Previously, only `mailto:` was handled, but
given the sheer number of [registered URI schemes][uri-schemes], a loose
pattern matcher is used to detect schemes instead.

External links, as identified by the renderer, are now limited to `http`
and `https` schemes.

Fixes #747 and fixes #816.

[uri-schemes]: https://www.iana.org/assignments/uri-schemes/uri-schemes.xhtml
2020-02-02 17:44:38 -08:00
Arne Beer f96aad2fdd Only shrink when resizing with fit (#803) 2019-09-24 16:54:14 -07:00
Vincent Prouillet 5844047435 Update slotmap 2019-09-16 11:44:39 +02:00
Marcus Klaas de Vries 4fd5d3f348 Bump pulldown_cmark to version 0.6.0 (#797)
* Bump pulldown_cmark to version 0.6.0

* Rename headers to headings
2019-09-06 23:36:30 +02:00
Neil Kistner 52c2b74b39 Add anchor existence checking to link_checker component (#786)
* Add anchor existant checking to link_checker component

* Oops, forgot some changes

* Drop scraper dependency and rework tests

* Handle name attributes
2019-09-04 20:31:19 +02:00
Zdenek Crha 096fefe7ed Remove pub visibility from Config::translations hash (#796)
The access to translations is not straightforward and requires checks if
language and key exists. It is better to forbit direct access to
attribute and provide method - `get_translation()` - that will handle
all details of key translations.

Remove unit tests that use direct access and test only public method.
2019-09-04 20:30:32 +02:00
Bob 9db9fc8fb2 Fix the issue of generating the search index for multiple language (#794)
* fix the issue of generating the search index for multiple language

* updat docs for generating the search index for multiple language

* fix failed tests

* add tests for the search index of multiple language
2019-09-03 16:50:23 +02:00
zdenek-crha 5aadd3d4f2 Fix crash of trans() function called on absent translation key (#793)
Add method get_translation(lang, key) into Config struct that retrieves
translated term from parsed configuration or error when either
desired language or key is missing.

Use the new method in Trans struct implementing global Tera function
trans().

Add unit test to cover both happy and error path for translation
retrieval in both config and templates crate.
2019-09-03 10:51:41 +02:00
Bob e77adc56fd Fix the issue when checking the changes for multiple language section index file (#787)
* Fix the issue when checking the changes of multiple language section
2019-08-30 15:44:57 +02:00
Vincent Prouillet fb89f94516 Process images on rebuild
Closes #790
2019-08-29 20:08:04 +02:00
Vincent Prouillet b396a1bc20 Add --drafts flag + rustfmt 2019-08-24 22:23:08 +02:00
Vincent Prouillet 6a7e955ab0 Add lang to get_taxonomy & get_taxonomy_url 2019-08-15 22:14:53 +02:00
Vincent Prouillet 6d5611f409 Use new Tera escape_xml filter for xml files 2019-08-15 20:33:13 +02:00
southerntofu 4695b029a0 Fix ToC generation for heading levels > 3 (bugfix) (#774)
* Fix ToC generation for heading levels > 3

* typo

* Add tests for deep ToCs

* Code style change
2019-08-15 10:19:32 +02:00
Vincent Prouillet 8942c15428 Add to changelog + rustfmt 2019-08-13 20:02:13 +02:00
Vincent Prouillet a6db79f89b Use fixed version for syntect
>3.2.0 has an updated onig version which requires llvm
which isn't built in azure pipelines in Windows
2019-08-12 22:48:39 +02:00
Katsutoshi Horie 0238e34047 Add trailing slash to multilingual section path (#772) 2019-08-12 18:59:04 +02:00
Vincent Prouillet e231818718 Add back subsections in basic section ser
Closes #733
2019-08-10 19:21:55 +02:00
Vincent Prouillet c503a9fe5d Fix test 2019-08-10 19:09:29 +02:00
Vincent Prouillet 7f459940e1 Allow multiple taxonomies with same name in different language
Closes #766
2019-08-10 18:54:32 +02:00
Vincent Prouillet e74dab535d Update deps & re-render on anchor-link.html changes
Closes #719
2019-08-08 00:37:38 +02:00
Vincent Prouillet 0199017d07 Slugify given slugs as well 2019-08-04 16:17:02 +02:00
Pyry Kovanen 4b43b75d22 Allow ignored_content to support markdown files (#759)
* Allow ignored_content to support markdown files

* Add test for markdown supported ignored_content
2019-08-01 10:18:42 +02:00
Thomas Hurst 0cd9e58a86 Allow relative paths in new_file()/new_section() (#763)
These functions expect that file_path can have base_path stripped from
it, but during reloading they can be given relative paths.  Maybe this
behaviour varies between the notify backends?

This fixes two zola serve panics on FreeBSD (poll backend).
2019-08-01 10:17:38 +02:00
Vincent Prouillet 7e618684da Ensure public exists for search index
Closes #756
2019-07-20 16:09:17 +02:00
Vincent Prouillet 0e4e0c35b3 Remove all draft specific code 2019-07-19 11:10:28 +02:00