Quantcast
Channel: User Joel Glovier - Stack Overflow
Viewing all articles
Browse latest Browse all 39

shell script to create a static HTML directory listing

$
0
0

So I'm creating a GitHub Pages site to list all of the Gifs in my jglovier/gifs repo. GH Pages runs only static HTML/CSS/JS or Jekyll, so I cannot use an apache directory listing or any other server generated variant.

So what I'd like to do is run a script on the command line and have it browse the root for directories, list all the files inside (which only go one level deep), and output that to an html ul > li > a structure, or something similar to this:

root/|├── accidents/|   ├── accident2.gif|   ├── accident3.gif|   └── accident4.gif├── bears/|   ├── bears1.gif|   ├── bears2.gif|   └── bears3.gif└── cats/├── cat1.gif├── cat2.gif└── cat3.gif

I'd like the href values to be site-root relative paths (i.e. href="/cats/cat.gif), and I need it to output into_includes/site-index.html, which will get pulled into a Jekyll layout file that wraps around myindex.mdfile and generatesindex.html` on build.

I found this other question which is very similar, and tried to implement it's answer for my purposes, but alas I'm too much of a shell n00b to accomplish it on my own.


Viewing all articles
Browse latest Browse all 39

Latest Images

Trending Articles





Latest Images