:- ensure_loaded(common).
cvs_id('$Id: hosting.pl,v 1.4 2004/10/21 18:50:04 sandro Exp $').
/*


  
*/

/*


  
% :- ensure_loaded(library('http/http_client')).
:- ensure_loaded(my_http_client).
%%%%%%%%%%  trouble with my* :- ensure_loaded(library('http/http_mime_plugin')).
% submitted_sources_filename('submitted_sources.pl').

% redo as   /hosting?op=new...
% and assemble a function name out of it
hosting_reply(Request, ReqId) :-
	member(path('/hosting_new'), Request),
	write_page(ReqId, hosting_new_body, '').
hosting_reply(Request, ReqId) :-
	member(path('/hosting_new_post'), Request),
	member(method(post), Request),
	hosting_new_post(Request, ReqId).
hosting_reply(Request, ReqId) :-
	member(path('/hosting_update_1'), Request),
	write_page(ReqId, hosting_update_body, '').
hosting_reply(Request, _ReqId) :-
	member(path('/hosting_update_1_post'), Request),
	member(method(post), Request),
	host_update_post(Request).
hosting_reply(Request, ReqId) :-
	member(path('/hosting_update_2'), Request),
	write_page(ReqId, hosting_update_body, '').
hosting_reply(Request, _ReqId) :-
	member(path('/hosting_update_2_post'), Request),
	member(method(post), Request),
	host_update_post(Request).

hosting_new_post(Req, ReqId) :-
	format(user_error, '~q', [Req]),
	http_read_data(Req, Data, []),
	format(user_error, 'DATA: ~q', [Data]),
	(   member(uploaded=UploadedData, Data),
	    UploadedData \= ''
	->  (   member(baseURI=BaseURI, Data),
		BaseURI \= ''
	    ->  true
	    ;   BaseURI = 'http://www.w3.org/2004/07/missing-base-uri/'
	    ),
	    new_upload(Req, UploadedData, BaseURI, Upload),
	    write_page(ReqId, +acknowledge_upload(Upload), '')
	;   write_page(ReqId, ['No data uploaded; go BACK and try again.'], '')
	).
	

acknowledge_upload(Upload, H) :-
	H=p('Data uploaded; metadata at ', Upload, ' @@ what now?').

hosting_new_body(H) :-
	H=[

	   h2('Contribute an Ontology'),

	   p('Use this form to contribute an ontology to the ', a(href='http://www.w3.org/2004/07/ontology-hosting', 'W3C Ontology Hosting Program'), '.'),

	   +hosted_disclaimer,
	   form(action='hosting_new_post', enctype='multipart/form-data',
		method='post',
		%+hosted_metadata,
		%+hosted_contributor,
		%+hosted_license,
		+hosted_upload
		%+hosted_pick_ssss,
		%+hosted_submit_new
	       )
	].

hosted_disclaimer(div(class=formBlock, H)) :-
	H=[
	   h2('Disclaimer!'),
	   p('This is a prototype.   The "Hosting Program" described here does ', strong('not yet exist'), ' and may never exist.  It is just an idea we are playing with.')
	  ].


hosted_submit_new(div(class=formBlock, H)) :-
	H=[
	   h2('Proceed'),
	   p('Select "SUBMIT" to begin uploading and machine-checking the ontology.   This is@@? the final step.'),
	   input(type=submit, value='Submit')
	  ].
	   
hosted_metadata(div(class=formBlock, H)) :-
	H=[
	   h2('About the Ontology'),
	   p('@@ this stuff could/should all come out of the ontology itself'),
	   p('Title: ', input(type=text, name=title, size='80')),
	   p('Description (100-300 characters, please):'),
	   textarea(name=description, rows='5', cols='80'),
	   p('Related dmoz categories'),
	   p('Related NAICS Industry Code(s)'),
	   p('Related UNSPSC Product/Service Code(s)'),
	   p('keywords'),
	   p('single/compound')
	   ].

hosted_contributor(div(class=formBlock, H)) :-
	H=[
	   h2('About the Contributor'),
	   p('you or some org?')
	  ].

hosted_license(div(class=formBlock, H)) :-
	H=[
	   h2('Confirm License'),

	   p('Please confirm your authority and intent to publish under our Open Source licenses.'),

	   table(class=optionRow,
		 tr(td(valign=top, input(type=radio, name=license, value=granted)),
		    td(span('I have the legal authority to contribute this document,   under the terms of the ', a(href='http://www.w3.org/2004/07/ontology-hosting/#aup', 'Policy'), ', and I do so now.  I understand that I am placing this document under the ', a(href='http://www.w3.org/Consortium/Legal/2002/copyright-documents-20021231', 'W3C Document License'), ' and the ', a(href='http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231', 'W3C Software License'), '.'),
		       
		    p('This is an irrevocable act.  After being published under these licenses, the document may be copied, modified, and published by other people without further permission.   See FAQ: ', +helplink([], 'license', 'Why these license terms?'))
		      ))),
	   table(class=optionRow,
		 tr(td(valign=top, input(type=radio, name=license, value=already)),
		    td('This document has already been published under these licenses, under compatable (broader) licenses, or is in the public domain.  No additional grant of license needs to be made.'))
		),

	  table(class=optionRow,
		 tr(td(valign=top, input(type=radio, name=license, value=already, checked=yes)),
		    td('Do not publish yet.   Just testing.'))
		)


	  ].

hosted_upload(div(class=formBlock, H)) :-
	H=[
	   h2('Step 1.  Select File For Upload'),
	   p('Where is the ontology (in RDF/XML format) on your local system?'),
	   % p('@@TODO: A unix "tar" file may be used to upload a compound (multi-file) ontology'),
	   input(type=file, size='80', name=uploaded),
	   %p('Base URI (if needed).   Some RDF/XML is written with relative URIs and no xml:base, expecting to be served from a particular web address.  If this ontology is in that form, you will need to provide that expected web address here.'),
	   %input(type=text, size='80', name=baseURI),
	   %p('Select "SUBMIT" to begin uploading and machine-checking the ontology.   This is@@? the final step.'),
	   p('After the file is uploaded, you will be asked to review the ontology metadata and confirm the document license before the contribution is official made.'),
	   input(type=submit, value='Upload and Proceed to Step 2.')

	  ].

hosted_pick_ssss(div(class=formBlock, H)) :-
	H=[
	   h2('Naming'),
	   p('Please pick a short name for this ontology.  It ', strong(may), ' be used as part of the URL, so it should consist of only URI characters.     @@@more explanation would be good.'),
	  input(type=text, name=shortname)
	  ].



/*

  	   form(method='post', action='hosting',
	     p('URI: '),
	     input(name=uri, size='72', type=text, value='http://'),
	     p('Your e-mail address (optional, kept private) in case we would like to contact you about your site:'),
	     input(name=email, size='72', type=text),
	     input(type=hosting, value='Hosting')
	    ),
	p('Question, comments, problem: send email to ', a(href='mailto:sandro@w3.org?cc=www-archive@w3.org?subject=Ontaria', 'sandro@w3.org CC: www-archive@w3.org'), '.')

  

do_hosting(Request) :-
	http_read_data(Request, Data, []),
	Data = [uri=URI, email=EMail],
	hostingted_sources_filename(Filename),
	open(Filename, append, File, [lock(write)]),
	get_time(Time),
	set_prolog_flag(float_format, '%.12g'),
	format(File, '~q.~n', [hostingted_source(URI, EMail, Time)]),
	close(File),
	hosting_done(Request).

hosting_done(ReqId) :-
	write_page(ReqId, hosting_done_body, '').

hosting_done_body(H) :-
	H = [
		h1(class='semWalkerTitle2', 'Add A Data Source'),
		p('Added.'),
		p('Depending on various factors, the site may be harvested within a few seconds, or it might take a few days.'),
		p('Return to ', a(href=".", 'front page'), '.')
		].

hosting(ReqId) :-
	write_page(ReqId, hosting_done_body, '').

hosting_body(H) :-
	H = [
		h1(class='semWalkerTitle2', 'Add A Data Source'),
		a(href="help", help),
		p('Use this form to request that some web data source be always included.   To remove a source, use a robots.txt file'),
		form(method='post', action='hosting',
		     p('URI: '),
		     input(name=uri, size='72', type=text, value='http://'),
		     p('Your e-mail address (optional, kept private) in case we would like to contact you about your site:'),
		     input(name=email, size='72', type=text),
		     input(type=hosting, value='Hosting')
		    ),
		p('Question, comments, problem: send email to ', a(href='mailto:sandro@w3.org?cc=www-archive@w3.org?subject=Ontaria', 'sandro@w3.org CC: www-archive@w3.org'), '.')
		].

*/


*/