Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Develop #481

Open
wants to merge 32 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 29 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
e7a028a
Fix anchor links to sections of documents
ggodlewski Jun 23, 2024
1a9a353
Remove console log
ggodlewski Jun 23, 2024
2e4d1e0
Fix tests
ggodlewski Jun 23, 2024
671eec0
Improve graph
ggodlewski May 23, 2024
4925f61
Increase restart delay
ggodlewski Jul 14, 2024
27f5a6d
Update docker build action
ggodlewski Jul 14, 2024
c7b08f7
Update deps
ggodlewski Jul 14, 2024
8e86d6a
Fix deploy
ggodlewski Jul 19, 2024
adbd690
Improving speed
ggodlewski Jul 19, 2024
a4b0145
Add webhook endpoint
ggodlewski Jul 26, 2024
1e6701c
Use tmpfs for tmp
ggodlewski Jul 26, 2024
3bb1d71
Fix overlapping intervals
ggodlewski Jul 27, 2024
bb9b9e2
Use experimental google markdown support
ggodlewski Jul 24, 2024
c6da626
Change process check cause kill -0 seems not to work on alpine for so…
ggodlewski Jul 25, 2024
f6d5221
Fix watching changes
ggodlewski Jul 26, 2024
7fc0e94
Skip double develop deploy
ggodlewski Jul 27, 2024
eb42bef
Make hash links nicer
ggodlewski Jul 4, 2024
948c5d3
Bump mocha version to fix dependabot warning
ggodlewski Aug 4, 2024
e11a6e6
Update pr deploys to use label
ggodlewski Aug 4, 2024
026e589
Update developer guide
ggodlewski Aug 11, 2024
d66402d
Remove unused anchor bookmarks
ggodlewski Aug 16, 2024
7ca722b
Improve removing unused anchor bookmarks
ggodlewski Aug 16, 2024
0edde7d
Fix docker render
ggodlewski Aug 18, 2024
d07d6a7
Fix git commit check all
ggodlewski Aug 18, 2024
8327a08
Improve git pull usability
ggodlewski Aug 29, 2024
17e70cf
Improve UI
ggodlewski Aug 30, 2024
b6cc832
Fix docker mounts
ggodlewski Sep 2, 2024
1fe0315
Fix ui
ggodlewski Sep 2, 2024
bf21af0
Fix linter
ggodlewski Sep 3, 2024
a2cf19d
Add changes webhook support
ggodlewski Sep 24, 2024
9cec1e9
Fix UI quirks
ggodlewski Sep 26, 2024
24578cf
Update docs
ggodlewski Sep 26, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
CLIENT_ID=
CLIENT_SECRET=

RENDER_IMAGE=hugo_render
VOLUME_DATA=/home//wikigdrive
VOLUME_PREVIEW=/home//wikigdrive-preview
DOMAIN=localhost
DOMAIN=http://localhost:3000
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we no longer need RENDER_IMAGE , VOLUME_DATA and VOLUME_PREVIEW?
maybe we should consider adding here placeholders for variables related to JWT and zipkin URL?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In https://github.com/mieweb/wikiGDrive/blob/develop/website/docs/developer-guide.md#running-locally-with-docker we specify those env variables in docker run command

I we use both .env file and -e RENDER_IMAGE... it's not clear which env would be used by wikigdrive.

11 changes: 5 additions & 6 deletions .github/workflows/DevelopServerDeploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,11 @@ jobs:
- name: Copy index for vite
run: mkdir -p ${GITHUB_WORKSPACE}/dist/hugo && cp -rf /var/www/dev.wikigdrive.com/* ${GITHUB_WORKSPACE}/dist/hugo

- uses: whoan/docker-build-with-cache-action@v5
- uses: docker/build-push-action@v6
with:
image_name: "wikigdrive-develop"
image_tag: "${{ github.sha }},latest"
push_image_and_stages: false
build_extra_args: "{'--build-arg': 'GIT_SHA=${{ github.sha }}'}"
tags: "wikigdrive-develop:${{ github.sha }},wikigdrive-develop:latest"
push: false
build-args: "{'--build-arg': 'GIT_SHA=${{ github.sha }}'}"

- name: Stop and remove
run: docker stop wikigdrive-develop ; docker rm wikigdrive-develop
Expand All @@ -73,6 +72,7 @@ jobs:
docker run -d --name wikigdrive-develop \
--restart unless-stopped \
--network nginx \
--tmpfs /tmp \
-v wikiGDriveDevelop:/data \
-v /home/wikigdrive/service_account.json:/service_account.json \
-v /home/wikigdrive/env.develop:/usr/src/app/.env \
Expand All @@ -81,7 +81,6 @@ jobs:
-e "GIT_SHA=${GITHUB_SHA}" \
-e "ZIPKIN_URL=https://dev.wikigdrive.com/zipkin" \
-e "ZIPKIN_SERVICE=wikigdrive-develop" \
--link=zipkin:zipkin \
--publish 127.0.0.1:4000:3000 \
"wikigdrive-develop:${GITHUB_SHA}" wikigdrive \
--service_account /service_account.json \
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/ProdServerDeploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,11 @@ jobs:
- name: Copy index for vite
run: mkdir -p ${GITHUB_WORKSPACE}/dist/hugo && cp -rf /var/www/wikigdrive.com/* ${GITHUB_WORKSPACE}/dist/hugo

- uses: whoan/docker-build-with-cache-action@v5
- uses: docker/build-push-action@v6
with:
image_name: "wikigdrive-prod"
image_tag: "${{ github.sha }},latest"
push_image_and_stages: false
build_extra_args: "{'--build-arg': 'GIT_SHA=${{ github.sha }}'}"
tags: "wikigdrive-prod:${{ github.sha }},wikigdrive-prod:latest"
push: false
build-args: "{'--build-arg': 'GIT_SHA=${{ github.sha }}'}"

- name: Stop and remove
run: docker stop wikigdrive-prod ; docker rm wikigdrive-prod
Expand All @@ -72,6 +71,7 @@ jobs:
- name: Start
run: |
docker run -d --name wikigdrive-prod \
--tmpfs /tmp \
-v wikiGDriveProd:/data \
-v /home/wikigdrive/service_account.json:/service_account.json \
-v /home/wikigdrive/env.prod:/usr/src/app/.env \
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 @@ -32,7 +32,7 @@ jobs:

build:
needs: test
runs-on: wgd-dev
runs-on: ubuntu-latest

steps:
- name: Create pull request
Expand Down
128 changes: 68 additions & 60 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@ name: Pull request created

on:
pull_request:
branches: [ master ]
types: [edited, synchronize]
paths-ignore:
- 'develop/**'

jobs:
test:
if: github.event.pull_request.head.ref != 'develop' && contains( github.event.pull_request.labels.*.name, 'deploy-pr')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we want to limit it? Does building/testing take too much time?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wikigdrive starts watching each shared drive for changes. It seems that the more watchers we use the slower they work. Each additional instance is another set of connections to the API.

runs-on: ubuntu-latest

steps:
Expand All @@ -31,70 +33,76 @@ jobs:
run: npm run test

build:
if: github.event.pull_request.head.ref != 'develop' && contains( github.event.pull_request.labels.*.name, 'deploy-pr')
needs: test
runs-on: wgd-dev

steps:
- name: Test
run: echo "${{ github.event.number }}"

- uses: actions/checkout@v4

- name: Use Node.js 20.x
uses: actions/setup-node@v3
with:
node-version: 20
cache: npm

- name: Build action runner
run: docker build -t "wgd-action-runner:pr-${{ github.event.number }}" --build-arg "GIT_SHA=${{ github.sha }}" apps/wgd-action-runner

- name: Build hugo docs
run: |
docker run \
-v "${GITHUB_WORKSPACE}/hugo:/site" \
-v "${GITHUB_WORKSPACE}/website:/website" \
-v "/var/www/pr-${{ github.event.number }}.wikigdrive.com:/dist/hugo" \
--env CONFIG_TOML="/site/config/_default/config.toml" --env BASE_URL="https://pr-${{ github.event.number }}.wikigdrive.com" \
wgd-action-runner:pr-${{ github.event.number }} /steps/step_render_hugo

- name: Copy index for vite
run: mkdir -p ${GITHUB_WORKSPACE}/dist/hugo && cp -rf /var/www/pr-${{ github.event.number }}.wikigdrive.com/* ${GITHUB_WORKSPACE}/dist/hugo

- name: build
uses: whoan/docker-build-with-cache-action@v5
with:
image_name: "wikigdrive-feature"
image_tag: "${{ github.sha }}"
push_image_and_stages: false
build_extra_args: "{'--build-arg': 'GIT_SHA=${{ github.sha }}'}"
- uses: actions/checkout@v4

- name: Use Node.js 20.x
uses: actions/setup-node@v3
with:
node-version: 20
cache: npm

- name: Build action runner
run: docker build -t "wgd-action-runner:pr-${{ github.event.number }}" --build-arg "GIT_SHA=${{ github.sha }}" apps/wgd-action-runner

- name: Build hugo docs
run: |
docker run \
-v "${GITHUB_WORKSPACE}/hugo:/site" \
-v "${GITHUB_WORKSPACE}/website:/website" \
-v "/var/www/pr-${{ github.event.number }}.wikigdrive.com:/dist/hugo" \
--env CONFIG_TOML="/site/config/_default/config.toml" --env BASE_URL="https://pr-${{ github.event.number }}.wikigdrive.com" \
wgd-action-runner:pr-${{ github.event.number }} /steps/step_render_hugo

- name: Copy index for vite
run: mkdir -p ${GITHUB_WORKSPACE}/dist/hugo && cp -rf /var/www/pr-${{ github.event.number }}.wikigdrive.com/* ${GITHUB_WORKSPACE}/dist/hugo

- name: build
uses: docker/build-push-action@v6
with:
tags: "wikigdrive-feature:${{ github.sha }}"
push: false
build-args: "{'--build-arg': 'GIT_SHA=${{ github.sha }}'}"

- 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 }}"

- name: Start
run: |
docker run -d --name "pr-${{ github.event.number }}" \
--restart unless-stopped \
--network nginx \
--tmpfs /tmp \
-v "pr-${{ github.event.number }}":/data \
-v /home/wikigdrive/service_account.json:/service_account.json \
-v /home/wikigdrive/env.develop:/usr/src/app/.env \
-v /var/run/docker.sock:/var/run/docker.sock \
-v "/var/www/pr-${{ github.event.number }}.wikigdrive.com:/usr/src/app/dist/hugo" \
-e "GIT_SHA=${{ github.sha }}" \
-e "ZIPKIN_URL=https://pr-${{ github.event.number }}.wikigdrive.com/zipkin" \
-e "ZIPKIN_SERVICE=pr-${{ github.event.number }}" \
-e "AUTH_DOMAIN=https://dev.wikigdrive.com" \
-e "AUTH_INSTANCE=pr-${{ github.event.number }}" \
-e "DOMAIN=https://pr-${{ github.event.number }}.wikigdrive.com" \
"wikigdrive-feature:${{ github.sha }}" wikigdrive \
--service_account /service_account.json \
--share_email [email protected] \
--workdir /data \
server 3000

remove:
if: github.event.pull_request.head.ref != 'develop' && !contains( github.event.pull_request.labels.*.name, 'deploy-pr')
runs-on: wgd-dev

steps:
- 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 }}"

- name: Start
run: |
docker run -d --name "pr-${{ github.event.number }}" \
--restart unless-stopped \
--network nginx \
-v "pr-${{ github.event.number }}":/data \
-v /home/wikigdrive/service_account.json:/service_account.json \
-v /home/wikigdrive/env.develop:/usr/src/app/.env \
-v /var/run/docker.sock:/var/run/docker.sock \
-v "/var/www/pr-${{ github.event.number }}.wikigdrive.com:/usr/src/app/dist/hugo" \
-e "GIT_SHA=${{ github.sha }}" \
-e "ZIPKIN_URL=https://pr-${{ github.event.number }}.wikigdrive.com/zipkin" \
-e "ZIPKIN_SERVICE=pr-${{ github.event.number }}" \
-e "AUTH_DOMAIN=https://dev.wikigdrive.com" \
-e "AUTH_INSTANCE=pr-${{ github.event.number }}" \
-e "DOMAIN=https://pr-${{ github.event.number }}.wikigdrive.com" \
--link=zipkin:zipkin \
"wikigdrive-feature:${{ github.sha }}" wikigdrive \
--service_account /service_account.json \
--share_email [email protected] \
--workdir /data \
server 3000
10 changes: 10 additions & 0 deletions apps/ui/assets/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -202,3 +202,13 @@ a[disabled] {
border-left: 3px solid var(--bs-gray-500);
padding: 2em 0 2em 3em;
}

.prism-editor__editor {
font-size: 16px;
font-family: monospace !important;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it work without !important? If not, maybe it would be better to use an id instead of a class as CSS selector?

}
pre.prism-editor__editor {
overflow-x: scroll; /* Adds a horizontal scrollbar when necessary */
white-space: pre !important; /* Ensures that text does not wrap */
word-wrap: normal !important; /* Ensures that long words don't break */
}
79 changes: 66 additions & 13 deletions apps/ui/src/components/BackLinks.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
<template>
<div class="x-container">
<div v-if="loading">Loading...</div>
<div v-else-if="notGenerated">
Links not generated. Run Transform.
</div>
<div v-else class="x-container">
<slot name="header">
<h5>Back Links</h5>
</slot>
Expand Down Expand Up @@ -34,7 +38,7 @@
No Links
</div>

<svg ref="graph" width="830" height="300" viewBox="0 0 830 300" style="max-width: 100%; height: auto;">
<svg ref="graph" width="830" height="800" viewBox="0 0 830 800" style="max-width: 100%; height: auto;">
<defs>
<marker id="arrow" viewBox="0 -10 20 20" refX="100" refY="0" markerWidth="8" markerHeight="8" orient="auto">
<path class="cool arrowHead" d="M0,-10L20,0L0,10" style="fill: teal; stroke: teal;"></path>
Expand All @@ -50,6 +54,39 @@
import {UtilsMixin} from './UtilsMixin.ts';
import * as d3 from 'https://cdn.jsdelivr.net/npm/d3@7/+esm';

function smartSlice(limit, arr) {
arr = Array.from(arr).map(subArr => {
subArr = Array.from(subArr);
subArr.sort((a, b) => b?.linksCount - a?.linksCount);
return subArr;
});

const ranges = new Set();
for (const subArr of arr) {
for (let i = 0; i < subArr.length; i++) {
ranges.add(subArr[i].linksCount);
}
}

const retVal = arr.map(() => []);
let total = 0;

for (const linksCount of ranges) {
if (total > limit) {
break;
}

for (let i = 0; i < arr.length; i++) {
const subArr = arr[i];
const filtered = subArr.filter(obj => obj.linksCount === linksCount);
retVal[i].push(...filtered);
total += filtered.length;
}
}

return retVal;
}

export default {
mixins: [UtilsMixin],
props: {
Expand All @@ -58,6 +95,7 @@ export default {
},
data() {
return {
loading: true,
backlinks: [],
links: [],
graphData: {
Expand All @@ -78,15 +116,24 @@ export default {
},
methods: {
async fetch() {
if (this.selectedFile.id) {
const { backlinks, links } = await this.FileClientService.getBacklinks(this.driveId, this.selectedFile.id);
this.backlinks = backlinks;
this.links = links;
} else {
this.backlinks = [];
this.links = [];
this.loading = true;
try {
if (this.selectedFile.id) {
const { backlinks, links, notGenerated } = await this.FileClientService.getBacklinks(this.driveId, this.selectedFile.id);
this.backlinks = backlinks;
this.links = links;
this.notGenerated = !!notGenerated;
} else {
this.backlinks = [];
this.links = [];
this.notGenerated = true;
}
} finally {
this.loading = false;
}
this.updateGraph();
this.$nextTick( () => {
this.updateGraph();
});
},
selectFile(path) {
if (this.isAddon) {
Expand All @@ -112,11 +159,15 @@ export default {
}
};

for (const row of this.links) {
const [ links, backlinks ] = smartSlice(20, [ this.links, this.backlinks ]);

for (const row of links) {
nodes[row.fileId] = {
id: row.fileId,
title: row.name,
path: row.path,
x: Math.random() * 1000 - 500,
y: Math.random() * 1000 - 500,
group: 1
};
data.edges.push({
Expand All @@ -125,11 +176,13 @@ export default {
value: 1
});
}
for (const row of this.backlinks) {
for (const row of backlinks) {
nodes[row.fileId] = {
id: row.fileId,
title: row.name,
path: row.path,
x: Math.random() * 1000 - 500,
y: Math.random() * 1000 - 500,
group: 2
};
data.edges.push({
Expand All @@ -150,7 +203,7 @@ export default {
this.graphData.nodes = data.nodes.map(d => ({...d}));

const width = 830;
const height = 300;
const height = 800;

// Specify the color scale.
const color = d3.scaleOrdinal(d3.schemeCategory10);
Expand Down
Loading
Loading