This commit is contained in:
Felix Ableitner 2024-10-02 14:35:32 +02:00
parent bb892571cb
commit 3e1d2a1d4a
19 changed files with 689 additions and 673 deletions

View File

@ -91,26 +91,26 @@ pub fn App() -> impl IntoView {
view! {
<>
<Stylesheet id="simple" href="/assets/simple.css"/>
<Stylesheet id="ibis" href="/assets/ibis.css"/>
<Stylesheet id="simple" href="/assets/simple.css" />
<Stylesheet id="ibis" href="/assets/ibis.css" />
<Router>
<Nav/>
<Nav />
<main>
<Routes>
<Route path="/" view=ReadArticle/>
<Route path="/article/:title" view=ReadArticle/>
<Route path="/article/:title/history" view=ArticleHistory/>
<Route path="/article/:title/edit/:conflict_id?" view=EditArticle/>
<Route path="/article/:title/actions" view=ArticleActions/>
<Route path="/article/:title/diff/:hash" view=EditDiff/>
<Route path="/article/create" view=CreateArticle/>
<Route path="/article/list" view=ListArticles/>
<Route path="/instance/:hostname" view=InstanceDetails/>
<Route path="/user/:name" view=UserProfile/>
<Route path="/login" view=Login/>
<Route path="/register" view=Register/>
<Route path="/search" view=Search/>
<Route path="/conflicts" view=Conflicts/>
<Route path="/" view=ReadArticle />
<Route path="/article/:title" view=ReadArticle />
<Route path="/article/:title/history" view=ArticleHistory />
<Route path="/article/:title/edit/:conflict_id?" view=EditArticle />
<Route path="/article/:title/actions" view=ArticleActions />
<Route path="/article/:title/diff/:hash" view=EditDiff />
<Route path="/article/create" view=CreateArticle />
<Route path="/article/list" view=ListArticles />
<Route path="/instance/:hostname" view=InstanceDetails />
<Route path="/user/:name" view=UserProfile />
<Route path="/login" view=Login />
<Route path="/register" view=Register />
<Route path="/search" view=Search />
<Route path="/conflicts" view=Conflicts />
</Routes>
</main>
</Router>

View File

@ -48,12 +48,16 @@ pub fn ArticleNav(article: Resource<Option<String>, ArticleView>) -> impl IntoVi
}>
<A href=format!("{article_link}/edit")>"Edit"</A>
</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>
{instance
.get()
.map(|i| {
view! { <InstanceFollowButton instance=i.instance.clone()/> }
view! {
<InstanceFollowButton instance=i.instance.clone() />
}
})}
</Show>

View File

@ -52,7 +52,7 @@ pub fn ArticleActions() -> impl IntoView {
}
});
view! {
<ArticleNav article=article/>
<ArticleNav article=article />
<Suspense fallback=|| {
view! { "Loading..." }
}>
@ -117,7 +117,7 @@ pub fn ArticleActions() -> impl IntoView {
</Suspense>
<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>
<p>"TODO: add option for admin to delete article etc"</p>
}

View File

@ -63,8 +63,7 @@ pub fn CreateArticle() -> impl IntoView {
let val = event_target_value(&ev);
set_text.update(|p| *p = val);
}
>
</textarea>
></textarea>
<div>
<a href="https://commonmark.org/help/" target="blank_">
Markdown
@ -90,7 +89,9 @@ pub fn CreateArticle() -> impl IntoView {
<button
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
</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>
}
}

View File

@ -100,7 +100,7 @@ pub fn EditArticle() -> impl IntoView {
);
view! {
<ArticleNav article=article/>
<ArticleNav article=article />
<Show
when=move || edit_response.get() == EditResponse::Success
fallback=move || {

View File

@ -12,7 +12,7 @@ pub fn ArticleHistory() -> impl IntoView {
let article = article_resource();
view! {
<ArticleNav article=article/>
<ArticleNav article=article />
<Suspense fallback=|| {
view! { "Loading..." }
}>

View File

@ -28,9 +28,9 @@ pub fn ListArticles() -> impl IntoView {
let is_local_only = val == "only-local";
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>
<input type="radio" name="listing-type" id="all" checked/>
<input type="radio" name="listing-type" id="all" checked />
<label for="all">All</label>
</fieldset>
<ul>

View File

@ -11,7 +11,7 @@ pub fn ReadArticle() -> impl IntoView {
let article = article_resource();
view! {
<ArticleNav article=article/>
<ArticleNav article=article />
<Suspense fallback=|| {
view! { "Loading..." }
}>
@ -25,7 +25,9 @@ pub fn ReadArticle() -> impl IntoView {
view! {
<div class="item-view">
<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>
}
})

View File

@ -18,10 +18,16 @@ pub fn Conflicts() -> impl IntoView {
.map(|c| {
c.into_iter()
.map(|c| {
let link = format!("{}/edit/{}", article_link(&c.article), c.id);
let link = format!(
"{}/edit/{}",
article_link(&c.article),
c.id,
);
view! {
<li>
<a href=link>{article_title(&c.article)} " - " {c.summary}</a>
<a href=link>
{article_title(&c.article)} " - " {c.summary}
</a>
</li>
}
})

View File

@ -8,7 +8,7 @@ pub fn EditDiff() -> impl IntoView {
let article = article_resource();
view! {
<ArticleNav article=article/>
<ArticleNav article=article />
<Suspense fallback=|| {
view! { "Loading..." }
}>

View File

@ -31,15 +31,19 @@ pub fn InstanceDetails() -> impl IntoView {
view! {
<h1>{instance.domain}</h1>
<Show when=move || global_state.with(|state| state.my_profile.is_some())>
<InstanceFollowButton instance=instance_.clone()/>
<Show when=move || {
global_state.with(|state| state.my_profile.is_some())
}>
<InstanceFollowButton instance=instance_.clone() />
</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>
"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>
<hr/>
<hr />
<h2>"Description:"</h2>
<div>{instance.description}</div>
}

View File

@ -53,7 +53,7 @@ pub fn Login() -> impl IntoView {
}
>
<Redirect path="/"/>
<Redirect path="/" />
</Show>
}
}

View File

@ -93,8 +93,7 @@ pub fn Search() -> impl IntoView {
]
} else {
vec![]
}}
// render articles from resolve/search
}} // render articles from resolve/search
{search_results
.articles
.iter()

View File

@ -28,6 +28,6 @@ fn main() {
_ = console_log::init_with_level(log::Level::Debug);
console_error_panic_hook::set_once();
mount_to_body(|| {
view! { <App/> }
view! { <App /> }
});
}