Skip to content

Instantly share code, notes, and snippets.

@thomasfl
Created January 10, 2012 15:11
Show Gist options
  • Select an option

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

Select an option

Save thomasfl/1589523 to your computer and use it in GitHub Desktop.
Hello World in Vortex on OSX
require 'rubygems'
require 'net/dav'
require 'json'
require 'highline/import'
require 'osx_keychain'
dav = Net::DAV.new('https://vortex-systest-dav.uio.no')
keychain = OSXKeychain.new
username = ENV['USER']
password = keychain['vortex-systest-dav.uio.no', username ]
if(!password)
password = ask("Password for '#{username}: ") {|q| q.echo = "*"}
end
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'
begin
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>')
published = true
rescue
published = false
end
if(published)
keychain['vortex-systest-dav.uio.no', username ] = password
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment