From 44fa0fd13601d717c5cec9394f0925fdfdeb6f23 Mon Sep 17 00:00:00 2001 From: Andrew Vivash Date: Tue, 27 Sep 2022 11:30:41 -0700 Subject: [PATCH] Feat: move gallery code to gallery domain (#69) --- README.md | 10 +-- src/lib/app-info.ts | 2 +- src/lib/auth/account.ts | 17 +--- src/routes/gallery/+layout.svelte | 47 +++++++++++ src/routes/gallery/+page.svelte | 10 +-- .../components/icons/FileUploadIcon.svelte | 19 +++++ .../components}/imageGallery/ImageCard.svelte | 2 +- .../imageGallery/ImageGallery.svelte | 32 +++++--- .../imageGallery/ImageModal.svelte | 9 +-- .../components}/upload/Dropzone.svelte | 6 +- .../components}/upload/FileUploadCard.svelte | 6 +- src/{ => routes/gallery}/lib/gallery.ts | 79 ++++++++++++------- src/routes/gallery/stores.ts | 16 ++++ src/stores.ts | 9 --- tsconfig.json | 2 + vite.config.ts | 2 + 16 files changed, 181 insertions(+), 87 deletions(-) create mode 100644 src/routes/gallery/+layout.svelte create mode 100644 src/routes/gallery/components/icons/FileUploadIcon.svelte rename src/{components/gallery => routes/gallery/components}/imageGallery/ImageCard.svelte (92%) rename src/{components/gallery => routes/gallery/components}/imageGallery/ImageGallery.svelte (56%) rename src/{components/gallery => routes/gallery/components}/imageGallery/ImageModal.svelte (94%) rename src/{components/gallery => routes/gallery/components}/upload/Dropzone.svelte (92%) rename src/{components/gallery => routes/gallery/components}/upload/FileUploadCard.svelte (85%) rename src/{ => routes/gallery}/lib/gallery.ts (76%) create mode 100644 src/routes/gallery/stores.ts diff --git a/README.md b/README.md index a5bae40..40ead71 100644 --- a/README.md +++ b/README.md @@ -98,11 +98,7 @@ The app template is designed to be easy for you to _make it your own._ Here's ho If you're not building an image gallery, you don't need the gallery demo code, except perhaps to learn from. To get rid of it, delete: - - `/src/lib/gallery.svelte` - - `/src/routes/gallery.svelte` - - `/src/components/gallery` - - the `galleryStore` in `/src/stores.ts` - - the `initializeFilesystem` function in `/src/lib/auth/account.ts` creates directories used by WNFS. Change those to what you need for your app or delete them if you're not using WNFS. + - `/src/routes/gallery` ๐Ÿ‘ You're ready to start adding custom functionality! ๐Ÿš€ @@ -110,7 +106,6 @@ Check out the [Webnative Guide](https://guide.fission.codes/developers/webnative ## ๐Ÿงจ Deploy - The Webnative App Template is currently deployed as a [Netlify app](https://webnative.netlify.app) and a [Fission app](https://webnative-template.fission.app), but it should be supported on any static hosting platform (Vercel, Cloudflare Pages, etc). ### Netlify @@ -120,9 +115,10 @@ In order to deploy your Webnative application on Netlify: 1. Create a new Netlify site and connect your app's git repository. (If you don't have your application stored in a git repository, you can upload the output of a [static build](#static-build).) 2. Netlify takes care of the rest. No Netlify-specific configuration is needed. 3. There is no step 3. + ### Fission App Hosting -A Webnative application can be published to IPFS with the [Fission CLI](https://guide.fission.codes/developers/cli) or the [Fission GitHub publish action](https://github.com/fission-suite/publish-action). +A Webnative application can be published to IPFS with the [Fission CLI](https://guide.fission.codes/developers/cli) or the [Fission GitHub publish action](https://github.com/fission-suite/publish-action). To publish with the Fission CLI: diff --git a/src/lib/app-info.ts b/src/lib/app-info.ts index 2b9275c..d2167cd 100644 --- a/src/lib/app-info.ts +++ b/src/lib/app-info.ts @@ -2,4 +2,4 @@ export const appName = 'Awesome Webnative App' export const appDescription = 'This is another awesome Webnative app.' export const appURL = 'https://webnative.netlify.app' export const appImageURL = `${appURL}/preview.png` -export const fissionServerUrl = 'runfission.com' +export const ipfsGatewayUrl = 'runfission.com' diff --git a/src/lib/auth/account.ts b/src/lib/auth/account.ts index 7e82ad3..3f60d33 100644 --- a/src/lib/auth/account.ts +++ b/src/lib/auth/account.ts @@ -1,10 +1,8 @@ import * as webnative from 'webnative' -import type FileSystem from 'webnative/fs/index' import { asyncDebounce } from '$lib/utils' import { filesystemStore, sessionStore } from '../../stores' import { getBackupStatus } from '$lib/auth/backup' -import { AREAS, GALLERY_DIRS } from '$lib/gallery' export const isUsernameValid = async (username: string): Promise => { return webnative.account.isUsernameValid(username) @@ -29,9 +27,6 @@ export const register = async (username: string): Promise => { const fs = await webnative.bootstrapRootFileSystem() filesystemStore.set(fs) - // TODO Remove if only public and private directories are needed - await initializeFilesystem(fs) - sessionStore.update(session => ({ ...session, username, @@ -41,16 +36,6 @@ export const register = async (username: string): Promise => { return success } -/** - * Create additional directories and files needed by the app - * - * @param fs FileSystem - */ -const initializeFilesystem = async (fs: FileSystem): Promise => { - await fs.mkdir(webnative.path.directory(...GALLERY_DIRS[AREAS.PUBLIC])) - await fs.mkdir(webnative.path.directory(...GALLERY_DIRS[AREAS.PRIVATE])) -} - export const loadAccount = async (username: string): Promise => { await checkDataRoot(username) @@ -90,4 +75,4 @@ const checkDataRoot = async (username: string): Promise => { resolve() }, 500) }) -} \ No newline at end of file +} diff --git a/src/routes/gallery/+layout.svelte b/src/routes/gallery/+layout.svelte new file mode 100644 index 0000000..586a37d --- /dev/null +++ b/src/routes/gallery/+layout.svelte @@ -0,0 +1,47 @@ + + +{#if fsCheckCompleted} + +{/if} diff --git a/src/routes/gallery/+page.svelte b/src/routes/gallery/+page.svelte index ea1a33c..6a15909 100644 --- a/src/routes/gallery/+page.svelte +++ b/src/routes/gallery/+page.svelte @@ -1,11 +1,11 @@ + + diff --git a/src/components/gallery/imageGallery/ImageCard.svelte b/src/routes/gallery/components/imageGallery/ImageCard.svelte similarity index 92% rename from src/components/gallery/imageGallery/ImageCard.svelte rename to src/routes/gallery/components/imageGallery/ImageCard.svelte index ae893b4..d90110b 100644 --- a/src/components/gallery/imageGallery/ImageCard.svelte +++ b/src/routes/gallery/components/imageGallery/ImageCard.svelte @@ -1,5 +1,5 @@
diff --git a/src/components/gallery/imageGallery/ImageModal.svelte b/src/routes/gallery/components/imageGallery/ImageModal.svelte similarity index 94% rename from src/components/gallery/imageGallery/ImageModal.svelte rename to src/routes/gallery/components/imageGallery/ImageModal.svelte index 0d7626d..992a9b4 100644 --- a/src/components/gallery/imageGallery/ImageModal.svelte +++ b/src/routes/gallery/components/imageGallery/ImageModal.svelte @@ -1,10 +1,9 @@