Skip to content

Commit

Permalink
fixing data link
Browse files Browse the repository at this point in the history
  • Loading branch information
doomlab committed Jan 21, 2025
1 parent f5d351b commit 6f80492
Show file tree
Hide file tree
Showing 8 changed files with 57 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,8 @@ p, table, figure, figcaption, h1, h2, h3, h4, h5, h6, ol, .katex-display {
font-size: 16px;
}

#observablehq-footer a div span {

#observablehq-footer span {
font-size: 16px !important;
margin-top: 10px;
}
Expand Down
4 changes: 2 additions & 2 deletions docs/elements_tasks.html
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,12 @@
<script>{const e=document.querySelector("#observablehq-sidebar"),t=document.querySelector("#observablehq-sidebar-toggle"),r=sessionStorage.getItem("observablehq-sidebar");r?t.checked=r==="true":t.indeterminate=!0;for(const o of document.querySelectorAll("#observablehq-sidebar summary")){const s=o.parentElement;switch(sessionStorage.getItem(`observablehq-sidebar:${o.textContent}`)){case"true":s.open=!0;break;case"false":s.classList.contains("observablehq-section-active")||(s.open=!1);break}}addEventListener("beforeunload",()=>sessionStorage.setItem("observablehq-sidebar-scrolly",`${e.scrollTop}`));const a=sessionStorage.getItem("observablehq-sidebar-scrolly");a!=null&&(e.style.cssText="overflow: hidden;",e.scrollTop=+a,e.style.cssText="");}</script>
<div id="observablehq-center">
<main id="observablehq-main" class="observablehq">
<link rel="stylesheet" href="./_file/style.d25d8d18.css">
<link rel="stylesheet" href="./_file/style.33474ede.css">
<div class="observablehq observablehq--block"><!--:0985608c:--></div>
</main>
<footer id="observablehq-footer">
<nav><a rel="prev" href="./people_roles"><span>Contributors</span></a><a rel="next" href="./forms"><span>Form Data</span></a></nav>
<div>Built with <a href="https://observablehq.com/" target="_blank" rel="noopener noreferrer">Observable</a> on <a title="2025-01-20T21:40:27">Jan 20, 2025</a>.</div>
<div>Built with <a href="https://observablehq.com/" target="_blank" rel="noopener noreferrer">Observable</a> on <a title="2025-01-20T21:58:24">Jan 20, 2025</a>.</div>
</footer>
</div>
</body>
Expand Down
4 changes: 2 additions & 2 deletions docs/forms.html
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,12 @@
<script>{const e=document.querySelector("#observablehq-sidebar"),t=document.querySelector("#observablehq-sidebar-toggle"),r=sessionStorage.getItem("observablehq-sidebar");r?t.checked=r==="true":t.indeterminate=!0;for(const o of document.querySelectorAll("#observablehq-sidebar summary")){const s=o.parentElement;switch(sessionStorage.getItem(`observablehq-sidebar:${o.textContent}`)){case"true":s.open=!0;break;case"false":s.classList.contains("observablehq-section-active")||(s.open=!1);break}}addEventListener("beforeunload",()=>sessionStorage.setItem("observablehq-sidebar-scrolly",`${e.scrollTop}`));const a=sessionStorage.getItem("observablehq-sidebar-scrolly");a!=null&&(e.style.cssText="overflow: hidden;",e.scrollTop=+a,e.style.cssText="");}</script>
<div id="observablehq-center">
<main id="observablehq-main" class="observablehq">
<link rel="stylesheet" href="./_file/style.d25d8d18.css">
<link rel="stylesheet" href="./_file/style.33474ede.css">
<div class="observablehq observablehq--block"><!--:0985608c:--></div>
</main>
<footer id="observablehq-footer">
<nav><a rel="prev" href="./elements_tasks"><span>Tasks</span></a><a rel="next" href="./timeline"><span>Events</span></a></nav>
<div>Built with <a href="https://observablehq.com/" target="_blank" rel="noopener noreferrer">Observable</a> on <a title="2025-01-20T21:40:27">Jan 20, 2025</a>.</div>
<div>Built with <a href="https://observablehq.com/" target="_blank" rel="noopener noreferrer">Observable</a> on <a title="2025-01-20T21:58:24">Jan 20, 2025</a>.</div>
</footer>
</div>
</body>
Expand Down
28 changes: 25 additions & 3 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,27 @@
return {toProperCase,metadataContainer,formatDate};
}});

define({id: "c0138030", inputs: ["jsonData"], outputs: ["jsonBlob","jsonUrl","downloadLink","linkContainer"], body: (jsonData) => {
// Create a Blob from the JSON data
const jsonBlob = new Blob([JSON.stringify(jsonData, null, 2)], { type: "application/json" });

// Generate a temporary URL for the Blob
const jsonUrl = URL.createObjectURL(jsonBlob);

// Create a dynamic download link
const downloadLink = document.createElement("a");
downloadLink.href = jsonUrl; // Use the generated Blob URL
downloadLink.textContent = "Download Data";
downloadLink.download = "project_summary.json"; // Suggest a filename for download

// Insert the link into the appropriate DOM element
const linkContainer = document.querySelector("#dynamic-download");
if (linkContainer) {
linkContainer.appendChild(downloadLink);
}
return {jsonBlob,jsonUrl,downloadLink,linkContainer};
}});

define({id: "f3af0daf", mode: "inline", inputs: ["jsonData","display"], body: async (jsonData,display) => {
display(await(
jsonData.name || "Unnamed Project"
Expand Down Expand Up @@ -111,9 +132,10 @@
<div id="observablehq-center">
<main id="observablehq-main" class="observablehq">
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css" rel="stylesheet">
<link rel="stylesheet" href="./_file/style.d25d8d18.css">
<link rel="stylesheet" href="./_file/style.33474ede.css">
<div class="observablehq observablehq--block"><!--:d099dc38:--></div>
<div class="observablehq observablehq--block"><!--:41e32c06:--></div>
<div class="observablehq observablehq--block"><!--:c0138030:--></div>
<div class="hero">
<h1><observablehq-loading></observablehq-loading><!--:f3af0daf:--></h1>
</div>
Expand Down Expand Up @@ -153,13 +175,13 @@ <h1><observablehq-loading></observablehq-loading><!--:f3af0daf:--></h1>
<center><a href="./timeline">Check out the timeline</a></center>
</div>
<div class="card">
<center><a href="./_file/data/project_summary.e372cc7d.json">Download Data</a></center>
<center><a id="dynamic-download"></a></center>
</div>
</div>
</main>
<footer id="observablehq-footer">
<nav><a rel="next" href="./people_roles"><span>Contributors</span></a></nav>
<div>Built with <a href="https://observablehq.com/" target="_blank" rel="noopener noreferrer">Observable</a> on <a title="2025-01-20T21:40:27">Jan 20, 2025</a>.</div>
<div>Built with <a href="https://observablehq.com/" target="_blank" rel="noopener noreferrer">Observable</a> on <a title="2025-01-20T21:58:24">Jan 20, 2025</a>.</div>
</footer>
</div>
</body>
Expand Down
4 changes: 2 additions & 2 deletions docs/people_roles.html
Original file line number Diff line number Diff line change
Expand Up @@ -841,7 +841,7 @@
<script src="https://cdn.datatables.net/buttons/2.4.1/js/dataTables.buttons.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.1.3/jszip.min.js"></script>
<script src="https://cdn.datatables.net/buttons/2.4.1/js/buttons.html5.min.js"></script>
<link rel="stylesheet" href="./_file/style.d25d8d18.css">
<link rel="stylesheet" href="./_file/style.33474ede.css">
<div class="hero">
<h1>Contributor Information</h1>
</div>
Expand Down Expand Up @@ -942,7 +942,7 @@ <h2 id="data-downloads" tabindex="-1"><a class="observablehq-header-anchor" href
</main>
<footer id="observablehq-footer">
<nav><a rel="prev" href="./"><span>Project Summary</span></a><a rel="next" href="./elements_tasks"><span>Tasks</span></a></nav>
<div>Built with <a href="https://observablehq.com/" target="_blank" rel="noopener noreferrer">Observable</a> on <a title="2025-01-20T21:40:27">Jan 20, 2025</a>.</div>
<div>Built with <a href="https://observablehq.com/" target="_blank" rel="noopener noreferrer">Observable</a> on <a title="2025-01-20T21:58:24">Jan 20, 2025</a>.</div>
</footer>
</div>
</body>
Expand Down
2 changes: 1 addition & 1 deletion docs/timeline.html
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ <h2 id="calendar" tabindex="-1"><a class="observablehq-header-anchor" href="#cal
</style></main>
<footer id="observablehq-footer">
<nav><a rel="prev" href="./forms"><span>Form Data</span></a></nav>
<div>Built with <a href="https://observablehq.com/" target="_blank" rel="noopener noreferrer">Observable</a> on <a title="2025-01-20T21:40:27">Jan 20, 2025</a>.</div>
<div>Built with <a href="https://observablehq.com/" target="_blank" rel="noopener noreferrer">Observable</a> on <a title="2025-01-20T21:58:24">Jan 20, 2025</a>.</div>
</footer>
</div>
</body>
Expand Down
22 changes: 21 additions & 1 deletion src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,26 @@ const formatDate = (dateString) => {
};
```

```js download data
// Create a Blob from the JSON data
const jsonBlob = new Blob([JSON.stringify(jsonData, null, 2)], { type: "application/json" });

// Generate a temporary URL for the Blob
const jsonUrl = URL.createObjectURL(jsonBlob);

// Create a dynamic download link
const downloadLink = document.createElement("a");
downloadLink.href = jsonUrl; // Use the generated Blob URL
downloadLink.textContent = "Download Data";
downloadLink.download = "project_summary.json"; // Suggest a filename for download

// Insert the link into the appropriate DOM element
const linkContainer = document.querySelector("#dynamic-download");
if (linkContainer) {
linkContainer.appendChild(downloadLink);
}
```

<div class="hero">
<h1>${jsonData.name || "Unnamed Project"}</h1>
</div>
Expand Down Expand Up @@ -90,6 +110,6 @@ const formatDate = (dateString) => {
<center><a href="timeline">Check out the timeline</a></center>
</div>
<div class="card">
<center><a href="./_file/data/project_summary.e372cc7d.json">Download Data</a></center>
<center><a id="dynamic-download"></a></center>
</div>
</div>
3 changes: 2 additions & 1 deletion src/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,8 @@ p, table, figure, figcaption, h1, h2, h3, h4, h5, h6, ol, .katex-display {
font-size: 16px;
}

#observablehq-footer a div span {

#observablehq-footer span {
font-size: 16px !important;
margin-top: 10px;
}
Expand Down

0 comments on commit 6f80492

Please sign in to comment.