webdavtools 0.0.1 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.rdoc +28 -15
- data/bin/wdav +42 -0
- data/lib/webdavtools.rb +34 -190
- data/lib/webdavtools/curl_commands.rb +50 -0
- data/lib/webdavtools/hpricot_extensions.rb +113 -0
- data/{bin/wdcd → lib/webdavtools/wdav_cd.rb} +3 -19
- data/{bin/wdls → lib/webdavtools/wdav_ls.rb} +5 -6
- data/{bin/wdprops → lib/webdavtools/wdav_props.rb} +3 -2
- data/lib/webdavtools/wdav_pwd.rb +10 -0
- metadata +11 -13
- data/bin/wdput +0 -3
- data/bin/wdpwd +0 -10
data/README.rdoc
CHANGED
@@ -5,21 +5,25 @@
|
|
5
5
|
|
6
6
|
== DESCRIPTION:
|
7
7
|
|
8
|
-
WebDAVTools is a
|
9
|
-
|
10
|
-
|
11
|
-
Apache JackRabbit, that support the WebDAV protocol.
|
8
|
+
WebDAVTools is a WebDAV client written in Ruby for managing
|
9
|
+
content on webservers that support the WebDAV extensions.
|
10
|
+
|
12
11
|
|
13
12
|
== Requirements
|
14
13
|
|
15
|
-
|
14
|
+
The command line utility curl installed. Available from
|
15
|
+
http://curl.haxx.se/ or on linux:
|
16
|
+
|
17
|
+
sudo apt-get install curl
|
16
18
|
|
17
19
|
== LIRBRARY SYNOPSIS:
|
18
20
|
|
19
21
|
require 'rubygems'
|
20
22
|
require 'webdavtools'
|
21
23
|
|
22
|
-
#
|
24
|
+
# Print url of all files in webdav folder recursively
|
25
|
+
# with basic tree walking
|
26
|
+
|
23
27
|
url = 'http://test.webdav.org/dav/'
|
24
28
|
WebDAV.find(url, :recursive => true) do |item|
|
25
29
|
puts item.href
|
@@ -27,31 +31,40 @@ Unix and the command line utility curl installed.
|
|
27
31
|
|
28
32
|
== COMMAND LINE UTILITES:
|
29
33
|
|
30
|
-
WebDAVTools includes
|
31
|
-
By using commands like
|
32
|
-
current working url, users can access files and
|
33
|
-
only authentication by adding usernames and passwords to ~/.netrc file is supported.
|
34
|
+
WebDAVTools includes the command line utility 'wdav'. It should be somewhat familiar to unix users.
|
35
|
+
By using commands like 'wdav cd url' to set current working url, 'wdav ls' to list files and 'wdav pwd'
|
36
|
+
to print current working url, users can access files, folders and their properties on webdav servers.
|
34
37
|
|
38
|
+
The only authentication method supported at the method is by reading usernames and passwords from
|
39
|
+
a file named ~/.netrc. If username is missing, 'wdav' will print out instructions for what to
|
40
|
+
add to the .netrc file.
|
35
41
|
|
36
42
|
== COMMAND LINE SYNOPSIS:
|
37
43
|
|
38
|
-
>
|
44
|
+
>wdav cd http://test.webdav.org/dav/
|
39
45
|
http://test.webdav.org/dav/
|
40
|
-
>
|
46
|
+
>wdav ls
|
41
47
|
images/
|
42
48
|
index.html
|
43
|
-
>
|
49
|
+
>wdav pwd
|
44
50
|
http://test.webdav.org/dav/
|
45
51
|
|
46
52
|
== INSTALL:
|
47
53
|
|
48
|
-
[sudo] gem sources -a http://gems.github.com
|
49
54
|
[sudo] gem install webdavtools
|
50
55
|
|
51
56
|
or
|
52
57
|
|
53
58
|
git clone git://github.com/thomasfl/webdavtools.git
|
54
59
|
cd webdavtools
|
55
|
-
|
60
|
+
gem build Rakefile
|
61
|
+
sudo gem install webdavtools-x.x.x.gem
|
62
|
+
|
63
|
+
== Background:
|
56
64
|
|
65
|
+
There has been posted a few examples on the web of how to make a WebDAV client.
|
66
|
+
The problem is that they all seem to support only one type of username and password
|
67
|
+
authentication. WebDAVTools instead uses the command line tool 'curl' to do all the
|
68
|
+
authentication and networking. To avoid handling authentication all togheter, curl
|
69
|
+
are told to look up all usernames and passwords are in a file named ~/.netrc.
|
57
70
|
|
data/bin/wdav
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'rubygems'
|
3
|
+
require 'webdavtools'
|
4
|
+
|
5
|
+
def print_usage
|
6
|
+
puts "usage: wdav COMMAND [ARGS]"
|
7
|
+
puts ""
|
8
|
+
puts "Available wdav commands:"
|
9
|
+
puts " ls List files on webdav server"
|
10
|
+
puts " pwd Print current working url"
|
11
|
+
puts " cd Change current working url"
|
12
|
+
puts " props Print webdav properties for url"
|
13
|
+
puts ""
|
14
|
+
puts "See 'wdav COMMAND -h' for more information on a specific command."
|
15
|
+
exit
|
16
|
+
end
|
17
|
+
|
18
|
+
command = ARGV[0]
|
19
|
+
if(command == "-h" or command =~ /help/ or command =~ /\?/) then
|
20
|
+
print_usage
|
21
|
+
end
|
22
|
+
|
23
|
+
if(command == "-v" or command =~ /version/ ) then
|
24
|
+
puts "wdav version " + WebDAV.version
|
25
|
+
exit
|
26
|
+
end
|
27
|
+
|
28
|
+
case command
|
29
|
+
when "ls" then
|
30
|
+
require 'webdavtools/wdav_ls'
|
31
|
+
when "pwd"
|
32
|
+
require 'webdavtools/wdav_pwd'
|
33
|
+
when "cd"
|
34
|
+
require 'webdavtools/wdav_cd'
|
35
|
+
when "props"
|
36
|
+
require 'webdavtools/wdav_props'
|
37
|
+
# when "put"
|
38
|
+
# require 'webdavtools/wdav_put'
|
39
|
+
else
|
40
|
+
puts "Unknown command :'" + command + "'"
|
41
|
+
print_usage
|
42
|
+
end
|
data/lib/webdavtools.rb
CHANGED
@@ -1,88 +1,22 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
|
-
# File: webdavtools.rb - WebDAV library
|
3
2
|
|
4
3
|
require 'rubygems'
|
5
4
|
require 'hpricot'
|
5
|
+
require 'tempfile'
|
6
|
+
require 'webdavtools/hpricot_extensions'
|
6
7
|
|
7
8
|
# :stopdoc:
|
8
9
|
|
9
10
|
# Path to curl executable:
|
10
|
-
$curl = "
|
11
|
-
|
12
|
-
|
13
|
-
curl_propfind_cmd = <<EOF
|
14
|
-
#{$curl}
|
15
|
-
--request PROPFIND
|
16
|
-
--header 'Content-Type: text/xml; charset="utf-8"'
|
17
|
-
--header "Depth: 1"
|
18
|
-
--data-ascii '<?xml version="1.0" encoding="utf-8"?>
|
19
|
-
<DAV:propfind xmlns:DAV="DAV:"><DAV:allprop/></DAV:propfind>'
|
20
|
-
--netrc
|
21
|
-
--silent
|
22
|
-
EOF
|
23
|
-
CURL_PROPFIND = curl_propfind_cmd.gsub("\n","").gsub(/ +/," ")
|
24
|
-
|
25
|
-
curl_proppatch_cmd = <<EOF
|
26
|
-
#{$curl}
|
27
|
-
--request PROPPATCH
|
28
|
-
--header 'Content-Type: text/xml; charset="utf-8"'
|
29
|
-
--header "Depth: 1"
|
30
|
-
--data-ascii '<?xml version="1.0"?>
|
31
|
-
<d:propertyupdate xmlns:d="DAV:" xmlns:v="vrtx">
|
32
|
-
<d:set>
|
33
|
-
<d:prop>
|
34
|
-
<!--property-and-value-->
|
35
|
-
</d:prop>
|
36
|
-
</d:set>
|
37
|
-
</d:propertyupdate>'
|
38
|
-
--netrc
|
39
|
-
--silent
|
40
|
-
EOF
|
41
|
-
CURL_PROPPATCH = curl_proppatch_cmd.gsub("\n","").gsub(/ +/," ")
|
42
|
-
|
43
|
-
curl_delete_cmd = <<EOF
|
44
|
-
#{$curl}
|
45
|
-
--request DELETE
|
46
|
-
--header 'Content-Type: text/xml; charset="utf-8"'
|
47
|
-
--netrc
|
48
|
-
--silent
|
49
|
-
EOF
|
50
|
-
CURL_DELETE = curl_delete_cmd.gsub("\n","").gsub(/ +/," ") + " "
|
51
|
-
|
52
|
-
curl_mkcol_cmd = <<EOF
|
53
|
-
#{$curl}
|
54
|
-
--request MKCOL
|
55
|
-
--header 'Content-Type: text/xml; charset="utf-8"'
|
56
|
-
--netrc
|
57
|
-
--silent
|
58
|
-
EOF
|
59
|
-
CURL_MKCOL = curl_mkcol_cmd.gsub("\n","").gsub(/ +/," ") + " "
|
60
|
-
|
61
|
-
# Disse er ikke i bruk lenger.
|
62
|
-
# Lag eventuelt et bibliotek som holder orden
|
63
|
-
# på vortex typer ut fra http://vortex-dev.uio.no/vrtx/resourcetypes.txt
|
64
|
-
EVENT_FOLDER = '<v:collection-type xmlns:v="vrtx">event-listing</v:collection-type>' +
|
65
|
-
'<v:resourceType xmlns:v="vrtx">event-listing</v:resourceType>'
|
66
|
-
ARTICLE_FOLDER = '<v:collection-type xmlns:v="vrtx">article-listing</v:collection-type>' +
|
67
|
-
'<v:resourceType xmlns:v="vrtx">article-listing</v:resourceType>'
|
11
|
+
$curl = "curl"
|
12
|
+
|
13
|
+
require 'webdavtools/curl_commands'
|
68
14
|
|
69
15
|
# :startdoc:
|
70
16
|
|
71
|
-
# WebDAV
|
17
|
+
# WebDAV client
|
72
18
|
module WebDAV
|
73
19
|
|
74
|
-
# Returns current working url. Used by command line utilites
|
75
|
-
def self.CWURL
|
76
|
-
cwurl = ""
|
77
|
-
File.open("/tmp/cwurl", 'r') {|f| cwurl = f.read() }
|
78
|
-
return cwurl
|
79
|
-
end
|
80
|
-
|
81
|
-
# Sets current working url
|
82
|
-
def self.CWURL=(url)
|
83
|
-
File.open("/tmp/cwurl", 'w') {|f| f.write(url) }
|
84
|
-
end
|
85
|
-
|
86
20
|
# :stopdoc:
|
87
21
|
VERSION = '0.1.0'
|
88
22
|
# :startdoc:
|
@@ -93,6 +27,21 @@ module WebDAV
|
|
93
27
|
VERSION
|
94
28
|
end
|
95
29
|
|
30
|
+
# Returns current working url. Used by command line utilites
|
31
|
+
def self.CWURL
|
32
|
+
cwurl = nil
|
33
|
+
filename = cwurl_filename
|
34
|
+
if(File.exists?(filename))
|
35
|
+
File.open(filename, 'r') {|f| cwurl = f.read() }
|
36
|
+
end
|
37
|
+
return cwurl
|
38
|
+
end
|
39
|
+
|
40
|
+
# Sets current working url
|
41
|
+
def self.CWURL=(url)
|
42
|
+
File.open(cwurl_filename, 'w') {|f| f.write(url) }
|
43
|
+
end
|
44
|
+
|
96
45
|
# Get content as string
|
97
46
|
# Example:
|
98
47
|
# html = WebDAV.get(url)
|
@@ -262,7 +211,8 @@ module WebDAV
|
|
262
211
|
|
263
212
|
# Low level WebDAV publish
|
264
213
|
# Example:
|
265
|
-
#
|
214
|
+
#
|
215
|
+
# WebDAV.publish("https://dav.example.org/index.html","<h1>Hello</h1>",nil)
|
266
216
|
def self.publish(url, string, props)
|
267
217
|
self.put_string(url, string)
|
268
218
|
if(props)then
|
@@ -271,7 +221,7 @@ module WebDAV
|
|
271
221
|
end
|
272
222
|
|
273
223
|
|
274
|
-
# PUT content
|
224
|
+
# PUT content of string
|
275
225
|
# Example:
|
276
226
|
# WebDAV.put("https://dav.webdav.org/file.html", "<html><h1>Test</h1></html>"
|
277
227
|
def self.put_string(url, html)
|
@@ -299,14 +249,19 @@ module WebDAV
|
|
299
249
|
return execute_curl_cmd(curl_put_cmd)
|
300
250
|
end
|
301
251
|
|
302
|
-
# TODO ????
|
303
|
-
def put_html_file(url_folder, filename, html)
|
304
|
-
# Write html
|
305
|
-
end
|
306
|
-
|
307
252
|
|
308
253
|
private
|
309
254
|
|
255
|
+
# Returns filename /tmp/cwurl.#pid that holds the current working directory
|
256
|
+
# for the shell's pid
|
257
|
+
def self.cwurl_filename
|
258
|
+
tmp_file = Tempfile.new("dummy").path
|
259
|
+
basename = File.basename(tmp_file)
|
260
|
+
tmp_folder = tmp_file.gsub(basename, "")
|
261
|
+
return tmp_folder + "cwurl." + Process.ppid.to_s
|
262
|
+
end
|
263
|
+
|
264
|
+
# Display instructions for adding credentials to .netrc file
|
310
265
|
def self.display_unauthorized_message(href)
|
311
266
|
puts "Error: 401 Unauthorized: " + href
|
312
267
|
href.match(/^http.*\/\/([^\/]*)/)
|
@@ -331,114 +286,3 @@ module WebDAV
|
|
331
286
|
end
|
332
287
|
|
333
288
|
end
|
334
|
-
|
335
|
-
# TODO Extract to ruby sourcefile
|
336
|
-
|
337
|
-
# Add custom functionality to the xml parser (monkey patching):
|
338
|
-
module Hpricot
|
339
|
-
|
340
|
-
|
341
|
-
# TODO: url method as alias for href
|
342
|
-
|
343
|
-
class Elem
|
344
|
-
|
345
|
-
def method_missing(method_name, *args)
|
346
|
-
if(args.size == 0) then
|
347
|
-
return property(method_name.to_s)
|
348
|
-
end
|
349
|
-
raise "Method missing"
|
350
|
-
end
|
351
|
-
|
352
|
-
def href()
|
353
|
-
self.at("d:href").innerText
|
354
|
-
end
|
355
|
-
|
356
|
-
def isCollection?()
|
357
|
-
self.at("d:collection") != nil
|
358
|
-
end
|
359
|
-
|
360
|
-
end
|
361
|
-
|
362
|
-
# TODO Not used. Delete???
|
363
|
-
def type_convert_value(value)
|
364
|
-
if(returnValue == "true")then
|
365
|
-
return true
|
366
|
-
end
|
367
|
-
if(returnValue == "false")then
|
368
|
-
return false
|
369
|
-
end
|
370
|
-
# Number format???
|
371
|
-
## Dato format
|
372
|
-
return returnValue
|
373
|
-
end
|
374
|
-
|
375
|
-
# TODO: Make list of recognized namespace prefixes configurable
|
376
|
-
# Get property.
|
377
|
-
# Example:
|
378
|
-
# page = WebDAV.find(url)
|
379
|
-
# print page.property("published-date")
|
380
|
-
def property(name)
|
381
|
-
|
382
|
-
property = property = self.at(name)
|
383
|
-
if(property)then
|
384
|
-
returnValue = property.innerText
|
385
|
-
return returnValue
|
386
|
-
end
|
387
|
-
|
388
|
-
property = property = self.at(name.downcase)
|
389
|
-
if(property)then
|
390
|
-
return property.innerText
|
391
|
-
end
|
392
|
-
|
393
|
-
vrtx_property = self.at("v:" + name)
|
394
|
-
if(vrtx_property)then
|
395
|
-
return vrtx_property.innerText
|
396
|
-
end
|
397
|
-
|
398
|
-
vrtx_property = self.at("v:" + name.downcase)
|
399
|
-
if(vrtx_property)then
|
400
|
-
return vrtx_property.innerText
|
401
|
-
end
|
402
|
-
|
403
|
-
dav_property = self.at("d:" +name)
|
404
|
-
if( dav_property)then
|
405
|
-
return dav_property.innerText
|
406
|
-
end
|
407
|
-
|
408
|
-
dav_property = self.at("d:" +name.downcase)
|
409
|
-
if( dav_property)then
|
410
|
-
return dav_property.innerText
|
411
|
-
end
|
412
|
-
|
413
|
-
return nil
|
414
|
-
end
|
415
|
-
|
416
|
-
def basename
|
417
|
-
File.basename(self.at("d:href").innerText)
|
418
|
-
end
|
419
|
-
|
420
|
-
# TODO: Move to vortex_lib.rb
|
421
|
-
def dateProperty(name)
|
422
|
-
date = self.property(name)
|
423
|
-
if(date =~ /\dZ$/)then
|
424
|
-
# Fix for bug in vortex:
|
425
|
-
#
|
426
|
-
# Some date properties are in xmlshcema datetime format, but
|
427
|
-
# all tough the time seems to be localtime the timezone is
|
428
|
-
# specified as Z not CEST. Fix is to set timezone and add
|
429
|
-
# 2 hours.
|
430
|
-
date = date.gsub(/\dZ$/," CEST")
|
431
|
-
time = Time.parse(date)
|
432
|
-
time = time + (60 * 60 * 2)
|
433
|
-
return time
|
434
|
-
end
|
435
|
-
time = Time.parse(date)
|
436
|
-
return time
|
437
|
-
end
|
438
|
-
|
439
|
-
# Set the items WebDAV properties. Properties must be a string with XML.
|
440
|
-
def proppatch(properties)
|
441
|
-
WebDAV.proppatch(href, properties)
|
442
|
-
end
|
443
|
-
|
444
|
-
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
|
3
|
+
# Templates for curl commands:
|
4
|
+
curl_propfind_cmd = <<EOF
|
5
|
+
#{$curl}
|
6
|
+
--request PROPFIND
|
7
|
+
--header 'Content-Type: text/xml; charset="utf-8"'
|
8
|
+
--header "Depth: 1"
|
9
|
+
--data-ascii '<?xml version="1.0" encoding="utf-8"?>
|
10
|
+
<DAV:propfind xmlns:DAV="DAV:"><DAV:allprop/></DAV:propfind>'
|
11
|
+
--netrc
|
12
|
+
--silent
|
13
|
+
EOF
|
14
|
+
CURL_PROPFIND = curl_propfind_cmd.gsub("\n","").gsub(/ +/," ")
|
15
|
+
|
16
|
+
curl_proppatch_cmd = <<EOF
|
17
|
+
#{$curl}
|
18
|
+
--request PROPPATCH
|
19
|
+
--header 'Content-Type: text/xml; charset="utf-8"'
|
20
|
+
--header "Depth: 1"
|
21
|
+
--data-ascii '<?xml version="1.0"?>
|
22
|
+
<d:propertyupdate xmlns:d="DAV:" xmlns:v="vrtx">
|
23
|
+
<d:set>
|
24
|
+
<d:prop>
|
25
|
+
<!--property-and-value-->
|
26
|
+
</d:prop>
|
27
|
+
</d:set>
|
28
|
+
</d:propertyupdate>'
|
29
|
+
--netrc
|
30
|
+
--silent
|
31
|
+
EOF
|
32
|
+
CURL_PROPPATCH = curl_proppatch_cmd.gsub("\n","").gsub(/ +/," ")
|
33
|
+
|
34
|
+
curl_delete_cmd = <<EOF
|
35
|
+
#{$curl}
|
36
|
+
--request DELETE
|
37
|
+
--header 'Content-Type: text/xml; charset="utf-8"'
|
38
|
+
--netrc
|
39
|
+
--silent
|
40
|
+
EOF
|
41
|
+
CURL_DELETE = curl_delete_cmd.gsub("\n","").gsub(/ +/," ") + " "
|
42
|
+
|
43
|
+
curl_mkcol_cmd = <<EOF
|
44
|
+
#{$curl}
|
45
|
+
--request MKCOL
|
46
|
+
--header 'Content-Type: text/xml; charset="utf-8"'
|
47
|
+
--netrc
|
48
|
+
--silent
|
49
|
+
EOF
|
50
|
+
CURL_MKCOL = curl_mkcol_cmd.gsub("\n","").gsub(/ +/," ") + " "
|
@@ -0,0 +1,113 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'hpricot'
|
5
|
+
|
6
|
+
# Extensions to hpricot xml parser
|
7
|
+
module Hpricot
|
8
|
+
|
9
|
+
|
10
|
+
# TODO: url method as alias for href
|
11
|
+
|
12
|
+
class Elem
|
13
|
+
|
14
|
+
def method_missing(method_name, *args)
|
15
|
+
if(args.size == 0) then
|
16
|
+
return property(method_name.to_s)
|
17
|
+
end
|
18
|
+
raise "Method missing"
|
19
|
+
end
|
20
|
+
|
21
|
+
def href()
|
22
|
+
self.at("d:href").innerText
|
23
|
+
end
|
24
|
+
|
25
|
+
def isCollection?()
|
26
|
+
self.at("d:collection") != nil
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
|
31
|
+
# TODO Not used. Delete???
|
32
|
+
def type_convert_value(value)
|
33
|
+
if(returnValue == "true")then
|
34
|
+
return true
|
35
|
+
end
|
36
|
+
if(returnValue == "false")then
|
37
|
+
return false
|
38
|
+
end
|
39
|
+
# Number format???
|
40
|
+
## Dato format
|
41
|
+
return returnValue
|
42
|
+
end
|
43
|
+
|
44
|
+
# TODO: Make list of recognized namespace prefixes configurable
|
45
|
+
# Get property.
|
46
|
+
# Example:
|
47
|
+
# page = WebDAV.find(url)
|
48
|
+
# print page.property("published-date")
|
49
|
+
def property(name)
|
50
|
+
|
51
|
+
property = property = self.at(name)
|
52
|
+
if(property)then
|
53
|
+
returnValue = property.innerText
|
54
|
+
return returnValue
|
55
|
+
end
|
56
|
+
|
57
|
+
property = property = self.at(name.downcase)
|
58
|
+
if(property)then
|
59
|
+
return property.innerText
|
60
|
+
end
|
61
|
+
|
62
|
+
vrtx_property = self.at("v:" + name)
|
63
|
+
if(vrtx_property)then
|
64
|
+
return vrtx_property.innerText
|
65
|
+
end
|
66
|
+
|
67
|
+
vrtx_property = self.at("v:" + name.downcase)
|
68
|
+
if(vrtx_property)then
|
69
|
+
return vrtx_property.innerText
|
70
|
+
end
|
71
|
+
|
72
|
+
dav_property = self.at("d:" +name)
|
73
|
+
if( dav_property)then
|
74
|
+
return dav_property.innerText
|
75
|
+
end
|
76
|
+
|
77
|
+
dav_property = self.at("d:" +name.downcase)
|
78
|
+
if( dav_property)then
|
79
|
+
return dav_property.innerText
|
80
|
+
end
|
81
|
+
|
82
|
+
return nil
|
83
|
+
end
|
84
|
+
|
85
|
+
def basename
|
86
|
+
File.basename(self.at("d:href").innerText)
|
87
|
+
end
|
88
|
+
|
89
|
+
# TODO: Move to vortex_lib.rb
|
90
|
+
def dateProperty(name)
|
91
|
+
date = self.property(name)
|
92
|
+
if(date =~ /\dZ$/)then
|
93
|
+
# Fix for bug in vortex:
|
94
|
+
#
|
95
|
+
# Some date properties are in xmlshcema datetime format, but
|
96
|
+
# all tough the time seems to be localtime the timezone is
|
97
|
+
# specified as Z not CEST. Fix is to set timezone and add
|
98
|
+
# 2 hours.
|
99
|
+
date = date.gsub(/\dZ$/," CEST")
|
100
|
+
time = Time.parse(date)
|
101
|
+
time = time + (60 * 60 * 2)
|
102
|
+
return time
|
103
|
+
end
|
104
|
+
time = Time.parse(date)
|
105
|
+
return time
|
106
|
+
end
|
107
|
+
|
108
|
+
# Set the items WebDAV properties. Properties must be a string with XML.
|
109
|
+
def proppatch(properties)
|
110
|
+
WebDAV.proppatch(href, properties)
|
111
|
+
end
|
112
|
+
|
113
|
+
end
|
@@ -1,8 +1,8 @@
|
|
1
|
-
|
1
|
+
# Handle 'wdav cd URL' commands
|
2
2
|
require 'rubygems'
|
3
3
|
require 'webdavtools'
|
4
4
|
|
5
|
-
url = ARGV[
|
5
|
+
url = ARGV[1]
|
6
6
|
if(url =~ /^http/)then
|
7
7
|
resource = WebDAV.propfind(url)
|
8
8
|
if(resource and resource.isCollection?)then
|
@@ -24,20 +24,4 @@ elsif(url)then
|
|
24
24
|
puts "DEBUG: type:" + type.to_s
|
25
25
|
end
|
26
26
|
|
27
|
-
|
28
|
-
exit
|
29
|
-
|
30
|
-
if(not url)then
|
31
|
-
url = WebDAV.CWURL
|
32
|
-
if(not url)then
|
33
|
-
puts "wdls: no current working url"
|
34
|
-
puts "Usage: Use 'wdopen url' or 'wdcd [url|dir] to set current working url "
|
35
|
-
exit
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
WebDAV.find(url, :recursive => false ) do |item|
|
40
|
-
puts item.href
|
41
|
-
end
|
42
|
-
|
43
|
-
# TODO only works on collections, should give som info about resources too.
|
27
|
+
# TODO Should take a folder name as parameter as well
|
@@ -1,12 +1,11 @@
|
|
1
|
-
|
1
|
+
# Handle command 'wdav ls [url]'
|
2
2
|
require 'rubygems'
|
3
3
|
require 'webdavtools'
|
4
4
|
require 'optparse'
|
5
|
-
|
6
5
|
options = {}
|
7
6
|
|
8
7
|
optparse = OptionParser.new do|opts|
|
9
|
-
opts.banner = "Usage: #{$0} [options] url"
|
8
|
+
opts.banner = "Usage: #{$0} ls [options] url"
|
10
9
|
|
11
10
|
opts.on( '-h', '--help', 'Display this screen' ) do
|
12
11
|
puts opts
|
@@ -34,12 +33,12 @@ rescue
|
|
34
33
|
end
|
35
34
|
|
36
35
|
|
37
|
-
url = ARGV[
|
36
|
+
url = ARGV[1]
|
38
37
|
if(not url)then
|
39
38
|
url = WebDAV.CWURL
|
40
39
|
if(not url)then
|
41
|
-
puts "
|
42
|
-
puts "Usage: Use '
|
40
|
+
puts "wdav ls: no current working url"
|
41
|
+
puts "Usage: Use 'wdav open url' or 'wdav cd [url|dir] to set current working url"
|
43
42
|
exit
|
44
43
|
end
|
45
44
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
# Handle 'wdav props [URL]' command
|
2
2
|
require 'rubygems'
|
3
3
|
require 'webdavtools'
|
4
4
|
require 'optparse'
|
@@ -34,8 +34,9 @@ rescue
|
|
34
34
|
exit
|
35
35
|
end
|
36
36
|
|
37
|
-
url = ARGV[
|
37
|
+
url = ARGV[1]
|
38
38
|
if(not(url)) then
|
39
|
+
# TODO: Use CWURL if not set
|
39
40
|
puts "Error: Missing mandatory url"
|
40
41
|
puts optparse
|
41
42
|
exit
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: webdavtools
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Thomas Flemming
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-08-
|
12
|
+
date: 2009-08-26 00:00:00 +02:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -22,25 +22,23 @@ dependencies:
|
|
22
22
|
- !ruby/object:Gem::Version
|
23
23
|
version: "0.6"
|
24
24
|
version:
|
25
|
-
description:
|
25
|
+
description: WebDAVTools is a WebDAV client written in Ruby for managing content on webservers that support the WebDAV extensions.
|
26
26
|
email: thomas.flemming@gmail.com
|
27
27
|
executables:
|
28
|
-
-
|
29
|
-
- wdls
|
30
|
-
- wdprops
|
31
|
-
- wdput
|
32
|
-
- wdpwd
|
28
|
+
- wdav
|
33
29
|
extensions: []
|
34
30
|
|
35
31
|
extra_rdoc_files:
|
36
32
|
- README.rdoc
|
37
33
|
files:
|
38
34
|
- lib/webdavtools.rb
|
39
|
-
-
|
40
|
-
-
|
41
|
-
- bin/
|
42
|
-
-
|
43
|
-
-
|
35
|
+
- lib/webdavtools/hpricot_extensions.rb
|
36
|
+
- lib/webdavtools/curl_commands.rb
|
37
|
+
- bin/wdav
|
38
|
+
- lib/webdavtools/wdav_ls.rb
|
39
|
+
- lib/webdavtools/wdav_pwd.rb
|
40
|
+
- lib/webdavtools/wdav_cd.rb
|
41
|
+
- lib/webdavtools/wdav_props.rb
|
44
42
|
- README.rdoc
|
45
43
|
has_rdoc: true
|
46
44
|
homepage: http://folk.uio.no/thomasfl
|
data/bin/wdput
DELETED