lib/mud.rb
def render_options(classname, *a)
		accept = env['rack-accept.request']

		if !classname.is_a?(Class)
			classname = GreyGoo.collection_to_class(classname)
		end
		options = get_options_for(classname, *a)

		# If in the root, also get options for the resource
		unless a.empty?
			request.path.match(%r{^/(\w+)$}) do |thing|
				options += get_options_for(GreyGoo.collection_to_class(thing[1]))
			end
		end

		options_json = JSON.pretty_generate(options)
		out = ""
		unless options.empty? 
			if accept.media_type?('text/html')
				form_html = form_from_options(options)
				unless form_html.empty?
					out += "<br><h1>Forms</h1>#{form_html}"
				end
				out += "<br><h1>Options</h1><pre>#{linkify(options_json)}</pre>"
			else
				content_type('application/json')
				out = options_json
			end
		end
		return out
	end
# Generate HTML from the options if in a browser, otherwise return json
Generate HTML from the options if in a browser, otherwise return json
Generate HTML from the options if in a browser otherwise return json
def render_options(classname, *a)
		accept = env['rack-accept.request']
		if !classname.is_a?(Class)
			classname = GreyGoo.collection_to_class(classname)
		end
		options = get_options_for(classname, *a)
		unless a.empty?
			request.path.match(%r{^/(\w+)$}) do |thing|
				options += get_options_for(GreyGoo.collection_to_class(thing[1]))
			end
		end
		options_json = JSON.pretty_generate(options)
		out = ""
		unless options.empty? 
			if accept.media_type?('text/html')
				form_html = form_from_options(options)
				unless form_html.empty?
					out += "<br><h1>Forms</h1>#{form_html}"
				end
				out += "<br><h1>Options</h1><pre>#{linkify(options_json)}</pre>"
			else
				content_type('application/json')
				out = options_json
			end
		end
		return out
	end
def render_options ( classname , * a ) accept = env [ 'rack-accept.request' ] if ! classname . is_a? ( Class ) classname = GreyGoo . collection_to_class ( classname ) end options = get_options_for ( classname , * a ) unless a . empty? request . path . match ( %r{ ^/( \w +)$ } ) do | thing | options += get_options_for ( GreyGoo . collection_to_class ( thing [ 1 ] ) ) end end options_json = JSON . pretty_generate ( options ) out = "" unless options . empty? if accept . media_type? ( 'text/html' ) form_html = form_from_options ( options ) unless form_html . empty? out += "<br><h1>Forms</h1>#{form_html}" end out += "<br><h1>Options</h1><pre>#{linkify(options_json)}</pre>" else content_type ( 'application/json' ) out = options_json end end return out end
Generate HTML from the options if in a browser, otherwise return json
Generate HTML from the options if in a browser otherwise return json
# If in the root, also get options for the resource
classname
a