@@ -3,10 +3,8 @@ var YAML = require('yaml');
33var createHandler = require ( 'github-webhook-handler' ) ;
44var handler = createHandler ( { path : '/MY_SECRET_PATH' , secret : 'MY_SECRET_KEY' } ) ;
55const elasticsearch = require ( 'elasticsearch' ) ;
6- const esHost = 'localhost:9200' ;
7- const articlePath = '/home/ubuntu/OI-wiki' ;
86var client = new elasticsearch . Client ( {
9- host : esHost ,
7+ host : 'localhost:9200' ,
108} ) ;
119
1210
@@ -48,7 +46,7 @@ function traversalArticle(data, callback) {
4846function getContent ( filename , data ) {
4947 let file ;
5048 try {
51- file = String ( fs . readFileSync ( `${ articlePath } /docs/` + filename ) ) ;
49+ file = String ( fs . readFileSync ( `/home/ubuntu/OI-wiki /docs/` + filename ) ) ;
5250 } catch ( e ) {
5351 console . error ( `Error reading file ${ filename } :` , e ) ;
5452 return [ '' , '' , '' ] ;
@@ -85,7 +83,7 @@ function getContent(filename, data) {
8583 * @param removed - Array of removed files
8684 */
8785function updateContent ( modified , removed ) {
88- const file = String ( fs . readFileSync ( `${ articlePath } /mkdocs.yml` ) ) ;
86+ const file = String ( fs . readFileSync ( `/home/ubuntu/OI-wiki /mkdocs.yml` ) ) ;
8987 const data = YAML . parse ( file . replaceAll ( '!!python/name:' , '' ) ) ;
9088 let ops = [ ] ;
9189 modified . forEach ( ( filename ) => {
@@ -160,9 +158,9 @@ handler.on('push', (event) => {
160158} ) ;
161159
162160function init ( ) {
163- exec ( `curl -X DELETE "http://${ esHost } /oiwiki"` ) ;
161+ exec ( `curl -X DELETE "http://localhost:9200 /oiwiki"` ) ;
164162 let modified = [ ] ;
165- const file = String ( fs . readFileSync ( `${ articlePath } /mkdocs.yml` ) ) ;
163+ const file = String ( fs . readFileSync ( `/home/ubuntu/OI-wiki /mkdocs.yml` ) ) ;
166164 const data = YAML . parse ( file . replaceAll ( '!!python/name:' , '' ) ) ;
167165 traversalArticle ( data [ 'nav' ] , ( key , value ) => modified . push ( value ) ) ;
168166 updateContent ( modified , [ ] ) ;
0 commit comments