极简网页记事本

若无单独说明,按照文章代码块中命令的顺序,一条一条执行,即可实现目标。

适用系统:Debian 系发行版,包括 Ubuntu 和 Armbian,其他发行版按流程稍改命令一般也可。

走通预计时间:10 分钟(Docker) 或 25 分钟(原生部署)


minimalist-web-notepad

Alt Text

这个网页记事本是我 2 年前玩机子初期的一大驱动力。当时主要从手机上浏览信息,刚转变到在电脑上处理信息,需要一种简便的渠道在两者之间传递文本、网址。

网盘太重,微信需要验证,tg 很好,但在找到这个记事本后,都是乐色,这就是最好的全平台传递文本的工具。
极简 网页记事本,是一个使用浏览器访问的轻量好用的记事本,专注于文本记录。
Github:pereorga/minimalist-web-notepad: Minimalist Web Notepad (github.com)


使用方法

  1. 访问网页: https://forward.vfly2.eu.org/index.php
  2. 它会随机分配 5 个字符组成的地址,如 https://forward.vfly2.eu.org/5b79m ,如果想指定地址,只需要访问时手动修改,如 https://forward.vfly2.eu.org/this_is_a_path 。下面以 5b79m 为例。
  3. 在上面编辑文本
  4. 等待一会(几秒,取决于延迟),服务端就会存储网页内容到名为 5b79m 的文件里。
  5. 关闭网页,如果关闭太快,会来不及保存,丢失编辑。
  6. 在其他平台再访问同样的网址,就能剪切内容了 ٩۹(๑•̀ω•́ ๑)۶

只要不关闭过快和在两个网页同时编辑,它都能很好地工作。因为极简,项目作者不会考虑增加多余功能。
Alt Text
在远控其他电脑时,用这个先传递命令,在目标电脑上使用,非常方便,而且适应性强。多个手机之间也一样。或者用于临时传送敏感数据,避免受到平台审查。

使用 Docker 安装 网页记事本

GitHub 的 Docker 分支: pereorga/minimalist-web-notepad at docker (github.com)

Docker 分支很久没更新了,文章最后一节是「解析 minimalist-web-notepad 的 Docker 分支」,可以参考从而使用最新版主分支创建 Docker 镜像。

官方 Docker 分支的部署

全复制并执行 ,一键创建工作目录并开放端口

myserve="webnote"
sudo ufw allow 8088/tcp comment $myserve && sudo ufw reload
cd ~/myserve/
wget https://github.com/pereorga/minimalist-web-notepad/archive/refs/heads/docker.zip
unzip docker.zip && mv minimalist-web-notepad-docker webnote
cd webnote

根据注释自定义 ,然后执行,一键创建 docker-compose.yml 文件

cat > docker-compose.yml << EOF
---

version: "2.4"
services:
minimalist-web-notepad:
build: .
container_name: webnote
restart: always
ports:
- "8088:80"
volumes:
- ./_tmp:/var/www/html/_tmp
EOF

前面的 5b79m 就存储在 _tmp 中。
构建并启动容器(完成后就可以访问网页了,通过 http://ip_addr_or_domain:8088 访问。将 ip_addr_or_domain 替换为服务器的 IP 或域名)

docker compose up -d

解析 minimalist-web-notepad 的 Docker 分支

相比主分支, Docker 分支有四个新增的文件

  • Dockerfile
  • docker-compose
  • minimalist-web-notepad-entrypoint
  • notes.htaccess
    利用最新版主分支,构建镜像的步骤如下:

前置准备

下载最新版主分支

wget https://github.com/pereorga/minimalist-web-notepad/archive/refs/heads/master.zip
unzip master.zip && rm master.zip
mv minimalist-web-notepad-master webnote
cd webnote

修改 index,改这两行为下面的

vim index.php
$base_url = getenv('MWN_BASE_URL') ?: '';
$save_path = getenv('MWN_SAVE_PATH') ?: '_tmp';

一键修改

sed -i "s/\$base_url = 'https:\/\/notes.orga.cat';/\$base_url = getenv('MWN_BASE_URL') ?: '';/g; s/\$save_path = '_tmp';/\$save_path = getenv('MWN_SAVE_PATH') ?: '_tmp';/g" ./index.php

创建 notes.htaccess

cat > notes.htaccess << EOF
<IfModule mod_authz_core.c>
Require all denied
</IfModule>
<IfModule !mod_authz_core.c>
Order allow,deny
</IfModule>
EOF

创建 entrypoint 文件

vim minimalist-web-notepad-entrypoint
#!/bin/sh
set -e

# Create save path
case "${MWN_SAVE_PATH:=_tmp}" in
/*) NOTES_PATH="$MWN_SAVE_PATH" ;;
*) NOTES_PATH="/var/www/html/$MWN_SAVE_PATH" ;;
esac
mkdir -p "$NOTES_PATH"
cp "/var/www/html/notes.htaccess" "$NOTES_PATH/.htaccess"
chown -R www-data:www-data "$NOTES_PATH"

# Run default entrypoint
exec docker-php-entrypoint "$@"

赋予执行权限

chmod +x minimalist-web-notepad-entrypoint

"$@" 是一个特殊变量,用于将在容器启动时传递给 docker-php-entrypoint 脚本的所有命令行参数传递过去。

例如,如果在运行容器时使用以下命令: docker run -it my_image arg1 arg2

那么 "$@" 将被展开为 arg1 arg2,并作为参数传递给 docker-php-entrypoint 脚本。这样可以确保容器内部的入口脚本能够正确处理传递的参数。

Dockerfile

先拉取基础镜像: php Tags | Docker Hub

docker pull php:7.4-apache
# docker run -it --rm php:7.4-apache bash
# 可以知道默认 workdir 是 /var/www/html

vim Dockerfile
FROM php:7.4-apache

# Import App and entrypoint file
COPY .htaccess index.php styles.css script.js favicon.ico favicon.svg notes.htaccess minimalist-web-notepad-entrypoint ./

# Set PHP configuration to production, then Set entrypoint for permissions
RUN cp /usr/local/etc/php/php.ini-production /usr/local/etc/php/php.ini && \
mv minimalist-web-notepad-entrypoint /usr/local/bin/ && \
a2enmod rewrite && \
rm -rf /var/lib/apt/lists/*

ENTRYPOINT ["minimalist-web-notepad-entrypoint"]
CMD ["apache2-foreground"]

构建镜像

docker build -t ahfeil/minimalist-web-notepad:latest .

删除重建

docker stop webnote && docker rm webnote && docker rmi ahfeil/minimalist-web-notepad:latest

docker-compose.yml 文件中,把 build: . 换成 image: ahfeil/minimalist-web-notepad:latest 即可