clipboard

master
km0 3 years ago
parent 7102ca7f4c
commit 343b843790

@ -1,10 +1,12 @@
import os import os
class Config(object): class Config(object):
DEBUG = False DEBUG = False
TESTING = False TESTING = False
URL_PREFIX = '' URL_PREFIX = ''
class ProductionConfig(Config): class ProductionConfig(Config):
DEBUG = False DEBUG = False
URL_PREFIX = os.environ.get("URL_PREFIX") URL_PREFIX = os.environ.get("URL_PREFIX")
@ -13,3 +15,4 @@ class ProductionConfig(Config):
class DevelopmentConfig(Config): class DevelopmentConfig(Config):
ENV = "development" ENV = "development"
DEVELOPMENT = True DEVELOPMENT = True
DEBUG = True

@ -1,7 +1,8 @@
import os import os
from flask import Flask from flask import Flask, send_from_directory
from . import prefix from . import prefix
def create_app(test_config=None): def create_app(test_config=None):
# create and configure the app # create and configure the app
app = Flask(__name__, instance_relative_config=True) app = Flask(__name__, instance_relative_config=True)
@ -26,6 +27,12 @@ def create_app(test_config=None):
from . import db from . import db
db.init_app(app) db.init_app(app)
@app.route("/favicon.ico")
def favicon():
return send_from_directory(
os.path.join(app.root_path, "static"), "favicon.ico", mimetype="image/vnd.microsoft.icon",
)
from . import draw from . import draw
app.register_blueprint(draw.bp) app.register_blueprint(draw.bp)
@ -38,8 +45,7 @@ def create_app(test_config=None):
from . import home from . import home
app.register_blueprint(home.bp) app.register_blueprint(home.bp)
app.wsgi_app = prefix.PrefixMiddleware(
app.wsgi_app, prefix=os.environ.get("URL_PREFIX", ''))
app.wsgi_app = prefix.PrefixMiddleware(app.wsgi_app, prefix=os.environ.get("URL_PREFIX", ''))
return app return app

@ -2,6 +2,7 @@ html,
body { body {
margin: 0; margin: 0;
background-color: var(--background); background-color: var(--background);
font-size: 1.25rem;
} }
* { * {

@ -0,0 +1,28 @@
.share {
width: 100vw;
height: 100vh;
line-height: 2;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}
a {
color: currentColor;
text-decoration: none;
}
button.clipboard {
background: none;
border: none;
text-decoration: underline;
cursor: pointer;
font-size: 1rem;
}
button.clipboard:hover {
color: dodgerblue;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

@ -0,0 +1,22 @@
copies = document.querySelectorAll("[data-copy]");
Array.from(copies).forEach((copy) => {
clipboard = document.createElement("button");
clipboard.classList.add("clipboard");
clipboard.innerHTML = "Copy to clipboard";
insertAfter(clipboard, copy);
clipboard.addEventListener("click", (e) => {
navigator.clipboard.writeText(copy.dataset.copy).then(
function () {
clipboard.innerHTML = "Copied!";
},
function (err) {
console.error("Async: Could not copy text: ", err);
}
);
});
});
function insertAfter(newNode, referenceNode) {
referenceNode.parentNode.insertBefore(newNode, referenceNode.nextSibling);
}

@ -8,12 +8,16 @@
<link rel="stylesheet" href="{{url_for('static', filename='css/variables.css')}}" /> <link rel="stylesheet" href="{{url_for('static', filename='css/variables.css')}}" />
<link rel="stylesheet" href="{{url_for('static', filename='css/global.css')}}" /> <link rel="stylesheet" href="{{url_for('static', filename='css/global.css')}}" />
<link rel="stylesheet" href="{{url_for('static', filename='css/share.css')}}" /> <link rel="stylesheet" href="{{url_for('static', filename='css/share.css')}}" />
<script src="{{url_for('static', filename='js/copy.js')}}" defer></script>
</head> </head>
<body> <body>
<div class="share"> <div class="share">
Send this link to your friends: Send this link to your friends:
<a href="{{url_for('draw.draw', parent=branch)}}" <a
>{{url_for('draw.draw', parent=branch)}}</a href="{{url_for('draw.draw', parent=branch)}}"
data-copy="{{ request.url_root[:-1] + url_for('draw.draw', parent=branch)}}"
>{{ request.url_root[:-1] + url_for('draw.draw', parent=branch)}}</a
> >
</div> </div>
</body> </body>

Loading…
Cancel
Save