Skip to content

Commit

Permalink
Merge remote-tracking branch 'refs/remotes/origin/develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
dgarijo committed Jul 18, 2016
2 parents 7d6248a + 5bdc1f8 commit ee335cd
Show file tree
Hide file tree
Showing 17 changed files with 287 additions and 56 deletions.
4 changes: 3 additions & 1 deletion ConfigSamples/config/config.properties
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ authorsInstitution=First author institution;Second author institution
contributors=First contributor;Second contributor
contributorsURI=http://example.org/contributor1;http://example.org/contributor2
contributorsInstitution=First contributor institution;Second contributor institution
publisher=publisherName
publisherURI=http://example.com/publisher1
importedOntologyNames=Imported Ontology 1; Imported Ontology 2
importedOntologyURIs=http://example.org/test11; http://example.org/test22
extendedOntologyNames=test1; test2
Expand All @@ -24,7 +26,7 @@ licenseURI=http://creativecommons.org/licenses/by-nc-sa/2.0/
licenseIconURL=http://i.creativecommons.org/l/by-nc-sa/2.0/88x31.png
citeAs=Insert here how you want to cite your ontology.
status=Ontology Draft
RDFXMLSerialization=http://vocab.linkeddata.es/p-plan/p-plan.owl
deafultSerialization=RDF/XMLRDFXMLSerialization=http://vocab.linkeddata.es/p-plan/p-plan.owl
TurtleSerialization=
N3Serialization=
JSONLDSerialization=
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ The character ";" is used for lists (for instance first author; second author; t

Now you can execute Widoco through the console. Usage:

java -jar widoco.jar [-ontFile file] or [-ontURI uri] [-outFolder folderName] [-confFile propertiesFile] or [-getOntologyMetadata] [-oops] [-rewriteAll] [-saveConfig configOutFile] [-useCustomStyle] [-lang lang1;lang2] [-includeImportedOntologies] [-htaccess]
java -jar widoco.jar [-ontFile file] or [-ontURI uri] [-outFolder folderName] [-confFile propertiesFile] or [-getOntologyMetadata] [-oops] [-rewriteAll] [-saveConfig configOutFile] [-useCustomStyle] [-lang lang1;lang2] [-includeImportedOntologies] [-htaccess] [-webVowl]

The ontFile and ontURI options allow you to choose the ontology file or ontology URI of your ontology.

Expand All @@ -71,6 +71,8 @@ The -includeImportedOntologies flag indicates whether the terms of the imported

The -htaccess flag creates a bundle for publication ready to be deployed on your apache server.

The -webVowl flag provides a link to a visualization based on WebVowl (http://vowl.visualdataweb.org/webvowl/index.html#)

Browser problems
==========
The result of executing Widoco is an html file. We have tested it in Mozilla, IE and Chrome, and when the page is stored in a server all the browsers work correctly. If you view the file locally, we recommend you to use Mozilla Firefox (or Internet Explorer, if you must). Google Chrome will not show the contents correctly, as it doesn't allow XMLHttpRequest without HTTP. If you want to view the page locally with Google Chrome you have two possibilities:
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/licensius/GetLicense.java
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public static String getFirstLicenseFound(String uriToScan) {
throw new RuntimeException("HTTP error code : "+ conn.getResponseCode());
}
String r="";
String linea="";
String linea;
BufferedReader br = new BufferedReader(new InputStreamReader((conn.getInputStream())));

while ((linea = br.readLine()) != null) {
Expand Down
34 changes: 31 additions & 3 deletions src/main/java/widoco/Configuration.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
public class Configuration {
private ArrayList<Agent> creators;
private ArrayList<Agent> contributors;
private Agent publisher;
private String previousVersion;
private String thisVersion;
private String latestVersion;
Expand Down Expand Up @@ -117,7 +118,7 @@ public class Configuration {
private boolean addImportedOntologies;
private File tmpFolder; //file where different auxiliary resources might be copied to
private boolean createHTACCESS;
// private boolean createWebVowlVisualization;
private boolean createWebVowlVisualization;


private OntModel mainOntologyModel;//model of the mainOntology. Loaded separately
Expand Down Expand Up @@ -161,6 +162,7 @@ public void cleanConfig(){
revision = "";
creators = new ArrayList<Agent>();
contributors = new ArrayList<Agent>();
publisher = new Agent();
importedOntologies = new ArrayList<Ontology>();
extendedOntologies = new ArrayList<Ontology>();
//this has to be checked because we might delete the uri of the onto from a previous step.
Expand Down Expand Up @@ -215,6 +217,9 @@ private void loadConfigPropertyFile(String path){
mainOntologyMetadata.setNamespacePrefix(propertyFile.getProperty(Constants.ontPrefix));
mainOntologyMetadata.setNamespaceURI(propertyFile.getProperty(Constants.ontNamespaceURI));
revision = propertyFile.getProperty(Constants.ontologyRevision);
publisher = new Agent();
publisher.setName(propertyFile.getProperty(Constants.publisher,""));
publisher.setURL(propertyFile.getProperty(Constants.publisherURI,""));
String aux = propertyFile.getProperty(Constants.authors,"");
String[]names,urls,authorInst;
if(!aux.equals("")){
Expand Down Expand Up @@ -363,6 +368,9 @@ public void loadPropertiesFromOntology(OntModel m){
if(propertyName.equals("versionInfo")){
this.revision = value;
}else
if(propertyName.equals("versionIRI")){
this.thisVersion = value;
}else
if(propertyName.equals("preferredNamespacePrefix")){
this.mainOntologyMetadata.setNamespacePrefix(value);
}else
Expand All @@ -380,7 +388,8 @@ public void loadPropertiesFromOntology(OntModel m){
}
mainOntologyMetadata.setLicense(l);
}else
if(propertyName.equals("creator")||propertyName.equals("contributor")){
if(propertyName.equals("creator")||propertyName.equals("contributor")
||propertyName.equals("publisher")){
Agent g = new Agent();
if(isURL(value)){
g.setURL(value);
Expand All @@ -391,8 +400,10 @@ public void loadPropertiesFromOntology(OntModel m){
}
if(propertyName.equals("creator")){
this.creators.add(g);
}else{
}else if (propertyName.equals("contributor")){
this.contributors.add(g);
}else{
this.publisher = g;
}
}else
if(propertyName.equals("created")){
Expand Down Expand Up @@ -923,6 +934,23 @@ public OntModel getMainModel() {
public void setMainModel(OntModel model) {
this.mainOntologyModel = model;
}

public boolean isCreateWebVowlVisualization() {
return createWebVowlVisualization;
}

public void setCreateWebVowlVisualization(boolean createWebVowlVisualization) {
this.createWebVowlVisualization = createWebVowlVisualization;
}

public Agent getPublisher() {
return publisher;
}

public void setPublisher(Agent publisher) {
this.publisher = publisher;
}




Expand Down
61 changes: 39 additions & 22 deletions src/main/java/widoco/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
package widoco;

import java.io.File;
import java.util.AbstractMap;
import java.util.AbstractMap.SimpleEntry;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
Expand Down Expand Up @@ -59,6 +57,8 @@ public class Constants {
public static final String contributors="contributors";
public static final String contributorsURI="contributorsURI";
public static final String contributorsInstitution="contributorsInstitution";
public static final String publisher="publisher";
public static final String publisherURI="publisherURI";
public static final String importedOntologyNames="importedOntologyNames";
public static final String importedOntologyURIs="importedOntologyURIs";
public static final String extendedOntologyNames="extendedOntologyNames";
Expand Down Expand Up @@ -351,33 +351,55 @@ public static String getHeadSection(Configuration c, Properties l){
head += getAuthors(c.getCreators(),l)+"\n";
if(!c.getContributors().isEmpty())
head += getContributors(c.getContributors(),l)+"\n";
if(c.getPublisher()!=null){
String publisherName = c.getPublisher().getName();
String publisherURL = c.getPublisher().getURL();
if(publisherURL == null ||publisherURL.equals("")){
publisherURL = "http://example.org/insertPublisherURIHere";
}
if(publisherName == null || publisherName.equals("")){
publisherName = publisherURL;
}
head += "<dl><dt>"+l.getProperty("publisher")+"</dt>"+"\n"
+ "<dd><a href="+publisherURL+" target=\"_blank\">"+publisherName+"</a></dd></dl>\n";
}
if(!c.getImportedOntologies().isEmpty())
head += getImports(c.getImportedOntologies(),l)+"\n";
if(!c.getExtendedOntologies().isEmpty())
head += getExtends(c.getExtendedOntologies(),l)+"\n";

HashMap<String,String> availableSerializations = c.getMainOntology().getSerializations();
head+="<dl><dt>"+l.getProperty("serialization")+"</dt>";
head+="<dl><dt>"+l.getProperty("serialization")+"</dt><dd>";
for(String serialization:availableSerializations.keySet()){
head+="<span><a href=\""+availableSerializations.get(serialization)+"\"><img src=\"https://img.shields.io/badge/Format-"+serialization.replace("-", "_")+"-blue.svg\"</img></a> </span>";
head+="<span><a href=\""+availableSerializations.get(serialization)+"\" target=\"_blank\"><img src=\"https://img.shields.io/badge/Format-"+serialization.replace("-", "_")+"-blue.svg\"</img></a> </span>";
}

head+="</dl>";
head+="</dd></dl>";
if(c.getMainOntology().getLicense()!=null){
String lname = c.getMainOntology().getLicense().getName();//"license name goes here";
String licenseURL = c.getMainOntology().getLicense().getUrl();//"http://insertlicenseURIhere.org";
if(licenseURL == null || "".equals(licenseURL))licenseURL = l.getProperty("licenseURLIfNull");
if(lname == null || "".equals(lname)) lname = l.getProperty("licenseIfNull");
head+="<dl><dt>"+l.getProperty("license")+"</dt><dd>"
+ "<a rel=\"license\" href=\""+licenseURL+"\" target=\"_blank\"><img src =\"https://img.shields.io/badge/License-"+lname.replace("-", "_")+"-blue.svg\"</img></a>\n"+
"<span property=\"dc:license\" resource=\""+licenseURL+"\"></span>\n";
if(c.getMainOntology().getLicense().getIcon()!=null && !"".equals(c.getMainOntology().getLicense().getIcon())){
head+="<a property=\"dc:rights\" href=\""+licenseURL+"\" rel=\"license\">\n" +
head+="<a property=\"dc:rights\" href=\""+licenseURL+"\" rel=\"license\" target=\"_blank\">\n" +
"<img src=\""+c.getMainOntology().getLicense().getIcon()+"\" style=\"border-width:0\" alt=\"License\"></img>\n" +
"</a>\n<br/>";
}
head+="<dl>"+l.getProperty("license")+"<a rel=\"license\" href=\""+licenseURL+"\">"+lname+"</a>.</dl>\n"+
"<span property=\"dc:license\" resource=\""+licenseURL+"\"></span>\n";
head+="</dd></dl>";
}
//add lang tags here
if(c.isCreateWebVowlVisualization()){
head+="<dl><dt>"+l.getProperty("visualization")+"</dt>"
+ "<dd>"
+ "<a href=\"http://vowl.visualdataweb.org/webvowl/index.html#iri="+c.getMainOntology().getNamespaceURI()+"\" target=\"_blank\"><img src=\"https://img.shields.io/badge/Visualize_with-WebVowl-blue.svg\"</img></a>"
+ "</dd>"
+ "</dl>";
}
if(c.isPublishProvenance()){
head+="<dl><a href=\"provenance/provenance-"+c.getCurrentLanguage()+".html\">"+l.getProperty("provHead")+"</a></dl>";
head+="<dl><a href=\"provenance/provenance-"+c.getCurrentLanguage()+".html\" target=\"_blank\">"+l.getProperty("provHead")+"</a></dl>";
}
head+= "<hr/>\n"+
"</div>\n";
Expand Down Expand Up @@ -703,19 +725,19 @@ public static final String getHTACCESS(Configuration c){
"RewriteCond %{HTTP_ACCEPT} !application/rdf\\+xml.*(text/html|application/xhtml\\+xml)\n" +
"RewriteCond %{HTTP_ACCEPT} text/html [OR]\n" +
"RewriteCond %{HTTP_ACCEPT} application/xhtml\\+xml [OR]\n" +
"RewriteCond %{HTTP_ACCEPT} text/\\* [OR]\n" +
"RewriteCond %{HTTP_ACCEPT} \\*/\\* [OR]\n" +
"RewriteCond %{HTTP_USER_AGENT} ^Mozilla/.*\n";
//this depends on whether the vocab is hash or slash!
if(c.getMainOntology().isHashOntology()){
htAccessFile +="RewriteRule ^$ index-"+c.getCurrentLanguage()+".html [R=303,L]\n";
htAccessFile +="RewriteRule ^$ index-"+c.getCurrentLanguage()+".html [R=303,L]\n\n";
HashMap<String,String> serializations = c.getMainOntology().getSerializations();
for(String serialization:serializations.keySet()){
htAccessFile +="# Rewrite rule to serve "+serialization+" content from the vocabulary URI if requested\n";
if(serialization.equals("RDF/XML")){
htAccessFile+="RewriteCond %{HTTP_ACCEPT} application/rdf\\+xml\n";
htAccessFile+="RewriteCond %{HTTP_ACCEPT} \\*/\\* [OR]\n" +
"RewriteCond %{HTTP_ACCEPT} application/rdf\\+xml\n";
}else if(serialization.equals("TTL")){
htAccessFile+="RewriteCond %{HTTP_ACCEPT} text/turtle [OR]\n" +
"RewriteCond %{HTTP_ACCEPT} text/\\* [OR]\n" +
"RewriteCond %{HTTP_ACCEPT} \\*/turtle \n";
}else if(serialization.equals("N-Triples")){
htAccessFile+="RewriteCond %{HTTP_ACCEPT} application/n-triples\n";
Expand Down Expand Up @@ -764,7 +786,7 @@ public static final String getHTACCESS(Configuration c){
htAccessFile += condition+normalSerialization+condition+complexSerialization;
}
htAccessFile += "RewriteCond %{HTTP_ACCEPT} .+\n" +
"RewriteRule ^def()$ 406.html [R=406,L]\n"
"RewriteRule ^def$ doc/406.html [R=406,L]\n"
+ "# Default response\n" +
"# ---------------------------\n" +
"# Rewrite rule to serve the RDF/XML content from the vocabulary URI by default\n" +
Expand All @@ -778,17 +800,12 @@ public static final String getHTACCESS(Configuration c){
/**
* Text for the 406 page
* @param c
* @param lang
* @return the content of the 406 page
*/
public static String get406(Configuration c) {
public static String get406(Configuration c, Properties lang) {
String page406 = "<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\">\n" +
"<html><head>\n" +
"<title>406 Not Acceptable</title>\n" +
"</head><body>\n" +
"<h1>Not Acceptable</h1>\n" +
"<p>An appropriate representation of the requested resource could not be found on this server.</p>\n" +
"\n" +
"Available variants:</ul>";
"<html><head>\n" + lang.getProperty("notAccPage")+"<ul>";
HashMap<String,String> serializations = c.getMainOntology().getSerializations();
page406+="<li><a href=\"index-"+c.getCurrentLanguage()+".html\">html</a></li>";
for(String s:serializations.keySet()){
Expand Down
12 changes: 6 additions & 6 deletions src/main/java/widoco/CreateResources.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public static void generateDocumentation(String outFolder, Configuration c, File
folderOut+=File.separator+"doc";
}
}
createFolderStructure(folderOut,c);
createFolderStructure(folderOut,c,languageFile);
if(c.isIncludeAbstract()){
createAbstractSection(folderOut+File.separator+"sections",c, languageFile);
}
Expand Down Expand Up @@ -119,7 +119,7 @@ public static void generateSkeleton(String folderOut, Configuration c, Propertie
c.setIncludeDiagram(false);
c.setPublishProvenance(false);
c.setUseW3CStyle(true);
createFolderStructure(folderOut,c);
createFolderStructure(folderOut,c,l);
createAbstractSection(folderOut+File.separator+"sections",c, l);
createIntroductionSection(folderOut+File.separator+"sections",null,c,l);
createDescriptionSection(folderOut+File.separator+"sections",c,l);
Expand All @@ -139,8 +139,8 @@ private static void createHTACCESSFile(String path, Configuration c){
saveDocument(path,Constants.getHTACCESS(c), c);
}

private static void create406Page(String path, Configuration c) {
saveDocument(path,Constants.get406(c), c);
private static void create406Page(String path, Configuration c, Properties lang) {
saveDocument(path,Constants.get406(c,lang), c);
}

/**
Expand Down Expand Up @@ -277,7 +277,7 @@ public static void saveDocument(String path, String textToWrite, Configuration c

}

private static void createFolderStructure(String s, Configuration c){
private static void createFolderStructure(String s, Configuration c, Properties lang){
File f = new File(s);
File sections = new File(s+File.separator+"sections");
File img = new File(s+File.separator+"img");
Expand Down Expand Up @@ -314,7 +314,7 @@ private static void createFolderStructure(String s, Configuration c){
//copy widoco readme
WidocoUtils.copyLocalResource("/widoco/readme.md", new File(f.getAbsolutePath()+File.separator+"readme.md"));
if(c.isCreateHTACCESS()){
create406Page(s+File.separator+"406.html",c);
create406Page(s+File.separator+"406.html",c,lang);
}
}

Expand Down
2 changes: 0 additions & 2 deletions src/main/java/widoco/entities/Ontology.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@
*/
package widoco.entities;

import java.util.AbstractMap;
import java.util.ArrayList;
import java.util.HashMap;

/**
Expand Down
13 changes: 12 additions & 1 deletion src/main/java/widoco/gui/EditProperty.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
*/
public class EditProperty extends javax.swing.JFrame {

public enum PropertyType{authors, contributors, extended, imported, license};
public enum PropertyType{authors, contributors, publisher, extended, imported, license};
private final GuiStep2 step2Gui;
private final Configuration c;
private final PropertyType type;
Expand Down Expand Up @@ -59,6 +59,15 @@ public EditProperty(GuiStep2 g, Configuration c, PropertyType p) {
createTable(new String[]{"Name","URI","Institution Name"});
loadAgents(c.getContributors());
break;
case publisher:
this.setTitle("Editing Publisher");
createTable(new String[]{"Name","URI","Institution Name"});
this.addRowButton.setEnabled(false);
this.deleteRowButton.setEnabled(false);
ArrayList<Agent> aux = new ArrayList<Agent>();
aux.add(c.getPublisher());
loadAgents(aux);
break;
case extended:
this.setTitle("Editing Extended Ontologies");
createTable(new String[]{"Extended Ontology Name","Extended Ontology URI"});
Expand Down Expand Up @@ -227,6 +236,8 @@ private void okButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRS
break;
case contributors:this.c.setContributors(getAgentsFromTable());
break;
case publisher:this.c.setPublisher(getAgentsFromTable().get(0));
break;
case extended:this.c.setExtendedOntologies(getOntologiesFromTable());
break;
case imported:this.c.setImportedOntologies(getOntologiesFromTable());
Expand Down
Loading

0 comments on commit ee335cd

Please sign in to comment.