cpack_repository/commit

Add new home-page

authorJan Wielemaker
Mon Nov 22 11:05:10 2010 +0100
committerJan Wielemaker
Mon Nov 22 11:05:10 2010 +0100
commit8ff94f0cdeee341ec4d5085af451a2ad95cded37
treefb8b053df1ddc407bbc9bd9557f3281f8da638cc
parent471753cff96c6e9cfd07fe9bb390e5d41a1a4286
Diff style: patch stat
diff --git a/applications/cpack_home.pl b/applications/cpack_home.pl
new file mode 100644
index 0000000..bdcf66c
--- /dev/null
+++ b/applications/cpack_home.pl
@@ -0,0 +1,47 @@
+/*  Part of ClioPatria SeRQL and SPARQL server
+
+    Author:        Jan Wielemaker
+    E-mail:        J.Wielemaker@cs.vu.nl
+    WWW:           http://www.swi-prolog.org
+    Copyright (C): 2010, University of Amsterdam,
+		   VU University Amsterdam
+
+    This program is free software; you can redistribute it and/or
+    modify it under the terms of the GNU General Public License
+    as published by the Free Software Foundation; either version 2
+    of the License, or (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public
+    License along with this library; if not, write to the Free Software
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    As a special exception, if you link this library with other files,
+    compiled with a Free Software compiler, to produce an executable, this
+    library does not by itself cause the resulting executable to be covered
+    by the GNU General Public License. This exception does not however
+    invalidate any other reasons why the executable file might be covered by
+    the GNU General Public License.
+*/
+
+:- module(cpack_home, []).
+:- include(bundle(html_page)).
+:- use_module(components(cpack)).
+
+:- http_handler(root(home), cpack_home, [id(home), priority(10)]).
+
+%%	cpack_home(+Request)
+%
+%	HTTP handler that provides the CPACK welcome page
+
+cpack_home(_Request) :-
+	reply_html_page(cliopatria(cpack),
+			title('CPACK: The ClioPatria Package Manager'),
+			div(class(cpack),
+			    [ \insert_html_file(html('cpack_home.html')),
+			      \package_table([])
+			    ])).
diff --git a/applications/cpack_submit.pl b/applications/cpack_submit.pl
index 76578de..99057ae 100644
--- a/applications/cpack_submit.pl
+++ b/applications/cpack_submit.pl
@@ -161,24 +161,15 @@ cpack_my_packages(_Request) :-
 	list_packages([user(UserURI), update_all_link(true)]).
 
 list_packages(Options) :-
-	findall(Package, current_package(Package, Options), Packages),
 	reply_html_page(cliopatria(cpack),
 			title('CPACK packages'),
 			[ div(class(cpack),
 			      [ h1('CPACK packages'),
-				\package_table(Packages, []),
+				\package_table(Options),
 				\update_all_link(Options)
 			      ])
 			]).
 
-current_package(Package, Options) :-
-	(   option(user(User), Options)
-	->  rdf_has(Package, cpack:submittedBy, User)
-	;   true
-	),
-	rdfs_individual_of(Package, cpack:'Package').
-
-
 update_all_link(Options) -->
 	{ option(update_all_link(true), Options),
 	  http_link_to_id(cpack_update_my_packages, [], HREF)
diff --git a/components/cpack.pl b/components/cpack.pl
index 7cdb7e6..ecec5ad 100644
--- a/components/cpack.pl
+++ b/components/cpack.pl
@@ -29,7 +29,7 @@
 */
 
 :- module(c_cpack,
-	  [ package_table//2,		% +Packages, +Options
+	  [ package_table//1,		% +Options
 	    cpack//2,			% +Pack, +Options
 	    cpack_status_icon//1,	% +Pack
 	    cpack_link//1,		% +Resource
@@ -72,12 +72,14 @@ cliopatria:list_resource(Pack) -->
 	cpack_file(Pack, []).
 
 
-%%	package_table(Packages, Options)// is det.
+%%	package_table(Options)// is det.
 %
 %	Emit a table that describes Packages.   Options is currently not
 %	used.
 
-package_table(Packages, Options) -->
+package_table(Options) -->
+	{ findall(Package, current_package(Package, Options), Packages)
+	},
 	html_requires(css('cpack.css')),
 	html(table(class(block),
 		   [ tr([ th('OK?'),
@@ -89,6 +91,14 @@ package_table(Packages, Options) -->
 		   | \package_rows(Packages, 1, Options)
 		   ])).
 
+current_package(Package, Options) :-
+	(   option(user(User), Options)
+	->  rdf_has(Package, cpack:submittedBy, User)
+	;   true
+	),
+	rdfs_individual_of(Package, cpack:'Package').
+
+
 package_rows([], _, []) --> [].
 package_rows([H|T], Row, Options) -->
 	odd_even_row(Row, Next, \package_row(H, Options)),
diff --git a/config-available/cpack_repository.pl b/config-available/cpack_repository.pl
index f22aa50..a9aeb7d 100644
--- a/config-available/cpack_repository.pl
+++ b/config-available/cpack_repository.pl
@@ -1,6 +1,7 @@
 :- module(conf_cpack_repository, []).
 :- use_module(config_available(foaf)).
 :- use_module(cpack_repository(applications/cpack_submit)).
+:- use_module(cpack_repository(applications/cpack_home)).
 :- use_module(library(http/http_path)).
 :- use_module(user(user_db)).
 :- use_module(cliopatria(hooks)).
diff --git a/web/html/cpack_home.html b/web/html/cpack_home.html
new file mode 100644
index 0000000..2f2f1eb
--- /dev/null
+++ b/web/html/cpack_home.html
@@ -0,0 +1,36 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
+
+<html>
+  <head>
+    <title>CPACK: The ClioPatria package manager</title>
+  </head>
+<body>
+<h1>CPACK: The ClioPatria package manager</h1>
+
+<p>
+Welcome to CPACK, the ClioPatria package manager. CPACK is a repository
+to which packages can be uploaded. The server performs cross-reference
+analysis to determine the dependencies between packages and validates
+that all predicate and file requirements of the package are fullfilled,
+either by Prolog, ClioPatria or some other package.
+
+<ul>
+  <li>
+How to I <a href="/help/cpack/Installing.html">install</a> a package?
+  <li>
+How to I <a href="/help/cpack/Creating.html">create</a> a package?
+  <li>
+To <a href="/help/cpack/Submitting.html">submit</a> a package, you need
+a login. In due time we will allow anyone to create a login. For now,
+mail <a href="mailto:J.Wielemaker@cs.vu.nl">Jan Wielemaker</a> to
+request for a login. Please specify your desired login name, and real
+name.
+  <li>
+<a href="/help/cpack/Status.html">Status and plans</a> with CPACK.
+</ul>
+
+<p>
+Below is the list of available packages.  We will provide additional
+search facilities later.
+</body>
+</html>