mirror of
https://github.com/Nutomic/ibis.git
synced 2024-11-26 00:51:08 +00:00
fmt
This commit is contained in:
parent
bb892571cb
commit
3e1d2a1d4a
19 changed files with 689 additions and 673 deletions
|
@ -91,26 +91,26 @@ pub fn App() -> impl IntoView {
|
||||||
|
|
||||||
view! {
|
view! {
|
||||||
<>
|
<>
|
||||||
<Stylesheet id="simple" href="/assets/simple.css"/>
|
<Stylesheet id="simple" href="/assets/simple.css" />
|
||||||
<Stylesheet id="ibis" href="/assets/ibis.css"/>
|
<Stylesheet id="ibis" href="/assets/ibis.css" />
|
||||||
<Router>
|
<Router>
|
||||||
<Nav/>
|
<Nav />
|
||||||
<main>
|
<main>
|
||||||
<Routes>
|
<Routes>
|
||||||
<Route path="/" view=ReadArticle/>
|
<Route path="/" view=ReadArticle />
|
||||||
<Route path="/article/:title" view=ReadArticle/>
|
<Route path="/article/:title" view=ReadArticle />
|
||||||
<Route path="/article/:title/history" view=ArticleHistory/>
|
<Route path="/article/:title/history" view=ArticleHistory />
|
||||||
<Route path="/article/:title/edit/:conflict_id?" view=EditArticle/>
|
<Route path="/article/:title/edit/:conflict_id?" view=EditArticle />
|
||||||
<Route path="/article/:title/actions" view=ArticleActions/>
|
<Route path="/article/:title/actions" view=ArticleActions />
|
||||||
<Route path="/article/:title/diff/:hash" view=EditDiff/>
|
<Route path="/article/:title/diff/:hash" view=EditDiff />
|
||||||
<Route path="/article/create" view=CreateArticle/>
|
<Route path="/article/create" view=CreateArticle />
|
||||||
<Route path="/article/list" view=ListArticles/>
|
<Route path="/article/list" view=ListArticles />
|
||||||
<Route path="/instance/:hostname" view=InstanceDetails/>
|
<Route path="/instance/:hostname" view=InstanceDetails />
|
||||||
<Route path="/user/:name" view=UserProfile/>
|
<Route path="/user/:name" view=UserProfile />
|
||||||
<Route path="/login" view=Login/>
|
<Route path="/login" view=Login />
|
||||||
<Route path="/register" view=Register/>
|
<Route path="/register" view=Register />
|
||||||
<Route path="/search" view=Search/>
|
<Route path="/search" view=Search />
|
||||||
<Route path="/conflicts" view=Conflicts/>
|
<Route path="/conflicts" view=Conflicts />
|
||||||
</Routes>
|
</Routes>
|
||||||
</main>
|
</main>
|
||||||
</Router>
|
</Router>
|
||||||
|
|
|
@ -48,12 +48,16 @@ pub fn ArticleNav(article: Resource<Option<String>, ArticleView>) -> impl IntoVi
|
||||||
}>
|
}>
|
||||||
<A href=format!("{article_link}/edit")>"Edit"</A>
|
<A href=format!("{article_link}/edit")>"Edit"</A>
|
||||||
</Show>
|
</Show>
|
||||||
<Show when=move || global_state.with(|state| state.my_profile.is_some())>
|
<Show when=move || {
|
||||||
|
global_state.with(|state| state.my_profile.is_some())
|
||||||
|
}>
|
||||||
<A href=format!("{article_link_}/actions")>"Actions"</A>
|
<A href=format!("{article_link_}/actions")>"Actions"</A>
|
||||||
{instance
|
{instance
|
||||||
.get()
|
.get()
|
||||||
.map(|i| {
|
.map(|i| {
|
||||||
view! { <InstanceFollowButton instance=i.instance.clone()/> }
|
view! {
|
||||||
|
<InstanceFollowButton instance=i.instance.clone() />
|
||||||
|
}
|
||||||
})}
|
})}
|
||||||
|
|
||||||
</Show>
|
</Show>
|
||||||
|
|
|
@ -52,7 +52,7 @@ pub fn ArticleActions() -> impl IntoView {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
view! {
|
view! {
|
||||||
<ArticleNav article=article/>
|
<ArticleNav article=article />
|
||||||
<Suspense fallback=|| {
|
<Suspense fallback=|| {
|
||||||
view! { "Loading..." }
|
view! { "Loading..." }
|
||||||
}>
|
}>
|
||||||
|
@ -117,7 +117,7 @@ pub fn ArticleActions() -> impl IntoView {
|
||||||
|
|
||||||
</Suspense>
|
</Suspense>
|
||||||
<Show when=move || fork_response.get().is_some()>
|
<Show when=move || fork_response.get().is_some()>
|
||||||
<Redirect path=article_link(&fork_response.get().unwrap())/>
|
<Redirect path=article_link(&fork_response.get().unwrap()) />
|
||||||
</Show>
|
</Show>
|
||||||
<p>"TODO: add option for admin to delete article etc"</p>
|
<p>"TODO: add option for admin to delete article etc"</p>
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,8 +63,7 @@ pub fn CreateArticle() -> impl IntoView {
|
||||||
let val = event_target_value(&ev);
|
let val = event_target_value(&ev);
|
||||||
set_text.update(|p| *p = val);
|
set_text.update(|p| *p = val);
|
||||||
}
|
}
|
||||||
>
|
></textarea>
|
||||||
</textarea>
|
|
||||||
<div>
|
<div>
|
||||||
<a href="https://commonmark.org/help/" target="blank_">
|
<a href="https://commonmark.org/help/" target="blank_">
|
||||||
Markdown
|
Markdown
|
||||||
|
@ -90,7 +89,9 @@ pub fn CreateArticle() -> impl IntoView {
|
||||||
|
|
||||||
<button
|
<button
|
||||||
prop:disabled=move || button_is_disabled.get()
|
prop:disabled=move || button_is_disabled.get()
|
||||||
on:click=move |_| submit_action.dispatch((title.get(), text.get(), summary.get()))
|
on:click=move |_| {
|
||||||
|
submit_action.dispatch((title.get(), text.get(), summary.get()))
|
||||||
|
}
|
||||||
>
|
>
|
||||||
Submit
|
Submit
|
||||||
</button>
|
</button>
|
||||||
|
@ -99,7 +100,7 @@ pub fn CreateArticle() -> impl IntoView {
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
|
|
||||||
<Redirect path=format!("/article/{}", title.get().replace(' ', "_"))/>
|
<Redirect path=format!("/article/{}", title.get().replace(' ', "_")) />
|
||||||
</Show>
|
</Show>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -100,7 +100,7 @@ pub fn EditArticle() -> impl IntoView {
|
||||||
);
|
);
|
||||||
|
|
||||||
view! {
|
view! {
|
||||||
<ArticleNav article=article/>
|
<ArticleNav article=article />
|
||||||
<Show
|
<Show
|
||||||
when=move || edit_response.get() == EditResponse::Success
|
when=move || edit_response.get() == EditResponse::Success
|
||||||
fallback=move || {
|
fallback=move || {
|
||||||
|
|
|
@ -12,7 +12,7 @@ pub fn ArticleHistory() -> impl IntoView {
|
||||||
let article = article_resource();
|
let article = article_resource();
|
||||||
|
|
||||||
view! {
|
view! {
|
||||||
<ArticleNav article=article/>
|
<ArticleNav article=article />
|
||||||
<Suspense fallback=|| {
|
<Suspense fallback=|| {
|
||||||
view! { "Loading..." }
|
view! { "Loading..." }
|
||||||
}>
|
}>
|
||||||
|
|
|
@ -28,9 +28,9 @@ pub fn ListArticles() -> impl IntoView {
|
||||||
let is_local_only = val == "only-local";
|
let is_local_only = val == "only-local";
|
||||||
set_only_local.update(|p| *p = is_local_only);
|
set_only_local.update(|p| *p = is_local_only);
|
||||||
}>
|
}>
|
||||||
<input type="radio" name="listing-type" id="only-local"/>
|
<input type="radio" name="listing-type" id="only-local" />
|
||||||
<label for="only-local">Only Local</label>
|
<label for="only-local">Only Local</label>
|
||||||
<input type="radio" name="listing-type" id="all" checked/>
|
<input type="radio" name="listing-type" id="all" checked />
|
||||||
<label for="all">All</label>
|
<label for="all">All</label>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
<ul>
|
<ul>
|
||||||
|
|
|
@ -11,7 +11,7 @@ pub fn ReadArticle() -> impl IntoView {
|
||||||
let article = article_resource();
|
let article = article_resource();
|
||||||
|
|
||||||
view! {
|
view! {
|
||||||
<ArticleNav article=article/>
|
<ArticleNav article=article />
|
||||||
<Suspense fallback=|| {
|
<Suspense fallback=|| {
|
||||||
view! { "Loading..." }
|
view! { "Loading..." }
|
||||||
}>
|
}>
|
||||||
|
@ -25,7 +25,9 @@ pub fn ReadArticle() -> impl IntoView {
|
||||||
view! {
|
view! {
|
||||||
<div class="item-view">
|
<div class="item-view">
|
||||||
<h1>{article_title(&article.article)}</h1>
|
<h1>{article_title(&article.article)}</h1>
|
||||||
<div inner_html=parser.parse(&article.article.text).render()></div>
|
<div inner_html=parser
|
||||||
|
.parse(&article.article.text)
|
||||||
|
.render()></div>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
@ -18,10 +18,16 @@ pub fn Conflicts() -> impl IntoView {
|
||||||
.map(|c| {
|
.map(|c| {
|
||||||
c.into_iter()
|
c.into_iter()
|
||||||
.map(|c| {
|
.map(|c| {
|
||||||
let link = format!("{}/edit/{}", article_link(&c.article), c.id);
|
let link = format!(
|
||||||
|
"{}/edit/{}",
|
||||||
|
article_link(&c.article),
|
||||||
|
c.id,
|
||||||
|
);
|
||||||
view! {
|
view! {
|
||||||
<li>
|
<li>
|
||||||
<a href=link>{article_title(&c.article)} " - " {c.summary}</a>
|
<a href=link>
|
||||||
|
{article_title(&c.article)} " - " {c.summary}
|
||||||
|
</a>
|
||||||
</li>
|
</li>
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
@ -8,7 +8,7 @@ pub fn EditDiff() -> impl IntoView {
|
||||||
let article = article_resource();
|
let article = article_resource();
|
||||||
|
|
||||||
view! {
|
view! {
|
||||||
<ArticleNav article=article/>
|
<ArticleNav article=article />
|
||||||
<Suspense fallback=|| {
|
<Suspense fallback=|| {
|
||||||
view! { "Loading..." }
|
view! { "Loading..." }
|
||||||
}>
|
}>
|
||||||
|
|
|
@ -31,15 +31,19 @@ pub fn InstanceDetails() -> impl IntoView {
|
||||||
view! {
|
view! {
|
||||||
<h1>{instance.domain}</h1>
|
<h1>{instance.domain}</h1>
|
||||||
|
|
||||||
<Show when=move || global_state.with(|state| state.my_profile.is_some())>
|
<Show when=move || {
|
||||||
<InstanceFollowButton instance=instance_.clone()/>
|
global_state.with(|state| state.my_profile.is_some())
|
||||||
|
}>
|
||||||
|
<InstanceFollowButton instance=instance_.clone() />
|
||||||
</Show>
|
</Show>
|
||||||
<p>Follow the instance so that new edits are federated to your instance.</p>
|
<p>
|
||||||
|
Follow the instance so that new edits are federated to your instance.
|
||||||
|
</p>
|
||||||
<p>
|
<p>
|
||||||
"TODO: show a list of articles from the instance. For now you can use the "
|
"TODO: show a list of articles from the instance. For now you can use the "
|
||||||
<a href="/article/list">Article list</a> .
|
<a href="/article/list">Article list</a>.
|
||||||
</p>
|
</p>
|
||||||
<hr/>
|
<hr />
|
||||||
<h2>"Description:"</h2>
|
<h2>"Description:"</h2>
|
||||||
<div>{instance.description}</div>
|
<div>{instance.description}</div>
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,7 +53,7 @@ pub fn Login() -> impl IntoView {
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
|
|
||||||
<Redirect path="/"/>
|
<Redirect path="/" />
|
||||||
</Show>
|
</Show>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -93,8 +93,7 @@ pub fn Search() -> impl IntoView {
|
||||||
]
|
]
|
||||||
} else {
|
} else {
|
||||||
vec![]
|
vec![]
|
||||||
}}
|
}} // render articles from resolve/search
|
||||||
// render articles from resolve/search
|
|
||||||
{search_results
|
{search_results
|
||||||
.articles
|
.articles
|
||||||
.iter()
|
.iter()
|
||||||
|
|
|
@ -28,6 +28,6 @@ fn main() {
|
||||||
_ = console_log::init_with_level(log::Level::Debug);
|
_ = console_log::init_with_level(log::Level::Debug);
|
||||||
console_error_panic_hook::set_once();
|
console_error_panic_hook::set_once();
|
||||||
mount_to_body(|| {
|
mount_to_body(|| {
|
||||||
view! { <App/> }
|
view! { <App /> }
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue