[PATCH] Added index.php for Python Server Pages

Wald Commits scm-commit at wald.intevation.org
Mon Mar 3 11:34:42 CET 2014


# HG changeset patch
# User Mathias Gebbe <mgebbe at intevation.de>
# Date 1393842870 -3600
# Node ID c66f4b393d15f7f0dff33362e5f2ceff0a8dda53
# Parent  c69b8e62172f5f543e840fc970043f8194091b69
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

diff -r c69b8e62172f -r c66f4b393d15 .htaccess
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/.htaccess	Mon Mar 03 11:34:30 2014 +0100
@@ -0,0 +1,2 @@
+AddDefaultCharset UTF-8
+DirectoryIndex index.psp
diff -r c69b8e62172f -r c66f4b393d15 index.psp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/index.psp	Mon Mar 03 11:34:30 2014 +0100
@@ -0,0 +1,81 @@
+<%
+import requests
+import urllib2
+import simplejson
+import time
+
+
+# SETTINGS
+
+tmpl = "./index.html"
+url        = "https://io.intevation.de/api/user/dive4elements/feed/public"
+#url       = "https://io.intevation.de/api/user/Intevation/feed/public"
+verb       = "share" # post or share
+max_posts  = 5
+max_length = 300
+opacity75  = 20
+ocacity50  = 10
+
+# END SETTINGS
+
+with open (tmpl, "r") as myfile:
+    template=myfile.read().replace('\n', '')
+
+req.content_type = "text/html; charset=UTF-8"
+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('utf-8')
+          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>' )
+
+str = ''.join(output)
+template = template.replace('{newsfeed}',str)
+
+req.write(template)
+%>
diff -r c69b8e62172f -r c66f4b393d15 scritps/d4e-website-loader.sh
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/scritps/d4e-website-loader.sh	Mon Mar 03 11:34:30 2014 +0100
@@ -0,0 +1,61 @@
+#!/bin/bash
+# Copyright (C) 2014 by Intevation GmbH
+# Author(s):
+# Mathias Gebbe <mgebbe at intevation.de>
+#
+# The Document Root of your projects website is available as:
+# wald.intevation.org:/$PROJECT/htdocs/
+# so to list the contents of your projects Document root you can use:
+# rsync $USER at wald.intevation.org:/$PROJECT/htdocs/
+# or to make a locale copy:
+# rsync -vrl $USER at wald.intevation.org:/$PROJECT/htdocs/ $TARGET [should be an empty directory]
+# to upload a new htdocs folder use:
+# rsync -rvPC --perms --chmod=ug+rw,o+r,Dg+s,Da+x,u-s,Fg-s,o-wt --exclude '*.swp' --delete ./website/* $username at wald.intevation.org:/$PROJECT/htdocs/
+#
+# to load the latest d4e-website from repositroy use: hg clone https://scm.wald.intevation.org/hg/dive4elements/website/
+
+
+PROJECT=dive4elements
+
+function usage
+{
+    echo "usage: -u username -d destination [-h]"
+}
+
+
+##### Main
+
+while [ "$1" != "" ]; do
+    case $1 in
+        -u | --user )           shift
+                                username=$1
+                                ;;
+        -d | --destination )    shift
+                                destination=$1
+                                ;;
+        -h | --help )           usage
+                                exit 0
+                                ;;
+        * )                     usage
+                                exit 1
+    esac
+    shift
+done
+
+if [ -z $username ];then
+ echo "Username:"
+ read username
+fi
+
+if [ -z $destination ];then
+ echo "Destination (hit enter for current directory `pwd` [should be an empty directory]):"
+ read destination
+  if [ -z $destination ];then
+   destination=`pwd`
+  fi
+fi
+
+hg clone ssh://$username@scm.wald.intevation.org/hg/dive4elements/website/ $destination
+
+echo "run the following command to upload the website from repository"
+echo "rsync -rvPC --perms --chmod=ug+rw,o+r,Dg+s,Da+x,u-s,Fg-s,o-wt --exclude '*.swp' --delete $destination/* $username at wald.intevation.org:/$PROJECT/htdocs/"


More information about the Dive4elements-commits mailing list