Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8af713636c | ||
|
|
5bf6e5f1dc | ||
|
|
929faf0722 | ||
|
|
5322f90383 | ||
|
|
fa3575cbae | ||
|
|
c94a34ffd7 | ||
|
|
50b49448b6 | ||
|
|
8ff3f5e875 | ||
|
|
640fa7ded4 | ||
|
|
18123f7002 | ||
|
|
cf2094667d | ||
|
|
2cd2165f06 | ||
|
|
4eada4b628 | ||
|
|
05f3ad043a | ||
|
|
6e9083e75d | ||
|
|
7bbdb5900f | ||
|
|
5be45315dc | ||
|
|
5d20ff1ef5 | ||
|
|
86e0eeafd1 | ||
|
|
49c1a87a67 | ||
|
|
ec7f81cb83 | ||
|
|
4b115d7b6a | ||
|
|
1bae6d8d2a | ||
|
|
bdafa19470 | ||
|
|
342236b6a7 | ||
|
|
ffce9f9e85 | ||
|
|
0097e041b1 | ||
|
|
42da621dfc | ||
|
|
2f5dbaa022 | ||
|
|
e181a6d5dd | ||
|
|
7873b21fb7 | ||
|
|
2a219518a4 | ||
|
|
afa7888db0 | ||
|
|
f6a589d5b2 | ||
|
|
41a09d5996 | ||
|
|
191977c0df | ||
|
|
5a4c06daee | ||
|
|
c4942ab807 | ||
|
|
6b83a9f632 | ||
|
|
3c88c0c29c | ||
|
|
35aab6bedc | ||
|
|
17033dc111 | ||
|
|
559df60f0d | ||
|
|
22d4ec1c31 | ||
|
|
d97ad5c843 | ||
|
|
34a67f647b | ||
|
|
9c3228b8fc | ||
|
|
4012d3e090 | ||
|
|
bc1c4d315c | ||
|
|
2a6f0c56a4 | ||
|
|
46e2a15116 | ||
|
|
c068f5a240 | ||
|
|
29bf49958f | ||
|
|
2fcad539ca | ||
|
|
45b79124c9 | ||
|
|
2b44452234 | ||
|
|
0e0b53fe9e | ||
|
|
dba5ba5277 | ||
|
|
942aaf654f | ||
|
|
37e0091502 | ||
|
|
a7c3f1bbda | ||
|
|
a40a070bdb | ||
|
|
082bfc63d1 | ||
|
|
0de8009e65 | ||
|
|
a5e4c81e72 | ||
|
|
c52c26145c | ||
|
|
f5e310a182 | ||
|
|
0828b91602 | ||
|
|
c4f664e412 | ||
|
|
a084c50095 | ||
|
|
9dacd0954d | ||
|
|
50b0a6068c | ||
|
|
4689492bf5 | ||
|
|
6ee9ee9ea4 | ||
|
|
8e3a743ed8 | ||
|
|
9550a16a0c | ||
|
|
a9edac3ce0 | ||
|
|
589850d311 | ||
|
|
9ba9439831 | ||
|
|
38f6b6996a | ||
|
|
1e16570b2f | ||
|
|
889adc6bae | ||
|
|
0de59911b3 | ||
|
|
f22e557b1c | ||
|
|
92ff757efc | ||
|
|
63165599ce | ||
|
|
a5b428d1ec | ||
|
|
cf3f9b1ac3 | ||
|
|
c212d67f49 | ||
|
|
b00a257699 | ||
|
|
3698c0c593 | ||
|
|
32a398609c | ||
|
|
54729fbafc | ||
|
|
b74e5cf94c | ||
|
|
475dd933fe | ||
|
|
60e0e7e61a | ||
|
|
e4a42d3a90 | ||
|
|
d86cd73ea6 | ||
|
|
67280f2ca2 | ||
|
|
a8bcd41f36 | ||
|
|
04cf137a74 | ||
|
|
d542e98581 | ||
|
|
dfaf95bf1d | ||
|
|
0a89426c93 | ||
|
|
7a026ef0e2 | ||
|
|
855f6c261f | ||
|
|
7099598a92 | ||
|
|
ad8851ea94 | ||
|
|
def9dc2707 | ||
|
|
91228a9446 |
No files matched your search
@@ -13,7 +13,7 @@ executors:
|
||||
- image: 'cimg/node:18.19.0'
|
||||
go:
|
||||
docker:
|
||||
- image: cimg/go:1.21.3
|
||||
- image: cimg/go:1.21.5
|
||||
|
||||
parameters:
|
||||
trigger-app:
|
||||
@@ -38,12 +38,12 @@ jobs:
|
||||
go version
|
||||
- restore_cache:
|
||||
keys:
|
||||
- go-mod-1.21.3-{{ checksum "go.sum" }}
|
||||
- go-mod-1.21.5-{{ checksum "go.sum" }}
|
||||
- run:
|
||||
name: Install Dependencies
|
||||
command: go mod download
|
||||
- save_cache:
|
||||
key: go-mod-1.21.3-{{ checksum "go.sum" }}
|
||||
key: go-mod-1.21.5-{{ checksum "go.sum" }}
|
||||
paths:
|
||||
- "~/go/pkg/mod"
|
||||
- run:
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
node_modules
|
||||
@@ -0,0 +1,14 @@
|
||||
# don't ever lint node_modules
|
||||
node_modules
|
||||
# don't lint build output (make sure it's set to your correct build folder name)
|
||||
dist
|
||||
# don't lint nyc coverage output
|
||||
coverage
|
||||
|
||||
vite*.config*
|
||||
|
||||
# ignore all js files
|
||||
**/*.*js
|
||||
|
||||
# ignore all config files
|
||||
*.config.ts
|
||||
@@ -5,7 +5,7 @@ module.exports = {
|
||||
parser: '@typescript-eslint/parser',
|
||||
env: { browser: true },
|
||||
parserOptions: {
|
||||
project: ['./packages/*/tsconfig.json'],
|
||||
project: ['./ui/*/tsconfig.json'],
|
||||
tsconfigRootDir: __dirname,
|
||||
},
|
||||
extends: [
|
||||
@@ -16,8 +16,7 @@ module.exports = {
|
||||
'plugin:import/typescript',
|
||||
'plugin:compat/recommended',
|
||||
],
|
||||
plugins: ['prettier', '@typescript-eslint', 'import'],
|
||||
ignorePatterns: ['node_modules/', 'coverage/', 'dist/', '**/*.js'],
|
||||
plugins: ['@typescript-eslint', 'import'],
|
||||
rules: {
|
||||
'no-alert': 'warn',
|
||||
'no-unused-vars': 0,
|
||||
@@ -41,7 +40,7 @@ module.exports = {
|
||||
settings: {
|
||||
'import/resolver': {
|
||||
typescript: {
|
||||
project: ['packages/artalk/tsconfig.json'].map((p) =>
|
||||
project: ['ui/artalk/tsconfig.json'].map((p) =>
|
||||
path.resolve(__dirname, p),
|
||||
),
|
||||
},
|
||||
@@ -0,0 +1,25 @@
|
||||
name: Comment issue
|
||||
description: Create comment on a issue
|
||||
|
||||
inputs:
|
||||
issue_number:
|
||||
required: true
|
||||
description: The issue number you want to comment
|
||||
content:
|
||||
required: true
|
||||
description: The content of comment
|
||||
|
||||
runs:
|
||||
using: "composite"
|
||||
steps:
|
||||
- uses: actions/github-script@v7
|
||||
env:
|
||||
STDOUT: ${{ inputs.content }}
|
||||
with:
|
||||
script: |
|
||||
github.rest.issues.createComment({
|
||||
issue_number: ${{ inputs.issue_number }},
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
body: process.env.STDOUT
|
||||
})
|
||||
@@ -1,13 +1,18 @@
|
||||
name: Build App
|
||||
run-name: Build Go App and Publish
|
||||
|
||||
on:
|
||||
repository_dispatch:
|
||||
types: [artalk-release]
|
||||
workflow_call:
|
||||
inputs:
|
||||
version:
|
||||
required: true
|
||||
type: string
|
||||
dry_run:
|
||||
required: true
|
||||
type: boolean
|
||||
|
||||
env:
|
||||
GO_VERSION: '1.21.3'
|
||||
PKG_NAME: 'github.com/ArtalkJS/Artalk'
|
||||
GO_VERSION: 1.21.5
|
||||
PKG_NAME: github.com/ArtalkJS/Artalk
|
||||
DOCKER_IMG: ghcr.io/goreleaser/goreleaser-cross
|
||||
CACHE_DIR: /tmp/cache/docker-image
|
||||
|
||||
@@ -17,18 +22,12 @@ jobs:
|
||||
|
||||
steps:
|
||||
- name: Checkout Code
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Checkout latest tag
|
||||
run: |
|
||||
# fetch tags
|
||||
git fetch --prune --unshallow --tags -f
|
||||
|
||||
# checkout latest version
|
||||
VERSION=$(git describe --tags --abbrev=0)
|
||||
git checkout ${VERSION}
|
||||
|
||||
echo "VERSION=${VERSION}" >> $GITHUB_ENV
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
ref: ${{ inputs.version }}
|
||||
# `go-releaser` will read the semver version from git tag name
|
||||
# `git-chglog` will diff the tag and generate changelog
|
||||
fetch-depth: 0
|
||||
|
||||
# disable cache because the err `no space left on device`
|
||||
# - name: Docker Image Cache
|
||||
@@ -64,11 +63,14 @@ jobs:
|
||||
echo "GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }}" > local/.release-env
|
||||
|
||||
# changelog
|
||||
git-chglog --config .github/chglog/config.yml ${VERSION} > local/release-notes.md
|
||||
git-chglog --config .github/chglog/config.yml ${{ inputs.version }} > local/release-notes.md
|
||||
|
||||
# copy config file
|
||||
cp conf/artalk.example.yml artalk.yml
|
||||
|
||||
- name: Print Relase Notes
|
||||
run: cat local/release-notes.md
|
||||
|
||||
- name: Build and Release
|
||||
run: |
|
||||
docker run \
|
||||
@@ -81,4 +83,4 @@ jobs:
|
||||
-e CGO_ENABLED=1 \
|
||||
--env-file local/.release-env \
|
||||
ghcr.io/goreleaser/goreleaser-cross:v${GO_VERSION} \
|
||||
release --release-notes local/release-notes.md
|
||||
release --release-notes local/release-notes.md ${{ inputs.dry_run && '--skip=publish' || '' }}
|
||||
@@ -1,9 +1,17 @@
|
||||
name: Build Docker
|
||||
run-name: Build Docker Image and Publish
|
||||
|
||||
on:
|
||||
repository_dispatch:
|
||||
types: [artalk-release]
|
||||
workflow_call:
|
||||
inputs:
|
||||
version:
|
||||
required: true
|
||||
type: string
|
||||
dry_run:
|
||||
required: true
|
||||
type: boolean
|
||||
target:
|
||||
required: true
|
||||
type: string
|
||||
|
||||
env:
|
||||
DOCKER_IMG: artalk/artalk-go
|
||||
@@ -14,58 +22,14 @@ jobs:
|
||||
|
||||
steps:
|
||||
- name: Checkout Code
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Checkout latest tag
|
||||
run: |
|
||||
# fetch tags
|
||||
git fetch --prune --unshallow --tags -f
|
||||
|
||||
# checkout latest version
|
||||
VERSION=$(git describe --tags --abbrev=0)
|
||||
git checkout ${VERSION}
|
||||
|
||||
VERSION_SHORT="$(cut -d '.' -f 1,2 <<< ${VERSION#v})" # (i.e "v1.2.3" -> "1.2")
|
||||
COMMIT_HASH="$(git rev-parse --short HEAD)"
|
||||
COMMIT_HASH_FULL="$(git rev-parse HEAD)"
|
||||
|
||||
echo "VERSION=${VERSION}" >> $GITHUB_ENV
|
||||
echo "VERSION_SHORT=${VERSION_SHORT}" >> $GITHUB_ENV
|
||||
echo "COMMIT_HASH=${COMMIT_HASH}" >> $GITHUB_ENV
|
||||
echo "COMMIT_HASH_FULL=${COMMIT_HASH_FULL}" >> $GITHUB_ENV
|
||||
|
||||
# https://github.com/docker/login-action
|
||||
- name: Login to DockerHub
|
||||
if: github.event_name != 'pull_request'
|
||||
uses: docker/login-action@v2
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
|
||||
# https://github.com/docker/setup-qemu-action
|
||||
- name: Setup QEMU
|
||||
id: qemu
|
||||
uses: docker/setup-qemu-action@v2
|
||||
with:
|
||||
platforms: 'amd64,arm64'
|
||||
|
||||
# https://github.com/docker/setup-buildx-action
|
||||
- name: Setup Docker Buildx
|
||||
id: buildx
|
||||
uses: docker/setup-buildx-action@v2
|
||||
|
||||
- name: Cache Docker layers
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: /tmp/.buildx-cache
|
||||
key: ${{ runner.os }}-buildx-${{ github.sha }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-buildx-
|
||||
ref: ${{ inputs.version }}
|
||||
|
||||
# https://github.com/docker/metadata-action
|
||||
- name: Gen docker meta
|
||||
id: meta
|
||||
uses: docker/metadata-action@v4
|
||||
uses: docker/metadata-action@v5
|
||||
with:
|
||||
context: git
|
||||
images: |
|
||||
@@ -77,34 +41,42 @@ jobs:
|
||||
type=semver,pattern={{major}}.{{minor}}
|
||||
type=sha
|
||||
|
||||
# https://github.com/docker/login-action
|
||||
- name: Login to DockerHub
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
|
||||
# https://github.com/docker/setup-qemu-action
|
||||
- name: Setup QEMU
|
||||
uses: docker/setup-qemu-action@v3
|
||||
with:
|
||||
platforms: ${{ inputs.target }}
|
||||
|
||||
# https://github.com/docker/setup-buildx-action
|
||||
- name: Setup Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
# Build UI outside of Docker to speed up cross-platform builds
|
||||
- name: Build UI
|
||||
run: |
|
||||
make build-frontend
|
||||
|
||||
# https://github.com/docker/build-push-action
|
||||
- name: Build and Push
|
||||
id: docker_build
|
||||
uses: docker/build-push-action@v4
|
||||
id: build
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
builder: ${{ steps.buildx.outputs.name }}
|
||||
context: ./
|
||||
push: ${{ !inputs.dry_run }}
|
||||
context: .
|
||||
file: ./Dockerfile
|
||||
platforms: 'linux/amd64,linux/arm64'
|
||||
push: true
|
||||
build-args: |
|
||||
APP_VERSION=${{ inputs.version }}
|
||||
SKIP_UI_BUILD=true
|
||||
platforms: ${{ inputs.target }}
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
||||
cache-from: type=local,src=/tmp/.buildx-cache
|
||||
cache-to: type=local,dest=/tmp/.buildx-cache
|
||||
|
||||
- name: Comment build info in commit
|
||||
uses: actions/github-script@v6
|
||||
env:
|
||||
STDOUT: "🐳 Published new docker image: [${{ env.DOCKER_IMG }}](https://hub.docker.com/r/${{ env.DOCKER_IMG }}) (${{ env.VERSION }} / sha-${{ env.COMMIT_HASH }})"
|
||||
with:
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
script: |
|
||||
github.rest.repos.createCommitComment({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
commit_sha: process.env.COMMIT_HASH_FULL, // context.sha
|
||||
body: process.env.STDOUT
|
||||
})
|
||||
|
||||
- name: Print image digest
|
||||
run: echo ${{ steps.docker_build.outputs.digest }}
|
||||
run: echo ${{ steps.build.outputs.digest }}
|
||||
@@ -0,0 +1,31 @@
|
||||
name: Build Done
|
||||
|
||||
on:
|
||||
workflow_call:
|
||||
inputs:
|
||||
version:
|
||||
required: true
|
||||
type: string
|
||||
dry_run:
|
||||
required: true
|
||||
type: boolean
|
||||
issue_number:
|
||||
required: true
|
||||
type: number
|
||||
|
||||
jobs:
|
||||
done:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout Code
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
ref: ${{ inputs.version }}
|
||||
|
||||
- name: Comment done info
|
||||
uses: ./.github/actions/comment
|
||||
if: ${{ inputs.issue_number != 0 }}
|
||||
with:
|
||||
issue_number: ${{ inputs.issue_number }}
|
||||
content: |-
|
||||
🎉 Finished build and publish ${{ inputs.version }} ([NPM Package](https://www.npmjs.com/package/artalk?activeTab=versions) / [Docker Image](https://hub.docker.com/r/artalk/artalk-go/tags) / [Github Release](https://github.com/ArtalkJS/Artalk/releases/tag/${{ inputs.version }})).
|
||||
@@ -1,58 +0,0 @@
|
||||
name: Build Frontend
|
||||
run-name: Build Frontend and Publish
|
||||
|
||||
on:
|
||||
repository_dispatch:
|
||||
types: [artalk-release]
|
||||
|
||||
jobs:
|
||||
build_publish:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
defaults:
|
||||
run:
|
||||
working-directory: ./ui # set for building frontend
|
||||
|
||||
steps:
|
||||
- name: Checkout Code
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Checkout latest tag
|
||||
run: |
|
||||
git fetch --prune --unshallow --tags -f
|
||||
git checkout $(git describe --tags --abbrev=0)
|
||||
|
||||
- name: Use pnpm
|
||||
uses: pnpm/action-setup@v2
|
||||
with:
|
||||
version: 8
|
||||
|
||||
- name: Setup node
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: 18.x
|
||||
registry-url: https://registry.npmjs.org/
|
||||
cache: 'pnpm'
|
||||
cache-dependency-path: './ui/pnpm-lock.yaml'
|
||||
|
||||
- name: Install dependencies
|
||||
run: pnpm install
|
||||
|
||||
- name: Build
|
||||
run: pnpm build
|
||||
|
||||
- name: Publish
|
||||
run: pnpm publish -F artalk --no-git-checks
|
||||
env:
|
||||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||
|
||||
# GitHub Packages
|
||||
#
|
||||
# Setup .npmrc file to publish to GitHub Packages
|
||||
# - uses: actions/setup-node@v2
|
||||
# with:
|
||||
# registry-url: 'https://npm.pkg.github.com'
|
||||
# # Publish to GitHub Packages
|
||||
# - run: npm publish
|
||||
# env:
|
||||
# NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
@@ -0,0 +1,60 @@
|
||||
name: Build Pre Tagging
|
||||
|
||||
on:
|
||||
workflow_call:
|
||||
inputs:
|
||||
dry_run:
|
||||
required: true
|
||||
type: boolean
|
||||
issue_number:
|
||||
required: true
|
||||
type: number
|
||||
outputs:
|
||||
version:
|
||||
description: 'Version'
|
||||
value: ${{ jobs.tagging.outputs.version }}
|
||||
|
||||
jobs:
|
||||
tagging:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Get release version
|
||||
run: |
|
||||
# `github.head_ref` only exists for pull_request events
|
||||
REF="${{ github.head_ref || github.ref }}"
|
||||
VERSION="${REF#release/}"
|
||||
VERSION="${VERSION#refs/tags/}"
|
||||
|
||||
echo "Version: $VERSION"
|
||||
echo "VERSION=$VERSION" >> $GITHUB_ENV
|
||||
|
||||
if [[ ! "$VERSION" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
|
||||
echo "Invalid version format: $VERSION, please check git ref or tag."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
- name: Checkout Code
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Create Tag
|
||||
run: |
|
||||
if [ ! $(git tag -l "${VERSION}") ]; then
|
||||
git config user.name github-actions[bot]
|
||||
git config user.email 41898282+github-actions[bot]@users.noreply.github.com
|
||||
git tag -a $VERSION -m "Release $VERSION"
|
||||
git push origin $VERSION
|
||||
else
|
||||
echo "Skip creating tag $VERSION, already exists."
|
||||
fi
|
||||
|
||||
- name: Comment tag info to PR
|
||||
uses: ./.github/actions/comment
|
||||
if: ${{ inputs.issue_number != 0 }}
|
||||
with:
|
||||
issue_number: ${{ inputs.issue_number }}
|
||||
content: |-
|
||||
🔖 Tagged version [${{ env.VERSION }}](https://github.com/ArtalkJS/Artalk/tree/${{ env.VERSION }}) and updated the [CHANGELOG.md](https://github.com/ArtalkJS/Artalk/blob/master/CHANGELOG.md).
|
||||
outputs:
|
||||
version: ${{ env.VERSION }}
|
||||
@@ -0,0 +1,55 @@
|
||||
name: Build UI
|
||||
|
||||
on:
|
||||
workflow_call:
|
||||
inputs:
|
||||
version:
|
||||
required: true
|
||||
type: string
|
||||
dry_run:
|
||||
required: true
|
||||
type: boolean
|
||||
|
||||
jobs:
|
||||
build_publish:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout Code
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
ref: ${{ inputs.version }}
|
||||
|
||||
- name: Use pnpm
|
||||
uses: pnpm/action-setup@v2
|
||||
with:
|
||||
version: 8
|
||||
|
||||
- name: Setup node
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 18.x
|
||||
registry-url: https://registry.npmjs.org/
|
||||
cache: 'pnpm'
|
||||
|
||||
- name: Install dependencies
|
||||
run: pnpm install --frozen-lockfile
|
||||
|
||||
- name: Build
|
||||
run: pnpm build
|
||||
|
||||
- name: Publish
|
||||
run: pnpm publish -F artalk --no-git-checks ${{ inputs.dry_run && '--dry-run' || '' }}
|
||||
env:
|
||||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||
|
||||
# GitHub Packages
|
||||
#
|
||||
# Setup .npmrc file to publish to GitHub Packages
|
||||
# - uses: actions/setup-node@v4
|
||||
# with:
|
||||
# registry-url: 'https://npm.pkg.github.com'
|
||||
# # Publish to GitHub Packages
|
||||
# - run: npm publish
|
||||
# env:
|
||||
# NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
@@ -0,0 +1,82 @@
|
||||
name: Build and Publish
|
||||
run-name: Build and Publish (${{ github.head_ref || github.ref }}) ${{ inputs.dry_run && '(🧪 Dry-Run)' || '' }}
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches: [master]
|
||||
types: [closed]
|
||||
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
dry_run:
|
||||
description: 'Dry run'
|
||||
type: boolean
|
||||
default: true
|
||||
build_items:
|
||||
description: 'Build items'
|
||||
type: string
|
||||
default: 'ui,app,docker'
|
||||
|
||||
jobs:
|
||||
# Tag the release version code before building
|
||||
# Getting the version code from the branch name or git ref.
|
||||
tagging:
|
||||
# Only run on manual trigger
|
||||
# or when a PR is merged into master.
|
||||
# (which the branch name start with `relase/`)
|
||||
if: |
|
||||
github.event_name == 'workflow_dispatch' ||
|
||||
(github.event.pull_request.merged == true && startsWith(github.head_ref, 'release/'))
|
||||
uses: ./.github/workflows/build-tagging.yml
|
||||
with:
|
||||
issue_number: ${{ github.event.pull_request.number || 0 }}
|
||||
dry_run: ${{ inputs.dry_run || false }}
|
||||
secrets: inherit
|
||||
|
||||
# Build the UI
|
||||
ui:
|
||||
if: inputs.build_items == '' || contains(inputs.build_items, 'ui')
|
||||
needs: tagging
|
||||
uses: ./.github/workflows/build-ui.yml
|
||||
with:
|
||||
version: ${{ needs.tagging.outputs.version }}
|
||||
dry_run: ${{ inputs.dry_run || false }}
|
||||
secrets: inherit
|
||||
|
||||
# Build the Docker image
|
||||
docker:
|
||||
if: inputs.build_items == '' || contains(inputs.build_items, 'docker')
|
||||
needs: tagging
|
||||
uses: ./.github/workflows/build-docker.yml
|
||||
# Parallel build the multi-arch docker image
|
||||
strategy:
|
||||
matrix:
|
||||
# since docker push actions will override the previous images,
|
||||
# so need to build `linux/amd64` and push first,
|
||||
# then build `linux/amd64` twice with other archs (build very slow so keep it last).
|
||||
target: ["linux/amd64", "linux/amd64,linux/arm64,linux/arm/v7"]
|
||||
with:
|
||||
version: ${{ needs.tagging.outputs.version }}
|
||||
dry_run: ${{ inputs.dry_run || false }}
|
||||
target: ${{ matrix.target }}
|
||||
secrets: inherit
|
||||
|
||||
# Build the binary app
|
||||
app:
|
||||
if: inputs.build_items == '' || contains(inputs.build_items, 'app')
|
||||
needs: tagging
|
||||
uses: ./.github/workflows/build-app.yml
|
||||
with:
|
||||
version: ${{ needs.tagging.outputs.version }}
|
||||
dry_run: ${{ inputs.dry_run || false }}
|
||||
secrets: inherit
|
||||
|
||||
# All builds are complete
|
||||
done:
|
||||
needs: [tagging, ui, docker, app]
|
||||
uses: ./.github/workflows/build-done.yml
|
||||
with:
|
||||
version: ${{ needs.tagging.outputs.version }}
|
||||
issue_number: ${{ github.event.pull_request.number || 0 }}
|
||||
dry_run: ${{ inputs.dry_run || false }}
|
||||
secrets: inherit
|
||||
@@ -38,7 +38,7 @@ jobs:
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
|
||||
# Initializes the CodeQL tools for scanning.
|
||||
- name: Initialize CodeQL
|
||||
|
||||
@@ -2,61 +2,39 @@ name: Docs CN Mirror Deploy
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
paths:
|
||||
- "docs/**"
|
||||
branches: ['master']
|
||||
paths: ['docs/**']
|
||||
|
||||
jobs:
|
||||
deploy:
|
||||
if: github.repository == 'ArtalkJS/Artalk'
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
defaults:
|
||||
run:
|
||||
# set for building docs
|
||||
working-directory: ./docs
|
||||
|
||||
steps:
|
||||
# - name: Wait for other docs build to succeed
|
||||
# uses: lewagon/wait-on-check-action@v1.2.0
|
||||
# with:
|
||||
# running-workflow-name: 'Docs CN Mirror Deploy'
|
||||
# check-name: 'Build Docs'
|
||||
# ref: ${{ github.ref }}
|
||||
# repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
# allowed-conclusions: success,skipped,cancelled
|
||||
# wait-interval: 10
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
- name: Use pnpm
|
||||
uses: pnpm/action-setup@v2
|
||||
|
||||
- name: Use pnpm
|
||||
uses: pnpm/action-setup@v2
|
||||
with:
|
||||
version: 8
|
||||
- name: Setup node
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 18
|
||||
cache: "pnpm"
|
||||
|
||||
- name: Setup node
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: 18.x
|
||||
registry-url: https://registry.npmjs.org/
|
||||
cache: 'pnpm'
|
||||
- name: Install dependencies
|
||||
run: pnpm install
|
||||
|
||||
- name: Install dependencies
|
||||
run: pnpm install
|
||||
- name: Build Docs
|
||||
run: pnpm build:docs
|
||||
|
||||
- name: Build Docs
|
||||
run: pnpm docs:build
|
||||
|
||||
- name: Deploy
|
||||
uses: TencentCloud/cos-action@v1
|
||||
with:
|
||||
secret_id: ${{ secrets.TENCENT_CLOUD_SECRET_ID }}
|
||||
secret_key: ${{ secrets.TENCENT_CLOUD_SECRET_KEY }}
|
||||
cos_bucket: ${{ secrets.DOCS_CN_COS_BUCKET }}
|
||||
cos_region: ${{ secrets.DOCS_CN_COS_REGION }}
|
||||
local_path: .vitepress/dist/
|
||||
remote_path: /
|
||||
clean: true
|
||||
- name: Deploy
|
||||
uses: TencentCloud/cos-action@v1
|
||||
with:
|
||||
secret_id: ${{ secrets.TENCENT_CLOUD_SECRET_ID }}
|
||||
secret_key: ${{ secrets.TENCENT_CLOUD_SECRET_KEY }}
|
||||
cos_bucket: ${{ secrets.DOCS_CN_COS_BUCKET }}
|
||||
cos_region: ${{ secrets.DOCS_CN_COS_REGION }}
|
||||
local_path: docs/docs/.vitepress/dist/
|
||||
remote_path: /
|
||||
clean: true
|
||||
@@ -1,5 +1,5 @@
|
||||
name: 📦 Release New Version
|
||||
run-name: 📦 Release ${{ inputs.custom || inputs.semver }} by @${{ github.actor }}
|
||||
name: 0x📦 Release New Version
|
||||
run-name: 📦 Release ${{ inputs.semver }} by @${{ github.actor }} ${{ inputs.dry_run && '(🧪 Dry-Run)' || '' }}
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
@@ -12,49 +12,40 @@ on:
|
||||
- minor
|
||||
- major
|
||||
required: true
|
||||
# custom:
|
||||
# description: 'Custom tag name (i.e v1.0.0-rc.1)'
|
||||
# required: false
|
||||
# default: ''
|
||||
|
||||
env:
|
||||
REPO_DISPATCH_EVENT_TYPE: 'artalk-release'
|
||||
UI_NPM_PKG_FILE: 'ui/packages/artalk/package.json'
|
||||
dry_run:
|
||||
description: 'Dry run?'
|
||||
type: boolean
|
||||
default: false
|
||||
|
||||
jobs:
|
||||
release:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout Code
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Git Fetch
|
||||
run: git fetch --prune --unshallow --tags -f
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
ref: master
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Setup Node
|
||||
uses: actions/setup-node@v3
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 18.x
|
||||
registry-url: https://registry.npmjs.org/
|
||||
|
||||
- name: Setup semver
|
||||
run: npm install -g semver
|
||||
|
||||
- name: Handle Version Number
|
||||
run: |
|
||||
if [ ! -z "${{ inputs.custom }}" ]; then
|
||||
next_version="${{ inputs.custom }}"
|
||||
else
|
||||
npm install -g semver
|
||||
prev_version="$(git describe --tags --abbrev=0)"
|
||||
echo "prev_version: ${prev_version}"
|
||||
next_version="v$(semver --increment ${{ inputs.semver }} ${prev_version})"
|
||||
fi
|
||||
PREV_VERSION="$(git describe --tags --abbrev=0)"
|
||||
NEXT_VERSION="v$(semver --increment ${{ inputs.semver }} ${PREV_VERSION})"
|
||||
|
||||
if [[ ! "${next_version}" =~ ^v.* ]]; then
|
||||
echo "[err] custom tag name must be v*."
|
||||
exit 1
|
||||
fi
|
||||
echo "PREV_VERSION=${PREV_VERSION}" >> $GITHUB_ENV
|
||||
echo "VERSION=${NEXT_VERSION}" >> $GITHUB_ENV
|
||||
|
||||
echo "next_version: ${next_version}"
|
||||
echo "VERSION=${next_version}" >> $GITHUB_ENV
|
||||
- name: Print Next Version
|
||||
run: echo "${VERSION}"
|
||||
|
||||
- name: Setup git-chglog
|
||||
run: |
|
||||
@@ -62,32 +53,35 @@ jobs:
|
||||
| grep -oP '"https://.+linux_amd64.tar.gz"' | tr -d \") | tar -C /usr/local/bin -xz git-chglog
|
||||
git-chglog --version
|
||||
|
||||
- name: Version Changelog and Tagging
|
||||
- name: Version Changelog
|
||||
run: |
|
||||
if [ ! $(git tag -l "${VERSION}") ]; then
|
||||
# prepend changelog
|
||||
changelog=$(git-chglog --config .github/chglog/config.yml --next-tag "${VERSION}" "${VERSION}")
|
||||
echo -e "${changelog}\n" | cat - CHANGELOG.md > temp && mv temp CHANGELOG.md
|
||||
# prepend changelog
|
||||
changelog=$(git-chglog --config .github/chglog/config.yml --next-tag "${VERSION}" "${VERSION}")
|
||||
echo -e "${changelog}\n" | cat - CHANGELOG.md > temp && mv temp CHANGELOG.md
|
||||
|
||||
# modify the version of `package.json`
|
||||
perl -i -pe 's/"version": ".*?"/"version": "'${VERSION#v}'"/g' "${UI_NPM_PKG_FILE}"
|
||||
# modify the version of `package.json`
|
||||
perl -i -pe 's/"version": ".*?"/"version": "'${VERSION#v}'"/g' ui/artalk/package.json
|
||||
|
||||
# modify the version in docs
|
||||
perl -pi -e 's#"latest"(\W+)?:(\W+)?".*?"#"latest": "'${VERSION#v}'"#g' docs/code/ArtalkVersion.json
|
||||
# modify the version in docs
|
||||
perl -pi -e 's#"latest"(\W+)?:(\W+)?".*?"#"latest": "'${VERSION#v}'"#g' docs/docs/code/ArtalkVersion.json
|
||||
|
||||
# git commit and push
|
||||
git config user.name github-actions[bot]
|
||||
git config user.email 41898282+github-actions[bot]@users.noreply.github.com
|
||||
git add .
|
||||
git commit -m "chore: release ${VERSION}"
|
||||
git tag "${VERSION}"
|
||||
- name: Print Git Diff
|
||||
run: git diff
|
||||
|
||||
git push origin master "${VERSION}"
|
||||
else
|
||||
echo "skipped because git tag already exists."
|
||||
fi
|
||||
|
||||
- name: Repository Dispatch
|
||||
uses: peter-evans/repository-dispatch@v2
|
||||
- name: Create Pull Request
|
||||
uses: peter-evans/create-pull-request@v5
|
||||
if: ${{ !inputs.dry_run }}
|
||||
with:
|
||||
event-type: ${{ env.REPO_DISPATCH_EVENT_TYPE }}
|
||||
branch: "release/${{ env.VERSION }}"
|
||||
commit-message: "chore: release ${{ env.VERSION }}"
|
||||
title: "chore: release ${{ env.VERSION }}"
|
||||
labels: release
|
||||
body: |
|
||||
## Release ${{ env.VERSION }} 📦🚀
|
||||
|
||||
This PR is auto-generated, please check the changelog and confirm the release. 😀
|
||||
|
||||
The build workflow will be triggered after the PR is merged.
|
||||
committer: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
|
||||
author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
|
||||
assignees: ${{ github.actor }}
|
||||
@@ -0,0 +1,33 @@
|
||||
name: Test Docs
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: ['*', '!release/*']
|
||||
paths: ['docs/**']
|
||||
tags-ignore: ['v*']
|
||||
pull_request:
|
||||
paths: ['docs/**']
|
||||
branches: ['*', '!release/*']
|
||||
|
||||
jobs:
|
||||
test_docs:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Use pnpm
|
||||
uses: pnpm/action-setup@v2
|
||||
|
||||
- name: Use Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 18.x
|
||||
cache: pnpm
|
||||
|
||||
- name: Install dependencies
|
||||
run: pnpm install
|
||||
|
||||
- name: Build Docs
|
||||
run: pnpm build:docs
|
||||
@@ -2,11 +2,12 @@ name: Test Frontend
|
||||
|
||||
on:
|
||||
push:
|
||||
paths:
|
||||
- 'ui/**'
|
||||
branches: ['*', '!release/*']
|
||||
paths: ['ui/**']
|
||||
tags-ignore: ['v*']
|
||||
pull_request:
|
||||
paths:
|
||||
- 'ui/**'
|
||||
paths: ['ui/**']
|
||||
branches: ['*', '!release/*']
|
||||
|
||||
jobs:
|
||||
test_ui:
|
||||
@@ -17,13 +18,9 @@ jobs:
|
||||
|
||||
runs-on: ${{ matrix.os }}
|
||||
|
||||
defaults:
|
||||
run:
|
||||
working-directory: ./ui
|
||||
|
||||
steps:
|
||||
- name: Checkout Code
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- uses: pnpm/action-setup@v2
|
||||
with:
|
||||
@@ -34,14 +31,16 @@ jobs:
|
||||
with:
|
||||
node-version: ${{ matrix.node }}
|
||||
cache: pnpm
|
||||
cache-dependency-path: './ui/pnpm-lock.yaml'
|
||||
|
||||
- name: Install Dependencies
|
||||
run: pnpm --dir ./ui install --frozen-lockfile
|
||||
run: pnpm install --frozen-lockfile
|
||||
|
||||
- name: Package Build Test
|
||||
run: pnpm build:all
|
||||
|
||||
# TODO: Add unit test
|
||||
# - name: Unit test
|
||||
# run: pnpm test
|
||||
- name: Unit test
|
||||
run: pnpm test
|
||||
|
||||
# https://github.com/arethetypeswrong/arethetypeswrong.github.io
|
||||
- name: 'arethetypeswrong test'
|
||||
run: pnpm -F artalk attw
|
||||
+57
@@ -0,0 +1,57 @@
|
||||
.DS_Store
|
||||
node_modules/
|
||||
|
||||
logs
|
||||
*.log
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
.pnpm-debug.log*
|
||||
|
||||
.idea
|
||||
.vscode
|
||||
*.suo
|
||||
*.ntvs*
|
||||
*.njsproj
|
||||
*.sln
|
||||
.history
|
||||
.editorconfig
|
||||
|
||||
# git
|
||||
.gitignore
|
||||
.gitattributes
|
||||
|
||||
# tests
|
||||
test
|
||||
coverage
|
||||
|
||||
# build tools
|
||||
.travis.yml
|
||||
.jenkins.yml
|
||||
.codeclimate.yml
|
||||
|
||||
# linters
|
||||
.jscsrc
|
||||
.jshintrc
|
||||
.eslintrc*
|
||||
|
||||
# vite configs
|
||||
vite*.config*
|
||||
|
||||
# develop tool configs
|
||||
.prettierrc
|
||||
.eslintrc.js
|
||||
.eslintignore
|
||||
postcss.config.js
|
||||
|
||||
yarn.lock
|
||||
package-lock.json
|
||||
|
||||
# local files
|
||||
deploy
|
||||
local
|
||||
CNAME
|
||||
index.html
|
||||
#dist
|
||||
|
||||
.github
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"semi": false,
|
||||
"arrowParens": "always",
|
||||
"singleQuote": true,
|
||||
"htmlWhitespaceSensitivity": "ignore"
|
||||
}
|
||||
Vendored
-1
@@ -1,5 +1,4 @@
|
||||
{
|
||||
"eslint.workingDirectories": ["./ui"],
|
||||
"cSpell.words": [
|
||||
"akismet",
|
||||
"artalk",
|
||||
|
||||
+186
@@ -1,4 +1,190 @@
|
||||
|
||||
## [v2.8.3](https://github.com/ArtalkJS/Artalk/compare/v2.8.2...v2.8.3) (2024-03-04)
|
||||
|
||||
### Features
|
||||
|
||||
* **api/auth:** invalidate old auth tokens after changing password
|
||||
* **api/domain:** add GET `/conf/domain` endpoint
|
||||
* **app:** add `onConfUpdated` hook
|
||||
* **comment:** add `is_verified` field for comment entity
|
||||
* **ui/api:** add `ctx.getApiHandlers()` to handle error responses and expose hooks
|
||||
* **ui/editor:** add `beforeSubmit` hook for editor submitting
|
||||
* **ui/plugins:** support dynamic loading of ui plug-in scripts ([#774](https://github.com/ArtalkJS/Artalk/issues/774))
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **captcha/image:** unable to display image captcha on initial load
|
||||
* **conf:** skip patching IP region conf if disabled
|
||||
* **exception:** missing `message` field after refactoring exception data structure
|
||||
* **sidebar/login:** cannot select a name with the same email upon login ([#781](https://github.com/ArtalkJS/Artalk/issues/781))
|
||||
* **ui/layer:** ensure immediate operation when calling `show()` after `hide()`
|
||||
|
||||
### Performance Improvements
|
||||
|
||||
* **ui/editor:** improve the icon details for editor
|
||||
|
||||
### Code Refactoring
|
||||
|
||||
* **dao:** validate the args of the `FindCreateUser` function
|
||||
* **entity/user:** extract `CheckPassword` function
|
||||
* **origin:** extract `CheckURLTrusted` function
|
||||
|
||||
|
||||
## [v2.8.2](https://github.com/ArtalkJS/Artalk/compare/v2.8.1...v2.8.2) (2024-02-05)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **api/comments:** `ua` field is optional and not required ([#767](https://github.com/ArtalkJS/Artalk/issues/767))
|
||||
* **style:** replace style `break-all` with `break-word` in content el ([#644](https://github.com/ArtalkJS/Artalk/issues/644))
|
||||
|
||||
### Performance Improvements
|
||||
|
||||
* **ui/editor:** optimize editor styles for narrow-width screens
|
||||
* **ui/editor:** modify editor plug-in text buttons to icons for brevity
|
||||
* **ui/editor:** place `Cancel Reply` at the bottom of editor area ([#644](https://github.com/ArtalkJS/Artalk/issues/644))
|
||||
* **ui/lite:** disable ArtalkLite `preview` config option by default
|
||||
|
||||
|
||||
## [v2.8.1](https://github.com/ArtalkJS/Artalk/compare/v2.8.0...v2.8.1) (2024-02-04)
|
||||
|
||||
### Features
|
||||
|
||||
* **api:** add GET `/comments/:id` endpoint ([#764](https://github.com/ArtalkJS/Artalk/issues/764))
|
||||
* **config:** add `db.prepare_stmt` config option ([#760](https://github.com/ArtalkJS/Artalk/issues/760)) ([#762](https://github.com/ArtalkJS/Artalk/issues/762))
|
||||
* **ui/goto:** improved solution of navigating to comment via link hash ([#693](https://github.com/ArtalkJS/Artalk/issues/693)) ([#765](https://github.com/ArtalkJS/Artalk/issues/765))
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **api/comments:** counting comments issue in PostgreSQL db ([#760](https://github.com/ArtalkJS/Artalk/issues/760)) ([#761](https://github.com/ArtalkJS/Artalk/issues/761))
|
||||
* **cmd/admin:** update user role to admin if already exists
|
||||
* **ip_region:** unable to output the IP region correctly ([#760](https://github.com/ArtalkJS/Artalk/issues/760))
|
||||
* **ui/list:** unable to reply or delete comments after switching pagination
|
||||
* **ui/no_comment:** always appears when creating comment
|
||||
* **ui/pv:** missing `pageTitle` field in the PV request
|
||||
* **ui/scroll:** scroll into view issue when `relativeTo` parameter is provided
|
||||
|
||||
### Performance Improvements
|
||||
|
||||
* **style/sidebar:** improve some detail in sidebar
|
||||
|
||||
### Code Refactoring
|
||||
|
||||
* **ui/comment:** loose coupling between `Comment` and `Context`
|
||||
* **ui/list:** refactor the list layout manager
|
||||
|
||||
### Documentation
|
||||
|
||||
* supplement and refine `fe-api.md`
|
||||
|
||||
|
||||
## [v2.8.0](https://github.com/ArtalkJS/Artalk/compare/v2.7.3...v2.8.0) (2024-01-31)
|
||||
|
||||
### Features
|
||||
|
||||
* **go:** upgrade golang to v1.21.5 and some deps
|
||||
* **notify:** add `notify_pending` config option ([#728](https://github.com/ArtalkJS/Artalk/issues/728)) ([#754](https://github.com/ArtalkJS/Artalk/issues/754))
|
||||
* **ui/admin:** add logout button in admin panel ([#488](https://github.com/ArtalkJS/Artalk/issues/488)) ([#753](https://github.com/ArtalkJS/Artalk/issues/753))
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **cache:** unable to change admin list after caching ([#748](https://github.com/ArtalkJS/Artalk/issues/748)) ([#750](https://github.com/ArtalkJS/Artalk/issues/750))
|
||||
* **i18n:** sidebar language cannot be changed
|
||||
* **ui/editor:** prevent propagation of click event in editor ([#734](https://github.com/ArtalkJS/Artalk/issues/734))
|
||||
* **ui/layer:** unexpected behavior with multiple items when closing
|
||||
* **ui/lite:** correct the instance name for compiling ArtalkLite ([#740](https://github.com/ArtalkJS/Artalk/issues/740))
|
||||
* **ui/no_comment:** flickering when clearing list before fetch
|
||||
* **ui/pagination:** auto load list when scroll reaches bottom
|
||||
* **ui/sidebar:** incorrectly increasing pv count in sidebar ([#724](https://github.com/ArtalkJS/Artalk/issues/724))
|
||||
* **ui/sidebar_layer:** sidebar still displays when login is required
|
||||
|
||||
### Performance Improvements
|
||||
|
||||
* **ui/conf:** support for watching partial changes in config with `watchConf()` ([#755](https://github.com/ArtalkJS/Artalk/issues/755))
|
||||
* **ui/i18n:** refine some translation ([#743](https://github.com/ArtalkJS/Artalk/issues/743))
|
||||
* **ui/pagination:** replace the prev/next text on pagination buttons with icons ([#743](https://github.com/ArtalkJS/Artalk/issues/743))
|
||||
* **ui/sidebar:** prevent potential token leakage by clearing query in iframe url
|
||||
|
||||
### Code Refactoring
|
||||
|
||||
* **api:** update swagger file of API v2
|
||||
* **api:** refactor HTTP API to version 2 ([#735](https://github.com/ArtalkJS/Artalk/issues/735))
|
||||
* **transfer:** normalize transfer payload parameter name
|
||||
* **ui:** optimize init and update lifecycle events
|
||||
* **ui/comment:** rename class `Comment` to `CommentNode`
|
||||
* **ui/ctx:** add `getComments` and `getCommentNodes` in context ([#752](https://github.com/ArtalkJS/Artalk/issues/752))
|
||||
|
||||
### Documentation
|
||||
|
||||
* update multi-sites manual ([#747](https://github.com/ArtalkJS/Artalk/issues/747))
|
||||
|
||||
### BREAKING CHANGE
|
||||
|
||||
|
||||
For Developers: The HTTP API has now been updated to version v2, with a lot of adjustments made, such as changing to Restful API style, request type, request body, response body, etc. data structure, adding error response codes. You can refer to [#735](https://github.com/ArtalkJS/Artalk/issues/735) or https://artalk.js.org/http-api Please update all your existing clients to adapt to the new v2 server. The new base path is `/api/v2/`. The UI package's HTTP client has been implemented to auto-generate based on `Swagger.json`, and there have been a lot of adjustments to the `artalk.ctx.getApi()` related code. In addition, the HTTP API no longer enforces checks on the header's `Origin` and `Referer` (to implement strict isolation of different sites) but still maintains the original CORS origin check.
|
||||
|
||||
For General Users: Now all administrators have the same level of authority (there is no longer super admin authority), the function of assigning sub-administrators with independent scope authority to individual sites has been removed, which can simplify the HTTP server maintenance and implementation. Upgrading only requires updating the client and server application at the same time, and there are no additional operations.
|
||||
|
||||
|
||||
## [v2.7.3](https://github.com/ArtalkJS/Artalk/compare/v2.7.2...v2.7.3) (2023-12-28)
|
||||
|
||||
### Features
|
||||
|
||||
* **ci:** add dry-run mode for build workflow
|
||||
* **cmd:** support cli flag for creating admin account
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **ui/init:** stack overflow when merging with config defaults ([#717](https://github.com/ArtalkJS/Artalk/issues/717))
|
||||
|
||||
### Performance Improvements
|
||||
|
||||
* **ui/build:** better dts generation ([#689](https://github.com/ArtalkJS/Artalk/issues/689))
|
||||
|
||||
### Code Refactoring
|
||||
|
||||
* **ci:** better release workflow
|
||||
* **docker:** add `--build-arg` argument to skip ui build
|
||||
* **test/ui:** add more ui api tests
|
||||
* **ui:** refactor directory structure ([#712](https://github.com/ArtalkJS/Artalk/issues/712))
|
||||
* **ui/conf:** better handling of mutable config ([#722](https://github.com/ArtalkJS/Artalk/issues/722))
|
||||
* **ui/test:** add vitest for unit testing
|
||||
|
||||
### Documentation
|
||||
|
||||
* update ui api documentation
|
||||
|
||||
### BREAKING CHANGE
|
||||
|
||||
|
||||
Directly referencing `artalk.conf` and `artalk.$root` is deprecated. Please use functions instead: `artalk.getConf()` and `artalk.getEl()`.
|
||||
|
||||
|
||||
## [v2.7.2](https://github.com/ArtalkJS/Artalk/compare/v2.7.1...v2.7.2) (2023-12-20)
|
||||
|
||||
### Features
|
||||
|
||||
* patch `locale` config from `zh-cn` to `zh-CN` ([#678](https://github.com/ArtalkJS/Artalk/issues/678))
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **sidebar:** sidebar language switch and config save issue ([#708](https://github.com/ArtalkJS/Artalk/issues/708))
|
||||
* **ui:** add `referrerpolicy` attribute for iframe ([#687](https://github.com/ArtalkJS/Artalk/issues/687)) ([#707](https://github.com/ArtalkJS/Artalk/issues/707))
|
||||
* **ui/dark-mode:** potential memory leak issue in auto mode ([#688](https://github.com/ArtalkJS/Artalk/issues/688))
|
||||
* **ui/pagination:** auto switch page by url hashtag issue ([#693](https://github.com/ArtalkJS/Artalk/issues/693))
|
||||
* **ui/sidebar:** refactor settings and fix save issue ([#677](https://github.com/ArtalkJS/Artalk/issues/677)) ([#706](https://github.com/ArtalkJS/Artalk/issues/706))
|
||||
|
||||
### Code Refactoring
|
||||
|
||||
* **ui:** move window references into function scope ([#675](https://github.com/ArtalkJS/Artalk/issues/675))
|
||||
* **ui/api:** losing coupling between `Api` and `User`
|
||||
* **ui/user:** user class no longer globally singleton
|
||||
|
||||
### Documentation
|
||||
|
||||
* **i18n:** add translation for `open` button
|
||||
* **refactor:** organize the pkgs and fix some issues ([#702](https://github.com/ArtalkJS/Artalk/issues/702))
|
||||
|
||||
|
||||
## [v2.7.1](https://github.com/ArtalkJS/Artalk/compare/v2.7.0...v2.7.1) (2023-12-17)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
+4
-4
@@ -41,9 +41,9 @@ The backend program will run by default on port `23366`. You can access it throu
|
||||
|
||||
### Build Frontend
|
||||
|
||||
First, you need to install the dependencies for the frontend. Simply run the `cd ui && pnpm install` command to install the dependencies.
|
||||
First, you need to install the dependencies for the frontend. Simply run the `pnpm install` command to install the dependencies.
|
||||
|
||||
Then, run the `cd ui && pnpm dev` to build and run the frontend, and you can pass startup parameters to the program using `ARGS="--port 5173" pnpm dev`.
|
||||
Then, run the `pnpm dev` to build and run the frontend, and you can pass startup parameters to the program using `ARGS="--port 5173" pnpm dev`.
|
||||
|
||||
The frontend program will run by default on port `5173`, and you can access it in a browser at `http://localhost:5173`. The frontend testing client will, by default, request the backend on port `23366`, so it's essential to keep the backend on this port.
|
||||
|
||||
@@ -51,9 +51,9 @@ The frontend program is divided into the main program and a sidebar program, wit
|
||||
|
||||
### Development Workflow
|
||||
|
||||
In most cases, to set up a complete development instance, you need to navigate to the Artalk Repo directory and then execute `make dev`. This will run the backend on port `23366`. Then, execute `cd ui && pnpm dev`, which will run the frontend on port `5173`. You can optionally execute `pnpm dev:sidebar` to run the sidebar frontend on port `23367`. For frontend development, you need to access `http://localhost:5173` in your browser to perform your development and testing.
|
||||
In most cases, to set up a complete development instance, you need to navigate to the Artalk Repo directory and then execute `make dev`. This will run the backend on port `23366`. Then, execute `pnpm dev`, which will run the frontend on port `5173`. You can optionally execute `pnpm dev:sidebar` to run the sidebar frontend on port `23367`. For frontend development, you need to access `http://localhost:5173` in your browser to perform your development and testing.
|
||||
|
||||
When you make changes to the frontend code, you can build the complete frontend program using `cd ui && pnpm build:all`. The JavaScript and CSS code can be found in `ui/packages/artalk/dist`.
|
||||
When you make changes to the frontend code, you can build the complete frontend program using `pnpm build:all`. The JavaScript and CSS code can be found in `ui/artalk/dist`.
|
||||
|
||||
When you make changes to the backend code, running `make all` will build the complete backend program. Note that since the backend program also embeds the frontend code, the `scripts/build-frontend.sh` script will run during backend program building, which includes the embedded frontend main program and sidebar frontend program. If you are interested, you can explore the complete frontend build process in the `Makefile` code.
|
||||
|
||||
|
||||
+24
-7
@@ -1,12 +1,11 @@
|
||||
### build Artalk
|
||||
FROM golang:1.21.3-alpine3.18 as builder
|
||||
FROM golang:1.21.5-alpine3.19 as builder
|
||||
|
||||
WORKDIR /source
|
||||
|
||||
# install tools
|
||||
RUN set -ex \
|
||||
&& apk add --no-cache make git gcc musl-dev nodejs bash npm\
|
||||
&& npm install -g pnpm@8.12.1
|
||||
&& apk add --no-cache make git gcc musl-dev bash
|
||||
|
||||
# download go deps
|
||||
# (cache by separating the downloading of deps)
|
||||
@@ -16,14 +15,32 @@ RUN go mod download
|
||||
# copy source code
|
||||
COPY . .
|
||||
|
||||
# build
|
||||
## build UI
|
||||
ARG SKIP_UI_BUILD=false
|
||||
|
||||
# install ui build toolchain
|
||||
RUN set -ex \
|
||||
&& export VERSION=$(git describe --tags --abbrev=0) \
|
||||
&& export COMMIT_SHA=$(git rev-parse --short HEAD) \
|
||||
&& if [ "$SKIP_UI_BUILD" = "false" ]; then \
|
||||
apk add --no-cache nodejs npm \
|
||||
&& npm install -g pnpm@8.12.1 \
|
||||
;fi
|
||||
|
||||
RUN set -ex \
|
||||
&& if [ "$SKIP_UI_BUILD" = "false" ]; then \
|
||||
make build-frontend \
|
||||
;fi
|
||||
|
||||
## build App
|
||||
ARG APP_VERSION=""
|
||||
ARG APP_COMMIT_HASH=""
|
||||
|
||||
RUN set -ex \
|
||||
&& if [[ ! -z "$APP_VERSION" ]]; then export VERSION=$APP_VERSION ;fi \
|
||||
&& if [[ ! -z "$APP_COMMIT_HASH" ]]; then export COMMIT_HASH=$APP_COMMIT_HASH ;fi \
|
||||
&& make build
|
||||
|
||||
### build final image
|
||||
FROM alpine:3.18
|
||||
FROM alpine:3.19
|
||||
|
||||
# we set the timezone `Asia/Shanghai` by default, you can be modified
|
||||
# by `docker build --build-arg="TZ=Other_Timezone ..."`
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
PKG_NAME := github.com/ArtalkJS/Artalk
|
||||
BIN_NAME := ./bin/artalk
|
||||
VERSION ?= $(shell git describe --tags --abbrev=0)
|
||||
COMMIT_HASH := $(shell git rev-parse --short HEAD)
|
||||
DEV_VERSION := dev-$(COMMIT_HASH)
|
||||
COMMIT_HASH ?= $(shell git rev-parse --short HEAD)
|
||||
|
||||
HAS_RICHGO := $(shell which richgo)
|
||||
GOTEST ?= $(if $(HAS_RICHGO), richgo test, go test)
|
||||
@@ -13,7 +12,7 @@ all: install build
|
||||
install:
|
||||
go mod tidy
|
||||
|
||||
build: build-frontend
|
||||
build:
|
||||
go build \
|
||||
-ldflags "-s -w -X $(PKG_NAME)/internal/config.Version=$(VERSION) \
|
||||
-X $(PKG_NAME)/internal/config.CommitHash=$(COMMIT_HASH)" \
|
||||
@@ -53,7 +52,8 @@ update-i18n:
|
||||
|
||||
update-swagger:
|
||||
go install github.com/swaggo/swag/cmd/swag@latest
|
||||
swag init -g server/server.go --output ./docs/swagger
|
||||
swag init -g server/server.go --output ./docs/swagger --requiredByDefault
|
||||
pnpm -r swagger:build-http-client
|
||||
|
||||
docker-build:
|
||||
./scripts/docker-build.sh
|
||||
|
||||
@@ -69,9 +69,10 @@ npm install artalk
|
||||
import Artalk from 'artalk'
|
||||
|
||||
Artalk.init({
|
||||
el: '#Comments',
|
||||
site: 'Artalk 的博客',
|
||||
server: 'https://artalk.example.com'
|
||||
el: '#Comments',
|
||||
site: 'Artalk 的博客',
|
||||
server: 'https://artalk.example.com',
|
||||
pageKey: '/2018/10/02/hello-world.html'
|
||||
})
|
||||
```
|
||||
|
||||
@@ -202,7 +203,7 @@ see [CONTRIBUTING.md](./CONTRIBUTING.md)
|
||||
- [x] 用户鉴权机制
|
||||
- [x] 跨域非法请求阻止
|
||||
- [x] 全局验证码操作次数限制
|
||||
- [x] JWT 登陆状态验证
|
||||
- [x] JWT 登录状态验证
|
||||
- [x] 时区自定义
|
||||
- [x] 只看作者功能
|
||||
- [x] 图片上传
|
||||
|
||||
+16
-3
@@ -25,14 +25,23 @@ func NewAdminCommand(app *ArtalkCmd) *cobra.Command {
|
||||
fmt.Println(" " + i18n.T("Create admin account"))
|
||||
fmt.Println("--------------------------------")
|
||||
|
||||
username, email, password, err := credentials()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
// get from flags
|
||||
username, _ := cmd.Flags().GetString("name")
|
||||
email, _ := cmd.Flags().GetString("email")
|
||||
password, _ := cmd.Flags().GetString("password")
|
||||
|
||||
if username == "" || email == "" || password == "" {
|
||||
var err error
|
||||
username, email, password, err = credentials()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
findUser := app.Dao().FindUser(username, email)
|
||||
if !findUser.IsEmpty() {
|
||||
findUser.SetPasswordEncrypt(password)
|
||||
findUser.IsAdmin = true
|
||||
if err := app.Dao().UpdateUser(&findUser); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
@@ -62,6 +71,10 @@ func NewAdminCommand(app *ArtalkCmd) *cobra.Command {
|
||||
},
|
||||
}
|
||||
|
||||
flag(adminCmd, "name", "", i18n.T("Username"))
|
||||
flag(adminCmd, "email", "", i18n.T("Email"))
|
||||
flag(adminCmd, "password", "", i18n.T("Password"))
|
||||
|
||||
return adminCmd
|
||||
}
|
||||
|
||||
|
||||
@@ -30,8 +30,6 @@ func NewImportCommand(app *ArtalkCmd) *cobra.Command {
|
||||
params := artransfer.ArrToImportParams(payload)
|
||||
params.Assumeyes, _ = cmd.Flags().GetBool("assumeyes")
|
||||
artransfer.RunImportArtrans(app.Dao(), params)
|
||||
|
||||
log.Info(i18n.T("Import complete"))
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@ db:
|
||||
password: ""
|
||||
charset: "utf8mb4"
|
||||
ssl: false
|
||||
prepare_stmt: true
|
||||
log:
|
||||
enabled: true
|
||||
filename: "./data/artalk.log"
|
||||
@@ -102,6 +103,7 @@ email:
|
||||
account_name: "noreply@example.com"
|
||||
admin_notify:
|
||||
notify_tpl: "default"
|
||||
notify_pending: false
|
||||
noise_mode: false
|
||||
email:
|
||||
enabled: true
|
||||
@@ -166,3 +168,4 @@ frontend:
|
||||
scrollable: false
|
||||
reqTimeout: 15000
|
||||
versionCheck: true
|
||||
pluginURLs: []
|
||||
@@ -47,6 +47,8 @@ db:
|
||||
charset: "utf8mb4"
|
||||
# Enable SSL mode
|
||||
ssl: false
|
||||
# Prepared Statement
|
||||
prepare_stmt: true
|
||||
|
||||
# Logging
|
||||
log:
|
||||
@@ -214,10 +216,12 @@ email:
|
||||
access_key_secret: ""
|
||||
account_name: "noreply@example.com"
|
||||
|
||||
# Multi-push
|
||||
# Multi-Push
|
||||
admin_notify:
|
||||
# Notification template (set to file path to use custom template)
|
||||
notify_tpl: "default"
|
||||
# Pending comment still send notification (notifications are still sent when comments are intercepted)
|
||||
notify_pending: false
|
||||
# Noise mode
|
||||
# -- noise_mode is disabled by default. --
|
||||
# -- When this option is set to `false`, only messages sent to the administrator will be notified, --
|
||||
@@ -325,3 +329,5 @@ frontend:
|
||||
reqTimeout: 15000
|
||||
# Version check
|
||||
versionCheck: true
|
||||
# Plugins
|
||||
pluginURLs: []
|
||||
@@ -19,7 +19,7 @@ timezone: "Asia/Shanghai"
|
||||
# 默认站点名
|
||||
site_default: "默认站点"
|
||||
|
||||
# 登陆有效时长 (单位:秒)
|
||||
# 登录有效时长 (单位:秒)
|
||||
login_timeout: 259200
|
||||
|
||||
# 数据库
|
||||
@@ -44,6 +44,8 @@ db:
|
||||
table_prefix: ""
|
||||
# 启用 SSL
|
||||
ssl: false
|
||||
# 预编译语句
|
||||
prepare_stmt: true
|
||||
|
||||
# 日志
|
||||
log:
|
||||
@@ -162,9 +164,9 @@ captcha:
|
||||
captcha_id: ""
|
||||
captcha_key: ""
|
||||
|
||||
# IP 归属地
|
||||
# IP 属地
|
||||
ip_region:
|
||||
# 启用 IP 归属地展示
|
||||
# 启用 IP 属地展示
|
||||
enabled: false
|
||||
# 数据文件路径 (.xdb 格式)
|
||||
db_path: "./data/ip2region.xdb"
|
||||
@@ -226,6 +228,8 @@ email:
|
||||
admin_notify:
|
||||
# 通知模版 (填入文件路径使用自定义模板)
|
||||
notify_tpl: "default"
|
||||
# 待审评论仍然发送通知 (当评论被拦截时仍然发送通知)
|
||||
notify_pending: false
|
||||
# 嘈杂模式
|
||||
noise_mode: false
|
||||
# 邮件通知管理员
|
||||
@@ -274,7 +278,7 @@ admin_notify:
|
||||
- "USER_ID_1"
|
||||
- "GROUP_ID_1"
|
||||
|
||||
# 前端配置
|
||||
# 界面配置
|
||||
frontend:
|
||||
# 评论框占位文字
|
||||
placeholder: ""
|
||||
@@ -332,3 +336,5 @@ frontend:
|
||||
reqTimeout: 15000
|
||||
# 版本检测
|
||||
versionCheck: true
|
||||
# 插件
|
||||
pluginURLs: []
|
||||
@@ -1,3 +0,0 @@
|
||||
/.vitepress/dist/
|
||||
/.vitepress/cache/
|
||||
/public/http-api.html
|
||||
@@ -1,2 +0,0 @@
|
||||
shamefully-hoist=true
|
||||
auto-install-peers=true
|
||||
@@ -1,211 +0,0 @@
|
||||
import { defineConfig } from 'vitepress'
|
||||
import iterator from 'markdown-it-for-inline'
|
||||
import * as Version from '../code/ArtalkVersion.json'
|
||||
|
||||
export default defineConfig({
|
||||
title: 'Artalk',
|
||||
description: '一款简洁的自托管评论系统',
|
||||
lang: 'zh-CN',
|
||||
|
||||
head: [
|
||||
['link', { rel: 'icon', href: '/favicon.png' }],
|
||||
['meta', { name: 'viewport', content: 'width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no, target-densitydpi=device-dpi' }],
|
||||
// artalk
|
||||
// ['link', { href: `https://npm.elemecdn.com/artalk@${Version.latest}/dist/Artalk.css`, rel: 'stylesheet' }],
|
||||
['link', { href: `https://artalk.qwqaq.com/dist/Artalk.css`, rel: 'stylesheet' }],
|
||||
// ['script', { src: ArtalkCDN.JS }],
|
||||
// light gallery
|
||||
['link', { href: 'https://npm.elemecdn.com/lightgallery@2.3.0/css/lightgallery.css', rel: 'stylesheet' }],
|
||||
['script', { src: 'https://npm.elemecdn.com/lightgallery@2.3.0/lightgallery.min.js' }],
|
||||
// katex
|
||||
// ['link', { href: "https://npm.elemecdn.com/katex@0.15.3/dist/katex.min.css", rel: 'stylesheet' }],
|
||||
// ['script', { src: 'https://npm.elemecdn.com/katex@0.15.3/dist/katex.min.js' }],
|
||||
// ['script', { src: 'https://npm.elemecdn.com/@artalkjs/plugin-katex/dist/artalk-plugin-katex.js' }],
|
||||
],
|
||||
|
||||
lastUpdated: true,
|
||||
|
||||
markdown: {
|
||||
// @link https://github.com/shikijs/shiki
|
||||
theme: {
|
||||
light: 'github-light',
|
||||
dark: 'github-dark',
|
||||
},
|
||||
config: (md) => {
|
||||
md.use(iterator, 'artalk_version', 'text', function (tokens, idx) {
|
||||
tokens[idx].content = tokens[idx].content.replace(/:ArtalkVersion:/g, Version.latest)
|
||||
});
|
||||
md.use(iterator, 'artalk_version_link', 'link_open', (tokens, idx) => {
|
||||
const href = tokens[idx].attrGet('href')
|
||||
tokens[idx].attrSet('href', href.replace(/:ArtalkVersion:/g, Version.latest))
|
||||
});
|
||||
},
|
||||
},
|
||||
|
||||
locales: {
|
||||
root: {
|
||||
label: '简体中文',
|
||||
lang: 'zh'
|
||||
},
|
||||
en: {
|
||||
label: 'English',
|
||||
lang: 'en',
|
||||
link: 'https://artalk-js-org.translate.goog/guide/intro?_x_tr_sl=auto&_x_tr_tl=en-US&_x_tr_hl=en-US&_x_tr_pto=wapp'
|
||||
// link: '/en/'
|
||||
}
|
||||
},
|
||||
|
||||
themeConfig: {
|
||||
sidebar: {
|
||||
"/guide/": [
|
||||
{
|
||||
text: "快速开始",
|
||||
collapsed: false,
|
||||
items: [
|
||||
{ text: '项目介绍', link: '/guide/intro.md' },
|
||||
{ text: '程序部署', link: '/guide/deploy.md' },
|
||||
{ text: '数据迁移', link: '/guide/transfer.md' },
|
||||
]
|
||||
},
|
||||
{
|
||||
text: "核心指南",
|
||||
collapsed: false,
|
||||
items: [
|
||||
{ text: '侧边栏', link: '/guide/frontend/sidebar.md' },
|
||||
{ text: '邮件通知', link: '/guide/backend/email.md' },
|
||||
{ text: '多元推送', link: '/guide/backend/admin_notify.md' },
|
||||
{ text: '评论审核', link: '/guide/backend/moderator.md' },
|
||||
{ text: '验证码', link: '/guide/backend/captcha.md' },
|
||||
{ text: '图片上传', link: '/guide/backend/img-upload.md' },
|
||||
{ text: '账户与多站点', link: '/guide/backend/multi-site.md' },
|
||||
{ text: '解析相对路径', link: '/guide/backend/relative-path.md' },
|
||||
{ text: '如何配置界面', link: '/guide/backend/fe-control.md' },
|
||||
{ text: 'English (i18n)', link: '/guide/frontend/i18n.md' },
|
||||
]
|
||||
},
|
||||
{
|
||||
text: "进阶指南",
|
||||
collapsed: false,
|
||||
items: [
|
||||
{ text: '表情包', link: '/guide/frontend/emoticons.md' },
|
||||
{ text: '浏览量统计', link: '/guide/frontend/pv.md' },
|
||||
{ text: 'Latex', link: '/guide/frontend/latex.md' },
|
||||
{ text: '图片灯箱', link: '/guide/frontend/lightbox.md' },
|
||||
{ text: 'IP 归属地', link: '/guide/frontend/ip-region.md' },
|
||||
{ text: '精简版本', link: '/guide/frontend/artalk-lite.md' },
|
||||
{ text: '置入博客', link: '/guide/frontend/import-blog.md' },
|
||||
{ text: '置入框架', link: '/guide/frontend/import-framework.md' },
|
||||
{ text: '前端 API', link: '/develop/fe-api.md', },
|
||||
{ text: '开发文档', link: '/develop/index.md', },
|
||||
],
|
||||
},
|
||||
{
|
||||
text: "配置文档",
|
||||
collapsed: true,
|
||||
items: [
|
||||
{ text: '后端配置', link: '/guide/backend/config.md' },
|
||||
{ text: '前端配置', link: '/guide/frontend/config.md' },
|
||||
]
|
||||
},
|
||||
{
|
||||
text: "部署说明",
|
||||
collapsed: true,
|
||||
items: [
|
||||
{ text: '守护进程', link: '/guide/backend/daemon.md' },
|
||||
{ text: '反向代理', link: '/guide/backend/reverse-proxy.md' },
|
||||
{ text: '编译构建', link: '/guide/backend/build.md' },
|
||||
{ text: '程序升级', link: '/guide/backend/update.md' },
|
||||
{ text: 'Docker', link: '/guide/backend/docker.md' },
|
||||
]
|
||||
},
|
||||
{
|
||||
text: '更多内容',
|
||||
collapsed: true,
|
||||
items: [
|
||||
{ text: '安全防范', link: '/guide/security.md' },
|
||||
{ text: '扩展阅读', link: '/guide/extras.md' },
|
||||
{ text: '案例展示', link: '/guide/cases.md' },
|
||||
{ text: '关于我们', link: '/guide/about.md' },
|
||||
]
|
||||
}
|
||||
],
|
||||
"/develop/": [
|
||||
{
|
||||
text: '开发文档',
|
||||
items: [
|
||||
{ text: '开发说明', link: '/develop/index.md', },
|
||||
{ text: '前端 API', link: '/develop/fe-api.md', },
|
||||
{ text: '前端 Event', link: '/develop/event.md', },
|
||||
{ text: '插件开发', link: '/develop/plugs.md' },
|
||||
{ text: '🔬 HTTP API', link: 'https://artalk.js.org/http-api.html', },
|
||||
{ text: '📖 Contributing Guide', link: 'https://github.com/ArtalkJS/Artalk/blob/master/CONTRIBUTING.md' },
|
||||
{ text: '🔖 Code of Conduct', link: 'https://github.com/ArtalkJS/Artalk/blob/master/CODE_OF_CONDUCT.md' },
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
nav: [
|
||||
// NavbarItem
|
||||
{
|
||||
text: '介绍',
|
||||
link: '/guide/intro',
|
||||
},
|
||||
{
|
||||
text: '部署',
|
||||
link: '/guide/deploy',
|
||||
},
|
||||
{
|
||||
text: '配置',
|
||||
link: '/guide/backend/config',
|
||||
},
|
||||
{
|
||||
text: '迁移',
|
||||
link: '/guide/transfer',
|
||||
},
|
||||
{
|
||||
text: '案例',
|
||||
link: '/guide/cases',
|
||||
},
|
||||
{
|
||||
text: '开发',
|
||||
link: '/develop/',
|
||||
},
|
||||
// NavbarGroup
|
||||
{
|
||||
text: '传送',
|
||||
items: [
|
||||
{
|
||||
text: '代码仓库',
|
||||
link: 'https://github.com/ArtalkJS/Artalk',
|
||||
},
|
||||
{
|
||||
text: '文档镜像 (国内)',
|
||||
link: 'https://artalk-docs.qwqaq.com'
|
||||
}
|
||||
],
|
||||
},
|
||||
],
|
||||
|
||||
socialLinks: [
|
||||
{ icon: 'github', link: 'https://github.com/ArtalkJS/Artalk' }
|
||||
],
|
||||
|
||||
search: {
|
||||
provider: 'algolia',
|
||||
options: {
|
||||
appId: '2WNJ32WVTY',
|
||||
apiKey: '6c6ebc345a87b738264f19095b78c91c',
|
||||
indexName: 'artalk-js',
|
||||
searchParameters: {
|
||||
facetFilters: ['lang:zh-CN']
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
editLink: {
|
||||
pattern: 'https://github.com/ArtalkJS/Artalk/edit/master/docs/:path',
|
||||
text: '完善文档'
|
||||
},
|
||||
}
|
||||
})
|
||||
@@ -1,3 +0,0 @@
|
||||
{
|
||||
"latest": "2.7.1"
|
||||
}
|
||||
@@ -1,64 +0,0 @@
|
||||
# 插件开发
|
||||
|
||||
使用 `Artalk.use` 来扩展 Artalk。
|
||||
|
||||
```js
|
||||
import Artalk from 'artalk'
|
||||
|
||||
Artalk.use((ctx) => {
|
||||
ctx.on('inited', () => {
|
||||
ctx.get('editor').setContent("Hello World")
|
||||
})
|
||||
|
||||
ctx.on('list-loaded', () => {
|
||||
console.log('评论列表加载完毕')
|
||||
})
|
||||
})
|
||||
|
||||
const artalk = Artalk.init({ ... })
|
||||
```
|
||||
|
||||
请注意:
|
||||
|
||||
- `Artalk.use` 必须在 `Artalk.init` 之前调用。
|
||||
- 请勿依赖插件的加载顺序,请监听事件来执行插件逻辑。
|
||||
- 当所有的插件加载完毕后,会触发 `inited` 事件。
|
||||
|
||||
在 use 函数中,你可以通过 `ctx` 来访问 Artalk 的上下文。
|
||||
|
||||
## Context
|
||||
|
||||
Context 对象包含了 Artalk 的上下文信息。
|
||||
|
||||
| 成员 | 说明 |
|
||||
| --- | --- |
|
||||
| `ctx.$root` | Artalk 容器元素 |
|
||||
| `ctx.conf` | Artalk 配置 |
|
||||
| `ctx.fetch` | 加载数据数据 |
|
||||
| `ctx.reload` | 重载评论列表 |
|
||||
| `ctx.on` | 添加事件监听 |
|
||||
| `ctx.off` | 解除事件监听 |
|
||||
| `ctx.trigger` | 触发事件 |
|
||||
| `ctx.inject` | 依赖注入 |
|
||||
| `ctx.get` | 获取依赖 |
|
||||
|
||||
::: warning
|
||||
Context API 目前仍不稳定,开发可能会有变动,升级请关注 CHANGELOG。
|
||||
:::
|
||||
|
||||
参考:[@artalk/types/context.ts](https://github.com/ArtalkJS/Artalk/blob/master/ui/packages/artalk/types/context.ts)
|
||||
|
||||
Artalk 拥有完整的 TypeScript 类型定义,你可以通过编辑器的自动补全来查看 API。
|
||||
|
||||
## 示例插件
|
||||
|
||||
Artalk 有很多内置的插件,你可以参考它们的源码来开发自己的插件。
|
||||
|
||||
[@ArtalkJS/Artalk - src/plugins](https://github.com/ArtalkJS/Artalk/tree/master/ui/packages/artalk/src/plugins)
|
||||
|
||||
我们还提供了一些外置的插件,同样可以参考:
|
||||
|
||||
| 插件 | 说明 |
|
||||
| --- | --- |
|
||||
| [@artalk/plugin-katex](https://github.com/ArtalkJS/Artalk/tree/master/ui/packages/plugin-katex) | LaTeX 公式插件 |
|
||||
| [@artalk/plugin-lightbox](https://github.com/ArtalkJS/Artalk/tree/master/ui/packages/plugin-lightbox) | 图片灯箱插件 |
|
||||
@@ -0,0 +1,2 @@
|
||||
.vitepress/dist/**
|
||||
.vitepress/cache/**
|
||||
@@ -0,0 +1,253 @@
|
||||
import { defineConfig } from "vitepress";
|
||||
import iterator from "markdown-it-for-inline";
|
||||
import * as Version from "../code/ArtalkVersion.json";
|
||||
|
||||
export default defineConfig({
|
||||
title: "Artalk",
|
||||
description: "一款简洁的自托管评论系统",
|
||||
lang: "zh-CN",
|
||||
|
||||
head: [
|
||||
["link", { rel: "icon", href: "/favicon.png" }],
|
||||
[
|
||||
"meta",
|
||||
{
|
||||
name: "viewport",
|
||||
content:
|
||||
"width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no, target-densitydpi=device-dpi",
|
||||
},
|
||||
],
|
||||
// artalk
|
||||
// ['link', { href: `https://npm.elemecdn.com/artalk@${Version.latest}/dist/Artalk.css`, rel: 'stylesheet' }],
|
||||
// [
|
||||
// "link",
|
||||
// { href: `https://artalk.qwqaq.com/dist/Artalk.css`, rel: "stylesheet" },
|
||||
// ],
|
||||
// ['script', { src: ArtalkCDN.JS }],
|
||||
// light gallery
|
||||
[
|
||||
"link",
|
||||
{
|
||||
href: "https://cdnjs.cloudflare.com/ajax/libs/lightgallery/2.3.0/css/lightgallery.css",
|
||||
rel: "stylesheet",
|
||||
},
|
||||
],
|
||||
[
|
||||
"script",
|
||||
{
|
||||
src: "https://cdnjs.cloudflare.com/ajax/libs/lightgallery/2.3.0/lightgallery.min.js",
|
||||
},
|
||||
],
|
||||
// katex
|
||||
['link', { href: "https://unpkg.com/katex@0.15.3/dist/katex.min.css", rel: 'stylesheet' }],
|
||||
['script', { src: 'https://unpkg.com/katex@0.15.3/dist/katex.min.js' }],
|
||||
// ['script', { src: 'https://unpkg.com/@artalk/plugin-katex/dist/artalk-plugin-katex.js' }],
|
||||
],
|
||||
|
||||
lastUpdated: true,
|
||||
|
||||
markdown: {
|
||||
// @link https://github.com/shikijs/shiki
|
||||
theme: {
|
||||
light: "github-light",
|
||||
dark: "github-dark",
|
||||
},
|
||||
config: (md) => {
|
||||
md.use(iterator, "artalk_version", "text", function (tokens, idx) {
|
||||
tokens[idx].content = tokens[idx].content.replace(
|
||||
/:ArtalkVersion:/g,
|
||||
Version.latest
|
||||
);
|
||||
});
|
||||
md.use(iterator, "artalk_version_link", "link_open", (tokens, idx) => {
|
||||
const href = tokens[idx].attrGet("href");
|
||||
tokens[idx].attrSet(
|
||||
"href",
|
||||
href.replace(/:ArtalkVersion:/g, Version.latest)
|
||||
);
|
||||
});
|
||||
},
|
||||
},
|
||||
|
||||
locales: {
|
||||
root: {
|
||||
label: "简体中文",
|
||||
lang: "zh",
|
||||
link: "https://artalk.js.org/",
|
||||
},
|
||||
en: {
|
||||
label: "English",
|
||||
lang: "en",
|
||||
link: "https://artalk-js-org.translate.goog/guide/intro?_x_tr_sl=auto&_x_tr_tl=en-US&_x_tr_hl=en-US&_x_tr_pto=wapp",
|
||||
},
|
||||
},
|
||||
|
||||
themeConfig: {
|
||||
sidebar: {
|
||||
"/guide/": [
|
||||
{
|
||||
text: "快速开始",
|
||||
collapsed: false,
|
||||
items: [
|
||||
{ text: "项目介绍", link: "/guide/intro.md" },
|
||||
{ text: "程序部署", link: "/guide/deploy.md" },
|
||||
{ text: "数据迁移", link: "/guide/transfer.md" },
|
||||
],
|
||||
},
|
||||
{
|
||||
text: "核心指南",
|
||||
collapsed: false,
|
||||
items: [
|
||||
{ text: "侧边栏", link: "/guide/frontend/sidebar.md" },
|
||||
{ text: "邮件通知", link: "/guide/backend/email.md" },
|
||||
{ text: "多元推送", link: "/guide/backend/admin_notify.md" },
|
||||
{ text: "评论审核", link: "/guide/backend/moderator.md" },
|
||||
{ text: "验证码", link: "/guide/backend/captcha.md" },
|
||||
{ text: "图片上传", link: "/guide/backend/img-upload.md" },
|
||||
{ text: "账户与多站点", link: "/guide/backend/multi-site.md" },
|
||||
{ text: "解析相对路径", link: "/guide/backend/relative-path.md" },
|
||||
{ text: "如何配置界面", link: "/guide/backend/fe-control.md" },
|
||||
{ text: "English (i18n)", link: "/guide/frontend/i18n.md" },
|
||||
],
|
||||
},
|
||||
{
|
||||
text: "进阶指南",
|
||||
collapsed: false,
|
||||
items: [
|
||||
{ text: "表情包", link: "/guide/frontend/emoticons.md" },
|
||||
{ text: "浏览量统计", link: "/guide/frontend/pv.md" },
|
||||
{ text: "Latex", link: "/guide/frontend/latex.md" },
|
||||
{ text: "图片灯箱", link: "/guide/frontend/lightbox.md" },
|
||||
{ text: "IP 属地", link: "/guide/frontend/ip-region.md" },
|
||||
{ text: "精简版本", link: "/guide/frontend/artalk-lite.md" },
|
||||
{ text: "置入博客", link: "/guide/frontend/import-blog.md" },
|
||||
{ text: "置入框架", link: "/guide/frontend/import-framework.md" },
|
||||
{ text: "前端 API", link: "/develop/fe-api.md" },
|
||||
{ text: "开发文档", link: "/develop/index.md" },
|
||||
],
|
||||
},
|
||||
{
|
||||
text: "配置文档",
|
||||
collapsed: true,
|
||||
items: [
|
||||
{ text: "后端配置", link: "/guide/backend/config.md" },
|
||||
{ text: "前端配置", link: "/guide/frontend/config.md" },
|
||||
],
|
||||
},
|
||||
{
|
||||
text: "部署说明",
|
||||
collapsed: true,
|
||||
items: [
|
||||
{ text: "守护进程", link: "/guide/backend/daemon.md" },
|
||||
{ text: "反向代理", link: "/guide/backend/reverse-proxy.md" },
|
||||
{ text: "编译构建", link: "/guide/backend/build.md" },
|
||||
{ text: "程序升级", link: "/guide/backend/update.md" },
|
||||
{ text: "Docker", link: "/guide/backend/docker.md" },
|
||||
],
|
||||
},
|
||||
{
|
||||
text: "更多内容",
|
||||
collapsed: true,
|
||||
items: [
|
||||
{ text: "安全防范", link: "/guide/security.md" },
|
||||
{ text: "扩展阅读", link: "/guide/extras.md" },
|
||||
{ text: "案例展示", link: "/guide/cases.md" },
|
||||
{ text: "关于我们", link: "/guide/about.md" },
|
||||
],
|
||||
},
|
||||
],
|
||||
"/develop/": [
|
||||
{
|
||||
text: "开发文档",
|
||||
items: [
|
||||
{ text: "开发说明", link: "/develop/index.md" },
|
||||
{ text: "前端 API", link: "/develop/fe-api.md" },
|
||||
{ text: "前端 Event", link: "/develop/event.md" },
|
||||
{ text: "插件开发", link: "/develop/plugs.md" },
|
||||
{
|
||||
text: "🔬 HTTP API",
|
||||
link: "https://artalk.js.org/http-api.html",
|
||||
},
|
||||
{
|
||||
text: "📖 Contributing Guide",
|
||||
link: "https://github.com/ArtalkJS/Artalk/blob/master/CONTRIBUTING.md",
|
||||
},
|
||||
{
|
||||
text: "🔖 Code of Conduct",
|
||||
link: "https://github.com/ArtalkJS/Artalk/blob/master/CODE_OF_CONDUCT.md",
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
nav: [
|
||||
// NavbarItem
|
||||
{
|
||||
text: "介绍",
|
||||
link: "/guide/intro",
|
||||
},
|
||||
{
|
||||
text: "部署",
|
||||
link: "/guide/deploy",
|
||||
},
|
||||
{
|
||||
text: "配置",
|
||||
link: "/guide/backend/config",
|
||||
},
|
||||
{
|
||||
text: "迁移",
|
||||
link: "/guide/transfer",
|
||||
},
|
||||
{
|
||||
text: "案例",
|
||||
link: "/guide/cases",
|
||||
},
|
||||
{
|
||||
text: "开发",
|
||||
link: "/develop/",
|
||||
},
|
||||
// NavbarGroup
|
||||
{
|
||||
text: "传送",
|
||||
items: [
|
||||
{
|
||||
text: "代码仓库",
|
||||
link: "https://github.com/ArtalkJS/Artalk",
|
||||
},
|
||||
// {
|
||||
// text: "文档镜像 (国内)",
|
||||
// link: "https://artalk-docs.qwqaq.com",
|
||||
// },
|
||||
],
|
||||
},
|
||||
],
|
||||
|
||||
socialLinks: [
|
||||
{ icon: "github", link: "https://github.com/ArtalkJS/Artalk" },
|
||||
],
|
||||
|
||||
search: {
|
||||
provider: "algolia",
|
||||
options: {
|
||||
appId: "2WNJ32WVTY",
|
||||
apiKey: "6c6ebc345a87b738264f19095b78c91c",
|
||||
indexName: "artalk-js",
|
||||
searchParameters: {
|
||||
facetFilters: ["lang:zh-CN"],
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
editLink: {
|
||||
pattern: "https://github.com/ArtalkJS/Artalk/edit/master/docs/:path",
|
||||
text: "完善文档",
|
||||
},
|
||||
},
|
||||
|
||||
vite: {
|
||||
server: {
|
||||
open: "/guide/intro.html",
|
||||
},
|
||||
},
|
||||
});
|
||||
@@ -1,13 +1,12 @@
|
||||
<template>
|
||||
<ClientOnly>
|
||||
<div ref="el" style="margin-top: 20px;"></div>
|
||||
</ClientOnly>
|
||||
<div ref="el" style="margin-top: 20px;"></div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { watch, nextTick, ref, onMounted, onUnmounted } from 'vue'
|
||||
import { useData, useRouter } from 'vitepress'
|
||||
import type Artalk from 'artalk'
|
||||
import Artalk from 'artalk'
|
||||
import 'artalk/dist/Artalk.css'
|
||||
|
||||
const el = ref<HTMLElement | null>(null)
|
||||
|
||||
@@ -17,10 +16,12 @@ const page = useData().page
|
||||
let artalk: Artalk
|
||||
|
||||
onMounted(() => {
|
||||
initArtalk(getConfByPage())
|
||||
nextTick(() => {
|
||||
initArtalk(getConfByPage())
|
||||
})
|
||||
})
|
||||
|
||||
watch(() => router.route.data.relativePath, () => {
|
||||
watch(() => router.route.path, () => {
|
||||
nextTick(() => {
|
||||
artalk.update(getConfByPage())
|
||||
artalk.reload()
|
||||
@@ -32,23 +33,21 @@ onUnmounted(() => {
|
||||
})
|
||||
|
||||
function initArtalk(conf: any) {
|
||||
import('artalk').then(({ default: Artalk }) => {
|
||||
artalk = Artalk.init({
|
||||
el: el.value,
|
||||
emoticons: '/assets/emoticons/default.json',
|
||||
gravatar: {
|
||||
mirror: 'https://cravatar.cn/avatar/'
|
||||
},
|
||||
...conf
|
||||
})
|
||||
}).then(() => {
|
||||
loadExtraFuncs()
|
||||
artalk = Artalk.init({
|
||||
el: el.value,
|
||||
emoticons: '/assets/emoticons/default.json',
|
||||
gravatar: {
|
||||
mirror: 'https://cravatar.cn/avatar/'
|
||||
},
|
||||
...conf
|
||||
})
|
||||
|
||||
loadExtraFuncs()
|
||||
}
|
||||
|
||||
function getConfByPage() {
|
||||
return {
|
||||
pageKey: 'https://artalk.js.org'+location.pathname,
|
||||
pageKey: 'https://artalk.js.org'+router.route.path,
|
||||
pageTitle: page.value.title,
|
||||
server: 'https://artalk.qwqaq.com',
|
||||
site: 'ArtalkDocs',
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -1,19 +1,20 @@
|
||||
## Artalk Documentation
|
||||
# Artalk Documentation
|
||||
|
||||
> The Documentation of Artalk
|
||||
[](https://app.netlify.com/sites/artalk/deploys)
|
||||
|
||||
Documentation of Artalk
|
||||
|
||||
## Build
|
||||
|
||||
```bash
|
||||
pnpm docs:dev
|
||||
pnpm docs:build
|
||||
pnpm dev:docs
|
||||
pnpm build:docs
|
||||
```
|
||||
|
||||
## Deploy
|
||||
|
||||
[](https://app.netlify.com/sites/artalk/deploys)
|
||||
|
||||
文档通过 [Netlify](https://www.netlify.com/) 对 master 分支进行自动部署。
|
||||
|
||||
## Licensed
|
||||
|
||||
CC BY-NC-SA 4.0
|
||||
File renamed without changes.
File renamed without changes.
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"latest": "2.8.3"
|
||||
}
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -4,33 +4,32 @@
|
||||
|
||||
|事件名|描述|
|
||||
|-|-|
|
||||
| `inited` | 初始化后 |
|
||||
| `destroy` | 实例销毁时 |
|
||||
| `created` | 初始化后 |
|
||||
| `mounted` | 数据加载后 |
|
||||
| `updated` | 数据更新后 |
|
||||
| `unmounted` | 销毁后 |
|
||||
| `list-fetch` | 评论列表请求时 |
|
||||
| `list-fetched` | 评论列表请求后 |
|
||||
| `list-load` | 评论装载前 |
|
||||
| `list-loaded` | 评论装载后 |
|
||||
| `list-error` | 评论加载错误时 |
|
||||
| `list-failed` | 评论加载错误时 |
|
||||
| `list-goto-first` | 评论列表归位时 |
|
||||
| `list-reach-bottom` | 评论列表滚动到底部时 |
|
||||
| `list-reach-bottom` | 评论列表滚动到底部时 |
|
||||
| `comment-inserted` | 评论插入后 |
|
||||
| `comment-updated` | 评论更新后 |
|
||||
| `comment-deleted` | 评论删除后 |
|
||||
| `comment-rendered` | 评论节点渲染后 |
|
||||
| `unreads-updated` | 未读消息变更时 |
|
||||
| `notifies-updated` | 未读消息变更时 |
|
||||
| `list-goto` | 评论跳转时 |
|
||||
| `page-loaded` | 页面数据更新后 |
|
||||
| `editor-submit` | 编辑器提交时 |
|
||||
| `editor-submitted` | 编辑器提交后 |
|
||||
| `user-changed` | 本地用户数据变更时 |
|
||||
| `conf-loaded` | 配置变更时 |
|
||||
| `dark-mode-changed` | 深色模式变更时 |
|
||||
| `sidebar-show` | 侧边栏显示 |
|
||||
| `sidebar-hide` | 侧边栏隐藏 |
|
||||
|
||||
|
||||
事件声明代码:[@ArtalkJS/Artalk - types/event.ts](https://github.com/ArtalkJS/Artalk/blob/master/ui/packages/artalk/types/event.ts)
|
||||
|
||||
事件声明代码:[@ArtalkJS/Artalk - src/types/event.ts](https://github.com/ArtalkJS/Artalk/blob/master/ui/artalk/src/types/event.ts)
|
||||
|
||||
## 添加事件监听
|
||||
|
||||
@@ -26,14 +26,16 @@ const artalk = Artalk.init({
|
||||
})
|
||||
```
|
||||
|
||||
调用该函数会向后端发起请求:
|
||||
调用该函数会异步地向后端发起请求:
|
||||
|
||||
1. 获取前端配置
|
||||
2. 获取评论列表
|
||||
|
||||
配置和评论加载完毕后会分别触发 `conf-loaded` 和 `list-loaded` 事件。
|
||||
配置和插件加载完毕后会触发 `mounted` 事件。
|
||||
|
||||
注:前端配置可能会被覆盖,详情见:[在后端控制前端](../guide/backend/fe-control.md)。
|
||||
评论列表加载完毕后会触发 `list-loaded` 事件。
|
||||
|
||||
注:前端界面配置可能会被覆盖,详情见:[在后端控制前端](../guide/backend/fe-control.md)。
|
||||
|
||||
## 释放资源 `destroy`
|
||||
|
||||
@@ -45,7 +47,7 @@ const artalk = Artalk.init({ ... })
|
||||
artalk.destroy()
|
||||
```
|
||||
|
||||
释放资源将执行 Artalk 挂载的 DOM 节点删除,以及解除 Artalk 事件监听等操作。
|
||||
调用该函数时,将触发 `unmounted` 事件。释放资源将执行 Artalk 挂载的 DOM 节点删除,以及解除 Artalk 事件监听等操作。当该函数执行完毕后,Artalk 实例将不再可用。
|
||||
|
||||
在 Vue / React 等框架中,务必在组件销毁时调用该函数,否则会造成内存泄漏:
|
||||
|
||||
@@ -69,11 +71,11 @@ artalk.update({
|
||||
})
|
||||
```
|
||||
|
||||
调用该函数将触发 `conf-loaded` 事件。
|
||||
调用该函数将触发 `updated` 事件。
|
||||
|
||||
更新配置不会自动刷新评论列表,可按需继续执行 `artalk.reload()` 函数。
|
||||
|
||||
请注意,该函数是一个实例化对象中的方法,并非全局函数。
|
||||
请注意,该函数是一个实例化对象中的成员方法,并非全局函数。
|
||||
|
||||
前端配置参考:[前端配置](../guide/frontend/config.md)
|
||||
|
||||
@@ -96,8 +98,9 @@ artalk.reload()
|
||||
```js
|
||||
const artalk = Artalk.init({ ... })
|
||||
|
||||
artalk.on('list-loaded', () => {
|
||||
alert('评论列表加载完毕')
|
||||
artalk.on('list-loaded', (comments) => {
|
||||
// comments 包含当前页面所有评论数据 (而非仅本次请求获取的部分评论)
|
||||
console.log('评论列表加载完毕: ', comments)
|
||||
})
|
||||
```
|
||||
|
||||
@@ -125,7 +128,7 @@ artalk.off('list-loaded', handler)
|
||||
```js
|
||||
const artalk = Artalk.init({ ... })
|
||||
|
||||
artalk.trigger('list-loaded')
|
||||
artalk.trigger('list-loaded', [...])
|
||||
```
|
||||
|
||||
## 加载插件 `use`
|
||||
@@ -154,6 +157,35 @@ const artalk = Artalk.init({ ... })
|
||||
artalk.setDarkMode(true)
|
||||
```
|
||||
|
||||
也可以通过调用 `Artalk.init` 时,通过 `darkMode` 参数设置初始夜间模式。
|
||||
|
||||
```js
|
||||
const artalk = Artalk.init({
|
||||
// ...其他配置
|
||||
darkMode: 'auto',
|
||||
})
|
||||
```
|
||||
|
||||
## 浏览量组件 `loadCountWidget`
|
||||
|
||||
详情见:[浏览量统计](../guide/frontend/pv.md)
|
||||
|
||||
## 获取配置 `getConf`
|
||||
|
||||
获取当前 Artalk 配置。
|
||||
|
||||
```js
|
||||
const artalk = Artalk.init({ ... })
|
||||
|
||||
const conf = artalk.getConf()
|
||||
```
|
||||
|
||||
## 获取挂载元素 `getEl`
|
||||
|
||||
获取当前 Artalk 挂载的 DOM 元素。
|
||||
|
||||
```js
|
||||
const artalk = Artalk.init({ ... })
|
||||
|
||||
const el = artalk.getEl()
|
||||
```
|
||||
@@ -19,10 +19,10 @@
|
||||
由于 Artalk 正处于开发阶段,使用此文档中 `API`、`Event` 前请务必检查时效性。
|
||||
|
||||
- `API` 部分参考源码
|
||||
* [@ArtalkJS/Artalk - src/api/](https://github.com/ArtalkJS/Artalk/tree/master/ui/packages/artalk/src/api)
|
||||
* [@ArtalkJS/Artalk - src/api/](https://github.com/ArtalkJS/Artalk/tree/master/ui/artalk/src/api)
|
||||
* [@ArtalkJS/Artalk - server/server.go](https://github.com/ArtalkJS/Artalk/blob/master/server/server.go)
|
||||
- `UI` 及 `Event` 部分参考源码
|
||||
* [@ArtalkJS/Artalk - src/artalk.ts](https://github.com/ArtalkJS/Artalk/blob/master/ui/packages/artalk/src/artalk.ts)
|
||||
* [@ArtalkJS/Artalk - types/event.ts](https://github.com/ArtalkJS/Artalk/blob/master/ui/packages/artalk/types/event.ts)
|
||||
* [@ArtalkJS/Artalk - src/artalk.ts](https://github.com/ArtalkJS/Artalk/blob/master/ui/artalk/src/artalk.ts)
|
||||
* [@ArtalkJS/Artalk - src/types/event.ts](https://github.com/ArtalkJS/Artalk/blob/master/ui/artalk/src/types/event.ts)
|
||||
|
||||
通过 Artalk 提供的 `API` 和 `Event`,你可以实现很多高级功能,比如编写评论管理机器人、评论提醒推送插件等。Artalk 并不为此提供技术指导,但鼓励你参考此处的文档自行定制。
|
||||
@@ -0,0 +1,90 @@
|
||||
# 插件开发
|
||||
|
||||
使用 `Artalk.use` 来扩展 Artalk。
|
||||
|
||||
```js
|
||||
import Artalk from 'artalk'
|
||||
|
||||
Artalk.use((ctx) => {
|
||||
ctx.on('list-loaded', () => {
|
||||
console.log('评论列表加载完毕')
|
||||
ctx.getCommentNodes().forEach((node) => {
|
||||
node.getEl().style.background = 'red'
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Artalk.use((ctx) => {
|
||||
let el = null
|
||||
|
||||
ctx.on('mounted', () => {
|
||||
el = document.createElement('div')
|
||||
document.body.appendChild(el)
|
||||
console.log('Artalk 实例被挂载')
|
||||
})
|
||||
|
||||
ctx.on('unmounted', () => {
|
||||
el.remove()
|
||||
console.log('Artalk 实例被销毁')
|
||||
})
|
||||
})
|
||||
|
||||
const artalk = Artalk.init({ ... })
|
||||
```
|
||||
|
||||
请注意:
|
||||
|
||||
- `Artalk.use` 必须在 `Artalk.init` 之前调用才生效。
|
||||
- 请勿依赖插件的加载顺序,请监听事件来执行插件逻辑。
|
||||
- 当所有的插件加载完毕后,会触发 `created` 事件。
|
||||
- 当插件和配置加载完毕后,会触发 `mounted` 事件。
|
||||
- 当 Artalk 实例被销毁时,会触发 `unmounted` 事件。
|
||||
- 当配置发生变化时,会触发 `updated` 事件。
|
||||
|
||||
在 use 函数中,你可以通过 `ctx` 来访问 Artalk 的 Context 对象。
|
||||
|
||||
## Context
|
||||
|
||||
Context 对象包含了 Artalk 的上下文信息。
|
||||
|
||||
| 成员 | 说明 |
|
||||
| --- | --- |
|
||||
| `ctx.getEl` | 获取容器元素 |
|
||||
| `ctx.getConf` | 获取配置 |
|
||||
| `ctx.updateConf` | 更新配置 |
|
||||
| `ctx.watchConf` | 监听配置 |
|
||||
| `ctx.setDarkMode` | 设置夜间模式 |
|
||||
| `ctx.getApi` | 获取 API 客户端对象 |
|
||||
|--|--|
|
||||
| `ctx.fetch` | 获取评论数据 |
|
||||
| `ctx.reload` | 重载评论列表 |
|
||||
| `ctx.getComments` | 获取所有评论数据对象 |
|
||||
| `ctx.getCommentNodes` | 获取所有评论节点对象 |
|
||||
|--|--|
|
||||
| `ctx.on` | 添加事件监听 |
|
||||
| `ctx.off` | 解除事件监听 |
|
||||
| `ctx.trigger` | 触发事件 |
|
||||
|--|--|
|
||||
| `ctx.get` | 获取依赖 |
|
||||
| `ctx.inject` | 注入依赖 |
|
||||
|
||||
::: warning
|
||||
Context API 目前仍不稳定,开发可能会有变动,升级请关注 CHANGELOG。
|
||||
:::
|
||||
|
||||
参考:[@artalk/src/types/context.ts](https://github.com/ArtalkJS/Artalk/blob/master/ui/artalk/src/types/context.ts)
|
||||
|
||||
Artalk 包含完整的 TypeScript 类型定义,你可以通过编辑器的自动补全来查看 API。
|
||||
|
||||
## 示例插件
|
||||
|
||||
Artalk 有很多内置的插件,你可以参考它们的源码来开发自己的插件。
|
||||
|
||||
[@ArtalkJS/Artalk - src/plugins](https://github.com/ArtalkJS/Artalk/tree/master/ui/artalk/src/plugins)
|
||||
|
||||
我们还提供了一些外置的插件,同样可以参考:
|
||||
|
||||
| 插件 | 说明 |
|
||||
| --- | --- |
|
||||
| [@artalk/plugin-katex](https://github.com/ArtalkJS/Artalk/tree/master/ui/plugin-katex) | LaTeX 公式插件 |
|
||||
| [@artalk/plugin-lightbox](https://github.com/ArtalkJS/Artalk/tree/master/ui/plugin-lightbox) | 图片灯箱插件 |
|
||||
File renamed without changes.
File renamed without changes.
@@ -229,6 +229,15 @@ admin_notify:
|
||||
|
||||
可用变量和邮件模板相同,可参考:[邮件模版](./email.md#邮件模板)
|
||||
|
||||
## 待审评论仍然发送通知 `notify_pending`
|
||||
|
||||
```yaml
|
||||
admin_notify:
|
||||
notify_pending: false
|
||||
```
|
||||
|
||||
`notify_pending` 默认为关闭状态,当该项设置为 `false` 时,待审评论不会发送通知。你可以在控制中心查看所有待审核的评论。
|
||||
|
||||
## 嘈杂模式 `noise_mode`
|
||||
|
||||
```yaml
|
||||
@@ -236,7 +245,7 @@ admin_notify:
|
||||
noise_mode: false
|
||||
```
|
||||
|
||||
noise_mode 默认为关闭状态,当该项设置为 `false` 时,站内仅向管理员回复的消息会发送通知,例如「普通用户 A」回复「普通用户 B」,这两个用户之间的通讯不会通知管理员。
|
||||
`noise_mode` 默认为关闭状态,当该项设置为 `false` 时,站内仅向管理员回复的消息会发送通知,例如「普通用户 A」回复「普通用户 B」,这两个用户之间的通讯不会通知管理员。
|
||||
|
||||
注:当 `moderator.pending_default` 为 `true` 时,noise_mode 为始终开启状态。
|
||||
|
||||
File renamed without changes.
File renamed without changes.
@@ -96,6 +96,7 @@ db:
|
||||
charset: "utf8mb4" # 编码格式
|
||||
table_prefix: "" # 表前缀 (例如:"atk_")
|
||||
ssl: false # 启用 SSL
|
||||
prepare_stmt: true # 预编译语句
|
||||
```
|
||||
|
||||
数据表将在 Artalk 启动时自动完成创建,无需额外操作。
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -1,10 +1,10 @@
|
||||
# 在后端控制前端
|
||||
|
||||
你可以在后端完全控制前端界面的行为(包括设定[前端的配置](/guide/frontend/config)),我们推荐使用这种方式部署 Artalk,并且这个特性「默认开启」。
|
||||
你可以在后端完全控制前端界面的行为(包括设定几乎所有[前端配置项](/guide/frontend/config)),我们推荐使用这种方式配置 Artalk 界面,并且这个特性「默认开启」。
|
||||
|
||||
## 如何修改前端配置
|
||||
## 如何修改前端界面配置
|
||||
|
||||
在侧边栏的[控制中心](/guide/frontend/sidebar.md#控制中心)提供了图形设置界面,你能快速轻松地对前端配置进行修改。
|
||||
在侧边栏的[控制中心](/guide/frontend/sidebar.md#控制中心)提供了图形设置界面,你能快速轻松地对前端界面配置进行修改。
|
||||
|
||||
<img src="../../images/sidebar/fe-setting.png" width="400px">
|
||||
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -0,0 +1,82 @@
|
||||
# 管理员 × 多站点
|
||||
|
||||
Artalk 支持多站点,管理员可以创建多个站点,并对不同站点的评论、页面进行集中管理。
|
||||
|
||||
## 创建管理员
|
||||
|
||||
执行命令根据命令行提示快速创建管理员。
|
||||
|
||||
```sh
|
||||
./artalk admin
|
||||
```
|
||||
|
||||
如果使用 Docker 可以执行以下命令:
|
||||
|
||||
```sh
|
||||
docker exec -it artalk artalk admin
|
||||
```
|
||||
|
||||
之后可使用管理员账户登录控制中心,在用户管理页面的图形界面可创建更多账户,无需手动编辑配置文件。
|
||||
|
||||
## 站点的创建和管理
|
||||
|
||||
你可以在侧边栏「[控制中心](../frontend/sidebar.md#控制中心)」创建多个站点,管理站点和快速切换站点,详情可参考:[侧边栏](/guide/frontend/sidebar.html)。
|
||||
|
||||
## 管理员配置
|
||||
|
||||
你可以设置多个管理员账户,当输入框输入匹配管理员用户名和邮箱时,将弹出密码验证提示框,
|
||||
|
||||
并且只有管理员才能访问「[控制中心](../frontend/sidebar.md#控制中心)」,在前端对评论内容进行管理操作。
|
||||
|
||||
(可选操作)通过配置文件添加管理员:
|
||||
|
||||
```yaml
|
||||
admin_users:
|
||||
- name: "admin"
|
||||
email: "admin@example.com"
|
||||
password: "(bcrypt)$2y$10$ti4vZYIrxVN8rLcYXVgXCO.GJND0dyI49r7IoF3xqIx8bBRmIBZRm"
|
||||
badge_name: "管理员"
|
||||
badge_color: "#0083FF"
|
||||
- name: "admin2"
|
||||
email: "admin2@example.com"
|
||||
password: "(bcrypt)$2y$10$ti4vZYIrxVN8rLcYXVgXCO.GJND0dyI49r7IoF3xqIx8bBRmIBZRm"
|
||||
badge_name: "小管理员"
|
||||
badge_color: "#0083FF"
|
||||
```
|
||||
|
||||
每项配置的解释:
|
||||
|
||||
- **name** & **email**:用户名和邮箱,**不区分大小写**。
|
||||
- **password**:用户密码。
|
||||
|
||||
支持 bcrypt 和 md5 加密,例如填写:`"(md5)50c21190c6e4e5418c6a90d2b5031119"`。
|
||||
|
||||
**建议使用更安全的 bcrypt 加密算法**,在 Linux 环境下,你可以使用 [htpasswd 命令](https://httpd.apache.org/docs/2.4/programs/htpasswd.html) 来生成密文:
|
||||
|
||||
```bash
|
||||
unset HISTFILE # 临时禁用 history 防止密码在历史记录中出现
|
||||
htpasswd -bnBC 10 "" "your_password" | tr -d ':'
|
||||
```
|
||||
|
||||
然后配置填写:`"(bcrypt)$2y$10$ti4vZYIrxVN8rLcY..."`,以 `(bcrypt)` 开头。
|
||||
|
||||
命令解释参考:[Compute bcrypt hash from command line](https://unix.stackexchange.com/questions/307994/compute-bcrypt-hash-from-command-line#answer-419855)
|
||||
|
||||
- **badge_name**:用户显示的头衔徽标文字。
|
||||
- **badge_color**:用户显示的头衔徽标背景颜色。
|
||||
|
||||
### 控制管理员接收邮件通知
|
||||
|
||||
当页面有新的评论时,默认配置是邮件会发送给全部管理员,但你可以配置 `receive_email` 强制禁用它。
|
||||
|
||||
这对于设定了多个邮箱,但又不希望某些邮箱收到评论邮件的情况很有帮助。
|
||||
|
||||
- **receive_email**:设置为 `false` 系统将不会发送邮件通知给该用户。
|
||||
|
||||
注:禁止后该管理员用户仍可以收到来自他人的 @AT 回复,只是当用户对页面进行评论时 (创建根评论时) 不发送邮件通知。
|
||||
|
||||
```yaml
|
||||
admin_users:
|
||||
- name: "admin"
|
||||
receive_email: false # ← 强制不接收邮件
|
||||
```
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -15,7 +15,7 @@ docker run -d \
|
||||
|
||||
> 假设域名 `http://your_domain` 已正确添加 DNS 记录并指向你的服务器 IP
|
||||
|
||||
浏览器打开 `http://your_domain:8080` 将出现 Artalk 后台登陆界面。
|
||||
浏览器打开 `http://your_domain:8080` 将出现 Artalk 后台登录界面。
|
||||
|
||||
执行命令创建管理员账户:
|
||||
|
||||
@@ -127,21 +127,27 @@ Artalk 静态资源通过上游 CDNJS 分发,以下镜像资源可供选择:
|
||||
>
|
||||
> https://cdnjs.cloudflare.com/ajax/libs/artalk/:ArtalkVersion:/Artalk.css
|
||||
|
||||
**Staticfile CDN (国内)**
|
||||
**SUSTech Mirrors (境内)**
|
||||
|
||||
> https://mirrors.sustech.edu.cn/cdnjs/ajax/libs/artalk/:ArtalkVersion:/Artalk.js
|
||||
>
|
||||
> https://mirrors.sustech.edu.cn/cdnjs/ajax/libs/artalk/:ArtalkVersion:/Artalk.css
|
||||
|
||||
::: details 查看更多
|
||||
|
||||
**Staticfile CDN (境内)**
|
||||
|
||||
> https://cdn.staticfile.org/artalk/:ArtalkVersion:/Artalk.js
|
||||
>
|
||||
> https://cdn.staticfile.org/artalk/:ArtalkVersion:/Artalk.css
|
||||
|
||||
::: details 查看更多
|
||||
|
||||
**BootCDN (国内)**
|
||||
**BootCDN (境内)**
|
||||
|
||||
> https://cdn.bootcdn.net/ajax/libs/artalk/:ArtalkVersion:/Artalk.js
|
||||
>
|
||||
> https://cdn.bootcdn.net/ajax/libs/artalk/:ArtalkVersion:/Artalk.css
|
||||
|
||||
**75CDN (国内)**
|
||||
**75CDN (境内)**
|
||||
|
||||
> https://lib.baomitu.com/artalk/:ArtalkVersion:/Artalk.js
|
||||
>
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -6,8 +6,8 @@ const artalk = Artalk.init({ ... })
|
||||
artalk.update({ ... })
|
||||
```
|
||||
|
||||
- 默认配置:[defaults.ts](https://github.com/ArtalkJS/Artalk/blob/master/ui/packages/artalk/src/defaults.ts)
|
||||
- 声明文件:[config.ts](https://github.com/ArtalkJS/Artalk/blob/master/ui/packages/artalk/types/config.ts)
|
||||
- 默认配置:[defaults.ts](https://github.com/ArtalkJS/Artalk/blob/master/ui/artalk/src/defaults.ts)
|
||||
- 声明文件:[config.ts](https://github.com/ArtalkJS/Artalk/blob/master/ui/artalk/src/types/config.ts)
|
||||
|
||||
## 轻松配置
|
||||
|
||||
@@ -179,7 +179,7 @@ JS DELIVR 在中国大陆的 [ICP 牌照已被吊销](https://github.com/jsdeliv
|
||||
artalk.setDarkMode(true)
|
||||
```
|
||||
|
||||
> 参考代码:“[index.html](https://github.com/ArtalkJS/Artalk/blob/master/ui/packages/artalk/index.html#L97-L150)”
|
||||
> 参考代码:“[index.html](https://github.com/ArtalkJS/Artalk/blob/master/ui/artalk/index.html#L97-L150)”
|
||||
|
||||
可设置为 `"auto"`,Artalk 将监听 `(prefers-color-scheme: dark)` 根据用户操作系统判断自动切换夜间模式。
|
||||
|
||||
@@ -57,7 +57,7 @@ Artalk 除了支持 OwO 格式外,还内置支持一种标准的表情包列
|
||||
|
||||
::: warning
|
||||
|
||||
前端的配置将默认被后端覆盖,详情参考:[在后端控制前端](/guide/backend/fe-control.html)
|
||||
前端的配置可能会被后端所覆盖,详情参考:[在后端控制前端](/guide/backend/fe-control.html)
|
||||
|
||||
:::
|
||||
|
||||
@@ -22,7 +22,7 @@ locale 配置项格式遵循 Unicode BCP 47 规范,默认为 "zh-CN" (简体
|
||||
|翻译内容|语言文件目录|模板文件|
|
||||
|-|-|-|
|
||||
|后端程序|[/i18n/[LANG].yml](https://github.com/ArtalkJS/Artalk/tree/master/i18n)|[zh-CN.yml](https://github.com/ArtalkJS/Artalk/blob/master/i18n/zh-CN.yml)|
|
||||
|前端界面|[/ui/packages/artalk/src/i18n/[LANG].ts](https://github.com/ArtalkJS/Artalk/tree/master/ui/packages/artalk/src/i18n)|[zh-CN.ts](https://github.com/ArtalkJS/Artalk/blob/master/ui/packages/artalk/src/i18n/zh-CN.ts)|
|
||||
|前端界面|[/ui/artalk/src/i18n/[LANG].ts](https://github.com/ArtalkJS/Artalk/tree/master/ui/artalk/src/i18n)|[zh-CN.ts](https://github.com/ArtalkJS/Artalk/blob/master/ui/artalk/src/i18n/zh-CN.ts)|
|
||||
|配置文件|[/conf/artalk.example.[LANG].yml](https://github.com/ArtalkJS/Artalk/tree/master/conf)|[artalk.example.zh-CN.yml](https://github.com/ArtalkJS/Artalk/blob/master/conf/artalk.example.zh-CN.yml)
|
||||
|说明文档|[/docs/[LANG]/**\/*.md](https://github.com/ArtalkJS/Artalk/tree/master/docs)|[/docs/**\/*.md](https://github.com/ArtalkJS/Artalk/tree/master/docs)
|
||||
|
||||
@@ -52,7 +52,7 @@ Artalk.init({
|
||||
|
||||
### 前端自定义 locale 内容
|
||||
|
||||
在前端可传入 Object 类型,按照 [模板文件](https://github.com/ArtalkJS/Artalk/blob/master/ui/packages/artalk/src/i18n/zh-CN.ts) 中的 Keys 编写自定义 locale 内容。
|
||||
在前端可传入 Object 类型,按照 [模板文件](https://github.com/ArtalkJS/Artalk/blob/master/ui/artalk/src/i18n/zh-CN.ts) 中的 Keys 编写自定义 locale 内容。
|
||||
|
||||
```js
|
||||
Artalk.init({
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -1,14 +1,14 @@
|
||||
# IP 归属地
|
||||
# IP 属地
|
||||
|
||||
Artalk 内置用户 IP 归属地展示功能,并且你可以设置显示的精度:精确到市、省。
|
||||
Artalk 内置用户 IP 属地展示功能,并且你可以设置显示的精度:精确到市、省。
|
||||
|
||||
该功能默认关闭,你可在 Artalk 控制中心设置中启用 IP 归属地展示功能。
|
||||
该功能默认关闭,你可在 Artalk 控制中心设置中启用 IP 属地展示功能。
|
||||
|
||||
## IP 归属地数据库
|
||||
## IP 属地数据库
|
||||
|
||||
在开启 IP 归属地展示功能之前,你需要下载一个数据库文件:
|
||||
在开启 IP 属地展示功能之前,你需要下载一个数据库文件:
|
||||
|
||||
- [GitHub 下载](https://github.com/lionsoul2014/ip2region/raw/master/data/ip2region.xdb) / [镜像站下载](https://ghproxy.com/?q=https%3A%2F%2Fgithub.com%2Flionsoul2014%2Fip2region%2Fblob%2Fmaster%2Fdata%2Fip2region.xdb) (国内推荐)
|
||||
- [GitHub 下载](https://github.com/lionsoul2014/ip2region/raw/master/data/ip2region.xdb) / [镜像站下载](https://gh-proxy.com/?q=https%3A%2F%2Fgithub.com%2Flionsoul2014%2Fip2region%2Fblob%2Fmaster%2Fdata%2Fip2region.xdb) (境内推荐)
|
||||
|
||||
下载后请手动放置到 `./data/` 目录下,文件命名为:`ip2region.xdb`
|
||||
|
||||
@@ -25,9 +25,9 @@ Artalk 内置用户 IP 归属地展示功能,并且你可以设置显示的精
|
||||
配置文件:
|
||||
|
||||
```yaml
|
||||
# IP 归属地
|
||||
# IP 属地
|
||||
ip_region:
|
||||
# 启用 IP 归属地展示
|
||||
# 启用 IP 属地展示
|
||||
enabled: false
|
||||
# 数据文件路径 (.xdb 格式)
|
||||
db_path: "./data/ip2region.xdb"
|
||||
File renamed without changes.
@@ -18,7 +18,7 @@ Artalk LightBox 插件能帮助你将网站**现有的图片灯箱**功能自动
|
||||
|
||||
目前自动集成支持:[LightGallery](https://github.com/sachinchoolur/lightGallery) [v2.5.0] / [FancyBox](https://github.com/fancyapps/fancybox) [v4.0.27] / [lightbox2](https://github.com/lokesh/lightbox2) [v2.11.3]
|
||||
|
||||
对于还未适配的图片灯箱,欢迎提交 PR -> [查看代码](https://github.com/ArtalkJS/Artalk/blob/master/packages/plugin-lightbox/main.ts)
|
||||
对于还未适配的图片灯箱,欢迎提交 PR -> [查看代码](https://github.com/ArtalkJS/Artalk/blob/master/ui/plugin-lightbox/main.ts)
|
||||
|
||||
::: details 附:图片灯箱依赖 CDN 资源
|
||||
|
||||
File renamed without changes.
@@ -40,4 +40,4 @@
|
||||
|
||||
## 设置
|
||||
|
||||
登陆管理员账户可进入到 “控制中心” 的图形设置界面,轻松地对 [配置文件](/guide/backend/config.md) 以及 [前端的配置](/guide/frontend/config.md) 进行修改,而无需手动编辑复杂的配置文件。
|
||||
登录管理员账户可进入到 “控制中心” 的图形设置界面,轻松地对 [配置文件](/guide/backend/config.md) 以及 [前端的配置](/guide/frontend/config.md) 进行修改,而无需手动编辑复杂的配置文件。
|
||||
File renamed without changes.
@@ -1,6 +1,19 @@
|
||||
# 安全防范
|
||||
|
||||
## 用户身份凭证存储
|
||||
## 程序运行安全性
|
||||
|
||||
有以下一些安全措施可以提高服务器的安全性:
|
||||
|
||||
1. 确保 Artalk 运行在非 `root` 用户或 Docker 容器中,让 Artalk 运行在较低的权限以及隔离的环境中,以降低程序被攻击后的危害。
|
||||
2. 保持 Artalk 的版本为最新,新版可能修复了一些安全漏洞,以及提升了安全性。
|
||||
3. 确保 Artalk 运行在 HTTPS 协议下,以防止数据被中间人窃取。
|
||||
4. 设置强度足够的密码,并配置好验证码等安全措施,以防止密码被破解。
|
||||
5. 设置 `trusted_domains`,以防止恶意的跨域请求。
|
||||
6. 定期备份数据库,以防止数据丢失。
|
||||
|
||||
## 程序设计安全性
|
||||
|
||||
### 用户身份凭证存储
|
||||
|
||||
Artalk 在努力保护用户的安全。参考 [OWASP 安全备忘录](https://cheatsheetseries.owasp.org/cheatsheets/DOM_based_XSS_Prevention_Cheat_Sheet.html) 中提到的内容,Artalk 的开发对于来自用户输入的任何数据始终持以怀疑的态度,我们严格遵循以下准则防范 XSS 攻击:
|
||||
|
||||
@@ -10,16 +23,16 @@ Artalk 在努力保护用户的安全。参考 [OWASP 安全备忘录](https://c
|
||||
- 不要去调用一些高风险的内置函数,因为会带来潜在的安全隐患。例如:`eval()`。
|
||||
- 注意来自内置 API 的数据,应任被视为不可信的。例如:`location.hash.split("#")[1]`。
|
||||
|
||||
## 跨域请求安全性
|
||||
### 跨域请求安全性
|
||||
|
||||
参考:[Cross-Origin Resource Sharing (CORS) | MDN](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS)
|
||||
|
||||
【待补充】
|
||||
|
||||
## API 设计安全性
|
||||
### API 设计安全性
|
||||
|
||||
【待补充】
|
||||
|
||||
## 写在结尾
|
||||
|
||||
Artalk 的功能在不断完善,同时也在不断向提高安全性的目标努力,但在努力的同时还是难免发生一些疏忽和遗漏,若遇问题或有好的建议,欢迎反馈与指正。
|
||||
Artalk 的功能在不断完善,同时也在不断向提高安全性的目标努力,但难免存在可能的问题,如果您发现了 Artalk 的安全漏洞,请通过 [GitHub Issues](https://github.com/ArtalkJS/Artalk/issues) 或者邮箱 artalkjs@gmail.com 快速向我们取得联系,我们会尽最大的努力在第一时间解决!感谢您的支持!
|
||||
@@ -165,15 +165,15 @@ typecho-20220424-202246.artrans
|
||||
参数格式遵循 `<key>:<value>`,例如:
|
||||
|
||||
```bash
|
||||
./artalk import 类型 t_name:"Site" t_url:"https://xx.com" json_file:"文件路径"
|
||||
./artalk import 类型 target_site_name:"Site" target_site_url:"https://xx.com" json_file:"文件路径"
|
||||
```
|
||||
|
||||
前端的导入同样可以手动输入启动参数,例如:
|
||||
|
||||
```json
|
||||
{
|
||||
"t_name": "Site",
|
||||
"t_url": "https://xx.com",
|
||||
"target_site_name": "Site",
|
||||
"target_site_url": "https://xx.com",
|
||||
"json_file": "服务器上的文件路径"
|
||||
}
|
||||
```
|
||||
@@ -182,10 +182,12 @@ Artalk 导入功能的通用启动参数:
|
||||
|
||||
| 参数 | 类型 | 说明 |
|
||||
| :------: | ------ | ------------ |
|
||||
| `t_name` | String | 导入站点名称 |
|
||||
| `t_url` | String | 导入站点 URL |
|
||||
| `target_site_name` | String | 导入站点名称 |
|
||||
| `target_site_url` | String | 导入站点 URL |
|
||||
| `url_resolver` | Boolean | 默认关闭,URL 解析器。将 `page_key` 基于 `target_site_url` 参数重新生成为完整 URL 作为评论的新 `page_key` |
|
||||
| `json_file` | String | JSON 数据文件路径 |
|
||||
| `json_data` | String | JSON 数据字符串内容 |
|
||||
| `assumeyes` | Boolean | 不提确认 `y/n`,直接执行 |
|
||||
|
||||
## 数据备份
|
||||
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loaded 100 of 579 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user