mirror of https://git.davidovski.xyz/kblg.git
added rss
This commit is contained in:
parent
e021b7b1f8
commit
07b3876853
25
build.py
25
build.py
|
@ -39,8 +39,12 @@ def formatEntry(content, page):
|
||||||
|
|
||||||
def make():
|
def make():
|
||||||
|
|
||||||
shutil.rmtree(dist)
|
try:
|
||||||
os.makedirs(os.path.join(dist, "entries"))
|
os.makedirs(os.path.join(dist, "entries"))
|
||||||
|
except:
|
||||||
|
print("Already have content")
|
||||||
|
shutil.rmtree(os.path.join(dist, "src"))
|
||||||
|
shutil.rmtree(os.path.join(dist, "images"))
|
||||||
shutil.copytree(source, os.path.join(dist, "src"))
|
shutil.copytree(source, os.path.join(dist, "src"))
|
||||||
shutil.copytree(images, os.path.join(dist, "images"))
|
shutil.copytree(images, os.path.join(dist, "images"))
|
||||||
|
|
||||||
|
@ -53,7 +57,7 @@ def make():
|
||||||
formatEntry(summary_templ, page)
|
formatEntry(summary_templ, page)
|
||||||
.replace(
|
.replace(
|
||||||
"%content%",
|
"%content%",
|
||||||
"\n".join(page["html"].split("\n")[:10])
|
"\n".join(page["html"].split("\n")[:summary_max])
|
||||||
)
|
)
|
||||||
|
|
||||||
for page in pages
|
for page in pages
|
||||||
|
@ -82,6 +86,21 @@ def make():
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
item_templ = getTemplateHTML("item.xml")
|
||||||
|
rss_templ = getTemplateHTML("rss.xml")
|
||||||
|
itemsXML = "\n".join(
|
||||||
|
[
|
||||||
|
formatEntry(item_templ, page).replace("%content%", page["html"])
|
||||||
|
for page in pages
|
||||||
|
]
|
||||||
|
)
|
||||||
|
|
||||||
|
with open(os.path.join(dist, "rss.xml"), "w") as index:
|
||||||
|
index.write(
|
||||||
|
rss_templ.replace("%items%", itemsXML)
|
||||||
|
)
|
||||||
|
|
||||||
|
print(f"built in {len(pages)} pages")
|
||||||
make()
|
make()
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
<item>
|
||||||
|
<title>%name%</title>
|
||||||
|
<link>https://davidovski.xyz/%url%</link>
|
||||||
|
<pubDate>%date%</pubDate>
|
||||||
|
<description><![CDATA[%content%]]></description>
|
||||||
|
</item>
|
|
@ -0,0 +1,10 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<rss version="2.0">
|
||||||
|
|
||||||
|
<channel>
|
||||||
|
<title>kblg</title>
|
||||||
|
<link>https://github.com/davidovski/kblg</link>
|
||||||
|
<description>kblg</description>
|
||||||
|
%items%
|
||||||
|
</channel>
|
||||||
|
</rss>
|
Loading…
Reference in New Issue