For an application integration, I need to provide one of the input field in a hidden field if the form submitted by the button in the view.html file, so that value can be in the HTTP request. Despite having followed the documentation from the jupyter example here Connection Parameters conn_params — Open OnDemand 4.0.0 documentation the value of the ruby working_folder variable is always empty.
Here is the before.sh.erb file
<%
# Set our working directory.
folder = Pathname.new(context.working_dir)
if ! folder.exist?
folder = Pathname.new(ENV['HOME'])
elsif folder.file?
folder = folder.parent
end
%>
# Export the module function if it exists
[[ $(type -t module) == "function" ]] && export -f module
# Find available port to run server on
export port=$(find_port ${host})
# Export compute node the script is running on
export host="${host}"
# Generate SHA1 encrypted password (requires OpenSSL installed)
export password="$(create_passwd 16)"
export working_folder="<%= folder %>"
Here is the view.html.erb file
<%-
require 'digest'
folder = "#{working_folder}"
# Generate form id, based on host and port
form_id = Digest::SHA1.hexdigest("--" + host.to_s + "--" + port.to_s + "--")
base_url = "/rnode/#{host}/#{port}/"
%>
<form id="<%= form_id %>" action="<%= base_url %>" method="get" target="_blank">
<input type="hidden" name="tkn" value="<%= password %>">
<input type="hidden" name="folder" value="<%= folder %>">
<button class="btn btn-primary" type="submit">
<i class="fa fa-cogs"></i> Connect to VS Code
</button>
</form>
Strangely the password is correctly set.
Any idea on how to solve this ?
Thank you
Xavier