Compare commits
2 Commits
542c9aa856
...
78773c5091
Author | SHA1 | Date | |
---|---|---|---|
78773c5091 | |||
011cfb2c71 |
Binary file not shown.
Before Width: | Height: | Size: 1.2 KiB |
@ -85,3 +85,11 @@ My site is currently hosted at SourceHut's.
|
|||||||
=> https://soc.webair.xyz/@theo Fediverse: @theo@soc.webair.xyz
|
=> https://soc.webair.xyz/@theo Fediverse: @theo@soc.webair.xyz
|
||||||
=> https://matrix.to/#/@theo:mtrx.webair.xyz Matrix: @theo:mtrx.webair.xyz
|
=> https://matrix.to/#/@theo:mtrx.webair.xyz Matrix: @theo:mtrx.webair.xyz
|
||||||
=> mailto:theow@tutanota.de Mail: theow@tutanota.de
|
=> 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
|
||||||
|
@ -8,14 +8,15 @@
|
|||||||
<link href="atom.xml" type="application/atom+xml" rel="alternate" title="$GLOBAL_TITLE (all posts)" >
|
<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_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 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="me" href="https://soc.webair.xyz/@theo">
|
||||||
<link rel="canonical" href="$HTMLLINK">
|
<link rel="canonical" href="$HTMLLINK">
|
||||||
<style>
|
<style>
|
||||||
:root {
|
:root {
|
||||||
--bg: #20283d;
|
--bg: #191724;
|
||||||
--bg-alt: #426e5d;
|
--bg-alt: #403d52;
|
||||||
--fg: #fbf7f3;
|
--fg: #e0def4;
|
||||||
--fg-alt: #e5b083;
|
--fg-alt: #eb6f92;
|
||||||
}
|
}
|
||||||
body {
|
body {
|
||||||
margin:40px auto;
|
margin:40px auto;
|
||||||
@ -35,13 +36,19 @@
|
|||||||
line-height:1.2;
|
line-height:1.2;
|
||||||
border-bottom: 1px solid;
|
border-bottom: 1px solid;
|
||||||
}
|
}
|
||||||
pre,blockquote,.signature{
|
|
||||||
background: var(--bg-alt);
|
|
||||||
padding: 1em;
|
|
||||||
}
|
|
||||||
blockquote,.signature{
|
blockquote,.signature{
|
||||||
font-style: italic;
|
font-style: italic;
|
||||||
margin: 2em 1em;
|
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{
|
.signature{
|
||||||
text-align: center;
|
text-align: center;
|
||||||
@ -61,7 +68,6 @@
|
|||||||
display: block;
|
display: block;
|
||||||
margin-left: auto;
|
margin-left: auto;
|
||||||
margin-right: auto;
|
margin-right: auto;
|
||||||
width: 60%;
|
|
||||||
}
|
}
|
||||||
.header{
|
.header{
|
||||||
margin: 1em 0;
|
margin: 1em 0;
|
||||||
|
84
publish.py
84
publish.py
@ -13,10 +13,10 @@ import unicodedata
|
|||||||
global_title = "webair.xyz"
|
global_title = "webair.xyz"
|
||||||
global_subtitle = "Alice's web corner"
|
global_subtitle = "Alice's web corner"
|
||||||
global_name = "Alice"
|
global_name = "Alice"
|
||||||
htmldir = "./public_html"
|
base_url = "webair.xyz/"
|
||||||
|
|
||||||
geminidir = "./public_gemini"
|
geminidir = "./public_gemini"
|
||||||
base_url = "webair.xyz/"
|
htmldir = "./public_html"
|
||||||
local_url = "/home/ploum/dev/gemlog/"
|
local_url = "/home/ploum/dev/gemlog/"
|
||||||
short_limit = 25
|
short_limit = 25
|
||||||
maxwidth = 72
|
maxwidth = 72
|
||||||
@ -26,12 +26,28 @@ html_page_template = "page_template.html"
|
|||||||
email_template = "email_template.html"
|
email_template = "email_template.html"
|
||||||
gemini_page_template = "page_template.gmi"
|
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 generate_rels(links):
|
||||||
|
result = ""
|
||||||
|
for link in links:
|
||||||
|
result += f'<link rel="me" href="https://soc.webair.xyz/@theo">\n'
|
||||||
|
return result
|
||||||
|
|
||||||
|
|
||||||
def fill_globals(text):
|
def fill_globals(text):
|
||||||
return text.replace("$AUTHOR", global_name)\
|
return text.replace("$AUTHOR", global_name)\
|
||||||
.replace("$BASE_URL", base_url)\
|
.replace("$BASE_URL", base_url)\
|
||||||
.replace("$GLOBAL_TITLE", global_title)\
|
.replace("$GLOBAL_TITLE", global_title)\
|
||||||
.replace("$SUBTITLE", global_subtitle)
|
.replace("$SUBTITLE", global_subtitle)\
|
||||||
|
|
||||||
|
|
||||||
# Add the html version to the post dictionnary
|
# Add the html version to the post dictionnary
|
||||||
@ -95,7 +111,7 @@ def gmi2html(raw,index=False,signature=None,relative_links=True,local=False):
|
|||||||
content += sanitize(line[2:])
|
content += sanitize(line[2:])
|
||||||
content += "</h1>\n"
|
content += "</h1>\n"
|
||||||
elif line.startswith("=>"):
|
elif line.startswith("=>"):
|
||||||
splitted = line[2:].strip().split(maxsplit=1)
|
splitted = line.strip().split(maxsplit=2)[1:]
|
||||||
link = splitted[0]
|
link = splitted[0]
|
||||||
#converting local links
|
#converting local links
|
||||||
if "://" not in link and link.endswith(".gmi"):
|
if "://" not in link and link.endswith(".gmi"):
|
||||||
@ -110,16 +126,14 @@ def gmi2html(raw,index=False,signature=None,relative_links=True,local=False):
|
|||||||
else:
|
else:
|
||||||
name = sanitize(splitted[1])
|
name = sanitize(splitted[1])
|
||||||
description = name
|
description = name
|
||||||
if link[-4:] in [".jpg",".png",".gif"] or link[-5:] == ".jpeg":
|
if is_image(link):
|
||||||
if inul:
|
if inul:
|
||||||
content += "</ul>\n"
|
content += "</ul>\n"
|
||||||
inul = False
|
inul = False
|
||||||
#content += "<div class=\"center\">"
|
imgtag = f"<img alt='{name}' src='{link}' class='center'>"
|
||||||
imgtag = "<img alt=\"%s\" src=\"%s\" width=\"450\" class=\"center\">"%(name,link)
|
content += f"<a href='{link}'>{imgtag}</a>"
|
||||||
content += "<a href=\"%s\">"%link + imgtag + "</a>"
|
|
||||||
#content += "</div>"
|
|
||||||
if description:
|
if description:
|
||||||
content += "<p class=\"subtitle\">" + description + "</p>"
|
content += f"<p class='subtitle'>{description}</p>"
|
||||||
else:
|
else:
|
||||||
if not inul:
|
if not inul:
|
||||||
if inindex:
|
if inindex:
|
||||||
@ -195,36 +209,18 @@ def build_post(filepath,lang="fr",signature=True,relative_links=True,local=False
|
|||||||
with open(filepath) as fi:
|
with open(filepath) as fi:
|
||||||
lines = fi.readlines()
|
lines = fi.readlines()
|
||||||
fi.close()
|
fi.close()
|
||||||
#special case for wordpress imported content
|
filename = ".".join(filepath.name.split(".")[:-1]) # Remove the extension
|
||||||
#to preserver URL
|
post["gmifilename"] = filename + ".gmi"
|
||||||
f = filepath.name
|
post["htmlfilename"] = filename + ".html"
|
||||||
# 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"
|
|
||||||
post["gem_url"] = "gemini://" + base_url + post["gmifilename"]
|
post["gem_url"] = "gemini://" + base_url + post["gmifilename"]
|
||||||
post["html_url"] = "https://" + base_url + post["htmlfilename"]
|
post["html_url"] = "https://" + base_url + post["htmlfilename"]
|
||||||
if len(lines) > 0 and lines[0].startswith("# "):
|
if len(lines) > 0 and lines[0].startswith("# "):
|
||||||
post["title"] = lines.pop(0).strip("# ").strip()
|
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)
|
content = "".join(lines)
|
||||||
post["gem_content"] = content
|
post["gem_content"] = content
|
||||||
if f.startswith("20") and len(f) >= 14:
|
# This code will be outdated in 2100
|
||||||
# We need to get the title of the post
|
if filename.startswith("20") and len(filename.split("-")) > 3:
|
||||||
line = ""
|
post["date"] = "-".join(filename.split("-")[:3])
|
||||||
post["date"] = f[:10]
|
|
||||||
elif f.startswith("20"):
|
|
||||||
post["date"] = f
|
|
||||||
else:
|
else:
|
||||||
post["date"] = ""
|
post["date"] = ""
|
||||||
# on produit la version html avec la signature
|
# on produit la version html avec la signature
|
||||||
@ -235,18 +231,9 @@ def build_post(filepath,lang="fr",signature=True,relative_links=True,local=False
|
|||||||
sigf.close()
|
sigf.close()
|
||||||
else:
|
else:
|
||||||
signature_content = None
|
signature_content = None
|
||||||
|
|
||||||
post["html_content"] = gmi2html(content,signature=signature_content,relative_links=relative_links,\
|
post["html_content"] = gmi2html(content,signature=signature_content,relative_links=relative_links,\
|
||||||
local=local)
|
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
|
return post
|
||||||
|
|
||||||
def build_list(allposts,folder,local=False):
|
def build_list(allposts,folder,local=False):
|
||||||
@ -470,15 +457,6 @@ def writehtml(post):
|
|||||||
ff.close()
|
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):
|
def writegmi(post):
|
||||||
with open(gemini_page_template) as f:
|
with open(gemini_page_template) as f:
|
||||||
template = f.read()
|
template = f.read()
|
||||||
|
BIN
static/img/button.png
Normal file
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
BIN
static/img/favicon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.6 KiB |
Loading…
Reference in New Issue
Block a user