You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

131 lines
2.6 KiB

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