dreamshark: (Default)
[personal profile] dreamshark
Does anybody know of a fast way to make an index file for a directory full of pictures on a web page?

It used to be I could position to the directory and see a list of all the files in the directory. My domain provider has disabled that, and now requires an index page.

Date: 2008-05-26 08:34 pm (UTC)
guppiecat: (Default)
From: [personal profile] guppiecat
Are you allowed to use PHP or Perl scripts?

Date: 2008-05-26 08:56 pm (UTC)
From: [identity profile] dd-b.livejournal.com
Um, ls -1 > /tmp/file, followed by an emacs macro on the file to get the html you want?

Photoshop will do it, as will many of the indexing programs. Or there are cgi scripts you can use on the web server side (so you don't have to regenerate the index each time you update the page). Or various fancier packages to install server-side, either on their own or as part of a blogging system. Dreamhost has Gallery on a one-click install, for example.

Date: 2008-05-26 08:58 pm (UTC)
From: [identity profile] dd-b.livejournal.com
Hang on; might work just to put a .htaccess file with "Options +Index " in the directory in question. Depends on the AllowOverride setting for the parent directory, but might work. If they're running Apache web server, but that's a fairly safe bet.

Date: 2008-05-27 02:42 am (UTC)
From: [identity profile] dreamshark.livejournal.com
Could you repeat that with a little more detail?
Create a text file with the string "Options +Index" in it?

Date: 2008-05-27 02:44 am (UTC)
From: [identity profile] dd-b.livejournal.com
Yes. Named .htaccess (note the leading period). In the web directory in question.

Date: 2008-05-27 03:16 pm (UTC)
From: [identity profile] dreamshark.livejournal.com
Thanks, but it didn't work. As soon as i tried to access the directory with the .htaccess file in it I started getting a vague error message along the lines of "something has gone wrong, contact your site administrator or look at the error logs."

Found a way!

Date: 2008-05-27 04:24 pm (UTC)
From: [identity profile] dreamshark.livejournal.com
Although editing the .htaccess file directly didn't work, knowing that the .htaccess file controls this feature allowed me to find a well-hidden tweak in the GUI front end to enable directory browsing on a directory-tree level. So, thanks!

Re: Found a way!

Date: 2008-05-27 05:28 pm (UTC)
From: [identity profile] dd-b.livejournal.com
Good, glad it worked out! Maybe I remembered the syntax slightly wrong, or maybe they don't let it work at the file level but the GUI tweak results in a change to the main apache config files, or something. The fact that it got an error when you tried the .htaccess at least shows that it was noticing the file.

Date: 2008-05-27 01:59 pm (UTC)
From: [identity profile] quadong.livejournal.com
The following line noise at a Unix prompt will create a list of links to all .jpg files in a file called index.html.

(echo '') > index.html

ddb's way is better if you can get it to work, though.

Date: 2008-05-27 02:03 pm (UTC)
From: [identity profile] quadong.livejournal.com

Gah! Let me try that again:

(echo '<ul>'; ls *.jpg | sed -e 's/.*/<li><a href="&">&<\/a><\/li>/'; echo '</ul>') > index.html

Date: 2008-05-27 03:31 pm (UTC)
From: [identity profile] dreamshark.livejournal.com
What a slick little one-line script! I tried it on a Linux system at work and it works perfectly.

I have no idea whether I can get to a Linux prompt on my domain hosting system, but if I can I'll use it. I wouldn't count on it, though. The user interface for my hosting service is a cumbersome GUI. If there's a Linux shell hidden in there, it's well hidden.

Did you just whip up that little script at a moment's notice, or is that something you had lying around? It's elegant.

Date: 2008-05-27 04:35 pm (UTC)
From: [identity profile] quadong.livejournal.com
I just whipped it up. I like to think of myself as being reasonably good at sed, even if I only understand about 10% of its functionality.

Date: 2008-05-27 08:23 pm (UTC)
From: [identity profile] dreamshark.livejournal.com
Yeah, sed is a powerful tool that I suspect is under-appreciated by many. I do use it, but I always have to look up the syntax in my tattered old Unix book, and even so it always takes me about 10 tries to get it right.

It also takes me at least two tries every time I try to use the href thing in HTML. I don't know why, since it's really not that complicated. But if I'd tried to write that little one-liner from scratch it would have taken me all day. :-)

Date: 2008-05-27 05:27 pm (UTC)
From: [identity profile] dd-b.livejournal.com
Briefly tried to figure out how that worked, before I noted the corrected (presumably protected against HTML interpretation) version below, which makes much more sense!

Profile

dreamshark: (Default)
dreamshark
February 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 2026

Style Credit