Skip to content

Commit

Permalink
[feature] finish main feature
Browse files Browse the repository at this point in the history
[fix] action

[fix] action 2

[fix] bash scripts

[feature] get version when auto release

[fix] fix aciton 3

[fix] fix aciton 4

[fix] fix aciton 5

[fix] fix aciton 6

[fix] fix aciton 7

[fix] fix aciton 8

[fix] fix aciton 9

[fix] fix aciton 10

[fix] fix aciton 11

Update release.yml

Update release.yml

[feature] Docker support && README

[update] Create LICENSE

[update] version
  • Loading branch information
WindLX committed Oct 11, 2023
1 parent 63ae570 commit 3a10812
Show file tree
Hide file tree
Showing 46 changed files with 855 additions and 217 deletions.
56 changes: 56 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Release Workflow

on:
push:
branches:
- main

jobs:
release:
runs-on: ubuntu-22.04

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Setup Node.js environment
uses: actions/setup-node@v3
with:
node-version: 18.17.0

- name: Run custom script to pack files
run: |
chmod +x scripts/tool.sh
./scripts/tool.sh --pack
env:
NODE_VERSION: 18.17.0

- name: Get Version
id: get_version
run: |
version=$(jq -r '.version' package.json)
echo "VERSION=v${version}" >> $GITHUB_ENV
- name: Set Git Config
run: |
git config --global user.name 'windlx'
git config --global user.email '1418043337@qq.com'
- name: Create Tag
uses: negz/create-tag@v1
with:
token: "${{ secrets.GITHUB_TOKEN }}"
version: ${{ env.VERSION }}
env:
VERSION: ${{ env.VERSION }}

- name: Upload release
uses: marvinpinto/action-automatic-releases@latest
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
automatic_release_tag: ${{ env.VERSION }}
title: ${{ env.VERSION }}
prerelease: false
files: |
PapPack.tar.gz
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,9 @@ __pycache__

# data
data
!data/config.toml
!data/config.toml

# release
PapPack
*.tar.gz
*.zip
9 changes: 9 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM python:3.11.4

WORKDIR /pap
COPY PapPack /pap
RUN pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple

EXPOSE 13956

CMD ["/bin/bash", "/pap/pap.sh"]
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2023 WindLX

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
34 changes: 30 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,35 @@
# Pap

## Quick Start
## 简介

execute `scripts/run.ps1` or `scripts/run.sh`
Pap 是一个pdf文件管理软件,提供了简洁的世界 Web 页面,通过标签对文件进行管理,可为托管文件自由添加 markdown 笔记.

## Develop
## 安装

execute `scripts/tool.ps1` or `scripts/tool.sh` for static type check or automatical test
Pap 需要 Python 3.11.4 的运行环境. 所有脚本均可通过 `Get-Help script.ps1` (Windows) 或者 `script.sh --help` (Linux) 获取帮助信息

### Windows/Linux

`release` 中下载最新版本的压缩包 `PapPack`,解压后在 `PapPack` 目录下运行 `.\pap.ps1` (Windows) 或者 `./pap/sh` (Linux) 即可启动程序,用浏览器打开对应的网络地址即可查看.

### Docker

运行 `docker build -t pap .` 即可构建 docker 镜像,容器内默认服务地址为 `172.17.0.2:13956`,容器暴露端口为 `13956`

### 从源码构建

从源码构建 Pap 需要安装 Node.js v18.17.0 和 Python 3.11.4 运行时,在项目目录下运行 `.\scripts\tools.ps1 -Pack` (Windows) 或者 `./scripts/tool.sh --pack` (Linux) 即可

## 开发

`scripts\tool.ps1``scripts/tool.sh` 提供了一些实用开发工具,如静态类型检查,测试,编译构建和打包。通过 `Get-Help .\scripts\tools.ps1` 或者 `./scripts/tool.sh --help` 命令获取脚本的更多帮助信息.

## TODO

- [ ] Markdown Parser
- [ ] Markdown Editor
- [ ] Timeline
- [ ] OCR
- [ ] PDF information extraction function
- [ ] More powerful PDF browsing and editing functions
- [ ] More Test
4 changes: 2 additions & 2 deletions data/config.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[system]
host = "127.0.0.1"
port = 8001
host = "172.17.0.2"
port = 13956

[basic]
title = "Pap"
Expand Down
4 changes: 4 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@

<body>
<div id="app"></div>
<script>
window.host = "{{ host }}"
window.port = "{{ port }}"
</script>
<script type="module" src="/src/main.ts"></script>
</body>

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "pap",
"private": true,
"version": "0.0.0",
"version": "0.1.1",
"type": "module",
"scripts": {
"dev": "vite",
Expand Down
51 changes: 51 additions & 0 deletions scripts/pap.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<#
.Synopsis
This PowerShell script is used for automating the setup of a running environment and execute Pap and update.
.Description
The pap.ps1 script is a versatile tool designed to simplify the process of creating and updating your running environment while seamlessly running Pap. It offers the following functionality:
- When executed without any options, it sets up the default environment for running Pap.
- If the `-Update` option is specified, the script update the version of Pap from remote repository
The script's flexibility allows it to adapt to your specific needs, whether you're focused on development or simply running Pap.
.Parameter Update
Whether to update.
.Example
To run the script with default settings:
PS .\pap.ps1
To update the version of Pap before running:
PS .\pap.ps1 -Dev
#>

[CmdletBinding()]
param (
[switch] $Update,
)

# Function to activate Python virtual environment
function Open-Venv {
if (Test-Path ".venv") {
.\.venv\Scripts\Activate
}
else {
python -m venv .venv --prompt pap
.\.venv\Scripts\Activate
pip install -r requirements_release.txt
}
}

if ($Update) {
if (Test-Path ".venv") {
Remove-Item -Path .\.venv -Recurse -Force
}
}

Open-Venv
try {
python src-python/app.py
}
finally {
deactivate
}
66 changes: 66 additions & 0 deletions scripts/pap.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
#!/bin/bash

# Function to activate Python virtual environment
activate_venv() {
if [ -d ".venv" ]; then
source .venv/bin/activate
else
python -m venv .venv --prompt pap
source .venv/bin/activate
pip install -r requirements_release.txt
fi
}

while [[ $# -gt 0 ]]; do
case "$1" in
--help)
less pap.sh.man
exit 0
shift
;;
--update)
Update=true
shift
;;
*)
echo "Unknown argument: $1"
exit 1
;;
esac
done

if [ "$Update" = true ]; then
latest_release=$(curl -s "https://api.github.com/repos/WindLX/Pap/releases/latest")
download_url=$(echo "$latest_release" | grep "browser_download_url" | grep "PapPack.tar.gz" | cut -d '"' -f 4)
if [ -z "$download_url" ]; then
echo "Error: Unable to find download URL for Pap in the latest release."
exit 1
fi

echo "Downloading PapPack.tar.gz..."
curl -L -o PapPack.tar.gz "$download_url"

echo "Extracting PapPack.tar.gz..."
tar -xzf PapPack.tar.gz

rm ./dist -r
rm ./src-python -r
rm ./README.md
rm ./requirements_release.txt

mv ./PapPack/dist ./dist
mv ./PapPack/src-python ./src-python
mv ./PapPack/README.md ./README.md
mv ./PapPack/requirements_release.txt ./requirements_release.txt

rm PapPack -r
rm PapPack.tar.gz

if [ -d ".venv" ]; then
rm .venv -r
fi
fi

activate_venv
python src-python/app.py
deactivate
30 changes: 30 additions & 0 deletions scripts/pap.sh.man
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
NAME
pap.sh - Automate the setup of a running environment and execute Pap and update.

SYNOPSIS
pap.sh [--update | --help]

DESCRIPTION
The pap.sh script is a versatile tool designed to simplify the process of creating and updating your running environment while seamlessly running Pap. It offers the following functionality:

- When executed without any options, it sets up the default environment for running Pap.

- If the `--update` option is specified, the script update the version of Pap from remote repository

- When the `--help` option is provided, it will show help document for this script

The script's flexibility allows it to adapt to your specific needs, whether you're focused on development or simply running Pap.

OPTIONS
--update
Specifies whether to update.

--help
To get the help.

EXAMPLES
To run the script with default settings (no development environment and no frontend build):
$ ./run.sh

To update the version of Pap before running:
$ ./run.sh --update
2 changes: 2 additions & 0 deletions requirements.txt → scripts/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ httpcore==0.18.0
httpx==0.25.0
idna==3.4
iniconfig==2.0.0
Jinja2==3.1.2
MarkupSafe==2.1.3
mypy==1.5.1
mypy-extensions==1.0.0
packaging==23.2
Expand Down
13 changes: 2 additions & 11 deletions requirements_windows.txt → scripts/requirements_release.txt
Original file line number Diff line number Diff line change
@@ -1,27 +1,18 @@
annotated-types==0.6.0
anyio==3.7.1
certifi==2023.7.22
click==8.1.7
colorama==0.4.6
fastapi==0.103.2
greenlet==3.0.0
h11==0.14.0
httpcore==0.18.0
httpx==0.25.0
idna==3.4
iniconfig==2.0.0
mypy==1.5.1
mypy-extensions==1.0.0
packaging==23.2
pluggy==1.3.0
Jinja2==3.1.2
MarkupSafe==2.1.3
pydantic==2.4.2
pydantic_core==2.10.1
pytest==7.4.2
python-multipart==0.0.6
sniffio==1.3.0
SQLAlchemy==2.0.21
starlette==0.27.0
toml==0.10.2
types-toml==0.10.8.7
typing_extensions==4.8.0
uvicorn==0.23.2
Loading

0 comments on commit 3a10812

Please sign in to comment.