vortex_client 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/vortex_client.rb +41 -9
- data/test/test_vortex_collection.rb +29 -0
- data/test/test_vortex_tags.rb +29 -0
- metadata +7 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.3.0
|
data/lib/vortex_client.rb
CHANGED
@@ -41,10 +41,9 @@ module Vortex
|
|
41
41
|
#
|
42
42
|
# vortex.exists?("https://www-dav.server.com/folder/index.html")
|
43
43
|
def exists?(uri)
|
44
|
-
|
45
|
-
@uri = URI.parse(@uri) if @uri.is_a? String
|
44
|
+
uri = URI.parse(uri) if uri.is_a? String
|
46
45
|
begin
|
47
|
-
self.propfind(
|
46
|
+
self.propfind(uri.path)
|
48
47
|
rescue Net::HTTPServerException => e
|
49
48
|
return false if(e.to_s =~ /404/)
|
50
49
|
end
|
@@ -74,6 +73,22 @@ module Vortex
|
|
74
73
|
end
|
75
74
|
end
|
76
75
|
|
76
|
+
# Creates collections
|
77
|
+
#
|
78
|
+
# Example:
|
79
|
+
#
|
80
|
+
# connection = Connection.new('https://host.com')
|
81
|
+
# collecion = ArticleListingCollection.new(:url => '/url')
|
82
|
+
# connection.create(collection)
|
83
|
+
def create(object)
|
84
|
+
if(object.is_a? ArticleListingCollection)
|
85
|
+
uri = @uri.merge(object.url)
|
86
|
+
self.mkdir(uri)
|
87
|
+
self.proppatch(uri, object.properties)
|
88
|
+
return uri.to_s
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
77
92
|
private
|
78
93
|
|
79
94
|
# Disable Net::DAV.credentials
|
@@ -102,7 +117,7 @@ module Vortex
|
|
102
117
|
# vortex.publish(article)
|
103
118
|
class HtmlArticle < PlainFile
|
104
119
|
|
105
|
-
attr_accessor :title, :introduction, :body, :filename, :modifiedDate, :publishedDate, :owner, :url, :author, :date
|
120
|
+
attr_accessor :title, :introduction, :body, :filename, :modifiedDate, :publishedDate, :owner, :url, :author, :date, :tags
|
106
121
|
|
107
122
|
# Create a new article of type html-article: plain html file with introduction stored as a webdav property.
|
108
123
|
def initialize(options={})
|
@@ -161,6 +176,16 @@ module Vortex
|
|
161
176
|
'</vrtx:values>' +
|
162
177
|
'</v:authors>'
|
163
178
|
end
|
179
|
+
|
180
|
+
if(tags and tags.kind_of?(Array))
|
181
|
+
props += '<v:tags xmlns:v="vrtx">' +
|
182
|
+
'<vrtx:values xmlns:vrtx="http://vortikal.org/xml-value-list">'
|
183
|
+
tags.each do |tag|
|
184
|
+
props += "<vrtx:value>#{tag}</vrtx:value>"
|
185
|
+
end
|
186
|
+
props += '</vrtx:values></v:tags>'
|
187
|
+
end
|
188
|
+
|
164
189
|
return props
|
165
190
|
end
|
166
191
|
|
@@ -216,11 +241,18 @@ module Vortex
|
|
216
241
|
end
|
217
242
|
|
218
243
|
def properties()
|
219
|
-
"<v:resourceType xmlns:v=\"vrtx\">article-listing</v:resourceType>" +
|
220
|
-
"<v:collection-type xmlns:v=\"vrtx\">article-listing</v:collection-type>"
|
221
|
-
|
222
|
-
"<v:
|
223
|
-
|
244
|
+
props = "<v:resourceType xmlns:v=\"vrtx\">article-listing</v:resourceType>" +
|
245
|
+
"<v:collection-type xmlns:v=\"vrtx\">article-listing</v:collection-type>"
|
246
|
+
if(title and title != "")
|
247
|
+
props += "<v:userTitle xmlns:v=\"vrtx\">#{title}</v:userTitle>"
|
248
|
+
end
|
249
|
+
if(navigationTitle and navigationTitle != "")
|
250
|
+
props += "<v:navigationTitle xmlns:v=\"vrtx\">#{navigationTitle}</v:navigationTitle>"
|
251
|
+
end
|
252
|
+
if(owner and owner != "")
|
253
|
+
props += "<owner xmlns=\"vrtx\">#{owner}</owner>"
|
254
|
+
end
|
255
|
+
return props
|
224
256
|
end
|
225
257
|
|
226
258
|
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
require 'helper'
|
3
|
+
|
4
|
+
class TestVortexCollection < Test::Unit::TestCase
|
5
|
+
include Vortex
|
6
|
+
|
7
|
+
def setup
|
8
|
+
if(not(@vortex))
|
9
|
+
user = ENV['DAVUSER']
|
10
|
+
pass = ENV['DAVPASS']
|
11
|
+
@vortex = Vortex::Connection.new("https://vortex-dav.uio.no/",user, pass)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
should "create collection (folder)" do
|
16
|
+
url = 'https://vortex-dav.uio.no/brukere/thomasfl/nyheter/my-collection'
|
17
|
+
if(@vortex.exists?(url))
|
18
|
+
@vortex.delete(url)
|
19
|
+
end
|
20
|
+
|
21
|
+
@vortex.cd('/brukere/thomasfl/nyheter/')
|
22
|
+
collection = ArticleListingCollection.new(:url => 'my-collection', :title => 'My Collection')
|
23
|
+
created_path = @vortex.create(collection)
|
24
|
+
|
25
|
+
assert @vortex.exists?(created_path)
|
26
|
+
assert created_path == url
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
require 'helper'
|
3
|
+
|
4
|
+
class TestVortexTags < Test::Unit::TestCase
|
5
|
+
include Vortex
|
6
|
+
|
7
|
+
def setup
|
8
|
+
if(not(@vortex))
|
9
|
+
user = ENV['DAVUSER']
|
10
|
+
pass = ENV['DAVPASS']
|
11
|
+
@vortex = Vortex::Connection.new("https://vortex-dav.uio.no/",user, pass)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
should "publish articles with tags" do
|
16
|
+
url = 'https://vortex-dav.uio.no/brukere/thomasfl/nyheter/my-sample-title.html'
|
17
|
+
if(@vortex.exists?(url))
|
18
|
+
@vortex.delete(url)
|
19
|
+
end
|
20
|
+
|
21
|
+
@vortex.cd('/brukere/thomasfl/nyheter/')
|
22
|
+
article = Vortex::HtmlArticle.new(:title => "My Sample Title", :introduction => "Introduction",
|
23
|
+
:body => "<p>Hello world</p>", :tags => ['tag 1','tag 2','tag 3'])
|
24
|
+
published_url = @vortex.publish(article)
|
25
|
+
assert @vortex.exists?(published_url)
|
26
|
+
assert published_url == url
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vortex_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
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: 2010-01-
|
12
|
+
date: 2010-01-08 00:00:00 +01:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -61,7 +61,10 @@ files:
|
|
61
61
|
- lib/vortex_client.rb
|
62
62
|
- lib/vortex_client/string_utils.rb
|
63
63
|
- test/helper.rb
|
64
|
+
- test/test_vortex_article_publish.rb
|
64
65
|
- test/test_vortex_client.rb
|
66
|
+
- test/test_vortex_collection.rb
|
67
|
+
- test/test_vortex_tags.rb
|
65
68
|
- test/test_vortex_utils.rb
|
66
69
|
has_rdoc: true
|
67
70
|
homepage: http://github.com/thomasfl/vortex_client
|
@@ -95,4 +98,6 @@ test_files:
|
|
95
98
|
- test/helper.rb
|
96
99
|
- test/test_vortex_article_publish.rb
|
97
100
|
- test/test_vortex_client.rb
|
101
|
+
- test/test_vortex_collection.rb
|
102
|
+
- test/test_vortex_tags.rb
|
98
103
|
- test/test_vortex_utils.rb
|