WEBDav Drupal Module
Le 19 September 2008, à 14:27 par Ulhume...

Historique (tout afficher)
  • v2 - Updated by DAV module (2008-09-29 00:36)

Avalaible releases

Project license

GNU general public license, version 2 and later.

What it is ?

This module target to add WebDAV access to Drupal content management. It is basically a WebDAV server pumping it's data from a specialized WebDAV API. It has been developed for tree years now and all this time I tried to improved it in order to get speed, compliance and security.

This module can be seen in three parts :

  • A WebDAV server integrated in Drupal using the URL /webdav/.... It is using PEAR WebDAV server for low level protocol processing. I think at one point I'll be tired of hacking it and I'll just remove it all.
  • A WebDAV API which offers high level hooks to handle WebDAV exposed data and allows modules to interact with WebDAV commands.
  • A set of sub-modules using the WebDAV API in order to manage drupal content using a webdav client. This includes nodes, file attachements and a first, read-only, file system support.

Managing Drupal content

From a user point of view, only the third part is interesting. By activating the WebDAV for nodes module, you can :

  • Browse nodes, first by content-types, after you have a folder using the node title as name, and inside you have a file representing the node body.
  • Create a new node when creating a new folder.
  • Read/Write node content (body) with any WebDAV compliant client (ex. gedit). You can set-up the module to create a new revision each time you save the "file".
  • Changing the node title by simply renaming its folder.
  • Deleting a node by deleting its folder (only with true webDAV clients like cadaver or DAVExplorer).

If you enable WebDAV for attachements module, you also be able to :

  • Browse the attachements folder in the node folder.
  • Create a new file that will be a new attachement.
  • Copy an attachement from one node to another.
  • Delete an atachemnt.
  • Move an attachement from one node to another.

If you enable WebDAV for filesystems module, you will be able to :

  • Declare a new file system given its name and absolute path.
  • Allow user to browser this file system and download files.

Every of those operations can be done using Gnome/Nautilus (specially with the new GVFS layer), KDE/Dolphin, DavFS2, Cadaver, MacOS and Windows Web shares, etc. You can also edit a node content with OpenOffice 3.0, gedit (as I'm doing right now) or event MS-Word.

It is also possible to use a simple web browser like firefox by just pointing to http://my_server/webdav. It's now fully integrated with Drupal so you can use this feature to allow users to browse some files in order to download them (ex. here).

WebDAV API

From a developer point of view, this module give the ability to expose any kind of Drupal data using a simplified WebDAV API. Originally this was not the case. It was Nick Vahalik who gave me this idea to turn this monolithic module in WebDAV framework. He also wrote the first draft of this hooking system.

A year later, I rewrote the all module in order to make it compatible with Drupal 6.x. I also tried to improve this API by trimming as much as possible the WebDAV complexity. Now, making a module using this API to, for example, manage comments, take me something like an hour of work.

The current version is still under development but is close to release. I use it on an every day base for a month now without any noticeable problem.

You can find a documentation for this API here.

How to connect ?

With a simple WEB browser by using the address http://my_server/webdav/. After authentication you should be able to browse your content.

For Gnome/Nautilus and any GIO/GVFS compliant applications (Gnome 2.24 and later), you can directly enter the url like this dav://my_server/webdav (davs if it is secured).

For KDE/Dolphin and any KIO compliant application, you can directly enter the url like this webdav://my_server/webdav (webdavs if it is secured).

With Cadaver you just have to entre cadaver http://my_server/webdav.

With DavFS and DavFS2 you have to mount like this mount -t davfs http://my_server/webdav/ /mnt/disk/ -o username=gaston. You can also use display names by setting use_displayname 1 in /etc/davfs2/davfs2.conf.

For MacOS, you can connect to a webdav folder using GO/Connect to server. Now you can add your server url : http://my_server/webdav (https if it is secured).

For Windows, you can connect to a webdav folder by opening Networks and clicking on Add a favorite network. Now you can add your server url : http://my_server/webdav (https if it is secured).

How to test ?

The best option for testing is cadaver as it is plain and simple. The only problem with cadaver is it don't support display names; So for those tests, to use NID and FID.

First be sure you set debug level to "verbose" in WebDAV server settings. Be careful with your data, never do this on a production server as the module has not been fully tested.

Now you can follow my testing path :

# We first create test data
$ mkdir test
$ cd test
$ cat > "new_content"
This is a new content
^D
$ cp ~/Desktop/test.pdf new_attachement.pdf
 
# we start cadaver
$ cadaver http://my_server/webdav/
 
# first "cd" should trigger authentication
dav:/webdav/> cd nodes
Authentication required for Drupal WebDav Access for 'Artisan Numérique on server `artisan.karma-lab.net':
Username: gaston
Password:
 
# we go to story content type
dav:/webdav/nodes/> cd story
 
# we create a new node
dav:/webdav/nodes/story/> mkdir "This is a test"
Creating `This is a test': succeeded.
 
# Now as Cadaver don't understand display names, we should have a look at drupal (admin/content) in order to grap
# the new NID for this node, here 1648
dav:/webdav/nodes/story/> cd 1648
 
# we get its content
dav:/webdav/nodes/story/1648/> cat content.html
Displaying `/webdav/nodes/story/1648/content.html':
 
 
Enter your data here...
 
 
# we replace with a new content
dav:/webdav/nodes/story/1648/> put new_content content.html
Uploading new_content to `/webdav/nodes/story/1648/content.html':
Progress: [=============================>] 100,0% of 22 bytes succeeded.
 
# test again to see if it changed
dav:/webdav/nodes/story/1648/> cat content.html
Displaying `/webdav/nodes/story/1648/content.html':
This is a new content
 
# go to attachments and see there's no rabbit inside
dav:/webdav/nodes/story/1648/> cd attachements
dav:/webdav/nodes/story/1648/attachements/> ls
Listing collection `/webdav/nodes/story/1648/attachements/': collection is empty.
 
# we put a new attachment in the folder
dav:/webdav/nodes/story/1648/attachements/> put new_attachement.pdf .
Uploading new_attachement.pdf to `/webdav/nodes/story/1648/attachements/':
Progress: [=============================>] 100,0% of 1460698 bytes succeeded.
 
# we see if the rabbit is there
dav:/webdav/nodes/story/1648/attachements/> ls
Listing collection `/webdav/nodes/story/1647/attachements/': succeeded.
1386 1460698 sept. 22 14:54
 
# we get it so we can verify binary integrity using evince
dav:/webdav/nodes/story/1647/attachements/> get 1386 getted.pdf
Downloading `/webdav/nodes/story/1647/attachements/1386' to getted.pdf:
Progress: [=============================>] 100,0% of 1460698 bytes succeeded.
 
# we delete the attachement
dav:/webdav/nodes/story/1647/attachements/> rm 1386
Deleting `1386': succeeded.
 
# no one there now
dav:/webdav/nodes/story/1647/attachements/> ls
Listing collection `/webdav/nodes/story/1647/attachements/': collection is empty.
 
# we go up two times to delete the node
dav:/webdav/nodes/story/1647/attachements/> cd ..
dav:/webdav/nodes/story/1647/> cd ..
 
dav:/webdav/nodes/story/> rmcol 1647
Deleting collection `1647': succeeded.
root# 

Comments

M Hill (not verified), le 28 December, 2008 - 12:39

When I try to connect to webdav folder usin OS X and the above instructions "GO/Connect to server" I get a authentication error for any user account, including UID 1 (admin).

Whereas browsing the webdav folder from within Drupal (once logged in) works fine. Do you know how to resolve this authentication problem, so that I can mount the folder on my local filesystem?

Many thanks.

M Hill (not verified), le 28 December, 2008 - 17:07

I reviewed the issues on the drupal project page and found a thread referring to a similar "authentication loop" problem. I've resolved it temporarily by developing locally using Mamp, where it works like a dream. I assume I've got some server issues to resolve.

Ulhume, le 1 January, 2009 - 11:51

I don't thing this can be the same issue as it was directly linked with a way of handling missing ending slashes that I don't use anymore. Can you increase your verbosity level and creating an issue on drupal.org ? I don't have any MacOS to test so I need more information.

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • To highlight piece of code, just surround them with <code type="language"> Your code &tl;/code>>. Language can be java,c++,bash,etc... Everything Geshi support.
  • Lines and paragraphs break automatically.
  • Textual smileys will be replaced with graphical ones.
  • Web page addresses and e-mail addresses turn into links automatically.

More information about formatting options

User login
Recent comments