arnaucube
arnaucube/padArchiverPublic Self-hosted repository
padArchiver/README.md
README.mdRaw
  1# padArchiver [![Go Report Card](https://goreportcard.com/badge/github.com/arnaucode/padArchiver)](https://goreportcard.com/report/github.com/arnaucode/padArchiver)
  2
  3Tool to store pads (from url) into local directory and IPFS.
  4
  5The tool is composed by different tools around the library:
  6- webServer
  7- listPadsImporter
  8- apiServer
  9- cli
 10
 11All the necessary files are in the /build directory. Can be build using the 'bash build.sh' script.
 12
 13## 1.- webServer
 14This is a webserver that automatically generates a web from the pads directories and files stored.
 15To run, inside 'build' directory:
 16```
 17./webServer
 18```
 19
 20![padArchiver-webServer](https://raw.githubusercontent.com/arnaucode/padArchiver/master/padArchiver-webServer.gif)
 21
 22The html template can be easily changed.
 23
 24## 2.- listPadsImporter
 25This is to import all pads from the json file 'list.json'.
 26Just need to edit the json file, for example:
 27```json
 28{
 29  "repoid": "repo01",
 30  "pads": [
 31    {
 32      "link": "http://board.net/p/pad1",
 33      "dir": "Group1",
 34      "title": "Pad1"
 35    },
 36    {
 37      "link": "http://board.net/p/pad2",
 38      "dir": "Group1",
 39      "title": "Pad2"
 40    },
 41    {
 42      "link": "http://board.net/p/pad3",
 43      "dir": "Group2",
 44      "title": "Pad3"
 45    }
 46  ]
 47}
 48```
 49To run, inside 'build' directory:
 50```
 51./importFromList
 52```
 53
 54## 3.- apiServer
 55This is an API to run in localhost.
 56
 57#### Run
 58To run using the compiled binary:
 59- The Git repo needs to be initialized, and with the remote already configured.
 60- The IPFS daemon needs to be running:
 61```
 62> ipfs daemon
 63```
 64
 65- Edit the file config.json to configure the desired port:
 66```
 67{
 68  "port": "3080"
 69}
 70```
 71
 72- Execute the API server, inside the directory 'build':
 73```
 74> ./padArchiver-APIserver
 75```
 76
 77#### API Routes
 78
 79##### - GET /repos
 80this returns:
 81```
 82[
 83  'repo01',
 84  'repo02'
 85]
 86```
 87
 88
 89##### - GET /repos/{repoid}
 90this returns:
 91```
 92[
 93  'repo01',
 94  'repo01/Group1',
 95  'repo01/Group1/Pad1.md',
 96  'repo01/Group2',
 97  'repo01/Group2/Pad2.md',
 98  'repo01/Group2/Pad3.md',
 99  'repo02/GroupA/Pad1.md'
100]
101```
102
103
104##### - POST /repos/{repoid}/pad
105data to send:
106```
107json: {
108  "link": "http://board.net/p/pad1",
109  "dir": "Group1",
110  "title": "Pad1"
111}
112```
113this returns:
114```
115{
116  "link": "http://board.net/p/pad1",
117  "dir": "Group1",
118  "title": "Pad1",
119  "ipfsHash": "QmVyp4JSREK5syLmNRCafkZkhzC7CfvS9qYWKfvfffqK2B"
120}
121```
122The IPFS hash is also added to the first line of the document, before adding the document to Git.
123
124## 4.- cli
125To run the CLI, just need to run inside the directory 'build':
126```
127./padArchiver-cli
128```
129And follow the instructions.
130
131![padArchiver-cli](https://raw.githubusercontent.com/arnaucode/padArchiver/master/padArchiver-cli.png)