-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Miel Vander Sande
committed
Dec 16, 2015
1 parent
f9d50e3
commit 19dfaf9
Showing
7 changed files
with
164 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
src/org/linkeddatafragments/exceptions/NoRegisteredMimeTypesException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package org.linkeddatafragments.exceptions; | ||
|
||
/** | ||
* | ||
* @author mielvandersande | ||
*/ | ||
public class NoRegisteredMimeTypesException extends Exception { | ||
|
||
public NoRegisteredMimeTypesException() { | ||
super("List of supported mimeTypes is empty."); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/* | ||
* To change this license header, choose License Headers in Project Properties. | ||
* To change this template file, choose Tools | Templates | ||
* and open the template in the editor. | ||
*/ | ||
|
||
package org.linkeddatafragments.views; | ||
|
||
import freemarker.template.Configuration; | ||
import freemarker.template.Template; | ||
import freemarker.template.TemplateException; | ||
import freemarker.template.TemplateExceptionHandler; | ||
import java.io.File; | ||
import java.io.IOException; | ||
import java.io.OutputStream; | ||
import java.io.OutputStreamWriter; | ||
import java.io.Writer; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
import org.linkeddatafragments.datasource.IDataSource; | ||
import org.linkeddatafragments.fragments.LinkedDataFragment; | ||
|
||
/** | ||
* | ||
* @author mielvandersande | ||
*/ | ||
public class HtmlWriter { | ||
private final Configuration cfg; | ||
|
||
public HtmlWriter() throws IOException { | ||
cfg = new Configuration(Configuration.VERSION_2_3_22); | ||
cfg.setDirectoryForTemplateLoading(new File(System.getProperty("user.dir") + "/views")); | ||
cfg.setDefaultEncoding("UTF-8"); | ||
cfg.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER); | ||
} | ||
|
||
public void write(OutputStream outputStream, HashMap<String, IDataSource> dataSources, IDataSource datasource, LinkedDataFragment fragment) throws IOException, TemplateException{ | ||
/* Get the template (uses cache internally) */ | ||
Template temp = cfg.getTemplate("index.ftl.html"); | ||
|
||
Map data = new HashMap(); | ||
data.put("assetsPath", "css/"); | ||
data.put("header", datasource.getTitle()); | ||
data.put("datasources", dataSources); | ||
data.put("content", ""); | ||
|
||
data.put("controls", fragment.getControls()); | ||
data.put("metadata", fragment.getMetadata()); | ||
data.put("triples", fragment.getTriples()); | ||
|
||
|
||
/* Merge data-model with template */ | ||
Writer out = new OutputStreamWriter(outputStream); | ||
temp.process(data, out); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<#-- @license ©2015 Miel Vander Sande - Multimedia Lab / iMinds / Ghent University --> | ||
<!DOCTYPE html> | ||
<html lang="en" prefix="hydra: http://www.w3.org/ns/hydra/core# void: http://rdfs.org/ns/void#"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title> | ||
<#attempt> | ||
${ title || header } | ||
<#recover> | ||
'Linked Data Fragments Server' | ||
</#attempt> | ||
</title> | ||
<link rel="stylesheet" href="${ assetsPath }style" /> | ||
<link rel="stylesheet" href="//fonts.googleapis.com/css?family=Open+Sans:700italic,400,700|Droid+Sans+Mono" type="text/css" /> | ||
<meta name="viewport" content="width=device-width,minimum-scale=1,maximum-scale=1"> | ||
</head> | ||
<body> | ||
<header> | ||
<h1><a href="/"> | ||
<#attempt> | ||
${ header } | ||
<#recover> | ||
'Linked Data Fragments Server' | ||
</#attempt> | ||
</a></h1> | ||
<figure class="logo"> | ||
<a href="http://linkeddatafragments.org/"><img src="/logo" alt="Linked Data Fragments" /></a> | ||
</figure> | ||
</header> | ||
<main> | ||
${ content } | ||
</main> | ||
<footer> | ||
<p> | ||
Powered by a <a href="https://github.com/LinkedDataFragments/Server.java" target="_blank">Linked Data Fragments Server</a> | ||
©2013–2015 Multimedia Lab – iMinds – Ghent University | ||
</p> | ||
</footer> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<#-- @license ©2015 Miel Vander Sande - Multimedia Lab / iMinds / Ghent University --> | ||
<#include "base.ftl.html"> | ||
<div class="index"> | ||
<h2>Available datasets</h2> | ||
<p>Browse the following datasets as <a href="http://linkeddatafragments.org/in-depth/#tpf">Triple Pattern Fragments</a>:</p> | ||
<dl class="datasets"> | ||
<#list datasources?keys as datasourceName> | ||
<dt><a href="/${datasourceName}">${datasources[datasourceName].getTitle() }</a></dt> | ||
<dd>${ datasources[datasourceName].getDescription() }</dd> | ||
</#list> | ||
</dl> | ||
<p>The current dataset <em class="dataset">index</em> contains metadata about these datasets.</p> | ||
</div> |