Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
150 changes: 0 additions & 150 deletions archive/search.html

This file was deleted.

45 changes: 31 additions & 14 deletions scripts/make_flat.py
Original file line number Diff line number Diff line change
@@ -1,31 +1,48 @@
#!/bin/python
"""
Make the organization of the mirror flat so that relative URLs cooperate
Produces a flat_archive version of the archive without OSF category folders registration, profile, and project, so that relative URLs cooperate

archive/project/mst3k -> archive/mst3k

:param 1 in CLI: folder to flatten
WARNING: Utilities will not work with a flattened archive

:param for CLI use: directory to flatten
"""
import os
import shutil
import sys

mirror = 'archive/' if len(sys.argv) < 2 else sys.argv[1] + '/'

inflated_directories = ['project/', 'registration/']

print("Flattening:", mirror)
def make_wiki_flat(subdir):
wiki_home = subdir + '/wiki/home/index.html'
if os.path.exists(wiki_home):
shutil.copy(wiki_home, subdir + '/wiki/index.html')


def remove_organization():
"""
Removes category folders and calls make_wiki_flat
:return:
"""
inflated_categories = ['project/', 'registration/', 'profile/']
for category in inflated_categories:
category_path = 'archive/' + category

for directory in inflated_directories:
if not os.path.exists(category_path):
continue

path = 'archive/' + directory
if os.path.exists(category_path + '/.DS_Store'):
os.remove(category_path + '/.DS_Store')

if not os.path.exists(path):
continue
subdirs = os.listdir(category_path)
for dir in subdirs:
make_wiki_flat(dir)
shutil.move(category_path + dir, 'archive/' + dir)
os.rmdir(category_path)

if os.path.exists(path + '/.DS_Store'):
os.remove(path + '/.DS_Store')
if __name__ == "__main__":
print("Flattening:", mirror)

subdirs = os.listdir(path)
for dir in subdirs:
shutil.move(path + dir, 'archive/' + dir)
os.rmdir(path)
remove_organization()