aboutsummaryrefslogtreecommitdiff
path: root/flakes/paste
diff options
context:
space:
mode:
Diffstat (limited to 'flakes/paste')
-rw-r--r--flakes/paste/flake.nix2
-rw-r--r--flakes/paste/paste/paste.py29
2 files changed, 30 insertions, 1 deletions
diff --git a/flakes/paste/flake.nix b/flakes/paste/flake.nix
index 08d0681..97e31c8 100644
--- a/flakes/paste/flake.nix
+++ b/flakes/paste/flake.nix
@@ -45,6 +45,8 @@
45 let 45 let
46 cfg = config.services.paste; 46 cfg = config.services.paste;
47 in { 47 in {
48 # Necessary for situations where flake gets included multiple times
49 key = builtins.hashString "sha256" (builtins.path { path = self.sourceInfo.outPath; name = "source"; });
48 options = { 50 options = {
49 services.paste = { 51 services.paste = {
50 enable = lib.mkOption { 52 enable = lib.mkOption {
diff --git a/flakes/paste/paste/paste.py b/flakes/paste/paste/paste.py
index 86666b8..3172de5 100644
--- a/flakes/paste/paste/paste.py
+++ b/flakes/paste/paste/paste.py
@@ -10,9 +10,32 @@ import mimetypes
10 10
11magic = magic.Magic(mime=True) 11magic = magic.Magic(mime=True)
12 12
13mit_license = """
14Copyright (c) 2022 Immae
15
16Permission is hereby granted, free of charge, to any person obtaining a copy
17of this software and associated documentation files (the "Software"), to deal
18in the Software without restriction, including without limitation the rights
19to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
20copies of the Software, and to permit persons to whom the Software is
21furnished to do so, subject to the following conditions:
22
23The above copyright notice and this permission notice shall be included in all
24copies or substantial portions of the Software.
25
26THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
27IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
28FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
29AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
30LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
31OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
32SOFTWARE.
33"""
34
13config = { 35config = {
14 "directory": os.environ["PASTE_DIRECTORY"], 36 "directory": os.environ["PASTE_DIRECTORY"],
15 "self_paste_id": "abcd123", 37 "self_paste_id": "abcd123",
38 "license_paste_id": "license",
16 "max_content_length": 16 * 1000 * 1000 39 "max_content_length": 16 * 1000 * 1000
17 } 40 }
18 41
@@ -33,6 +56,8 @@ def read_paste(paste_id):
33 if mime.startswith("text/x-script."): 56 if mime.startswith("text/x-script."):
34 mime="text/plain" 57 mime="text/plain"
35 return (content, mime) 58 return (content, mime)
59 elif paste_id == config["license_paste_id"]:
60 return (mit_license, "text/plain")
36 else: 61 else:
37 abort(404) 62 abort(404)
38 63
@@ -69,9 +94,11 @@ $ curl -X POST --data-binary @{self} {host}
69-> GET {paste}/download 94-> GET {paste}/download
70 force download of file 95 force download of file
71</pre> 96</pre>
72<a href="{paste}/py">Get the source</a> 97<a href="{paste}/py">Get the source</a><br />
98Software licensed under the terms of the <a href="{host}/license">MIT license</a>
73'''.format(host=url_for('post_paste', _external=True, _scheme="https"), 99'''.format(host=url_for('post_paste', _external=True, _scheme="https"),
74 paste=url_for('get_paste', _external=True, _scheme="https", paste_id=config["self_paste_id"]), 100 paste=url_for('get_paste', _external=True, _scheme="https", paste_id=config["self_paste_id"]),
101 license=url_for('get_paste', _external=True, _scheme="https", paste_id=config["license_paste_id"]),
75 self=os.path.basename(__file__) 102 self=os.path.basename(__file__)
76 ), mimetype="text/html") 103 ), mimetype="text/html")
77 104