Commit fb2ecf2a authored by qkeunebr's avatar qkeunebr
Browse files

Merge branch 'master' of gitlab.utc.fr:crozatst/hdoc

parents 692f0637 fb816496
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:dc="http://www.idpf.org/2007/opf"
xpath-default-namespace="http://www.utc.fr/ics/hdoc/xhtml"
exclude-result-prefixes="xs"
xmlns="http://www.idpf.org/2007/opf"
version="2.0">
<xsl:import href="content/metadata.xsl"/>
<xsl:import href="content/manifest.xsl"/>
<xsl:import href="content/spine.xsl"/>
<xsl:output method="xml" indent="yes" encoding="UTF-8"/>
<xsl:template match="html">
<package unique-identifier="BookID" version="3.0">
<package unique-identifier="BookID" version="2.0">
<xsl:call-template name="metadata"/>
<xsl:call-template name="manifest"/>
<xsl:call-template name="spine"/>
......
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:dc="http://www.idpf.org/2007/opf"
xpath-default-namespace="http://www.utc.fr/ics/hdoc/xhtml"
exclude-result-prefixes="xs"
xmlns="http://www.idpf.org/2007/opf"
version="2.0">
<xsl:param name="images"/>
<xsl:template name="manifest">
<manifest>
<item id="tDMncx" href="tableDesMatieres.ncx" media-type="application/x-dtbncx+xml" />
<xsl:for-each select="body/section">
<!-- Table des matières -->
<item id="tDMncx" href="tableDesMatieres.ncx" media-type="application/x-dtbncx+xml"/>
<!-- Chapitre -->
<xsl:for-each select="//section[(count(ancestor::section) = 1 and position() &gt; 1) or (count(ancestor::section) = 0)]">
<item>
<xsl:attribute name="href">chapitres/chapitre<xsl:number level="multiple" count="section" format="1"/>.xhtml</xsl:attribute>
<xsl:attribute name="id">ch<xsl:number level="multiple" count="section" format="1"/></xsl:attribute>
<xsl:attribute name="href">chapitres/chapitre<xsl:number level="multiple" count="section" format="1_1"/>.xhtml</xsl:attribute>
<xsl:attribute name="id">ch_<xsl:number level="multiple" count="section" format="1_1"/></xsl:attribute>
<xsl:attribute name="media-type">application/xhtml+xml</xsl:attribute>
</item>
</xsl:for-each>
<!-- CSS -->
<item id="CSS" href="styles/stylesheet.css" media-type="text/css"/>
<!-- Première page -->
<item href="chapitres/titlepage.xhtml" id="titlepage" media-type="application/xhtml+xml"/>
<!-- Images -->
<xsl:call-template name="parse-comma-separated">
<xsl:with-param name="text" select="$images"/>
<xsl:with-param name="i" select="1"/>
</xsl:call-template>
</manifest>
</xsl:template>
</xsl:stylesheet>
\ No newline at end of file
<xsl:template name="parse-comma-separated">
<xsl:param name="text"/>
<xsl:param name="i"/>
<xsl:choose>
<xsl:when test="contains($text, ',')">
<!-- Récupération du nom du fichier et de son extension -->
<xsl:variable name="filename"><xsl:value-of select="normalize-space(substring-before($text, ','))"/></xsl:variable>
<xsl:variable name="extension">
<xsl:call-template name="get-file-extension">
<xsl:with-param name="path" select="$filename" />
</xsl:call-template>
</xsl:variable>
<!-- Création de l'item -->
<item>
<!-- Test sur son extension -->
<xsl:choose>
<xsl:when test="$extension = 'jpg' or $extension = 'jpeg'">
<xsl:attribute name="media-type">image/jpeg</xsl:attribute>
</xsl:when>
<xsl:otherwise>
<xsl:attribute name="media-type">image/<xsl:value-of select="$extension"/></xsl:attribute>
</xsl:otherwise>
</xsl:choose>
<xsl:attribute name="href">images/<xsl:value-of select="$filename"/></xsl:attribute>
<xsl:attribute name="id">img<xsl:value-of select="$i"/></xsl:attribute>
</item>
<!-- Boucle tant qu'il y a des ',' -->
<xsl:call-template name="parse-comma-separated">
<xsl:with-param name="text" select="substring-after($text, ',')"/>
<xsl:with-param name="i" select="$i + 1"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<!-- Récupération du nom du fichier et de son extension -->
<xsl:variable name="filename"><xsl:value-of select="normalize-space($text)"/></xsl:variable>
<xsl:variable name="extension">
<xsl:call-template name="get-file-extension">
<xsl:with-param name="path" select="$filename" />
</xsl:call-template>
</xsl:variable>
<!-- Création de l'item -->
<item>
<!-- Test sur son extension -->
<xsl:choose>
<xsl:when test="$extension = 'jpg' or $extension = 'jpeg'">
<xsl:attribute name="media-type">image/jpeg</xsl:attribute>
</xsl:when>
<xsl:otherwise>
<xsl:attribute name="media-type">image/<xsl:value-of select="$extension"/></xsl:attribute>
</xsl:otherwise>
</xsl:choose>
<xsl:attribute name="href">images/<xsl:value-of select="$filename"/></xsl:attribute>
<xsl:attribute name="id">img<xsl:value-of select="$i"/></xsl:attribute>
</item>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<!-- Récupère l'extension du fichier -->
<xsl:template name="get-file-extension">
<xsl:param name="path"/>
<xsl:choose>
<xsl:when test="contains($path, '/')">
<xsl:call-template name="get-file-extension">
<xsl:with-param name="path" select="substring-after($path, '/')"/>
</xsl:call-template>
</xsl:when>
<xsl:when test="contains($path, '.')">
<xsl:call-template name="get-file-extension">
<xsl:with-param name="path" select="substring-after($path, '.')"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$path"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:dc="http://www.idpf.org/2007/opf"
xpath-default-namespace="http://www.utc.fr/ics/hdoc/xhtml"
exclude-result-prefixes="xs"
xmlns="http://www.idpf.org/2007/opf"
version="2.0">
<xsl:template name="metadata">
<metadata>
<metadata xmlns:dc="http://purl.org/dc/elements/1.1/">
<dc:title><xsl:value-of select="head/title"/></dc:title>
<dc:creator><xsl:value-of select="head/meta[@name='author']/@content"/></dc:creator>
<dc:language>fr</dc:language>
<dc:identifier id="BookID">V2.0</dc:identifier>
</metadata>
</xsl:template>
</xsl:stylesheet>
\ No newline at end of file
</xsl:stylesheet>
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:dc="http://www.idpf.org/2007/opf"
xpath-default-namespace="http://www.utc.fr/ics/hdoc/xhtml"
exclude-result-prefixes="xs"
xmlns="http://www.idpf.org/2007/opf"
version="2.0">
<xsl:template name="spine">
<spine toc="tDMncx">
<xsl:for-each select="body/section">
<itemref idref="titlepage"/>
<xsl:for-each select="//section[(count(ancestor::section) = 1 and position() &gt; 1) or (count(ancestor::section) = 0)]">
<itemref>
<xsl:attribute name="idref">ch<xsl:number level="multiple" count="section" format="1"/></xsl:attribute>
<xsl:attribute name="idref">ch_<xsl:number level="multiple" count="section" format="1_1"/></xsl:attribute>
</itemref>
</xsl:for-each>
</spine>
</xsl:template>
</xsl:stylesheet>
\ No newline at end of file
</xsl:stylesheet>
......@@ -9,18 +9,20 @@
<xsl:output method="xml" indent="yes" encoding="UTF-8"/>
<xsl:template match="html">
<ncx version="2005-1" xml:lang="en-US">
<ncx version="2005-1" xml:lang="fra">
<head>
<meta content="org-example-5059463624137734586" name="dtb:uid"/>
</head>
<docTitle>
<text><xsl:value-of select="head/title"/></text>
</docTitle>
<navMap>
<xsl:apply-templates/>
</navMap>
</ncx>
</xsl:template>
<xsl:template match="//section">
<xsl:template match="html/body/section">
<navPoint>
<xsl:attribute name="class">h<xsl:value-of select="count(ancestor::section)+1"/></xsl:attribute>
<xsl:attribute name="id">ch_<xsl:number level="multiple" count="section" format="1_1"/></xsl:attribute>
......@@ -30,10 +32,25 @@
</text>
</navLabel>
<content>
<xsl:attribute name="src">content.html#ch_<xsl:number level="multiple" count="section" format="1_1"/></xsl:attribute>
<xsl:attribute name="src">chapitres/chapitre<xsl:number level="multiple" count="section" format="1_1"/>.xhtml</xsl:attribute>
</content>
<xsl:apply-templates/>
</navPoint>
</xsl:template>
<xsl:template match="//section[count(ancestor::section) = 1 and position() &gt; 1]">
<navPoint>
<xsl:attribute name="class">h<xsl:value-of select="count(ancestor::section)+1"/></xsl:attribute>
<xsl:attribute name="id">ch_<xsl:number level="multiple" count="section" format="1_1"/></xsl:attribute>
<navLabel>
<text>
<xsl:value-of select="header/h1"/>
</text>
</navLabel>
<content>
<xsl:attribute name="src">chapitres/chapitre<xsl:number level="multiple" count="section" format="1_1"/>.xhtml</xsl:attribute>
</content>
<xsl:apply-templates/>
</navPoint>
</xsl:template>
......
<html>
<head>
<title>page principale</title>
<script type="text/javascript" src="https://code.jquery.com/jquery-3.1.1.min.js" ></script>
<script type="text/javascript">
jQuery("document").ready(function () {
var myData = [{
"title":
"XSLT (oprations avances): expressions rgulires et fichiers texte"
,
"authors":
"Karim El Aktaa (Contributions: Stphane Crozat et les tudiants de NF29)"
,
"keywords":
[
"XSL"
,
"XSLT"
,
"XSL-XSLT"
,
"Expression rgulire"
]
,
"rights":
"by-sa"
,
"introduction":
"XSL-XSLT est un langage de programmation qui permet notamment de manipuler des documents XML. Ce module a pour but de vous apporter des connaissances plus approfondies sur ce langage que vous connaissez dj: l'utilisation de document non XML et d'expressions rgulires."
},
{
"title":
"XSLT (oprations avances): expressions rgulires et fichiers texte"
,
"authors":
"Karim El Aktaa (Contributions: Stphane Crozat et les tudiants de NF29)"
,
"keywords":
[
"XSL"
,
"XSLT"
,
"XSL-XSLT"
,
"Expression rgulire"
]
,
"rights":
"by-sa"
,
"introduction":
"XSL-XSLT est un langage de programmation qui permet notamment de manipuler des documents XML. Ce module a pour but de vous apporter des connaissances plus approfondies sur ce langage que vous connaissez dj: l'utilisation de document non XML et d'expressions rgulires."
}]
for (var item in myData) {
var model = jQuery("div[name='toFill']").first().clone();
model.find("a[name='link']").attr("href", "title.html#" + encodeURI(JSON.stringify(myData[item])));
model.find("span[name='title']").text(myData[item].title);
model.css("display", "block")
model.appendTo(jQuery("body").first());
}
});
</script>
</head>
<body>
<input type="text" id="search" style="width:100%"/>
<div name="toFill" style="display:none;">
<a href="" name="link">
<div style="width:100%; text-align: center; border: solid 1px black; padding: 5px; margin: 3px;">
<span name="title">
</span>
</div>
</a>
</div>
</body>
</html>
\ No newline at end of file
<html>
<head>
<title>page secondaire</title>
<script type="text/javascript" src="https://code.jquery.com/jquery-3.1.1.min.js" ></script>
<script type="text/javascript">
jQuery("document").ready(function () {
var myData = JSON.parse(decodeURI(document.location.href.split("#")[1]));
jQuery("#title").text(myData.title);
jQuery("#spData").append("<p>Auteur(s) : " + myData.authors + "</p>");
jQuery("#spData").append("<p>License de droits d'usage : " + myData.rights + "</p>");
jQuery("#spData").append("");
jQuery("#rwData").append("<p>non classs : " + myData.keywords.join(", ") + "</p>");
jQuery("#introduction").text(myData.introduction);
});
function loadFullText() {
jQuery("#preview").empty();
jQuery("#preview").text("TODO");
}
</script>
<style type="text/css">
div {
border: solid 1px black;
}
</style>
</head>
<body>
<div id="toFill">
<h1 id="title"></h1>
<div>
<div style="width: 62%; display:inline-block">
<p id="spData">
</p>
<div style="text-align:center;"><a href="#todo">Lien de tlchargement</a></div>
</div>
<div id="rwData" style="width: 35%; margin-top:0px; float:right;%">
<h2>Tags</h2>
</div>
</div>
<div id="preview" style="clear:both">
<div id="introduction" ></div>
<div style="text-align:center;">
<a href="#" onclick="loadFullText()">Lire plus ...</a>
</div>
</div>
</div>
</body>
</html>
\ No newline at end of file
......@@ -6,7 +6,7 @@
<xsl:import href="../xsl-import/string.xsl"/>
<xsl:template name="title-main">
<xsl:choose>
<xsl:when test="../section">
<xsl:when test="name() = 'section'">
<xsl:call-template name="title-section"></xsl:call-template>
</xsl:when>
<xsl:otherwise>
......
......@@ -30,15 +30,15 @@ User documentation
You have to respect the following steps :
0. If you start from an Opale format, you can use the opale_to_hdoc converter, or directly execute the opale_to_Neo4j one.
1 - Placer un ou plusieurs fichiers (format hdoc) dans le dossier input
1. The first step is to put you HDOC document into the input directory inside the project hdoc_to_neo4j. Please, place only one file in that folder.
2 - Modifier le fichier config.json (dans le dossier node) avec la base de données locale et le mot de passe personnel (base publique à venir)
2. The second one is to launch the bash, the bat or start the ant (depending on your Operating System) by typing the following instruction :
ant -buildfile hdoc_to_neo4j
3 - En ligne de commande, executer "npm install" pour installer les packages nodes (en attendant une automatisation future de la tache)
3. After the execution, you should find in the output folder (which is created in step 2) a result.cql file that contains all the requests to recreate the items and links of you hdoc input.
4 - Lancer le fichier runWithNode (choisissez l'extension selon votre OS)
5 - Admirez le graph créé avec neo4j dans votre navigateur (sur localhost:7474)
Unsupported
......
<?xml version="1.0" encoding="UTF-8"?>
<project name="antModule" default="main" basedir="./">
<taskdef resource="net/sf/antcontrib/antlib.xml">
<classpath>
<pathelement location="lib/ant-contrib.jar"/>
</classpath>
</taskdef>
<taskdef resource="net/sf/antcontrib/antlib.xml">
<classpath>
<pathelement location="lib/ant-contrib.jar"/>
</classpath>
</taskdef>
<property name="node" value="false" ></property>
......@@ -38,7 +38,7 @@
</target>
<target name="unZip">
<unzip src="./input/${file}" dest="./input/unziped/" overwrite="false"/>
<unzip src="./input/${file}" dest="./input/unziped/" overwrite="false"/>
</target>
<target name="transformation">
......@@ -50,8 +50,8 @@
<mkdir dir="./input/unziped"/>
</sequential>
</target>
<target name="insertion" if="wantToInsert">
<exec executable="node" dir="./node">
<arg line="insert.js"/>
......
......@@ -2,7 +2,7 @@
set ant=hdoc_to_neo4j.ant
set antparam=-Dnode true;
IF NOT EXIST ./node_modules call npm install
ant -buildfile %ant% %antparam%
pause
......
......@@ -31,5 +31,9 @@ fi
#Lancer la commande
scJarList="$lib/*"
#test si les packages ont été installés
if [ ! -d "$node_modules" ]; then
npm install
fi
$vJavaCmd -classpath "$scJarList:" -Xmx150m org.apache.tools.ant.Main -buildfile $ant $antparam
......@@ -19,27 +19,15 @@
</xsl:template>
<xsl:template match="body/section">
MERGE (i:item {title:"<xsl:value-of select="concat(./header/h1,' (',string-length(.), ')')"/>"});
MATCH (l1:item {title:"<xsl:value-of select="concat(./header/h1,' (',string-length(.), ')')"/>"}), (l2:module {title:"<xsl:value-of select="concat(ancestor::html/head/title,' (',string-length(ancestor::html/body), ')')"/>"}) MERGE (l2)-[:LIEN]->(l1);
MERGE (i:<xsl:value-of select="./@data-hdoc-type"/> {title:"<xsl:value-of select="concat(./header/h1,' (',string-length(.), ')')"/>"});
MATCH (l1 {title:"<xsl:value-of select="concat(./header/h1,' (',string-length(.), ')')"/>"}), (l2 {title:"<xsl:value-of select="concat(ancestor::html/head/title,' (',string-length(ancestor::html/body), ')')"/>"}) MERGE (l2)-[:LIEN]->(l1);
<xsl:apply-templates select="./section"/>
</xsl:template>
<xsl:template match="body/section/section">
MERGE (i:item {title:"<xsl:value-of select="concat(./header/h1,' (',string-length(.), ')')"/>"});
MATCH (l1:item {title:"<xsl:value-of select="concat(./header/h1,' (',string-length(.), ')')"/>"}), (l2:item {title:"<xsl:value-of select="concat(parent::section/header/h1,' (',string-length(parent::section), ')')"/>"}) MERGE (l2)-[:LIEN]->(l1);
MERGE (i:<xsl:value-of select="./@data-hdoc-type"/> {title:"<xsl:value-of select="concat(./header/h1,' (',string-length(.), ')')"/>"});
MATCH (l1 {title:"<xsl:value-of select="concat(./header/h1,' (',string-length(.), ')')"/>"}), (l2 {title:"<xsl:value-of select="concat(parent::section/header/h1,' (',string-length(parent::section), ')')"/>"}) MERGE (l2)-[:LIEN]->(l1);
<!--<xsl:apply-templates select="./div"/>-->
</xsl:template>
<!--
<xsl:template match="body/section[@data-hdoc-type]">
MERGE (i:<xsl:value-of select="./@data-hdoc-type"/> {title:"<xsl:value-of select="./header/h1"/>"});
<xsl:apply-templates select="./section"/>
</xsl:template>
<xsl:template match="body/section[not(@data-hdoc-type)]">
MERGE (i:item {title:"<xsl:value-of select="./header/h1"/>"});
<xsl:apply-templates select="./section"/>
</xsl:template>
-->
</xsl:stylesheet>
\ No newline at end of file
!tmp/.gitkeep
!output/.gitkeep
Converter hdoc_to_pdf
-----------------------
The purpose of this converter is to obtain a PDF file from a hdoc document.
The purpose of this converter is to obtain a PDF file from a hdoc document.
License GPL3.0
......@@ -28,7 +28,36 @@ This project can be used alone if you only want to convert a hdoc file into a PD
User documentation
------------------
There are two different ways to use the converter hdoc_to_pdf: by running a script run.bat/run.sh or by command line using a terminal (allows the user to specify some parameters).
#### Running the script run.bat/run.sh:
Use this method if you do not want to use a terminal.
1. Download hdoc_converter.zip and unzip it.
2. Add your source file into the input folder. It must be a .hdoc file.
3. Place _only one file_ in that folder.
4. On Linux or Mac, run the script run.sh. On Windows, run the script run.bat.
5. Your file has been converted, the result is in the output folder.
#### Terminal:
By using the terminal you can specify some parameters to the conversion at the moment: the source file.
1. Download hdoc_converter.zip and unzip it.
2. Open your terminal and go into the folder hdoc_to_pdf.
3. Run the following command:
"ant -buildfile hdoc_to_pdf.ant"
You can specify the source file by adding parameters.
Use -DInputFile to specify the source file.
Exemple:
"ant -buildfile hdoc_to_optim.ant -DInputFile=sample.hdoc"
This parameter is optional. Your file has been converted, the result is in the output folder.
Known bugs
......@@ -51,6 +80,7 @@ Generic Todo
Technical notes
---------------
* This converter works with _only one_ hdoc file in the input folder, please ensure to clean the folder before proceeding with the hdoc you want to convert to PDF.
User Story
----------
......@@ -64,5 +94,3 @@ User Story
Capitalisation
--------------
/* Font declarations */
@font-face {
font-family: "CMU Serif";
src: url(cmunrm.ttf);
font-weight: normal;
font-style: normal;
-fs-pdf-font-embed: embed;
-fs-pdf-font-encoding: Identity-H;
}
@font-face {
font-family: "CMU Serif Extra";
src: url(cmunrb.ttf);
font-weight: bold;
font-style: normal;
-fs-pdf-font-embed: embed;
-fs-pdf-font-encoding: Identity-H;
}
@font-face {
font-family: "CMU Serif";
src: url(cmunti.ttf);
font-weight: normal;
font-style: italic;
-fs-pdf-font-embed: embed;
-fs-pdf-font-encoding: Identity-H;
}
@font-face {
font-family: "CMU Typewriter Text";
src: url(cmuntt.ttf);
font-weight: normal;
font-style: normal;
-fs-pdf-font-embed: embed;
-fs-pdf-font-encoding: Identity-H;
}
/* Global page styles */
@page {
size: A4 portrait;
margin-left: 44mm;
margin-right: 44mm;
margin-top: 20mm;
margin-bottom: 40mm;