Commit 8cc8cc2a authored by Neveux Anais's avatar Neveux Anais
Browse files

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

parents 6618d4db d77c17a9
*/input/* */input/*
*/tmp/* */tmp/*
*/output/* */output/*
*/node_modules*/
*.DS_Store* *.DS_Store*
[submodule "hdoc_to_mongo/node_modules/node-mongodb-native"]
path = hdoc_to_mongo/node_modules/node-mongodb-native
url = https://github.com/mongodb/node-mongodb-native.git
...@@ -16,7 +16,7 @@ http://www.gnu.org/licenses/gpl-3.0.txt ...@@ -16,7 +16,7 @@ http://www.gnu.org/licenses/gpl-3.0.txt
- Fecherolle Cécile - Fecherolle Cécile
## Presentation ## Presentation
This module is able to convert several [etherpad](http://etherpad.org/) files (exported as html files) to the hdoc format. This module is able to convert several [framad](https://framapad.org/) files (exported as html files) to the hdoc format.
## User documentation ## User documentation
...@@ -24,8 +24,8 @@ This module is able to convert several [etherpad](http://etherpad.org/) files (e ...@@ -24,8 +24,8 @@ This module is able to convert several [etherpad](http://etherpad.org/) files (e
Vous êtes un utilisateur de framapad et en créez un pour un projet. Après avoir travaillé sur votre pad, vous souhaitez transformer ce document en un autre format que vous pourrez utiliser dans un nouveau contexte de travail. Pour ce faire, vous exportez le framapad au format HTML grâce au bouton « Import/Export ». Vous récupérez ensuite les fichiers nécessaires à la transformation framapad to hdoc sur le répertoire git du projet hdoc (voir http://hdoc.crzt.fr/). Il ne vous reste alors plus qu'à placer le fichier html précédemment récupéré dans le dossier « input » du dossier framapad_to_hdoc et à exécuter le /run.bat si vous êtes sur Windows ou le /run.sh si vous êtes sur Linux/Mac. Cela produira une archive .hdoc dont l'intérêt est de servir de format de passage pour une transformation d'un format à un autre, et ce pour une grande variété de format. Il vous restera ensuite à déterminer le nouveau format dans lequel vous voulez transformer votre hdoc et utiliser le convertisseur approprié s'il existe. Vous êtes un utilisateur de framapad et en créez un pour un projet. Après avoir travaillé sur votre pad, vous souhaitez transformer ce document en un autre format que vous pourrez utiliser dans un nouveau contexte de travail. Pour ce faire, vous exportez le framapad au format HTML grâce au bouton « Import/Export ». Vous récupérez ensuite les fichiers nécessaires à la transformation framapad to hdoc sur le répertoire git du projet hdoc (voir http://hdoc.crzt.fr/). Il ne vous reste alors plus qu'à placer le fichier html précédemment récupéré dans le dossier « input » du dossier framapad_to_hdoc et à exécuter le /run.bat si vous êtes sur Windows ou le /run.sh si vous êtes sur Linux/Mac. Cela produira une archive .hdoc dont l'intérêt est de servir de format de passage pour une transformation d'un format à un autre, et ce pour une grande variété de format. Il vous restera ensuite à déterminer le nouveau format dans lequel vous voulez transformer votre hdoc et utiliser le convertisseur approprié s'il existe.
## Running etherpad_to_hdoc.ant ## Running framapad_to_hdoc.ant
1. Create an etherpad document and export it as an html file. 1. Create a framapad document and export it as an html file.
2. please place your html files in the `/input` folder 2. please place your html files in the `/input` folder
3. run the `run.[bat|sh]` script of your choice depending on your OS 3. run the `run.[bat|sh]` script of your choice depending on your OS
4. and retrieve the hdoc outputs in the `/output` folder 4. and retrieve the hdoc outputs in the `/output` folder
......
...@@ -10,6 +10,21 @@ ...@@ -10,6 +10,21 @@
</xsl:template> </xsl:template>
<xsl:template match="//ul[parent::ul or parent::ol]" priority="1">
<li>
<ul>
<xsl:apply-templates select="*"/>
</ul>
</li>
</xsl:template>
<xsl:template match="//ol[parent::ul or parent::ol]" priority="1">
<li>
<ol>
<xsl:apply-templates select="*"/>
</ol>
</li>
</xsl:template>
<!--Identity template, <!--Identity template,
provides default behavior that copies all content into the output --> provides default behavior that copies all content into the output -->
<xsl:template match="@*|node()"> <xsl:template match="@*|node()">
......
...@@ -6,12 +6,12 @@ ...@@ -6,12 +6,12 @@
<xsl:template match="ul"> <xsl:template match="ul">
<ul> <ul>
<xsl:apply-templates select="*"/> <xsl:apply-templates select="*"/>
</ul><br/> </ul>
</xsl:template> </xsl:template>
<xsl:template match="ol"> <xsl:template match="ol">
<ol> <ol>
<xsl:apply-templates select="*"/> <xsl:apply-templates select="*"/>
</ol><br/> </ol>
</xsl:template> </xsl:template>
<xsl:template match="@*|node()"> <xsl:template match="@*|node()">
......
...@@ -48,8 +48,14 @@ ...@@ -48,8 +48,14 @@
<xsl:apply-templates select="*"/> <xsl:apply-templates select="*"/>
</ol> </ol>
</xsl:template> </xsl:template>
<xsl:template match="h1 | h2 | h3 | h4 | h5 | h6">
Titre (non pris en compte pour l'instant) :
<xsl:apply-templates select="@*|node()"/>
</xsl:template>
<xsl:template match="code">
Code (non pris en compte pour l'instant) :
<xsl:apply-templates select="@*|node()"/>
</xsl:template>
<xsl:template match="page"> <xsl:template match="page">
<xsl:apply-templates select="@*|node()"/> <xsl:apply-templates select="@*|node()"/>
</xsl:template> </xsl:template>
...@@ -59,4 +65,4 @@ ...@@ -59,4 +65,4 @@
<xsl:apply-templates select="@*|node()"/> <xsl:apply-templates select="@*|node()"/>
</xsl:copy> </xsl:copy>
</xsl:template> </xsl:template>
</xsl:stylesheet> </xsl:stylesheet>
\ No newline at end of file
# Etherpad2Opale -- HDOC CONVERTER PROJECT # framapad2opale -- HDOC CONVERTER PROJECT
## License ## License
[GPL 3.0](http://www.gnu.org/licenses/gpl-3.0.txt) [GPL 3.0](http://www.gnu.org/licenses/gpl-3.0.txt)
## Credits ## Credits
- Boucaud Fabien
- Chognard Etienne
- Rit Gabrielle - Rit Gabrielle
- Vintache Jean - Vintache Jean
- Douteau Jean-Come - Douteau Jean-Come
- Fecherolle Cecile (2014) - Fecherolle Cecile (2014)
## Presentation ## Presentation
How to transform an etherpad document in opale document. How to transform an framapad document in opale document.
Filepaths in this document are relative to this readme file. Filepaths in this document are relative to this readme file.
## Dependence ## Dependence
- Etherpad2Hdoc - framapad2Hdoc
- Hdoc2Opale - Hdoc2Opale
## User Documentation ## User Documentation
1. Download an etherpad document in html format. 1. Download a framapad document in html format.
1. Create or join an etherpad document then export it in html format (Import/Export Button) in the `/input` directory (if the directory does not exists, you have to create it). 1. Create or join a framapad document then export it in html format (Import/Export Button) in the `/input` directory (if the directory does not exists, you have to create it).
2. Execute the file `/run.bat` or `/run.sh` depending on the OS. A `.scar` file is created in the directory `/output` 2. Execute the file `/run.bat` or `/run.sh` depending on the OS. A `.scar` file is created in the directory `/output`
*If the `/input` directory contains multiple files, they will be all treated. *If the `/input` directory contains multiple files, they will be all treated.
3. Open the document with Opale 3. Open the document with Opale
1. Open Scenari, and choose "UTC-etu_opale" as distant depot. 1. Open Scenari, and choose "UTC-etu_opale" as distant depot.
2. Go in the directory `sandBox/etherpad-to-opale.` 2. Go in the sandbox.
3. Import your `.scar` file in the directory. 3. Import your `.scar` file in the directory.
4. Open the file Main.xml created. 4. Open the file Main.xml created.
...@@ -52,7 +54,7 @@ Here's an example : ...@@ -52,7 +54,7 @@ Here's an example :
- Correct nested lists - Correct nested lists
## Technical notes ## Technical notes
### Description of etherpad_to_hdoc.ant ### Description of framapad_to_hdoc.ant
#### Prelude #### Prelude
- Importation of necessary classes (antlib, htmlcleaner, jing) - Importation of necessary classes (antlib, htmlcleaner, jing)
...@@ -75,4 +77,4 @@ Here's an example : ...@@ -75,4 +77,4 @@ Here's an example :
We have to change how we get the input file: We have to change how we get the input file:
1 Get the first file of the input directory 1 Get the first file of the input directory
2 Make the run with the name of the file as parameter 2 Make the run with the name of the file as parameter
Finally, ant should be changed to manage multiple entries Finally, ant should be changed to manage multiple entries
\ No newline at end of file
!input/.gitkeep
!output/.gitkeep
\ No newline at end of file
...@@ -3,11 +3,10 @@ ...@@ -3,11 +3,10 @@
(: For example, $author := '^Baptiste Montangé$', to search for an exact name:) (: For example, $author := '^Baptiste Montangé$', to search for an exact name:)
(: For example, $name := 'Montangé', to search for documents whose author named Coutant:) (: For example, $name := 'Montangé', to search for documents whose author named Coutant:)
(: Remark : Accents in the authors' names have been taken care of :) (: Remark : Accents in the authors' names have been taken care of :)
declare function local:searchDocByAuthor($name as xs:string, $docs as node()*) as node()*
<documents>{ {
let $name := 'Montangé'
let $name_noAcc := translate($name, 'áàâäéèêëíìîïóòôöúùûü','aaaaeeeeiiiioooouuuu') let $name_noAcc := translate($name, 'áàâäéèêëíìîïóòôöúùûü','aaaaeeeeiiiioooouuuu')
for $doc in //document for $doc in $docs
return return
for $author in $doc/authors/author for $author in $doc/authors/author
let $titre := $doc/titre let $titre := $doc/titre
...@@ -15,4 +14,7 @@ ...@@ -15,4 +14,7 @@
where matches($author_noAcc, $name_noAcc) where matches($author_noAcc, $name_noAcc)
group by $titre (: Avoid duplications of documents by their titre:) group by $titre (: Avoid duplications of documents by their titre:)
return $doc return $doc
}</documents> };
\ No newline at end of file
(: Example :)
local:searchDocByAuthor('Montangé', //document)
\ No newline at end of file
...@@ -3,9 +3,12 @@ ...@@ -3,9 +3,12 @@
(: For example, $name := '^NF29_HdocEtherpad$', to search for an exact name:) (: For example, $name := '^NF29_HdocEtherpad$', to search for an exact name:)
(: For example, $name := 'NF29', to search for documents whose name contains 'NF29':) (: For example, $name := 'NF29', to search for documents whose name contains 'NF29':)
<documents>{ declare function local:searchDocByTitle($name as xs:string, $docs as node()*) as node()*
let $name := '^NF29_HdocEtherpad$' {
for $doc in //document for $doc in $docs
where matches($doc/titre, $name, "i") where matches($doc/titre, $name, "i")
return $doc return $doc
}</documents> };
\ No newline at end of file
(: Example :)
local:searchDocByTitle('^NF29_HdocEtherpad$', //document)
\ No newline at end of file
...@@ -20,6 +20,10 @@ Dependencies ...@@ -20,6 +20,10 @@ Dependencies
--- ---
There's no particular dependencies needed to run the converter. There's no particular dependencies needed to run the converter.
Conditions particulières
---
Pour le moment, il ne faut pas utilisé les "sous-Division" de Opale. Les divisions à la racine sont autorisées.
User Story User Story
--- ---
### Running the script ### Running the script
......
...@@ -32,16 +32,16 @@ ...@@ -32,16 +32,16 @@
<!-- Targeted markups. --> <!-- Targeted markups. -->
<xsl:template match="h:img"> <xsl:template match="h:img">
<copy tofile="${{filename2}}/decompressedOpale/res/{./@src}" file="${{filename2}}/decompressedHdoc/{./@src}"/> <copy tofile="${{filename2}}/decompressedcanoprof/res/{./@src}" file="${{filename2}}/decompressedHdoc/{./@src}"/>
</xsl:template> </xsl:template>
<xsl:template match="h:audio"> <xsl:template match="h:audio">
<copy tofile="${{filename2}}/decompressedOpale/res/{./@src}" file="${{filename2}}/decompressedHdoc/{./@src}"/> <copy tofile="${{filename2}}/decompressedcanoprof/res/{./@src}" file="${{filename2}}/decompressedHdoc/{./@src}"/>
</xsl:template> </xsl:template>
<xsl:template match="h:video"> <xsl:template match="h:video">
<copy tofile="${{filename2}}/decompressedOpale/res/{./@src}" file="${{filename2}}/decompressedHdoc/{./@src}"/> <copy tofile="${{filename2}}/decompressedcanoprof/res/{./@src}" file="${{filename2}}/decompressedHdoc/{./@src}"/>
</xsl:template> </xsl:template>
<xsl:template match="h:object"> <xsl:template match="h:object">
<copy tofile="${{filename2}}/decompressedOpale/res/{./@data}" file="${{filename2}}/decompressedHdoc/{./@data}"/> <copy tofile="${{filename2}}/decompressedcanoprof/res/{./@data}" file="${{filename2}}/decompressedHdoc/{./@data}"/>
</xsl:template> </xsl:template>
<!-- These markups are matched in order to minimize "apply-templates" side-effects (i.e. their contents are not relevant for this transformation). --> <!-- These markups are matched in order to minimize "apply-templates" side-effects (i.e. their contents are not relevant for this transformation). -->
......
...@@ -102,26 +102,6 @@ ...@@ -102,26 +102,6 @@
</sp:shortActivity> </sp:shortActivity>
</xsl:template> </xsl:template>
<!-- if Section has sub section(s), we create a real activity to print differents possible types of sub sections -->
<xsl:template match="h:body/h:section/h:section">
<sp:textActivity>
<cp:textActivity>
<cp:activityM>
<sp:title>
<xsl:value-of select="./h:header/h:h1"/>
</sp:title>
</cp:activityM>
<xsl:if test="./h:section">
<sp:body>
<cp:blocks>
<xsl:apply-templates select="./*"/>
</cp:blocks>
</sp:body>
</xsl:if>
</cp:textActivity>
</sp:textActivity>
</xsl:template>
<!-- Toutes les introductions de sections sont transformés en résumé. --> <!-- Toutes les introductions de sections sont transformés en résumé. -->
<xsl:template match="h:header/h:div[@data-hdoc-type = 'introduction']"> <xsl:template match="h:header/h:div[@data-hdoc-type = 'introduction']">
<sp:abstract> <sp:abstract>
...@@ -133,27 +113,224 @@ ...@@ -133,27 +113,224 @@
</sp:abstract> </sp:abstract>
</xsl:template> </xsl:template>
<!-- Gestion des définitions. --> <!-- CanoProf's Activite TetM = hdoc's body/Section/Section = Opale's Grain -->
<xsl:template match="h:div[@data-hdoc-type = 'definition']|h:div[@data-hdoc-type = 'example']"> <xsl:template match="h:body/h:section/h:section">
<!-- <xsl:variable name="vtype" select="./@data-hdoc-type/text()"/> <xsl:if test="./*">
<xsl:element name="{$vtype}">--> <sp:textActivity>
<sp:definition> <cp:textActivity>
<cp:block> <cp:activityM>
<cp:blockM> <sp:title>
<sp:title> <xsl:if test="not(./h:header/h:h1/text())"> Untitled </xsl:if>
<xsl:value-of select="./h:h6"/> <xsl:value-of select="./h:header/h:h1"/>
</sp:title> </sp:title>
</cp:blockM> <xsl:if test="(./h:header/h:div[@data-hdoc-type = 'introduction']/text())">
<xsl:apply-templates
select="./h:header/h:div[@data-hdoc-type = 'introduction']"/>
</xsl:if>
</cp:activityM>
<xsl:if test="./h:div/*">
<sp:body>
<cp:blocks>
<xsl:apply-templates select="./h:div"/>
</cp:blocks>
</sp:body>
</xsl:if>
<xsl:if test="./h:section/*">
<xsl:apply-templates select="./h:section" mode="CanoprofSection"/>
</xsl:if>
</cp:textActivity>
</sp:textActivity>
</xsl:if>
</xsl:template>
<!-- CanoProf's Activite TetM (section) = hdoc's body/Section/Section/(Section...) = Opale's Grain (partie) -->
<!-- TODO -->
<xsl:template match="h:section" mode="CanoprofSection">
</xsl:template>
<!-- Div related templates -->
<!-- Formatting content based on @data-hdoc-type -->
<xsl:template match="h:div">
<xsl:choose>
<!-- hdoc's explanation = canoprof's information (NOT EXPLICIT...) -->
<xsl:when test="./@data-hdoc-type = 'explanation'">
<sp:info>
<cp:block>
<xsl:if test="string-length(./h:h6/text()) > 0">
<cp:blockM>
<sp:title>
<xsl:value-of select="./h:h6"/>
</sp:title>
</cp:blockM>
</xsl:if>
<sp:body>
<cp:flow>
<xsl:apply-templates select="./*"/>
</cp:flow>
</sp:body>
</cp:block>
</sp:info>
</xsl:when>
<!-- hdoc's warning = canoprof's warning -->
<xsl:when test="./@data-hdoc-type = 'warning'">
<sp:warning>
<cp:block>
<cp:blockM>
<xsl:if test="string-length(./h:h6/text()) > 0">
<sp:title>
<xsl:value-of select="./h:h6"/>
</sp:title>
</xsl:if>
</cp:blockM>
<sp:body>
<cp:flow>
<xsl:apply-templates select="./*"/>
</cp:flow>
</sp:body>
</cp:block>
</sp:warning>
</xsl:when>
<!-- hdoc's complement = canoprof's complement (extra) -->
<xsl:when test="./@data-hdoc-type = 'complement'">
<sp:extra>
<cp:block>
<cp:blockM>
<xsl:if test="string-length(./h:h6/text()) > 0">
<sp:title>
<xsl:value-of select="./h:h6"/>
</sp:title>
</xsl:if>
</cp:blockM>
<sp:body>
<cp:flow>
<xsl:apply-templates select="./*"/>
</cp:flow>
</sp:body>
</cp:block>
</sp:extra>
</xsl:when>
<!-- hdoc's advice = canoprof's advice -->
<xsl:when test="./@data-hdoc-type = 'advice'">
<sp:advice>
<cp:block>
<cp:blockM>
<xsl:if test="string-length(./h:h6/text()) > 0">
<sp:title>
<xsl:value-of select="./h:h6"/>
</sp:title>
</xsl:if>
</cp:blockM>
<sp:body>
<cp:flow>
<xsl:apply-templates select="./*"/>
</cp:flow>
</sp:body>
</cp:block>
</sp:advice>
</xsl:when>
<!-- hdoc's definition = canoprof's definition -->
<xsl:when test="./@data-hdoc-type = 'definition'">
<sp:definition>
<cp:block>
<cp:blockM>
<xsl:if test="string-length(./h:h6/text()) > 0">
<sp:title>
<xsl:value-of select="./h:h6"/>
</sp:title>
</xsl:if>
</cp:blockM>
<sp:body>
<cp:flow>
<xsl:apply-templates select="./*"/>
</cp:flow>
</sp:body>
</cp:block>
</sp:definition>
</xsl:when>
<!-- hdoc's example = canoprof's example -->
<xsl:when test="./@data-hdoc-type = 'example'">
<sp:example>
<cp:block>
<cp:blockM>
<xsl:if test="string-length(./h:h6/text()) > 0">
<sp:title>
<xsl:value-of select="./h:h6"/>
</sp:title>
</xsl:if>
</cp:blockM>
<sp:body>
<cp:flow>
<xsl:apply-templates select="./*"/>
</cp:flow>
</sp:body>
</cp:block>
</sp:example>
</xsl:when>
<!-- hdoc's remark = canoprof's hypothesis (NOT EXPLICIT...) -->
<xsl:when test="./@data-hdoc-type = 'remark'">
<sp:hypothesis>
<cp:block>
<cp:blockM>
<xsl:if test="string-length(./h:h6/text()) > 0">
<sp:title>
<xsl:value-of select="./h:h6"/>
</sp:title>
</xsl:if>
</cp:blockM>
<sp:body>
<cp:flow>
<xsl:apply-templates select="./*"/>
</cp:flow>
</sp:body>
</cp:block>
</sp:hypothesis>
</xsl:when>
<!-- hdoc's emphasis = canoprof's method (NOT EXPLICIT...) -->
<xsl:when test="./@data-hdoc-type = 'emphasis'">
<sp:method>
<cp:block>
<cp:blockM>
<xsl:if test="string-length(./h:h6/text()) > 0">
<sp:title>
<xsl:value-of select="./h:h6"/>
</sp:title>
</xsl:if>
</cp:blockM>
<sp:body>
<cp:flow>
<xsl:apply-templates select="./*"/>
</cp:flow>
</sp:body>
</cp:block>
</sp:method>
</xsl:when>
<!-- hdoc's autres or no attribute = canoprof's information-->
<xsl:otherwise>
<sp:info>
<cp:block>
<xsl:if test="string-length(./h:h6/text()) > 0">
<cp:blockM>
<sp:title>
<xsl:value-of select="./h:h6"/>
</sp:title>
</cp:blockM>
</xsl:if>
<sp:body>
<cp:flow>
<xsl:apply-templates select="./*"/>
</cp:flow>
</sp:body>
</cp:block>
</sp:info>
<!--
<sp:body> <sp:body>
<cp:flow> <cp:flow>
<xsl:if test="./h:p/text()"> <xsl:apply-templates select="./*"/>
<xsl:apply-templates select="./*"/>
</xsl:if>
</cp:flow> </cp:flow>
</sp:body> </sp:body>
</cp:block> -->
</sp:definition> </xsl:otherwise>
<!--</xsl:element>--> </xsl:choose>
</xsl:template> </xsl:template>
<!-- Text related templates --> <!-- Text related templates -->
......
Supports Markdown
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