README.md 3.82 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14
# Hdoc to Mongo (`hdoc_to_mongo`)

## License
License GPL3.0
http://www.gnu.org/licenses/gpl-3.0.txt

## Credits
Alexandre Thouvenin
Kapilraj Thangeswaran

## Presentation
This module is able to extract data from a file in Hdoc format and insert them into MongoDB.

## Dependencies
15 16
In order to work properly this module needs :
- to download and install Node.js
17
    - For windows :
18
        - from the [Node.js download page](https://nodejs.org/en/)
19
    - For linux (instruction for debian 8, may vary depending on your distrbution) execute the followings commands :
20 21 22 23
        - `su`
        - `apt install nodejs`
        - `apt install node`
        - `apt install npm`
Nyashes's avatar
Nyashes committed
24
	- `npm link mongodb`
25 26

- to download and install MongoDB 
27
    - For Windows :
28
        - from the [MongoDB download page](https://www.mongodb.com/download-center#community)
29
    - For linux : 
Nyashes's avatar
Nyashes committed
30 31 32 33 34
	- `# apt install mongodb`
	- `# echo 'jsonp=true' >> /etc/mongodb.conf`
	- `# echo 'rest=true' >> /etc/mongodb.conf`
	- on a virtual machine or a small system ONLY : `# echo 'smallfiles=true' >> /etc/mongodb.conf`
	- `# service mongodb restart`
35

36
## Instructions
37
1. Install dependencies
38 39 40
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 (for more details, please check "Mongo configuration")
41
5. Make sure that MongoDB is running (`mongod.exe --rest --jsonp` command from "MongoDB/Server/3.2/bin" folder)
42
6. Execute run.bat or chmod +x run.sh & ./run.sh
43

44 45 46 47 48 49
## Web
This module provides a Web application to access MongoDB and execute simples requests.
1. Launch MongoDB using `mongod.exe --rest --jsonp` command from "MongoDB/Server/3.2/bin" folder.
2. Edit "config.json" file from "web" folder (for more details, please check "MongoDB configuration")
3. Open "index.html" in "web" folder

Nyashes's avatar
Nyashes committed
50 51 52 53 54 55 56
## Setting up a mongodb server as service on linux
`# apt install mongodb`
`# echo 'jsonp=true' >> /etc/mongodb.conf`
`# echo 'rest=true' >> /etc/mongodb.conf`
on a virtual machine or a small system ONLY : `# echo 'smallfiles=true' >> /etc/mongodb.conf`
`# service mongodb restart`

57 58 59 60 61 62 63
## 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>
64
	<file name='sample.scar'>
65 66 67 68 69
		<link>https://stph.scenari-community.org/nf17/co/nf17.html</link>
	</file>
</config>
```

70 71
## MongoDB configuration
### In "mongo" folder
72
Use "config.json" in the "mongo" folder to specify
73 74 75 76
- 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")
77
```
78 79 80 81 82 83 84 85 86
{
	"url" : "mongodb://localhost:27017/",
	"database" : "database",
	"collection" : "collection",
	"request" : "insert"
}
```

### In "web" folder
87
Use "config.json" in the "web" folder to specify
88
- url : mongodb's url including the database
89
- collection : the collection you are using
90
```
91
{
92
	"url" : "mongodb://localhost:27017/database",
93 94 95
	"collection" : "collection",
}
```
96 97 98

## Supported requests
- insert
99 100
- update (using the title as filter)
- remove (using the title as filter)
101

102
## User stories
103 104
- 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.
105
- 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.