Refactor with the help of Clippy (#462)
We add clippy as our build — also rectifying the missing `plume-cli` build! In the next step we follow clippy's advise and fix some of the "simple" mistakes in our code, such as style or map usage. Finally, we refactor some hard bits that need extraction of new types, or refactoring of function call-types, especially those that thread thru macros, and, of course functions with ~15 parameters should probably be rethought.
This commit is contained in:
committed by
Baptiste Gelez
parent
570d7fe2d0
commit
732f514da7
@@ -5,7 +5,7 @@
|
||||
@use template_utils::*;
|
||||
@use routes::*;
|
||||
|
||||
@(ctx: BaseContext, blog: Blog, authors: &Vec<User>, total_articles: i64, page: i32, n_pages: i32, is_author: bool, posts: Vec<Post>)
|
||||
@(ctx: BaseContext, blog: Blog, authors: &[User], total_articles: i64, page: i32, n_pages: i32, is_author: bool, posts: Vec<Post>)
|
||||
|
||||
@:base(ctx, blog.title.clone(), {}, {
|
||||
<a href="@uri!(blogs::details: name = &blog.fqn, page = _)">@blog.title</a>
|
||||
@@ -36,7 +36,7 @@
|
||||
@i18n!(ctx.1, "Latest articles")
|
||||
<small><a href="@uri!(blogs::atom_feed: name = &blog.fqn)" title="Atom feed">@icon!("rss")</a></small>
|
||||
</h2>
|
||||
@if posts.len() < 1 {
|
||||
@if posts.is_empty() {
|
||||
<p>@i18n!(ctx.1, "No posts to see here yet.")</p>
|
||||
}
|
||||
@if is_author {
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
<div class="h-feed">
|
||||
<h1 "p-name">@i18n!(ctx.1, "All the articles of the Fediverse")</h1>
|
||||
|
||||
@if let Some(_) = ctx.2 {
|
||||
@if ctx.2.is_some() {
|
||||
@tabs(&[
|
||||
(&uri!(instance::index).to_string(), i18n!(ctx.1, "Latest articles"), false),
|
||||
(&uri!(instance::feed: _).to_string(), i18n!(ctx.1, "Your feed"), false),
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
<div class="h-feed">
|
||||
<h1 class="p-name">@i18n!(ctx.1, "Articles from {}"; instance.name)</h1>
|
||||
|
||||
@if let Some(_) = ctx.2 {
|
||||
@if ctx.2.is_some() {
|
||||
@tabs(&[
|
||||
(&uri!(instance::index).to_string(), i18n!(ctx.1, "Latest articles"), false),
|
||||
(&uri!(instance::feed: _).to_string(), i18n!(ctx.1, "Your feed"), false),
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
|
||||
<section>
|
||||
<figure class="media">
|
||||
@Html(media.html(ctx.0).unwrap_or(SafeString::new("")))
|
||||
@Html(media.html(ctx.0).unwrap_or_else(|_| SafeString::new("")))
|
||||
<figcaption>@media.alt_text</figcaption>
|
||||
</figure>
|
||||
<div>
|
||||
@@ -22,7 +22,7 @@
|
||||
@i18n!(ctx.1, "Markdown syntax")
|
||||
<small>@i18n!(ctx.1, "Copy it into your articles, to insert this media:")</small>
|
||||
</p>
|
||||
<code>@media.markdown(ctx.0).unwrap_or(SafeString::new(""))</code>
|
||||
<code>@media.markdown(ctx.0).unwrap_or_else(|_| SafeString::new(""))</code>
|
||||
</div>
|
||||
<div>
|
||||
@if media.category() == MediaCategory::Image {
|
||||
|
||||
@@ -5,12 +5,12 @@
|
||||
@(ctx: BaseContext, comment_tree: &CommentTree, in_reply_to: Option<&str>, blog: &str, slug: &str)
|
||||
|
||||
@if let Some(ref comm) = Some(&comment_tree.comment) {
|
||||
@if let Some(author) = comm.get_author(ctx.0).ok() {
|
||||
@if let Ok(author) = comm.get_author(ctx.0) {
|
||||
<div class="comment u-comment h-cite" id="comment-@comm.id">
|
||||
<a class="author u-author h-card" href="@uri!(user::details: name = &author.fqn)">
|
||||
@avatar(ctx.0, &author, Size::Small, true, ctx.1)
|
||||
<span class="display-name p-name">@author.name()</span>
|
||||
<small>@&author.fqn</small>
|
||||
<small>@author.fqn</small>
|
||||
</a>
|
||||
@if let Some(ref ap_url) = comm.ap_url {
|
||||
<a class="u-url" href="@ap_url"></a>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
@(ctx: BaseContext, articles: Vec<Post>, link: &str, title: String)
|
||||
|
||||
@if articles.len() > 0 {
|
||||
@if !articles.is_empty() {
|
||||
<div class="h-feed">
|
||||
<h2><span class="p-name">@title</span> — <a href="@link">@i18n!(ctx.1, "View all")</a></h2>
|
||||
<div class="cards spaced">
|
||||
|
||||
@@ -23,8 +23,8 @@
|
||||
<a href="@uri!(blogs::details: name = &blog.fqn, page = _)">@blog.title</a>
|
||||
}, {
|
||||
<div class="h-entry">
|
||||
<h1 class="article p-name">@&article.title</h1>
|
||||
<h2 class="article p-summary">@&article.subtitle</h2>
|
||||
<h1 class="article p-name">@article.title</h1>
|
||||
<h2 class="article p-summary">@article.subtitle</h2>
|
||||
<div class="article-info">
|
||||
<span class="author">
|
||||
@Html(i18n!(ctx.1, "Written by {0}"; format!("<a href=\"{}\">{}</a>",
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
@input!(ctx.1, subtitle (optional text), "Subtitle", form, errors.clone(), "")
|
||||
|
||||
@if let Some(ValidationErrorsKind::Field(errs)) = errors.clone().errors().get("content") {
|
||||
@format!(r#"<p class="error">{}</p>"#, errs[0].message.clone().unwrap_or(Cow::from("Unknown error")))
|
||||
@format!(r#"<p class="error">{}</p>"#, errs[0].message.clone().unwrap_or_else(|| Cow::from("Unknown error")))
|
||||
}
|
||||
|
||||
<label for="editor-content">@i18n!(ctx.1, "Content")<small>@i18n!(ctx.1, "Markdown syntax is supported")</small></label>
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
<h1 class="grow flex vertical">
|
||||
<span class="p-name">@user.name()</span>
|
||||
<small class="p-nickname">@&user.fqn</small>
|
||||
<small class="p-nickname">@user.fqn</small>
|
||||
</h1>
|
||||
|
||||
<p>
|
||||
|
||||
Reference in New Issue
Block a user