You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

3.3 KiB

title description date categories cover cover_alt
Soup to Wiki Teleport this log to the wiki (teleport not ready yet) 12/04/2022
Log
Wiki
wiki-soup.jpg wikipedia page for soup sorry

Since the Soupboat is fragile and temporary (like everything else?), it's nice to keep this documentation updated also in the Wiki.

update 12/04

Since the previous version was too messy I tried with a more concise approach. Instead of dumping the whole contents I choose to report only title + description and a link to the project here in the SB.

The page is generated with Mako, started looking at it during the workshop with Brendan. Its syntax seems much more legible than the Jinja2's one.

The code is more or less the same. Find it in this notebook. The file for the template is baloons.html.

And this is the result !!!!!

first attempt 21/02

ATM i'm using this notebook to do a simple conversion from all the markdown files of these pages to wikitext. In this way it's less painful (but also less curated?) to have the wiki up to date. It uses pypandoc, that is a python wrapper for pandoc.



import os
import frontmatter
from datetime import datetime
import pypandoc

def list_folders(folder):
    ''' Return all the folders in a folder '''
    names = []
    for entry in os.scandir(folder):
        # add to the list only proper files
        if not entry.name.startswith('.') and entry.is_dir():
            # remove the extension from the filename
            names.append(entry.name)
    return names

def get_md_contents(filename, directory='./contents'):
    ''' Return contents from a filename as frontmatter handler '''
    with open(f"{directory}/{filename}", "r") as f:
        metadata, content = frontmatter.parse(f.read())
    return metadata, content


# in the projects directory there is a folder for every project.
# The info about the project are in a "documentation.md" file

folders = list_folders('public_html/projects')
projects = []

for folder in folders:
    project = get_md_contents('documentation.md', f'public_html/projects/{folder}')    
    project_date = datetime.strptime(project[0]['date'], '%d/%m/%Y')
    project[0]['date'] = datetime.strftime(project_date, '%d %b, %y')
    project[0]['categories'].sort()
    projects.append(project)

    
# the projects are sorted by date
projects.sort(reverse=False, key=lambda project: datetime.strptime(
    project[0]['date'], '%d %b, %y'))
    


# the variable page will be filled with wikitext
page = ''

# here we insert a bit of meta info such as the title and the description  
for project in projects:
       
    page = page + f"==={project[0]['title']}=== \n"
    page = page + f"''{project[0]['description']}''\n"
    page = page + pypandoc.convert_text(project[1], 'mediawiki', format='md',  extra_args=['--base-header-level=3'])
  
# and then i copy this result and paste it in the wiki 
print(page)


there are still problems (as always?) especially with the images, that need to be uploaded manually in the wiki........... maybe i will provide super nice alt description to avoid this tedious workk sorry.

ok