kopia lustrzana https://github.com/dgtlmoon/changedetection.io
Bulk import
rodzic
abef169382
commit
016937d5de
|
@ -103,6 +103,35 @@ def edit_page():
|
||||||
output = render_template("edit.html", uuid=uuid, watch=datastore.data['watching'][uuid], messages=messages)
|
output = render_template("edit.html", uuid=uuid, watch=datastore.data['watching'][uuid], messages=messages)
|
||||||
return output
|
return output
|
||||||
|
|
||||||
|
@app.route("/import", methods=['GET', "POST"])
|
||||||
|
def import_page():
|
||||||
|
import validators
|
||||||
|
global messages
|
||||||
|
remaining_urls=[]
|
||||||
|
|
||||||
|
good = 0
|
||||||
|
|
||||||
|
if request.method == 'POST':
|
||||||
|
urls = request.values.get('urls').split("\n")
|
||||||
|
for url in urls:
|
||||||
|
url = url.strip()
|
||||||
|
if len(url) and validators.url(url):
|
||||||
|
datastore.add_watch(url=url.strip(), tag="")
|
||||||
|
good += 1
|
||||||
|
else:
|
||||||
|
if len(url):
|
||||||
|
remaining_urls.append(url)
|
||||||
|
|
||||||
|
messages.append({'class': 'ok', 'message': "{} imported, {} skipped.".format(good, len(remaining_urls))})
|
||||||
|
|
||||||
|
launch_checks()
|
||||||
|
|
||||||
|
output = render_template("import.html",
|
||||||
|
messages=messages,
|
||||||
|
remaining="\n".join(remaining_urls)
|
||||||
|
)
|
||||||
|
return output
|
||||||
|
|
||||||
|
|
||||||
@app.route("/favicon.ico", methods=['GET'])
|
@app.route("/favicon.ico", methods=['GET'])
|
||||||
def favicon():
|
def favicon():
|
||||||
|
|
|
@ -124,6 +124,7 @@ body:after, body:before {
|
||||||
.edit-form {
|
.edit-form {
|
||||||
background: #fff;
|
background: #fff;
|
||||||
padding: 2em;
|
padding: 2em;
|
||||||
|
margin: 1em;
|
||||||
border-radius: 5px;
|
border-radius: 5px;
|
||||||
}
|
}
|
||||||
.button-secondary {
|
.button-secondary {
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
|
|
||||||
<div class="header">
|
<div class="header">
|
||||||
<div class="home-menu pure-menu pure-menu-horizontal pure-menu-fixed">
|
<div class="home-menu pure-menu pure-menu-horizontal pure-menu-fixed">
|
||||||
<a class="pure-menu-heading" href=""><strong>Change</strong>Detection.io</a>
|
<a class="pure-menu-heading" href="/"><strong>Change</strong>Detection.io</a>
|
||||||
|
|
||||||
<ul class="pure-menu-list">
|
<ul class="pure-menu-list">
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
{% extends 'base.html' %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<div class="edit-form">
|
||||||
|
|
||||||
|
|
||||||
|
<form class="pure-form pure-form-aligned" action="/import" method="POST">
|
||||||
|
|
||||||
|
<fieldset class="pure-group">
|
||||||
|
<legend>One URL per line, URLs that do not pass validation will stay in the textarea.</legend>
|
||||||
|
|
||||||
|
<textarea name="urls" class="pure-input-1-2" placeholder="https://" cols="150" style="width: 100%;font-family:monospace;" rows="25">{{ remaining }}</textarea>
|
||||||
|
</fieldset>
|
||||||
|
<button type="submit" class="pure-button pure-input-1-2 pure-button-primary">Import</button>
|
||||||
|
|
||||||
|
</form>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{% endblock %}
|
||||||
|
|
Ładowanie…
Reference in New Issue