better file listing for sub folders(and normal listing)
This commit is contained in:
parent
c2e2aac13c
commit
4f54a8c602
9 changed files with 45 additions and 29 deletions
|
@ -9,11 +9,8 @@
|
||||||
(yes i know i hate python but its v quick for simple stuff)
|
(yes i know i hate python but its v quick for simple stuff)
|
||||||
to transform input from <code>ls</code> into a list of <a> tags(with space between)
|
to transform input from <code>ls</code> into a list of <a> tags(with space between)
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<hr/>
|
||||||
here is the list of files here:
|
<INJECT>python $HOME/bscripts/ls_table.py $CURRENT</INJECT>
|
||||||
<br>
|
|
||||||
<INJECT>cd $CURRENT && ls *.* | python3 $HOME/bscripts/ls_to_a.py</INJECT>
|
|
||||||
</p>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
27
bscripts/ls_table.py
Normal file
27
bscripts/ls_table.py
Normal file
|
@ -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('<table style="border-spacing: 20px;text-align: left;margin-left: auto;margin-right: auto;">')
|
||||||
|
print('<tr>\n<th></th><th>Created</th><th>Modified</th></tr>')
|
||||||
|
|
||||||
|
# print each row
|
||||||
|
for x in files:
|
||||||
|
if x[0] == 'index.html': # skip the index.html file because kinda boring
|
||||||
|
continue
|
||||||
|
x[0] = f'<a href="{x[0]}">{x[0].replace(".html", "")}</a>'
|
||||||
|
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'<tr><td>{x[0]}</td><td>{x[1]}</td><td>{x[2]}</td></tr>');
|
||||||
|
# finish printing the table
|
||||||
|
print('</table>')
|
|
@ -6,4 +6,4 @@ while True:
|
||||||
a = input()
|
a = input()
|
||||||
except:
|
except:
|
||||||
break
|
break
|
||||||
print('<a href=\'' + a + '\'>' + a.replace('.html', '') + '</a><t>')
|
print('<a href=\'' + a + '\'>' + a.replace('.html', '') + '</a> ')
|
||||||
|
|
|
@ -1,10 +1,9 @@
|
||||||
<INJECT>cat $HOME/template/header.html | sed "s/__PAGE TITLE__/Rusty's website/"</INJECT>
|
<INJECT>cat $HOME/template/header.html | sed "s/__PAGE TITLE__/Rusty's website/"</INJECT>
|
||||||
<p>
|
<p>
|
||||||
Folders: <INJECT>cd $CURRENT && ls */ -d | sed 's/\///' | python3 $HOME/bscripts/ls_to_a.py</INJECT>
|
Folders<br> <INJECT>cd $CURRENT && ls */ -d | sed 's/\///' | python3 $HOME/bscripts/ls_to_a.py</INJECT>
|
||||||
<br>
|
<br><br>
|
||||||
Files: <INJECT>cd $CURRENT && ls *.html | python3 $HOME/bscripts/ls_to_a.py</INJECT>
|
Files<br> <INJECT>cd $CURRENT && ls *.html | python3 $HOME/bscripts/ls_to_a.py</INJECT>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<p>
|
<p>
|
||||||
Hello and welcome to my personal website
|
Hello and welcome to my personal website
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
<INJECT>cat $HOME/template/header.html | sed "s/__PAGE TITLE__/Rusty's website/"</INJECT>
|
<INJECT>cat $HOME/template/header.html | sed "s/__PAGE TITLE__/Rusty's website/"</INJECT>
|
||||||
<p>
|
<p>
|
||||||
Folders: <INJECT>cd $CURRENT && ls */ -d | sed 's/\///' | python3 $HOME/bscripts/ls_to_a.py</INJECT>
|
Folders<br> <INJECT>cd $CURRENT && ls */ -d | sed 's/\///' | python3 $HOME/bscripts/ls_to_a.py</INJECT>
|
||||||
<br>
|
<br><br>
|
||||||
Files: <INJECT>cd $CURRENT && ls *.html | python3 $HOME/bscripts/ls_to_a.py</INJECT>
|
Files<br> <INJECT>cd $CURRENT && ls *.html | python3 $HOME/bscripts/ls_to_a.py</INJECT>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<h1>
|
<h1>
|
||||||
|
|
|
@ -7,11 +7,8 @@
|
||||||
<br>
|
<br>
|
||||||
or about stuff that happens to me
|
or about stuff that happens to me
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<hr/>
|
||||||
Stories:
|
<INJECT>python $HOME/bscripts/ls_table.py $CURRENT .html</INJECT>
|
||||||
<br>
|
|
||||||
<INJECT>cd $CURRENT && ls *.html | python3 $HOME/bscripts/ls_to_a.py</INJECT>
|
|
||||||
</p>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
<INJECT>cat $HOME/template/header.html | sed "s/__PAGE TITLE__/Injector/"</INJECT>
|
<INJECT>cat $HOME/template/header.html | sed "s/__PAGE TITLE__/Injector/"</INJECT>
|
||||||
<p>
|
<p>
|
||||||
Folders: <INJECT>cd $CURRENT && ls */ -d | sed 's/\///' | python3 $HOME/bscripts/ls_to_a.py</INJECT>
|
Folders<br> <INJECT>cd $CURRENT && ls */ -d | sed 's/\///' | python3 $HOME/bscripts/ls_to_a.py</INJECT>
|
||||||
<br>
|
<br><br>
|
||||||
Files: <INJECT>cd $CURRENT && ls *.html | python3 $HOME/bscripts/ls_to_a.py</INJECT>
|
Files<br> <INJECT>cd $CURRENT && ls *.html | python3 $HOME/bscripts/ls_to_a.py</INJECT>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<h1>Injector</h1>
|
<h1>Injector</h1>
|
||||||
|
|
|
@ -7,11 +7,8 @@
|
||||||
like the <a href = "header.html">header</a> and <a href = "footer.html">footer</a>
|
like the <a href = "header.html">header</a> and <a href = "footer.html">footer</a>
|
||||||
of the pages(also contains the start and end of the pages!, tho I might change that)
|
of the pages(also contains the start and end of the pages!, tho I might change that)
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<hr/>
|
||||||
here is the list of templates in here:
|
<INJECT>python $HOME/bscripts/ls_table.py $CURRENT</INJECT>
|
||||||
<br>
|
|
||||||
<INJECT>cd $CURRENT && ls *.html | python3 $HOME/bscripts/ls_to_a.py</INJECT>
|
|
||||||
</p>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -5,9 +5,8 @@
|
||||||
<p>
|
<p>
|
||||||
Useful stuff to know/resources
|
Useful stuff to know/resources
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<hr/>
|
||||||
<INJECT>cd $CURRENT && ls *.html | python3 $HOME/bscripts/ls_to_a.py</INJECT>
|
<INJECT>python $HOME/bscripts/ls_table.py $CURRENT</INJECT>
|
||||||
</p>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue