ding
authorMart Lubbers <mart@martlubbers.net>
Thu, 15 May 2014 10:13:43 +0000 (12:13 +0200)
committerMart Lubbers <mart@martlubbers.net>
Thu, 15 May 2014 10:13:43 +0000 (12:13 +0200)
program/hypfront/contextmenu_o.js
program/hypfront/hyper.py
program/hypfront/index.html

index 468cfc6..feb3135 100644 (file)
@@ -29,7 +29,6 @@ function init(a, w) {
     var c = '<div style="position:relative;left:5px;top:-4px;">';
     c += a;
     c += '</div>';
-       console.log(c)
     b.innerHTML = c;
     b.style.position = "absolute";
     b.style.left = "0px";
@@ -44,10 +43,10 @@ function init(a, w) {
 }
 
 function mouseUp(e) {
-       var curselection = window.getSelection().getRangeAt(0);
-       if (curselection.endOffset - curselection.startOffset > 0)
-               selection = curselection;
-       console.log(selection)
+    var curselection = window.getSelection().getRangeAt(0);
+    if (curselection.endOffset - curselection.startOffset > 0)
+       selection = curselection;
+    console.log(selection)
     if (e.which == 1) document.getElementById("contextmenu").style.visibility = "hidden";
     else if (e.which == 3) mouse_right = false
 }
@@ -94,7 +93,12 @@ function post_all() {
             document.write(xmlhttp.responseText);
         }
     }
-    var params = "content="+encodeURIComponent(document.getElementsByTagName("table")[0].innerHTML);
+    var params = "content="+encodeURIComponent(document.getElementById("content-table").innerHTML);
+    params += "&name="+encodeURIComponent(document.getElementById("rssname").innerHTML);
+    var indatarray = document.getElementsByClassName('indat')
+    for (var i = 0; i<indatarray.length; i++) {
+        params += "&" + indatarray[i].name + "=" + indatarray[i].value;
+    }
     xmlhttp.open("POST", "hyper.py", true);
     xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
     xmlhttp.setRequestHeader("Content-length", params.length); 
index 7640394..2613481 100644 (file)
@@ -1,13 +1,34 @@
 #!/bin/env python
 # -*- coding: utf-8 -*-
 
-from mod_python import apache
+from mod_python import apache, util
 import feedparser
 import pprint
 import re
 import urllib
 
 
+def req_pre_pos(req):
+    req.log_error('handler')
+    req.content_type = 'text/html'
+    req.send_http_header()
+    args = util.FieldStorage(req)
+    req.write("""\
+<html>
+    <head>
+        <title>HyperFrontend RSS feed POSTREQUEST</title>
+    </head>
+    <body>
+        Thanks submitting: {}<br />
+        <a href="index.html">Enter new rss feed</a>
+        <pre>
+{}
+        </pre>
+    </body>
+</html>
+""".format(args.keys(), args['content']))
+
+
 def req_pre(req):
     req.log_error('handler')
     req.content_type = 'text/html'
@@ -17,35 +38,44 @@ def req_pre(req):
     <head>
         <title>HyperFrontend RSS feed input</title>
         <script src="contextmenu_o.js"></script>
-        <style type="text/css">
-            a:link {color: #000000 ; text-decoration: none; font-family: Verdana;font-size:8pt;}
-            a:visited {color: #0c2b86 ; text-decoration: none; font-family: Verdana;font-size:8pt;}
-            a:hover {color: #555555 ; text-decoration: underline; }
-            a:active {color: #333333 ;text-decoration: underline;font-size:8pt; }
-            img  { border : 0 }
-        </style>
     </head>
     <body>
+
+    <table>
+        <tr><td>Venue: </td><td>
+            <input type="text" name="venue" class="indat"></td></tr>
+        <tr><td>Frequency: </td><td>
+            <input type="text" name="freq" class="indat"></td></tr>
+        <tr><td>Default location name: </td><td>
+            <input type="text" name="dloc" class="indat"></td></tr>
+        <tr><td>Adress: </td><td>
+            <input type="text" name="adress" class="indat"></td></tr>
+        <tr><td>Website: </td><td>
+            <input type="text" name="website" class="indat"></td></tr>
+    </table>
+
     Selecteer iets en klik de link<br />
     <button style="color:blue" onclick="javascript:f_waar()">Waar</button>
-    <button style="color:green" onclick="javascript:f_wat()">Wie</button>
+    <button style="color:green" onclick="javascript:f_wat()">Wat</button>
     <button style="color:red" onclick="javascript:f_wanneer()">Wanneer</button>
+    <br />
 
 <div style="position:absolute;left:12px;width:500px;"></div>
 <script language="javascript" type="text/javascript">
-       var content='<b>Categorize</b><br />';
-       content+=' <a href="#" onclick="javascript:f_waar()">Waar</a><br />';
-       content+=' <a href="#" onclick="javascript:f_wat()">Wat</a>';
-       content+=' <a href="#" onclick="javascript:f_wanneer()>Wanneer</a><br />';
-        content+=' Test 123';
-       init(content,120); 
+    var content='<b>Categorize</b><br />';
+    content+=' <a href="#" onclick="javascript:f_waar()">Waar</a><br />';
+    content+=' <a href="#" onclick="javascript:f_wat()">Wat</a>';
+    content+=' <a href="#" onclick="javascript:f_wanneer()>Wanneer</a><br />';
+    content+=' Test 123';
+    init(content,120);
 </script>
 """)
 
 
 def req_post(req):
     req.write("""\
-            <button onclick="javascript:post_all()" method="post" target="_blank">Submit</button>
+            <button onclick="javascript:post_all()" method="post" target="_bla\
+nk">Submit</button>
     </body>
 </html>
 """)
@@ -54,31 +84,29 @@ def req_post(req):
 def feed2html(req, url, name):
     url = urllib.unquote(url)
     url = url if re.match('https?://', url) else 'http://{}'.format(url)
-    req.write('\tLoading "{}" as "{}"<br />\n'.format(url, name))
+    req.write(
+        '\tLoading "{}" as <p id="rssname">"{}"</p><br />\n'.format(url, name))
     feed = feedparser.parse(url)
     channel = feed.feed
-    req.write('\t<table border="1" id="htab">\n')
+    req.write('\t<table id="content-table" border="1" id="htab">\n')
     req.write('\t\t<tr><th>Title</th><th>Summary</th><th>...</th></tr>\n')
     for i in feed.entries:
         req.write('\t\t<tr><td>{}</td><td>{}</td><td>...</td></tr>\n'.
                   format(i['title'].encode('ascii', 'xmlcharrefreplace'),
                          i['summary'].encode('ascii', 'xmlcharrefreplace')))
     req.write('\t</table>\n<br />')
-    for k, v in feed.entries[0].iteritems():
-        req.write('{}: {}<br />\n'.format(k, v))
+
 
 def handler(req):
     if req.method == "POST":
-        raise Exception("POSTEDDDD")
+        req_pre_pos(req)
     else:
         req_pre(req)
-        args = dict(filter(lambda x: x[1],
-                           map(lambda x: x.split('='),
-                               req.__getattribute__('args').split('&'))))
+        args = util.FieldStorage(req)
         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)
-        return apache.OK
+    return apache.OK
index c533b6e..788eeee 100644 (file)
@@ -1,12 +1,14 @@
 <html>
-       <body>
-               <form method="get" action="./hyper.py">
-                       <table>
-                               <tr><td><p>RSS URL:  </td><td><input type="text" name="url"
-                                               value="localhost/py/paradiso.rss.xml"></td></tr>
-                               <tr><td><p>RSS Name: </td><td><input type="text" name="name"></td></tr>
-                               <tr><td><input type="submit" value="Submit"</p>
-                       </table>
-               </form>
-       </body>
+    <head>
+    </head>
+    <body>
+        <form method="get" action="./hyper.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>
+                <tr><td><input type="submit" value="Submit"</p>
+            </table>
+        </form>
+    </body>
 </html>