Commit 6bc78266 authored by Neveux Anais's avatar Neveux Anais

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

parents e2174339 275c389e
...@@ -5,9 +5,13 @@ ...@@ -5,9 +5,13 @@
<xsl:output method="xml" indent="yes"/> <xsl:output method="xml" indent="yes"/>
<xsl:template match="p[child::ul or child::ol]" priority="1"> <xsl:template match="p[child::ul or child::ol]" priority="1">
<xsl:apply-templates select="./*"></xsl:apply-templates> <xsl:apply-templates select="./ul"/>
<xsl:apply-templates select="./ol"/>
<p>
<xsl:apply-templates select="./node()[not(self::ul) and not(self::ol)]"/>
</p>
</xsl:template> </xsl:template>
<xsl:template match="//ul[parent::ul or parent::ol]" priority="1"> <xsl:template match="//ul[parent::ul or parent::ol]" priority="1">
......
...@@ -110,3 +110,34 @@ td{ ...@@ -110,3 +110,34 @@ td{
.bold{ .bold{
font-weight: bold; font-weight: bold;
} }
.imgContainer1{
text-indent:0;
text-align:center;
margin-right:auto;
margin-left:auto;
width:99%;
page-break-before:auto;
page-break-inside:avoid;
page-break-after:auto;
}
.imgContainer2{
margin-left:0;
margin-right:0;
text-align:center;
text-indent:0;
height:100%;
width:100%;
}
p .imgContainer3{
display:inline-block;
text-indent:0;
width:100%;
}
img{
max-width:99%;
max-height:75%;
}
...@@ -97,7 +97,7 @@ ...@@ -97,7 +97,7 @@
<target name="MakeOPF"> <target name="MakeOPF">
<!-- Récupération du nom des images dans my.images séparé par des ','--> <!-- Récupération du nom des images dans my.images séparé par des ','-->
<path id="pathImage"> <path id="pathImage">
<fileset dir="${tmp}/${filename}/decompressedHdoc/re"> <fileset dir="${tmp}/${filename}/decompressedHdoc/re" erroronmissingdir="false">
<include name="**/*.jpeg"/> <include name="**/*.jpeg"/>
<include name="**/*.jpg"/> <include name="**/*.jpg"/>
<include name="**/*.svg"/> <include name="**/*.svg"/>
...@@ -151,7 +151,7 @@ ...@@ -151,7 +151,7 @@
<target name="ValidateOutput"> <target name="ValidateOutput">
<java jar="./epubcheck-4.0.2/epubcheck.jar" fork="true"> <java jar="./epubcheck-4.0.2/epubcheck.jar" fork="true">
<arg value="${out}/${properFilename}.epub"/> <arg value="${out}/${properFilename}.epub"/>
</java> </java>
</target> </target>
<target name="CleanTmp"> <target name="CleanTmp">
......
...@@ -184,10 +184,23 @@ ...@@ -184,10 +184,23 @@
</xsl:template> </xsl:template>
<xsl:template match="//img" priority="4"> <xsl:template match="//img" priority="4">
<xsl:element name="img"> <!--<div class="imageWrapperHi">
<xsl:attribute name="src">../images/<xsl:value-of select="./@alt"/></xsl:attribute> <xsl:element name="img">
<xsl:attribute name="alt"><xsl:value-of select="./@alt"/></xsl:attribute> <xsl:attribute name="src">../images/<xsl:value-of select="./@alt"/></xsl:attribute>
</xsl:element> <xsl:attribute name="alt"><xsl:value-of select="./@alt"/></xsl:attribute>
</xsl:element>
</div>-->
<div class="imgContainer1">
<div class="imgContainer2">
<xsl:element name="img">
<xsl:attribute name="src">../images/<xsl:value-of select="./@alt"/></xsl:attribute>
<xsl:attribute name="alt"><xsl:value-of select="./@alt"/></xsl:attribute>
</xsl:element>
</div>
</div>
</xsl:template> </xsl:template>
<xsl:template match="//a[not(starts-with(@href,'http'))]" priority="4"> <xsl:template match="//a[not(starts-with(@href,'http'))]" priority="4">
......
...@@ -12,13 +12,16 @@ Kapilraj Thangeswaran ...@@ -12,13 +12,16 @@ Kapilraj Thangeswaran
This module is able to extract data from a file in Hdoc format and insert them into MongoDB. This module is able to extract data from a file in Hdoc format and insert them into MongoDB.
## Dependencies ## Dependencies
In order to work properly this module needs
- In order to make this module work you have to download and install Node.js from the [Node.js download page](https://nodejs.org/en/). - In order to make this module work you have to download and install Node.js from the [Node.js download page](https://nodejs.org/en/).
- If needed, download and install MongoDB from the [MongoDB download page](https://www.mongodb.com/download-center#community). - If needed, download and install MongoDB from the [MongoDB download page](https://www.mongodb.com/download-center#community).
## Instructions ## Instructions
1. Install dependencies 1. Install dependencies
2. Edit "config.json" file from "mongo" folder (for more details, please check "Mongo configuration") 2. Add all your hdoc documents in an "input" folder
3. Execute run.bat or run.sh 3. Add or edit "config.xml" file in "input" folder (for more details, please check "Input configuration")
4. Edit "config.json" file from "mongo" folder (for more details, please check "Mongo configuration")
5. Execute run.bat or run.sh
## Web ## Web
This module provides a Web application to access MongoDB and execute simples requests. This module provides a Web application to access MongoDB and execute simples requests.
...@@ -26,9 +29,22 @@ This module provides a Web application to access MongoDB and execute simples req ...@@ -26,9 +29,22 @@ This module provides a Web application to access MongoDB and execute simples req
2. Edit "config.json" file from "web" folder (for more details, please check "MongoDB configuration") 2. Edit "config.json" file from "web" folder (for more details, please check "MongoDB configuration")
3. Open "index.html" in "web" folder 3. Open "index.html" in "web" folder
## Input configuration
You can add or edit "config.xml" in "input" folder in order to provide more information about your documents.
Supported information
- link
```
<?xml version="1.0" encoding="UTF-8"?>
<config>
<file name='sample.scar'>
<link>https://stph.scenari-community.org/nf17/co/nf17.html</link>
</file>
</config>
```
## MongoDB configuration ## MongoDB configuration
### In "mongo" folder ### In "mongo" folder
Use "config.json" in the "mongo" folder to specify : Use "config.json" in the "mongo" folder to specify
- url : mongodb's url - url : mongodb's url
- database : the database you are using - database : the database you are using
- collection : the collection you are using - collection : the collection you are using
...@@ -43,7 +59,7 @@ Use "config.json" in the "mongo" folder to specify : ...@@ -43,7 +59,7 @@ Use "config.json" in the "mongo" folder to specify :
``` ```
### In "web" folder ### In "web" folder
Use "config.json" in the "web" folder to specify : Use "config.json" in the "web" folder to specify
- url : mongodb's url including the database - url : mongodb's url including the database
- collection : the collection you are using - collection : the collection you are using
``` ```
...@@ -61,4 +77,4 @@ Use "config.json" in the "web" folder to specify : ...@@ -61,4 +77,4 @@ Use "config.json" in the "web" folder to specify :
## User stories ## User stories
- En tant qu’utilisateur rédigeant des documents sous opale, je veux récupérer les exercices corrigés d’un sujet donné dans le but de les réutiliser. - En tant qu’utilisateur rédigeant des documents sous opale, je veux récupérer les exercices corrigés d’un sujet donné dans le but de les réutiliser.
- En tant qu’utilisateur rédigeant des documents sous opale, je veux récupérer les cours d’un auteur précis dans le but d’utiliser ses cours comme références. - En tant qu’utilisateur rédigeant des documents sous opale, je veux récupérer les cours d’un auteur précis dans le but d’utiliser ses cours comme références.
- En tant qu’utilisateur universitaire, je souhaite mettre à disposition mes exercices sur internet de manière structuré dans le but de permettre à d’autre utilisateurs universitaires de les trouver, par thème, auteur ou contenu et de les réutiliser. - En tant qu’utilisateur universitaire, je souhaite mettre à disposition mes exercices sur internet de manière structuré dans le but de permettre à d’autre utilisateurs universitaires de les trouver, par thème, auteur ou contenu et de les réutiliser.
\ No newline at end of file
...@@ -48,7 +48,10 @@ ...@@ -48,7 +48,10 @@
<target name="convertHdoc"> <target name="convertHdoc">
<echo>Convert ${inputPath}/${file}</echo> <echo>Convert ${inputPath}/${file}</echo>
<basename property="basename" file="${inputPath}/${file}" suffix=".hdoc"/> <basename property="basename" file="${inputPath}/${file}" suffix=".hdoc"/>
<xslt in="${tmpdir}/content.xml" out="${outputPath}/${basename}.json" style="xsl/main.xsl"/> <xslt in="${tmpdir}/content.xml" out="${outputPath}/${basename}.json" style="xsl/main.xsl">
<param name="fileName" expression="${basename}"/>
<param name="inputPath" expression="${inputPath}"/>
</xslt>
</target> </target>
<target name="clean"> <target name="clean">
......
<?xml version="1.0" encoding="UTF-8"?>
<config>
<file name='alg1_2016-12-12.scar'>
<link>https://stph.scenari-community.org/nf17/co/nf17.html</link>
</file>
</config>
\ No newline at end of file
...@@ -10,11 +10,19 @@ ...@@ -10,11 +10,19 @@
<xsl:import href="subroutines/right.xsl"/> <xsl:import href="subroutines/right.xsl"/>
<xsl:import href="subroutines/introduction.xsl"/> <xsl:import href="subroutines/introduction.xsl"/>
<xsl:import href="subroutines/exercise.xsl"/> <xsl:import href="subroutines/exercise.xsl"/>
<xsl:import href="subroutines/config.xsl"/>
<xsl:output method="text" encoding="UTF-8" omit-xml-declaration="yes"/> <xsl:output method="text" encoding="UTF-8" omit-xml-declaration="yes"/>
<xsl:param name="fileName" required="yes" as="xs:string"/>
<xsl:param name="inputPath" required="yes" as="xs:string"/>
<xsl:template match="/"> <xsl:template match="/">
{ {
<xsl:call-template name="config-main">
<xsl:with-param name="fileName"><xsl:value-of select="$fileName"/></xsl:with-param>
<xsl:with-param name="inputPath"><xsl:value-of select="$inputPath"/></xsl:with-param>
</xsl:call-template>
"title" : <xsl:call-template name="title-main"/>, "title" : <xsl:call-template name="title-main"/>,
"authors" : <xsl:call-template name="author-main"/>, "authors" : <xsl:call-template name="author-main"/>,
"keywords" : <xsl:call-template name="keyword-main"/>, "keywords" : <xsl:call-template name="keyword-main"/>,
......
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:h2m="http://www.utc.fr/hdoc/hdoc_to_mongo">
<xsl:import href="../xsl-import/string.xsl"/>
<xsl:template name="config-main">
<xsl:param name="fileName"/>
<xsl:param name="inputPath"/>
"link" : <xsl:value-of select="h2m:escape-string(document('C:\Users\Kapil\Documents\Projets\github\hdoc\hdoc_to_mongo/input/config.xml')/config/file[@name = $fileName]/link)" />,
</xsl:template>
</xsl:stylesheet>
\ No newline at end of file
...@@ -66,6 +66,7 @@ Known bugs ...@@ -66,6 +66,7 @@ Known bugs
* Nested ul in ol are sometimes converted to ol. * Nested ul in ol are sometimes converted to ol.
* It seems that FS doesn't support the max-width for img tags, which makes proper scaling harder. * It seems that FS doesn't support the max-width for img tags, which makes proper scaling harder.
* ToC lines rendering is sometimes ugly if the title label is too long. * ToC lines rendering is sometimes ugly if the title label is too long.
* Inline elements like em cause bad paragraphs justification.
Generic Todo Generic Todo
------------ ------------
......
...@@ -56,29 +56,50 @@ body { ...@@ -56,29 +56,50 @@ body {
p { p {
text-align: justify; text-align: justify;
text-indent: 2em; text-indent: 2em;
-webkit-hyphens: auto;
-ms-hyphens: auto;
hyphens: auto; hyphens: auto;
word-break: normal; word-break: normal;
} }
h1 {font-size: 2em}
h2 {font-size: 1.6em}
h3 {font-size: 1.4em}
h4 {font-size: 1.2em}
h5, h6 {font-size: 1em}
h5 {font-family: "CMU Serif Extra"}
h6 {font-style: italic}
/* Global headings numbering */ /* Global headings numbering */
body {counter-reset: h2} body {counter-reset: h2}
h2 {counter-reset: h3} h2 {counter-reset: h3}
h3 {counter-reset: h4} h3 {counter-reset: h4}
/*
h4 {counter-reset: h5} h4 {counter-reset: h5}
h5 {counter-reset: h6} h5 {counter-reset: h6}
*/
h2::before {counter-increment: h2; content: counter(h2) ".\0000a0\0000a0"} h2::before {counter-increment: h2; content: counter(h2) ".\0000a0\0000a0"}
h3::before {counter-increment: h3; content: counter(h2) "." counter(h3) ".\0000a0\0000a0"} h3::before {counter-increment: h3; content: counter(h2) "." counter(h3) ".\0000a0\0000a0"}
h4::before {counter-increment: h4; content: counter(h2) "." counter(h3) "." counter(h4) ".\0000a0\0000a0"} h4::before {counter-increment: h4; content: counter(h2) "." counter(h3) "." counter(h4) ".\0000a0\0000a0"}
/*
h5::before {counter-increment: h5; content: counter(h2) "." counter(h3) "." counter(h4) "." counter(h5) ".\0000a0\0000a0"} h5::before {counter-increment: h5; content: counter(h2) "." counter(h3) "." counter(h4) "." counter(h5) ".\0000a0\0000a0"}
h6::before {counter-increment: h6; content: counter(h2) "." counter(h3) "." counter(h4) "." counter(h5) "." counter(h6) ".\0000a0\0000a0"} h6::before {counter-increment: h6; content: counter(h2) "." counter(h3) "." counter(h4) "." counter(h5) "." counter(h6) ".\0000a0\0000a0"}
*/
/*
h2.nocount:before, h2.nocount:before,
h3.nocount:before, h3.nocount:before,
h4.nocount:before, h4.nocount:before,
h5.nocount:before, h5.nocount:before,
h6.nocount:before { content: ""; counter-increment: none } h6.nocount:before { content: ""; counter-increment: none }
*/
h2.nocount:before,
h3.nocount:before,
h4.nocount:before { content: ""; counter-increment: none }
/* Global lists styling */ /* Global lists styling */
......
...@@ -12,6 +12,13 @@ ...@@ -12,6 +12,13 @@
<xsl:template match="h:container"> <xsl:template match="h:container">
<project name="hdoc_to_pdf" basedir=".." default="main"> <project name="hdoc_to_pdf" basedir=".." default="main">
<property name="lib" location="lib"/>
<property name="Schema" location="schemas"/>
<taskdef name="jing" classname="com.thaiopensource.relaxng.util.JingTask">
<classpath>
<pathelement location="${lib}/jing.jar"/>
</classpath>
</taskdef>
<target name="main"> <target name="main">
<xsl:apply-templates/> <xsl:apply-templates/>
</target> </target>
...@@ -41,6 +48,15 @@ ...@@ -41,6 +48,15 @@
<echo message="Filename : {$filename}"/> <echo message="Filename : {$filename}"/>
<echo message="Dirpath : {$dirpath}"/> <echo message="Dirpath : {$dirpath}"/>
<trycatch property="foo" reference="bar">
<try>
<jing file="{$TempDirectory}/{$path}" rngfile="${{Schema}}/xhtml/hdoc1-xhtml.rng"></jing>
</try>
<catch>
<echo>Validation failed</echo>
</catch>
</trycatch>
<copy file="{$BaseDirectory}/css/main.css" tofile="{$dirpath}/main.css"/> <copy file="{$BaseDirectory}/css/main.css" tofile="{$dirpath}/main.css"/>
<copy file="{$BaseDirectory}/font/cmunrm.ttf" tofile="{$dirpath}/cmunrm.ttf"/> <copy file="{$BaseDirectory}/font/cmunrm.ttf" tofile="{$dirpath}/cmunrm.ttf"/>
<copy file="{$BaseDirectory}/font/cmunrb.ttf" tofile="{$dirpath}/cmunrb.ttf"/> <copy file="{$BaseDirectory}/font/cmunrb.ttf" tofile="{$dirpath}/cmunrb.ttf"/>
......
...@@ -21,7 +21,9 @@ ...@@ -21,7 +21,9 @@
<xsl:apply-templates select="node()|@*"/> <xsl:apply-templates select="node()|@*"/>
<xsl:call-template name="toc"/> <xsl:call-template name="toc">
<xsl:with-param name="toclevel" select="2"/>
</xsl:call-template>
</body> </body>
</xsl:template> </xsl:template>
...@@ -31,81 +33,55 @@ ...@@ -31,81 +33,55 @@
<!-- Gestion de la table des matières --> <!-- Gestion de la table des matières -->
<xsl:template name="toc">
<xsl:if test="count(//h2) &gt; 0">
<h2 class="nocount toc-title">Table des matières</h2>
<ul class="toc level2">
<xsl:for-each select="//h2">
<li>
<xsl:call-template name="toc-a"/>
<xsl:if test="count(..//h3) &gt; 0">
<ul class="toc level3">
<xsl:for-each select="..//h3">
<li>
<xsl:call-template name="toc-a"/>
<xsl:if test="count(..//h4) &gt; 0">
<ul class="toc level4"> <xsl:template name="toc">
<xsl:for-each select="..//h4">
<li>
<xsl:call-template name="toc-a"/>
<xsl:if test="count(..//h5) &gt; 0">
<ul class="toc level5">
<xsl:for-each select="..//h5">
<li>
<xsl:call-template name="toc-a"/>
<xsl:if test="count(..//h6) &gt; 0">
<ul class="toc level6">
<xsl:for-each select="..//h6">
<li>
<xsl:call-template name="toc-a"/>
</li> <xsl:param name="toclevel"/>
</xsl:for-each> <xsl:variable name="hnlevel" select="concat('h', $toclevel)"/>
</ul>
</xsl:if> <xsl:choose>
</li> <xsl:when test="$toclevel = 2">
</xsl:for-each> <xsl:if test="count(//*[local-name()=$hnlevel]) &gt; 0">
</ul> <h2 class="nocount toc-title">Table des matières</h2>
</xsl:if> <ul class="toc level2">
<xsl:for-each select="//*[local-name()=$hnlevel]">
<li>
<xsl:call-template name="toc-a"/>
</li> <xsl:call-template name="toc">
</xsl:for-each> <xsl:with-param name="toclevel" select="3"/>
</ul> </xsl:call-template>
</xsl:if> </li>
</xsl:for-each>
</ul>
</xsl:if>
</xsl:when>
</li> <xsl:otherwise>
</xsl:for-each> <xsl:if test="count(..//*[local-name()=$hnlevel]) &gt; 0">
</ul>
</xsl:if> <ul class="toc level{$toclevel}">
<xsl:for-each select="..//*[local-name()=$hnlevel]">
<li>
<xsl:call-template name="toc-a"/>
</li> <xsl:if test="$toclevel &lt; 4">
</xsl:for-each> <xsl:call-template name="toc">
</ul> <xsl:with-param name="toclevel" select="$toclevel + 1"/>
</xsl:call-template>
</xsl:if>
</li>
</xsl:for-each>
</ul>
</xsl:if>
</xsl:otherwise>
</xsl:if> </xsl:choose>
</xsl:template> </xsl:template>
<xsl:template name="toc-a"> <xsl:template name="toc-a">
<a> <a>
......
...@@ -65,6 +65,9 @@ You can use special rules in Freemind to personnalize your Scenari Module : ...@@ -65,6 +65,9 @@ You can use special rules in Freemind to personnalize your Scenari Module :
* **#ex** : an example * **#ex** : an example
* **#def** : a definition * **#def** : a definition
* **#question** : a MCQ * **#question** : a MCQ
* **#singlechoicequestion** : a QCU
* **#choice-qcu** : an answer within a QCU
* **#solution** : a solution associated to a single choice within a QCU (matches an integer)
* **#choice-correct** : a correct answer within a MCQ * **#choice-correct** : a correct answer within a MCQ
* **#choice-incorrect** : an incorrect answer within a MCQ * **#choice-incorrect** : an incorrect answer within a MCQ
* **#explanation** : an explanation of the answers within a MCQ * **#explanation** : an explanation of the answers within a MCQ
......
...@@ -13,6 +13,54 @@ This module is able to extract data from a file in Opale format and insert them ...@@ -13,6 +13,54 @@ This module is able to extract data from a file in Opale format and insert them
## Dependencies ## Dependencies
In order to work properly this module needs In order to work properly this module needs
- In order to make this module work you have to download and install Node.js from the [Node.js download page](https://nodejs.org/en/).
- If needed, download and install MongoDB from the [MongoDB download page](https://www.mongodb.com/download-center#community).
- [`opale_to_hdoc`](https://gitlab.utc.fr/crozatst/hdoc/tree/master/opale_to_hdoc) (Opale to Hdoc conversion)
- [`hdoc_to_mongo`](https://gitlab.utc.fr/crozatst/hdoc/tree/master/hdoc_to_mongo) (Hdoc to Mongo conversion)
1. [`opale_to_hdoc`](https://gitlab.utc.fr/crozatst/hdoc/tree/master/opale_to_hdoc) (Opale to Hdoc conversion) ## Instructions
2. [`hdoc_to_mongo`](https://gitlab.utc.fr/crozatst/hdoc/tree/master/hdoc_to_mongo) (Hdoc to Mongo conversion) 1. Install dependencies
\ No newline at end of file 2. Add all your hdoc documents in an "input" folder
3. Add or edit "config.xml" file in "input" folder (for more details, please check "Input configuration")
4. Edit "config.json" file from "mongo" folder in "hdoc_to_mongo" module (for more details, please check "Mongo configuration")
5. Execute run.bat or run.sh
## Input configuration
You can add or edit "config.xml" in "input" folder to provide more information about your documents.
Supported information
- link
```
<?xml version="1.0" encoding="UTF-8"?>
<config>
<file name='sample.scar'>
<link>https://stph.scenari-community.org/nf17/co/nf17.html</link>
</file>
</config>
```
## MongoDB configuration
### In "mongo" folder from "hdoc_to_mongo" module
Use "config.json" in the "mongo" folder to specify
- url : mongodb's url
- database : the database you are using
- collection : the collection you are using
- request : the request you want to perform (for allowed requests, please check "Supported requests")
```
{
"url" : "mongodb://localhost:27017/",
"database" : "database",
"collection" : "collection",
"request" : "insert"
}
```
## Supported requests
- insert
- update (using the title as filter)
- remove (using the title as filter)
## User stories
- En tant qu’utilisateur rédigeant des documents sous opale, je veux récupérer les exercices corrigés d’un sujet donné dans le but de les réutiliser.
- En tant qu’utilisateur rédigeant des documents sous opale, je veux récupérer les cours d’un auteur précis dans le but d’utiliser ses cours comme références.
- En tant qu’utilisateur universitaire, je souhaite mettre à disposition mes exercices sur internet de manière structuré dans le but de permettre à d’autre utilisateurs universitaires de les trouver, par thème, auteur ou contenu et de les réutiliser.
\ No newline at end of file
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
<copy todir="${inputHdocToMongo}"> <copy todir="${inputHdocToMongo}">
<fileset dir="${outputOpaleToHdoc}"/> <fileset dir="${outputOpaleToHdoc}"/>
</copy> </copy>
<copy file="${inputPath}/config.xml" todir="${inputHdocToMongo}"/>
<copy todir="${nodeModulesHdocToMongo}"> <copy todir="${nodeModulesHdocToMongo}">
<fileset dir="${nodeModules}"/> <fileset dir="${nodeModules}"/>
</copy> </copy>
......
<?xml version="1.0" encoding="UTF-8"?>
<config>
<file name='alg1_2016-12-12.scar'>
<link>https://stph.scenari-community.org/nf17/co/nf17.html</link>
</file>
</config>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment