Plume/templates/search/index.rs.html
Baptiste Gelez 70af57c6e1
Use Ructe (#327)
All the template are now compiled at compile-time with the `ructe` crate.

I preferred to use it instead of askama because it allows more complex Rust expressions, where askama only supports a small subset of expressions and doesn't allow them everywhere (for instance, `{{ macro!() | filter }}` would result in a parsing error).

The diff is quite huge, but there is normally no changes in functionality.

Fixes #161 and unblocks #110 and #273
2018-12-06 18:54:16 +01:00

44 lines
1.9 KiB
HTML

@use templates::base;
@use template_utils::*;
@(ctx: BaseContext, now: &str)
@:base(ctx, "Search", {
<script>
window.onload = function(evt) @{
var form = document.getElementById('form');
form.addEventListener('submit', function () @{
for (var input of form.getElementsByTagName('input')) @{
if (input.name === '') @{
input.name = input.id
@}
if (input.name && !input.value) @{
input.name = '';
@}
@}
@});
@}
</script>
}, {}, {
<h1>@i18n!(ctx.1, "Search")</h1>
<form method="get" id="form">
<input id="q" name="q" placeholder="Your query" type="search">
<details>
<summary>Advanced search</summary>
@input!(ctx.1, title (text), "Title matching these words", "placeholder=\"Title\"")
@input!(ctx.1, subtitle (text), "Subtitle matching these words", "placeholder=\"Subtitle\"")
@input!(ctx.1, content (text), "Content matching these words", "placeholder=\"Content\"")
@input!(ctx.1, after (date), "From this date", &format!("max={}", now)))
@input!(ctx.1, before (date), "To this date", &format!("max={}", now))
@input!(ctx.1, tag (text), "Containing these tags", "placeholder=\"Tags\"")
@input!(ctx.1, instance (text), "Posted in one of these instances", "placeholder=\"Instance domain\"")
@input!(ctx.1, author (text), "Posted by one of these authors", "placeholder=\"Authors\"")
@input!(ctx.1, blog (text), "Posted in one of these blogs", "placeholder=\"Blog title\"")
@input!(ctx.1, lang (text), "Wrote in this language", "placeholder=\"Language\"")
@input!(ctx.1, license (text), "Using this license", "placeholder=\"License\"")
</details>
<input type="submit" value="Search"/>
</form>
})