pfad-foo entwirrt...
This commit is contained in:
parent
339cd88c6c
commit
e3392163ac
|
|
@ -4,7 +4,7 @@
|
||||||
<p>Fedi: <a rel="me" href="https://chaos.social/@dm2lct">@dm2lct@chaos.social</a></p>
|
<p>Fedi: <a rel="me" href="https://chaos.social/@dm2lct">@dm2lct@chaos.social</a></p>
|
||||||
<p>QRZ.com: <a href="https://www.qrz.com/db/dm2lct">https://www.qrz.com/db/dm2lct</a></p>
|
<p>QRZ.com: <a href="https://www.qrz.com/db/dm2lct">https://www.qrz.com/db/dm2lct</a></p>
|
||||||
<p>hamqth.com: <a href="https://www.hamqth.com/dm2lct">https://www.hamqth.com/dm2lct</a></p>
|
<p>hamqth.com: <a href="https://www.hamqth.com/dm2lct">https://www.hamqth.com/dm2lct</a></p>
|
||||||
<p>Built with 💜 using <a href="https://github.com/spectrasecure/arise">Arise</a></p>
|
<p>Built with 💜 using <a href="https://gitea.dm2lct.radio/chrissy/purrpic">Purrpic =^.^=</a></p>
|
||||||
</div>
|
</div>
|
||||||
<!-- End Page Footer -->
|
<!-- End Page Footer -->
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
<!-- Basic Metadata -->
|
<!-- Basic Metadata -->
|
||||||
<meta charset="utf-8" />
|
<meta charset="utf-8" />
|
||||||
<meta name="HandheldFriendly" content="True" />
|
<meta name="HandheldFriendly" content="True" />
|
||||||
<meta name="generator" content="Arise" />
|
<meta name="generator" content="Purrpic" />
|
||||||
|
|
||||||
<title>{{title}} · {{global_name}}</title>
|
<title>{{title}} · {{global_name}}</title>
|
||||||
<meta name="description" content="{{description}}">
|
<meta name="description" content="{{description}}">
|
||||||
|
|
@ -53,8 +53,8 @@
|
||||||
hr {color:#fff;}
|
hr {color:#fff;}
|
||||||
.topbar a {color:#fff; text-decoration:none;}
|
.topbar a {color:#fff; text-decoration:none;}
|
||||||
</style>
|
</style>
|
||||||
<link rel="stylesheet" href="/config/main.css">
|
<link rel="stylesheet" href="../../conf/main.css">
|
||||||
<div class="logo"><a href="/"><img src="/config/logo.png" /></a></div>
|
<div class="logo"><a href="/"><img src="../../conf/logo.png" /></a></div>
|
||||||
<!-- End Styles+Logo -->
|
<!-- End Styles+Logo -->
|
||||||
<div class="header">
|
<div class="header">
|
||||||
<a href="/">Chrissys random stuff.</a>
|
<a href="/">Chrissys random stuff.</a>
|
||||||
|
|
|
||||||
|
|
@ -246,6 +246,8 @@ nav li {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
||||||
padding: 0 4px;
|
padding: 0 4px;
|
||||||
|
margin-left: auto;
|
||||||
|
margin-right: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Create four equal columns that sits next to each other */
|
/* Create four equal columns that sits next to each other */
|
||||||
|
|
@ -253,12 +255,21 @@ nav li {
|
||||||
flex: 25%;
|
flex: 25%;
|
||||||
max-width: 25%;
|
max-width: 25%;
|
||||||
padding: 0 4px;
|
padding: 0 4px;
|
||||||
|
margin-left: auto;
|
||||||
|
margin-right: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
.column img {
|
.column img {
|
||||||
margin-top: 8px;
|
margin-top: 8px;
|
||||||
vertical-align: middle;
|
vertical-align: middle;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
margin-left: auto;
|
||||||
|
margin-right: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.column div.desc {
|
||||||
|
padding: 15px;
|
||||||
|
text-align: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Responsive layout - makes a two column-layout instead of four columns */
|
/* Responsive layout - makes a two column-layout instead of four columns */
|
||||||
|
|
@ -266,6 +277,8 @@ nav li {
|
||||||
.column {
|
.column {
|
||||||
flex: 50%;
|
flex: 50%;
|
||||||
max-width: 50%;
|
max-width: 50%;
|
||||||
|
margin-left: auto;
|
||||||
|
margin-right: auto;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -274,6 +287,8 @@ nav li {
|
||||||
.column {
|
.column {
|
||||||
flex: 100%;
|
flex: 100%;
|
||||||
max-width: 100%;
|
max-width: 100%;
|
||||||
|
margin-left: auto;
|
||||||
|
margin-right: auto;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
165
purrpic.py
165
purrpic.py
|
|
@ -15,17 +15,19 @@ import configparser
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
import datetime
|
import datetime
|
||||||
|
|
||||||
BUILD_DIR = Path("./build")
|
BUILD_DIR = Path("./build").resolve()
|
||||||
CONF_DIR = Path("./conf")
|
CONF_DIR = Path("./conf").resolve()
|
||||||
THUMBSIZE = (300, 300)
|
THUMBSIZE = (300, 300)
|
||||||
GLOBALNAME = "Chrissys random Imagelibrary"
|
GLOBALNAME = "Chrissys random Imagelibrary"
|
||||||
|
LICENCE = "CC BY-NC-SA 4.0"
|
||||||
AUTHOR = "Luzia Christiane Tesar"
|
AUTHOR = "Luzia Christiane Tesar"
|
||||||
LANGUAGE = "en"
|
LANGUAGE = "en"
|
||||||
DESCRIPTION = ""
|
DESCRIPTION = ""
|
||||||
TODAY = datetime.datetime.today().strftime("%Y-%m-%d")
|
TODAY = datetime.datetime.today().strftime("%Y-%m-%d")
|
||||||
CANONICALURL = "https://dm2lct.radio"
|
CANONICALURL = "https://dm2lct.radio"
|
||||||
|
|
||||||
exclude = set(['.thumbnails'])
|
exclude = set([".thumbnails", ".git", "conf", "build"])
|
||||||
|
|
||||||
|
|
||||||
class HTML:
|
class HTML:
|
||||||
def __init__(self, **kwargs):
|
def __init__(self, **kwargs):
|
||||||
|
|
@ -74,64 +76,73 @@ class HTML:
|
||||||
header = header.replace("{{description}}", DESCRIPTION)
|
header = header.replace("{{description}}", DESCRIPTION)
|
||||||
header = header.replace("{{published_date}}", TODAY)
|
header = header.replace("{{published_date}}", TODAY)
|
||||||
header = header.replace("{{modified_date}}", TODAY)
|
header = header.replace("{{modified_date}}", TODAY)
|
||||||
header = header.replace("{{canonical_URL}}", CANONICALURL)
|
header = header.replace("{{canonical_url}}", CANONICALURL)
|
||||||
return header
|
return header
|
||||||
|
|
||||||
def writeIndex(self, indir, odir, title, info=None) -> None:
|
def writeIndex(self, odir, meta) -> None:
|
||||||
try:
|
try:
|
||||||
|
title=meta['title']
|
||||||
|
desc=meta['description']
|
||||||
|
buf = self.headermeta(title)
|
||||||
|
buf += self.title(title)
|
||||||
|
if len(desc) > 0:
|
||||||
|
buf += self.ul()
|
||||||
|
for line in desc:
|
||||||
|
buf += self.li(line)
|
||||||
|
buf += self.li(f"© {AUTHOR}, {LICENCE}")
|
||||||
|
buf += self.endUl()
|
||||||
|
buf += self.div("row")
|
||||||
|
#imglist = glob.glob(str(odir) + "/.thumbnails/*")
|
||||||
|
imglist =[]
|
||||||
|
for img in Path.iterdir(odir / ".thumbnails"):
|
||||||
|
imglist.append(img)
|
||||||
|
for n in range(0, 3):
|
||||||
|
buf += self.div("column")
|
||||||
|
breakpoint()
|
||||||
|
for i in range(n, len(imglist), 3):
|
||||||
|
buf += self.aimg(
|
||||||
|
".thumbnails/" + imglist[i].name,
|
||||||
|
imglist[i].name)
|
||||||
|
buf += self.endDiv()
|
||||||
|
buf += self.endDiv()
|
||||||
|
buf += self.footer
|
||||||
with open(f"{odir}/index.html", "w", encoding="utf-8") as file:
|
with open(f"{odir}/index.html", "w", encoding="utf-8") as file:
|
||||||
file.write(self.headermeta(title))
|
file.write(buf)
|
||||||
file.write(self.title(title))
|
|
||||||
if info is not None:
|
|
||||||
file.write(self.ul())
|
|
||||||
for line in info:
|
|
||||||
file.write(self.li(line))
|
|
||||||
file.write(self.endUl())
|
|
||||||
file.write(self.div("row"))
|
|
||||||
imglist = glob.glob(str(odir) + "/.thumbnails/*")
|
|
||||||
for n in range(0,3):
|
|
||||||
file.write(self.div("column"))
|
|
||||||
for i in range(n, len(imglist),3):
|
|
||||||
file.write(
|
|
||||||
self.aimg(
|
|
||||||
imglist[i].removeprefix(str(odir) + "/"),
|
|
||||||
imglist[i].removeprefix(str(odir) + "/.thumbnails/"),
|
|
||||||
)
|
|
||||||
)
|
|
||||||
file.write(self.endDiv())
|
|
||||||
file.write(self.endDiv())
|
|
||||||
file.write(self.footer)
|
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def writeDetail(self, img, previmg, nextimg):
|
def writeDetail(self, img, previmg, nextimg):
|
||||||
buf+= self.headermeta(title)
|
buf = self.headermeta(title)
|
||||||
buf+= self.title(title)
|
buf += self.title(title)
|
||||||
buf+= self.img(image)
|
buf += self.img(image)
|
||||||
buf+= self.footer
|
buf += self.footer
|
||||||
with open(f"build/{self.outfolder}/index.html", "w", encoding="utf-8") as file:
|
with open(f"build/{self.outfolder}/index.html", "w", encoding="utf-8") as file:
|
||||||
file.write(buf)
|
file.write(buf)
|
||||||
|
|
||||||
def writeMain(self):
|
def writeMain(self, titles):
|
||||||
with open(f"{str(BUILD_DIR)}/index.html", "w", encoding="utf-8") as file:
|
with open(f"{str(BUILD_DIR)}/index.html", "w", encoding="utf-8") as file:
|
||||||
title="Chrissys random Imagelibrary"
|
title = "Chrissys random Imagelibrary"
|
||||||
file.write(self.headermeta(title))
|
file.write(self.headermeta(title))
|
||||||
file.write(self.title(title))
|
file.write(self.title(title))
|
||||||
file.write(self.div("row"))
|
file.write(self.div("row"))
|
||||||
dirs = list(filter(lambda x: x.is_dir(),os.scandir(BUILD_DIR)))
|
dirs = list(
|
||||||
#dirs[:] = list(filter(lambda x: not x in exclude, dirs))
|
filter(lambda x: x.is_dir() and x not in exclude, os.scandir(BUILD_DIR))
|
||||||
for n in range(0,3):
|
)
|
||||||
|
for n in range(0, 3):
|
||||||
file.write(self.div("column"))
|
file.write(self.div("column"))
|
||||||
for i in range(n, len(dirs),3):
|
for i in range(n, len(dirs), 3):
|
||||||
thumbs = os.listdir(str(BUILD_DIR)+"/"+dirs[i].name+"/.thumbnails")
|
thumbs = os.listdir(
|
||||||
|
str(BUILD_DIR) + "/" + dirs[i].name + "/.thumbnails"
|
||||||
|
)
|
||||||
file.write(self.div("desc"))
|
file.write(self.div("desc"))
|
||||||
file.write("EH23")
|
file.write(titles[dirs[i].name])
|
||||||
file.write(self.endDiv())
|
file.write(self.endDiv())
|
||||||
file.write(
|
file.write(
|
||||||
self.aimg(
|
self.aimg(
|
||||||
str(dirs[i].name)+"/.thumbnails/"+thumbs[0],
|
str(dirs[i].name) + "/.thumbnails/" + thumbs[0],
|
||||||
str(dirs[i].name)+"/"),
|
str(dirs[i].name) + "/",
|
||||||
)
|
),
|
||||||
|
)
|
||||||
file.write(self.endDiv())
|
file.write(self.endDiv())
|
||||||
file.write(self.endDiv())
|
file.write(self.endDiv())
|
||||||
file.write(self.footer)
|
file.write(self.footer)
|
||||||
|
|
@ -163,42 +174,49 @@ def processImage(img, odir):
|
||||||
|
|
||||||
|
|
||||||
def generateDir(path):
|
def generateDir(path):
|
||||||
Path(BUILD_DIR / path.name).mkdir(parents=True, exist_ok=True)
|
odir = BUILD_DIR / path.name
|
||||||
Path(BUILD_DIR / path.name / ".thumbnails").mkdir(parents=True, exist_ok=True)
|
thumbdir = BUILD_DIR / path.name / ".thumbnails"
|
||||||
return Path(BUILD_DIR / path.name), Path(BUILD_DIR / path.name / ".thumbnails")
|
Path.mkdir(odir, parents=True, exist_ok=True)
|
||||||
|
Path.mkdir(thumbdir, parents=True, exist_ok=True)
|
||||||
|
return odir, thumbdir
|
||||||
|
|
||||||
def parseIni(file):
|
def parseIni(file):
|
||||||
title = ""
|
meta = {"title": None, "category": None, "description": [], "files": []}
|
||||||
desc=[]
|
|
||||||
files = []
|
|
||||||
try:
|
try:
|
||||||
with open(file, 'r') as f:
|
with open(file, "r") as f:
|
||||||
for line in f:
|
for line in f:
|
||||||
if line.startswith("desc = "):
|
if line.startswith("desc = "):
|
||||||
desc.append(line.removeprefix("desc = ").strip())
|
meta["description"].append(line.removeprefix("desc = ").strip())
|
||||||
elif line.endswith(".jpg\n" or ".png\n" or ".jpeg\n"):
|
elif line.endswith(".jpg\n" or ".png\n" or ".jpeg\n"):
|
||||||
files.append(line.strip())
|
meta["files"].append(line.strip())
|
||||||
elif line.startswith("title = "):
|
elif line.startswith("title = "):
|
||||||
title=line.removeprefix("title = ").strip()
|
meta["title"] = line.removeprefix("title = ").strip()
|
||||||
|
elif line.startswith("category = "):
|
||||||
|
meta["category"] = line.removeprefix("category = ").strip()
|
||||||
else:
|
else:
|
||||||
next
|
next
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
return files, desc, title
|
return meta
|
||||||
|
|
||||||
|
|
||||||
def processDir(path):
|
def processDir(path):
|
||||||
try:
|
try:
|
||||||
if Path(path/".purrpic.ini").is_file():
|
if Path.is_file(path /".purrpic.ini"):
|
||||||
files, desc, title = parseIni(Path(args.inpath/".purrpic.ini"))
|
breakpoint()
|
||||||
odir, thumbdir = generateDir(args.inpath)
|
meta = parseIni(path / ".purrpic.ini")
|
||||||
for img in files:
|
odir, thumbdir = generateDir(path)
|
||||||
createThumb(Path(args.inpath/img), thumbdir)
|
for img in meta["files"]:
|
||||||
processImage(Path(args.inpath/img), odir)
|
createThumb(path / img, thumbdir)
|
||||||
html = HTML()
|
processImage(path / img, odir)
|
||||||
html.writeIndex(thumbdir, odir, title, desc)
|
return odir, thumbdir, meta
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
def writeIndex(odir, meta):
|
||||||
|
html = HTML()
|
||||||
|
html.writeIndex(odir, meta)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
||||||
parser = argparse.ArgumentParser(
|
parser = argparse.ArgumentParser(
|
||||||
|
|
@ -208,13 +226,13 @@ if __name__ == "__main__":
|
||||||
)
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--inpath",
|
"--inpath",
|
||||||
type=lambda p: Path(p),
|
type=lambda p: Path(p).resolve(),
|
||||||
help="",
|
help="",
|
||||||
)
|
)
|
||||||
|
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--outpath",
|
"--outpath",
|
||||||
type=lambda p: Path(p),
|
type=lambda p: Path(p).resvolve(),
|
||||||
help="",
|
help="",
|
||||||
)
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
|
|
@ -224,8 +242,19 @@ if __name__ == "__main__":
|
||||||
help="",
|
help="",
|
||||||
)
|
)
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
breakpoint()
|
||||||
processDir(args.inpath)
|
if args.outpath:
|
||||||
|
BUILD_DIR = args.outpath
|
||||||
|
|
||||||
html=HTML()
|
metadata = {}
|
||||||
html.writeMain()
|
for d in args.inpath.iterdir():
|
||||||
|
if d.is_dir() and d.name not in exclude:
|
||||||
|
# processDir(d.name)
|
||||||
|
try:
|
||||||
|
odir, thumbdir, meta = processDir(d)
|
||||||
|
metadata[d.name] = meta
|
||||||
|
writeIndex(odir, meta)
|
||||||
|
except:
|
||||||
|
next
|
||||||
|
# html = HTML()
|
||||||
|
# html.writeMain(metadata)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue