Commit graph

817 commits

Author SHA1 Message Date
Sergio A. Vargas
1de1dd56de Add attributes to base_url link in atom template (#2261)
The `rel` and `type` HTML attributes are needed in the `base_url` (or
`section.permalink`) link so feed aggregators know that's the HTML page
that corresponds to the atom feed.

Note: The RSS template doesn't have this issue.
2023-12-18 23:24:06 +01:00
Heitor
a1ac81681b Atom template authors (#2259)
* templates:atom: add support for multiple authors

Atom 1.0 [0] support multiple `<author>` entries in the feed. This commit
modified the template to generate as many `<author>` as the page's
metadata contains.

[0] https://validator.w3.org/feed/docs/atom.html#recommendedEntryElements

* Test we can have multiple authors in ATOM feeds
2023-12-18 23:24:06 +01:00
William Ouwehand
c18a0c8031 always sort assets by filename (Windows/Linux difference) (#2236)
* sort page.assets by filename

Uses .to_str() to sort files and subfolders.

The .unwrap() may need work or be replaced by unwrap_or_default(). Given
earlier checks in the function it should work however.

* add tests for assets sorting

* fix rustfmt

* use existing loop instead of windows

* also check the non-recursive test

* use .zip() and add assert msg
2023-12-18 23:24:06 +01:00
TheOnlyMrCat
2532198acb Prevent spans crossing line boundaries in class-based code block formatter (#2237)
* Prevent spans crossing line boundaries in class formatter

* Add snapshot tests for classed highlighting
2023-12-18 23:24:06 +01:00
sinofp
22dc32a589 Add support for lazy loading images (#2211)
* Add optional decoding="async" loading="lazy" for img

In theory, they can make the page load faster and show content faster.

There’s one problem: CommonMark allows arbitrary inline elements in alt text.
If I want to get the correct alt text, I need to match every inline event.

I think most people will only use plain text, so I only match Event::Text.

* Add very basic test for img

This is the reason why we should use plain text when lazy_async_image is enabled.

* Explain lazy_async_image in documentation

* Add test with empty alt and special characters

I totaly forgot one can leave the alt text empty.
I thought I need to eliminate the alt attribute in that case,
but actually empty alt text is better than not having an alt attribute at all:
https://www.w3.org/TR/WCAG20-TECHS/H67.html
https://www.boia.org/blog/images-that-dont-need-alternative-text-still-need-alt-attributes
Thus I will leave the empty alt text.

Another test is added to ensure alt text is properly escaped.
I will remove the redundant escaping code after this commit.

* Remove manually escaping alt text

After removing the if-else inside the arm of Event::Text(text),
the alt text is still escaped.
Indeed they are redundant.

* Use insta for snapshot testing

`cargo insta review` looks cool!

I wanted to dedup the cases variable,
but my Rust skill is not good enough to declare a global vector.
2023-12-18 23:24:06 +01:00
Andrew Langmeier
0a9bfa16c2 Hard link serve panic fix (#2210)
* Fix hard link panic and add better error info to std:fs errors

* cargo fmt

* Remove erroneously committed config change

* Remove console import; Use with context to provide additional error info

* improve error wording
2023-12-18 23:24:06 +01:00
Vincent Prouillet
448a941f93 Fix typo in error message 2023-12-18 23:24:06 +01:00
Andrew Langmeier
8e37025729 Add search.index_format into the serialized config (#2165) (#2196)
* Add search into the serialized config (#2165)

* Only expose index_format

* Create config.search struct

* cargo fmt
2023-12-18 23:24:06 +01:00
Jake G
d72ebb1bdb Fix multi-lingual json index (#2197)
* Fix multi-ligual json index

* multi-lingual search Fix cargo fmt
2023-12-18 23:24:06 +01:00
Jeremy Kerr
63054a96d2 templates: add base URL for feed content (#2190)
Relative links in the entry content do not currently have a base URI, so
will be resolved relative to the feed URI:

Given an entry with the content:

    <a href="some-resource.bin">

And URIS of:

 * entry: https://example.org/blog/some-entry/
 * feed:  https://example.org/atom.xml

The link URI will end up as:

    https://example.org/some-resource.bin

rather than the URI that ends up resolved in the rendered page:

   https://example.org/blog/some-entry/some-resource.bin

The atom and RSS formats allow for an xml:base attribute (itself
specified in [1]) to provide a base URI of a subset of a document. This
change adds xml:base attributes to each entry, using the page permalink.

This gives us something equivalent to:

    <entry>
     <content xml:base="https://example.org/blog/some-entry/">
      <![CDATA[
       <a href="some-resource.bin">
      ]]>
     </content>
    </entry>

[1]: https://www.w3.org/TR/xmlbase/

Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
2023-12-18 23:24:06 +01:00
‏‏Dave
c61e925073 Implement replace_re filter (#2163)
* Implement replace_re filter

* Cargo fmt

* add regex caching

* cargo fmt

* update docs, update unit test

* rename replace_re -> regex_replace
2023-12-18 23:24:06 +01:00
Marcel
c0dd38b234 Speedup "zola check" command by reusing the Client (#2171)
* Reuse Client when checking urls and add timeout for requests
2023-12-18 23:24:06 +01:00
Justin Tennant
d52a071c05 Implement Default for LanguageOptions (#2145)
Closes #2137
2023-03-19 20:36:25 +01:00
Vincent Prouillet
a4a85fe202 Fix cachebusting not working with binary files
Closes #2142
2023-03-19 20:36:25 +01:00
Icy Defiance
0ba2707316 Use page.summary if available (#2141) 2023-03-19 20:36:25 +01:00
Vincent Prouillet
b7fec4d31a Remove dummy test 2023-03-19 20:36:25 +01:00
Vincent Prouillet
deaaa16017 Fix tests 2023-03-19 20:36:25 +01:00
Vincent Prouillet
f6c0d52d16 Revert "Allow external links to start with "www.*" (#2100)"
This reverts commit 902fd3a9fb.
2023-03-19 20:36:25 +01:00
François
dd65e99300 Fix index errors (#2129)
* consider sections by path instead of by component

* add tests

* update more tests
2023-03-19 20:36:25 +01:00
Felix Zwettler
5ad9f84a81 fix zola serve not respecting preserve_dotfiles_in_output (#2113)
* fix `zola serve` not  respecting `preserve_dotfiles_in_output`
2023-02-24 22:20:26 +01:00
Vincent Prouillet
64feaeb3ee Pass section.generate_feed 2023-02-24 22:20:26 +01:00
Vincent Prouillet
c67655e29f Fix colocated assets in content directory
Closes #2101
2023-02-24 22:20:26 +01:00
Vincent Prouillet
193d97d930 Update changelog & test-case 2023-02-16 20:49:03 +01:00
Katie Watson
902fd3a9fb Allow external links to start with "www.*" (#2100)
* Make www.* URLs considered valid external links

* Tweak description of is_external_link
2023-02-16 20:49:03 +01:00
Vincent Prouillet
bc27c01024 Remove println 2023-02-16 20:49:03 +01:00
Vincent Prouillet
6b461495fd cargo fmt 2023-02-16 20:49:03 +01:00
Vincent Prouillet
0b31fc10d2 Add test for #1566
Closes #1566
2023-02-16 20:49:03 +01:00
Vincent Prouillet
05ab07bff0 Downgrade mockito to not raise MSRV 2023-02-16 20:49:03 +01:00
Vincent Prouillet
b4a8d3ce75 Update changelog & mockito 2023-02-16 20:49:03 +01:00
Kartavya Vashishtha
3e1f5777f1 feat: External URL redirect (#2080) 2023-02-16 20:49:03 +01:00
Seth Morabito
f4a1e99b98 Page and config authors (#2024) (#2092)
The W3C feed validator fails to validate RSS 2.0 and Atom 1.0 feed
elements that do not contain a valid author. This change adds an
`authors: Vec<String>` to pages, as well as an `author: Option<String>`
to Config that will act as a default to use in RSS and Atom templates if
no page-level authors are specified.
2023-02-16 20:49:03 +01:00
Vincent Prouillet
4cd80a3df2 Update toml lib
Closes #1313
2023-02-16 20:49:03 +01:00
Vincent Prouillet
9f490bfb81 clippy 2023-02-16 20:49:03 +01:00
Vincent Prouillet
8ba6c1c2a1 Procimage refactor (#2086)
* Refactor image proc

Closes #2066

* Add colocated_path to shortcodes

Closes #1793
2023-02-16 20:49:03 +01:00
Orson Peters
29cb3fca7a Removed faulty Windows-specific path check/conversion. Fixes #2076. (#2088) 2023-02-16 20:49:03 +01:00
Vincent Prouillet
60d8425470 Errors on empty taxonomies term
Closes #2085
2023-02-16 20:49:03 +01:00
Vincent Prouillet
f363ea1ae8 Filter out temp files or with no extensions from colocated assets 2023-02-16 20:49:03 +01:00
Vincent Prouillet
ee4cbb649a Handle pages named index.md in sections
Closes #2082
2023-02-16 20:49:03 +01:00
Vincent Prouillet
bb171009a1 Revert "Use reqwest rustls-tls"
This reverts commit 17c8aa77a5.
2023-02-16 20:49:03 +01:00
Vincent Prouillet
a56e4248e1 Remove built-in shortcodes
Bazooka way of fixing #1832
2023-02-16 20:49:03 +01:00
Vincent Prouillet
61570bbf57 Use reqwest rustls-tls
Easier cross-compiling
Closes #1569
2023-02-16 20:49:03 +01:00
Vincent Prouillet
d828d526ca Add plain text syntax alias to text
Closes #1633
2023-02-16 20:49:03 +01:00
Vincent Prouillet
d43b5e12ca fmt + changelog + updates 2023-02-16 20:49:03 +01:00
Orson Peters
84d057fa1e Reduced cachebust fingerprint to be more reasonable (#2074)
* Reduced cachebust fingerprint to be more reasonable.
2023-02-16 20:49:03 +01:00
Vincent Prouillet
0c5ffa8963 Remove code blocks from search index
Kinda closes #1176
2023-02-16 20:49:03 +01:00
Vincent Prouillet
5090c9e965 Use macro for LanguageOptions::merge 2023-02-16 20:49:03 +01:00
Victor Nilsson
2d44fe81f6 Merge default language data with section language data (#2039)
* Merge language data in config.toml
2023-02-16 20:49:03 +01:00
Vincent Prouillet
4aaed16c6d Update base64 2023-02-16 20:49:03 +01:00
Vincent Prouillet
608837cddf Clippy + 1.63 2023-02-16 20:49:03 +01:00
Vincent Prouillet
e12b766e2c Fmt + change min version 2023-02-16 20:49:03 +01:00