Skip to content

Instantly share code, notes, and snippets.

@thomasfl
Created January 10, 2012 14:43
Show Gist options
  • Select an option

  • Save thomasfl/1589407 to your computer and use it in GitHub Desktop.

Select an option

Save thomasfl/1589407 to your computer and use it in GitHub Desktop.
Vortex Hello World script
require 'rubygems'
require 'net/dav'
require 'json'
require 'highline/import'
webdav_url = 'https://vortex-systest-dav.uio.no'
dav = Net::DAV.new(webdav_url)
username = ask("Username: ")
password = ask("Password: ") {|q| q.echo = "*"}
dav.credentials(username, password)
article = {
"resourcetype" => "structured-article",
"properties" => {
"title" => "Hello world!",
"introduction" => "This is the introduction.",
"content" => "<p>And this is the main content.</p>"
}
}
dest_url = '/test/hello-world.html'
dav.put_string(dest_url, article.to_json)
dav.proppatch(dest_url, '<v:publish-date xmlns:v="vrtx">' + Time.now.httpdate.to_s + '</v:publish-date>')
puts "Published to " + webdav_url.sub('-dav','') + dest_url
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment