Skip to content

Commit c1b0ebb

Browse files
committed
Merge branch 'next' for v1.7
2 parents bec4951 + c3eb5cf commit c1b0ebb

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+1955
-1318
lines changed

.github/workflows/tests.yml

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ on:
55
branches: [ main ]
66
pull_request:
77
branches: [ main, next ]
8+
workflow_dispatch:
89

910
jobs:
1011
lint:
@@ -19,14 +20,13 @@ jobs:
1920
uses: actions/cache@v3
2021
with:
2122
path: ~/.cache/pip
22-
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
23+
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements*.txt') }}
2324
restore-keys: |
2425
${{ runner.os }}-pip-
2526
- name: Install dependencies
2627
run: |
2728
python -m pip install --upgrade pip
28-
pip install flake8
29-
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
29+
pip install -r requirements.txt -r requirements-dev.txt
3030
- name: Run Linter
3131
run: |
3232
# stop the build if there are Python syntax errors or undefined names
@@ -45,12 +45,17 @@ jobs:
4545
uses: actions/cache@v3
4646
with:
4747
path: ~/.cache/pip
48-
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
48+
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements*.txt') }}
4949
restore-keys: |
5050
${{ runner.os }}-pip-
5151
- name: Install dependencies
5252
run: |
53-
python -m pip install --upgrade pip
54-
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
53+
pip install -r requirements.txt -r requirements-dev.txt
5554
- name: Run Unit Tests
56-
run: python -m unittest -v
55+
run: mkdir reports && nose2
56+
- name: Upload Test Reports
57+
uses: actions/upload-artifact@v3
58+
if: success() || failure()
59+
with:
60+
name: reports
61+
path: reports/

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@ data/
99
__pycache__
1010
.venv/
1111
.coverage
12+
reports/

CHANGELOG.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,23 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7+
## [1.7.0] - 2022-10-30
8+
### Added
9+
- Show expiry on paste screen
10+
- Configurable multi-tiered caching
11+
- CLI can remove empty cache folders
12+
- Strict paste id checking in URLs
13+
- Better general exception handling
14+
- Add human padding for paste id
15+
- Some more unit tests
16+
### Changed
17+
- Major code refactoring (pastes are no longer dependant on storage types, for future s3 object support)
18+
- Tidy REST API routes
19+
### Fixed
20+
- Fixed #53 Expiry set in UI always interpreted as UTC, by having a configurable timezone
21+
### Removed
22+
- Removed deprecated features, see #50
23+
724
## [1.6.1] - 2022-10-09
825
### Fixed
926
- #51, When override lexer is given in paste url incorrectly uses cached content

README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
A fast and minimal paste bin, written in Python using Quart.
99

10-
> **IMPORTANT NOTICE** Some deprecated features will be removed in V1.7, view [here](https://github.com/enchant97/hasty-paste/issues/50)
10+
> **IMPORTANT NOTICE** Some deprecated features have been removed in V1.7, view [here](https://github.com/enchant97/hasty-paste/issues/50)
1111
1212
## Features
1313
- Quickly paste and save, to share some text
@@ -20,13 +20,17 @@ A fast and minimal paste bin, written in Python using Quart.
2020
- Uses minimal resources
2121
- REST API
2222
- No Database needed, everything stored as flat-files
23+
- Caching (Internal & Redis)
2324
- Lightweight Docker image (uses Alpine Linux)
2425

2526
## Showcase
2627
[![Showcase Image](docs/assets/showcase.png)](docs/assets/showcase.png)
2728

2829
## Docs
29-
Docs are located in the [/docs](docs/index.md) directory.
30+
Docs are located in the [/docs](docs/index.md) directory. Or on the site: [enchantedcode.co.uk/hasty-paste](https://enchantedcode.co.uk/hasty-paste)
31+
32+
## Hastily Paste It CLI
33+
This is a simple script allowing the creation of pastes from the command-line. You can download your version [here](hastily-paste-it/README.md).
3034

3135
## Branches
3236
| Name | Description | State |

docs/assets/openapi.yml

Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
openapi: 3.0.0
2+
info:
3+
title: Hasty Paste API
4+
description: "A fast and minimal paste bin, written in Python using Quart."
5+
version: 1.7.0
6+
7+
paths:
8+
/api/is-healthy:
9+
get:
10+
tags:
11+
- Status
12+
summary: "Check the health of server"
13+
description: ""
14+
responses:
15+
200:
16+
description: "Server is OK"
17+
/api/pastes:
18+
post:
19+
tags:
20+
- Paste
21+
summary: ""
22+
description: ""
23+
requestBody: { $ref: "#/components/requestBodies/PasteCreate" }
24+
responses:
25+
201:
26+
description: ""
27+
content:
28+
application/json:
29+
schema: { $ref: "#/components/schemas/Paste" }
30+
400:
31+
description: "required fields are missing, or invalid"
32+
/api/pastes/:
33+
get:
34+
tags:
35+
- Paste
36+
summary: "Get all id's, requires ENABLE_PUBLIC_LIST to be True"
37+
description: ""
38+
responses:
39+
200:
40+
description: "Paste id's"
41+
403:
42+
description: "It has been disabled by administrator"
43+
/api/pastes/simple:
44+
post:
45+
tags:
46+
- Paste
47+
summary: "Create a paste without any fancy features"
48+
description: "Could be used easily with curl by a user."
49+
responses:
50+
201:
51+
description: "paste id of created paste"
52+
/api/pastes/{paste_id}:
53+
parameters:
54+
- name: paste_id
55+
example: be4Q5k2K0L
56+
schema:
57+
type: string
58+
in: path
59+
required: true
60+
get:
61+
tags:
62+
- Paste
63+
summary: "Get a paste's raw content"
64+
responses:
65+
200:
66+
description: "The paste raw content"
67+
404:
68+
description: "The provided paste id does not exist or has expired"
69+
/api/pastes/{paste_id}/meta:
70+
parameters:
71+
- name: paste_id
72+
example: be4Q5k2K0L
73+
schema:
74+
type: string
75+
in: path
76+
required: true
77+
get:
78+
tags:
79+
- Paste
80+
summary: "Get a paste's meta"
81+
responses:
82+
200:
83+
description: "The paste's meta"
84+
content:
85+
application/json:
86+
schema: { $ref: "#/components/schemas/Paste" }
87+
404:
88+
description: "The provided paste id does not exist or has expired"
89+
90+
components:
91+
schemas:
92+
PasteCreate:
93+
type: object
94+
required:
95+
- content
96+
properties:
97+
content:
98+
type: string
99+
expire_dt:
100+
type: string
101+
format: date-time
102+
lexer_name:
103+
type: string
104+
example: python
105+
long_id:
106+
type: boolean
107+
default: false
108+
title:
109+
type: string
110+
Paste:
111+
type: object
112+
required:
113+
- paste_id
114+
- creation_dt
115+
properties:
116+
paste_id:
117+
type: string
118+
example: be4Q5k2K0L
119+
creation_dt:
120+
type: string
121+
format: date-time
122+
expire_dt:
123+
type: string
124+
format: date-time
125+
lexer_name:
126+
type: string
127+
example: python
128+
long_id:
129+
type: boolean
130+
default: false
131+
title:
132+
type: string
133+
version:
134+
type: integer
135+
default: 1
136+
137+
requestBodies:
138+
PasteCreate:
139+
content:
140+
application/json:
141+
schema:
142+
allOf: [{ $ref: "#/components/schemas/PasteCreate" }]
143+
description: ""
144+
required: true

docs/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ It is a place to quickly paste some text and share it. Mostly used for sharing d
1515
- Uses minimal resources
1616
- REST API
1717
- No Database needed, everything stored as flat-files
18+
- Caching (Internal & Redis)
1819
- Lightweight Docker image (uses Alpine Linux)
1920

2021
## Showcase

docs/install.md

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ All configs shown here should be given as environment variables.
1818
| Name | Description | Default | Docker Default |
1919
| :------------------------------- | :----------------------------------------------------------------- | :------------ | :------------- |
2020
| PASTE_ROOT | Where the paste flat file system will be kept | | /app/data |
21+
| TIME_ZONE | The time-zone where your clients are (used in web UI) | Europe/London | Europe/London |
2122
| NEW_AT_INDEX | Index page displays new paste page instead | False | False |
2223
| ENABLE_PUBLIC_LIST | Whether to enable public access for listing pastes | False | False |
2324
| | | | |
@@ -28,8 +29,8 @@ All configs shown here should be given as environment variables.
2829
| UI_DEFAULT__EXPIRE_TIME__DAYS | Default days in ui for expiry if enabled | 0 | 0 |
2930
| | | | |
3031
| CACHE__ENABLE | Whether to enable caching of any type | True | True |
31-
| CACHE__MAX_INTERNAL_SIZE | The max size of the internal cache | 4 | 4 |
32-
| CACHE__REDIS_URI | Use redis for caching (disabled internal) | - | - |
32+
| CACHE__INTERNAL_MAX_SIZE | The max size of the internal cache (<=0 to disable) | 4 | 4 |
33+
| CACHE__REDIS_URI | Use redis for caching | - | - |
3334
| | | | |
3435
| BRANDING__TITLE | Customise the app title | - | - |
3536
| BRANDING__DESCRIPTION | Customise the app description | - | - |
@@ -64,6 +65,15 @@ e.g
6465
CACHE__REDIS_URI="redis://localhost:6379"
6566
```
6667

68+
### Cache
69+
Hasty Paste supports tired caching. For example both the internal cache and Redis cache can be used. The priority of the cache types are shown below:
70+
71+
```
72+
Internal -> Redis -> Miss
73+
```
74+
75+
If you are using multiple workers (set via `WORKERS`), each worker does **not** share memory. This means when using the internal cache, each cached item will be duplicated across workers (increasing memory usage). If this is the case you may want to use Redis and select a smaller internal cache size.
76+
6777
## With Docker (Recommended)
6878
This will assume you have both Docker and Docker Compose installed.
6979

@@ -87,6 +97,7 @@ services:
8797
- 8000:8000
8898
environment:
8999
- "UI_DEFAULT__USE_LONG_ID=False"
100+
- "TIME_ZONE=Europe/London"
90101

91102
volumes:
92103
data:
@@ -113,6 +124,7 @@ services:
113124
- 8000:8000
114125
environment:
115126
- "UI_DEFAULT__USE_LONG_ID=False"
127+
- "TIME_ZONE=Europe/London"
116128
- "CACHE__REDIS_URI=redis://redis:6379"
117129
depends_on:
118130
- redis

0 commit comments

Comments
 (0)