From: Mart Lubbers Date: Thu, 25 Sep 2014 09:59:57 +0000 (+0200) Subject: last push, gui works, i think X-Git-Url: https://git.martlubbers.net/?a=commitdiff_plain;h=5d23d53d719f3a6c3901b7a221811cd8fdac9d41;p=bsc-thesis1415.git last push, gui works, i think --- diff --git a/program/everything/contextmenu_o.js b/program/everything/contextmenu_o.js index d241f82..b04c2b2 100644 --- a/program/everything/contextmenu_o.js +++ b/program/everything/contextmenu_o.js @@ -4,36 +4,35 @@ var mouse_y = 0; 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" } } @@ -65,6 +64,28 @@ function f_waar() { 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(); diff --git a/program/everything/index.py b/program/everything/index.py index 1c66e28..8254614 100644 --- a/program/everything/index.py +++ b/program/everything/index.py @@ -2,6 +2,9 @@ # -*- codng: utf-8 -*- import crawler +import re +import urllib +import feedparser def index(req, args, apok): @@ -40,11 +43,19 @@ def crawler_edit(req, args, apok): req.write(status) elif args['action'] == 'edit': cr = crawler.Crawler() - req.write('') - req.write(''.join( - ''.format(a[0], a[1]) - for a in cr.entries[args['name']]['content'])) - req.write('
{}{}
') + 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('') + # req.write(''.join( + # ''.format(a[0], a[1]) + # for a in cr.entries[args['name']]['content'])) + # req.write('
{}{}
') else: req.write('Unknown editing action: {}'.format(args['action'])) req.write('
Go back') @@ -70,3 +81,58 @@ def crawler_test(req, args, apok): for k, v in sorted(respons.iteritems()))) req.write('

Go back') 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 += '' + result += '' + for i in feed.entries[:10]: + result += ('').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').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...' + '

Go back') + 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 diff --git a/program/everything/input_app.py b/program/everything/input_app.py index 6a155e3..376f664 100644 --- a/program/everything/input_app.py +++ b/program/everything/input_app.py @@ -32,8 +32,8 @@ def structure_data(d): con = d['content'] d['content'] = [] d['headers'] = [] - for line in con.split('\n\t\t'): - if not line: + for line in con.split(''): + if not line or '' not in line: continue row = re_row.search(line) row = row.group('row') @@ -64,7 +64,7 @@ def create_nodes(d): '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)) @@ -156,7 +156,7 @@ def data_main(d): 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() @@ -219,16 +219,11 @@ def handler(req): 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?
') - req.write('back') - else: - feed2html(req, args['url'], args['name']) - req_post(req) + req.write('Unknown case') return apache.OK diff --git a/program/everything/main.html.t b/program/everything/main.html.t index 6606818..b7c571b 100644 --- a/program/everything/main.html.t +++ b/program/everything/main.html.t @@ -28,7 +28,7 @@
TitleSummary
{}{}
Venue: \n' + '\t\t\t\n' + '\t\t
Frequency: \n' + '\t\t\t\n' + '\t\t
Default location name: \n' + '\t\t\t\n' + '\t\t
Adress: \n' + '\t\t\t\n' + '\t\t
Website: \n' + '\t\t\t\n' + '\t\t
RSS URL: \n' + '\t\t\t\n' + '\t\t
-
+ diff --git a/program/everything/new.html.t b/program/everything/new.html.t new file mode 100644 index 0000000..1ecfbbd --- /dev/null +++ b/program/everything/new.html.t @@ -0,0 +1,19 @@ + + + HyperFrontend RSS feed input new + + + +

RSS URL:

RSS Name:
+{input_data} +
+ + + + + +
Loading "{url}" as

{rssname}


+{feed_html} + + +