chiark / gitweb /
bundles download: Send url to web clients (wip)
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Tue, 4 May 2021 11:26:30 +0000 (12:26 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Tue, 4 May 2021 11:28:46 +0000 (12:28 +0100)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
nwtemplates/bundles-info-pane.tera
src/accounts.rs
src/bundles.rs
src/global.rs

index df5a3558940f4d5bdbf630f2115f207819489d69..41b23d5149272a0b8ab4d55e600a9ee28f49357a 100644 (file)
@@ -4,7 +4,7 @@
      There is NO WARRANTY. -->
 {% for b in bundles %}
 <div class="bundle">
-<a class="b_link" href=""><code class="b_id">{{ b.id }}</code></a>
+<a class="b_link" href="b.url"><code class="b_id">{{ b.id }}</code></a>
 <span class="b_title">{{ b.title }}</span>
 </div>
 {% endfor %}
index a55b2662309a14892e758c8c4eac1ad53ba1d5eb..f51a9948e03e747c293ba36f8e59cfc8b1e9a965 100644 (file)
@@ -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<Item=&'out &'out str>,
index 2b04488ea756a3d5bd7a8a90b98e83f2330934f4..fda794f586bff31eac15e84355644cc983914726 100644 (file)
@@ -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(
index 952cee4b462edc38614ecda6d5c585387d6eef31..415a01ada84305675eed9347daa8db5a8acb6348 100644 (file)
@@ -532,6 +532,7 @@ impl Display for InstanceName {
     )?
   }
 }
+hformat_as_display!{InstanceName}
 
 fn link_a_href(k: &HtmlStr, v: &str) -> Html {
   hformat!("<a href={}>{}</a>", v, k)