[Fusionforge-commits] r16127 - in trunk/src: debian plugins plugins/admssw plugins/admssw/common plugins/admssw/etc plugins/admssw/include plugins/admssw/packaging plugins/admssw/packaging/control plugins/admssw/packaging/dirs plugins/admssw/packaging/docs plugins/admssw/packaging/install

Olivier Berger olberger at fusionforge.org
Tue Aug 21 18:20:57 CEST 2012


Author: olberger
Date: 2012-08-21 18:20:56 +0200 (Tue, 21 Aug 2012)
New Revision: 16127

Added:
   trunk/src/plugins/admssw/
   trunk/src/plugins/admssw/NAME
   trunk/src/plugins/admssw/README
   trunk/src/plugins/admssw/common/
   trunk/src/plugins/admssw/common/admssw-init.php
   trunk/src/plugins/admssw/etc/
   trunk/src/plugins/admssw/etc/admssw.ini
   trunk/src/plugins/admssw/include/
   trunk/src/plugins/admssw/include/admsswPlugin.class.php
   trunk/src/plugins/admssw/packaging/
   trunk/src/plugins/admssw/packaging/control/
   trunk/src/plugins/admssw/packaging/control/222plugin-admssw
   trunk/src/plugins/admssw/packaging/control/222plugin-admssw.shortdesc
   trunk/src/plugins/admssw/packaging/dirs/
   trunk/src/plugins/admssw/packaging/dirs/plugin-admssw
   trunk/src/plugins/admssw/packaging/docs/
   trunk/src/plugins/admssw/packaging/docs/plugin-admssw
   trunk/src/plugins/admssw/packaging/install/
   trunk/src/plugins/admssw/packaging/install/plugin-admssw
Modified:
   trunk/src/debian/control
Log:
Add 'admssw' plugin to render ADMS.SW 1.0 compatible RDF on /projects[/...]

Modified: trunk/src/debian/control
===================================================================
--- trunk/src/debian/control	2012-08-21 16:20:30 UTC (rev 16126)
+++ trunk/src/debian/control	2012-08-21 16:20:56 UTC (rev 16127)
@@ -277,6 +277,19 @@
  This package is only present for transitional purposes and can be
  safely removed.
 
+Package: fusionforge-plugin-admssw
+Architecture: all
+Depends: gforge-common, gforge-db-postgresql | gforge-db, gforge-web-apache2 | gforge-web, php-http, fusionforge-plugin-doaprdf, ${misc:Depends}
+Description: collaborative development tool - ADMS.SW plugin
+ FusionForge provides many tools to aid collaboration in a
+ development project, such as bug-tracking, task management,
+ mailing-lists, SCM repository, forums, support request helper,
+ web/FTP hosting, release management, etc. All these services are
+ integrated into one web site and managed through a web interface.
+ .
+ This plugin provides ADMS.SW additions to the DOAP RDF documents for projects on /projects URLs 
+ with content-negociation (application/rdf+xml).
+ 
 Package: fusionforge-plugin-authcas
 Architecture: all
 Depends: gforge-common, gforge-db-postgresql | gforge-db, gforge-web-apache2 | gforge-web, ${misc:Depends}

Added: trunk/src/plugins/admssw/NAME
===================================================================
--- trunk/src/plugins/admssw/NAME	                        (rev 0)
+++ trunk/src/plugins/admssw/NAME	2012-08-21 16:20:56 UTC (rev 16127)
@@ -0,0 +1 @@
+ADMS.SW RDF for projects description

Added: trunk/src/plugins/admssw/README
===================================================================
--- trunk/src/plugins/admssw/README	                        (rev 0)
+++ trunk/src/plugins/admssw/README	2012-08-21 16:20:56 UTC (rev 16127)
@@ -0,0 +1,11 @@
+ADMS.SW plugin
+
+This plugin will provide content-negociation means to export RDF+XML ADMS.SW profiles for projects on /projects URLs, in addition to the content already provided by doaprdf.
+
+ADMS.SW stands for Asset Description Metadata Schema for Software. See https://joinup.ec.europa.eu/asset/adms_foss/description for more details.
+
+For instance, one may try :
+ curl -k -H 'Accept: application/rdf+xml' https://myforge.example.com/projects/aproject/
+
+The doaprdf plugin has to be installed.
+

Added: trunk/src/plugins/admssw/common/admssw-init.php
===================================================================
--- trunk/src/plugins/admssw/common/admssw-init.php	                        (rev 0)
+++ trunk/src/plugins/admssw/common/admssw-init.php	2012-08-21 16:20:56 UTC (rev 16127)
@@ -0,0 +1,32 @@
+<?php
+
+/**
+ * This file is part of FusionForge. FusionForge 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 Licence, or (at your option)
+ * any later version.
+ *
+ * FusionForge 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 FusionForge; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+global $gfplugins;
+require_once $gfplugins.'admssw/include/admsswPlugin.class.php' ;
+
+$admsswPluginObject = new admsswPlugin ;
+
+register_plugin ($admsswPluginObject) ;
+
+// Local Variables:
+// mode: php
+// c-file-style: "bsd"
+// End:
+
+?>

Added: trunk/src/plugins/admssw/etc/admssw.ini
===================================================================
--- trunk/src/plugins/admssw/etc/admssw.ini	                        (rev 0)
+++ trunk/src/plugins/admssw/etc/admssw.ini	2012-08-21 16:20:56 UTC (rev 16127)
@@ -0,0 +1,7 @@
+[admssw]
+
+; plugin_status is a string.
+; valid means : production ready.
+; Any other strings means it's under work or broken and plugin
+; is available in installation_environment = development only.
+plugin_status = valid

Added: trunk/src/plugins/admssw/include/admsswPlugin.class.php
===================================================================
--- trunk/src/plugins/admssw/include/admsswPlugin.class.php	                        (rev 0)
+++ trunk/src/plugins/admssw/include/admsswPlugin.class.php	2012-08-21 16:20:56 UTC (rev 16127)
@@ -0,0 +1,220 @@
+<?php
+
+/**
+ * admsswPlugin Class
+ *
+ * Copyright 2012, Olivier Berger & Institut Mines-Telecom
+ *
+ * This file is part of FusionForge. FusionForge 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 Licence, or (at your option)
+ * any later version.
+ *
+ * FusionForge 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 FusionForge; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+
+//require_once('common/include/ProjectManager.class.php');
+//require_once('common/include/rdfutils.php');
+
+class admsswPlugin extends Plugin {
+	public function __construct($id=0) {
+		$this->Plugin($id) ;
+		$this->name = "admssw";
+		$this->text = "ADMS.SW"; // To show in the tabs, use...
+
+		$this->_addHook("project_rdf_metadata"); // will provide some RDF metadata for the project's DOAP profile to 'doaprdf' plugin		
+		$this->_addHook("alt_representations");
+		$this->_addHook("script_accepted_types");
+		$this->_addHook("content_negociated_projects_list");
+	}
+
+
+	/**
+	 * Declares itself as accepting RDF XML on /projects/...
+	 * @param unknown_type $params
+	 */
+	function project_rdf_metadata (&$params) {
+	
+		# TODO : create another resource
+		$group_id=$params['group'];
+	
+		$new_prefixes = array('admssw' => 'http://purl.org/adms/sw/',
+				'rad' => 'http://www.w3.org/ns/radion#',
+				'schema' => 'http://schema.org/');
+		foreach($new_prefixes as $s => $u)
+		{
+			if (! isset($params['prefixes'][$u])) {
+				$params['prefixes'][$u] = $s;
+			}
+		}
+			
+		$res = $params['in_Resource'];
+	
+		// we could save the type doap:Project in such case, as there's an equivalence, but not sure all consumers do reasoning
+		$types = array('doap:Project', 'admssw:SoftwareProject');
+		rdfutils_setPropToUri($res, 'rdf:type', $types);
+		
+		$tags_list = NULL;
+		if (forge_get_config('use_project_tags')) {
+			$group = group_get_object($group_id);
+			$tags_list = $group->getTags();
+		}
+		// connect to FusionForge internals
+		$pm = ProjectManager::instance();
+		$project = $pm->getProject($group_id);
+		
+		$tags = array();
+		if($tags_list) {
+			$tags = split(', ',$tags_list);
+			
+			// reuse the same as dcterms:subject until further specialization of adms.sw keywords
+			$res->setProp('rad:keyword', $tags);
+		}
+			
+		$project_description = $project->getDescription();
+		if($project_description) {
+				// it seems that doap:description is not equivalent to dcterms:description, so repeat
+				$res->setProp('dcterms:description', $project_description);
+			}
+				
+		$res->setProp('rdfs:comment', "Generated with the doaprdf and admssw plugins of fusionforge");
+
+		rdfutils_setPropToUri($res, 'dcterms:isPartOf', util_make_url ("/projects"));
+		
+		$admins = $project->getAdmins() ;
+		$members = $project->getUsers() ;
+		$contributors_uris = array();
+		
+		foreach ($admins as $u) {
+			$contributor_uri = util_make_url_u ($u->getUnixName(),$u->getID());
+			$contributor_uri = rtrim($contributor_uri, '/');
+			$contributor_uri = $contributor_uri . '#person';
+			if (! in_array($contributor_uri, $contributors_uris) ) {
+				$contributors_uris[] = $contributor_uri;
+			}
+		}
+		foreach ($members as $u) {
+			$contributor_uri = util_make_url_u ($u->getUnixName(),$u->getID());
+			$contributor_uri = rtrim($contributor_uri, '/');
+			$contributor_uri = $contributor_uri . '#person';
+			if (! in_array($contributor_uri, $contributors_uris) ) {
+				$contributors_uris[] = $contributor_uri;
+			}
+		}
+		rdfutils_setPropToUri($res, 'schema:contributor', $contributors_uris);
+		
+		$params['out_Resources'][] = $res;
+
+	}
+	
+	
+	/**
+	 * Declares a link to itself in the link+meta HTML headers
+	 * @param unknown_type $params
+	 */
+	function alt_representations (&$params) {
+		$script_name = $params['script_name'];
+		$php_self = $params['php_self'];
+		$php_self = rtrim($php_self, '/');
+		if ($php_self == '/projects') {
+			$params['return'][] = '<link rel="meta" type="application/rdf+xml" title="ADMS.SW RDF Data" href=""/>';
+		}
+	}
+	
+	
+	/**
+	 * Declares itself as accepting RDF XML on /projects ...
+	 * @param unknown_type $params
+	 */
+	function script_accepted_types (&$params) {
+		$script = $params['script'];
+		if ($script == 'projects_list') {
+			$params['accepted_types'][] = 'application/rdf+xml';
+		}
+	}
+	
+	/**
+	 * Outputs the public projects list as ADMS.SW for /projects
+	 * @param unknown_type $params
+	 */
+	function content_negociated_projects_list (&$params) {
+		
+		$accept = $params['accept'];
+			
+		if($accept == 'application/rdf+xml') {
+				
+				
+			// We will return RDF+XML
+			$params['content_type'] = 'application/rdf+xml';
+	
+			// Construct an ARC2_Resource containing the project's RDF (DOAP) description
+			$ns = array(
+					'rdf' => 'http://www.w3.org/1999/02/22-rdf-syntax-ns#',
+					'rdfs' => 'http://www.w3.org/2000/01/rdf-schema#',
+					'doap' => 'http://usefulinc.com/ns/doap#',
+					'dcterms' => 'http://purl.org/dc/terms/',
+					'admssw' => 'http://purl.org/adms/sw/',
+					'adms' => 'http://www.w3.org/ns/adms#'
+			);
+	
+			$conf = array(
+					'ns' => $ns
+			);
+				
+			$res = ARC2::getResource($conf);
+			$res->setURI( util_make_url ("/projects") );
+	
+			// $res->setRel('rdf:type', 'doap:Project');
+			rdfutils_setPropToUri($res, 'rdf:type', 'admssw:SoftwareRepository');
+				
+			//$res->setProp('doap:name', $projectname);
+			$res->setProp('adms:accessURL', util_make_url ("/softwaremap/") );
+			$forge_name = forge_get_config ('forge_name');
+			$ff = new FusionForge();
+			$res->setProp('dcterms:description', 'Public projects in the '. $ff->software_name .' Software Map on '. $forge_name );
+			$res->setProp('rdfs:label', $forge_name .' public projects');
+			$res->setProp('adms:supportedSchema', 'ADMS.SW v1.0');
+			
+			// same as for trove's full list
+			$projects = get_public_active_projects_asc();
+			$proj_uris = array();
+			foreach ($projects as $row_grp) {
+				$proj_uri = util_make_url_g(strtolower($row_grp['unix_group_name']),$row_grp['group_id']);
+				$proj_uris[] = $proj_uri;
+			}
+			if(count($proj_uris)) {
+				rdfutils_setPropToUri($res, 'dcterms:hasPart', $proj_uris);
+			}
+			
+			$conf = array(
+					'ns' => $ns,
+					'serializer_type_nodes' => true
+			);
+				
+			$ser = ARC2::getRDFXMLSerializer($conf);
+				
+			/* Serialize a resource index */
+			$doc = $ser->getSerializedIndex($res->index);
+	
+			$params['content'] = $doc . "\n";
+		
+		}
+	}
+	
+}
+
+// Local Variables:
+// mode: php
+// c-file-style: "bsd"
+// End:
+
+?>

Added: trunk/src/plugins/admssw/packaging/control/222plugin-admssw
===================================================================
--- trunk/src/plugins/admssw/packaging/control/222plugin-admssw	                        (rev 0)
+++ trunk/src/plugins/admssw/packaging/control/222plugin-admssw	2012-08-21 16:20:56 UTC (rev 16127)
@@ -0,0 +1,4 @@
+Package: @PACKAGE at -plugin-admssw
+Architecture: all
+Depends: @OLDPACKAGE at -common, @OLDPACKAGE at -db-postgresql | @OLDPACKAGE at -db, @OLDPACKAGE at -web-apache2 | @OLDPACKAGE at -web, php-http, @PACKAGE at -plugin-doaprdf, ${misc:Depends}
+Description: collaborative development tool - ADMS.SW plugin

Added: trunk/src/plugins/admssw/packaging/control/222plugin-admssw.shortdesc
===================================================================
--- trunk/src/plugins/admssw/packaging/control/222plugin-admssw.shortdesc	                        (rev 0)
+++ trunk/src/plugins/admssw/packaging/control/222plugin-admssw.shortdesc	2012-08-21 16:20:56 UTC (rev 16127)
@@ -0,0 +1,3 @@
+ This plugin provides ADMS.SW additions to the DOAP RDF documents for projects on /projects URLs 
+ with content-negociation (application/rdf+xml).
+ 
\ No newline at end of file

Added: trunk/src/plugins/admssw/packaging/dirs/plugin-admssw
===================================================================
--- trunk/src/plugins/admssw/packaging/dirs/plugin-admssw	                        (rev 0)
+++ trunk/src/plugins/admssw/packaging/dirs/plugin-admssw	2012-08-21 16:20:56 UTC (rev 16127)
@@ -0,0 +1,5 @@
+etc/gforge/httpd.d
+etc/gforge/plugins/admssw
+usr/share/gforge/plugins/admssw/cgi-bin
+usr/share/gforge/plugins/admssw/common
+usr/share/gforge/plugins/admssw/www

Added: trunk/src/plugins/admssw/packaging/docs/plugin-admssw
===================================================================
--- trunk/src/plugins/admssw/packaging/docs/plugin-admssw	                        (rev 0)
+++ trunk/src/plugins/admssw/packaging/docs/plugin-admssw	2012-08-21 16:20:56 UTC (rev 16127)
@@ -0,0 +1 @@
+debian/README.Debian

Added: trunk/src/plugins/admssw/packaging/install/plugin-admssw
===================================================================
--- trunk/src/plugins/admssw/packaging/install/plugin-admssw	                        (rev 0)
+++ trunk/src/plugins/admssw/packaging/install/plugin-admssw	2012-08-21 16:20:56 UTC (rev 16127)
@@ -0,0 +1,3 @@
+plugins/admssw/common/*                  usr/share/@OLDPACKAGE@/plugins/admssw/common/
+plugins/admssw/include/*                 usr/share/@OLDPACKAGE@/plugins/admssw/include/
+plugins/admssw/etc/admssw.ini	             etc/@PACKAGE@/config.ini.d/




More information about the Fusionforge-commits mailing list