From: Ian Jackson Date: Tue, 4 May 2021 11:26:30 +0000 (+0100) Subject: bundles download: Send url to web clients (wip) X-Git-Tag: otter-0.6.0~397 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=b053c47270b50fa6eef038efd6fe5830b7e3aa48;p=otter.git bundles download: Send url to web clients (wip) Signed-off-by: Ian Jackson --- diff --git a/nwtemplates/bundles-info-pane.tera b/nwtemplates/bundles-info-pane.tera index df5a3558..41b23d51 100644 --- a/nwtemplates/bundles-info-pane.tera +++ b/nwtemplates/bundles-info-pane.tera @@ -4,7 +4,7 @@ There is NO WARRANTY. --> {% for b in bundles %}
-{{ b.id }} +{{ b.id }} {{ b.title }}
{% endfor %} diff --git a/src/accounts.rs b/src/accounts.rs index a55b2662..f51a9948 100644 --- a/src/accounts.rs +++ b/src/accounts.rs @@ -109,7 +109,7 @@ const ACCOUNTS_FILE: &str = "accounts"; //---------- AccountScope and AccountName (ncl. string format) ---------- impl AccountScope { - /// Return value is parseable and filesystem- and html-safe + /// Return value is parseable and filesystem- and url- and html-safe #[throws(E)] pub fn display_name<'out, NS: IntoIterator, diff --git a/src/bundles.rs b/src/bundles.rs index 2b04488e..fda794f5 100644 --- a/src/bundles.rs +++ b/src/bundles.rs @@ -125,6 +125,8 @@ impl FromStr for AssetUrlToken { AssetUrlToken(buf) } } +hformat_as_display!{AssetUrlToken} + #[derive(Error,Debug,Copy,Clone,Serialize)] pub struct BadAssetUrlToken; display_as_debug!{BadAssetUrlToken} @@ -425,14 +427,17 @@ impl MgmtBundleList { #[derive(Serialize,Debug)] struct RenderBundle { id: Html, + url: Html, title: Html, } let bundles = self.iter().filter_map(|(&id, state)| { if_let!{ State::Loaded(Loaded { meta }) = state; else return None; } let BundleMeta { title } = meta; - let id = hformat!("{}", id); let title = Html::from_txt(title); - Some(RenderBundle { id, title }) + let token = id.token(ig); + let url = hformat!("/_/bundle/{}/{}/{}", &*ig.name, &id, &token); + let id = hformat!("{}", id); + Some(RenderBundle { id, url, title }) }).collect(); Html::from_html_string( diff --git a/src/global.rs b/src/global.rs index 952cee4b..415a01ad 100644 --- a/src/global.rs +++ b/src/global.rs @@ -532,6 +532,7 @@ impl Display for InstanceName { )? } } +hformat_as_display!{InstanceName} fn link_a_href(k: &HtmlStr, v: &str) -> Html { hformat!("{}", v, k)