diff --git a/bscripts/index.html b/bscripts/index.html index 8974ef2..2077d69 100644 --- a/bscripts/index.html +++ b/bscripts/index.html @@ -9,11 +9,8 @@ (yes i know i hate python but its v quick for simple stuff) to transform input from ls into a list of <a> tags(with space between)

-

- here is the list of files here: -
- cd $CURRENT && ls *.* | python3 $HOME/bscripts/ls_to_a.py -

+
+ python $HOME/bscripts/ls_table.py $CURRENT diff --git a/bscripts/ls_table.py b/bscripts/ls_table.py new file mode 100644 index 0000000..97a149e --- /dev/null +++ b/bscripts/ls_table.py @@ -0,0 +1,27 @@ +import sys +import os +import time +# Make sure we got a directory +if len(sys.argv) < 2: + print("Error: Directory not given!") + quit() +# Get path, files, and creation/modification times +path = sys.argv[1] +file_filter = sys.argv[2] if len(sys.argv) > 2 else '' +files = [[x, os.path.getctime(f'{path}/{x}'), os.path.getmtime(f'{path}/{x}')] for x in os.listdir(path) if x.endswith(file_filter)] +# sort by creation time +files.sort(key= lambda x: x[1], reverse=True) +# print start of table(including headers) +print('') +print('\n') + +# print each row +for x in files: + if x[0] == 'index.html': # skip the index.html file because kinda boring + continue + x[0] = f'{x[0].replace(".html", "")}' + x[1] = time.strftime("%b %d %Y", time.strptime(time.ctime(x[1]))) + x[2] = time.strftime("%b %d %Y", time.strptime(time.ctime(x[2]))) + print(f''); +# finish printing the table +print('
CreatedModified
{x[0]}{x[1]}{x[2]}
') diff --git a/bscripts/ls_to_a.py b/bscripts/ls_to_a.py index cc5833c..e94744e 100644 --- a/bscripts/ls_to_a.py +++ b/bscripts/ls_to_a.py @@ -6,4 +6,4 @@ while True: a = input() except: break - print('' + a.replace('.html', '') + '') + print('' + a.replace('.html', '') + ' ') diff --git a/index.html b/index.html index e0586df..d5f11af 100644 --- a/index.html +++ b/index.html @@ -1,10 +1,9 @@ cat $HOME/template/header.html | sed "s/__PAGE TITLE__/Rusty's website/"

- Folders: cd $CURRENT && ls */ -d | sed 's/\///' | python3 $HOME/bscripts/ls_to_a.py -
- Files: cd $CURRENT && ls *.html | python3 $HOME/bscripts/ls_to_a.py + Folders
cd $CURRENT && ls */ -d | sed 's/\///' | python3 $HOME/bscripts/ls_to_a.py +

+ Files
cd $CURRENT && ls *.html | python3 $HOME/bscripts/ls_to_a.py

-

Hello and welcome to my personal website diff --git a/old_index.html b/old_index.html index 87638fa..e480666 100644 --- a/old_index.html +++ b/old_index.html @@ -1,8 +1,8 @@ cat $HOME/template/header.html | sed "s/__PAGE TITLE__/Rusty's website/"

- Folders: cd $CURRENT && ls */ -d | sed 's/\///' | python3 $HOME/bscripts/ls_to_a.py -
- Files: cd $CURRENT && ls *.html | python3 $HOME/bscripts/ls_to_a.py + Folders
cd $CURRENT && ls */ -d | sed 's/\///' | python3 $HOME/bscripts/ls_to_a.py +

+ Files
cd $CURRENT && ls *.html | python3 $HOME/bscripts/ls_to_a.py

diff --git a/stories/index.html b/stories/index.html index d75cdd2..8bcb174 100644 --- a/stories/index.html +++ b/stories/index.html @@ -7,11 +7,8 @@
or about stuff that happens to me

-

- Stories: -
- cd $CURRENT && ls *.html | python3 $HOME/bscripts/ls_to_a.py -

+
+ python $HOME/bscripts/ls_table.py $CURRENT .html

diff --git a/stories/injector.html b/stories/injector.html index 0b14e85..a372248 100644 --- a/stories/injector.html +++ b/stories/injector.html @@ -1,8 +1,8 @@ cat $HOME/template/header.html | sed "s/__PAGE TITLE__/Injector/"

- Folders: cd $CURRENT && ls */ -d | sed 's/\///' | python3 $HOME/bscripts/ls_to_a.py -
- Files: cd $CURRENT && ls *.html | python3 $HOME/bscripts/ls_to_a.py + Folders
cd $CURRENT && ls */ -d | sed 's/\///' | python3 $HOME/bscripts/ls_to_a.py +

+ Files
cd $CURRENT && ls *.html | python3 $HOME/bscripts/ls_to_a.py

Injector

diff --git a/template/index.html b/template/index.html index e82ad13..cc01742 100644 --- a/template/index.html +++ b/template/index.html @@ -7,11 +7,8 @@ like the header and footer of the pages(also contains the start and end of the pages!, tho I might change that)

-

- here is the list of templates in here: -
- cd $CURRENT && ls *.html | python3 $HOME/bscripts/ls_to_a.py -

+
+ python $HOME/bscripts/ls_table.py $CURRENT diff --git a/useful/index.html b/useful/index.html index e4cef02..c9c9dd6 100644 --- a/useful/index.html +++ b/useful/index.html @@ -5,9 +5,8 @@

Useful stuff to know/resources

-

- cd $CURRENT && ls *.html | python3 $HOME/bscripts/ls_to_a.py -

+
+ python $HOME/bscripts/ls_table.py $CURRENT