forked from alemi/upub
fix(web): variable width pretty uris
and jank fix for lemmy inline posts, ughh
This commit is contained in:
parent
6c88dec148
commit
905564ce15
3 changed files with 6 additions and 6 deletions
|
@ -80,7 +80,7 @@ pub fn Attachment(
|
||||||
view! {
|
view! {
|
||||||
<p class="center mt-s mb-s">
|
<p class="center mt-s mb-s">
|
||||||
<a href={href.clone()} title={href.clone()} rel="noreferrer nofollow" target="_blank">
|
<a href={href.clone()} title={href.clone()} rel="noreferrer nofollow" target="_blank">
|
||||||
<input type="submit" class="w-100" value={Uri::pretty(&href)} title={object.name().unwrap_or_default().to_string()} />
|
<input style="max-width: 100%" type="submit" class="w-100" value={Uri::pretty(&href, 20)} title={object.name().unwrap_or_else(|_| href.as_str()).to_string()} />
|
||||||
</a>
|
</a>
|
||||||
</p>
|
</p>
|
||||||
}.into_view(),
|
}.into_view(),
|
||||||
|
@ -136,7 +136,7 @@ pub fn Object(object: crate::Object) -> impl IntoView {
|
||||||
>
|
>
|
||||||
<code class="color">&</code>
|
<code class="color">&</code>
|
||||||
<small>
|
<small>
|
||||||
{Uri::pretty(&x)}
|
{Uri::pretty(&x, 30)}
|
||||||
</small>
|
</small>
|
||||||
</span>
|
</span>
|
||||||
</a>
|
</a>
|
||||||
|
|
|
@ -20,7 +20,7 @@ pub fn ActorStrip(object: crate::Object) -> impl IntoView {
|
||||||
pub fn ActorBanner(object: crate::Object) -> impl IntoView {
|
pub fn ActorBanner(object: crate::Object) -> impl IntoView {
|
||||||
match object.as_ref() {
|
match object.as_ref() {
|
||||||
serde_json::Value::String(id) => view! {
|
serde_json::Value::String(id) => view! {
|
||||||
<div><b>?</b>" "<a class="clean hover" href={Uri::web(U::Actor, id)}>{Uri::pretty(id)}</a></div>
|
<div><b>?</b>" "<a class="clean hover" href={Uri::web(U::Actor, id)}>{Uri::pretty(id, 50)}</a></div>
|
||||||
},
|
},
|
||||||
serde_json::Value::Object(_) => {
|
serde_json::Value::Object(_) => {
|
||||||
let uid = object.id().unwrap_or_default().to_string();
|
let uid = object.id().unwrap_or_default().to_string();
|
||||||
|
|
|
@ -204,12 +204,12 @@ impl Uri {
|
||||||
uriproxy::uri(URL_BASE, kind, id)
|
uriproxy::uri(URL_BASE, kind, id)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn pretty(url: &str) -> String {
|
pub fn pretty(url: &str, len: usize) -> String {
|
||||||
let bare = url.replace("https://", "");
|
let bare = url.replace("https://", "");
|
||||||
if bare.len() < 50 {
|
if bare.len() < len {
|
||||||
bare
|
bare
|
||||||
} else {
|
} else {
|
||||||
format!("{}..", bare.get(..50).unwrap_or_default())
|
format!("{}..", bare.get(..len).unwrap_or_default())
|
||||||
}.replace('/', "\u{200B}/\u{200B}")
|
}.replace('/', "\u{200B}/\u{200B}")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue