aboutsummaryrefslogtreecommitdiff
path: root/src/server
diff options
context:
space:
mode:
authormonikahedman <monika_hedman@brown.edu>2019-08-08 15:03:03 -0400
committermonikahedman <monika_hedman@brown.edu>2019-08-08 15:03:03 -0400
commit8f951d9110d096d665af6fbd295902ef8d3574e8 (patch)
tree37cc6881cbf93aeea5deae53a6415d6607377edc /src/server
parent030af1b9112cd12383abcd7f35142cc382ea4d6a (diff)
parent316c241d72fb83aad5f2bf9b143c317fdc906654 (diff)
Merge branch 'master' of https://github.com/browngraphicslab/Dash-Web into checkbox
Diffstat (limited to 'src/server')
-rw-r--r--src/server/GarbageCollector.ts2
-rw-r--r--src/server/authentication/models/current_user_utils.ts2
-rw-r--r--src/server/index.ts29
-rw-r--r--src/server/remapUrl.ts2
4 files changed, 32 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/authentication/models/current_user_utils.ts b/src/server/authentication/models/current_user_utils.ts
index 1c52a3f11..91d7ba87d 100644
--- a/src/server/authentication/models/current_user_utils.ts
+++ b/src/server/authentication/models/current_user_utils.ts
@@ -71,7 +71,7 @@ export class CurrentUserUtils {
doc.sidebar = sidebar;
}
StrCast(doc.title).indexOf("@") !== -1 && (doc.title = StrCast(doc.title).split("@")[0] + "'s Library");
-
+ doc.width = 100;
}
public static loadCurrentUser() {
diff --git a/src/server/index.ts b/src/server/index.ts
index 10a84c823..29b44713c 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';
@@ -148,6 +148,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,