[PATCH] Remove PSP, Added SSI, Added newsfeed.py for include

Wald Commits scm-commit at wald.intevation.org
Mon Mar 10 17:47:13 CET 2014


# HG changeset patch
# User Mathias Gebbe <mgebbe at intevation.de>
# Date 1394470027 -3600
# Node ID 5541d758f62aa25458471cdd2fac5675540796d9
# Parent  3fe0a15a02d0e73e47a505ccd6426ca9c50e3662
Remove PSP, Added SSI, Added newsfeed.py for include

diff -r 3fe0a15a02d0 -r 5541d758f62a .htaccess
--- a/.htaccess	Mon Mar 10 16:31:19 2014 +0100
+++ b/.htaccess	Mon Mar 10 17:47:07 2014 +0100
@@ -1,14 +1,4 @@
 # Activate serversite includes.
-AddOutputFilter INCLUDES .shtml
+Options +Includes +ExecCGI
 XBitHack on
-
-# Activate "Python Server Pages"
-AddHandler mod_python .psp
-PythonHandler mod_python.psp
-
 AddDefaultCharset UTF-8
-DirectoryIndex index.psp
-
-# Nobody should see the index.html
-RewriteEngine On
-RewriteRule  ^index\.html$ $1/index.psp [R]
diff -r 3fe0a15a02d0 -r 5541d758f62a feed.html
--- a/feed.html	Mon Mar 10 16:31:19 2014 +0100
+++ b/feed.html	Mon Mar 10 17:47:07 2014 +0100
@@ -1,6 +1,6 @@
 <div class="col-xs-6 col-md-4 sidebar-dive4elements">
     <div class="news feed">
         <p>News Feed</p>
-        {newsfeed}
+        <!--#exec cgi="/newsfeed.py" -->
     </div><!-- /news feed -->
 </div><!-- /col-xs-6 -->
diff -r 3fe0a15a02d0 -r 5541d758f62a newsfeed.py
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/newsfeed.py	Mon Mar 10 17:47:07 2014 +0100
@@ -0,0 +1,75 @@
+#!/usr/bin/env python
+
+import urllib2
+import simplejson
+import time
+import sys
+
+# SETTINGS
+
+url        = "http://goldenrod.rgb/api/user/dive4elements/feed/public"
+verb       = "share" # post or share
+max_posts  = 5
+max_length = 350
+opacity75  = 20
+ocacity50  = 10
+
+# END SETTINGS
+
+output = []
+
+postcount  = 1
+
+output.append(
+        '<ul style="list-style-type: square; margin-left:-25px;line-height: 23px;">'
+)
+
+response = urllib2.urlopen(url)
+data = simplejson.load(response,'utf8')
+
+for item in data["items"]:
+
+          # only shares or posts are interesting
+          if item["verb"] != verb: continue
+
+          # max_posts
+          if postcount > max_posts: break
+
+          try:
+              content = item["object"]["content"]
+          except KeyError:
+              continue
+          postcount+=1
+
+          content = content.encode('utf8')
+          output.append("<li>")
+
+          if len(content) >= max_length:
+             output.append(content[:(max_length-opacity75)])
+             output.append("<a href="+item["actor"]["url"]+">")
+             #output.append("<a href="+item["object"]["url"]+">")
+             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>')
+          else:
+             output.append(content)
+
+          output.append('<br>')
+          #output.append("<a href="+item["object"]["links"]["self"]["href"]+">more...</a>")
+          output.append('<span style="font-size:smaller">')
+          output.append('<a href="'+item["actor"]["url"]+'">'+item["actor"]["displayName"]+'</a>')
+          #output.append(item["content"])
+          if verb == "share": output.append(' via <a href="'+item["object"]["url"]+'">'+item["object"]["author"]["displayName"]+'</a>')
+          #if verb == "share": output.append(' via <a href="'+item["object"]["author"]["url"]+'">'+item["object"]["author"]["displayName"]+'</a>')
+          # 2014-01-03T10:30:02Z
+          date=time.strptime(item["updated"],"%Y-%m-%dT%H:%M:%SZ")
+          output.append(" "+(time.strftime("%d.%m.%Y um %H:%M:%S", date)))
+          output.append('</span>')
+          output.append("</li>")
+
+output.append("</ul>")
+#output.append('<a href="'+data["author"]["url"]+'">mehr von '+data["author"]["displayName"]+'</a>' )
+s = ''.join(output)
+
+print "Content-Type: text/html;charset=utf-8"
+print
+print s
+


More information about the Dive4elements-commits mailing list