diff options
Diffstat (limited to 'src/server')
| -rw-r--r-- | src/server/GarbageCollector.ts | 2 | ||||
| -rw-r--r-- | src/server/index.ts | 30 | ||||
| -rw-r--r-- | src/server/remapUrl.ts | 2 | 
3 files changed, 31 insertions, 3 deletions
| diff --git a/src/server/GarbageCollector.ts b/src/server/GarbageCollector.ts index ea5388004..09b52eadf 100644 --- a/src/server/GarbageCollector.ts +++ b/src/server/GarbageCollector.ts @@ -13,7 +13,7 @@ function addDoc(doc: any, ids: string[], files: { [name: string]: string[] }) {          if (field === undefined || field === null) {              continue;          } -        if (field.__type === "proxy") { +        if (field.__type === "proxy" || field.__type === "prefetch_proxy") {              ids.push(field.fieldId);          } else if (field.__type === "list") {              addDoc(field.fields, ids, files); diff --git a/src/server/index.ts b/src/server/index.ts index 10a84c823..eae018f13 100644 --- a/src/server/index.ts +++ b/src/server/index.ts @@ -1,6 +1,6 @@  require('dotenv').config();  import * as bodyParser from 'body-parser'; -import { exec } from 'child_process'; +import { exec, ExecOptions } from 'child_process';  import * as cookieParser from 'cookie-parser';  import * as express from 'express';  import * as session from 'express-session'; @@ -44,7 +44,6 @@ import * as Archiver from 'archiver';  import * as AdmZip from 'adm-zip';  import * as YoutubeApi from './youtubeApi/youtubeApiSample.js';  import { Response } from 'express-serve-static-core'; -import { DocComponent } from '../client/views/DocComponent';  const MongoStore = require('connect-mongo')(session);  const mongoose = require('mongoose');  const probe = require("probe-image-size"); @@ -148,6 +147,33 @@ app.get("/pull", (req, res) =>          res.redirect("/");      })); +app.get("/buxton", (req, res) => { +    let cwd = '../scraping/buxton'; + +    let onResolved = (stdout: string) => { console.log(stdout); res.redirect("/"); }; +    let onRejected = (err: any) => { console.error(err.message); res.send(err); }; +    let tryPython3 = () => command_line('python3 scraper.py', cwd).then(onResolved, onRejected); + +    command_line('python scraper.py', cwd).then(onResolved, tryPython3); +}); + +const command_line = (command: string, fromDirectory?: string) => { +    return new Promise<string>((resolve, reject) => { +        let options: ExecOptions = {}; +        if (fromDirectory) { +            options.cwd = path.join(__dirname, fromDirectory); +        } +        exec(command, options, (err, stdout) => err ? reject(err) : resolve(stdout)); +    }); +}; + +const read_text_file = (relativePath: string) => { +    let target = path.join(__dirname, relativePath); +    return new Promise<string>((resolve, reject) => { +        fs.readFile(target, (err, data) => err ? reject(err) : resolve(data.toString())); +    }); +}; +  app.get("/version", (req, res) => {      exec('"C:\\Program Files\\Git\\bin\\git.exe" rev-parse HEAD', (err, stdout, stderr) => {          if (err) { diff --git a/src/server/remapUrl.ts b/src/server/remapUrl.ts index 69c766d56..5218a239a 100644 --- a/src/server/remapUrl.ts +++ b/src/server/remapUrl.ts @@ -2,6 +2,8 @@ import { Database } from "./database";  import { Search } from "./Search";  import * as path from 'path'; +//npx ts-node src/server/remapUrl.ts +  const suffixMap: { [type: string]: true } = {      "video": true,      "pdf": true, | 
