Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

MicroBin中文版v1.2.0 #148

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
189 changes: 21 additions & 168 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -1,165 +1,18 @@
name: Release
name: Docker Image

on:
push:
tags:
- v[0-9]+.[0-9]+.[0-9]+*

jobs:
release:
name: Publish to Github Relases
outputs:
rc: ${{ steps.check-tag.outputs.rc }}

strategy:
matrix:
include:
- target: aarch64-unknown-linux-musl
os: ubuntu-latest
use-cross: true
cargo-flags: ""
- target: aarch64-apple-darwin
os: macos-latest
use-cross: true
cargo-flags: ""
- target: aarch64-pc-windows-msvc
os: windows-latest
use-cross: true
cargo-flags: "--no-default-features"
- target: x86_64-apple-darwin
os: macos-latest
cargo-flags: ""
- target: x86_64-pc-windows-msvc
os: windows-latest
cargo-flags: ""
- target: x86_64-unknown-linux-musl
os: ubuntu-latest
use-cross: true
cargo-flags: ""
- target: i686-unknown-linux-musl
os: ubuntu-latest
use-cross: true
cargo-flags: ""
- target: i686-pc-windows-msvc
os: windows-latest
use-cross: true
cargo-flags: ""
- target: armv7-unknown-linux-musleabihf
os: ubuntu-latest
use-cross: true
cargo-flags: ""
- target: arm-unknown-linux-musleabihf
os: ubuntu-latest
use-cross: true
cargo-flags: ""
- target: mips-unknown-linux-musl
os: ubuntu-latest
use-cross: true
cargo-flags: "--no-default-features"
- target: mipsel-unknown-linux-musl
os: ubuntu-latest
use-cross: true
cargo-flags: "--no-default-features"
- target: mips64-unknown-linux-gnuabi64
os: ubuntu-latest
use-cross: true
cargo-flags: "--no-default-features"
- target: mips64el-unknown-linux-gnuabi64
os: ubuntu-latest
use-cross: true
cargo-flags: "--no-default-features"
runs-on: ${{matrix.os}}

steps:
- uses: actions/checkout@v2

- name: Check Tag
id: check-tag
shell: bash
run: |
tag=${GITHUB_REF##*/}
echo "::set-output name=version::$tag"
if [[ "$tag" =~ [0-9]+.[0-9]+.[0-9]+$ ]]; then
echo "::set-output name=rc::false"
else
echo "::set-output name=rc::true"
fi


- name: Install Rust Toolchain Components
uses: actions-rs/toolchain@v1
with:
override: true
target: ${{ matrix.target }}
toolchain: stable
profile: minimal # minimal component installation (ie, no documentation)

- name: Show Version Information (Rust, cargo, GCC)
shell: bash
run: |
gcc --version || true
rustup -V
rustup toolchain list
rustup default
cargo -V
rustc -V

- name: Build
uses: actions-rs/cargo@v1
with:
use-cross: ${{ matrix.use-cross }}
command: build
args: --locked --release --target=${{ matrix.target }} ${{ matrix.cargo-flags }}

- name: Build Archive
shell: bash
id: package
env:
target: ${{ matrix.target }}
version: ${{ steps.check-tag.outputs.version }}
run: |
set -euxo pipefail

bin=${GITHUB_REPOSITORY##*/}
src=`pwd`
dist=$src/dist
name=$bin-$version-$target
executable=target/$target/release/$bin

if [[ "$RUNNER_OS" == "Windows" ]]; then
executable=$executable.exe
fi

mkdir $dist
cp $executable $dist
cd $dist

if [[ "$RUNNER_OS" == "Windows" ]]; then
archive=$dist/$name.zip
7z a $archive *
echo "::set-output name=archive::`pwd -W`/$name.zip"
else
archive=$dist/$name.tar.gz
tar czf $archive *
echo "::set-output name=archive::$archive"
fi

- name: Publish Archive
uses: softprops/action-gh-release@v0.1.5
if: ${{ startsWith(github.ref, 'refs/tags/') }}
with:
draft: false
files: ${{ steps.package.outputs.archive }}
prerelease: ${{ steps.check-tag.outputs.rc == 'true' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

docker:
name: Publish to Docker Hub
if: startsWith(github.ref, 'refs/tags/')
docker_image:
name: Build & push docker image to DockerHub
runs-on: ubuntu-latest
needs: release
steps:
- name: Checkout repo
uses: actions/checkout@v3

- name: Docker meta
id: meta
uses: docker/metadata-action@v4
Expand All @@ -169,24 +22,24 @@ jobs:
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to DockerHub
uses: docker/login-action@v1

- name: Setup QEMU
uses: docker/setup-qemu-action@v2

- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Login DockerHub
if: github.event_name != 'pull_request'
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v2

- name: Build & push
uses: docker/build-push-action@v3
with:
build-args: |
REPO=${{ github.repository }}
VER=${{ github.ref_name }}
platforms: |
linux/amd64
linux/arm64
platforms: linux/amd64, linux/arm64
push: ${{ github.ref_type == 'tag' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
labels: ${{ steps.meta.outputs.labels }}
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ COPY --from=build \
/etc/ssl/certs/ca-certificates.crt \
/etc/ssl/certs/ca-certificates.crt

# copy built executable
# copy built exacutable
COPY --from=build \
/app/target/release/microbin \
/usr/bin/microbin

# Expose webport used for the webserver to the docker runtime
EXPOSE 8080

ENTRYPOINT ["microbin"]
ENTRYPOINT ["microbin"]
116 changes: 51 additions & 65 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,76 +1,62 @@

![Screenshot](.github/index.png)

# MicroBin

![Build](https://github.com/szabodanika/microbin/actions/workflows/rust.yml/badge.svg)
![crates.io](https://img.shields.io/crates/v/microbin.svg)
[![Docker Image](https://github.com/szabodanika/microbin/actions/workflows/docker.yml/badge.svg)](https://hub.docker.com/r/danielszabo99/microbin)
[![Docker Pulls](https://img.shields.io/docker/pulls/danielszabo99/microbin?label=Docker%20pulls)](https://img.shields.io/docker/pulls/danielszabo99/microbin?label=Docker%20pulls)
[![Support Server](https://img.shields.io/discord/662017309162078267.svg?color=7289da&label=Discord&logo=discord&style=flat-square)](https://discord.gg/3DsyTN7T)

MicroBin is a super tiny, feature rich, configurable, self-contained and self-hosted paste bin web application. It is very easy to set up and use, and will only require a few megabytes of memory and disk storage. It takes only a couple minutes to set it up, why not give it a try now?
MicroBin是一个超小型、功能丰富、可配置、自包含和自托管的粘贴箱web应用程序。它非常易于设置和使用,只需要几兆字节的内存和磁盘存储。设置它只需要几分钟,为什么不现在就试试呢?

Install from Cargo:
## microbin汉化
### 说明
简单部分汉化,仅供学习使用,随缘更新!
## 演示:
图片:
![](https://lsky.balabi.asia/i/2023/03/26/641ff7330d924.png)
测试demo:[microbin中文测试](https://bin.alldreams.top/)

```bash
cargo install microbin
```
## 使用方法:

And run with your custom configuration:

```bash
microbin --port 8080 --public-path https://myserver.net --highlightsyntax --editable
zip包上传至服务器并解压
`unzip [包名]`
1. 进入项目Dockerfile所在目录
2. 构建镜像
```shell
docker build -t microbin-zh_cn:v1 .
```
3. 配置容器
```shell
nano docker-compose.yml
```

Or get the Docker Image from [Dockerhub: danielszabo99/microbin](https://hub.docker.com/r/danielszabo99/microbin).

On our website [microbin.eu](https://microbin.eu) you will find the following:

- [Screenshots](https://microbin.eu/screenshots/)
- [Quickstart Guide](https://microbin.eu/quickstart/)
- [Documentation](https://microbin.eu/documentation/)
- [Donations and Sponsorships](https://microbin.eu/donate/)
- [Community](https://microbin.eu/community/)

## Features

- Is very small
- Entirely self-contained executable, MicroBin is a single file!
- Animal names instead of random numbers for pasta identifiers (64 animals)
- File uploads (eg. `server.com/file/pig-dog-cat`)
- Raw text serving (eg. `server.com/raw/pig-dog-cat`)
- URL shortening and redirection
- QR code support
- Very simple database (JSON + files) for portability, easy backups and integration
- Listing and manually removing pastas (`/pastalist`)
- Private and public, editable and final, automatically and never expiring pastas
- Syntax highlighting
- Automatic dark mode and custom styling support with very little CSS and only vanilla JS (see [`water.css`](https://github.com/kognise/water.css))
- Most of the above can be toggled on and off!

## What is a "pasta" anyway?

In MicroBin, a pasta can be:

- A text that you want to paste from one machine to another, eg. some code,
- A file that you want to share, eg. a video that is too large for Discord, a zip with a code project in it or an image,
- A URL redirect.

## When is MicroBin useful?

You can use MicroBin:

- As a URL shortener/redirect service,
- To send long texts to other people,
- To send large files to other people,
- To serve content on the web, eg. configuration files for testing, images, or any other file content using the Raw functionality,
- To move files between your desktop and a server you access from the console,
- As a "postbox" service where people can upload their files or texts, but they cannot see or remove what others sent you - just disable the pastalist page
- To take notes! Simply create an editable pasta.

...and many other things, why not get creative?

MicroBin and MicroBin.eu are available under the [BSD 3-Clause License](LICENSE).

© Dániel Szabó 2022
参考配置:(注意镜像名的修改!!!)
```yaml
version: '3.5'

services:
microbin:
image: microbin-zh_cn:v1
container_name: microbin
restart: unless-stopped
environment:
- TZ=Asia/Shanghai
- MICROBIN_HIGHLIGHTSYNTAX=true
- MICROBIN_HASH_IDS=true
- MICROBIN_EDITABLE=true
- MICROBIN_PRIVATE=true
- MICROBIN_HIDE_FOOTER=false
- MICROBIN_HELP=true
- MICROBIN_FOOTER_TEXT=内容设置保存的最长时间只有一周,请及时将内容保存到本地!!!
- MICROBIN_HIDE_HEADER=false
- MICROBIN_HIDE_LOGO=false
- MICROBIN_NO_ETERNAL_PASTA=true
- MICROBIN_NO_FILE_UPLOAD=false
- MICROBIN_NO_LISTING=false
- MICROBIN_THREADS=2
- MICROBIN_TITLE=free-bin
- MICROBIN_PUBLIC_PATH=http://localhost:5423/
- MICROBIN_QR=true
ports:
- 5423:8080
volumes:
- ./microbin-data:/app/pasta_data
```
29 changes: 29 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
version: '3.5'

services:
microbin:
image: microbin-zh_cn:v1
container_name: microbin
restart: unless-stopped
environment:
- TZ=Asia/Shanghai
- MICROBIN_HIGHLIGHTSYNTAX=true
- MICROBIN_HASH_IDS=true
- MICROBIN_EDITABLE=true
- MICROBIN_PRIVATE=true
- MICROBIN_HIDE_FOOTER=false
- MICROBIN_HELP=true
- MICROBIN_FOOTER_TEXT=内容设置保存的最长时间只有一周,请及时将内容保存到本地!!!
- MICROBIN_HIDE_HEADER=false
- MICROBIN_HIDE_LOGO=false
- MICROBIN_NO_ETERNAL_PASTA=true
- MICROBIN_NO_FILE_UPLOAD=false
- MICROBIN_NO_LISTING=false
- MICROBIN_THREADS=2
- MICROBIN_TITLE=free-bin
- MICROBIN_PUBLIC_PATH=http://localhost:5423/
- MICROBIN_QR=true
ports:
- 5423:8080
volumes:
- ./microbin-data:/app/pasta_data