export
This commit is contained in:
+26
-1
@@ -2,6 +2,7 @@ from flask import render_template, request, jsonify, send_from_directory
|
||||
from www import app
|
||||
import json, logging
|
||||
from selection import sel
|
||||
from export import exportxml, exportlist
|
||||
import urllib.parse
|
||||
import urllib.request
|
||||
import config
|
||||
@@ -48,11 +49,35 @@ def tags_w_lists():
|
||||
if a == "dump":
|
||||
if sel.commit_from_selection():
|
||||
return "done"
|
||||
if a == "delete":
|
||||
elif a == "delete":
|
||||
if sel.delete_url(data.get('tag'), data.get('url')):
|
||||
return "ok"
|
||||
elif a == "export":
|
||||
pass
|
||||
return "-"
|
||||
|
||||
@app.route('/export', methods = ['POST'])
|
||||
def export():
|
||||
if request.method == 'POST':
|
||||
data = request.form
|
||||
a = data.get('action')
|
||||
if a == "export":
|
||||
if exportxml.export_selection_tag(data.get('tagid'), xml_out=data.get('exportpath')):
|
||||
return 'ok'
|
||||
elif a == "export_all":
|
||||
if exportxml.export_selection_all():
|
||||
return 'ok'
|
||||
return "-"
|
||||
|
||||
@app.route('/ex/<path:fn>')
|
||||
def ex(fn):
|
||||
if fn == "all":
|
||||
return render_template("ex_all.html", files=exportlist.list_all())
|
||||
else:
|
||||
e = exportlist.get(fn)
|
||||
if e:
|
||||
return render_template("chapter.html", chapter=e['chapter'])
|
||||
return "Request for " + fn + " failed..."
|
||||
|
||||
@app.route('/report')
|
||||
def report():
|
||||
|
||||
@@ -40,3 +40,21 @@ bb {
|
||||
li button {
|
||||
margin-top: 0em;
|
||||
}
|
||||
|
||||
.header {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.payload {
|
||||
white-space: pre-wrap;
|
||||
font-family: monospace;
|
||||
display: block;
|
||||
unicode-bidi: embed;
|
||||
border: 2px solid red;
|
||||
word-wrap: break-word;
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
.mail {
|
||||
width: 35em;
|
||||
}
|
||||
|
||||
@@ -26,4 +26,29 @@ $(document).ready(function(){
|
||||
});
|
||||
});
|
||||
|
||||
$('.export').click(function(e) {
|
||||
var form = $(this).parent("form");
|
||||
var g = form.serialize() + "&tagid=" + form.data('tagid') + "&action=export";
|
||||
$('#status').text("Exporting - " + form.data('tagid'))
|
||||
$.post('/export', g, function(d) {
|
||||
if(d === 'ok') {
|
||||
$('#status').text("Exporting - " + form.data('tagid') + " - success!!!")
|
||||
} else {
|
||||
$('#status').text("Exporting - " + form.data('tagid') + " - error...")
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$('#export_all').click(function(a){
|
||||
var g = "&action=export_all";
|
||||
$('#status').text("Exporting - all")
|
||||
$.post('/export', g, function(d) {
|
||||
if(d === 'ok') {
|
||||
$('#status').text("Exporting - all - success!!!")
|
||||
} else {
|
||||
$('#status').text("Exporting - all - error...")
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
@@ -0,0 +1,27 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Chapter: {{chapter.title}}</title>
|
||||
<link rel="stylesheet" href="{{ url_for('static',filename='lestyle.css') }}">
|
||||
</head>
|
||||
<body>
|
||||
<h1>{{chapter.title}}</h1>
|
||||
<h2>{{chapter.desc}}</h2>
|
||||
<div id="all">
|
||||
{% for m in chapter.mails.mail %}
|
||||
<div class="mail">
|
||||
<hr>
|
||||
<div class="header">
|
||||
<div class="field">From: {{m.from}}</div>
|
||||
<div class="field">To: {{m.to}}</div>
|
||||
<div class="field">Date: {{m.date}}</div>
|
||||
<div class="field">Subject: {{m.subject}}</div>
|
||||
</div>
|
||||
<div class="payload">
|
||||
{{m.content}}
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,16 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Exports [all]</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Exports [all] - [<a href="/search" target="_blank">SEARCH</a>, <a href="/tags" target="_blank">TAGS</a>]</h1>
|
||||
<div id="all">
|
||||
<ul>
|
||||
{% for f in files %}
|
||||
<li><a href="/ex/{{f}}">{{f}}</a></li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -7,11 +7,10 @@
|
||||
<script type="text/javascript" src="{{ url_for('static',filename='tags_w_lists.js') }}"></script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Selection [tags w lists]</h1>
|
||||
<h1>Selection [tags w lists] - [<a href="/search" target="_blank">SEARCH</a>, <a href="/tags" target="_blank">TAGS</a>]</h1>
|
||||
<hr>
|
||||
<h2><a href="/search" target="_blank">SEARCH</a></h2>
|
||||
<h2><a href="/tags" target="_blank">TAGS</a></h2>
|
||||
<!-- <button id="commit">commit</button> -->
|
||||
<div id="status">Ok</div>
|
||||
<button id="export_all">export all</button>
|
||||
<div id="all">
|
||||
{% for v in tags %}
|
||||
<hr>
|
||||
@@ -19,8 +18,10 @@
|
||||
<form class="tag_item" id="{{v.tag}}" method="post" data-tagid="{{v.tag}}">
|
||||
<input name="tag" class="tagedit" type="text" value="{{v.tag}}">
|
||||
<textarea name="desc">{{v.desc}}</textarea>
|
||||
<input name="exportpath" class="tagedit export" type="text" value="{{v.export}}">
|
||||
<input type="submit" class="update" value="update">
|
||||
<input type="submit" class="delete" value="delete">
|
||||
<input type="submit" class="export" value="export">
|
||||
</form>
|
||||
<lists>
|
||||
<ul>
|
||||
|
||||
Reference in New Issue
Block a user