---
title: Soup to Wiki
description: Teleport this log to the wiki (teleport not ready yet)
date: 12/04/2022
categories:
  - Log
  - Wiki
cover: wiki-soup.jpg
cover_alt: 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](https://pzwiki.wdka.nl/mediadesign/Main_Page).

## 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](https://www.makotemplates.org/), 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](log_to_wiki_2.ipynb). The file for the template is [baloons.html](baloons.html).

[And this is the result !!!!!](output.html)

## first attempt 21/02



ATM i'm using this [notebook](log_to_wiki.ipynb) 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](https://pypi.org/project/pypandoc/), that is a python wrapper for [pandoc](https://pandoc.org/). 

```python


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

