Skip to content

Instantly share code, notes, and snippets.

@stuartf
Created August 18, 2011 16:39
Show Gist options
  • Save stuartf/1154485 to your computer and use it in GitHub Desktop.
Save stuartf/1154485 to your computer and use it in GitHub Desktop.
runtime widget config
def enableInPortal(path, server)
json = ""
c = Curl::Easy.new("#{server}/#{path}")
if c.http_get
json = JSON.parse(c.body_str)
json["personalportal"] = true
postJsonAsFile(path, json.to_s(), server)
end
end
def enableInSakaiDoc(path, server)
json = ""
c = Curl::Easy.new("#{server}/#{path}")
if c.http_get
json = JSON.parse(c.body_str)
json["sakaidocs"] = true
postJsonAsFile(path, json.to_s(), server)
end
end
def postJsonAsFile(path, json, server)
filename = File.basename(path)
c = Curl::Easy.new("#{server}/#{File.dirname(path)}")
c.multipart_form_post = true
json_field = Curl::PostField.content(filename, json)
json_field.remote_file = filename
json_field.content_type = "text/plain"
typehint_field = Curl::PostField.content("#{filename}@TypeHint", "nt:file")
c.http_auth_types = :basic
c.username = "admin"
c.password = "admin"
c.http_post(json_field, typehint_field)
puts c.body_str
puts json
end
desc "Enable Hybrid Widgets"
task :enable_hybrid do
enableInPortal("devwidgets/mysakai2/config.json", "http://localhost:#{nakamura["port"]}")
enableInSakaiDoc("devwidgets/basiclti/config.json", "http://localhost:#{nakamura["port"]}")
enableInSakaiDoc("devwidgets/sakai2tools/config.json", "http://localhost:#{nakamura["port"]}")
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment