Re: [xwiki-users] Automatically list and link files in a directory with Groovy
Lockie wrote: > Okay I got it working and I'm very happy with the result! I'll share what I > did incase anyone else is interested in doing this. Note that the links > don't work in Firefox (the file:// part doesn't seem to generate). My users > only use IE so I didn't really explore this problem, but you can play around > with it to get it working. Also, the user has to have access to the > directory so this is only useful on an Intranet with networked drives. > > First step install the PHP Macro, then copy/paste this code in your page > making sure you change the desired drive. > > > {{velocity}} > $xwiki.jsfx.use("js/xwiki/table/tablefilterNsort.js") > $xwiki.ssfx.use("js/xwiki/table/table.css") > {{/velocity}} > > {{php}} > {{html}} > cellpadding="0" cellspacing="0" border="0"> > > Form Name > Path > > $dirname = "R:/Quality/FORMS/"; > $dir = opendir($dirname); > > while(false != ($file = readdir($dir))) > { > if(($file != ".") and ($file != "..")) > { > echo(" $file "); > echo(" $dirname$file Open Form "); > } > } > ?> > > {{/html}} > {{/php}} > > > This results in a filterable table with a list of all the files in the > directory and subfolders of it with the file names in the left column and a > link to open the file in the right column. > > Regards, > > - > > Lockie > Thanks, Lockie. I've not used this yet. If I'm not wrong, I think that some PHP developer here will be happy to use some of the scripts they have programmed within XWiki :-) Greetings, Ricardo -- Ricardo RodrÃguez CTO eBioTIC. Life Sciences, Data Modeling and Information Management Systems ___ users mailing list users@xwiki.org http://lists.xwiki.org/mailman/listinfo/users
Re: [xwiki-users] Automatically list and link files in a directory with Groovy
Okay I got it working and I'm very happy with the result! I'll share what I did incase anyone else is interested in doing this. Note that the links don't work in Firefox (the file:// part doesn't seem to generate). My users only use IE so I didn't really explore this problem, but you can play around with it to get it working. Also, the user has to have access to the directory so this is only useful on an Intranet with networked drives. First step install the PHP Macro, then copy/paste this code in your page making sure you change the desired drive. {{velocity}} $xwiki.jsfx.use("js/xwiki/table/tablefilterNsort.js") $xwiki.ssfx.use("js/xwiki/table/table.css") {{/velocity}} {{php}} {{html}} Form Name Path $file "); echo(" $dirname$file Open Form "); } } ?> {{/html}} {{/php}} This results in a filterable table with a list of all the files in the directory and subfolders of it with the file names in the left column and a link to open the file in the right column. Regards, - Lockie -- View this message in context: http://xwiki.475771.n2.nabble.com/Automatically-list-and-link-files-in-a-directory-with-Groovy-tp5715784p5738940.html Sent from the XWiki- Users mailing list archive at Nabble.com. ___ users mailing list users@xwiki.org http://lists.xwiki.org/mailman/listinfo/users
Re: [xwiki-users] Automatically list and link files in a directory with Groovy
Thanks for the reply Ricardo it was very informative! Fortunately I simply just need to list and link the files and not worry about addding metadata. I think there might be a way to do this using the php macro so I'll try that and post here if I work it out. - Lockie -- View this message in context: http://xwiki.475771.n2.nabble.com/Automatically-list-and-link-files-in-a-directory-with-Groovy-tp5715784p5738708.html Sent from the XWiki- Users mailing list archive at Nabble.com. ___ users mailing list users@xwiki.org http://lists.xwiki.org/mailman/listinfo/users
Re: [xwiki-users] Automatically list and link files in a directory with Groovy
Hi! Lockie wrote: > Hello all, > > I'm running my Xwiki as an information management Intranet alongside a > networked drive that holds hundreds of documents. Based off the TODO > tutorial, I made a system of inputting these documents as objects on > individual pages that then appear on a filterable-sortable table. The link > being a windowsPath macro. The idea behind this is that users can access > these documents much easier. > So, you are using XWiki to "annotate" or add "metainformation" to files stored in your Windows file system, on that networked hard drive. I guess you have created a customized class where you fill in several properties for each file. One of that properties stored the mapped path for a given file. Provided the box where you are running the client accessing XWiki has the correct mapping, users will be able to recover each file by entering this path in an explorer window. What you want is to have "active links" to this mapped drive. Concerning this development I think you must be aware of the current developments oriented to set an alternative store for attachments in the system file. Check devs list for "The future of attachments and attachment versioning" and related threads and Jira issues. Once this is working, you could have this networked drive set as alternative storage location. About having alternative methods to access those files... well, we'll see! It is always tricky to access a single repository with several, let's call them, agents (XWiki will be the primary agent, that storing files and being able to apply all its logic to add huge amounts of information and metainformation to each stored file). > The problem with this system is if a new document is created, Do you mean a new file stored in the file system? Perhaps this initiative could be useful for you by changing stored attachments with paths/filenames in the networked drive. Lool for [xwiki-users] Create application similar to attach file application in the users list. > the user then > has to manually add it to this table, and if the document's title is > changed, the link gets broken. So I'm after a way of automatically listing > the documents and have working links, to make it require as little upkeep as > possible. > To avoid to get this links broken, you need to reference the files with a UID independente from the name. By the end, even though I'm not a developer, you will end requiring the complexity needed to develop the alternative repository referenced above. > So far I am able to list the name and the path of all the documents in the > directory, but I need some help in integrating the sortable table html tags > and turning the path into a working link, without breaking the groovy macro. > This is what I have so far: > > > {{groovy}} > > import groovy.io.FileType > > def list = [] > > def dir = new File("R:/Quality/FORMS/") > dir.eachFileRecurse (FileType.FILES) { file -> > list << file > } > > list.each { > println it.name > println it.path > } > > {{/groovy}} > > > Any help would be appreciated, > > Thanks, > > - > > Lockie > Finally, consider also this Jira issue about UNC paths... http://jira.xwiki.org/jira/browse/XWIKI-193 Hope this helps! Ricardo -- Ricardo RodrÃguez CTO eBioTIC. Life Sciences, Data Modeling and Information Management Systems ___ users mailing list users@xwiki.org http://lists.xwiki.org/mailman/listinfo/users