Source Code | NiCL1g3r bootstrap plus generator
This program generates NoNIC and L1G3R from the steps directory, which is built using the build tab of MAN. Just pass nic or l1g as the parameter, and it will create the proper source directories so that MON will generate the website.
Here is the source:
#!/usr/bin/python3 # coding=utf-8 #noNiCL1g3r bootstrap plus generator # The person who associated a work with this deed has dedicated # the work to the public domain by waiving all of his or her rights # to the work worldwide under copyright law, including all related # and neighboring rights, to the extent allowed by law. # You can copy, modify, distribute and perform the work, even for # commercial purposes, all without asking permission. # In no way are the patent or trademark rights of any person affected by # CC0, nor are the rights that other persons may have in the work or in # how the work is used, such as publicity or privacy rights. # Unless expressly stated otherwise, the person who associated a work with # this deed makes no warranties about the work, and disclaims liability # for all uses of the work, to the fullest extent permitted by applicable law. # When using or citing the work, you should not imply endorsement by the # author or the affirmer. # https://creativecommons.org/publicdomain/zero/1.0/ # # Weirdness: no ~ or whitespace in name of component title for build. no : in source filename for build # # Technical debt: using os.system is nasty, particularly with spaces in the path. I should # re-write using python tools. This is getting way too specific. I originally went this route # because cat was such an easy way to add to the bottom of the file. Bad design decision. # Just consider this a hacked up structure to support the water dispenser at base camp, and consider # tomorrow's ascent, ignoring just how very ugly the water dispenser support is. import os import sys import re from scandir import scandir, walk from os.path import expanduser try: sitename=sys.argv.rstrip() except: print('Provide "l1g" or "nic" as sitename.') sys.exit(1) home = expanduser("~")+'/sync' rootdoc=home+'/websites/source/'+sitename+'/0/' sitehome=home+'/websites/site/'+sitename+'/' #os.system("rm -rf '"+rootdoc+"1'") steps=home+'/websites/'+sitename+'steps/' bits=re.compile('^(\d+)$') scans=scandir(steps) buildonly='457' #buildone=True trbld=True #trbld copies source files that are part of the base image buildone=False if buildone: print('Only number: '+buildonly) #^ this can be used to view individual pages immediately; however, the nav will break. The entire site really # needs to be regenerated for nav (last page is always changing, as is next page on the second to the last page). # The tags are auto-generated from the title, so as long as the journal and other sites have the corresponding tag, # there will be cross-referencing. for s in scans: try: m = bits.match(s.name) label=m.group(1) tranny=False if (s.name==buildonly or not buildone): if int(s.name) < 73 and sitename=='l1g': tranny=True elif int(s.name) < 32 and sitename=='nic': tranny=True drt=rootdoc+'1/'+s.name+'/' sdrt=sitehome+'1/'+s.name+'/' os.system("mkdir -p '"+drt+"'") srt=steps+s.name+'/' if os.path.isfile(srt+'outputfull.txt'): os.system("cat '"+srt+"outputfull.txt' > '"+sdrt+"outputfull.txt'") if os.path.isfile(srt+'date.txt'): with open(srt+'/date.txt','r') as fd: dtt=fd.read() dt=dtt[:4]+'-'+dtt[4:6]+'-'+dtt[6:8] with open(srt+'notes.md','r') as fn: fullnote=fn.read() srccount=fullnote.count('<!--s-->') with open(drt+'/narrative.md','w+') as fn: fn.write(fullnote) if os.path.isfile(srt+'files.txt'): with open(srt+'files.txt','r') as fl: os.system("echo '\n\n<table><tr><th>Source</th><th>MD5</th>' >> '"+drt+"narrative.md'") for line in fl.readlines(): parts=line.split(' : ') if trbld and tranny: trnfile=parts.rstrip() trnmd5=parts.rstrip() #os.system("mkdir -p '"+sitehome+"/source/"+trnmd5+"/'") #os.system("cp -f '"+home+"/websites/l1g3rsources/"+trnfile+"' '"+sitehome+"source/"+trnmd5+"/'") #above two are for md5 access os.system("cp -f '"+home+"/websites/l1g3rsources/"+trnfile+"' '/backup/mcjsource/'") os.system("echo '<tr><td>"+parts.rstrip()+"</td>' >> '"+drt+"narrative.md'") os.system("echo '<td>"+parts+"</td></tr>\n' >> '"+drt+"narrative.md'") os.system("echo '</table>\n' >> '"+drt+"narrative.md'") os.system("mkdir -p '"+drt+"has_source';cat '"+srt+"command.txt' > '"+drt+"has_source/"+str(1+srccount)+".txt';cat '"+srt+"output.txt' > '"+drt+"has_source/"+str(2+srccount)+".txt'") os.system("echo 'sh' > '"+drt+"has_source/"+str(1+srccount)+".type.txt'") os.system("echo 'txt' > '"+drt+"has_source/"+str(2+srccount)+".type.txt'") os.system("echo 'Run these commands to compile and install: \n\n<div class=\"output\"><!--s--></div>\n\nYou should see something like this as output:\n\n<div class=\"output\"><!--s--></div>\n\n[full raw output](outputfull.txt)\n\n' >> '"+drt+"narrative.md'") with open(srt+'/title.txt','r') as ft: nn=ft.read().rstrip().replace('-','_')+'.md' with open(drt[:-1]+'.title.txt','w+') as f: f.write(nn[:-3]) os.system("touch '"+rootdoc+"tags/"+nn+"'") os.system("mkdir -p '"+drt+"has_tag';cd '"+drt+"has_tag/';ln -s ../../../tags/"+nn+" ./"+nn) except: six=9