bygdis.fi

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

commit 74eb466e3bab176118f6bed0aa12efa7b0587536
parent d7e910a379ecf1c2fd4ffc7657b8d16425e6482b
Author: rob <rob@tarina.org>
Date:   Sun,  4 Oct 2020 11:30:29 +0300

ok, myky att committa, ska testa ifall dehär static web sidorna fungerar

Diffstat:
Adailymail.py | 102+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Apublic_html/html/bilder.html | 98+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Apublic_html/html/index.html | 56++++++++++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 256 insertions(+), 0 deletions(-)

diff --git a/dailymail.py b/dailymail.py @@ -0,0 +1,102 @@ +#!/usr/bin/env python3 + +import sqlite3 +from datetime import datetime, timedelta +import subprocess +import os + +def sendmail(email, subject, msg): + #Send mail + echomsg = subprocess.Popen(('echo', msg), stdout=subprocess.PIPE) + sendmsg = subprocess.check_output(('mail', '-r', 'rob@bygdis.fi', '-s', subject, email, '-a', 'Content-Type: text/html;'), stdin=echomsg.stdout) + echomsg.wait() + #subprocess.call(['echo', msg, '|', 'mail', '-r', 'rob@tarina.org','-s', subject, email]) + +basedir = os.path.dirname(os.path.realpath(__file__)) + +conn = sqlite3.connect(basedir + '/db/bygdis.db') +c = conn.cursor() + +c.execute('SELECT * FROM "bilder" ORDER BY "uploaddate" DESC') +bilder = c.fetchall().copy() +c.execute('SELECT * FROM "allaversioner" ORDER BY "lastmod" DESC') +info = c.fetchall().copy() +c.execute('SELECT * FROM "bildkommentar" ORDER BY "datumtid" DESC') +comments = c.fetchall().copy() + +get_info = True +get_bild = True +get_comment = True +msg = '' +info +commentdate = datetime.now() - timedelta(days=90) +bilddate = datetime.now() - timedelta(days=90) +infodate = datetime.now() - timedelta(days=90) +for n in range(100): + if get_comment == True: + for k in comments: + try: + commentdate = datetime.strptime(k[1], "%Y-%m-%d %H:%M:%S.%f") + except: + commentdate = datetime.now() - timedelta(days=90) + comments.pop(0) + break + else: + commentdate = datetime.now() - timedelta(days=90) + if get_bild == True: + for b in bilder: + imageurl = b[1] + '.jpeg' + try: + bilddate = datetime.strptime(b[2], "%Y-%m-%d %H:%M:%S.%f") + except: + bilddate = datetime.now() - timedelta(days=90) + bilder.pop(0) + break + if get_info == True: + for i in info: + imageurl = i[1] + '.jpeg' + try: + infodate = datetime.strptime(i[10], "%Y-%m-%d %H:%M:%S.%f") + except: + infodate = datetime.now() - timedelta(days=90) + info.pop(0) + break + if info == [] and bilder == [] and comments == []: + break + get_info = False + get_bild = False + get_comment = False + d = max(infodate,bilddate,commentdate) + daily = datetime.now() - timedelta(days=1) + if d < daily: + break + if d == infodate: + get_info = True + try: + msg += ("<p><a href='https://bygdis.fi/bild/"+i[1]+"'>"+i[10][:16] + " "+ i[9] +" lade till bildinfo " + i[3] + "</a></p>") + except: + pass + if d == bilddate: + get_bild = True + try: + msg += ("<p><a href='https://bygdis.fi/bild/"+b[1]+"'>"+ b[2][:16]+" "+b[7]+" lade till bild "+b[3]+"</a></p>") + except: + pass + if d == commentdate: + get_comment = True + try: + msg +=("<p><a href='https://bygdis.fi/bild/"+k[5]+"'>"+ k[1][:16]+" "+k[2]+" kommenterade "+k[3]+"</a></p>") + except: + pass +print(msg) + +c.execute('SELECT * FROM bildadmin WHERE subscribe="dagligen"') +users = c.fetchall().copy() +print(users) +print(msg) +if msg != '': + for u in users: + sendmail(u[4], 'Va ha de häändi nu då?', msg) + +c.close() + diff --git a/public_html/html/bilder.html b/public_html/html/bilder.html @@ -0,0 +1,98 @@ +$def with (bilder, rights, namn, totbilder, offset, bildpersida, search, db, str, print) +<div id="bilder"> +$ displayname = db.query("SELECT displayname FROM bildadmin WHERE name='"+namn+"';")[0] +<p>inloggad som <b><a href="/tuning">$displayname.displayname</a></b> ❃ | <a href="/logout">Logga ut</a> 🗝</p> +<h1>Byyns eji fotoalbum</h1> +<h4><a href="/upload">lägg opp ny bild</a> 💾 <a href="/senaste">senast häändi</a> 🔥</h4> +$if search == '': + <p>bilder totalt: $totbilder</p> +$else: + <p>bilder med sökordet $search: $totbilder</p> + <p><a href="/bilder?search=">ta bort sökordet</a></p> +$if offset > bildpersida: + <a href="/bilder?page=back"><--- föregåående siidå</a> +$if offset < totbilder: + <a href="/bilder?page=next">nästa siidå --></a> +<br> +<br> +$if search != '': + $for bild in bilder: + $for i in bild: + $ l = db.query("SELECT Count(*) AS likes FROM likes WHERE bild='"+i.filename+"';")[0] + $ h = db.query("SELECT Count(*) AS hates FROM hates WHERE bild='"+i.filename+"';")[0] + $ k = db.query("SELECT Count(*) AS comments FROM bildkommentar WHERE filename='"+i.filename+"';")[0] + $if k.comments > 0: + $ comments = "💬 " + str(k.comments) + $else: + $ comments = '' + $if l.likes > 0: + $ likes = "❤️ " + str(l.likes) + $else: + $ likes = '' + $if h.hates > 0: + $ hates = '☠️ ' + str(h.hates) + $else: + $ hates = '' + $if i.beskrivning != '' and i.beskrivning != None: + $ story = '✏️' + $else: + $ story = '' + $if i.fotograf != '' and i.fotograf != None: + $ fotograf = '📸' + $else: + $ fotograf = '' + $ print(i.beskrivning) + $ imageurl = i.filename + '.jpeg' + <div class="bild" id="$i.filename"> + <a href="/bild/$i.filename"><img src="/static/bilder/thumb/$imageurl"></a> + $if i.titel != None: + $if i.titel != '': + <h4><a href="/bild/$i.filename">$i.titel</a></h4> + <p><a href="/bilder?search=$i.year">$i.year</a> $fotograf <a href="/bilder?search=$i.fotograf">$i.fotograf</a> $story $likes $hates $comments<p> + $if rights=="admin": + <a href="/bilder?delete=$i.filename">ta bort bild</a> + </div> + +$else: + $for i in bilder: + $ l = db.query("SELECT Count(*) AS likes FROM likes WHERE bild='"+i.filename+"';")[0] + $ h = db.query("SELECT Count(*) AS hates FROM hates WHERE bild='"+i.filename+"';")[0] + $ k = db.query("SELECT Count(*) AS comments FROM bildkommentar WHERE filename='"+i.filename+"';")[0] + $if k.comments > 0: + $ comments = "💬 " + str(k.comments) + $else: + $ comments = '' + $if l.likes > 0: + $ likes = "❤️ " + str(l.likes) + $else: + $ likes = '' + $if h.hates > 0: + $ hates = '☠️ ' + str(h.hates) + $else: + $ hates = '' + $if i.beskrivning != '' and i.beskrivning != None: + $ story = '✏️' + $else: + $ story = '' + $if i.fotograf != '' and i.fotograf != None: + $ fotograf = '📸' + $else: + $ fotograf = '' + $ print(i.beskrivning) + $ imageurl = i.filename + '.jpeg' + <div class="bild" id="$i.filename"> + <a href="/bild/$i.filename"><img src="/static/bilder/thumb/$imageurl"></a> + $if i.titel != None: + $if i.titel != '': + <h4><a href="/bild/$i.filename">$i.titel</a></h4> + <p><a href="/bilder?search=$i.year">$i.year</a> $fotograf <a href="/bilder?search=$i.fotograf">$i.fotograf</a> $story $likes $hates $comments<p> + $if rights=="admin": + <a href="/bilder?delete=$i.filename">ta bort bild</a> + </div> + +$if offset < totbilder: + <h2><a href="/bilder?page=next">nästa siidå ---></a></h2> + <br> + <br> + <p id="footer">hemsiidåna duunade mää <a href="https://webpy.org">web.py</a> av bebin rockman 😎 +</div> diff --git a/public_html/html/index.html b/public_html/html/index.html @@ -0,0 +1,56 @@ +$def with (upcomingevents) +$var upcomingevents = upcomingevents +<div id="container"> + <div id="default"> + <br> + <h1>Bygdis.fi</h1> + <h4><a href="#styrelsen">Styrelsen</a> | <a href="#bokningar">Bokningar</a> | <a href="/login">Logga in</a></h4> + $for i in upcomingevents: + <div id=event> + <h4>$i.event</h4> + $i.veckodag $i.datumtid[8:10] $i.datumtid[5:7] kl. $i.datumtid[10:16] + </div> + <div id="styrelsen"> + <h1>Styrelsen</h1> + Lars-Erik Kullström | ordförande </a><br> + Robin Bäckman | sekreterare | <a href="tel:0447624040">0447624040</a><br> + Benjamin Bäckman, Frieda Ramstedt, Johanna Granqvist, Tom Granqvist, Mia Wigren<br> + </div> + <div id="bokningar"> + <h1>Bokningar</h1> + Bokningar tas emot på <a href="tel:0447624040">0447624040</a><br> + <h2>Veckoslut</h2> + <b>fredagkväll till söndag eftermiddag</b><br> + <h3>Hela huset</h3> + medlemmar 180 €<br> + icke medlemmar 300 €<br> + <h3>Serveringsrummet</h3> + medlemmar 80 €<br> + icke medlemmar 120 €<br> + <h3>Serveringsrummet och kök</h3> + medlemmar 100 €<br> + icke medlemmar 150 €<br> + ~-~<br> + <h2>En dag</h2> + <h3>Hela huset</h3> + medlemmar 100 €<br> + icke medlemmar 150€<br> + <h3>Serveringsrummet</h3> + medlemmar 50 €<br> + icke medlemmar 100 €<br> + <h3>Serveringsrummet och kök</h3> + medlemmar 80 €<br> + icke medlemmar 120 €<br> + ~-~<br> + <h3>Städning</h3> + Städning kan skötas av en städfirma om hyresgästen så önskar då faktureras hyresgästen enligt städfirmans avgift. + <h3>Bordsdukar och löpare</h3> + 8€/kg (2-3 vita dukar går på 1kg) + <br>Hommansby Uf sköter <b>alltid</b> om tvättning av dukarna. + <h3>Uthyrning av jaktföreningens kylrum</h3> + 30€/veckoslut + <h3>Marthornas mat- och kaffeservis</h3> + 20€/servis + </div> + </div> +</div>