On pipelink walls

The problem
I want to display a series of links in my homenode, pointing to all I’ve done here, either in alphabetical or random order.
The limitation
I’m lazy
The solution
Write code
You will need
Python. This was written with 3.x (c’mon, this is easy to install and I promise you don’t need anything else by default)
A proper Node Backup. Put all your html files in a single directory.
The result
A pretty wall like the one below

000: [???][???][???][???][???][???][???][???][???][???]
010: [???][???][???][???][???][???][???][???][???][???]
020: [???][???][???][???][???][???][???][???][???][???]
030: [???][???][???][???][???][???][???][???][???][???]
040: [???][???][???][???][???][???][???][???][???][???]
050: [???][???][???][???][???][???][???][???][???][???]
060: [???][???][???][???][???][???][???][???][???][???]
070: [???][???][???][???][???][???][???][???][???][???]
080: [???][???][???][???][???][???][???][???][???][???]
090: [???][???][???][???][???][???][???][???][???][???]
100: [???][???][???][???][???][???][???][???][???][???]
110: [???][???][???][???][???][???][???][???][???][???]
120: [???][???][???][???][???][???][???][???][???][???]
130: [???][???][???][???][???][???][???][???][???][???]
140: [???][???][???][???][???][???][???][???][???][???]
150: [???]

Limitations
The links are made based on the filenames of the html files. As such, some special characters (like semicolons or commas) might not appear in the final product. These will have to be cleaned by hand... if you can be bothered.

1 How-to

  1. Perform a Node Backup and put all your .html files in a single directory
  2. Look below for the line that says path = 'REDACTED' and put the path to the directory where you have all the files between the quote marks.
  3. Look a bit further for the line that says username = 'YOUR-NAME-HERE' and put your username between the quote marks
  4. By default, you don’t need to do anything else. Save this in a text document called e2wall.pyTell python to execute this script and you’ll end up with a small file called e2wall.txt. Copy and paste its contents in your homenode or whenever.

2 Advanced usage

You may change these to further customize the wall. Remember to put strings of characters between single or double quotes.

  • ignored is the list of nodetypes that the script will ignore, of course
  • character is the actual list of characters that will get displayed. Default is three question marks between square brackets, but you can change that easily
  • sep is what will separate one link from another. If you want to leave it blank, put ''
  • width is how many links per line you’ll have. Default is 10
  • chaos is just a variable controlling whether the links are shuffled. If set to False they will be displayed alphabetically.

3 Advanced advanced usage

Fine, you can go to the last few lines to further customize the line start, the links and whatnot. Look for the lines called f.write(). If you’re not smart enough to figure this out on your own, you shouldn’t be doing it.

4 Result

Copy and paste the results in your homenode, or a daylog, or wherever. Note that if you use very basic editors (Like the regular notepad) you might not see the line breaks. Please upgrade your software.

Send me any and all questions and suggestions. I may improve this toy in the future, watch this space.

5 The code

import os
#import markdown  # <-- could be useful later on for more powerful conversions
import re
import random

# original functions do not steal
def trim_extension(filename):
    '''
    Trims the html extension.
    '''
    return filename[:-5]

def get_title_and_type(filename):
    '''
    Returns (approximate) title and type of node.

    Assumes the filename is formatted like so:

        This is my node title (nodetype)

    If the filename cannot be parsed, it will return the strings
    "NONETYPE" and "unparseable"

    Parameters
    ----------
    filename : Path
         Path to a single file without extension.

    Returns
    -------
    TITLE
        String of the node title.
    TYPE
        String of the node type.

    '''
    regex = r"^(.+) \((.+)\)$"
    match = re.search(regex, filename)
    if match:
        return match.group(1), match.group(2)
    else:
        return "NONETYPE", "unparseable"

# -------------------------------------------------------------------------
# Most customization happens here!
# Edit these!

# Your path to the directory where all your html files live.
# This tool assumes the directory contains only your html 
# files as they are given after performing a node backup.

# Also, the filename limitations means your final links
# won't have semicolons, commas or other special characters.
# You might want to clear those in the final product.

# If you're on Windows, the double \\ are needed
path = 'REDACTED'

# Your username for inserting on the pipelinks
username = 'YOUR-NAME-HERE'

# If you want to filter out certain nodetypes, put them here
ignored = ['draft', 'log']

# The character(s) that will adorn the wall
character = '&#91;???&#93;'

# How do you want to separate these links? just write '' if you want no separation
sep = '&mdash;'

# How many of the above characters per line?
width = 10

# Want a randomized list?
chaos = True

# Most customization ends here.
# -------------------------------------------------------------------------

# Pay no attention to the man behind the curtain
final_titles = []
final_types = []
for root, dirs, files in os.walk(path):
    for filename in files:
        name = trim_extension(filename)
        title, nodetype = get_title_and_type(name)
        if nodetype not in ignored:
            final_titles.append(title)
            final_types.append(nodetype)

order = [i for i in range(len(final_titles))]
if chaos:
    random.shuffle(order)

# Ok maybe you can play around here

# Make sure you don't have a file called 'e2wall.txt', this will overwrite it.
with open('e2wall.txt','w+') as f:
    c = 0
    for n in order:
        # If you know how, you can alter this to further customize your wall
        if c % width == 0:
            # These go at the start of a line.
            f.write(f'{c:03}' + ': ')
        # General line. You can also access nodetypes with its appropriate list
        f.write('[%s[by %s]|%s]'%(final_titles[n], username, character))
        if c % width == width - 1:
            f.write('<br>\n') # Do not use regular notepad, use a real text editor.
        else:
            f.write(sep)
        c += 1

🜞⚔️⚔️⚔️⚔️⚔️⚔️⚔️⚔️⚔️