summaryrefslogtreecommitdiff
path: root/cgi-bin/display.py
blob: 262a52300be8236ae5233b1be47c57c7f27f4cea (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# -*- coding: utf8 -*-
import link, os, config
from datetime import datetime

class Body:
	def __init__(self, site):
		self.site=site
		self.a=link.Link(site)
		self.datadir=config.datadir
		
	def menu(self):
		print (self.a.link(self.a.delta('+w'), '-týden'))
		print (self.a.link(self.a.delta('+d'), '-den'))
		print (self.a.link(self.a.delta('+h'), '-hodina'))
		print (self.a.link(self.a.delta('+m'), 'minulý'))
		print (self.a.link(self.a.delta('-m'), 'následující'))
		print (self.a.link(self.a.delta('-h'), '+hodina'))
		print (self.a.link(self.a.delta('-d'), '+den'))
		print (self.a.link(self.a.delta('-w'), '+týden'))
		print ("<a href=\"?f=latest\">nejnovější</a>")

	
	def articles(self):
		print ("<header>")
		print ("<h1>Hnízdo</h1>")
		print ("<nav>")
		self.menu()
		print ("</nav>")
		print ("</header>")
		print ("<article id=\"prev\">")
		print (self.a.imglink(self.a.delta('+m'),'prev'))
		print ("<p>"+self.a.timestamp(self.a.delta('+m'))+"</p>")
		print ("</article>")
		print ("<article id=\"now\">")
		print (self.a.imglink(self.a.img, 'now'))
		print ("<p>"+self.a.timestamp(self.a.img)+"</p>")
		print ("</article>")
		print ("<article id=\"next\">")
		print (self.a.imglink(self.a.delta('-m'), 'next'))
		print ("<p>"+self.a.timestamp(self.a.delta('-m'))+"</p>")
		print ("</article>")
		print ("<footer>")
		print ("<a href=\"?f=index\" title=\"všechny fotky\">vše</a>")
		print ("</footer>")
	
	def index(self):
		index=os.listdir(os.path.realpath(self.datadir))
		remove=['notfound.jpeg', 'latest.jpeg']
		for r in remove:
			index.remove(r)
		print ("<header>")
		print ("<h1>Hnízdo - Index</h1>")
		print ("</header>")
		print ("<ul>")
		for f in index:
			print("<li>")
			print(self.a.link(f, self.a.timestamp(f)))
			print("</li>")
		print ("</ul>")
		
	def page(self):
		if self.site == "index":
			self.index()
		else:
			self.articles()