comparison index.psp @ 31:c66f4b393d15

Added index.php for Python Server Pages Added .htaccess to overwrite Apaches directory indexing Added scritps/d4e-website-loader.sh to upload website to wald.intevation.org
author Mathias Gebbe <mgebbe@intevation.de>
date Mon, 03 Mar 2014 11:34:30 +0100
parents
children 960c044010e5
comparison
equal deleted inserted replaced
30:c69b8e62172f 31:c66f4b393d15
1 <%
2 import requests
3 import urllib2
4 import simplejson
5 import time
6
7
8 # SETTINGS
9
10 tmpl = "./index.html"
11 url = "https://io.intevation.de/api/user/dive4elements/feed/public"
12 #url = "https://io.intevation.de/api/user/Intevation/feed/public"
13 verb = "share" # post or share
14 max_posts = 5
15 max_length = 300
16 opacity75 = 20
17 ocacity50 = 10
18
19 # END SETTINGS
20
21 with open (tmpl, "r") as myfile:
22 template=myfile.read().replace('\n', '')
23
24 req.content_type = "text/html; charset=UTF-8"
25 output = []
26
27 postcount = 1
28
29 output.append(
30 '<ul style="list-style-type: square; margin-left:-25px;line-height: 23px;">'
31 )
32
33 response = urllib2.urlopen(url)
34 data = simplejson.load(response,'utf8')
35
36 for item in data["items"]:
37
38 # only shares or posts are interesting
39 if item["verb"] != verb: continue
40
41 # max_posts
42 if postcount > max_posts: break
43
44 try:
45 content = item["object"]["content"]
46 except KeyError:
47 continue
48 postcount+=1
49
50 content = content.encode('utf-8')
51 output.append("<li>")
52
53 if len(content) >= max_length:
54 output.append(content[:(max_length-opacity75)])
55 output.append("<a href="+item["actor"]["url"]+">")
56 #output.append("<a href="+item["object"]["url"]+">")
57 output.append('<span style="opacity: 0.75;filter:Alpha(opacity=75)">' + content[(max_length-opacity75):(max_length-ocacity50)] + '</span>' + '<span style="opacity: 0.50;filter:Alpha(opacity=50)">' + content[(max_length-ocacity50):(max_length)] + '...</span></a>')
58 else:
59 output.append(content)
60
61 output.append('<br>')
62 #output.append("<a href="+item["object"]["links"]["self"]["href"]+">more...</a>")
63 output.append('<span style="font-size:smaller">')
64 output.append('<a href="'+item["actor"]["url"]+'">'+item["actor"]["displayName"]+'</a>')
65 #output.append(item["content"])
66 if verb == "share": output.append(' via <a href="'+item["object"]["url"]+'">'+item["object"]["author"]["displayName"]+'</a>')
67 #if verb == "share": output.append(' via <a href="'+item["object"]["author"]["url"]+'">'+item["object"]["author"]["displayName"]+'</a>')
68 # 2014-01-03T10:30:02Z
69 date=time.strptime(item["updated"],"%Y-%m-%dT%H:%M:%SZ")
70 output.append(" "+(time.strftime("%d.%m.%Y um %H:%M:%S", date)))
71 output.append('</span>')
72 output.append("</li>")
73
74 output.append("</ul>")
75 #output.append('<a href="'+data["author"]["url"]+'">mehr von '+data["author"]["displayName"]+'</a>' )
76
77 str = ''.join(output)
78 template = template.replace('{newsfeed}',str)
79
80 req.write(template)
81 %>
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)