GithubHelp home page GithubHelp logo

schmurfy / rack_dav Goto Github PK

View Code? Open in Web Editor NEW

This project forked from georgi/rack_dav

0.0 3.0 0.0 443 KB

WEBDAV Handler for Rack

Home Page: http://www.matthias-georgi.de/rack_dav

License: Other

rack_dav's Introduction

title
RackDAV - Web Authoring for Rack

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 RubyGems:

$ gem install 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(:root => '/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.

  • lock(token, timeout, scope, type, owner): Lock this resource. If scope, type and owner are nil, refresh the given lock.

  • unlock(token): Unlock this resource

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

rack_dav's People

Contributors

vjt avatar weppos avatar georgi avatar nevir avatar gregormelhorn avatar

Watchers

Julien Ammous avatar James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.