Add QR, codes, improve mobile UI, add patch_no_tensorflow.sh

pull/12/head
Cesura 4 years ago
parent 074c16f3a0
commit cafbb2d8fe

@ -6,7 +6,7 @@ from os import environ
from distutils.util import strtobool
from threading import Thread
pastey_version = "0.3.1"
pastey_version = "0.4"
loaded_config = {}
loaded_themes = []
@ -36,6 +36,8 @@ config.purge_interval = int(environ["PASTEY_PURGE_INTERVAL"]) if "PASTEY_PURGE_I
config.force_show_recent = bool(strtobool(environ["PASTEY_FORCE_SHOW_RECENT"])) if "PASTEY_FORCE_SHOW_RECENT" in environ else config.force_show_recent
config.ignore_guess = environ["PASTEY_IGNORE_GUESS"].split(",") if "PASTEY_IGNORE_GUESS" in environ else config.ignore_guess
config.show_cli_button = bool(strtobool(environ["PASTEY_SHOW_CLI_BUTTON"])) if "PASTEY_SHOW_CLI_BUTTON" in environ else config.show_cli_button
config.force_https_links = bool(strtobool(environ["PASTEY_FORCE_HTTPS_LINKS"])) if "PASTEY_FORCE_HTTPS_LINKS" in environ else config.force_https_links
config.override_domain = environ["PASTEY_OVERRIDE_DOMAIN"] if "PASTEY_OVERRIDE_DOMAIN" in environ else config.override_domain
# Main loop
if __name__ == "__main__":

@ -85,3 +85,10 @@ def is_expired(paste):
return True
return False
# Build a URL, accounting for config options
def build_url(request, path="/"):
protocol = request.url.split('//')[0] if not config.force_https_links else "https:"
domain = request.url.split('//')[1].split("/")[0] if config.override_domain == "" else config.override_domain
return protocol + "//" + domain + path

@ -50,3 +50,14 @@ ignore_guess = ['TeX', 'SQL']
# Show CLI button on home page
show_cli_button = True
# Include https in the generated links instead of http
# This assumes you are behind something else doing the SSL
# termination, but want the users to see https links
force_https_links = False
# This can be used to specify a different domain for generated links
#
# Note: exclude the http:// or https:// prefix, as well as anything
# following the domain (except the port, if applicable)
override_domain = ""

@ -31,7 +31,7 @@ def home():
themes=loaded_themes,
force_show_recent=config.force_show_recent,
show_cli_button=config.show_cli_button,
script_url=request.url.rsplit('/', 1)[0] + "/pastey")
script_url=common.build_url(request, "/pastey"))
# New paste page
@app.route("/new")
@ -51,7 +51,7 @@ def config_page():
return render_template("config.html",
config_items=loaded_config,
script_url=request.url.rsplit('/', 1)[0] + "/pastey",
script_url=common.build_url(request, "/pastey"),
whitelisted=whitelisted,
active_theme=common.set_theme(request),
themes=loaded_themes)
@ -64,7 +64,7 @@ def view(unique_id):
if content is not None:
return render_template("view.html",
paste=content,
url=request.url,
url=common.build_url(request, "/view/" + unique_id),
whitelisted=common.verify_whitelist(common.get_source_ip(request)),
active_theme=common.set_theme(request),
themes=loaded_themes)
@ -81,7 +81,7 @@ def view_key(unique_id, key):
elif content is not None:
return render_template("view.html",
paste=content,
url=request.url,
url=common.build_url(request, "/view/" + unique_id + "/" + key),
whitelisted=common.verify_whitelist(common.get_source_ip(request)),
active_theme=common.set_theme(request),
themes=loaded_themes)
@ -101,7 +101,7 @@ def delete(unique_id):
# Script download
@app.route("/pastey")
def pastey_script():
return render_template('pastey.sh', endpoint=request.url.rsplit('/', 1)[0] + "/raw"), 200, {
return render_template('pastey.sh', endpoint=common.build_url(request, "/raw")), 200, {
'Content-Disposition': 'attachment; filename="pastey"',
'Content-Type': 'text/plain'
}
@ -147,7 +147,7 @@ def raw():
# Create paste
unique_id, key = functions.new_paste("Untitled", request.data.decode('utf-8'), source_ip, single=False, encrypt=False)
link = request.url.rsplit('/', 1)[0] + "/view/" + unique_id
link = common.build_url(request, "/view/" + unique_id)
return link, 200

@ -0,0 +1,13 @@
#!/bin/bash
# Patch functions.py
sed -i '/^[^#]/ s/\(^.*guesses = guess.probabilities.*$\)/#\ \1/' pastey/functions.py
sed -i '/^[^#]/ s/\(^.*from __main__ import guess.*$\)/#\ \1/' pastey/functions.py
sed -i '/^[^#]/ s/\(^.*language = guesses.*$\)/ language = "Plaintext"/' pastey/functions.py
# Patch app.py
sed -i '/^[^#]/ s/\(^.*from guesslang import Guess.*$\)/#\ \1/' app.py
sed -i '/^[^#]/ s/\(^.*guess = Guess().*$\)/#\ \1/' app.py
# Patch requirements.txt
sed -i '/^[^#]/ s/\(^.*guesslang.*$\)/#\ \1/' requirements.txt

@ -10,12 +10,19 @@
.pastey-checkbox {
margin-bottom:20px;
}
.pastey-view-button, .pastey-view-url {
margin-bottom:20px;
}
}
.tooltip {
pointer-events: none;
}
.pastey-view-button {
box-sizing: content-box;
}
.prettyprint {
overflow-x: auto;
white-space: pre-wrap;

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -41,10 +41,18 @@ body, tr {
color: rgba(255, 255, 255);
}
.pastey-navbar-toggler {
color: rgb(255,255,255) !important;
}
.nocode {
color: rgb(255,255,255) !important;
}
.modal-title {
color: rgb(0,0,0);
}
/* Google prettify elements */
/* Alternating line colors */

@ -19,12 +19,25 @@
<nav class="navbar navbar-expand-lg fixed-top bg-white pastey-navbar">
<div class="container-fluid">
<!-- Toggle button -->
<button
class="navbar-toggler"
type="button"
data-mdb-toggle="collapse"
data-mdb-target="#pasteyNavbarContainer"
aria-controls="pasteyNavbarContainer"
aria-expanded="false"
aria-label="Toggle navigation"
>
<i class="fas fa-bars pastey-navbar-toggler"></i>
</button>
<!-- Navbar logo -->
<a class="navbar-brand" href="/">
<div class="pastey-logo" style="margin-top: -3px;"></div>
</a>
<div class="collapse navbar-collapse">
<div class="collapse navbar-collapse" id="pasteyNavbarContainer">
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
<li class="nav-item active">
<a class="nav-link pastey-link" href="/">Home</a>

@ -19,12 +19,25 @@
<nav class="navbar navbar-expand-lg fixed-top bg-white pastey-navbar">
<div class="container-fluid">
<!-- Toggle button -->
<button
class="navbar-toggler"
type="button"
data-mdb-toggle="collapse"
data-mdb-target="#pasteyNavbarContainer"
aria-controls="pasteyNavbarContainer"
aria-expanded="false"
aria-label="Toggle navigation"
>
<i class="fas fa-bars pastey-navbar-toggler"></i>
</button>
<!-- Navbar logo -->
<a class="navbar-brand" href="/">
<div class="pastey-logo" style="margin-top: -3px;"></div>
</a>
<div class="collapse navbar-collapse">
<div class="collapse navbar-collapse" id="pasteyNavbarContainer">
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
<li class="nav-item active">
<a class="nav-link pastey-link" href="/">Home</a>

@ -19,12 +19,25 @@
<nav class="navbar navbar-expand-lg fixed-top bg-white pastey-navbar">
<div class="container-fluid">
<!-- Toggle button -->
<button
class="navbar-toggler"
type="button"
data-mdb-toggle="collapse"
data-mdb-target="#pasteyNavbarContainer"
aria-controls="pasteyNavbarContainer"
aria-expanded="false"
aria-label="Toggle navigation"
>
<i class="fas fa-bars pastey-navbar-toggler"></i>
</button>
<!-- Navbar logo -->
<a class="navbar-brand" href="/">
<div class="pastey-logo" style="margin-top: -3px;"></div>
</a>
<div class="collapse navbar-collapse">
<div class="collapse navbar-collapse" id="pasteyNavbarContainer">
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
<li class="nav-item active">
<a class="nav-link pastey-link" href="/">Home</a>
@ -114,14 +127,13 @@
</div>
</div><br />
<div class="row">
<div class="col-md-3"></div>
<div class="col-md-5">
<div class="row justify-content-md-center">
<div class="col-md-4">
<input class="form-control pastey-input" id="paste-url" type="text" value="{{ script_url }}" readonly />
</div>
<div class="col-md-1">
<a href="{{ script_url }}">
<button type="button" class="btn btn-success">Download</button>
<button type="button" class="btn btn-success text-nowrap"><i class="fas fa-download"></i>&nbsp;&nbsp;&nbsp;Download</button>
</a>
</div>
</div>

@ -20,12 +20,25 @@
<nav class="navbar navbar-expand-lg fixed-top bg-white pastey-navbar">
<div class="container-fluid">
<!-- Toggle button -->
<button
class="navbar-toggler"
type="button"
data-mdb-toggle="collapse"
data-mdb-target="#pasteyNavbarContainer"
aria-controls="pasteyNavbarContainer"
aria-expanded="false"
aria-label="Toggle navigation"
>
<i class="fas fa-bars pastey-navbar-toggler"></i>
</button>
<!-- Navbar logo -->
<a class="navbar-brand" href="/">
<div class="pastey-logo" style="margin-top: -3px;"></div>
</a>
<div class="collapse navbar-collapse">
<div class="collapse navbar-collapse" id="pasteyNavbarContainer">
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
<li class="nav-item active">
<a class="nav-link pastey-link" aria-current="page" href="/">Home</a>
@ -80,14 +93,14 @@
<p class="mb-3">A lightweight, self-hosted paste platform</p><br />
<div class="row justify-content-md-center">
<div class="col-md-2">
<a class="btn btn-primary text-nowrap m-2" href="/new" role="button" rel="nofollow">New Paste</a>
<a class="btn btn-primary text-nowrap m-2" href="/new" role="button" rel="nofollow"><i class="fas fa-plus"></i>&nbsp;&nbsp;&nbsp;New Paste</a>
</div>
{% if show_cli_button %}
<div class="col-md-2">
<a class="btn btn-success text-nowrap m-2" href="{{ script_url }}" role="button"
data-mdb-toggle="tooltip"
title="Pastey provides a script that can be used to pipe output directly from the command line">Use CLI</a>
title="Pastey provides a script that can be used to pipe output directly from the command line"><i class="fas fa-terminal"></i>&nbsp;&nbsp;&nbsp;Use CLI</a>
</div>
{% endif %}
</div>
@ -115,7 +128,7 @@
<div class="col-md-8 mb-4">
{% if whitelisted %}
<a class="btn btn-danger m-2" href="/delete/{{ paste.unique_id }}" role="button" style="float:right;">Delete</a>
<a class="btn btn-danger m-2" href="/delete/{{ paste.unique_id }}" role="button" style="float:right;"><i class="fas fa-trash"></i>&nbsp;&nbsp;&nbsp;Delete</a>
{% endif %}
<h5>{{ paste.title }}</h5>

@ -19,12 +19,25 @@
<nav class="navbar navbar-expand-lg fixed-top bg-white pastey-navbar">
<div class="container-fluid">
<!-- Toggle button -->
<button
class="navbar-toggler"
type="button"
data-mdb-toggle="collapse"
data-mdb-target="#pasteyNavbarContainer"
aria-controls="pasteyNavbarContainer"
aria-expanded="false"
aria-label="Toggle navigation"
>
<i class="fas fa-bars pastey-navbar-toggler"></i>
</button>
<!-- Navbar logo -->
<a class="navbar-brand" href="/">
<div class="pastey-logo" style="margin-top: -3px;"></div>
</a>
<div class="collapse navbar-collapse">
<div class="collapse navbar-collapse" id="pasteyNavbarContainer">
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
<li class="nav-item active">
<a class="nav-link pastey-link" href="/">Home</a>
@ -109,7 +122,7 @@
<input class="form-check-input" type="checkbox" value="" id="encrypt" name="encrypt"
data-mdb-toggle="tooltip" title="Your paste's content will not be accessible without its accompanying decryption key" />
<label class="form-check-label" for="encrypt">
Encrypt
Encrypt&nbsp;&nbsp;&nbsp;<i class="fas fa-lock"></i>
</label>
</div>
</div>
@ -137,7 +150,7 @@
</div>
<div class="col-md-1"></div>
<div class="col-md-4">
<button type="submit" class="btn btn-primary btn-block">Paste</button>
<button type="submit" class="btn btn-primary btn-block"><i class="fas fa-check"></i>&nbsp;&nbsp;&nbsp;Paste</button>
</div>
</div>
</form>

@ -21,12 +21,25 @@
<nav class="navbar navbar-expand-lg fixed-top bg-white pastey-navbar">
<div class="container-fluid">
<!-- Toggle button -->
<button
class="navbar-toggler"
type="button"
data-mdb-toggle="collapse"
data-mdb-target="#pasteyNavbarContainer"
aria-controls="pasteyNavbarContainer"
aria-expanded="false"
aria-label="Toggle navigation"
>
<i class="fas fa-bars pastey-navbar-toggler"></i>
</button>
<!-- Navbar logo -->
<a class="navbar-brand" href="/">
<div class="pastey-logo" style="margin-top: -3px;"></div>
</a>
<div class="collapse navbar-collapse">
<div class="collapse navbar-collapse" id="pasteyNavbarContainer">
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
<li class="nav-item active">
<a class="nav-link pastey-link" href="/">Home</a>
@ -88,13 +101,19 @@
{% if paste.expiration is defined and paste.expiration != "" %}
<span style="font-weight:bold;">Expires: </span><span>{{ paste.expiration }}</span><br />
{% endif %}<br />
<div class="row">
<div class="col-md-3"></div>
<div class="row justify-content-md-center">
<div class="col-md-1" style="min-width: 140px;">
<button type="button" class="btn btn-secondary text-nowrap pastey-view-button"
data-mdb-toggle="modal"
data-mdb-target="#qrModal">
<i class="fas fa-qrcode"></i>&nbsp;&nbsp;&nbsp;QR Code
</button>
</div>
<div class="col-md-5">
<input class="form-control pastey-input" id="paste-url" type="text" value="{{ url }}" readonly />
<input class="form-control pastey-input pastey-view-url" id="paste-url" type="text" value="{{ url }}" readonly />
</div>
<div class="col-md-1">
<button type="button" class="btn btn-success text-nowrap" onclick="copyToClipboard()">Copy Link</button>
<button type="button" class="btn btn-success text-nowrap pastey-view-button" onclick="copyToClipboard()"><i class="fas fa-copy"></i>&nbsp;&nbsp;&nbsp;Copy Link</button>
</div>
</div>
{% if paste.uses == 0 %}
@ -111,20 +130,65 @@
<!--Main layout-->
<main class="my-5">
<div class="container">
<form action="/paste" method="POST">
<div class="row">
<div class="col-md-12 mb-4">
<pre class="prettyprint linenums">{{ paste.content }}</pre>
</div>
</div>
</form>
<!-- QR Modal -->
<div
class="modal fade"
id="qrModal"
tabindex="-1"
aria-labelledby="qrModalLabel"
aria-hidden="true"
>
<div class="modal-dialog modal-dialog-centered">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="qrModalLabel">QR Code</h5>
<button
type="button"
class="btn-close"
data-mdb-dismiss="modal"
aria-label="Close"
></button>
</div>
<div class="modal-body">
<div id="qrcode" style="display: flex; justify-content: center;"></div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-danger" data-mdb-dismiss="modal">
Close
</button>
</div>
</div>
</div>
</div>
</div>
</main>
<!--Main layout-->
<!--JS-->
<script type="text/javascript" src="/static/js/jquery.min.js"></script>
<script type="text/javascript" src="/static/js/qrcode.min.js"></script>
<script type="text/javascript" src="/static/js/mdb.min.js"></script>
<script type="text/javascript" src="/static/js/common.js"></script>
<script src="/static/js/prettify.min.js"></script>
<script src="/static/js/run_prettify.js"></script></body>
<script type="text/javascript" src="/static/js/prettify.min.js"></script>
<script type="text/javascript" src="/static/js/run_prettify.js"></script>
<!-- Generate QR code -->
<script type="text/javascript">
var qrcode = new QRCode("qrcode", {
text: "{{ url }}",
width: 256,
height: 256,
colorDark : "#000000",
colorLight : "#ffffff",
correctLevel : QRCode.CorrectLevel.H
});
</script>
</body>
</html>
Loading…
Cancel
Save