-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* buggy adapter * chore: update dependencies * feat: basic input output * fix: fallback when no supabase setting * fix: types * feat: functional import export * fix: loading optimize * fix: tweak debounce timeout * feat: login logout button * fix: title of created page * fix: delete block issue * refactor: optimize delete block ui * chore: Docker build * chore: github workflow * fix: favicon * chore: static Docker * feat: directly return 404 * chore: enable docker image push on master branch * feat: github login and init sql * chore: build static in workflow
- Loading branch information
Showing
39 changed files
with
7,694 additions
and
5,427 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# Docker | ||
Dockerfile | ||
|
||
# dependencies | ||
/node_modules | ||
/.pnp | ||
.pnp.js | ||
|
||
# misc | ||
.DS_Store | ||
*.pem | ||
|
||
# debug | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
|
||
# local env files | ||
.env.local | ||
.env.development.local | ||
.env.test.local | ||
.env.production.local | ||
|
||
# vercel | ||
.vercel |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
name: Publish Docker | ||
on: | ||
- push | ||
- pull_request_target | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
- name: Cache pnpm modules | ||
uses: actions/cache@v2 | ||
with: | ||
path: ~/.pnpm-store | ||
key: ${{ runner.os }}-${{ hashFiles('**/pnpm-lock.yaml') }} | ||
restore-keys: | | ||
${{ runner.os }}- | ||
- name: Set up pnpm | ||
uses: pnpm/[email protected] | ||
with: | ||
version: 6 | ||
run_install: true | ||
- name: Build static | ||
shell: bash | ||
id: build-static | ||
run: | | ||
export NEXT_PUBLIC_SUPABASE_URL=ECALPER_EB_OT_GNIRTS_EUQINU_YREV_EMOS_SUPABASE_URL | ||
export NEXT_PUBLIC_SUPABSE_PUBLIC_ANON_KEY=ECALPER_EB_OT_GNIRTS_EUQINU_YREV_EMOS_SUPABSE_PUBLIC_ANON_KEY | ||
pnpm run build | ||
pnpm run export | ||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v1 | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v1 | ||
- name: Login to DockerHub | ||
if: ${{ github.ref == 'refs/heads/master' }} | ||
uses: docker/login-action@v1 | ||
with: | ||
username: ${{ secrets.DOCKER_USERNAME }} | ||
password: ${{ secrets.DOCKER_PASSWORD }} | ||
- name: output-docker-tag | ||
shell: bash | ||
id: docker-tag | ||
run: | | ||
unset BRANCH_NAME | ||
BRANCH_NAME=`echo $GITHUB_REF | cut -d '/' -f3 -` | ||
echo "BRANCH_NAME: $BRANCH_NAME" | ||
unset IMG_TAGS ; if [[ $BRANCH_NAME == "master" ]]; then IMG_TAGS='latest' ; else IMG_TAGS="$BRANCH_NAME"; fi | ||
SHA_TAG=`echo $GITHUB_SHA | head -c 7` | ||
echo "SHA_TAG: $SHA_TAG" | ||
echo ::set-output name=DOCKER_BRANCH_TAG::${IMG_TAGS} | ||
echo ::set-output name=DOCKER_SHA_TAG::${SHA_TAG} | ||
- name: Build and push | ||
uses: docker/build-push-action@v2 | ||
with: | ||
context: . | ||
file: Dockerfile-ci | ||
push: ${{ github.ref == 'refs/heads/master' }} | ||
platforms: linux/amd64,linux/arm64,linux/arm/v7,linux/arm/v6 | ||
tags: fengkx/plastic-editor:${{steps.docker-tag.outputs.DOCKER_BRANCH_TAG}},fengkx/plastic-editor:${{steps.docker-tag.outputs.DOCKER_SHA_TAG}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
FROM node:lts AS builder | ||
RUN apt update && apt install -y git build-essential | ||
WORKDIR /app | ||
COPY package.json pnpm-lock.yaml /app/ | ||
RUN npm i -g pnpm | ||
RUN pnpm install --frozen-lockfile | ||
COPY . /app/ | ||
ARG NEXT_PUBLIC_SUPABASE_URL=ECALPER_EB_OT_GNIRTS_EUQINU_YREV_EMOS_SUPABASE_URL | ||
ARG NEXT_PUBLIC_SUPABSE_PUBLIC_ANON_KEY=ECALPER_EB_OT_GNIRTS_EUQINU_YREV_EMOS_SUPABSE_PUBLIC_ANON_KEY | ||
RUN pnpm run build && pnpm run export | ||
|
||
FROM ranadeeppolavarapu/nginx-http3:latest | ||
ENV NGINX_ENVSUBST_OUTPUT_DIR /etc/nginx | ||
|
||
COPY nginx/nginx.conf /etc/nginx/templates/nginx.conf.template | ||
COPY nginx/site-common.conf /etc/nginx/site-common.conf | ||
COPY --from=builder /app/out/ /var/www/static/ | ||
COPY docker-entry-static.sh /app/docker-entry-static.sh | ||
WORKDIR /var/www/static | ||
CMD ["sh", "/app/docker-entry-static.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
FROM ranadeeppolavarapu/nginx-http3:latest | ||
ENV NGINX_ENVSUBST_OUTPUT_DIR /etc/nginx | ||
|
||
COPY nginx/nginx.conf /etc/nginx/templates/nginx.conf.template | ||
COPY nginx/site-common.conf /etc/nginx/site-common.conf | ||
COPY out/ /var/www/static/ | ||
COPY docker-entry-static.sh /app/docker-entry-static.sh | ||
WORKDIR /var/www/static | ||
CMD ["sh", "/app/docker-entry-static.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
A block-based note app. | ||
|
||
|
||
# Prior Art | ||
|
||
- https://github.com/djyde/plastic-editor/ | ||
- https://github.com/pmndrs/jotai |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import Error from "next/error"; | ||
|
||
export default function NotFound() { | ||
return <Error statusCode={404} />; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,31 @@ | ||
import { createContext, useContext } from "react"; | ||
import { hasSupabase, supabase } from "../../../db"; | ||
import { memoryAdapter } from "./memory"; | ||
import { supbaseAdapter } from "./supabase"; | ||
|
||
const AdapterContext = createContext(memoryAdapter); | ||
type IAdapter = typeof memoryAdapter | typeof supbaseAdapter; | ||
const AdapterContext = createContext<IAdapter>(memoryAdapter); | ||
|
||
export type PropsType = { | ||
adapter: typeof memoryAdapter; | ||
adapter?: IAdapter; | ||
}; | ||
export const AdapterProvider: React.FC<PropsType> = ({ adapter, children }) => { | ||
export const AdapterProvider: React.FC<PropsType> = ({ children, adapter }) => { | ||
if (!adapter) { | ||
if (hasSupabase) { | ||
const session = supabase.auth.session(); | ||
console.log(session, Boolean(session)); | ||
adapter = Boolean(session) ? supbaseAdapter : memoryAdapter; | ||
} else { | ||
adapter = memoryAdapter; | ||
} | ||
} | ||
return ( | ||
<AdapterContext.Provider value={adapter}> | ||
{children} | ||
</AdapterContext.Provider> | ||
); | ||
}; | ||
|
||
export function useAdapter() { | ||
return useContext(AdapterContext); | ||
export function useAdapter<T extends IAdapter>() { | ||
return useContext(AdapterContext) as T; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
6cfb8a7
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs: