From 71469d99bc02cfd0c5cd939c41df7c1f14a14b81 Mon Sep 17 00:00:00 2001 From: fordprefect Date: Fri, 8 Jan 2021 12:01:20 +0100 Subject: [PATCH] initial project state, working and waiting for some more elaborated text --- .gitignore | 1 + README.md | 4 ++ index.html | 8 +++ pin.run | 194 +++++++++++++++++++++++++++++++++++++++++++++++++++++ style.css | 36 ++++++++++ 5 files changed, 243 insertions(+) create mode 100644 .gitignore create mode 100644 README.md create mode 100644 index.html create mode 100755 pin.run create mode 100644 style.css diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..151a12d --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +db.txt diff --git a/README.md b/README.md new file mode 100644 index 0000000..8b35497 --- /dev/null +++ b/README.md @@ -0,0 +1,4 @@ +## Simple pinboard script + +Use with fcgi. +Create httpd-writable db.txt as simple database diff --git a/index.html b/index.html new file mode 100644 index 0000000..323a6e7 --- /dev/null +++ b/index.html @@ -0,0 +1,8 @@ + +Upload + + + + +Ihr Browser unterstützt keine Umleitung, bitte hier klicken. + diff --git a/pin.run b/pin.run new file mode 100755 index 0000000..bc15ef0 --- /dev/null +++ b/pin.run @@ -0,0 +1,194 @@ +#!/usr/bin/python + +print("Content-type: text/html\n") +print("") +import os +import cgi +from datetime import datetime +#import locale +#locale.setlocale(locale.LC_TIME, "de_DE") + +origin_url = "https://augustiner-kantorei.de/pinnwand" +database = "db.txt" + +def get_arguments(): + """Wrapper for cgi-environment. + Takes no options, return dict of arguments + """ + rawargs = cgi.FieldStorage() + args = {} + + for i in rawargs: + args[i] = rawargs.getvalue(i) + + return args + +args = get_arguments() + +oversize=False +if os.path.getsize(database) < 100 * 1024 * 1024: + # only add entries if file size does not exceed 100 MiB + + if "ort" in args and "name" in args and "comment" in args: + # add entry + try: + zeit = datetime.timestamp(datetime(int(args["year"]), int(args["month"]), int(args["day"]), int(args["hour"]), int(args["minute"]))) + except: + exit() + try: + with open(database, "a") as f: + f.write("\t".join( + [ + str(zeit), + args["ort"].replace("\t", ""), + args["name"].replace("\t", ""), + args["comment"].replace("\t", "").replace("\n", " ").replace("\r", " "), + datetime.now().strftime("%Y-%m-%d %H:%M:%S") + ] + )) + f.write("\n") + except Exception as e: + exit() +else: + oversize = True + +# display current entries +now = datetime.timestamp(datetime.now()) +with open(database, "r") as f: + content = f.readlines() + +table = "" +for line in content: + tstamp, ort, name, comment, timestamp = line.split("\t") + if float(tstamp) < now: + continue + zeit = datetime.fromtimestamp(float(tstamp)) + hzeit = datetime.strftime(zeit, "%a, %d.%m.%Y %H:%M") + table += f"{hzeit}{ort}{name}{comment}" + +print(f""" + + + + + +

Überschrift

+
+

Terminangebote

+ + +{table} +
ZeitOrtNameBemerkung
+ +

+ +

Neuer Eintrag

+""") +if oversize: + print("neuer Eintrag derzeit nicht möglich, Datei voll.") +else: + print(""" +
+ + : + +   + + . + + . + +   Zeit (hh:mm DD.MM.YYYY)
+  Ort
+  Name
+  Bemerkung
+ +
+""") +print("
Augustiner-Pinnwand - ein Service von dukun.de
Rückmeldung
") + diff --git a/style.css b/style.css new file mode 100644 index 0000000..477118f --- /dev/null +++ b/style.css @@ -0,0 +1,36 @@ +div.box { + color:#cecece; + background-image: url('https://dukun.de/linen_login.jpg'); + background-size: 100%; + width: 100%; + height: 90%; + margin: 0px auto; + overflow: auto; + padding:10px; + border-radius:10px; + box-shadow: 0px 0px 20px #000; +} + +body { + background-image:url('https://dukun.de/linen.jpg'); + background-repeat:repeat; +} + +div.head { + width: 90%; + margin: auto; +} + +div.foot { + width: 90%; + margin:auto; + margin-top:20px; +} + +div.foot a { + color: #0000aa; +} + +a { + color:#8080ee; +}