Browse Source

generate atom feed from changelogs

master
Nils 7 months ago
parent
commit
6c8b9524ca
2 changed files with 90 additions and 1 deletions
  1. +79
    -0
      atomfeedgen.py
  2. +11
    -1
      generate.bash

+ 79
- 0
atomfeedgen.py View File

@@ -0,0 +1,79 @@
#! /usr/bin/env python3
# -*- coding: utf-8 -*-

#https://github.com/lkiesow/python-feedgen
#Package in Arch [Communiy] python-feedgen . Not python-feedgenerator

from zoneinfo import ZoneInfo
from datetime import datetime, timezone, tzinfo
import sys
from feedgen.feed import FeedGenerator


fg = FeedGenerator()

descs = {
"patroneo" : """Patroneo is an easy to use, pattern based midi sequencer.""",
"laborejo" : """Laborejo is a MIDI sequencer based on classical music notation.""",
"fluajho" : """Fluajho is a simple, standalone sf2 soundfont host/player.""",
"agordejo" : """Agordejo is a music and audio production session manager based on NSM.""",
}

if (not len(sys.argv) == 4) or not sys.argv[1] in descs or not sys.argv[2].endswith("/CHANGELOG") or not sys.argv[3].endswith("feed.atom"):
raise ValueError("Wrong number or wrong arguments: ./atomfeedgen.py patroneo /home/nils/lss/patroneo/CHANGELOG" "out/patroneo/feed.atom" )

project = sys.argv[1]
CHANGELOGFILE = sys.argv[2]
assert project in descs
description = descs[project]

print (f"Atom Feed Generation: {project}")

fg.id(f"https://laborejo.org/{project}/")
fg.title(f"{project.title()} Releases")
fg.author( {'name':'Laborejo Software Suite','email':'info@laborejo.org'} )
fg.link( href=f"https://laborejo.org/{project}/", rel='alternate' )
fg.logo(f"https://laborejo.org/images/{project}.png")
fg.subtitle(description)
fg.link( href=f"https://laborejo.org/{project}/feed.atom", rel="self" )
fg.language('en')



with open(CHANGELOGFILE) as fcl:
changelogData = fcl.read()


for cl in changelogData.split("\n\n"):

firstLine, changelog = cl.split("\n", maxsplit=1)
print(firstLine)
date, semVersion = firstLine.split("Version")
semVersion = semVersion.strip()
isodate = datetime.fromisoformat(date.strip())
isodate = isodate.replace(tzinfo=ZoneInfo("UTC"))


fe = fg.add_entry()
fe.id(f"https://laborejo.org/downloads/{project}-{semVersion}")
fe.title(f"{project.title()} Version {semVersion}")
#fe.link(href=f"https://laborejo.org/downloads/{project}-{semVersion}.tar.gz")
fe.link(href=f"https://laborejo.org/{project}")
fe.pubDate(isodate)
fe.rights("GPL3+")

cl = "</li>".join("<li>" + line.lstrip() for line in changelog.split("\n"))

desc = f"""
Download: <a href="https://laborejo.org/downloads/{project}-{semVersion}.tar.gz">https://laborejo.org/downloads/{project}-{semVersion}.tar.gz</a>
<p>
Changelog:
<ul>
{cl}
</ul>
</p>
"""
fe.content(desc, type="html")

atomfeed = fg.atom_str(pretty=True) # Get the ATOM feed as string
fg.atom_file(sys.argv[3]) # Write the ATOM feed to a file

+ 11
- 1
generate.bash View File

@@ -15,7 +15,7 @@ cd temp
#We loop over all projects several times, each stage of the generation.
#Instead of doing one project fully at a time, creating one giant nested loop.
#Administration first, the processing!
PROJECTS=(laborejo patroneo agordejo fluajho vico) #The order here is the order on the page. Each of these gets its own entry.
PROJECTS=(laborejo patroneo agordejo fluajho) #The order here is the order on the page. Each of these gets its own entry.
PROJECTS_AS_STRING=$( IFS=$' '; echo "${PROJECTS[*]}" )


@@ -35,6 +35,7 @@ do
done
cd "$ROOTPATH" #reset for next step


#Documentation, just a copy
for PROJECT in ${PROJECTS[*]}
do
@@ -43,6 +44,8 @@ do
cp -r "temp/$PROJECT/documentation/screenshot.png" "out/screenshots/$PROJECT.png" #there is now png and apng
done



#Generate Menu. n^2 loop. For each project all projects
for PROJECT in ${PROJECTS[*]}
do
@@ -80,6 +83,13 @@ do
cat "modules/10head" "temp/$PROJECT/module_menu" "modules/20aftermenu" "temp/$PROJECT/module_page" "modules/90foot" > "out/$PROJECT/index.html"
done

#Update Atom Release Feeds. We already need the project dirs in /out for this step.
for PROJECT in ${PROJECTS[*]}
do
./atomfeedgen.py "$PROJECT" "temp/$PROJECT/CHANGELOG" "out/$PROJECT/feed.atom"
done
cd "$ROOTPATH" #reset for next step

#Create Home/Welcome page
#A bit of redundancy first. Generate a menu.
echo "" > "temp/index_menu" #empty file

Loading…
Cancel
Save