Added a 88x31 button

This commit is contained in:
theo@manjaro 2023-01-12 23:40:30 +01:00
parent 542c9aa856
commit 011cfb2c71
6 changed files with 42 additions and 58 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

View File

@ -85,3 +85,11 @@ My site is currently hosted at SourceHut's.
=> https://soc.webair.xyz/@theo Fediverse: @theo@soc.webair.xyz
=> https://matrix.to/#/@theo:mtrx.webair.xyz Matrix: @theo:mtrx.webair.xyz
=> mailto:theow@tutanota.de Mail: theow@tutanota.de
I also made a 88x31 button for this site !
You can integrate it in your site with the following code :
```
<a href='https://webair.xyz'><img src='https://webair.xyz/img/button.png' width=88 height=31></a>
```
=> img/button.png The 88x31 button, showing the website's name with some hearts

View File

@ -8,7 +8,7 @@
<link href="atom.xml" type="application/atom+xml" rel="alternate" title="$GLOBAL_TITLE (all posts)" >
<link href="atom_en.xml" type="application/atom+xml" rel="alternate" title="$GLOBAL_TITLE (EN only)" >
<link href="atom_fr.xml" type="application/atom+xml" rel="alternate" title="$GLOBAL_TITLE (en français)" >
<link rel="shortcut icon" href="favicon.png" >
<link rel="shortcut icon" href="img/favicon.png" >
<link rel="canonical" href="$HTMLLINK">
<style>
:root {
@ -35,13 +35,19 @@
line-height:1.2;
border-bottom: 1px solid;
}
pre,blockquote,.signature{
background: var(--bg-alt);
padding: 1em;
}
blockquote,.signature{
font-style: italic;
margin: 2em 1em;
background: var(--bg-alt);
padding: 1em;
}
pre {
overflow: auto;
padding: 5px;
background-color: var(--bg-alt);
border-style: dashed;
border-width: 5px;
border-color: var(--bg);
}
.signature{
text-align: center;
@ -61,7 +67,6 @@
display: block;
margin-left: auto;
margin-right: auto;
width: 60%;
}
.header{
margin: 1em 0;

View File

@ -13,10 +13,10 @@ import unicodedata
global_title = "webair.xyz"
global_subtitle = "Alice's web corner"
global_name = "Alice"
htmldir = "./public_html"
base_url = "webair.xyz/"
geminidir = "./public_gemini"
base_url = "webair.xyz/"
htmldir = "./public_html"
local_url = "/home/ploum/dev/gemlog/"
short_limit = 25
maxwidth = 72
@ -26,6 +26,15 @@ html_page_template = "page_template.html"
email_template = "email_template.html"
gemini_page_template = "page_template.gmi"
image_extensions = [".png", ".jpg", ".jpeg"]
def is_image(link):
for ext in image_extensions:
if link.endswith(ext):
return True
return False
def fill_globals(text):
return text.replace("$AUTHOR", global_name)\
@ -95,7 +104,7 @@ def gmi2html(raw,index=False,signature=None,relative_links=True,local=False):
content += sanitize(line[2:])
content += "</h1>\n"
elif line.startswith("=>"):
splitted = line[2:].strip().split(maxsplit=1)
splitted = line.strip().split(maxsplit=2)[1:]
link = splitted[0]
#converting local links
if "://" not in link and link.endswith(".gmi"):
@ -110,16 +119,14 @@ def gmi2html(raw,index=False,signature=None,relative_links=True,local=False):
else:
name = sanitize(splitted[1])
description = name
if link[-4:] in [".jpg",".png",".gif"] or link[-5:] == ".jpeg":
if is_image(link):
if inul:
content += "</ul>\n"
inul = False
#content += "<div class=\"center\">"
imgtag = "<img alt=\"%s\" src=\"%s\" width=\"450\" class=\"center\">"%(name,link)
content += "<a href=\"%s\">"%link + imgtag + "</a>"
#content += "</div>"
imgtag = f"<img alt='{name}' src='{link}' class='center'>"
content += f"<a href='{link}'>{imgtag}</a>"
if description:
content += "<p class=\"subtitle\">" + description + "</p>"
content += f"<p class='subtitle'>{description}</p>"
else:
if not inul:
if inindex:
@ -195,36 +202,18 @@ def build_post(filepath,lang="fr",signature=True,relative_links=True,local=False
with open(filepath) as fi:
lines = fi.readlines()
fi.close()
#special case for wordpress imported content
#to preserver URL
f = filepath.name
# old if the last directory is called old
old = filepath.parent.parts[-1] == "old"
if old:
slug = f[11:-4] #we remove the date and extension
post["gmifilename"] = slug + "/index.gmi"
post["htmlfilename"] = slug + "/index.html"
#normal case
else:
post["gmifilename"] = f[:-4] + ".gmi"
post["htmlfilename"] = f[:-4] + ".html"
filename = ".".join(filepath.name.split(".")[:-1]) # Remove the extension
post["gmifilename"] = filename + ".gmi"
post["htmlfilename"] = filename + ".html"
post["gem_url"] = "gemini://" + base_url + post["gmifilename"]
post["html_url"] = "https://" + base_url + post["htmlfilename"]
if len(lines) > 0 and lines[0].startswith("# "):
post["title"] = lines.pop(0).strip("# ").strip()
# special case for header images which are right after the title
if len(lines) > 0 and lines[0].startswith("=> "):
if lines[0].strip().endswith(".jpg") or lines[0].strip().endswith(".png") or\
lines[0].strip().endswith(".jpeg"):
post["image"] = lines.pop(0).removeprefix("=> ").strip()
content = "".join(lines)
post["gem_content"] = content
if f.startswith("20") and len(f) >= 14:
# We need to get the title of the post
line = ""
post["date"] = f[:10]
elif f.startswith("20"):
post["date"] = f
# This code will be outdated in 2100
if filename.startswith("20") and len(filename.split("-")) > 3:
post["date"] = "-".join(filename.split("-")[:3])
else:
post["date"] = ""
# on produit la version html avec la signature
@ -235,18 +224,9 @@ def build_post(filepath,lang="fr",signature=True,relative_links=True,local=False
sigf.close()
else:
signature_content = None
post["html_content"] = gmi2html(content,signature=signature_content,relative_links=relative_links,\
local=local)
txt = ""
if "title" in post.keys():
txt += textwrap.fill(post["title"].upper(),width=maxwidth) + "\n"
txt += "by Ploum"
if "date" in post.keys():
txt += " on %s"%post["date"]
txt += "\n\n"
txt += post["html_url"] + "\n\n"
txt += plaintext(content)
post["plaintext_content"] = txt
return post
def build_list(allposts,folder,local=False):
@ -470,15 +450,6 @@ def writehtml(post):
ff.close()
def make_email(file, lang, html=True):
post = build_post(file, lang, signature=False, relative_links=False)
if html:
content = filltemplate(post, email_template)
else:
content = post["plaintext_content"]
return content
def writegmi(post):
with open(gemini_page_template) as f:
template = f.read()

BIN
static/img/button.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

BIN
static/img/favicon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB