Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
SimpleDir - Directory listing plugin
#1
This is the plugin support thread for the SimpleDir plugin.

Written as a repose to a post in the general request forum this plugin will generate a CSS style-able directory listing. The plugin includes a bunch of filetype icons and a sample CSS file.

Now updated to include a configuration page (see attachment).


To Install:
  • Unzip the file to your plugin directory.
  • Navigate to the config page and enter your configuration.
  • Create a page and include (% simpledir %) in the body of page - this will be replaced with the table.
  • Copy and paste the CSS into your main theme CSS file, or include the css in a page template

Demo site here: http://testbed.cartocopia.com/simpledir-test-page/

Couple of notes:
You need to have the .htaccess file in the simpledir subdirectory - this redirects any file extension that does not match one of the provided icons to unknown.png

If you want to change/replace/add to the direcory icons, they are 16x16 png files (hardcoded right now) named <lowercase extension>.png so for example, if you wanted to create a new icon for file type mp4, you would create a new icon file (or copy one of the existing movie icons) to mp4.png as put it in that directory.

Any directory must be in the web path as the plugin just serves up links to the files and does not serve the files directly itself. (I'm still working on that one...)

There is fairly simple error checking (All periods are stripped from the subdir parameter to prevent directory traversals) so it will NOT work for subdirectories having a period in the dubdirectory name.
-Rob A>
Reply
#2
Thanks for sharing! From what I saw in the demo, this plugin looks very promising.
Reply
#3
Looks great!
Just one comment: it's not KB, but either kB (= 1000 B theoretically) or KiB (= 1024 B, but this is not widely used yet).
I18N, I18N Search, I18N Gallery, I18N Special Pages - essential plugins for multi-language sites.
Reply
#4
mvlcek Wrote:Looks great!
Just one comment: it's not KB, but either kB (= 1000 B theoretically) or KiB (= 1024 B, but this is not widely used yet).

Thanks!

Regarding the KiB vs. KB, that is a IEC vs. SI issue. My understanding KB is the accepted comon binary SI abbreviation for 2^10 Bytes (as opposed to kB which would be 10^3 Bytes) and most folks don't know what KiB means.

But I appreciate your passion for correctness!

-Rob A>
Reply
#5
RobA Wrote:
mvlcek Wrote:Looks great!
Just one comment: it's not KB, but either kB (= 1000 B theoretically) or KiB (= 1024 B, but this is not widely used yet).

Thanks!

Regarding the KiB vs. KB, that is a IEC vs. SI issue. My understanding KB is the accepted comon binary SI abbreviation for 2^10 Bytes (as opposed to kB which would be 10^3 Bytes) and most folks don't know what KiB means.

But I appreciate your passion for correctness!

-Rob A>

It's the common IT abbreviation (JEDEC).

I was looking at Total Commander and Gnome Commander, but I see that Explorer and Nautilus use K:
Nautilus, Windows Explorer: KB
Gnome Commander, Total Commander: kB (but it's probably 1024 B)
So your use of KB is probably the best way ;-)

SI decimal: 1 kB = 1000 B, MB, GB
SI binary (IEC): 1 KiB = 1024 B, MiB, GiB
JEDEC: 1 KB = 1024 B, MB, GB
I18N, I18N Search, I18N Gallery, I18N Special Pages - essential plugins for multi-language sites.
Reply
#6
Rob, the plugin looks great as I see it on your website.

I've resolved other issues I have with it but now it's giving me a permissions error. See http://beachsun.org/Lakes/documents/

Any ideas on what's causing this error?

Thanks.

Don
Reply
#7
dondemaio Wrote:Rob, the plugin looks great as I see it on your website.

I've resolved other issues I have with it but now it's giving me a permissions error. See http://beachsun.org/Lakes/documents/

Any ideas on what's causing this error?

Thanks.

Don

Looks like you have it now under http://beachsun.org/Lakes/docs/ ?

You need to add some css to style the table?You directory structures seem odd as the document links don't work... do you want to PM/email me your directories in the setup so I can figure out what isn't working?

-Rob A>
Reply
#8
Just added a version 0.2 that provides a config page (screen shot attached to the first post) to specify the base directory, its associated URL, and an extension exclusion list.

-Rob A>
Reply
#9
RobA Wrote:
dondemaio Wrote:Rob, the plugin looks great as I see it on your website.

I've resolved other issues I have with it but now it's giving me a permissions error. See http://beachsun.org/Lakes/documents/

Any ideas on what's causing this error?

Thanks.

Don

Looks like you have it now under http://beachsun.org/Lakes/docs/ ?

You need to add some css to style the table?You directory structures seem odd as the document links don't work... do you want to PM/email me your directories in the setup so I can figure out what isn't working?

-Rob A>

The updated version should lets you specify the directory file path and url path separately, so upgrade to 0.2 and it should work on your page.

-Rob A>
Reply
#10
Great Plugin!

Suggestions.

Support for htaccess style directory headers and descriptions.
This would be in a file similar to a .htaccess file.

This is the .htaccess syntax for index directories listings, 1 per line

Code:
AddDescription "DESCRIPTION TEXT" filename.ext

And this is to include a header html file

Code:
HeaderName header.html

Then one of these "dir config" files per folder and you have the same functionality as apache dir indexs, but in getsimple. (except sorting)

But sorting can be added with jquery datatables or something similar, and isn't a big deal.

USER TIP: dont forget the last / in the full path, you will get filesize and filetime errors. ugh.
NEW: SA Admin Toolbar Plugin | View All My Plugins
- Shawn A aka Tablatronix
Reply
#11
I wasn't familiar with that, thanks for the reference!

mod_autoindex has dozens of options though - it would be a real headache to support all of those...no time right now Sad

-Rob A>
Reply
#12
It sure does, but most aren't very necessary when you have styling, and many are just icon and sorting related.

Ill probably be adding descriptions and header support to my install, so I thought I would post it as a suggestion.

Its probably all most people would need.
NEW: SA Admin Toolbar Plugin | View All My Plugins
- Shawn A aka Tablatronix
Reply
#13
shawn_a Wrote:It sure does, but most aren't very necessary when you have styling, and many are just icon and sorting related.

Ill probably be adding descriptions and header support to my install, so I thought I would post it as a suggestion.

Its probably all most people would need.

I haven't played with this on Apache, so let me know if I have this right...

Code:
HeaderName header.html
- Apache will display the contents of header.html above the listing.

Code:
AddDescription "DESCRIPTION TEXT" filename.ext
- Apache will display the description text in an additional field of each row.

the docs state the match can be "a file extension, partial filename, wild-card expression or full filename" - would that flexability be worthwhile?

I'm thinking I could have a set of canned descriptions for just the extensions (like I already can the icons) like this list I found online:
Code:
AddDescription "MPEG Layer 3 Format" .mp3
AddDescription "GZIP compressed TAR archive" .tgz .tar.gz
AddDescription "GZIP compressed archive" .Z .z .gz .zip
AddDescription "RAR compressed archive" .rar
AddDescription "TAR compressed archive" .tar
AddDescription "ZIP compressed archive" .zip
AddDescription "Windows executable file" .exe
AddDescription "Common Gateway Interface" .cgi
AddDescription "Joint Photographics Experts Group" .jpg .jpeg .jpe
AddDescription "Graphic Interchange Format" .gif
AddDescription "Portable Network Graphic" .png
AddDescription "Vector graphic" .ps .ai .eps
AddDescription "Hypertext Markup Language" .html .shtml .htm
AddDescription "Cascading Style Sheet" .css
AddDescription "DocType Definition" .dtd
AddDescription "Extensible Markup Language" .xml
AddDescription "Win32 compressed HTML help" .chm
AddDescription "Adobe Portable Document Format" .pdf
AddDescription "Plain text file" .txt .nfo .faq .readme
AddDescription "Unix man page" .man
AddDescription "Email data" .eml .mbox
AddDescription "Microsoft Word document" .doc
AddDescription "PHP: Hypertext Preprocessor script" .php  .php3 .php4
AddDescription "PHP: Hypertext Preprocessor source code" .phps
AddDescription "Javascript" .js
AddDescription "Java code"  .java
AddDescription "Unix shell script" .sh .shar .csh .ksh .command
AddDescription "Mac OS X shell script" .command
AddDescription "Configuration file" .conf
AddDescription "Mac OS X terminal" .term
AddDescription "BitTorrent file" .torrent
AddDescription "Windows link" .lnk .url

and then only do filename matches that would override these canned ones only when there is an AddDescription line that matches the filename...

Thoughts?

(I'm also doing to add an alt [SND] style of label to the icons, which aren't done right now...)

-Rob A>
Reply
#14
Oh I was just thinking straight full filename.ext match, so you don't have to use any pattern matching.

My goal was to just not have to have my files that look like this
Thisiswhatthisfileisjustsoyouknow.pdf

But your idea sounds pretty good too.
NEW: SA Admin Toolbar Plugin | View All My Plugins
- Shawn A aka Tablatronix
Reply
#15
I randomly found this also in the php.net docs for str_getcsv

Code:
xoneca at gmail dot com 26-Nov-2011 09:26
Note that this function can also be used to parse other types of constructions. For example, I have used to parse .htaccess AddDescription lines:

    AddDescription "My description to the file." filename.jpg

Those lines can be parsed like this:

<?php

$line = 'AddDescription "My description to the file." filename.jpg';

$parsed = str_getcsv(
    $line, # Input line
    ' ',   # Delimiter
    '"',   # Enclosure
    '\\'   # Escape char
);

var_dump( $parsed );

?>

The output:

array(3) {
  [0]=>
  string(14) "AddDescription"
  [1]=>
  string(27) "My description to the file."
  [2]=>
  string(12) "filename.jpg"
}

These 2 features would be awesome, header and description support.

Also it would be nice if this plugin supported function calls with folder, so it can be used multiple times as a component or a inline shortcode.
NEW: SA Admin Toolbar Plugin | View All My Plugins
- Shawn A aka Tablatronix
Reply
#16
hi.

im getting this: Unable to open the folder /home/user/data/uploads/, check the folder privileges.

Cant see the files .

Solution?
Reply
#17
maxpop Wrote:hi.

im getting this: Unable to open the folder /home/user/data/uploads/, check the folder privileges.

Cant see the files .

Solution?


Like the message states, check the privileges of /home/user/data/uploads/ to make sure they are read/writable by the webserver account.

-Rob A>
Reply
#18
Thanks for this very useful plugin! I however have a couple of questions:

1 - Is it possible for 2 different directory listings to feature on 2 different pages - i.e. on the "Application Forms" page there would be a list of .pdf & .jpg files for download. On the "Education" page there would be .pdf files?

2 - Would it be possible to have an extra column that shows how many times a file has been downloaded?

Thanks in advance.
Reply
#19
chaos Wrote:Thanks for this very useful plugin! I however have a couple of questions:

1 - Is it possible for 2 different directory listings to feature on 2 different pages - i.e. on the "Application Forms" page there would be a list of .pdf & .jpg files for download. On the "Education" page there would be .pdf files?

2 - Would it be possible to have an extra column that shows how many times a file has been downloaded?

Thanks in advance.

These features do not exist in the current version.

Rob A>
Reply
#20
Hello Rob...great Plugin.

I believe I have been able to solve the multiple list problem by renaming the simpledir plugin to a name of my choice, works great! But I do have one question, I cannot get subdirectory listings from the plugin when run. I am using getsimple on XAMPP. Could this be an issue? I'm stumped, any suggestions as to why no subdirectory listings?

Thanks!

kwc
Reply
#21
Rob-

Another note I failed to mention earlier...I see the demo page works correctly...That's how I would like it to operate, but, no subdirectories!

Any suggestions? Ideas?

Thanks!

kwc
Reply
#22
It was pointed out there was a directory traversal vulnerability in this plugin - I have updated the code to deal with this. Please update to version 0.3

@kwc1963 - I have no idea why this does not work on an XAMPP server. What OS?

-Rob A>
Reply
#23
maybe is_dir is not working as expected.
Is this on windows ? What version of php ?
NEW: SA Admin Toolbar Plugin | View All My Plugins
- Shawn A aka Tablatronix
Reply
#24
Thanks shawn...more food for thought...windows 7...php ver. 5.4.7
Reply
#25
(2012-08-23, 03:35:45)RobA Wrote:
maxpop Wrote:hi.

im getting this: Unable to open the folder /home/user/data/uploads/, check the folder privileges.

Cant see the files .

Solution?


Like the message states, check the privileges of /home/user/data/uploads/ to make sure they are read/writable by the webserver account.

-Rob A>

I have checked all the privileges and they are okay, but it still says "Unable to open folder". Could you explain in detail what do I have to type in the field »Full Server Path to Directory« and what exactly in »Base URL for Directory« ? Thanks Blush
Reply




Users browsing this thread: 2 Guest(s)