mirror of
https://github.com/Nutomic/ibis.git
synced 2024-11-22 19:01:10 +00:00
clippy
This commit is contained in:
parent
f9f83974d3
commit
14e6382765
7 changed files with 58 additions and 32 deletions
|
@ -1,8 +1,13 @@
|
||||||
use crate::{
|
use crate::{
|
||||||
backend::{database::IbisData, error::MyResult, federation::activities::follow::Follow},
|
backend::{database::IbisData, error::MyResult, federation::activities::follow::Follow},
|
||||||
common::{
|
common::{
|
||||||
DbInstance, FollowInstance, FollowInstanceResponse, GetInstance, InstanceView,
|
DbInstance,
|
||||||
LocalUserView, ResolveObject,
|
FollowInstance,
|
||||||
|
FollowInstanceResponse,
|
||||||
|
GetInstance,
|
||||||
|
InstanceView,
|
||||||
|
LocalUserView,
|
||||||
|
ResolveObject,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
use activitypub_federation::{config::Data, fetch::object_id::ObjectId};
|
use activitypub_federation::{config::Data, fetch::object_id::ObjectId};
|
||||||
|
|
|
@ -7,7 +7,13 @@ use crate::{
|
||||||
utils::generate_activity_id,
|
utils::generate_activity_id,
|
||||||
},
|
},
|
||||||
common::{
|
common::{
|
||||||
utils::http_protocol_str, Auth, DbArticle, DbInstance, DbPerson, EditVersion, AUTH_COOKIE,
|
utils::http_protocol_str,
|
||||||
|
Auth,
|
||||||
|
DbArticle,
|
||||||
|
DbInstance,
|
||||||
|
DbPerson,
|
||||||
|
EditVersion,
|
||||||
|
AUTH_COOKIE,
|
||||||
MAIN_PAGE_NAME,
|
MAIN_PAGE_NAME,
|
||||||
},
|
},
|
||||||
frontend::app::{shell, App},
|
frontend::app::{shell, App},
|
||||||
|
@ -26,7 +32,8 @@ use axum::{
|
||||||
middleware::Next,
|
middleware::Next,
|
||||||
response::{IntoResponse, Response},
|
response::{IntoResponse, Response},
|
||||||
routing::get,
|
routing::get,
|
||||||
Router, ServiceExt,
|
Router,
|
||||||
|
ServiceExt,
|
||||||
};
|
};
|
||||||
use axum_extra::extract::CookieJar;
|
use axum_extra::extract::CookieJar;
|
||||||
use axum_macros::debug_middleware;
|
use axum_macros::debug_middleware;
|
||||||
|
@ -37,7 +44,8 @@ use diesel::{
|
||||||
};
|
};
|
||||||
use diesel_migrations::{embed_migrations, EmbeddedMigrations, MigrationHarness};
|
use diesel_migrations::{embed_migrations, EmbeddedMigrations, MigrationHarness};
|
||||||
use federation::objects::{
|
use federation::objects::{
|
||||||
articles_collection::local_articles_url, instance_collection::linked_instances_url,
|
articles_collection::local_articles_url,
|
||||||
|
instance_collection::linked_instances_url,
|
||||||
};
|
};
|
||||||
use leptos::prelude::*;
|
use leptos::prelude::*;
|
||||||
use leptos_axum::{generate_route_list, LeptosRoutes};
|
use leptos_axum::{generate_route_list, LeptosRoutes};
|
||||||
|
|
|
@ -246,7 +246,7 @@ pub struct FollowInstance {
|
||||||
|
|
||||||
#[derive(Deserialize, Serialize, Debug)]
|
#[derive(Deserialize, Serialize, Debug)]
|
||||||
pub struct FollowInstanceResponse {
|
pub struct FollowInstanceResponse {
|
||||||
pub success: bool
|
pub success: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Deserialize, Serialize, Clone, Debug)]
|
#[derive(Deserialize, Serialize, Clone, Debug)]
|
||||||
|
|
|
@ -2,19 +2,38 @@ use crate::{
|
||||||
common::{
|
common::{
|
||||||
newtypes::{ArticleId, ConflictId},
|
newtypes::{ArticleId, ConflictId},
|
||||||
utils::http_protocol_str,
|
utils::http_protocol_str,
|
||||||
ApiConflict, ApproveArticleForm, ArticleView, CreateArticleForm, DbArticle, DbInstance,
|
ApiConflict,
|
||||||
DbPerson, DeleteConflictForm, EditArticleForm, FollowInstance, FollowInstanceResponse,
|
ApproveArticleForm,
|
||||||
ForkArticleForm, GetArticleForm, GetInstance, GetUserForm, InstanceView, ListArticlesForm,
|
ArticleView,
|
||||||
LocalUserView, LoginUserForm, Notification, ProtectArticleForm, RegisterUserForm,
|
CreateArticleForm,
|
||||||
ResolveObject, SearchArticleForm, SiteView,
|
DbArticle,
|
||||||
|
DbInstance,
|
||||||
|
DbPerson,
|
||||||
|
DeleteConflictForm,
|
||||||
|
EditArticleForm,
|
||||||
|
FollowInstance,
|
||||||
|
FollowInstanceResponse,
|
||||||
|
ForkArticleForm,
|
||||||
|
GetArticleForm,
|
||||||
|
GetInstance,
|
||||||
|
GetUserForm,
|
||||||
|
InstanceView,
|
||||||
|
ListArticlesForm,
|
||||||
|
LocalUserView,
|
||||||
|
LoginUserForm,
|
||||||
|
Notification,
|
||||||
|
ProtectArticleForm,
|
||||||
|
RegisterUserForm,
|
||||||
|
ResolveObject,
|
||||||
|
SearchArticleForm,
|
||||||
|
SiteView,
|
||||||
},
|
},
|
||||||
frontend::error::MyResult,
|
frontend::error::MyResult,
|
||||||
};
|
};
|
||||||
use anyhow::anyhow;
|
use anyhow::anyhow;
|
||||||
use http::*;
|
use http::*;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::fmt::Debug;
|
use std::{fmt::Debug, sync::LazyLock};
|
||||||
use std::sync::LazyLock;
|
|
||||||
use url::Url;
|
use url::Url;
|
||||||
|
|
||||||
pub static CLIENT: LazyLock<ApiClient> = LazyLock::new(|| {
|
pub static CLIENT: LazyLock<ApiClient> = LazyLock::new(|| {
|
||||||
|
@ -39,12 +58,9 @@ pub struct ApiClient {
|
||||||
impl ApiClient {
|
impl ApiClient {
|
||||||
#[cfg(feature = "ssr")]
|
#[cfg(feature = "ssr")]
|
||||||
pub fn new(client: reqwest::Client, hostname_: Option<String>) -> Self {
|
pub fn new(client: reqwest::Client, hostname_: Option<String>) -> Self {
|
||||||
let mut hostname;
|
|
||||||
let ssl;
|
|
||||||
use leptos::config::get_config_from_str;
|
use leptos::config::get_config_from_str;
|
||||||
let leptos_options = get_config_from_str(include_str!("../../Cargo.toml")).unwrap();
|
let leptos_options = get_config_from_str(include_str!("../../Cargo.toml")).unwrap();
|
||||||
hostname = leptos_options.site_addr.to_string();
|
let mut hostname = leptos_options.site_addr.to_string();
|
||||||
ssl = false;
|
|
||||||
// required for tests
|
// required for tests
|
||||||
if let Some(hostname_) = hostname_ {
|
if let Some(hostname_) = hostname_ {
|
||||||
hostname = hostname_;
|
hostname = hostname_;
|
||||||
|
@ -52,7 +68,7 @@ impl ApiClient {
|
||||||
Self {
|
Self {
|
||||||
client,
|
client,
|
||||||
hostname,
|
hostname,
|
||||||
ssl,
|
ssl: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#[cfg(not(feature = "ssr"))]
|
#[cfg(not(feature = "ssr"))]
|
||||||
|
@ -177,10 +193,7 @@ impl ApiClient {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn logout(&self) -> MyResult<()> {
|
pub async fn logout(&self) -> MyResult<()> {
|
||||||
Ok(self
|
self.get("/api/v1/account/logout", None::<()>).await
|
||||||
.get("/api/v1/account/logout", None::<()>)
|
|
||||||
.await
|
|
||||||
.unwrap())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn fork_article(&self, form: &ForkArticleForm) -> MyResult<ArticleView> {
|
pub async fn fork_article(&self, form: &ForkArticleForm) -> MyResult<ArticleView> {
|
||||||
|
@ -273,12 +286,13 @@ impl ApiClient {
|
||||||
|
|
||||||
let path_with_endpoint = self.request_endpoint(path);
|
let path_with_endpoint = self.request_endpoint(path);
|
||||||
let path = if method == Method::GET {
|
let path = if method == Method::GET {
|
||||||
|
// Cannot pass the struct directly but need to convert it manually
|
||||||
|
// https://github.com/rustwasm/gloo/issues/378
|
||||||
let query = serde_urlencoded::to_string(¶ms).unwrap();
|
let query = serde_urlencoded::to_string(¶ms).unwrap();
|
||||||
format!("{path_with_endpoint}?{query}")
|
format!("{path_with_endpoint}?{query}")
|
||||||
} else {
|
} else {
|
||||||
path_with_endpoint
|
path_with_endpoint
|
||||||
};
|
};
|
||||||
log::info!("{path}");
|
|
||||||
let builder = RequestBuilder::new(&path)
|
let builder = RequestBuilder::new(&path)
|
||||||
.method(method.clone())
|
.method(method.clone())
|
||||||
.abort_signal(abort_signal.as_ref())
|
.abort_signal(abort_signal.as_ref())
|
||||||
|
|
|
@ -6,8 +6,12 @@ use crate::{
|
||||||
dark_mode::DarkMode,
|
dark_mode::DarkMode,
|
||||||
pages::{
|
pages::{
|
||||||
article::{
|
article::{
|
||||||
actions::ArticleActions, create::CreateArticle, edit::EditArticle,
|
actions::ArticleActions,
|
||||||
history::ArticleHistory, list::ListArticles, read::ReadArticle,
|
create::CreateArticle,
|
||||||
|
edit::EditArticle,
|
||||||
|
history::ArticleHistory,
|
||||||
|
list::ListArticles,
|
||||||
|
read::ReadArticle,
|
||||||
},
|
},
|
||||||
diff::EditDiff,
|
diff::EditDiff,
|
||||||
instance::{details::InstanceDetails, list::ListInstances},
|
instance::{details::InstanceDetails, list::ListInstances},
|
||||||
|
@ -57,7 +61,7 @@ impl<T: Default + Send + Sync> DefaultResource<T> for Resource<T> {
|
||||||
}
|
}
|
||||||
pub fn shell(options: LeptosOptions) -> impl IntoView {
|
pub fn shell(options: LeptosOptions) -> impl IntoView {
|
||||||
view! {
|
view! {
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8" />
|
<meta charset="utf-8" />
|
||||||
|
|
|
@ -51,7 +51,7 @@ pub fn Nav() -> impl IntoView {
|
||||||
<A href="/article/list">"Articles"</A>
|
<A href="/article/list">"Articles"</A>
|
||||||
</li>
|
</li>
|
||||||
<Transition>
|
<Transition>
|
||||||
<Show when=move || is_logged_in()>
|
<Show when=is_logged_in>
|
||||||
<li>
|
<li>
|
||||||
<A href="/article/create">"Create Article"</A>
|
<A href="/article/create">"Create Article"</A>
|
||||||
</li>
|
</li>
|
||||||
|
|
|
@ -32,9 +32,6 @@ pub fn ListArticles() -> impl IntoView {
|
||||||
class="btn rounded-r-none"
|
class="btn rounded-r-none"
|
||||||
node_ref=button_only_local
|
node_ref=button_only_local
|
||||||
on:click=move |_| {
|
on:click=move |_| {
|
||||||
// TODO
|
|
||||||
//button_all.get().map(|c| c.class("btn-primary", false));
|
|
||||||
//button_only_local.get().map(|c| c.class("btn-primary", true));
|
|
||||||
set_only_local.set(true);
|
set_only_local.set(true);
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
|
@ -44,8 +41,6 @@ pub fn ListArticles() -> impl IntoView {
|
||||||
class="btn btn-primary rounded-l-none"
|
class="btn btn-primary rounded-l-none"
|
||||||
node_ref=button_all
|
node_ref=button_all
|
||||||
on:click=move |_| {
|
on:click=move |_| {
|
||||||
//button_all.get().map(|c| c.class("btn-primary", true));
|
|
||||||
//button_only_local.get().map(|c| c.class("btn-primary", false));
|
|
||||||
set_only_local.set(false);
|
set_only_local.set(false);
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
|
|
Loading…
Reference in a new issue