var mouse_left = false;
var mouse_right = false;
if (document.addEventListener != undefined) document.addEventListener('mousemove', mouseMove, true);
-else if (document.layers) document.captureEvents(Event.MOUSEDOWN | Event.MOUSEMOVE | Event.MOUSEUP);
-document.onmousemove = mouseMove;
-document.oncontextmenu = RightMouseDown;
+else if (document.layers) document.captureEvents(Event.MOUSEDOWN | Event.MOUSEUP);
+//document.onmousemove = mouseMove;
+//document.oncontextmenu = RightMouseDown;
document.onmousedown = mouseDown;
document.onmouseup = mouseUp;
function mouseMove(a) {
- mouse_x = document.all ? event.clientX + document.body.scrollLeft : document.layers ? a.x + window.pageXOffset : a.clientX + window.pageXOffset;
- mouse_y = document.all ? event.clientY + document.body.scrollTop : document.layers ? a.y + window.pageYOffset : a.clientY + window.pageYOffset
+// mouse_x = document.all ? event.clientX + document.body.scrollLeft : document.layers ? a.x + window.pageXOffset : a.clientX + window.pageXOffset;
+// mouse_y = document.all ? event.clientY + document.body.scrollTop : document.layers ? a.y + window.pageYOffset : a.clientY + window.pageYOffset
}
-function RightMouseDown() {
- mouse_right = true;
- return false
-}
+//function RightMouseDown() {
+// mouse_right = true;
+// return false
+//}
function mouseUp(e) {
var curselection = window.getSelection().getRangeAt(0);
if (curselection.endOffset - curselection.startOffset > 0)
- selection = curselection;
- console.log(selection)
+ selection = curselection;
if (e.which == 3) mouse_right = false
}
function mouseDown(e) {
if (e.which == 3) {
mouse_right = true;
- document.getElementById("contextmenu").style.left = mouse_x + "px";
- document.getElementById("contextmenu").style.top = mouse_y + "px";
- document.getElementById("contextmenu").style.visibility = "visible"
+// document.getElementById("contextmenu").style.left = mouse_x + "px";
+// document.getElementById("contextmenu").style.top = mouse_y + "px";
+// document.getElementById("contextmenu").style.visibility = "visible"
}
}
stylizeHighlightedString(selection, "blue")
}
+function f_clear() {
+ parnt = selection.commonAncestorContainer.parentNode;
+ stopp = selection.endContainer.parentNode;
+ starp = selection.startContainer.parentNode;
+ console.log(selection);
+ if(parnt.tagName == "SPAN"){
+ superparent = parnt.parentNode;
+ var text = document.createTextNode(parnt.innerHTML);
+ superparent.insertBefore(text, parnt);
+ superparent.removeChild(parnt);
+ console.log("You selected a colored piece perfectly");
+ }
+ else {
+ if(starp.tagName == "SPAN"){
+ superparent = starp.parentNode;
+ var text = document.createTextNode(starp.innerHTML);
+ superparent.insertBefore(text, starp);
+ superparent.removeChild(starp);
+ console.log("You selected a overlap with span start");
+ }
+ }
+}
function post_all() {
var xmlhttp = new XMLHttpRequest();
# -*- codng: utf-8 -*-
import crawler
+import re
+import urllib
+import feedparser
def index(req, args, apok):
req.write(status)
elif args['action'] == 'edit':
cr = crawler.Crawler()
- req.write('<table>')
- req.write(''.join(
- '<tr><td>{}</td><td>{}</td></tr>'.format(a[0], a[1])
- for a in cr.entries[args['name']]['content']))
- req.write('</table>')
+ with open('/var/www/py/new.html.t', 'r') as f:
+ data = f.read()
+ params = {
+ 'rssname': args['name'],
+ 'url': cr.entries[args['name']]['url'],
+ 'input_data': input_data(cr.entries[args['name']]),
+ 'feed_html': str(cr.entries[args['name']]['content'])}
+ req.write(data.format(**params))
+ # req.write('<table>')
+ # req.write(''.join(
+ # '<tr><td>{}</td><td>{}</td></tr>'.format(a[0], a[1])
+ # for a in cr.entries[args['name']]['content']))
+ # req.write('</table>')
else:
req.write('Unknown editing action: {}'.format(args['action']))
req.write('<br/><a href="index.py">Go back</a>')
for k, v in sorted(respons.iteritems())))
req.write('<br/><br/><a href="index.py">Go back</a>')
return apok
+
+
+def feed2html(url, name):
+ result = ''
+ url = urllib.unquote(url)
+ url = url if re.match('https?://', url) else 'http://{}'.format(url)
+ feed = feedparser.parse(url)
+ result += '<table id="content-table" border="1" id="htab">'
+ result += '<tr><th>Title</th><th>Summary</th></tr><!--line-->'
+ for i in feed.entries[:10]:
+ result += ('<tr><td id="cel">{}</td><!--cel--><td id="cel">{}</td><!--'
+ 'cel--></tr><!--line-->').format(
+ i['title'].encode('ascii', 'xmlcharrefreplace'),
+ i['summary'].encode('ascii', 'xmlcharrefreplace'))
+ return result
+
+
+def input_data(dictio):
+ basicdict = {'venue': '', 'freq': '', 'dloc': '', 'adress': '',
+ 'adress': '', 'website': '', 'url': ''}
+ basicdict.update(dictio)
+
+ return (
+ '\t\t<tr><td>Venue: </td><td>\n'
+ '\t\t\t<input type="text" name="venue" class="indat" value="{venue}">\n'
+ '\t\t</td></tr><tr><td>Frequency: </td><td>\n'
+ '\t\t\t<input type="text" name="freq" class="indat" value="{freq}">\n'
+ '\t\t</td></tr><tr><td>Default location name: </td><td>\n'
+ '\t\t\t<input type="text" name="dloc" class="indat" value="{dloc}">\n'
+ '\t\t</td></tr><tr><td>Adress: </td><td>\n'
+ '\t\t\t<input type="text" name="adress" class="indat" value="{adress}">\n'
+ '\t\t</td></tr><tr><td>Website: </td><td>\n'
+ '\t\t\t<input type="text" name="website" class="indat" value="{website}">\n'
+ '\t\t</td></tr><tr><td>RSS URL: </td><td>\n'
+ '\t\t\t<input type="text" name="url" class="indat" value="{url}">\n'
+ '\t\t</td></tr>').format(**basicdict)
+
+
+def crawler_new(req, args, apok):
+ req.log_error('handler')
+ req.content_type = 'text/html'
+ req.send_http_header()
+ if 'name' not in args or 'url' not in args:
+ req.write('Empty name or empty url...'
+ '<br/><br/><a href="index.py">Go back</a>')
+ else:
+ with open('/var/www/py/new.html.t', 'r') as f:
+ data = f.read()
+ params = {
+ 'rssname': args['name'],
+ 'url': args['url'],
+ 'input_data': input_data({'url': args['url']}),
+ 'feed_html': feed2html(args['url'], args['name'])}
+ req.write(data.format(**params))
+ return apok
con = d['content']
d['content'] = []
d['headers'] = []
- for line in con.split('\n\t\t'):
- if not line:
+ for line in con.split('<!--line-->'):
+ if not line or '<!--cel-->' not in line:
continue
row = re_row.search(line)
row = row.group('row')
'blue': '\x04' # wanneer
}
line_w_match = []
- d['content'] = d['content'][1:]
+# d['content'] = d['content'][1:]
for i, m in enumerate(d['matchdata']):
if filter(None, m):
line_w_match.append((d['content'][i], m))
return crawl.list_names()
-def req_pre(req, args):
+def eq_pre(req, args):
req.log_error('handler')
req.content_type = 'text/html'
req.send_http_header()
return index.crawler_test(req, util.FieldStorage(req), apache.OK)
elif req.uri.split('/')[-1] == 'crawler_edit.py':
return index.crawler_edit(req, util.FieldStorage(req), apache.OK)
+ elif req.uri.split('/')[-1] == 'crawler_new.py':
+ return index.crawler_new(req, util.FieldStorage(req), apache.OK)
else:
if req.method == "POST":
req_pre_pos(req)
else:
- args = util.FieldStorage(req)
- req_pre(req, args)
- if 'url' not in args and 'name' not in args:
- req.write('Something went wrong, empty fields?<br />')
- req.write('<a href="index.html">back</a>')
- else:
- feed2html(req, args['url'], args['name'])
- req_post(req)
+ req.write('Unknown case')
return apache.OK
</form>
</td>
<td>
- <form method="get" action="./input_app.py">
+ <form method="get" action="./crawler_new.py">
<table>
<tr><td><p>RSS URL:</td><td><input type="text" name="url" value="localhost/py/paradiso.rss.xml"></td></tr>
<tr><td>RSS Name:</td><td><input type="text" name="name"></td></tr>
--- /dev/null
+<html>
+<head>
+ <title>HyperFrontend RSS feed input new</title>
+ <script src="contextmenu_o.js"></script>
+</head>
+<body>
+ <table>
+{input_data}
+ </table>
+ <button style="color:blue" onclick="javascript:f_waar()">Waar</button>
+ <button style="color:green" onclick="javascript:f_wat()">Wat</button>
+ <button style="color:red" onclick="javascript:f_wann_tijd()">Tijd</button>
+ <button style="color:darkred" onclick="javascript:f_wann_dat()">Datum</button>
+ <button onclick="javascript:f_clear()">Clear selection</button>
+ <br/>Loading "{url}" as <b><p id="rssname">{rssname}</p></b><br/>
+{feed_html}
+ <button onclick="javascript:post_all()" method="post" target="_blank">Submit</button>
+</body>
+</html>