From 525f4847c833ee79f6652bf16a5d968e260fc320 Mon Sep 17 00:00:00 2001 From: Fons van der Plas Date: Tue, 5 Apr 2022 16:06:42 +0200 Subject: [PATCH 01/49] hello --- frontend/components/welcome/Featured.js | 88 +++++++++++++++++++++++++ frontend/components/welcome/Welcome.js | 2 + frontend/featured_sources.json | 3 + 3 files changed, 93 insertions(+) create mode 100644 frontend/components/welcome/Featured.js create mode 100644 frontend/featured_sources.json diff --git a/frontend/components/welcome/Featured.js b/frontend/components/welcome/Featured.js new file mode 100644 index 0000000000..b84e7c58c9 --- /dev/null +++ b/frontend/components/welcome/Featured.js @@ -0,0 +1,88 @@ +import _ from "../../imports/lodash.js" +import { html, Component, useEffect, useState, useMemo } from "../../imports/Preact.js" + +const run = (f) => f() + +/** + * @typedef SourceManifestEntry + * @type {{ + * id: String, + * hash: String, + * html_path: String, + * statefile_path: String, + * notebookfile_path: String, + * frontmatter: Record, + * }} + */ + +/** + * @typedef SourceManifest + * @type {{ + * notebooks: Record, + * collections: Array, + * pluto_version: String, + * julia_version: String, + * format_version: String, + * source_url: String, + * }} + */ + +export const Featured = () => { + const [sources, set_sources] = useState(/** @type{Array} */ (null)) + + const [source_data, set_source_data] = useState(/** @type{Array} */ ([])) + + useEffect(() => { + run(async () => { + const data = await (await fetch("featured_sources.json")).json() + + set_sources(data.sources) + }) + }, []) + + useEffect(() => { + if (sources != null) { + const promises = sources.map(async (src) => { + const data = await (await fetch(src)).json() + + if (data.format_version !== "1") { + throw new Error(`Invalid format version: ${data.format_version}`) + } + + set_source_data((old) => [ + ...old, + { + ...data, + source_url: src, + }, + ]) + }) + } + }, [sources]) + + return html` + + ` +} diff --git a/frontend/components/welcome/Welcome.js b/frontend/components/welcome/Welcome.js index 61a1983731..e5080356e1 100644 --- a/frontend/components/welcome/Welcome.js +++ b/frontend/components/welcome/Welcome.js @@ -6,6 +6,7 @@ import { create_pluto_connection } from "../../common/PlutoConnection.js" import { new_update_message } from "../../common/NewUpdateMessage.js" import { Open } from "./Open.js" import { Recent } from "./Recent.js" +import { Featured } from "./Featured.js" // This is imported asynchronously - uncomment for development // import environment from "../../common/Environment.js" @@ -75,5 +76,6 @@ export const Welcome = () => { <${Open} client=${client_ref.current} connected=${connected} CustomPicker=${CustomPicker} show_samples=${show_samples} />
<${Recent} client=${client_ref.current} connected=${connected} remote_notebooks=${remote_notebooks} CustomRecent=${CustomRecent} /> + <${Featured} /> ` } diff --git a/frontend/featured_sources.json b/frontend/featured_sources.json new file mode 100644 index 0000000000..3f5f3fa446 --- /dev/null +++ b/frontend/featured_sources.json @@ -0,0 +1,3 @@ +{ + "sources": ["https://cdn.jsdelivr.net/gh/JuliaPluto/featured@d20e3fb/pluto_export.json"] +} \ No newline at end of file From cbfeb718eceac6ef35286f3c00c4c378e29ae8d8 Mon Sep 17 00:00:00 2001 From: Fons van der Plas Date: Tue, 5 Apr 2022 21:20:17 +0200 Subject: [PATCH 02/49] =?UTF-8?q?CSS=20=F0=9F=92=95=F0=9F=92=95?= =?UTF-8?q?=F0=9F=92=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/components/welcome/Featured.js | 37 +++--- frontend/components/welcome/FeaturedCard.js | 78 +++++++++++ frontend/components/welcome/Welcome.js | 2 +- frontend/dark_color.css | 1 + frontend/featured_sources.json | 2 +- frontend/index.css | 139 +++++++++++++++++++- frontend/light_color.css | 1 + 7 files changed, 233 insertions(+), 27 deletions(-) create mode 100644 frontend/components/welcome/FeaturedCard.js diff --git a/frontend/components/welcome/Featured.js b/frontend/components/welcome/Featured.js index b84e7c58c9..46bf09b406 100644 --- a/frontend/components/welcome/Featured.js +++ b/frontend/components/welcome/Featured.js @@ -1,5 +1,6 @@ import _ from "../../imports/lodash.js" import { html, Component, useEffect, useState, useMemo } from "../../imports/Preact.js" +import { FeaturedCard } from "./FeaturedCard.js" const run = (f) => f() @@ -61,28 +62,22 @@ export const Featured = () => { }, [sources]) return html` -