cpack_repository/commit

Provide a resubmit facility when viewing a pack

authorJan Wielemaker
Thu Nov 18 15:01:50 2010 +0100
committerJan Wielemaker
Thu Nov 18 15:01:50 2010 +0100
commit9f4d200d346329b2389ddd2dbc9bb25235240539
tree62e3b8cc8ad75b424218f4eeb77d8ee92294e6b6
parent6314c6f70bd22a8041d779ba209f8384399306b6
Diff style: patch stat
diff --git a/applications/cpack_submit.pl b/applications/cpack_submit.pl
index e70773f..de513e7 100644
--- a/applications/cpack_submit.pl
+++ b/applications/cpack_submit.pl
@@ -50,6 +50,7 @@ http:location(cpack_api,  api(cpack),  []).
 :- http_handler(cpack(my_packages),	   cpack_my_packages,	     []).
 :- http_handler(cpack(update_my_packages), cpack_update_my_packages, []).
 :- http_handler(cpack_api(submit),	   cpack_submit,	     []).
+:- http_handler(cpack_api(resubmit),	   cpack_resubmit,	     []).
 :- http_handler(cpack(show_file),	   cpack_show_file,	     []).
 :- http_handler(cpack(git_show),	   git_show,	             []).
 
@@ -107,6 +108,34 @@ cpack_submit(Request) :-
 			      []).
 
 
+%%	cpack_resubmit(+Request)
+%
+%	Resubmit an already submitted package: run   a =|git pull|= from
+%	the cloned repository and recompute the  meta-data. This is very
+%	similar to cpack_submit/1, but the information is extracted from
+%	the existing package resource.
+
+cpack_resubmit(Request) :-
+	logged_on(User),
+	http_parameters(Request,
+			[ pack(Pack,
+			       [ description('URI of the CPACK to update')
+			       ])
+			]),
+	rdf_has(Pack, cpack:clonedRepository, GitRepo),
+	rdf_has(GitRepo, cpack:gitURL, GitURL),
+	(   rdf_has(GitRepo, cpack:branch, literal(Branch))
+	->  true
+	;   Branch = master
+	),
+	authorized(write(cpack, GitURL)),
+	user_property(User, url(UserURL)),
+	call_showing_messages(cpack_add_repository(UserURL, GitURL,
+						   [ branch(Branch)
+						   ]),
+			      []).
+
+
 %%	cpack_list_packages(+Request) is det.
 %%	cpack_my_packages(+Request) is det.
 %
diff --git a/components/cpack.pl b/components/cpack.pl
index 3feb690..aa59da4 100644
--- a/components/cpack.pl
+++ b/components/cpack.pl
@@ -36,6 +36,7 @@
 	    commit_info//3		% +Record, +Body, +Options
 	  ]).
 :- include(bundle(html_page)).
+:- use_module(user(user_db)).
 :- use_module(library(http/http_path)).
 :- use_module(library(http/dcg_basics)).
 :- use_module(library(cpack/repository)).
@@ -87,7 +88,9 @@ cpack(Pack, _Options) -->
 		 [ h2([ 'Package "', Name, '" -- ',
 			\cpack_prop(Pack, dcterms:title),
 			span([class(status), style('float:right')],
-			     \cpack_status_icon(Pack, Problems))
+			     [ \cpack_update_icon(Pack),
+			       \cpack_status_icon(Pack, Problems)
+			     ])
 		      ]),
 		   table(class(infobox),
 			 [ \p_row(Pack, rdf:type),
@@ -402,7 +405,25 @@ package_problem(Pack, conflict(Pack2, Why)) :-
 package_problem(Pack, not_satified(What)) :-
 	cpack_not_satisfied(Pack, What).
 
-
+%%	cpack_update_icon(+Pack)//
+%
+%	Show an icon to update  the  Pack   if  the  current user is the
+%	submitter.
+
+cpack_update_icon(Pack) -->
+	{ logged_on(User),
+	  user_property(User, url(UserURI)),
+	  rdf_has(Pack, cpack:submittedBy, UserURI),
+	  http_absolute_location(icons('webdev-arrow-up-icon.png'), IMG, []),
+	  http_link_to_id(cpack_resubmit, [pack(Pack)], Resubmit)
+	},
+	html(a(href(Resubmit),
+	       img([ class(update),
+		     alt('Update'),
+		     title('Pull a new version'),
+		     src(IMG)
+		   ]))).
+cpack_update_icon(_) --> [].
 
 
 		 /*******************************
diff --git a/rdf/cpack/cpack_repository.ttl b/rdf/cpack/cpack_repository.ttl
index a4b57a0..d4a5f1e 100644
--- a/rdf/cpack/cpack_repository.ttl
+++ b/rdf/cpack/cpack_repository.ttl
@@ -6,7 +6,9 @@
 <> a cpack:Application ;
 	cpack:packageName "cpack_repository" ;
 	dcterms:title "CPACK package repository manager" ;
-	cpack:author <http://www.swi-prolog.org/cliopatria/user/jan> ;
+	cpack:author [ foaf:name "Jan Wielemaker" ;
+		       foaf:mbox "J.Wielemaker@cs.vu.nl" ;
+		     ] ;
 	cpack:primaryRepository
 	    [ a cpack:GitRepository ;
 	      cpack:gitURL <git://eculture.cs.vu.nl/home/janw/git/ClioPatria/foaf_user.git>
diff --git a/web/css/cpack.css b/web/css/cpack.css
index 2c5b3f3..30f7096 100644
--- a/web/css/cpack.css
+++ b/web/css/cpack.css
@@ -28,6 +28,14 @@ div.cpack h2 span.status
   margin-top: -0.3em;
 }
 
+div.cpack a img
+{ border: 0px;
+}
+
+div.cpack a img:hover
+{ border: 1px outset;
+}
+
 div.cpack table.infobox
 { font-size: 80%;
   float: right;