Created
August 18, 2011 16:39
-
-
Save stuartf/1154485 to your computer and use it in GitHub Desktop.
runtime widget config
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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