Skip to content

Commit

Permalink
Fix bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
ggodlewski committed Dec 4, 2024
1 parent 2a69b40 commit 96fed86
Show file tree
Hide file tree
Showing 17 changed files with 678 additions and 228 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/DevelopServerDeploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
run: npm run lint

- name: Test
run: npm run test
run: npm run test --workspaces --if-present

build:
needs: test
Expand Down Expand Up @@ -58,7 +58,7 @@ jobs:
docker run \
-v "/var/www/dev.wikigdrive.com:/usr/src/app/website/.vitepress/dist" \
-e "GIT_SHA=${{ github.sha }}" \
"wikigdrive-develop:${{ github.sha }}" npm run docs:build
"wikigdrive-develop:${{ github.sha }}" npm run build --workspace website
- name: Stop and remove
run: docker stop wikigdrive-develop ; docker rm wikigdrive-develop
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/ProdServerDeploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
run: npm run lint

- name: Test
run: npm run test
run: npm run test --workspaces --if-present

build:
needs: test
Expand Down Expand Up @@ -59,7 +59,7 @@ jobs:
docker run \
-v "/var/www/wikigdrive.com:/usr/src/app/website/.vitepress/dist" \
-e "GIT_SHA=${{ github.sha }}" \
"wikigdrive-prod:${{ github.sha }}" npm run docs:build
"wikigdrive-prod:${{ github.sha }}" npm run npm run build --workspace website
- name: Stop and remove
run: docker stop wikigdrive-prod ; docker rm wikigdrive-prod
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/feat-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
run: npm run lint

- name: Test
run: npm run test
run: npm run test --workspaces --if-present

build:
needs: test
Expand Down
7 changes: 4 additions & 3 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
run: npm run lint

- name: Test
run: npm run test
run: npm run test --workspaces --if-present

build:
if: github.event.pull_request.head.ref != 'develop' && contains( github.event.pull_request.labels.*.name, 'deploy-pr')
Expand Down Expand Up @@ -63,14 +63,15 @@ jobs:
docker run \
-v "/var/www/pr-${{ github.event.number }}.wikigdrive.com:/usr/src/app/website/.vitepress/dist" \
-e "GIT_SHA=${{ github.sha }}" \
"wikigdrive-feature:${{ github.sha }}" npm run docs:build
"wikigdrive-feature:${{ github.sha }}" npm run build --workspace website
- name: Stop and remove
run: docker stop "pr-${{ github.event.number }}" ; docker rm "pr-${{ github.event.number }}"
continue-on-error: true

- name: "Create empty volume"
run: docker volume rm -f "pr-${{ github.event.number }}" ; docker volume create "pr-${{ github.event.number }}"
run: docker volume create "pr-${{ github.event.number }}"
continue-on-error: true

- name: Start
run: |
Expand Down
21 changes: 12 additions & 9 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,28 @@ FROM node:22-bookworm-slim

ARG BUILD_UI
ARG GIT_SHA
EXPOSE 3000
VOLUME /data
WORKDIR /usr/src/app

RUN apt-get update
RUN apt-get install -yq bash git-lfs openssh-client curl unzip socat
RUN curl -fsSL https://deno.land/install.sh | DENO_INSTALL=/usr/local sh
WORKDIR /usr/src/app

COPY package.json package-lock.json ./
RUN npm install
RUN npm install --location=global ts-node

RUN if [ -z "$BUILD_UI" ] ; then cd /usr/src/app/apps/ui && npm run build ; fi
COPY deno.json deno.lock ./
#RUN npm install
#RUN npm install --location=global ts-node

COPY . ./
RUN npm link --location=user

EXPOSE 3000
VOLUME /data
RUN deno install
#RUN if [ -z "$BUILD_UI" ] ; then cd /usr/src/app/apps/ui && npm run build ; fi
#RUN npm link --location=user
RUN ln -sf /usr/src/app/src/wikigdrive.sh /usr/local/bin/wikigdrive
RUN ln -sf /usr/src/app/src/wikigdrivectl.sh /usr/local/bin/wikigdrivectl

RUN cd /usr/src/app/apps/ui && npm install && npm run build
RUN npm install && npm run build --workspaces

WORKDIR "/usr/src/app"

Expand Down
1 change: 0 additions & 1 deletion apps/ui/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
<link rel="stylesheet" type="text/css" href="/assets/prism.css?GIT_SHA" media="(prefers-color-scheme: light)" />
<link rel="stylesheet" type="text/css" href="/assets/prism-dark.css?GIT_SHA" media="(prefers-color-scheme: dark)" />
<link rel="icon" type="image/svg+xml" href="/images/logo.svg?GIT_SHA" />
<script src="/assets/prism.js?GIT_SHA" ></script>
</head>
<body>
<div id="app"></div>
Expand Down
3 changes: 2 additions & 1 deletion apps/ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,15 @@
"build": "vue-tsc -b && vite build"
},
"dependencies": {
"bootstrap": "5.2.3",
"vue": "3.5.12",
"vue-prism-editor": "2.0.0-alpha.2",
"vue-router": "4.4.5"
},
"devDependencies": {
"@vitejs/plugin-vue": "5.1.4",
"eslint-plugin-vue": "9.31.0",
"vite": "5.4.9",
"vite": "5.4.10",
"vue-tsc": "2.1.10"
}
}
81 changes: 41 additions & 40 deletions apps/ui/src/main.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import {Tooltip} from 'bootstrap';
import {createApp} from './app.ts';
import {addTelemetry} from './telemetry.ts';
import {Emitter, EventType} from 'mitt';

const { app, router } = createApp();
await router.isReady();
addTelemetry(app);

app.mixin({
Expand All @@ -27,48 +25,51 @@ if (!import.meta.env.SSR) {
}
}

const vm= app.mount('#app', true);
router.beforeEach(async (to, from, next) => {
if (to.meta.ssg) {
try {
const response = await fetch(window.location.protocol + '//' + window.location.host + to.path);
const html = await response.text();
router.isReady().then(() => {
const vm = app.mount('#app', true);
router.beforeEach(async (to, from, next) => {
if (to.meta.ssg) {
try {
const protocol = window.location.host.indexOf('localhost') > -1 ? 'http:' : 'https:';
const response = await fetch(protocol + '//' + window.location.host + to.path);
const html = await response.text();

const parser = new DOMParser();
const r = parser.parseFromString(html, 'text/html');
const titleElem = r.querySelector('title');
if (titleElem) {
document.title = titleElem.innerText;
const parser = new DOMParser();
const r = parser.parseFromString(html, 'text/html');
const titleElem = r.querySelector('title');
if (titleElem) {
document.title = titleElem.innerText;
}
const mainContent = r.querySelector('.mainbar__content');
const elemContent = document.querySelector('.mainbar__content');
if (mainContent && elemContent) {
setTimeout(() => {
const emitter = (vm as any).emitter;
emitter.emit('html_lazy_content', mainContent.innerHTML);
}, 100);
}
next(true);
return;
} catch (err) {
console.error(err);
}
const mainContent = r.querySelector('.mainbar__content');
const elemContent = document.querySelector('.mainbar__content');
if (mainContent && elemContent) {
setTimeout(() => {
const emitter = (vm as any).emitter;
emitter.emit('html_lazy_content', mainContent.innerHTML);
}, 100);
}
next(true);
return;
} catch (err) {
console.error(err);
}
}

const toDriveId = Array.isArray(to.params?.driveId) ? to.params.driveId[0] : to.params.driveId;
const fromDriveId = Array.isArray(from.params?.driveId) ? from.params.driveId[0] : from.params.driveId;
if (toDriveId !== fromDriveId) {
await (vm as any).FileClientService.clearCache();
await (vm as any).changeDrive(toDriveId);
}
next();
});
router.afterEach(() => {
const elements = document.querySelectorAll('[data-bs-toggle=tooltip]');
elements.forEach(element => {
const tooltip = Tooltip.getInstance(element);
if (tooltip) {
tooltip.hide();
const toDriveId = Array.isArray(to.params?.driveId) ? to.params.driveId[0] : to.params.driveId;
const fromDriveId = Array.isArray(from.params?.driveId) ? from.params.driveId[0] : from.params.driveId;
if (toDriveId !== fromDriveId) {
await (vm as any).FileClientService.clearCache();
await (vm as any).changeDrive(toDriveId);
}
next();
});
router.afterEach(() => {
const elements = document.querySelectorAll('[data-bs-toggle=tooltip]');
elements.forEach(element => {
const tooltip = Tooltip.getInstance(element);
if (tooltip) {
tooltip.hide();
}
});
});
});
2 changes: 2 additions & 0 deletions apps/ui/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export function generateIndexHtml() {
<meta name="viewport" content="width=device-width,initial-scale=1" />
<title>WikiGDrive</title>
<meta name="description" content="${description}" />
<meta name="generator" content="generateIndexHtml()" />
${renderHead()}
</head>
<body>
Expand Down Expand Up @@ -90,6 +91,7 @@ export default defineConfig({
vue: 'vue/dist/vue.esm-bundler.js',
}
},
base: '/',
build: {
sourcemap: true,
manifest: true,
Expand Down
Loading

0 comments on commit 96fed86

Please sign in to comment.