GithubHelp home page GithubHelp logo

rack_dav's Introduction


RackDAV - Web Authoring for Rack

RackDAV is a Ruby gem that allows you to use the WebDAV protocol to edit and manage files over HTTP. It comes with its own file backend, but you can also create your own backend by subclassing RackDAV::Resource.

Quickstart

To install the gem, run gem install rack_dav.

To quickly test out RackDAV, copy the config.ru file from this repository and run bundle exec rackup. This will start a web server on a default port that you can connect to without any authentication.

Rack Handler

To use RackDAV in your own rack application, include the following in your config.ru file:

require 'rubygems'
require 'rack_dav'

use Rack::CommonLogger

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

Implementing your own WebDAV resource

If you want to create your own WebDAV resource, you will need to subclass RackDAV::Resource and implement the 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.

  • 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.

  • set_custom_property(name, value): Set a custom property on the resource. If the value is nil, delete the custom property.

  • get_custom_property(name): Return the value of the named custom property.

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

  • unlock(token): Unlock this resource

Note that it is possible that a resource object may be instantiated for a resource that does not yet exist.

For more examples and inspiration, you can look at the FileResource implementation.

rack_dav's People

Contributors

asppsa avatar codeodor avatar georgi avatar gregormelhorn avatar jatoben avatar lleirborras avatar nevir avatar pho3nixf1re avatar pschrammel avatar ramonmaruko avatar vjt avatar weppos avatar yuya-takeyama avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

rack_dav's Issues

Readme documentation outdated

Just ran across this small omission in the readme example while trying to implement rack_dav. The example in the Rack Handler section has the line: "run RackDAV::Handler.new('/path/to/docs')" and it should be: "run RackDAV::Handler.new(:root => '/path/to/docs')" otherwise a merge error will occur.

Need access to rack parameters in Resource subclasses

I see you are passing the request and response objects into the get put and post methods, but that is not enough. If I'm pulling resources dynamically then I need to be able to generate etags, modify dates, delete actions, etc with the params as well. Eg. a database driven resource. I do not see a way to retrieve the parameters from any methods other than get put and post which prevents this. Am I missing something or do I need to submit a patch for this?

As far as a patch, why don't we just add the request and response to the initialization of the resource?

rack_dav implementation example

I would want to display all the files from owncloud on a webpage on Rails which i'm creating.

Can anyone give me an example which would explain the implementation of this gem ? The documentation of it does not say much for a newbie.

Thanks

Wrong resource urls in response if RackDAV handler not mounted at '/'

My application has RackDAV handler mounted at /webdav, which prevents any client I tried from even showing any collection properly. The reason for that is that the urls in WebDAV responses are wrong, eg. www.mydomain.com/resource instead of www.mydomain.com/webdav/resource.

The problem is line 188 in controller.rb - if I add request.script_name there:

xml.href "http://#{host}#{@request.script_name}#{url_escape resource.path}"

all the clients start working properly.

BadGateway

in copy and move you are checking :

 raise BadGateway if dest_uri.host and dest_uri.host != request.host

I have a situation where I am forwarding to the rack server from another device and it is not setting the variables up correctly.

Why is it a bad thing if the dest_uir.host does not match the request.host?

Binary file write fails with OSX/Finder connection

  • in OSX, used finder to map the rack_dav endpoint as a share location localhost:3000 using rack_dav binary
  • drag-and-drop a binary file onto the new share (1.7MB dmg file)
  • Finder reports: '... can't complete operation because some data in "file" can't be read or written. (Error code -36)'
  • no exceptions from rack_dav, but there are a sequence of PROPFIND, PUT, LOCK and UNLOCK commands and a 404 on a request for '/.root_folder' near the end of the transaction

RackDAV::Controller#url_escape problem

Hello,

Thank you for very nice product.

in ruby1.9.3, RackDAV::Controller#url_escape doesn't work fine. (cannot use Japanese)
(in ruby1.8.7, it works fine.)

Test Code:

#!ruby -Ku
#coding: utf-8

require "uri"

def url_escape(s)
  s.gsub(/([^\/a-zA-Z0-9_.-]+)/n) do
    '%' + $1.unpack('H2' * $1.size).join('%').upcase
  end.tr(' ', '+')
end

str = "現像"
puts "#{str} should be escaped to [#{URI.escape(str)}]"
puts "#{str} is escaped to [#{url_escape(str)}]"

Result:

$ rvm use 1.9.3
$ ruby a.rb
現像 should be escaped to [%E7%8F%BE%E5%83%8F]
a.rb:8: warning: regexp match /.../n against to UTF-8 string
a.rb:8: warning: regexp match /.../n against to UTF-8 string
a.rb:8: warning: regexp match /.../n against to UTF-8 string
現像 is escaped to [%E7%8F]
$ rvm use 1.8.7
$ ruby a.rb
現像 should be escaped to [%E7%8F%BE%E5%83%8F]
現像 is escaped to [%E7%8F%BE%E5%83%8F]

I modified this method, then It seems to work well.

After:

def url_escape(s)
  s.gsub(/([^\/a-zA-Z0-9_.-]+)/) do
    '%' + $1.unpack('H2' * $1.bytesize).join('%').upcase
  end.tr(' ', '+')
end

Result:

$ rvm use 1.9.3
$ ruby a.rb
現像 should be escaped to [%E7%8F%BE%E5%83%8F]
現像 is escaped to [%E7%8F%BE%E5%83%8F]
$ rvm use 1.8.7
$ ruby a.rb
現像 should be escaped to [%E7%8F%BE%E5%83%8F]
現像 is escaped to [%E7%8F%BE%E5%83%8F]

Thanks,
kinumi.

litmus compatibility

Would like to know if you intend to put rack_dav working according trough litmus [ http://www.webdav.org/neon/litmus/ ] compliance test suite.

If you intend, then I can help

good job on this project ;)

Incompatible with rails 7.0.x and 7.1.x.alpha

Bundler could not find compatible versions for gem "rackup":
  In Gemfile:
    rack_dav (~> 0.5.2) was resolved to 0.5.2, which depends on
      rackup (~> 0.2.3)

    rails was resolved to 7.1.0.alpha, which depends on
      railties (= 7.1.0.alpha) was resolved to 7.1.0.alpha, which depends on
        rackup (>= 1.0.0)

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.