RailsDAV now up for Rails 2.0.2
February 23rd, 2008
Hi all,
The RailsDAV plugin for integrating WebDAV controllers into your Rails application is now compatible with Rails 2.0.2. I’m doing a complete re-write to make RailsDAV easier to use and work with merb as well, but it’s slow going.
You can install RailsDAV with
ruby script/plugin install http://svn.liverail.net/svn/plugins/railsdav
WebDAV plugin for Mephisto
May 5th, 2007
I’ve put together a WebDAV plugin for mephisto the rails blogging engine which runs this site which adds 2 webdav controllers using RailsDAV.
1. Theme DAV Controller – Allows a standard file mount of the mephisto themes directory protected by a BASIC authentication requiring you to log in as an admin user. This means you can edit the life themes from your favourite editor. All general file functions such as move, copy, delete and make folder should all be good.
2. Asset DAV Controller – Allows uploading and downloading of Mephisto assets through the file system mounting. This is a great example of using RailsDAV with attachment_fu which i’ll go into greater detail about in a later post. It’s worth noting that if you upload images, the resized versions thumb and tiny are also then available for download. You can’t create new directories but you can delete assets.
For now installing the mephisto_dav plugin has the following pre-reqs:
- Using Edge Mephisto
- Using Edge Rails
- Latest version of RailsDAV plugin installed.
So installation is a matter of running the following in your mephisto rails directory:
ruby script/plugin install http://svn.liverail.net/svn/plugins/railsdav
ruby script/plugin install http://svn.liverail.net/svn/plugins/mephisto_dav
Then after starting your server you can connect your favourite WebDAV client (such as Finder on Mac OS X) to http://server/theme_dav or http://server/asset_dav
UPDATE: I realise that the comments havn’t been working on liverail and the railsdav lighthouse project was shut. Both should be working now.
28 comments »RailsDAV Issue tracking on Lighthouse
April 20th, 2007
While I was away I noticed the release of the Lighthouse application for issue tracking by ActiveReload and thought this will be a great way to do my issue tracking on a few projects. I was going to setup a Trac instance for it but this may be an alternative which saves some time and effort on my part.
So there is now a public Lighthouse project for RailsDAV which I invite anyone using it to submit tickets for me with any problems they may be having, bugs, or feature requests.
I’ve also added a Paypal donate button because some nice chap said he would love to able to donate a little to keep this project alive which is awful kind of him. So if anyone wants to donate some money to RailsDAV and any other projects appearing on liverail.net go right ahead.
Thanks Stuart
10 comments »RailsDAV update, dynamic base_dir
January 13th, 2007
I’ve added a couple of features to the RailsDAV act_as_filewebdav. Dynamic base directories and absolute base directories.
act_as_filewebdav takes two parameters:
base_dir can take either a String for the base directory or a Symbol which will use a method in the controller to return the base directory to use on each request.
absolute allows for either true or false (defaults to false) to determine to use either an absolute filesystem directory or relative to the RAILS_ROOT
So a common example usecase to allow users to upload/download to their own directories after they have logged on using basic HTTP authentication.
class FileDavController < ApplicationController
act_as_filewebdav :base_dir => :user_web_dir, :absolute => true
before_filter :user_auth
def user_auth
basic_auth_required {|username, password| session[:user] = User.authenticate(username,password) }
end
def user_web_dir
"/var/user/#{session[:user].username}"
end
end
12 comments »
New WebDAV Ruby On Rails Plugin Release
January 6th, 2007
I’ve finally had some time over the holidays to put together a new release of the RailsDAV plugin for WebDAV functionality in Rails.
It’s still really a 0.0.2 release as bugs are to be fixed and still havn’t nailed a structure for the plugin i’m happy with. But for now I have improved the structure and implemented some fixes courtesy of Albert Ramstedt. Thanks Albert.
As such the use of RailsDAV plugin has changed a bit and it won’t be backwards compatible so scan the code if you are using it.
The act_as_railsdav method is attached to ActionController and can be used by calling act_as_railsdav on a controller
class MyDavController < ActionController::Base
act_as_railsdav
The controller must then have a route of
map.connect 'mydav/*path_info', :controller => 'my_dav', :action => 'webdav'
It is then necessary to implement some or all of the following methods:
- mkcol_for_path(path)
- write_content_to_path(path, content),
- copy_to_path(resource, dest_path, depth)
- move_to_path(resource, dest_path, depth)
- get_resource_for_path(path)
get_resource_for_path needs to return a WebDAVResource object such as FileWebDavResource
To add webdav authentication to your controller just use
class MyDavController < ActionController::Base
act_as_railsdav
before_filter :my_auth
def my_auth()
basic_auth_required |username, password| do
session[:user] = User.your_authentication(username,password)
end
end
Additionally you can add a simple filesystem expose to a controller by:
class FileDavController < ActionController::Base
act_as_filewebdav :base_dir => 'public'
end
The new version of the plugin can be donwloaded using
svn co http://svn.liverail.net/svn/plugins/railsdav
It also requires the following gems
- unicode (gem install unicode)
- mimetypes (gem install mime-types)
I’m going to spend a lot more time on RailsDAV now so let me know what you want out of it!
27 comments »WebDAV Ruby On Rails Plugin
June 25th, 2006
The moment a few of you have been waiting for.
I’m releasing the first version of the RailsDAV plugin. What does RailsDAV do. Well it allows people to create Ruby On Rails controllers which will respond to WebDAV requests and expose functionality as a file-system.
The plugin can be downloaded from
http://svn.liverail.net/svn/plugins/railsdav
Of course the great thing about WebDAV is that it doesn’t just need to expose a directory on your server but can expose any concept you have in your application. For instance, for a Digital Asset Management System expose a list of tags as directory names, navigate into that directory and see all the images tagged with that word.
I’ll write about using the plugin in just a second, but first a little wording. This is definitely a 0.1 release and still needs work and a lot of testing before being production ready. It is likely to take on a different shape as well. It has many problems under WebBrick but works very very nicely under Mongrel (this is a problem with WebBrick) But release early, release often huh!
The plugin contains a base WebDAV controller and 2 specific implementations. A file-system exposer and an ActiveRecord exposer.
With thanks to Fabien Franzen for his input so far
There is also video of the FileSystem WebDAV Controller and the ActiveRecord WebDAV Controller
Read the rest of this entryWebDAV on Rails
May 8th, 2006 A little treat for you all. As part of a larger project i've been working on, i've created a plugin for Rails which allows for controllers to handle "WebDAV":http://www.webdav.org/ requests. At the moment it is only working for Rails 1.0 but i'll work on upgrading it. It's still only beta, has a few problems and doesn't do the whole spec, which is massive. But it's a good start. WebDav controllers can be registered by:
class DavController < WebDavController
set_rails_webdav_root "directory_path"
set_max_propfind_depth 1
end
This will allow a directory under RAILS_ROOT to be accessible via WebDAV.
You can also register callbacks to handle the assets after a request
def after_webdav_put
logger.info("got a new file #{@file_path}")
end
WebDAV is great and a Rails implementation will allow exposing not just files but a file-system representation of your data and system to users.
Anyway i'll release the code soon but for now "here is a video":/assets/2007/2/4/WebDavOnRails.mov