The Artima Developer Community
Sponsored Link

Web Buzz Forum
RackDAV - Web Authoring for Rack

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Matthias Georgi

Posts: 54
Nickname: georgi
Registered: Apr, 2007

Matthias Georgi is a Ruby on Rails freelancer.
RackDAV - Web Authoring for Rack Posted: Apr 11, 2009 2:27 AM
Reply to this message Reply

This post originated from an RSS feed registered with Web Buzz by Matthias Georgi.
Original Post: RackDAV - Web Authoring for Rack
Feed Title: Matthias Georgi
Feed URL: http://feeds.feedburner.com/matthias-georgi?format=xml
Feed Description: Webdev, Gamedev and Interaction Design.
Latest Web Buzz Posts
Latest Web Buzz Posts by Matthias Georgi
Latest Posts From Matthias Georgi

Advertisement

RackDAV is Handler for Rack, which allows content authoring over HTTP. RackDAV brings its own file backend, but other backends are possible by subclassing RackDAV::Resource.

Install

Just install the gem from github:

$ gem sources -a http://gems.github.com
$ sudo gem install georgi-rack_dav

Quickstart

If you just want to share a folder over WebDAV, you can just start a simple server with:

$ rack_dav

This will start a WEBrick server on port 3000, which you can connect to without authentication.

Rack Handler

Using RackDAV inside a rack application is quite easy. A simple rackup script looks like this:

require 'rubygems'
require 'rack_dav'

use Rack::CommonLogger

run RackDAV::Handler.new('/path/to/docs')

Implementing your own WebDAV resource

RackDAV::Resource is an abstract base class and defines an interface for accessing resources.

Each resource will be initialized with a path, which should be used to find the real resource.

RackDAV::Handler needs to be initialized with the actual resource class:

RackDAV::Handler.new(:resource_class => MyResource)

RackDAV needs some information about the resources, so you have to implement following methods:

  • children: If this is a collection, return the child resources.

  • collection?: Is this resource a collection?

  • exist?: Does this recource exist?

  • creation_date: Return the creation time.

  • last_modified: Return the time of last modification.

  • last_modified=(time): Set the time of last modification.

  • etag: Return an Etag, an unique hash value for this resource.

  • content_type: Return the mime type of this resource.

  • content_length: Return the size in bytes for this resource.

Most importantly you have to implement the actions, which are called to retrieve and change the resources:

  • get(request, response): Write the content of the resource to the response.body.

  • put(request, response): Save the content of the request.body.

  • post(request, response): Usually forbidden.

  • delete: Delete this resource.

  • copy(dest): Copy this resource to given destination resource.

  • move(dest): Move this resource to given destination resource.

  • make_collection: Create this resource as collection.

Note, that it is generally possible, that a resource object is instantiated for a not yet existing resource.

For inspiration you should have a look at the FileResource implementation. Please let me now, if you are going to implement a new type of resource.

RackDAV on GitHub

Download or fork the project on its Github page

Read: RackDAV - Web Authoring for Rack

Topic: Download Apple iTunes 8.1.1 For Windows and Mac OS X. Previous Topic   Next Topic Topic: Visual Studio Flex Property Pages

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use