rejetto forum

Software => HFS ~ HTTP File Server => F.A.Q.s => Topic started by: Foggy on November 20, 2007, 08:59:47 AM

Title: Flash Folder Tree
Post by: Foggy on November 20, 2007, 08:59:47 AM
I've had some free time and decided I'd try and create a browseable folder tree. Here is what I have so far, again it uses the same files.lst file as the search I created but a newer version of it. So it will only show the folders that the current user has access to.
If you click on one of the folders it will take you to that folder so you must use the arrows to browse it.

You can see a preview of it HERE (http://users.on.net/~foggy2/Folder%20Tree/Folder%20Tree%20-%20Example.html) Note: The preview is not the most current version.

To use, just simply use the files.lst file and place the swf/html file somewhere in your vfs/template.

Comments/suggestions please. :)



The latest version I've made should work and have the following features.


Auto Expand: To use the auto expand you have to pass the current url to the tree either by a querystring or flashvars in a variable called "current_location". I recommend the use of flashvars as that way the .swf is cached and not redownloaded every time the user changes the page.

Restricted Access: You need to pass the name of the current user to the tree same way as you do with the url, but this time inside the "user" variable.

you can use this code as an example to automatically send the variable if you are calling it from the template and not the html file.
Quote from: Example TPL Code
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="550" height="400">
<param name="movie" value="relative path to folder tree.swf">
<param name="quality" value="high">
<param name="FlashVars" value="current_location=http://%host%%folder%&user=%user%">
<embed src="relative path to folder tree.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="550" height="400" flashvars="current_location=http://%host%%folder%&user=%user%"></embed>
</object>
Title: Re: Flash Folder Tree
Post by: ELEVENNNN on November 20, 2007, 10:44:32 AM
woo hoo! I like it. Great work foggy, thanks for the time.  It works perfectly and has endless potential, and though its simplistic it does the job and looks much better than the search imo.

Thanks
Posted on: November 20, 2007, 06:30:23 PM
Hmm..

Quote
%files%

[files]
<?xml version="1.0" encoding="iso-8859-1"?>
<list>
%list%</list>

[file]
   <item url="%encoded-folder%%item-url%" name="%item-name%" type="file"/>
[folder]
   <item url="%encoded-folder%%item-url%" name="%item-name%" type="folder"/>

Right now im just using exactly what you gave me and I havent had any luck.  I moved over the html and flash file to the root and replaced the tpl file with the one in my hfs root. ( I want to embed it to work along the side first ).  Is this the same issue, do I need to enable compressed browsing or anything?

As of now it loads the flash file and its empty.
Posted on: November 20, 2007, 06:40:33 PM
This works great now.  I'm not sure if the result will be the same for others, but my problem was the filelist.tpl... I had to physically move or delete the originally filelist.tpl (in my case from Terayon) and then move over the other filelist.tpl from the zip/rar.. a simple overwrite left a cached file (of sorts) and it would not work.

Good work Josh, and thanks for your time again.. going to bed.
Title: Re: Flash Folder Tree
Post by: TSG on November 20, 2007, 11:29:11 AM
 ::) 3 posts in a row elevennnn? I will merge them for you  :-\.

Ye this is a nice idea with room to build upon :)
Title: Re: Flash Folder Tree
Post by: Unknown8063 on November 20, 2007, 04:06:07 PM
Oh very nice.  Great work Foggy!
Title: Re: Flash Folder Tree
Post by: Foggy on November 22, 2007, 06:13:18 AM
I have made a couple changes that will reduce the amount of processing needed on the client side and the size of the xml file used to generate the tree. Just download the folder tree.zip from the first post and its the same as the first version.

Edit: With the changes I made hfs is now only transferring 6000bytes instead of 43000 bytes for my vfs, so that is quite an improvement especially if you have lots of files and not many folders.
Title: Re: Flash Folder Tree
Post by: ELEVENNNN on November 22, 2007, 07:39:51 AM
I'm not sure if this is after or before we talked but I'm still looking for it calling that folder only when you click an arrow instead of running a recursive search (45 seconds within lan:X) each time.

Its really nice that your working on this for everyone, I tested it with an insane amount of files and indeed it does work.  Downloading new one now.

@TSG, Thanks for sorting.  Usually after posting I go look at other post and don't realize that I've posted a few times in a row.
Title: Re: Flash Folder Tree
Post by: Foggy on November 22, 2007, 10:18:30 AM
I'm looking into making it use a non recursive file list but if I can figure it out it will take some time, In the mean time though I think I might be able to make flash store the xml on the local machine by using a kind of flash cookie. Which if works would mean that the user would only have to download the filelist once per session instead of each time the folder tree is called.
Posted on: 22 November 2007, 09:31:43
I can now cache the xml used to create the tree structure, so each time the folder tree is called it will not download a recursive filelist from the server. It will only download a file list when the old one is 1 hour or older. I will update the first post again with the new version.
Title: Re: Flash Folder Tree
Post by: rejetto on November 22, 2007, 03:05:59 PM
this is a very cool thing.

since build #145 the standard filelist.tpl HAS folders. they are excluded by the listing through the url filter. so you won't need to ask people to install the customized one. ;)
Title: Re: Flash Folder Tree
Post by: Foggy on November 22, 2007, 09:22:28 PM
Thanks rejetto, but unfortunately the default one will not work because I do not know of a way to make flash read it. The customized filelist I use with this generates an xml page.
Title: Re: Flash Folder Tree
Post by: TSG on November 23, 2007, 04:17:13 AM
hmm, true... i wonder if we can get flash to convert the default strings to xml for us, you can create hidden xml sheets within flash itself... by splitting the url up to give us the url var and then unescaping the last item in the URL to give the name var... is that all that is needed? cause then all you have to do is build your own xml strings, i have some code that might help.

[file]
<item url="%encoded-folder%%item-url%" name="%item-name%"/>
[folder]
<item url="%encoded-folder%%item-url%" name="%item-name%"/>
Title: Re: Flash Folder Tree
Post by: Foggy on November 23, 2007, 09:15:38 AM
Currently it already builds its own xml in the structure of the vfs to output it correctly on the tree, the problem I have with using the default filelist is I dont know how to import it into something flash can read with out using a var= at the very start of it.

Edit: I was just thinking and thought I should explain a little more how it it works currently. Currently because the fielist I use is only 2 nodes deep I get the url attribute and split it into sections at every "/" to get the different folders. I then use  or so loops to loop through the split urls to either create a new node or go one node deeper in a new xml that is then used to populate the tree. The folder names are just that section of url decoded. So I'm thinking it sounds very easy to adapt it for use on the default tpl, I just need to know how to import the data so I can get all the urls in one array.
Posted on: November 23, 2007, 02:09:57 PM
I just got it to use the default filelist and finished perfecting how it remebers the file structure after finding some bugs. :P

I have to goto work now, so ill post it up later for all to see.
Title: Re: Flash Folder Tree
Post by: ELEVENNNN on November 24, 2007, 07:24:48 AM
Great work with the flash cookie, that was what was holding me back from downloading it before.  This has potential to be widely used; sorry the search didnt work out but it was made at a bad time (because rejetto's was just days away)

Keep up the good work.
Be on more tomorrow, staying at someones place with dial up, yuck :X
Title: Re: Flash Folder Tree
Post by: bacter on November 24, 2007, 10:29:20 AM
I'm working on an implementation to create the tree with java script, and the biggest problem is to get the list into the template also in my case.

I now create a list on localhost with the filelst.tpl as an array, then I have to save the displayed list as a .js file and edit it a bit to correct the tree levels to get it to work properly.

I think we could ask rejetto to add a option filename &out= with the execution of filelst.tpl

href="~files.lst?recursive&out=/sys/%user%.js"

that instead of responding with the .lst file would write the output to /sys/%user%.js in our vfs, and would respond with the page where invoked from, once the .js is created.

This feature could also be usefull for other purposes when we need to construct an array of files in our templates.

¿what do you think about such a feature?
Title: Re: Flash Folder Tree
Post by: Mars on November 24, 2007, 11:27:01 AM
Thought you of using a frame to show the list of directories with  ?recursive&folder-filter=*&file-filter=\*  and when we click on a directory the contents appears in another frame, simply but effective with a minimum of javascript, and so no external file are needed, all of work is make on the client browser. in tour template you can make a special section to this use.
Title: Re: Flash Folder Tree
Post by: Foggy on November 24, 2007, 01:06:42 PM
bacter try using /files.lst.js?recursive&folder-filter I discovered that I could add .xml to the end and it would work so maybe .js will work too. If you would like to know how I got the files.lst into the tree I can send you the source file because flash and javascript are very similar.
Title: Re: Flash Folder Tree
Post by: bacter on November 24, 2007, 02:50:52 PM
mars:
I've already considered the use of frames for that purpose, but as generating the tree on serverside is relativly slow, I think it would be much faster to load a stored file that can be valid as long as we don't change the vfs-tree, also, because it may be necesary to generate that tree several times during a session if the visitor jumps to other pages and it could be necessary to reload the mainpage. But probably I will use this system in lack of other possibilities.

Foggy:
Many thanks for your offer, it would be interesting to see and learn something with your code. I would agree you if you could paste the code in a message, as with the templates i'm working on these days there is no working upload section. Thankyou.
Title: Re: Flash Folder Tree
Post by: rejetto on November 24, 2007, 02:56:17 PM
I like the frame idea by mars.
What bacter asks seems to be unsafe. An URL storing files. But the idea is to cache a listing.
I could create a cache in RAM for listings.
You pass the URL you want adding a &cache-id=stupidname&cache-expire=10
Anyone accessing such URL when the cache is not expired, will make HFS skip the phase where it collects the list of files and just use the cached listing.

I'm unsure if only thing to skip/cache is the listing itself, or the produced output.
The output would be even easier to implement.
Title: Re: Flash Folder Tree
Post by: Foggy on November 24, 2007, 03:00:48 PM
Thats not a bad idea but I have no use for such a feature as I've perfected my flash cookies and it remembers the tree structure between pages.
Title: Re: Flash Folder Tree
Post by: Mars on November 24, 2007, 03:15:08 PM
Quote
I could create a cache in RAM for listings

i had same idea:

hfs conserverait en cache le résultat de la commande ?recursive . Quand un upload est effectué, le cache est mis à jour, l'administrateur peut choisir le timing de rafraichissement du cache entre 5mn,15mn, 30mn,1H
et celui ci est forcé quand un upload ou un ?recursive ou un ajout dans vfs est effectué, comme cela hfs ne rechercherait pas dans toute l'arborescence du dos pour n'afficher que quelques fichiers.

quand il ya 1 ou 2 utilisateurs qui utilisent en même temps ?recursive ça va encore mais imaginons que une centaine de personnes en même temps le fassent : le disque dur va exploser alors que si la même information est en cache le résultat est plus rapide pour l'ensemble des utilisateurs, et il n'y a pas besoin d'avoir un cache pour chaque session.
Title: Re: Flash Folder Tree
Post by: rejetto on November 24, 2007, 04:07:14 PM
et celui ci est forcé quand un upload ou un ?recursive ou un ajout dans vfs est effectué, comme cela hfs ne rechercherait pas dans toute l'arborescence du dos pour n'afficher que quelques fichiers.

this "rules" are not enough.
when you have real folders, the listing may change without having an upload or a VFS change.
even if you have a file in your vfs, that file has been modified, so its timestamp is different, the result of ?recursive should be different if it displays the timestamp as well.

there is a solution to this problem, but i won't implement it in HFS 2, because it is 90% implemented in the experiment for HFS 3.
Title: Re: Flash Folder Tree
Post by: bacter on November 24, 2007, 09:49:31 PM
Quote
You pass the URL you want adding a &cache-id=stupidname&cache-expire=10
Anyone accessing such URL when the cache is not expired, will make HFS skip the phase where it collects the list of files and just use the cached listing.

That's a very good idea! But I don't understand what would be the difference between the listing or the produced output.

I think having some form of coma separated list would be enough, as in most cases y suppose that formatting or asigning of the values can be done in the template.
Title: Re: Flash Folder Tree
Post by: rejetto on November 25, 2007, 04:13:26 PM
the listing is the list of files before it is applied to the template
Title: Re: Flash Folder Tree
Post by: Foggy on November 26, 2007, 06:57:36 AM
I updated the first post with my latest version.



Updated yet again :P

I also updated the preview.

Anyone know why %, / and some other characters arnt bold in the quote I made about auto expand?
Title: Re: Flash Folder Tree
Post by: Foggy on December 06, 2007, 12:34:02 PM
It will now check each time the current folder is changed if the logged in user has changed, and if it has it will reflect any changes that changing the user had on the folder structure. eg. more folders are now accessible due to restrict access permissions.
Posted on: December 03, 2007, 10:24:03 PM
Version 1.0 of the folder tree is released with a change in the clickable folders.
You can now click on the folder once to expand/minimize it or you can double click on it to open the folder.

Now that I have time and have had some ideas for it, it is really starting to come along. Tomorrow I might try and neaten up the code and shrink the size down a bit.

Also if someone would like to have a go at creating a skin/style for it I'll let you know how its done. To do that though you will need flash 8, not sure but you might need the professional version.