From 79e1323acd0d0f95d08a09cefce908e35d0e7558 Mon Sep 17 00:00:00 2001 From: Sam Wilkins Date: Sat, 8 Feb 2020 17:32:33 -0500 Subject: initial commit, pending png read error bug fix --- src/server/ApiManagers/UtilManager.ts | 38 +++++++++++----------- .../authentication/models/current_user_utils.ts | 2 +- 2 files changed, 20 insertions(+), 20 deletions(-) (limited to 'src/server') diff --git a/src/server/ApiManagers/UtilManager.ts b/src/server/ApiManagers/UtilManager.ts index dbf274e93..e590a5b85 100644 --- a/src/server/ApiManagers/UtilManager.ts +++ b/src/server/ApiManagers/UtilManager.ts @@ -4,7 +4,7 @@ import { exec } from 'child_process'; import { command_line } from "../ActionUtilities"; import RouteSubscriber from "../RouteSubscriber"; import { red } from "colors"; -import { main } from "../../scraping/buxton/node_scraper"; +import executeImport from "../../scraping/buxton/final/BuxtonImporter"; export default class UtilManager extends ApiManager { @@ -40,29 +40,29 @@ export default class UtilManager extends ApiManager { } }); - register({ - method: Method.GET, - subscription: "/buxton", - secureHandler: async ({ res }) => { - const cwd = './src/scraping/buxton'; + // register({ + // method: Method.GET, + // subscription: "/buxton", + // secureHandler: async ({ res }) => { + // const cwd = './src/scraping/buxton'; - const onResolved = (stdout: string) => { console.log(stdout); res.redirect("/"); }; - const onRejected = (err: any) => { console.error(err.message); res.send(err); }; - const tryPython3 = (reason: any) => { - console.log("Initial scraper failed for the following reason:"); - console.log(red(reason.Error)); - console.log("Falling back to python3..."); - return command_line('python3 scraper.py', cwd).then(onResolved, onRejected); - }; + // const onResolved = (stdout: string) => { console.log(stdout); res.redirect("/"); }; + // const onRejected = (err: any) => { console.error(err.message); res.send(err); }; + // const tryPython3 = (reason: any) => { + // console.log("Initial scraper failed for the following reason:"); + // console.log(red(reason.Error)); + // console.log("Falling back to python3..."); + // return command_line('python3 scraper.py', cwd).then(onResolved, onRejected); + // }; - return command_line('python scraper.py', cwd).then(onResolved, tryPython3); - }, - }); + // return command_line('python scraper.py', cwd).then(onResolved, tryPython3); + // }, + // }); register({ method: Method.GET, - subscription: "/newBuxton", - secureHandler: async ({ res }) => res.send(await main()) + subscription: "/buxton", + secureHandler: async ({ res }) => res.send(await executeImport()) }); register({ diff --git a/src/server/authentication/models/current_user_utils.ts b/src/server/authentication/models/current_user_utils.ts index 71775bed6..896b88631 100644 --- a/src/server/authentication/models/current_user_utils.ts +++ b/src/server/authentication/models/current_user_utils.ts @@ -58,7 +58,7 @@ export class CurrentUserUtils { { title: "todo item", icon: "check", ignoreClick: true, drag: 'getCopy(this.dragFactory, true)', dragFactory: notes[notes.length - 1] }, { title: "web page", icon: "globe-asia", ignoreClick: true, drag: 'Docs.Create.WebDocument("https://en.wikipedia.org/wiki/Hedgehog", {_width: 300, _height: 300, title: "New Webpage" })' }, { title: "cat image", icon: "cat", ignoreClick: true, drag: 'Docs.Create.ImageDocument("https://upload.wikimedia.org/wikipedia/commons/thumb/3/3a/Cat03.jpg/1200px-Cat03.jpg", { _width: 200, title: "an image of a cat" })' }, - { title: "buxton", icon: "faObjectGroup", ignoreClick: true, drag: "Docs.Create.Buxton()" }, + { title: "buxton", icon: "cloud-upload-alt", ignoreClick: true, drag: "Docs.Create.Buxton()" }, { title: "record", icon: "microphone", ignoreClick: true, drag: `Docs.Create.AudioDocument("${nullAudio}", { _width: 200, title: "ready to record audio" })` }, { title: "clickable button", icon: "bolt", ignoreClick: true, drag: 'Docs.Create.ButtonDocument({ _width: 150, _height: 50, title: "Button" })' }, { title: "presentation", icon: "tv", click: 'openOnRight(Doc.UserDoc().curPresentation = getCopy(this.dragFactory, true))', drag: `Doc.UserDoc().curPresentation = getCopy(this.dragFactory,true)`, dragFactory: emptyPresentation }, -- cgit v1.2.3-70-g09d2 From 10ad4f200e888f98b53a40d35db758c1f4cd445f Mon Sep 17 00:00:00 2001 From: Sam Wilkins Date: Sat, 8 Feb 2020 19:43:11 -0500 Subject: image upload in importer now functional --- src/scraping/buxton/final/BuxtonImporter.ts | 36 +- src/scraping/buxton/final/json/buxton.json | 409 ++++++++++++++++++ src/scraping/buxton/final/json/incomplete.json | 569 +++++++++++++++++++++++++ src/server/ApiManagers/UtilManager.ts | 20 - 4 files changed, 999 insertions(+), 35 deletions(-) create mode 100644 src/scraping/buxton/final/json/buxton.json create mode 100644 src/scraping/buxton/final/json/incomplete.json (limited to 'src/server') diff --git a/src/scraping/buxton/final/BuxtonImporter.ts b/src/scraping/buxton/final/BuxtonImporter.ts index 804d65d74..9c98ec5b0 100644 --- a/src/scraping/buxton/final/BuxtonImporter.ts +++ b/src/scraping/buxton/final/BuxtonImporter.ts @@ -1,6 +1,6 @@ import { readdirSync, writeFile, mkdirSync, createWriteStream, createReadStream, unlinkSync } from "fs"; import * as path from "path"; -import { red, cyan, yellow, green } from "colors"; +import { red, cyan, yellow } from "colors"; import { Utils } from "../../../Utils"; import rimraf = require("rimraf"); const StreamZip = require('node-stream-zip'); @@ -199,7 +199,7 @@ async function extractFileContents(pathToDocument: string): Promise<{ body: stri }); }); }); - const images = (await writeImages(zip)).map(name => `http://localhost:1050/files/images/buxton/${name}`); + const images = await writeImages(zip); zip.close(); let body = ""; const components = contents.toString().split(' { const entryNames = Object.values(zip.entries()).map(({ name }) => name); const resolved: { mediaPath: string, ext: string }[] = []; - let initialWritePath: string; entryNames.forEach(name => { - const matches = /^word\/media\/\w+\.(jpeg|jpg|png|gif)/.exec(name); + const matches = /^word\/media\/\w+(\.jpeg|jpg|png|gif)/.exec(name); matches && resolved.push({ mediaPath: name, ext: matches[1] }); }); - return Promise.all(resolved.map(async ({ mediaPath, ext }) => { - const outName = `upload_${Utils.GenerateGuid()}.${ext}`; - const initialWrite = await new Promise((resolve, reject) => { + const outNames: string[] = []; + for (const { mediaPath, ext } of resolved) { + const outName = `upload_${Utils.GenerateGuid()}${ext}`; + const initialWritePath = path.resolve(imageDir, outName); + await new Promise((resolve, reject) => { zip.stream(mediaPath, (error: any, stream: any) => { if (error) { console.error(error); return reject(error); } - initialWritePath = `${imageDir}/${outName}`; const writeStream = createWriteStream(initialWritePath); - stream.on('end', () => resolve(outName)); + stream.on('end', resolve); stream.on('error', reject); stream.pipe(writeStream); }); @@ -242,16 +242,21 @@ async function writeImages(zip: any): Promise { })) ]; const { pngs, jpgs } = AcceptibleMedia; - if (pngs.includes(ext)) { + const lower = ext.toLowerCase(); + if (pngs.includes(lower)) { resizers.forEach(element => element.resizer = element.resizer.png()); - } else if (jpgs.includes(ext)) { + } else if (jpgs.includes(lower)) { resizers.forEach(element => element.resizer = element.resizer.jpeg()); + } else { + throw new Error(red(initialWritePath + " " + lower)); } for (const { resizer, suffix } of resizers) { await new Promise(resolve => { const filename = InjectSize(outName, suffix); - console.log(filename); - createReadStream(initialWritePath).pipe(resizer).pipe(createWriteStream(`${imageDir}/${filename}`)) + createReadStream(initialWritePath).pipe(resizer).on('error', error => { + console.log(red(error.message) + filename); + resolve(); + }).pipe(createWriteStream(path.resolve(imageDir, filename))) .on('close', resolve) .on('error', error => { console.log(red(error)); @@ -260,8 +265,9 @@ async function writeImages(zip: any): Promise { }); } unlinkSync(initialWritePath); - return initialWrite; - })); + outNames.push(`http://localhost:1050/files/images/buxton/${outName}`); + } + return outNames; } function analyze(pathToDocument: string, { body, images }: DocumentContents): AnalysisResult { diff --git a/src/scraping/buxton/final/json/buxton.json b/src/scraping/buxton/final/json/buxton.json new file mode 100644 index 000000000..35be6f623 --- /dev/null +++ b/src/scraping/buxton/final/json/buxton.json @@ -0,0 +1,409 @@ +[ + { + "title": "3Dconnexion CadMan 3D Motion Controller", + "company": "3Dconnexion", + "year": 2003, + "primaryKey": [ + "Joystick" + ], + "secondaryKey": [ + "Isometric", + "Joystick" + ], + "originalPrice": 399, + "degreesOfFreedom": 6, + "dimensions": { + "dim_length": 175, + "dim_width": 122, + "dim_height": 43, + "dim_unit": "mm" + }, + "shortDescription": "The CadMan is a 6 degree of freedom (DOF) joystick controller. It represented a significant step towards making this class of is controller affordable. It was mainly directed at 3D modelling and animation and was a “next generation” of the Magellan controller, which is also in the collection.", + "longDescription": "The CadMan is a 6 degree of freedom (DOF) joystick controller. It represented a significant step towards making this class of is controller more affordable. It was mainly directed at 3D modelling and animation and was a “next generation” of the Magellan/SpaceMouse controller, which is also in the collection. Like the Magellan, this is an isometric rate-control joystick. That is, it rests in a neutral central position, not sending and signal. When a force is applied to it, it emits a signal indicating the direction and strength of that force. This signal can then be mapped to a parameter of a selected object, such as a sphere, and – for example – cause that sphere to rotate for as long as, and as fast as, and in the direction determined by, the duration, force, and direction of the applied force. When released, it springs back to neutral position. Note that the force does not need to be directed along a single DOF. In fact, a core feature of the device is that one can simultaneously and independently apply force that asserts control over more than one DOF, and furthermore, vary those forces dynamically. As an aid to understanding, let me walk through some of the underlying concepts at play here by using a more familiar device: a computer mouse. If you move a mouse in a forward/backward direction, the mouse pointer on the screen moves between the screen’s top and bottom. If you think of the screen as a piece of graph paper, that corresponds to moving along the “Y” axis. That is one degree of freedom. On the other hand, you could move the mouse left and right, which causes the mouse to move between the left and right side of the screen. That would correspond to moving along the graph paper’s “X” axis – a second degree of freedom. Yet, you can also move the mouse diagonally. This is an example of independently controlling two degrees of freedom. Now imagine that if you lifted your mouse off your desktop, that your computer could dynamically sense its height as you did so. This would constitute a “flying mouse” (the literal translation of the German word for a “Bat”, which Canadian colleague, Colin Ware, applied to just such a mouse which he built in 1988). If you moved your Bat vertically up and down, perpendicular to the desktop, you would be controlling movement along the “Z” axis - a third degree of freedom. Having already seen that we can move a mouse diagonally, we have established that we need not be constrained to only moving along a single axis. That extends to the movement of our Bat and movement along the “Z” axis. We can control our hand movement in dependently in any or all directions in 3D space. But how does one reconcile the fact that we call the CadMan a “3D controller, and yet also describe it as having 6 degrees of freedom? After all, the example this far demonstrates that our Bat, as described thus far, has freedom on movement in 3 Dimensions. While true, we can extend our example to prove that that freedom to move in 3D is also highly constrained. To demonstrate this, move your hand in 3D space on and above your desktop. However, do so keeping your palm flat, parallel to the desktop with your fingers pointing directly forward. In so doing, you are still moving in 3D. Now, while moving, twist your wrist, while moving the hand, such that your palm is alternatively exposed to the left and right side. This constitutes rotation around the “Y” axis. A fourth DOF. Now add a waving motion to your hand, as if it were a paper airplane diving up and down, while also rocking left and right. But keep your fingers pointing forward. You have now added a fifth DOF, rotation around the “X” axis. Finally, add a twist to your wrist so that your fingers are no longer constrained to pointing forward. This is the sixth degree of freedom, rotation around the “Z” axis. Now don’t be fooled, this exercise could continue. We are not restricted to even six DOF. Imagine doing the above, but where the movement and rotations are measured relative to the Bat’s position and orientation, rather than to the holding/controlling hand, per se. One could imagine the Bat having a scroll wheel, like the one on most mice today. Furthermore, while flying your Bat around in 3D, that wheel could easily be rolled in either forward or backward, and thereby control the size of whatever was being controlled. Hence, with one hand we could assert simultaneous and independent control over 7 DOF in 3D space. This exercise has two intended take-aways. The first is a better working understanding between the notion of Degree of Freedom (DOF) and Dimension in space. Hopefully, the confusion frequently encountered when 3D and 6DOF are used in close context, can now be eliminated. Second, is that, with appropriate sensing, the human hand is capable of exercising control over far more degrees of freedom that six. And if we use the two hands together, the potential number of DOF that one can control goes even further. Finally, it is important to add one more take-away – one which both emerges from, and is frequently encountered when discussing, the previous two. That is, do not equate exercising simultaneous control over a high number of DOF with consciously doing the same number of different things all at once. The example that used to be thrown at me when I started talking about coordinated simultaneously bi-manual action went along the lines of, “Psychology tells us that we cannot do multiple things at once, for example, simultaneously tapping your head and rubbing your stomach. ”Well, first, I can tap my head with one hand while rubbing my stomach with the other. But that is not the point. The whole essence of skill – motor-sensory and cognitive – is “chunking” or task integration. When one appears to be doing many different things at once, if they are skilled, they are consciously doing only one thing. Playing a chord on the piano, for example, or skiing down the hill. Likewise, in flying your imaginary BAT in the previous exercise with the scroll wheel, were you doing 7 things at once, or one thing with 7 DOF? And if you had a Bat in each hand, does that mean you are now doing 14 things at once, or are you doing one thing with 14 DOF? Let me provide a different way of answering this question: if you have ever played air guitar, or “conducted” the orchestra that you are listening to on the radio, you are exercising control over more than 14 DOF. And you are doing exactly what I just said, “playing air guitar” or “conducting an orchestra”. One thing – at the conscious level, which is what matters – despite almost any one thing being able to be deconstructed into hundreds of sub-tasks. As I said the essence of skill: aggregation, or chunking. What is most important for both tool designers and users to be mindful of, is the overwhelming influence that our choice and design of tools impacts the degree to which such integration or chunking can take place. The degree to which the tool matches both the skills that we have already acquired through a lifetime of living in the everyday world, and the demands of the intended task, the more seamless that task can be performed, the more “natural” it will feel, and the less learning will be required. In my experience, it brought particular value when used bimanually, in combination with a mouse, where the preferred hand performed conventional pointing, selection and dragging tasks, while the non-preferred hand could manipulate the parameters of the thing being selected. First variation of the since the 2001 formation of 3Dconnextion. The CadMan came in 5 colours: smoke, orange, red, blue and green. See the notes for the LogiCad3D Magellan for more details on this class of device. It is the “parent” of the CadMan, and despite the change in company name, it comes from the same team.", + "__images": [ + "http://localhost:1050/files/images/buxton/upload_65cb89ee-88a5-48d9-ac89-194a0ae41f98.jpeg" + ] + }, + { + "title": "Adesso ACK-540UB USB Mini-Touch Keyboard with Touchpad", + "company": "Adesso", + "year": 2005, + "primaryKey": [ + "Keyboard" + ], + "secondaryKey": [ + "Pad", + "Touch" + ], + "originalPrice": 59.95, + "degreesOfFreedom": 2, + "dimensions": { + "dim_length": 287, + "dim_width": 140, + "dim_height": 35.5, + "dim_unit": "mm" + }, + "shortDescription": "The Mini-Touch Keyboard is a surprisingly rare device: a laptop-style, small-footprint keyboard with a centrally mounted touch-pad. .", + "longDescription": "First released in 2003 with a PS/2 connector (ACK-540PW & ACK-540PB). USB version released in 2006 in either black (ACK-540UB) or white (ACK-540UW). Marketed under different brands, including SolidTek: http: //www. tigerdirect. com/applications/searchtools/item-details. asp? EdpNo=1472243https: //acecaddigital. com/index. php/products/keyboards/mini-keyboards/kb-540 Deltaco: https: //www. digitalimpuls. no/logitech/116652/deltaco-minitastatur-med-touchpad-usb", + "__images": [ + "http://localhost:1050/files/images/buxton/upload_fdcdb560-03d7-4d96-8653-eb7497a5a6be.jpeg", + "http://localhost:1050/files/images/buxton/upload_22af6f24-1bd7-497c-a111-e3536790ab31.jpeg", + "http://localhost:1050/files/images/buxton/upload_d942b775-5c7f-4899-8eae-cb8f956df846.jpeg", + "http://localhost:1050/files/images/buxton/upload_94d78d8e-ff44-42a2-93d3-2c6ddf395783.jpeg", + "http://localhost:1050/files/images/buxton/upload_5e9b5174-e6ba-4182-a8c9-fd1081e635e8.jpeg" + ] + }, + { + "title": "Braun AG T3 Transistor Radio", + "company": "Braun AG", + "year": 1958, + "primaryKey": [ + "Radio" + ], + "secondaryKey": [ + "Handheld", + "Object", + "Reference" + ], + "originalPrice": 28.57, + "degreesOfFreedom": 2, + "dimensions": { + "dim_length": 152, + "dim_width": 41, + "dim_height": 83, + "dim_unit": "mm" + }, + "shortDescription": "The 1958 Braun T3 transistor radio, designed by Dieter Rams Dieter Rams in conjunction with the Ulm Hochschüle fur Gestaltung (School of Design). An excellent example of the international style of design of the mid-20th century, the T3 radio was the inspiration for the design language of the Apple iPod Classic.", + "longDescription": "The 1958 Braun T3 transistor radio is a classic of the international design style prevalent in the mid-20th century. By its sparse clean lines, it shares characteristics of the style seen in another familiar example, the font Helvetic, which was designed the previous year. The T3 was designed by Dieter Rams, recruited by Braun in 1955, in collaboration with the Ulm Hochschüle fur Gestaltun. . Its design language had a strong influence on that of the original Apple iPod Classic. The connection is made more obvious if one views the radio rotated 90° clockwise, as in one of the accompanying photographs. Here one can easily see the the similarity of proportions, uniformity of colour, angle of corners, location of display (audio versus visual), and the use of a flush rotary wheel controller.", + "__images": [ + "http://localhost:1050/files/images/buxton/upload_c405d7d8-4e1f-4273-9b25-d2c9fede8ca4.jpeg", + "http://localhost:1050/files/images/buxton/upload_88a638bd-f1b8-4b27-b004-29595e756f99.jpeg", + "http://localhost:1050/files/images/buxton/upload_01bbb598-5ddd-49d3-9844-2bdc4a1ce3c0.jpeg", + "http://localhost:1050/files/images/buxton/upload_4c362bd9-0ad2-463b-b3e8-363eb84f6975.jpeg", + "http://localhost:1050/files/images/buxton/upload_6e5ba351-f26a-4926-9e2b-d1673e990cf2.jpeg", + "http://localhost:1050/files/images/buxton/upload_c073327a-cbcf-40f1-96f8-cd1733e4da97.jpeg", + "http://localhost:1050/files/images/buxton/upload_0133a88b-bb20-44b1-9f5f-3825c928fa4a.jpeg", + "http://localhost:1050/files/images/buxton/upload_609a8e9f-d3cb-4f06-929c-c0fc105b4d15.jpeg", + "http://localhost:1050/files/images/buxton/upload_0b06ad42-6cd3-460d-9f85-019dfc4834e8.jpeg", + "http://localhost:1050/files/images/buxton/upload_339e2c3d-2422-485b-a75f-e2f91409616f.jpeg", + "http://localhost:1050/files/images/buxton/upload_ff5bcbf8-cebd-4e54-a957-133b39e30ed9.jpeg" + ] + }, + { + "title": "Casio CZ-101 Digital Synthesizer", + "company": "Casio", + "year": 1984, + "primaryKey": [ + "Synthesizer" + ], + "secondaryKey": [ + "Chord", + "Keyboard", + "Object", + "Reference", + "Wheel" + ], + "originalPrice": 499, + "degreesOfFreedom": 1, + "dimensions": { + "dim_length": 20, + "dim_width": 65.7, + "dim_height": 58, + "dim_unit": "mm" + }, + "shortDescription": "One of the first programable polyphonic (8 simultaneous voices) digital synthesizers for less than $500. 00. Used a form of digital synthesis known as Phase Distortion to obtain a rich variety of dynamic timbres. Could be used with batteries or plugged in to power. This one was given to me at the product launch.", + "longDescription": "One of the first programable polyphonic (8 simultaneous voices) digital synthesizers for less than $500. 00. Used a form of digital synthesis known as Phase Distortion to obtain a rich variety of dynamic timbres. Could be used with batteries or plugged in to power. This one was given to me at the product launch. The inclusion of this synthesizer in the collection is as a small reminder of the diversity of keyboard types, and especially, as an example to shed light on chord keyboards. In entering text, for example, chord keyboards are those where more than one key must be simultaneously pressed to enter a single character. Technically, this includes any keyboard with a SHIFT key. Interestingly, piano-type like keyboards like that on the Casio-CZ-101 probably don’t conform to this definition of chording, despite its ability to play musical chords. On the other hand, flutes and trumpets definitely do fall within the definition. Why? With piano-like keyboards, each unique note has a single unique key dedicated to it. When one plays a chord, i. e. , simultaneously presses multiple keys, the result is a chord of notes – the note associated with each depressed key sounds. On the other hand, with trumpet valves or flute keys, only one note is produced at a time. It is the combination of keys pressed (coupled with breath) which determines the pitch of that single note. This is far closer to entering text with a chord keyboard, where each chord enters a single unique character.", + "__images": [ + "http://localhost:1050/files/images/buxton/upload_071a80d0-10e7-4c88-9b98-06c8f00cd651.jpeg", + "http://localhost:1050/files/images/buxton/upload_b30deca6-f704-4a2e-a211-a357b7a8cd7f.jpeg", + "http://localhost:1050/files/images/buxton/upload_7170825e-2362-41d6-8793-9da98c4377fb.jpeg", + "http://localhost:1050/files/images/buxton/upload_c81c1438-bc91-4278-8376-0a6daf152bdc.jpeg", + "http://localhost:1050/files/images/buxton/upload_4b6cd630-d985-4851-9a5b-ae8321684cd1.jpeg", + "http://localhost:1050/files/images/buxton/upload_2de8214f-1b39-425f-bf48-a26914028956.jpeg", + "http://localhost:1050/files/images/buxton/upload_2956e41d-3b23-455d-90cc-5fdffabfb40c.jpeg" + ] + }, + { + "title": "Contour Design UniTrap ", + "company": "Contour Design", + "year": 1999, + "primaryKey": [ + "Re-skin" + ], + "secondaryKey": [ + "Mouse" + ], + "originalPrice": 14.99, + "degreesOfFreedom": 2, + "dimensions": { + "dim_length": 130.5, + "dim_width": 75.7, + "dim_height": 43, + "dim_unit": "mm" + }, + "shortDescription": "This is a plastic shell within which the round Apple iMac G3 “Hockey Puck” mouse can be fit. While the G3 Mouse worked well mechanically, when gripped its round shape gave few cues as to its orientation. Hence, if you moved your hand up, the screen pointer may well have moved diagonally. By reskinning it with the inexpensive Contour UniTrap, the problem went away without the need to buy a whole new mouse.", + "longDescription": "Also add back pointers from devices re-skinned", + "__images": [ + "http://localhost:1050/files/images/buxton/upload_95ffc881-bd56-4234-9a91-6b354e5a8811.jpeg", + "http://localhost:1050/files/images/buxton/upload_4539a934-9769-4138-8956-9f987693eada.jpeg", + "http://localhost:1050/files/images/buxton/upload_d3a3623d-5084-45c5-baf6-83580e45f8f9.jpeg", + "http://localhost:1050/files/images/buxton/upload_fdba55ec-2b46-433f-ad27-899e6774ed30.jpeg", + "http://localhost:1050/files/images/buxton/upload_53ef39dd-0cd2-4a61-8269-753a85fff568.jpeg", + "http://localhost:1050/files/images/buxton/upload_b57d9249-95ea-4b9b-a7e5-a6aab2dfd474.jpeg", + "http://localhost:1050/files/images/buxton/upload_09ae658a-e8b6-4e37-b83b-af6264d6b926.jpeg", + "http://localhost:1050/files/images/buxton/upload_9a067bf4-0c21-4dce-a149-9f3224c8a8b3.jpeg", + "http://localhost:1050/files/images/buxton/upload_dbacb2b3-eeb4-45bf-b72d-73ac36620a60.jpeg", + "http://localhost:1050/files/images/buxton/upload_241b31c3-1e11-4303-a445-44e500b3126f.jpeg", + "http://localhost:1050/files/images/buxton/upload_193ed17e-8291-4363-8f44-55b2a5f812af.jpeg", + "http://localhost:1050/files/images/buxton/upload_20f73424-c824-4eb0-b555-655dd718db7d.jpeg", + "http://localhost:1050/files/images/buxton/upload_8fc9b3b4-ce66-47b9-b94d-3ed14f8e9751.jpeg", + "http://localhost:1050/files/images/buxton/upload_ffaedf7e-4189-4f70-bd5e-1a08ba2ea8ba.jpeg" + ] + }, + { + "title": "Depraz Swiss Mouse", + "company": "Depraz", + "year": 1980, + "primaryKey": [ + "Mouse" + ], + "secondaryKey": [ + "Ball", + "Chord", + "Keyboard", + "Mouse" + ], + "originalPrice": 295, + "degreesOfFreedom": 2, + "dimensions": { + "dim_length": 50.8, + "dim_width": 76.2, + "dim_height": 114.3, + "dim_unit": "mm" + }, + "shortDescription": "This mouse is one of the first commercially available mice to be sold publicly. It is known as the Swiss mouse, and yes, the roller mechanism was designed by a Swiss watchmaker. Coincidentally, the company that made it, Depraz, is based in Apples, Switzerland. Their success in selling this mouse is what caused Logitech to switch from a software development shop to one of the world’s leading suppliers of mice and other input devices.", + "longDescription": "DePraz began manufacturing in 1980, but following design built in 1979. Logitech started selling it in 1982. It was one of the first mass produced mice, one of the first available ball mice, as well as to have an optical shaft encoder – thereby improving linearity. An interesting fact, given its Swiss heritage, is that its designer, André Guignard, was trained as a Swiss watch maker. Unlike most modern mice, the DePraz, or “Swiss” mouse had a quasi-hemispherical shape. Hence, it was held in a so-called “power-grip”, much as one would grip a horizontally held ball – the thumb and small finger applying pressure on each side, with added support from the weight/friction of the palm on the back of the mouse. In this posture, the three middle fingers naturally positioning themselves over the three buttons mounted at the lower edge of the front. Largely freed of grip pressure, by grace of thumb and little finger, the middle fingers had essentially freedom of motion to independently operate the buttons. Each having a dedicated finger, the buttons could be easily pushed independently or in any combination. Like the three valves on a trumpet, this ability to “chord” extended the three physical buttons to have the power of seven. The down-side of this “turtle shell” form factor is that it placed the hand in a posture in which mouse movement relied more of the larger muscle groups of the arm to wrist, rather than wrist to fingers – the latter being the approach taken in most subsequent mice. The original Swiss Mouse was developed at École Polytechnique Fédérale de Lausanne by a project led by Jean-Daniel Nicoud, who was also responsible for the development of its optical shaft encoder. To augment their revenue stream, Logitech, then a software and hardware consulting company for the publishing industry, acquired marketing rights for North America. Mouse revenue quickly overshadowed that from software. In 1983, Logitech acquired DePraz, named the Swiss Mouse the “P4”, and grew to become one of the largest input device manufacturer in the world. One curious coincidence is that they were founded in the town of Apples, Switzerland.", + "__images": [ + "http://localhost:1050/files/images/buxton/upload_a4e54d14-93b4-4e7e-8ca3-404679b3610d.jpeg", + "http://localhost:1050/files/images/buxton/upload_2c399205-2e53-4601-a2f4-8f30ae8645c0.jpeg", + "http://localhost:1050/files/images/buxton/upload_979acbde-8d24-43c7-a070-2911f9fe625a.jpeg", + "http://localhost:1050/files/images/buxton/upload_ed8a92e2-cd5f-4b66-959f-57ecd67043fd.jpeg", + "http://localhost:1050/files/images/buxton/upload_7e2fbd60-1fe3-4ed4-9db8-ff377591abab.jpeg", + "http://localhost:1050/files/images/buxton/upload_568a763c-6d2e-49a9-b1fe-dbbac19ca1c4.jpeg", + "http://localhost:1050/files/images/buxton/upload_7ae37170-c881-407e-9f50-e4b04ed6444b.jpeg", + "http://localhost:1050/files/images/buxton/upload_b7318579-d4d6-4a79-b335-f1836bf6dd78.jpeg", + "http://localhost:1050/files/images/buxton/upload_10c77ad9-a215-465e-b413-25aa7d903924.jpeg", + "http://localhost:1050/files/images/buxton/upload_89acc088-062c-4469-8781-fbceb9e8485a.jpeg", + "http://localhost:1050/files/images/buxton/upload_92fea7aa-b629-450b-bd79-5ff0bbea33cd.jpeg" + ] + }, + { + "title": "FingerWorks TouchStream LP", + "company": "FingerWorks", + "year": 2002, + "primaryKey": [ + "Keyboard" + ], + "secondaryKey": [ + "Foldable", + "Gesture", + "Keyboard", + "Multi-touch", + "Reskin", + "Touchpad" + ], + "originalPrice": 339, + "degreesOfFreedom": 2, + "dimensions": { + "dim_length": 180, + "dim_width": 140, + "dim_height": 9, + "dim_unit": "mm" + }, + "shortDescription": "The TouchStream is a keyboard based on a pair of multi-touch pads. These can sense key taps and finger gestures. The “keys” are graphic. They are flush with the pad and have no mechanical movement. There are however, small raised points to help position the hands on the keyboard eyes-free typing, but these still allow the fingers slide easily on the surface when gesturing, such as when emulating a mouse. . The keyboard is independent of the base. It can be folded in half for compact portability. It can also be placed conveniently over a laptop’s keyboard as a replacement which then also enables the gesture enhancements to be used on the road. Although not obvious to the eye, this is the core technology which, after being acquired by Apple, evolved into the iPhone’s multi-touch capability.", + "longDescription": "Named FingerBoard during development, this product was relabeled TouchStream in October 2001 as the release date approached. when finally shipped, was renamed TouchStreamThe very rare original stand for this device was a gift from Sean Gerety, Atlanta, GA.", + "__images": [ + "http://localhost:1050/files/images/buxton/upload_27c393d7-ab12-4684-b5ac-3ff810565c80.jpeg", + "http://localhost:1050/files/images/buxton/upload_4137999f-13bf-4106-83cf-bf68901b74fe.jpeg", + "http://localhost:1050/files/images/buxton/upload_1bea7829-9a36-4446-acc3-5d6e5c3e89da.jpeg", + "http://localhost:1050/files/images/buxton/upload_dc79cd33-92d7-4efa-b15c-8a78b4dc805b.jpeg", + "http://localhost:1050/files/images/buxton/upload_dbd7e531-c4c1-44f8-93eb-54d06cf59e02.jpeg", + "http://localhost:1050/files/images/buxton/upload_7f467bf9-c508-4879-b115-756a9649755c.jpeg", + "http://localhost:1050/files/images/buxton/upload_faac6f26-8082-4f55-b98e-7e7d91f64ea0.jpeg", + "http://localhost:1050/files/images/buxton/upload_1339552a-d9ce-4690-945c-e357f1bf52f4.jpeg", + "http://localhost:1050/files/images/buxton/upload_1b8dff2d-2b84-4748-8b12-5102f9e3fa32.jpeg", + "http://localhost:1050/files/images/buxton/upload_d4e40dcf-a7fe-47c2-a7c8-9f9c74c60047.jpeg", + "http://localhost:1050/files/images/buxton/upload_7cac0f8d-e2af-445f-95d4-b18e28da44c2.jpeg", + "http://localhost:1050/files/images/buxton/upload_b7f1da77-e56a-406d-af43-53fe54ff71ee.jpeg", + "http://localhost:1050/files/images/buxton/upload_6e568712-77d3-4a50-8fdb-9cd997b0b881.jpeg" + ] + }, + { + "title": "One Laptop Per Child (OLPC) XO-1", + "company": "One Laptop Per Child (OLPC)", + "year": 2007, + "primaryKey": [ + "Computer" + ], + "secondaryKey": [ + "Keyboard", + "Laptop", + "Pad", + "Slate", + "Touch" + ], + "originalPrice": 199, + "degreesOfFreedom": 2, + "dimensions": { + "dim_length": 242, + "dim_width": 228, + "dim_height": 30, + "dim_unit": "mm" + }, + "shortDescription": "The OLPC XO-1 is very innovative device that nevertheless raises serious issues about technology and social responsibility. It is included in the collection primarily as a warning against technological hubris, and the fact that no technologies are neutral from a social-cultural perspective.", + "longDescription": "IntroductionI have this computer in my collection as a reminder of the delicate relationship between object and purpose, and how no matter how well one does on the former, it will likely have no impact on making a wanting concept achieve the stated (and even valid) purpose any better. I include it in the collection as a cautionary tale of how the object may help sell a concept, regardless how ill-conceived – even to those who should know better, had they applied the most basic critical thinking. For consumers, investors and designers, its story serves as a cautionary reminder to the importance of cultivating and retaining a critical mind and questioning perspective, regardless of how intrinsically seductive or well-intentioned a technology may be. From the perspective of hardware and software, what the One Laptop Per Child (OLPC) project was able to accomplish is impressive. In general, the team delivered a computer that could be produced at a remarkably low price – even if about double that which was targeted. Specifically, the display, for example, is innovative, and stands out due to its ability to work both in the bright sun (reflective) as well as in poorly lit spaces (emissive) – something that goes beyond pretty much anything else that is available on today’s (2017) slate computers or e-readers. In short, some excellent work went into this machine, something that is even more impressive, given the nature of the organization from which it emerged. The industrial design was equally impressive. Undertaken by Yves Behar’s FuseprojectUltimately, however, the machine was a means to an end, not the end itself. Rather than a device, the actual mission of the OLPC project was: … to empower the world's poorest children through education. Yet, as described by in their materials, the computer was intended to play a key role in this: With access to this type of tool [the computer], children are engaged in their own education, and learn, share, and create together. They become connected to each other, to the world and to a brighter future. Hence, making a suitable computer suitable to that purpose and the conditions where it would be used, at a price point that would enable broad distribution, was a key part of the project. The Underlying Belief System of the OLPC ProjectSince they are key to the thinking behind the OLPC project, I believe if fair to frame my discussion around the following four questions: Will giving computers to kids in the developing world improve their education? Will having a thus better-educated youth help bring a society out of poverty? Can that educational improvement be accomplished by giving the computers to the kids, with no special training for teachers? Should this be attempted on a global scale without any advance field trials or pilot studies? From the perspective of the OLPC project, the answer to every one of these questions is an unequivocal “yes”. In fact, as we shall see, any suggestion to the contrary is typically answered by condescension and/or mockery. The answers appear to be viewed as self-evident and not worth even questioning. Those who have not subscribed to this doctrine might call such a viewpoint hubris. What staggers me is how the project got so far without the basic assumptions being more broadly questioned, much less such questions being seriously addressed by the proponents. How did seemingly otherwise people commit to the project, through their labour or financial investment, given the apparently naïve and utopian approach that it took? Does the desire to do good cloud judgment that much? Are we that dazzled by a cool technology or big hairy audacious goal? Or by a charismatic personality? To explain my concern, and what this artifact represents to me, let me just touch on the four assumptions on which the project was founded. Will giving computers to kids in the developing world improve education? The literature on this question is, at best, mixed. What is clear is that one cannot make any assumption that such improvements will occur, regardless of whether one is talking about the developing world or suburban USA. For example, in January 2011, The World Bank published the following study: Can Computers Help Students Learn? From Evidence to Policy, January 2011, Number 4, The World Bank. A public-private partnership in Colombia, called Computers for Education, was created in 2002 to increase the availability of computers in public schools for use in education. Since starting, the program has installed more than 73, 000 computers in over 6, 300 public schools in more than 1, 000 municipalities. By 2008, over 2 million students and 83, 000 teachers had taken part. This document reports on a two-year study to determine the impact of the program on student performance. Students in schools that received the computers and teacher training did not do measurably better on tests than students in the control group. Nor was there a positive effect on other measures of learning. Researchers did not find any difference in test scores when they looked at specific components of math and language studies, such as algebra and geometry, and grammar and paraphrase ability in Spanish. But report also notes that results of such studies are mixed: Studies on the relationship between using computers in the classroom and improved test scores in developing countries give mixed results: A review of Israel’s Tomorrow-98 program in the mid-1990s, which put computers in schools across the country, did not find any impact on math and Hebrew language scores. But in India, a study of a computer-assisted learning program showed a significant positive impact on math scores. One thing researchers agree on, more work is needed in this field. Before moving on, a search of the literature will show that these results are consistent with those that were available in the literature at the time that the project was started. The point that I am making is not that the OLPC project could not be made to work; rather, that it was wrong to assume that it would do so without spending at least as much time designing the process to bring that about, as was expended designing the computer itself. Risk is fine, and something that can be mitigated. But diving in under the assumption that it would just work is not calculated risk, it is gambling - with other people’s lives, education and money. Will a better educated population help bring a society out of poverty? I am largely going to punt on this question. The fact is, I would be hard pressed to argue against education. But let us grant that improving education in the developing world is a good thing. The appropriate question is: is the approach of the OLPC project a reasonable or responsible way to disburse the limited resources that are available to address the educational challenges of the developing world? At the very least, I would suggest that this is a topic worthy of debate. An a priori assumption that giving computers is the right solution is akin to the, “If you build it they will come” approach seen in the movie, Field of Dreams. The problem here is that this is not a movie. There are real lives and futures that are at stake here – lives of those who cannot afford to see the movie, much less have precious resources spent on projects that are not well thought through. Can that improvement be accomplished by just giving the computers to the kids without training teachers? Remarkably, the OLPC Project’s answer is an explicit, “Yes”. In a TED talk filmed in December 2007, the founder of the OLPC initiative, Nicholas Negroponte states: “When people tell me, you know, who’s going to teach the teachers to teach the kids, I say to myself, “What planet do you come from? ” Okay, there’s not a person in this room [the TED Conference], I don’t care how techy you are, there’s not a person in this room that doesn’t give their laptop or cell phone to a kid to help them debug it. Okay, we all need help, even those of us who are very seasoned. ”Let us leave aside the naïvete of this statement stemming from the lack of distinction between ability to use applications and devices versus the ability to create and shape them. A failure of logic remains in that those unseasoned kids are part of “us”, as in “we all need help”. Where do the kids go for help? To other kids? What if they don’t know? Often they won’t. After all, the question may well have to do with a concept in calculus, rather than how to use the computer. What then? No answer is offered. Rather, those who dare raise the serious and legitimate concerns regarding teacher preparation are mockingly dismissed as coming from another planet! Well, perhaps they are. But in that case, there should at least be some debate as to who lives on which planet. Is it the people raising the question or the one dismissing the concern that lives in the real world of responsible thought and action? Can this all be accomplished without any advance field trials? Should one just immediately commit to international deployment of the program? As recently as September 2009, Negroponte took part in a panel discussion where he spoke on this matter. He states: I'd like you to imagine that I told you \"I have a technology that is going to change the quality of life. \" And then I tell you \"Really the right thing to do is to set up a pilot project to test my technology. And then the second thing to do is, once the pilot has been running for some period of time, is to go and measure very carefully the benefits of that technology. \"And then I am to tell you that what we are going to is very scientifically evaluate this technology, with control groups - giving it to some, giving it to others. And this all is very reasonable until I tell you the technology is electricity. And you say \"Wait, you don't have to do that!\"But you don't have to do that with laptops and learning either. And the fact that somebody in the room would say the impact is unclear is to me amazing - unbelievably amazing. There's not a person in this room who hasn't bought a laptop for their child, if they could afford it. And you don't know somebody who hasn't done it, if they can afford it. So there's only one question on the table and that's, “How to afford it? ” That's the only question. There is no other question - it's just the economics. And so, when One Laptop Per Child started, I didn't have the picture quite as clear as that, but we did focus on trying to get the price down. We did focus on those things. Unfortunately, Negroponte demonstrates his lack of understanding of both the history of electricity and education in this example. His historical mistake is this: yes, it was pretty obvious that electricity could bring many benefits to society. But what happened when Edison did exactly what Negroponte advocates? He almost lost his company due to his complete (but mistaken) conviction that DC, rather the AC was the correct technology to pursue. As with electricity, yes, it is rather obvious that education could bring significant benefits to the developing world. But in order to avoid making the same kind of expensive mistake that Edison did, perhaps one might want to do one’s best to make sure that the chosen technology is the AC, rather than DC, of education. A little more research, and a little less hubris might have put the investments in Edison and the OLPC to much better use. But the larger question is this: in what way is it responsible for the wealthy western world to advocate an untested and expensive (in every sense) technological solution on the poorest nations in the world? If history has taught us anything, it has taught us that just because our intentions are good, the same is not necessarily true for consequences of our actions. Later in his presentation, Negroponte states: … our problems are swimming against very naïve views of education. With this, I have to agree. It is just whose views on education are naïve, and how can such views emerge from MIT, no less, much less pass with so little critical scrutiny by the public, the press, participants, and funders? In an interview with Paul Marks, published in the New Scientist in December 2008, we see the how the techno-centric aspect of the project plays into the ostensible human centric purpose of the project. Negroponte’s retort regarding some of the initial skepticism that the project provoked was this: “When we first said we could build a laptop for $100 it was viewed as unrealistic and so 'anti-market' and so 'anti' the current laptops which at the time were around $1000 each, \" Negroponte said. \"It was viewed as pure bravado - but look what happened: the netbook market has developed in our wake. \" The project's demands for cheaper components such as keyboards, and processors nudged the industry into finding ways to cut costs, he says. \"What started off as a revolution became a culture. \"Surprise, yes, computers get smaller, faster, and cheaper over the course of time, and yes, one can even grant that the OLPC project may have accelerated that inevitable move. And, I have already stated my admiration and respect for the quality of the technology that was developed. But in the context of the overall objectives of the project, the best that one can say is, “Congratulations on meeting a milestone. ” However, by the same token, one might also legitimately question if starting with the hardware was not an instance of putting the cart before the horse. Yes, it is obviously necessary to have portable computers in the first place, before one can introduce them into the classroom, home, and donate them to children in the developing world. But it is also the case that small portable computers were already in existence and at the time that the project was initiated. While a factor of ten more expensive than the eventual target price, they were both available and adequate to support limited preliminary testing of the underlying premises of the project in an affordable manner. That is, before launching into a major - albeit well-intentioned – hardware development project, it may have been prudent to have tested the underlying premises of its motivation. Here we have to return to the raison d’être of the initiative: … to empower the world's poorest children through educationHence, the extent to which this is achieved from a given investment must be the primary metric of success, as well as the driving force of the project. Yet, that is clearly not what happened. Driven by a blind Edisonian belief in their un-tested premise, the project’s investments were overwhelmingly on the side of technology rather than pedagogy. Perhaps the nature and extent of the naïve (but well-meaning) utopian dream underlying the project is captured in the last part of the interview, above: Negroponte believes that empowering children and their parents with the educational resources offered by computers and the Internet will lead to informed decisions that improve democracy. Indeed, it has led to some gentle ribbing between himself and his brother: John Negroponte - currently deputy secretary of state in the outgoing Bush administration and the first ever director of national intelligence at the National Security Agency. \"I often joke with John that he can bring democracy his way - and I'll bring it mine, \" he says. Apparently providing inexpensive laptops to children in the developing world is not only going to raise educational standards, eradicate poverty, it is also going to bring democracy! All that, with no mention of the numerous poor non-democratic countries that have literacy levels equal to or higher than the USA (Cuba might be one reasonable example). The words naïve technological-utopianism come to mind. I began by admitting that I was conflicted in terms of this project. From the purely technological perspective, there is much to admire in the project’s accomplishments. Sadly, that was not the project’s primary objective. What appears to be missing throughout is an inability to distinguish between the technology and the purpose to which is was intended to serve. My concern in this regard is reflected in a paper by Warschauer & Ames(2010). The analysis reveals that provision of individual laptops is a utopian vision for the children in the poorest countries, whose educational and social futures could be more effectively improved if the same investments were instead made on more sustainable and proven interventions. Middle- and high-income countries may have a stronger rationale for providing individual laptops to children, but will still want to eschew OLPC’s technocentric vision. In summary, OLPC represents the latest in a long line of technologically utopian development schemes that have unsuccessfully attempted to solve complex social problems with overly simplistic solutions. There is a delicate relationship between technology and society, culture, ethics, and values. What this case study reflects is the fact that technologies are not neutral. They never are. Hence, technological initiatives must be accompanied by appropriate social, cultural and ethical considerations – especially in projects such as this where the technologies are being introduced into particularly vulnerable societies. That did not happen here, The fact that this project got the support that it did, and has gone as far as it has, given the way it was approached, is why this reminder – in the form of this device – is included in the collection. And if anyone ever wonders why I am so vocal about the need for public discourse around technology, one need look no further than the OLPC project.", + "__images": [ + "http://localhost:1050/files/images/buxton/upload_df83dd41-0787-4729-b0f8-1feb5e0c999c.jpeg", + "http://localhost:1050/files/images/buxton/upload_7cf46050-92bb-467d-b10b-710ead4598fb.jpeg", + "http://localhost:1050/files/images/buxton/upload_518436fb-59bf-46ec-ad39-8bd6d7aa80a1.jpeg", + "http://localhost:1050/files/images/buxton/upload_14579515-1051-4f38-a816-128f3e5a2e33.jpeg", + "http://localhost:1050/files/images/buxton/upload_ffb0bfe5-936c-4c61-93f2-a9959f1d64e5.jpeg", + "http://localhost:1050/files/images/buxton/upload_6078b1e5-a996-494c-85ba-f8b9d07c97aa.jpeg", + "http://localhost:1050/files/images/buxton/upload_352ed224-547a-49c9-ad3a-2e7826ad20fa.jpeg", + "http://localhost:1050/files/images/buxton/upload_f3ca3ef5-61ca-4c77-9d9c-fed6b91b5f85.jpeg", + "http://localhost:1050/files/images/buxton/upload_e0391087-61a4-415a-84f3-15f38856d29c.jpeg", + "http://localhost:1050/files/images/buxton/upload_8980a470-05bc-4350-a357-ceb049b64b2f.jpeg", + "http://localhost:1050/files/images/buxton/upload_1b63c6c5-eb8e-4ef7-b2d2-55dca9d1a721.jpeg" + ] + }, + { + "title": "Blue Orb Inc. OrbiTouch", + "company": "Blue Orb Inc", + "year": 2002, + "primaryKey": [ + "Joystick" + ], + "secondaryKey": [ + "Keyboard" + ], + "originalPrice": 695, + "degreesOfFreedom": 4, + "dimensions": { + "dim_length": 482.6, + "dim_width": 228.6, + "dim_height": 74.2, + "dim_unit": "mm" + }, + "shortDescription": "On the one hand, this device has the overall footprint of a keyboard, and it is used to enter text. And yet, it is two wide, flat, spring-loaded, self-returning joysticks, which are used to enter characters, rather than the keys that we typically employ. To add to the unconventional nature of this device, one enters text via these two joysticks by means of something called radial menus, one for each hand. And, in keeping with many keyboards, such as those with an integrated touch pad, the OrbiTouch also enables mouse like capabilities, such as pointing and selecting, also by means of one of the joysticks.", + "longDescription": "Keyboards, Joysticks and Hierarchic Radial MenusIntroductionWhen you first look at this device, you might guess that it is some kind of keyboard. It even says so on the box and on the device itself. The keyboard-like footprint might reinforce this notion, as might the alphanumeric characters in the grey ring around the circular orb on the right-hand. On the other hand, if this is a keyboard, where are the keys? Reading the labels more carefully sheds light on the paradox: there are none. This is a “keyless keyboard. ” Yes, this is a contradiction in terms. But it is just such curiosities that make devices like this potentially interesting. Hence, we shall take a reasonably deep dive to see what might be revealed. Let’s start by trying to understand what the rationale was for landing on this particular design. The orbiTouch was developed by an industrial engineering doctoral student at the University of Central Florida, Peter McAlindon. His goal was to develop a means of text entry that minimized hand and wrist motion. The intent was to reduce the incidence of repetitive stress injury. A fair bit of research was undertaken between initial concept and commercial release. This can be accessed online, and doing so is a worthwhile exercise. Let us now turn our eye to the physical device in order to get a sense of where all of this landed. The Physical DeviceThe orbiTouch is dominated by two large circular “orbs. ” To my eye, their form initially practically screamed out, “I am a rotary control - Turn me!” However, appearances can be deceptive. Rather than dials, the orbs turn out to be a pair of a joysticks of a particular type. Rather than the stick-tilting motion typical of most, these “joysticks” are operated by moving them along the horizontal plane. In this they are a close cousins of the Altra Felix and KA Design Turbo Puck, both also in the collection. However, in contrast with the Felix and Turbo Puck, whose handles are “floating” (if you let go, they remain in the position where you released your grip), the orbs are “self-centering. ” That is, when released, internal springs return the orbs to their neutral central “home” position. In this, they behave much like the Gravis joystick in the collection, for example. At a finer level of detail, the orbs are specific class of joystick: “8-way joy-switches”. The term”8-way” indicates that only movement along the 8 main axes of the compass are sensed. As to the word “switch”, think of each orb as 8 switches, any one of which can be turned on by moving the orb in one of the 8 directions. (Conversely, they are turned off when the orb is released and returns to home position). Unlike an analogue joystick, such switches do not, and cannot, report how far or fast the orb has moved in any particular direction, nor how much pressure might be applied in the process. While limited, joy-switches provide a less complex and lower cost solution that are appropriate in situations where this additional data is not needed. There are several examples of joy-switches in the collection, especially video game controllers. One of the most iconic examples is the Atari CX-40 controller, which is a 4-way joy-switch. To recap, the orbiTouch is a bi-manual device for entering text by means of two orb-shaped planer-moving 8-way self-centering joy-switches. Having swallowed that mouth-full, let us now explore how text is entered using such a transducer. Entering TextIn general, a character or function is input by moving the two orbs. Which character or function depends on the direction (if any) each of the orbs has moved. For example, if both the left and right orb move west (left), the character “a” is entered. On the other hand, if the right orb again moves west, but the left one east (right), then the character input is “e”. How or why this is the case can be explained with the help of some images. For easier reading, the figure below shows the labels around the orbs in an exploded view. Notice that for both orbs, there is a label segment for each of its 8 directions. Since the example discussed entering an “a” and an “e”, each of which involved the right orb moving west (left) let’s look at the associated label segment in even more detail. Like all of the label segments for the right orb, this one consists of six areas containing text, each with a distinct background colour: red, yellow, green, orange and blue for the letters A through E, respectively, and black for the region containing “BACKSPACE”. Now look again at previous image and notice that each of these colours matches the label associated with one of the directions of the left orb. Text is entered using a two part process. Moving the right orb to the left/west specifies that you are going to enter one of: a, b, c, d, e, or BACKSPACE. (Like most keyboards, despite the labels on the key-caps being upper case, lower-case characters are entered unless the shift key is depressed. )Moving the left orb in the direction whose label corresponds to the background colour of the desired character causes that character to be entered. Hence, with the right orb held in the left/west position, one can enter the sequence, “abcde”, followed by a Backspace, by sequentially moving the left orb west (red), north-west (yellow), north (green), north-east (orange), east (blue) and south (black). The same technique can then be used to access all the characters and commands found in the right orb’s labels. Special ModesThere is one thing to add at this point: While entering printing characters always requires the use of both orbs, some actions can be performed using the left orb only. This can be inferred by the text that accompanies some of the left orb’s labels. For example, moving the left orb north (green) in quick succession (analogous to a double-click on a mouse), indicates that SHIFT will apply to the next character entered. Likewise, doing the same thing in the south-west (grey) direction applies the Caps Lock mode, i. e. , SHIFT will be applied to all subsequent entries until the mode is cancelled. These one-handed special modes/functions are summarized in the image below. Of these, the only one that I want to discuss at the moment is the ability of the orbiTouch to switch from entering text to controlling the screen cursor. This is done by moving the left orb south (black) twice in quick succession. When this is done, the right orb controls the cursor movement – the cursor moves continuously in the direction that you move the orb. In this, any doubts that you had about me characterizing the orbs as joysticks should disappear, since this cursor control is classic joystick behaviour. One issue of note is that the label describes this as “mouse” not “joystick”, which while understandable, is incorrect. Finally, before moving on to the next topic, note that while the right orb controls the movement of the screen cursor in mouse mode, movement of the left or left/west or right/east is taken as a left and right mouse button press, respectively. Remembering that the premise here is that the hands don’t have to move from the orbiTouch in order switch between typing and pointing tasks. But that doesn’t mean that the overhead in switching between the tasks is removed. One type of overhead is just substituted for another. And, the moded nature of the orbiTouch means that the option of parallel pointing-typing actions are eliminated. Rather than criticism, I mention these points to indicate the need to be mindful of the trade-offs and consequences of different design decisions - consequences that the designer should be aware of. Going Meta: What’s Really Going On? I want to approach doing so by stepping back, and approaching the underlying method of “typing” by going “meta”. That is, I want to jump up a lever of abstraction, beyond the physical device (for the moment), and explain what is going on at the conceptual level. The rest of the text is in much rougher form …. What will be revealed, if we do so, is that text is entered by means of the parallel use of two 8-direction radial menus. So what is a radial menu? These are the neglected cousins of the linear menus that populate conventional graphical user interfaces. The difference is that one makes a selection by the direction of movement, rather than the distance (as in the case with linear menus). It turns out that people can learn these quickly if the directions correspond to the 8 main points of the compass. For example, in a program menu, moving up (North) might mean Print, down (South) could mean Save, and moving down to the right (South East), Save As. Like linear menus, these menus can also be hierarchic. So, for example, after moving South East in order to specify Save As, a stroke to the left (West) might mean that it should be saved as a PDF file, whereas it would be saved as a Plain Text file if the secondary connected stroke was to the right (East). The reason for this brief tutorial on radial menus is that they pretty much define at the conceptual level how text is entered using the orbiTouch. The eight directions that you can move the orbs defines the menu item selected. And, by having the actual output depending on the combination of the selection made by each of the two orbs, the device can perhaps be best described as entering text using a two-level hierarchic radial menu, where menu selections are made using two planar moving 8-way joy switches. That is quite a mouth-full, and it has taken all of the text above to bring us to the point where there is a reasonable chance that it makes sense. And we still haven’t gotten into the details! it uses hierarchic (2-level) radial menus, but where the hierarchy is space multiplexed, rather than time multiplexed. That is, rather than doing one menu selection after the other, you do them simultaneously, by using a different hand to articulate the selection from each of the two menus. (While the text on the description is sparse still, look at the training cards, etc. and the photos on the page. )At the level of the mental model, there is no question in my mind (actually, I shouldn’t say that, because I am supposed to be an objective researcher who needs empirical data to inform decisions, but what the hell!) that you could give someone who knew how to use this device two isotonic joysticks, such as used with a video game controller, and they would be able to enter text just as fast as with this device. Furthermore, I am sure that if one had a slate capable of sensing both touch and stylus simultaneously, I am certain that the skill would transfer equally to using a touch radial gesture in the non-dominant hand, and stylus (or touch) radial gesture with the other. At the basic level, it is a 2-level radial menu, but where each level is operated independently and quasi-simultaneously by a different one of the operator’s two hands. Level 1: Right HandThis lets the operator select one of eight regionsThe label for each region consists of 6 characters (5 printing and one “special)In selecting one of the regions, one is not selecting any one of the characters of that region; rather, they are just indicating that the character that they want is one of the six in that regionEach of the characters in a region has a different background colour: blue, orange, green, yellow, red and black. Level 2: Left HandThis lets the operator select one of eight regionsEach region is labeled by a single colourAmong the colours that label the eight regions are the same ones used as character background colours in the regions of the right-hand control: blue, orange, green, yellow, red and blackBy the left hand selecting one of these six colours, one indicates which character is to be entered from among the six characters in the region indicated by the right hand – the selected character being the one whose background colour corresponds to the colour selected by the left hand. Hence, there are two 8-way, single level radial menus used. I believe it fair to say that it is, nevertheless, a 2 level radial menu, since both need to be used in order to enter one token. In actual fact, things are more complex, since none of the above covers issues such as all of the special character, punctuation, etc. , that do not appear on the labels of the right hand. To keep things brief, this is why only 6 of the left-hand menu options are used in what is discussed above. The other two options are needed to fill in the gaps. And, even then, the device resorts to something like double-clicks to get special modes and capabilities. For example, double clicking the black (south) region of the left hand turns the right-hand dome into a pointing device, i. e. , a mouse substitute for pointing, etc. I went through the – as it turned out – interesting exercise of translating the two parallel depth-1 radial menus of the orbiTouch UI into two different depth-2, breadth-8 hierarchic radial menus. You can see them in the attached images. The one assumes that the LH “dome” as the first-level selection, and then make the second-level selection with the right-hand dome. The other does the opposite, i. e. , the right-hand dome selection is the first level. It is interesting to compare the two with each other, as well as with both the labeling on the orbiTouch and the Quickstart documentation: The RH level-1 version seems easier to get rudimentary understanding compared to the LH due to clustering of letters and numbers on outer menus. Likewise, for the special characters that are the upper case of the numbersThe physical device is fine for letting you hunt-and-peck, so to speak, for characters, but it is useless for numbers, and most special characters. The documentation provided with the Quick Start (attached is not especially useful in terms of providing heuristics for memorization. While the orbiTouch certainly uses radial menus, it decidedly does not employ marking menus. One of the key things missing is the ability to check and correct before committing to an input, and the lack of ability to backtrack to the start, and therefore abort without entering anything. One thing that I have learned from this exercise is the difference that results due to having self-returning joysticks. Gestures don’t have that attribute. It matters esp w. r. t. the last point. What I like about this story, is how looking at something seemingly very different at the right level of abstraction, teaches us/me something new about something I was supposed to be an expert in. That is, that 2-level hierarchic marking menus can be achieved by two simultaneous single-level MMs. This is why I have the collection, and why I love what I do. There is still delight, despite being a 63-year-old geezer grandfather. The orbiTouch Keyless Keyboard was first known as the Keybowl, and the company was formerly known as Keybowl Inc. , and then Blue Orb Inc.", + "__images": [ + "http://localhost:1050/files/images/buxton/upload_4810cb96-ee04-4f89-95cc-87baaa37b8d5.jpeg", + "http://localhost:1050/files/images/buxton/upload_8da6444e-d0d4-4975-a3fa-1f1ccae6b53b.jpeg", + "http://localhost:1050/files/images/buxton/upload_24a751d3-5364-4a17-941e-6c2b0a29377c.jpeg", + "http://localhost:1050/files/images/buxton/upload_b3706d22-b08d-4fac-af77-0cb9a5805476.jpeg", + "http://localhost:1050/files/images/buxton/upload_76c47d1b-963e-45e6-85ea-479155235eda.jpeg", + "http://localhost:1050/files/images/buxton/upload_5c85b83f-6b51-4f77-88e0-dbadfff84b43.jpeg", + "http://localhost:1050/files/images/buxton/upload_ed156a9a-d2cb-4d3e-834e-6f444f202ae9.jpeg", + "http://localhost:1050/files/images/buxton/upload_a19eb9d8-e25b-42bc-9828-2b74dfdf11d5.jpeg", + "http://localhost:1050/files/images/buxton/upload_7874c972-37aa-4fe1-854d-30e473d95c05.jpeg", + "http://localhost:1050/files/images/buxton/upload_08f18b47-0f58-45ac-8995-f673286563d3.jpeg", + "http://localhost:1050/files/images/buxton/upload_c4dc755b-7424-4758-8c3e-5e57a01341a1.jpeg", + "http://localhost:1050/files/images/buxton/upload_5e53cb03-6bee-45df-949e-8f5727e55a1b.jpeg", + "http://localhost:1050/files/images/buxton/upload_a2557ac5-1d4e-48c9-8b19-352cae25ec21.jpeg", + "http://localhost:1050/files/images/buxton/upload_eef6a171-ba65-4132-bce3-9066fdc7bc0b.jpeg", + "http://localhost:1050/files/images/buxton/upload_3624cda2-0500-457c-892d-5493955364d7.jpeg", + "http://localhost:1050/files/images/buxton/upload_08c68d86-da4a-4f4f-8daa-56d7def0c2bb.jpeg", + "http://localhost:1050/files/images/buxton/upload_b888548e-fe12-42b5-8afc-df312d6b6f75.jpeg", + "http://localhost:1050/files/images/buxton/upload_53f13990-2fb5-4d7e-be62-0d31833445da.jpeg", + "http://localhost:1050/files/images/buxton/upload_193fdbfe-cd1a-46f3-a1e9-08eedb8319de.jpeg", + "http://localhost:1050/files/images/buxton/upload_a1e95b03-dc01-4891-b17f-c8b88b32921f.jpeg", + "http://localhost:1050/files/images/buxton/upload_d7994f7e-58c8-4405-bd95-b1f925fe70b3.jpeg", + "http://localhost:1050/files/images/buxton/upload_5479f0b3-87c7-45fb-b086-b306d2414a44.jpeg", + "http://localhost:1050/files/images/buxton/upload_413df73a-ac67-4068-89be-57d3d122bbf0.jpeg" + ] + }, + { + "title": "TASA Model 55 ASCII Keyboard", + "company": "TASA (Touch Activated Switch Arrays)", + "year": 1979, + "primaryKey": [ + "Keyboard" + ], + "secondaryKey": [ + "Pad", + "Touch" + ], + "originalPrice": 80, + "degreesOfFreedom": 0, + "dimensions": { + "dim_length": 382.27, + "dim_width": 158.75, + "dim_height": 8.255, + "dim_unit": "mm" + }, + "shortDescription": "This touch-sensitive keyboard is especially suited for super clean environments, such as hospitals, and those which are just the opposite. The reason is that, being completely flat, there are no crack or gaps where dirt or bacteria can accumulate. This same property enables it to be easily cleaned. However, the reason that I got this keyboard because it was silent – there are no mechanical key-clicks. Hence, for example, it enabled me to soundlessly enter data to my digital musical instrument during a concert or while recording.", + "longDescription": "This is a solid-state touch-sensitive keyboard with no moving parts. Because its surface is flat, the only way one knows that it is a QWERTY keyboard is by the graphical representation on its surface. One types by placing one’s fingers on pictures of keys, rather than physical/mechanical keycaps. Because of the lack of the tactile feedback associated with conventional keyboards, as expected, typing speed and/or accuracy will be compromised with this keyboard. And yet, this keyboard brings real value in certain situations, and in so doing, it provides a good example of the rule: Everything is best for something and worst for something else. Because the is especially suited for super clean environments, such as hospitals, and those which are just the opposite. The reason is that, being completely flat, there are no crack or gaps where dirt or bacteria can accumulate. This same property enables it to be easily cleaned. However, the reason that I got this keyboard because it was silent – there are no mechanical key-clicks. Hence, for example, it enabled me to soundlessly enter data to my digital musical instrument during a concert or while recording. This is one of a number of capacitive touch-sensing input devices produced in the period around 1981 by Touch Activated Switch Arrays (TASA). The others included a touch-sensitive linear controller, the Ferinstat, which could function as a linear slider/fader, for applications such as audio or process control. These came in two lengths and are included in the collection. There were also the Model 16 Micro Proximity Keyboards, which were 16-button keyboards, arranged in a 4x4 array of touch-sensitive buttons that included a touch-sensitive numerical keypad. They also demonstrated a small, capacitive touch-sensitive touch pad, not unlike what one sees on today’s laptops, for example.", + "__images": [ + "http://localhost:1050/files/images/buxton/upload_c9fc05c4-868e-4723-b2b8-51ce4c6f3fd6.jpeg", + "http://localhost:1050/files/images/buxton/upload_9d120c30-bc36-46ef-b0b4-f34d9797606c.jpeg", + "http://localhost:1050/files/images/buxton/upload_de375a30-1d3e-4e1f-8324-ffff307c69e4.jpeg", + "http://localhost:1050/files/images/buxton/upload_c323f012-c284-4aa0-bbae-ee9faf9a0b85.jpeg", + "http://localhost:1050/files/images/buxton/upload_2855f368-040a-48e3-9162-a9873cdd4392.jpeg", + "http://localhost:1050/files/images/buxton/upload_54d09848-d253-4283-af11-29dd30f70771.jpeg", + "http://localhost:1050/files/images/buxton/upload_ead68112-d9f9-4ab5-aed0-764e14c254ae.jpeg", + "http://localhost:1050/files/images/buxton/upload_6ae5554e-abb0-48cd-b16a-7e5c713f8125.jpeg", + "http://localhost:1050/files/images/buxton/upload_0493351a-3be6-4f90-94b8-529d31c94cb2.jpeg", + "http://localhost:1050/files/images/buxton/upload_9a96a1dd-5e8c-4311-bf81-5e0398b6d1f5.jpeg", + "http://localhost:1050/files/images/buxton/upload_df2b52eb-b7a7-41ea-8e7a-9247c096ea40.jpeg" + ] + }, + { + "title": "HandyKey (TekGear) Twiddler ", + "company": "HandyKey (TekGear)", + "year": 1991, + "primaryKey": [ + "Chord", + "Keyboard" + ], + "secondaryKey": [ + "Gesture", + "Joystick", + "Keyboard", + "Reality", + "Virtual", + "Vr", + "Wearable" + ], + "originalPrice": 199, + "degreesOfFreedom": 2, + "dimensions": { + "dim_length": 128, + "dim_width": 45, + "dim_height": 50, + "dim_unit": "mm" + }, + "shortDescription": "The Twiddler is a one-hand chord keyboard with integrated pointing capability, which can control the cursor in a joystick-like manner. This was a favourite device of the early Cyborg wearable-computer community.", + "longDescription": "……. . Note: Lyons, et al. abstract: An experienced user of the Twiddler, a one--handed chording keyboard, averages speeds of 60 words per minute with letter--by--letter typing of standard test phrases. This fast typing rate coupled with the Twiddler's 3x4 button design, similar to that of a standard mobile telephone, makes it a potential alternative to multi--tap for text entry on mobile phones. Despite this similarity, there is very little data on the Twiddler's performance and learnability. We present a longitudinal study of novice users' learning rates on the Twiddler. Ten participants typed for 20 sessions using two different methods. Each session is composed of 20 minutes of typing with multi--tap and 20 minutes of one--handed chording on the Twiddler. We found that users initially have a faster average typing rate with multi--tap; however, after four sessions the difference becomes negligible, and by the eighth session participants type faster with chording on the Twiddler. Furthermore, after 20 sessions typing rates for the Twiddler are still increasing.", + "__images": [ + "http://localhost:1050/files/images/buxton/upload_87851e1d-d9ae-46f6-b5d1-667247a334c7.jpeg", + "http://localhost:1050/files/images/buxton/upload_86a88c71-2464-4918-afb4-9ecffe9ebbbb.jpeg", + "http://localhost:1050/files/images/buxton/upload_8c06fc22-ff8f-4386-a716-fffc90d7a5f2.jpeg", + "http://localhost:1050/files/images/buxton/upload_6e0f4cb4-3b2d-4ae5-8dcd-873a93f2ff61.jpeg", + "http://localhost:1050/files/images/buxton/upload_546e97ee-6c3b-4146-ba03-7a5f8cec7695.jpeg", + "http://localhost:1050/files/images/buxton/upload_df840af0-48a4-4a08-8893-89545c520b6d.jpeg", + "http://localhost:1050/files/images/buxton/upload_727448e6-2702-4462-bd21-a86836e9ae45.jpeg", + "http://localhost:1050/files/images/buxton/upload_acf24b43-16ba-48cc-b8aa-62d9d4209ca6.jpeg", + "http://localhost:1050/files/images/buxton/upload_a677ad5d-9200-4ac0-883d-da35bfce7c23.jpeg", + "http://localhost:1050/files/images/buxton/upload_2824f09a-95a2-4c16-86cb-41be8fa4ae46.jpeg", + "http://localhost:1050/files/images/buxton/upload_ac7bdaf5-8cf6-44ab-a767-74a8ef172980.jpeg", + "http://localhost:1050/files/images/buxton/upload_987fff8f-c41b-409c-a1dc-a331d8129c55.jpeg", + "http://localhost:1050/files/images/buxton/upload_9b3cc2ce-6851-4144-ab8f-94c9a029fa7c.jpeg", + "http://localhost:1050/files/images/buxton/upload_9c19b8a2-76b7-4498-93f8-9779e623174e.jpeg", + "http://localhost:1050/files/images/buxton/upload_a47629fd-a32f-4cf3-bb5a-1d1b8ea9239d.jpeg", + "http://localhost:1050/files/images/buxton/upload_6c1cc20d-54aa-43bc-a9b3-eaa55e16e77d.jpeg", + "http://localhost:1050/files/images/buxton/upload_6726a5e4-3547-4a92-8f8e-5fadd55fa761.jpeg", + "http://localhost:1050/files/images/buxton/upload_c8db5eb9-dac1-4e70-a66e-de9f90bca112.jpeg", + "http://localhost:1050/files/images/buxton/upload_036304b6-a8b3-4d42-b8c8-eb0925afab25.jpeg" + ] + } +] \ No newline at end of file diff --git a/src/scraping/buxton/final/json/incomplete.json b/src/scraping/buxton/final/json/incomplete.json new file mode 100644 index 000000000..a9ed39e21 --- /dev/null +++ b/src/scraping/buxton/final/json/incomplete.json @@ -0,0 +1,569 @@ +[ + { + "filename": "3Dconnexion_SpaceNavigator.docx", + "dimensions": "ERR__DIMENSIONS__: outer match wasn't captured." + }, + { + "filename": "3DMag.docx", + "secondaryKey": "ERR__SECONDARYKEY__: outer match wasn't captured.", + "dimensions": "ERR__DIMENSIONS__: outer match wasn't captured." + }, + { + "filename": "3DPlus.docx", + "year": "ERR__YEAR__: outer match was captured.", + "secondaryKey": "ERR__SECONDARYKEY__: outer match wasn't captured.", + "dimensions": "ERR__DIMENSIONS__: outer match wasn't captured.", + "longDescription": "ERR__LONGDESCRIPTION__: outer match was captured." + }, + { + "filename": "3DSpace.docx", + "year": "ERR__YEAR__: outer match was captured.", + "secondaryKey": "ERR__SECONDARYKEY__: outer match wasn't captured.", + "dimensions": "ERR__DIMENSIONS__: outer match wasn't captured.", + "longDescription": "ERR__LONGDESCRIPTION__: outer match was captured." + }, + { + "filename": "3MErgo.docx", + "secondaryKey": "ERR__SECONDARYKEY__: outer match wasn't captured.", + "dimensions": "ERR__DIMENSIONS__: outer match wasn't captured.", + "longDescription": "ERR__LONGDESCRIPTION__: outer match was captured." + }, + { + "filename": "Abaton.docx", + "secondaryKey": "ERR__SECONDARYKEY__: outer match wasn't captured.", + "dimensions": "ERR__DIMENSIONS__: outer match wasn't captured." + }, + { + "filename": "Active.docx", + "secondaryKey": "ERR__SECONDARYKEY__: outer match wasn't captured.", + "originalPrice": "ERR__ORIGINALPRICE__: outer match wasn't captured.", + "dimensions": "ERR__DIMENSIONS__: outer match wasn't captured.", + "longDescription": "ERR__LONGDESCRIPTION__: outer match was captured." + }, + { + "filename": "ADB2.docx", + "secondaryKey": "ERR__SECONDARYKEY__: outer match wasn't captured.", + "originalPrice": "ERR__ORIGINALPRICE__: outer match wasn't captured.", + "dimensions": "ERR__DIMENSIONS__: outer match wasn't captured." + }, + { + "filename": "adecm.docx", + "secondaryKey": "ERR__SECONDARYKEY__: outer match wasn't captured.", + "originalPrice": "ERR__ORIGINALPRICE__: outer match wasn't captured.", + "dimensions": "ERR__DIMENSIONS__: outer match wasn't captured.", + "longDescription": "ERR__LONGDESCRIPTION__: outer match was captured." + }, + { + "filename": "AlphaSmart_Pro.docx", + "degreesOfFreedom": "ERR__DEGREESOFFREEDOM__: outer match wasn't captured." + }, + { + "filename": "Amazon_Kindle_Keyboard.docx", + "dimensions": "ERR__DIMENSIONS__: outer match wasn't captured." + }, + { + "filename": "Apple_ADB_Mouse.docx", + "originalPrice": "ERR__ORIGINALPRICE__: outer match wasn't captured." + }, + { + "filename": "Apple_Adj_Keyboard.docx", + "degreesOfFreedom": "ERR__DEGREESOFFREEDOM__: outer match wasn't captured.", + "dimensions": "ERR__DIMENSIONS__: outer match wasn't captured.", + "longDescription": "ERR__LONGDESCRIPTION__: outer match was captured." + }, + { + "filename": "Apple_iPhone.docx", + "longDescription": "ERR__LONGDESCRIPTION__: outer match was captured." + }, + { + "filename": "Apple_Mac_Portable-Katy’s MacBook Air-2.docx", + "year": "__ERR__YEAR__TRANSFORM__: NaN cannot be parsed to a numeric value.", + "longDescription": "ERR__LONGDESCRIPTION__: outer match was captured." + }, + { + "filename": "Apple_Mac_Portable-Katy’s MacBook Air.docx", + "longDescription": "ERR__LONGDESCRIPTION__: outer match was captured." + }, + { + "filename": "Apple_Mac_Portable.docx", + "longDescription": "ERR__LONGDESCRIPTION__: outer match was captured." + }, + { + "filename": "Apple_Scroll_Mouse.docx", + "year": "__ERR__YEAR__TRANSFORM__: NaN cannot be parsed to a numeric value.", + "originalPrice": "ERR__ORIGINALPRICE__: outer match wasn't captured.", + "dimensions": "ERR__DIMENSIONS__: outer match wasn't captured." + }, + { + "filename": "AWrock.docx", + "secondaryKey": "ERR__SECONDARYKEY__: outer match wasn't captured.", + "originalPrice": "ERR__ORIGINALPRICE__: outer match wasn't captured.", + "dimensions": "ERR__DIMENSIONS__: outer match wasn't captured." + }, + { + "filename": "BAT.docx", + "degreesOfFreedom": "ERR__DEGREESOFFREEDOM__: outer match wasn't captured.", + "dimensions": "ERR__DIMENSIONS__: outer match wasn't captured.", + "longDescription": "ERR__LONGDESCRIPTION__: outer match was captured." + }, + { + "filename": "Bill_Notes_CyKey.docx", + "degreesOfFreedom": "ERR__DEGREESOFFREEDOM__: outer match wasn't captured." + }, + { + "filename": "Brailler.docx", + "originalPrice": "ERR__ORIGINALPRICE__: outer match wasn't captured.", + "degreesOfFreedom": "ERR__DEGREESOFFREEDOM__: outer match wasn't captured.", + "longDescription": "ERR__LONGDESCRIPTION__: outer match was captured." + }, + { + "filename": "Brewster_Stereoscope.docx", + "originalPrice": "ERR__ORIGINALPRICE__: outer match wasn't captured.", + "degreesOfFreedom": "ERR__DEGREESOFFREEDOM__: outer match wasn't captured.", + "dimensions": "ERR__DIMENSIONS__: outer match wasn't captured." + }, + { + "filename": "CasioC801.docx", + "degreesOfFreedom": "ERR__DEGREESOFFREEDOM__: outer match wasn't captured.", + "dimensions": "ERR__DIMENSIONS__: outer match wasn't captured." + }, + { + "filename": "CasioTC500.docx", + "secondaryKey": "ERR__SECONDARYKEY__: outer match wasn't captured.", + "degreesOfFreedom": "ERR__DEGREESOFFREEDOM__: outer match wasn't captured.", + "dimensions": "ERR__DIMENSIONS__: outer match wasn't captured." + }, + { + "filename": "Casio_Mini.docx", + "degreesOfFreedom": "ERR__DEGREESOFFREEDOM__: outer match wasn't captured.", + "dimensions": "ERR__DIMENSIONS__: outer match wasn't captured." + }, + { + "filename": "Citizen_LCl_914.docx", + "originalPrice": "ERR__ORIGINALPRICE__: outer match wasn't captured.", + "degreesOfFreedom": "ERR__DEGREESOFFREEDOM__: outer match wasn't captured." + }, + { + "filename": "Citizen_LC_909.docx", + "originalPrice": "ERR__ORIGINALPRICE__: outer match wasn't captured.", + "degreesOfFreedom": "ERR__DEGREESOFFREEDOM__: outer match wasn't captured.", + "dimensions": "ERR__DIMENSIONS__: outer match wasn't captured." + }, + { + "filename": "Citizen_LC_913.docx", + "originalPrice": "ERR__ORIGINALPRICE__: outer match wasn't captured." + }, + { + "filename": "CoolPix.docx", + "secondaryKey": "ERR__SECONDARYKEY__: outer match wasn't captured.", + "originalPrice": "ERR__ORIGINALPRICE__: outer match wasn't captured.", + "degreesOfFreedom": "ERR__DEGREESOFFREEDOM__: outer match wasn't captured.", + "shortDescription": "ERR__SHORTDESCRIPTION__: outer match was captured." + }, + { + "filename": "Cross.docx", + "secondaryKey": "ERR__SECONDARYKEY__: outer match wasn't captured.", + "dimensions": "ERR__DIMENSIONS__: outer match wasn't captured.", + "longDescription": "ERR__LONGDESCRIPTION__: outer match was captured." + }, + { + "filename": "Dymo_MK-6.docx", + "secondaryKey": "ERR__SECONDARYKEY__: outer match wasn't captured.", + "originalPrice": "ERR__ORIGINALPRICE__: outer match wasn't captured.", + "degreesOfFreedom": "ERR__DEGREESOFFREEDOM__: outer match wasn't captured.", + "longDescription": "ERR__LONGDESCRIPTION__: outer match was captured." + }, + { + "filename": "eMate.docx", + "primaryKey": "ERR__PRIMARYKEY__: outer match was captured.", + "secondaryKey": "ERR__SECONDARYKEY__: outer match wasn't captured.", + "degreesOfFreedom": "ERR__DEGREESOFFREEDOM__: outer match wasn't captured.", + "dimensions": "ERR__DIMENSIONS__: outer match wasn't captured.", + "shortDescription": "ERR__SHORTDESCRIPTION__: outer match was captured.", + "longDescription": "ERR__LONGDESCRIPTION__: outer match was captured." + }, + { + "filename": "Emotiv.docx", + "primaryKey": "ERR__PRIMARYKEY__: outer match was captured.", + "secondaryKey": "ERR__SECONDARYKEY__: outer match wasn't captured.", + "degreesOfFreedom": "ERR__DEGREESOFFREEDOM__: outer match wasn't captured.", + "shortDescription": "ERR__SHORTDESCRIPTION__: outer match was captured.", + "longDescription": "ERR__LONGDESCRIPTION__: outer match was captured." + }, + { + "filename": "Explorer.docx", + "secondaryKey": "ERR__SECONDARYKEY__: outer match wasn't captured.", + "shortDescription": "ERR__SHORTDESCRIPTION__: outer match was captured.", + "longDescription": "ERR__LONGDESCRIPTION__: outer match was captured." + }, + { + "filename": "Falcon.docx", + "primaryKey": "ERR__PRIMARYKEY__: outer match was captured.", + "secondaryKey": "ERR__SECONDARYKEY__: outer match wasn't captured.", + "degreesOfFreedom": "ERR__DEGREESOFFREEDOM__: outer match wasn't captured.", + "dimensions": "ERR__DIMENSIONS__: outer match wasn't captured.", + "shortDescription": "ERR__SHORTDESCRIPTION__: outer match was captured." + }, + { + "filename": "FingerWorks_Prototype.docx", + "originalPrice": "ERR__ORIGINALPRICE__: outer match wasn't captured.", + "dimensions": "ERR__DIMENSIONS__: outer match wasn't captured." + }, + { + "filename": "Freeboard.docx", + "secondaryKey": "ERR__SECONDARYKEY__: outer match was captured.", + "originalPrice": "ERR__ORIGINALPRICE__: outer match wasn't captured.", + "degreesOfFreedom": "ERR__DEGREESOFFREEDOM__: outer match wasn't captured.", + "dimensions": "ERR__DIMENSIONS__: outer match wasn't captured." + }, + { + "filename": "FrogPad.docx", + "degreesOfFreedom": "ERR__DEGREESOFFREEDOM__: outer match wasn't captured." + }, + { + "filename": "FujitsuPalm.docx", + "primaryKey": "ERR__PRIMARYKEY__: outer match was captured.", + "secondaryKey": "ERR__SECONDARYKEY__: outer match wasn't captured.", + "originalPrice": "ERR__ORIGINALPRICE__: outer match wasn't captured.", + "degreesOfFreedom": "ERR__DEGREESOFFREEDOM__: outer match wasn't captured.", + "shortDescription": "ERR__SHORTDESCRIPTION__: outer match was captured.", + "longDescription": "ERR__LONGDESCRIPTION__: outer match was captured." + }, + { + "filename": "FujitsuTouch.docx", + "secondaryKey": "ERR__SECONDARYKEY__: outer match wasn't captured.", + "originalPrice": "ERR__ORIGINALPRICE__: outer match wasn't captured.", + "degreesOfFreedom": "ERR__DEGREESOFFREEDOM__: outer match wasn't captured.", + "shortDescription": "ERR__SHORTDESCRIPTION__: outer match was captured." + }, + { + "filename": "Gavilan_SC.docx", + "company": "ERR__COMPANY__: outer match wasn't captured.", + "year": "__ERR__YEAR__TRANSFORM__: NaN cannot be parsed to a numeric value.", + "dimensions": "ERR__DIMENSIONS__: outer match wasn't captured.", + "longDescription": "ERR__LONGDESCRIPTION__: outer match was captured." + }, + { + "filename": "Genius_Ring_Mouse.docx", + "dimensions": "ERR__DIMENSIONS__: outer match wasn't captured." + }, + { + "filename": "Grandjean_Stenotype.docx", + "originalPrice": "ERR__ORIGINALPRICE__: outer match wasn't captured.", + "degreesOfFreedom": "ERR__DEGREESOFFREEDOM__: outer match wasn't captured.", + "dimensions": "ERR__DIMENSIONS__: outer match wasn't captured.", + "longDescription": "ERR__LONGDESCRIPTION__: outer match was captured." + }, + { + "filename": "gravis.docx", + "year": "ERR__YEAR__: outer match was captured.", + "secondaryKey": "ERR__SECONDARYKEY__: outer match wasn't captured.", + "originalPrice": "ERR__ORIGINALPRICE__: outer match wasn't captured.", + "dimensions": "ERR__DIMENSIONS__: outer match wasn't captured.", + "longDescription": "ERR__LONGDESCRIPTION__: outer match was captured." + }, + { + "filename": "GRiD1550-Katy’s MacBook Air-2.docx", + "year": "__ERR__YEAR__TRANSFORM__: NaN cannot be parsed to a numeric value.", + "shortDescription": "ERR__SHORTDESCRIPTION__: outer match was captured." + }, + { + "filename": "GRiD1550-Katy’s MacBook Air.docx", + "secondaryKey": "ERR__SECONDARYKEY__: outer match wasn't captured.", + "degreesOfFreedom": "ERR__DEGREESOFFREEDOM__: outer match wasn't captured.", + "shortDescription": "ERR__SHORTDESCRIPTION__: outer match was captured." + }, + { + "filename": "GRiD1550.docx", + "primaryKey": "ERR__PRIMARYKEY__: outer match was captured.", + "secondaryKey": "ERR__SECONDARYKEY__: outer match wasn't captured.", + "degreesOfFreedom": "ERR__DEGREESOFFREEDOM__: outer match wasn't captured.", + "shortDescription": "ERR__SHORTDESCRIPTION__: outer match was captured." + }, + { + "filename": "Helios-Klimax.docx", + "primaryKey": "ERR__PRIMARYKEY__: outer match was captured.", + "secondaryKey": "ERR__SECONDARYKEY__: outer match wasn't captured.", + "originalPrice": "ERR__ORIGINALPRICE__: outer match wasn't captured.", + "degreesOfFreedom": "ERR__DEGREESOFFREEDOM__: outer match wasn't captured.", + "dimensions": "ERR__DIMENSIONS__: outer match wasn't captured.", + "longDescription": "ERR__LONGDESCRIPTION__: outer match was captured." + }, + { + "filename": "Honeywell_T86.docx", + "dimensions": "ERR__DIMENSIONS__: outer match wasn't captured." + }, + { + "filename": "HTC_Touch.docx", + "year": "__ERR__YEAR__TRANSFORM__: NaN cannot be parsed to a numeric value.", + "originalPrice": "ERR__ORIGINALPRICE__: outer match wasn't captured." + }, + { + "filename": "IBMTrack.docx", + "year": "ERR__YEAR__: outer match was captured.", + "secondaryKey": "ERR__SECONDARYKEY__: outer match wasn't captured.", + "originalPrice": "ERR__ORIGINALPRICE__: outer match wasn't captured.", + "dimensions": "ERR__DIMENSIONS__: outer match wasn't captured." + }, + { + "filename": "IBM_Convertable-Katy’s MacBook Air-2.docx", + "degreesOfFreedom": "ERR__DEGREESOFFREEDOM__: outer match wasn't captured.", + "dimensions": "ERR__DIMENSIONS__: outer match wasn't captured." + }, + { + "filename": "IBM_Convertable-Katy’s MacBook Air.docx", + "degreesOfFreedom": "ERR__DEGREESOFFREEDOM__: outer match wasn't captured.", + "dimensions": "ERR__DIMENSIONS__: outer match wasn't captured." + }, + { + "filename": "IBM_Convertable.docx", + "degreesOfFreedom": "ERR__DEGREESOFFREEDOM__: outer match wasn't captured.", + "dimensions": "ERR__DIMENSIONS__: outer match wasn't captured." + }, + { + "filename": "IBM_PS2_Mouse.docx", + "primaryKey": "ERR__PRIMARYKEY__: outer match was captured.", + "secondaryKey": "ERR__SECONDARYKEY__: outer match wasn't captured.", + "dimensions": "ERR__DIMENSIONS__: outer match wasn't captured.", + "shortDescription": "ERR__SHORTDESCRIPTION__: outer match was captured.", + "longDescription": "ERR__LONGDESCRIPTION__: outer match was captured." + }, + { + "filename": "IBM_Simon.docx", + "year": "__ERR__YEAR__TRANSFORM__: NaN cannot be parsed to a numeric value." + }, + { + "filename": "IDEO.docx", + "secondaryKey": "ERR__SECONDARYKEY__: outer match wasn't captured.", + "degreesOfFreedom": "ERR__DEGREESOFFREEDOM__: outer match wasn't captured.", + "dimensions": "ERR__DIMENSIONS__: outer match wasn't captured.", + "longDescription": "ERR__LONGDESCRIPTION__: outer match was captured." + }, + { + "filename": "iGesture.docx", + "year": "__ERR__YEAR__TRANSFORM__: NaN cannot be parsed to a numeric value.", + "primaryKey": "ERR__PRIMARYKEY__: outer match was captured.", + "secondaryKey": "ERR__SECONDARYKEY__: outer match wasn't captured.", + "degreesOfFreedom": "ERR__DEGREESOFFREEDOM__: outer match wasn't captured.", + "longDescription": "ERR__LONGDESCRIPTION__: outer match was captured." + }, + { + "filename": "iGrip.docx", + "shortDescription": "ERR__SHORTDESCRIPTION__: outer match was captured.", + "longDescription": "ERR__LONGDESCRIPTION__: outer match was captured." + }, + { + "filename": "iLiad.docx", + "secondaryKey": "ERR__SECONDARYKEY__: outer match wasn't captured.", + "degreesOfFreedom": "ERR__DEGREESOFFREEDOM__: outer match wasn't captured." + }, + { + "filename": "Joyboard.docx", + "primaryKey": "ERR__PRIMARYKEY__: outer match was captured.", + "secondaryKey": "ERR__SECONDARYKEY__: outer match wasn't captured.", + "degreesOfFreedom": "ERR__DEGREESOFFREEDOM__: outer match wasn't captured.", + "dimensions": "ERR__DIMENSIONS__: outer match wasn't captured.", + "shortDescription": "ERR__SHORTDESCRIPTION__: outer match was captured." + }, + { + "filename": "Kensington_SB_TB-Mouse.docx", + "secondaryKey": "ERR__SECONDARYKEY__: outer match wasn't captured.", + "degreesOfFreedom": "ERR__DEGREESOFFREEDOM__: outer match wasn't captured.", + "dimensions": "ERR__DIMENSIONS__: outer match wasn't captured." + }, + { + "filename": "Kindle_3G_lighted_cover.docx", + "degreesOfFreedom": "ERR__DEGREESOFFREEDOM__: outer match wasn't captured." + }, + { + "filename": "Leatherman_Tread.docx", + "primaryKey": "ERR__PRIMARYKEY__: outer match was captured.", + "secondaryKey": "ERR__SECONDARYKEY__: outer match wasn't captured.", + "degreesOfFreedom": "ERR__DEGREESOFFREEDOM__: outer match wasn't captured.", + "dimensions": "ERR__DIMENSIONS__: outer match wasn't captured.", + "shortDescription": "ERR__SHORTDESCRIPTION__: outer match was captured.", + "longDescription": "ERR__LONGDESCRIPTION__: outer match was captured." + }, + { + "filename": "M1.docx", + "secondaryKey": "ERR__SECONDARYKEY__: outer match wasn't captured." + }, + { + "filename": "MaltronLH.docx", + "secondaryKey": "ERR__SECONDARYKEY__: outer match wasn't captured.", + "degreesOfFreedom": "ERR__DEGREESOFFREEDOM__: outer match wasn't captured." + }, + { + "filename": "Marine_Band_Harmonica.docx", + "company": "ERR__COMPANY__: outer match was captured.", + "year": "ERR__YEAR__: outer match was captured.", + "primaryKey": "ERR__PRIMARYKEY__: outer match was captured.", + "secondaryKey": "ERR__SECONDARYKEY__: outer match wasn't captured.", + "originalPrice": "ERR__ORIGINALPRICE__: outer match wasn't captured.", + "degreesOfFreedom": "ERR__DEGREESOFFREEDOM__: outer match wasn't captured.", + "dimensions": "ERR__DIMENSIONS__: outer match wasn't captured.", + "longDescription": "ERR__LONGDESCRIPTION__: outer match was captured." + }, + { + "filename": "Matrox.docx", + "originalPrice": "ERR__ORIGINALPRICE__: outer match wasn't captured.", + "degreesOfFreedom": "ERR__DEGREESOFFREEDOM__: outer match wasn't captured." + }, + { + "filename": "Metaphor_Kbd.docx", + "originalPrice": "ERR__ORIGINALPRICE__: outer match wasn't captured.", + "degreesOfFreedom": "ERR__DEGREESOFFREEDOM__: outer match wasn't captured.", + "dimensions": "ERR__DIMENSIONS__: outer match wasn't captured.", + "shortDescription": "ERR__SHORTDESCRIPTION__: outer match was captured." + }, + { + "filename": "Metaphor_Mouse.docx", + "originalPrice": "ERR__ORIGINALPRICE__: outer match wasn't captured.", + "longDescription": "ERR__LONGDESCRIPTION__: outer match was captured." + }, + { + "filename": "Microwriter.docx", + "dimensions": "ERR__DIMENSIONS__: outer match wasn't captured." + }, + { + "filename": "Motorola_DynaTAC.docx", + "year": "__ERR__YEAR__TRANSFORM__: NaN cannot be parsed to a numeric value.", + "degreesOfFreedom": "ERR__DEGREESOFFREEDOM__: outer match wasn't captured.", + "dimensions": "ERR__DIMENSIONS__: outer match wasn't captured.", + "longDescription": "ERR__LONGDESCRIPTION__: outer match was captured." + }, + { + "filename": "MousePen.docx", + "dimensions": "ERR__DIMENSIONS__: outer match wasn't captured." + }, + { + "filename": "MS-1_Stereoscope.docx", + "year": "__ERR__YEAR__TRANSFORM__: NaN cannot be parsed to a numeric value.", + "originalPrice": "ERR__ORIGINALPRICE__: outer match wasn't captured.", + "degreesOfFreedom": "ERR__DEGREESOFFREEDOM__: outer match wasn't captured." + }, + { + "filename": "MWB_Braille_Writer.docx", + "company": "ERR__COMPANY__: outer match wasn't captured.", + "year": "__ERR__YEAR__TRANSFORM__: NaN cannot be parsed to a numeric value.", + "originalPrice": "ERR__ORIGINALPRICE__: outer match wasn't captured.", + "degreesOfFreedom": "ERR__DEGREESOFFREEDOM__: outer match wasn't captured." + }, + { + "filename": "NB75D.docx", + "year": "ERR__YEAR__: outer match was captured.", + "primaryKey": "ERR__PRIMARYKEY__: outer match was captured.", + "secondaryKey": "ERR__SECONDARYKEY__: outer match wasn't captured.", + "originalPrice": "ERR__ORIGINALPRICE__: outer match wasn't captured.", + "degreesOfFreedom": "ERR__DEGREESOFFREEDOM__: outer match wasn't captured.", + "dimensions": "ERR__DIMENSIONS__: outer match wasn't captured.", + "shortDescription": "ERR__SHORTDESCRIPTION__: outer match was captured.", + "longDescription": "ERR__LONGDESCRIPTION__: outer match was captured." + }, + { + "filename": "NewO.docx", + "degreesOfFreedom": "ERR__DEGREESOFFREEDOM__: outer match wasn't captured.", + "dimensions": "ERR__DIMENSIONS__: outer match wasn't captured." + }, + { + "filename": "Newton120.docx", + "dimensions": "ERR__DIMENSIONS__: outer match wasn't captured.", + "longDescription": "ERR__LONGDESCRIPTION__: outer match was captured." + }, + { + "filename": "Nikon_Coolpix-100.docx", + "degreesOfFreedom": "ERR__DEGREESOFFREEDOM__: outer match wasn't captured.", + "shortDescription": "ERR__SHORTDESCRIPTION__: outer match was captured." + }, + { + "filename": "Numonics_Mgr_Mouse.docx", + "company": "ERR__COMPANY__: outer match was captured.", + "year": "ERR__YEAR__: outer match was captured.", + "primaryKey": "ERR__PRIMARYKEY__: outer match was captured.", + "secondaryKey": "ERR__SECONDARYKEY__: outer match wasn't captured.", + "originalPrice": "ERR__ORIGINALPRICE__: outer match wasn't captured.", + "degreesOfFreedom": "ERR__DEGREESOFFREEDOM__: outer match wasn't captured.", + "dimensions": "ERR__DIMENSIONS__: outer match wasn't captured.", + "shortDescription": "ERR__SHORTDESCRIPTION__: outer match was captured.", + "longDescription": "ERR__LONGDESCRIPTION__: outer match was captured." + }, + { + "filename": "PadMouse.docx", + "secondaryKey": "ERR__SECONDARYKEY__: outer match wasn't captured.", + "originalPrice": "ERR__ORIGINALPRICE__: outer match wasn't captured.", + "dimensions": "ERR__DIMENSIONS__: outer match wasn't captured." + }, + { + "filename": "PARCkbd.docx", + "originalPrice": "ERR__ORIGINALPRICE__: outer match wasn't captured." + }, + { + "filename": "Philco_Mystery_Control.docx", + "originalPrice": "ERR__ORIGINALPRICE__: outer match wasn't captured.", + "dimensions": "ERR__DIMENSIONS__: outer match wasn't captured." + }, + { + "filename": "PowerTrack.docx", + "dimensions": "ERR__DIMENSIONS__: outer match wasn't captured.", + "longDescription": "ERR__LONGDESCRIPTION__: outer match was captured." + }, + { + "filename": "ProAgio (1).docx", + "secondaryKey": "ERR__SECONDARYKEY__: outer match wasn't captured.", + "degreesOfFreedom": "ERR__DEGREESOFFREEDOM__: outer match wasn't captured.", + "dimensions": "ERR__DIMENSIONS__: outer match wasn't captured." + }, + { + "filename": "ProAgio.docx", + "secondaryKey": "ERR__SECONDARYKEY__: outer match wasn't captured.", + "degreesOfFreedom": "ERR__DEGREESOFFREEDOM__: outer match wasn't captured.", + "dimensions": "ERR__DIMENSIONS__: outer match wasn't captured." + }, + { + "filename": "Pulsar_time_Computer.docx", + "primaryKey": "ERR__PRIMARYKEY__: outer match was captured.", + "secondaryKey": "ERR__SECONDARYKEY__: outer match wasn't captured.", + "degreesOfFreedom": "ERR__DEGREESOFFREEDOM__: outer match wasn't captured." + }, + { + "filename": "Ring.docx", + "secondaryKey": "ERR__SECONDARYKEY__: outer match wasn't captured.", + "longDescription": "ERR__LONGDESCRIPTION__: outer match was captured." + }, + { + "filename": "round.docx", + "secondaryKey": "ERR__SECONDARYKEY__: outer match wasn't captured.", + "originalPrice": "ERR__ORIGINALPRICE__: outer match wasn't captured.", + "dimensions": "ERR__DIMENSIONS__: outer match wasn't captured.", + "longDescription": "ERR__LONGDESCRIPTION__: outer match was captured." + }, + { + "filename": "SafeType_Kbd.docx", + "degreesOfFreedom": "ERR__DEGREESOFFREEDOM__: outer match wasn't captured." + }, + { + "filename": "Samsung_SPH-A500.docx", + "longDescription": "ERR__LONGDESCRIPTION__: outer match was captured." + }, + { + "filename": "SurfMouse.docx", + "originalPrice": "ERR__ORIGINALPRICE__: outer match wasn't captured." + }, + { + "filename": "The_Tap.docx", + "secondaryKey": "ERR__SECONDARYKEY__: outer match wasn't captured.", + "dimensions": "ERR__DIMENSIONS__: outer match wasn't captured.", + "longDescription": "ERR__LONGDESCRIPTION__: outer match was captured." + }, + { + "filename": "Thumbelina.docx", + "secondaryKey": "ERR__SECONDARYKEY__: outer match wasn't captured.", + "degreesOfFreedom": "ERR__DEGREESOFFREEDOM__: outer match wasn't captured.", + "dimensions": "ERR__DIMENSIONS__: outer match wasn't captured." + }, + { + "filename": "TPARCtab.docx", + "originalPrice": "ERR__ORIGINALPRICE__: outer match wasn't captured.", + "dimensions": "ERR__DIMENSIONS__: outer match wasn't captured." + } +] \ No newline at end of file diff --git a/src/server/ApiManagers/UtilManager.ts b/src/server/ApiManagers/UtilManager.ts index e590a5b85..4cb57a4e7 100644 --- a/src/server/ApiManagers/UtilManager.ts +++ b/src/server/ApiManagers/UtilManager.ts @@ -1,7 +1,6 @@ import ApiManager, { Registration } from "./ApiManager"; import { Method } from "../RouteManager"; import { exec } from 'child_process'; -import { command_line } from "../ActionUtilities"; import RouteSubscriber from "../RouteSubscriber"; import { red } from "colors"; import executeImport from "../../scraping/buxton/final/BuxtonImporter"; @@ -40,25 +39,6 @@ export default class UtilManager extends ApiManager { } }); - // register({ - // method: Method.GET, - // subscription: "/buxton", - // secureHandler: async ({ res }) => { - // const cwd = './src/scraping/buxton'; - - // const onResolved = (stdout: string) => { console.log(stdout); res.redirect("/"); }; - // const onRejected = (err: any) => { console.error(err.message); res.send(err); }; - // const tryPython3 = (reason: any) => { - // console.log("Initial scraper failed for the following reason:"); - // console.log(red(reason.Error)); - // console.log("Falling back to python3..."); - // return command_line('python3 scraper.py', cwd).then(onResolved, onRejected); - // }; - - // return command_line('python scraper.py', cwd).then(onResolved, tryPython3); - // }, - // }); - register({ method: Method.GET, subscription: "/buxton", -- cgit v1.2.3-70-g09d2 From 59d286eafda87712a2be376d70e2ac0063d853c9 Mon Sep 17 00:00:00 2001 From: Sam Wilkins Date: Sun, 9 Feb 2020 18:20:36 -0500 Subject: resizing is now stable --- src/scraping/buxton/final/BuxtonImporter.ts | 101 ++++++----- src/scraping/buxton/final/json/buxton.json | 252 ++++++++++++++-------------- src/server/DashUploadUtils.ts | 5 + 3 files changed, 187 insertions(+), 171 deletions(-) (limited to 'src/server') diff --git a/src/scraping/buxton/final/BuxtonImporter.ts b/src/scraping/buxton/final/BuxtonImporter.ts index 3a6ee5914..f012b83d4 100644 --- a/src/scraping/buxton/final/BuxtonImporter.ts +++ b/src/scraping/buxton/final/BuxtonImporter.ts @@ -1,4 +1,4 @@ -import { readdirSync, writeFile, mkdirSync, createWriteStream, createReadStream, unlinkSync } from "fs"; +import { readdirSync, writeFile, mkdirSync, createWriteStream } from "fs"; import * as path from "path"; import { red, cyan, yellow } from "colors"; import { Utils } from "../../../Utils"; @@ -159,13 +159,19 @@ async function parseFiles(): Promise { const sourceDirectory = path.resolve(`${__dirname}/source`); const candidates = readdirSync(sourceDirectory).filter(file => file.endsWith(".doc") || file.endsWith(".docx")).map(file => `${sourceDirectory}/${file}`); - const imported = await Promise.all(candidates.map(async path => ({ path, body: await extractFileContents(path) }))); - const data = imported.map(({ path, body }) => analyze(path, body)); + const imported: any[] = []; + for (const filePath of candidates) { + const fileName = path.basename(filePath).replace("Bill_Notes_", ""); + console.log(cyan(`\nExtracting contents from ${fileName}...`)); + imported.push({ fileName, body: await extractFileContents(filePath) }); + } + console.log(yellow("\nAnalyzing the extracted document text...\n")); + const results = imported.map(({ fileName, body }) => analyze(fileName, body)); const masterDevices: DeviceDocument[] = []; const masterErrors: any[] = []; - data.forEach(({ device, errors }) => { + results.forEach(({ device, errors }) => { if (device) { masterDevices.push(device); } else { @@ -186,6 +192,7 @@ async function parseFiles(): Promise { } async function extractFileContents(pathToDocument: string): Promise<{ body: string, images: string[] }> { + console.log('Extracting text...'); const zip = new StreamZip({ file: pathToDocument, storeEntries: true }); const contents = await new Promise((resolve, reject) => { zip.on('ready', () => { @@ -199,7 +206,10 @@ async function extractFileContents(pathToDocument: string): Promise<{ body: stri }); }); }); + console.log("Text extracted."); + console.log("Beginning image extraction..."); const images = await writeImages(zip); + console.log(`Extracted ${images.length} images.`); zip.close(); let body = ""; const components = contents.toString().split(' { + let initial = sharp().resize(size.width, undefined, { withoutEnlargement: true }); + if (pngs.includes(ext)) { + initial = initial.png(pngOptions); + } else if (jpgs.includes(ext)) { + initial = initial.jpeg(); + } + return { + resizer: initial, + suffix: size.suffix + }; + }) + ]; +} + async function writeImages(zip: any): Promise { const entryNames = Object.values(zip.entries()).map(({ name }) => name); const resolved: { mediaPath: string, ext: string }[] = []; @@ -221,55 +256,31 @@ async function writeImages(zip: any): Promise { const outNames: string[] = []; for (const { mediaPath, ext } of resolved) { const outName = `upload_${Utils.GenerateGuid()}${ext}`; - const initialWritePath = path.resolve(imageDir, outName); - await new Promise((resolve, reject) => { - zip.stream(mediaPath, (error: any, stream: any) => { - if (error) { - console.error(error); - return reject(error); - } - const writeStream = createWriteStream(initialWritePath); - stream.on('end', resolve); - stream.on('error', reject); - stream.pipe(writeStream); - }); + const streamImage = () => new Promise((resolve, reject) => { + zip.stream(mediaPath, (error: any, stream: any) => error ? reject(error) : resolve(stream)); }); - const resizers = [ - { resizer: sharp().rotate(), suffix: SizeSuffix.Original }, - ...Object.values(DashUploadUtils.Sizes).map(size => ({ - resizer: sharp().resize(size.width, undefined, { withoutEnlargement: true }).rotate(), - suffix: size.suffix - })) - ]; - const { pngs, jpgs } = AcceptibleMedia; - const lower = ext.toLowerCase(); - if (pngs.includes(lower)) { - resizers.forEach(element => element.resizer = element.resizer.png()); - } else if (jpgs.includes(lower)) { - resizers.forEach(element => element.resizer = element.resizer.jpeg()); - } else { - throw new Error(red(`The following image extension is unsupported: ${cyan(lower)}`)); - } - for (const { resizer, suffix } of resizers) { - await new Promise((resolve, reject) => { - const filename = InjectSize(outName, suffix); - createReadStream(initialWritePath).pipe(resizer).pipe(createWriteStream(path.resolve(imageDir, filename))) - .on('close', resolve) - .on('error', reject); + for (const { resizer, suffix } of resizers(ext)) { + const filePath = path.resolve(imageDir, InjectSize(outName, suffix)); + await new Promise(async (resolve, reject) => { + const writeStream = createWriteStream(filePath); + const readStream = await streamImage(); + let source = readStream; + if (resizer) { + source = readStream.pipe(resizer.withMetadata()); + } + const out = source.pipe(writeStream); + out.on("close", resolve); + out.on("error", reject); }); } - unlinkSync(initialWritePath); outNames.push(`http://localhost:1050/files/images/buxton/${outName}`); } return outNames; } -function analyze(pathToDocument: string, { body, images }: DocumentContents): AnalysisResult { - const filename = path.basename(pathToDocument).replace("Bill_Notes_", ""); - console.log(`Parsing ${filename}...`); - +function analyze(fileName: string, { body, images }: DocumentContents): AnalysisResult { const device: any = {}; - const errors: any = { filename }; + const errors: any = { fileName }; for (const key of deviceKeys) { const { exp, transformer, matchIndex } = RegexMap.get(key)!; @@ -296,7 +307,7 @@ function analyze(pathToDocument: string, { body, images }: DocumentContents): An const errorKeys = Object.keys(errors); if (errorKeys.length > 1) { - console.log(red(`\n@ ${cyan(filename.toUpperCase())}...`)); + console.log(red(`@ ${cyan(fileName.toUpperCase())}...`)); errorKeys.forEach(key => key !== "filename" && console.log(red(errors[key]))); return { errors }; } diff --git a/src/scraping/buxton/final/json/buxton.json b/src/scraping/buxton/final/json/buxton.json index 7e03f994c..e21fdd2ab 100644 --- a/src/scraping/buxton/final/json/buxton.json +++ b/src/scraping/buxton/final/json/buxton.json @@ -21,7 +21,7 @@ "shortDescription": "The CadMan is a 6 degree of freedom (DOF) joystick controller. It represented a significant step towards making this class of is controller affordable. It was mainly directed at 3D modelling and animation and was a “next generation” of the Magellan controller, which is also in the collection.", "longDescription": "The CadMan is a 6 degree of freedom (DOF) joystick controller. It represented a significant step towards making this class of is controller more affordable. It was mainly directed at 3D modelling and animation and was a “next generation” of the Magellan/SpaceMouse controller, which is also in the collection. Like the Magellan, this is an isometric rate-control joystick. That is, it rests in a neutral central position, not sending and signal. When a force is applied to it, it emits a signal indicating the direction and strength of that force. This signal can then be mapped to a parameter of a selected object, such as a sphere, and – for example – cause that sphere to rotate for as long as, and as fast as, and in the direction determined by, the duration, force, and direction of the applied force. When released, it springs back to neutral position. Note that the force does not need to be directed along a single DOF. In fact, a core feature of the device is that one can simultaneously and independently apply force that asserts control over more than one DOF, and furthermore, vary those forces dynamically. As an aid to understanding, let me walk through some of the underlying concepts at play here by using a more familiar device: a computer mouse. If you move a mouse in a forward/backward direction, the mouse pointer on the screen moves between the screen’s top and bottom. If you think of the screen as a piece of graph paper, that corresponds to moving along the “Y” axis. That is one degree of freedom. On the other hand, you could move the mouse left and right, which causes the mouse to move between the left and right side of the screen. That would correspond to moving along the graph paper’s “X” axis – a second degree of freedom. Yet, you can also move the mouse diagonally. This is an example of independently controlling two degrees of freedom. Now imagine that if you lifted your mouse off your desktop, that your computer could dynamically sense its height as you did so. This would constitute a “flying mouse” (the literal translation of the German word for a “Bat”, which Canadian colleague, Colin Ware, applied to just such a mouse which he built in 1988). If you moved your Bat vertically up and down, perpendicular to the desktop, you would be controlling movement along the “Z” axis - a third degree of freedom. Having already seen that we can move a mouse diagonally, we have established that we need not be constrained to only moving along a single axis. That extends to the movement of our Bat and movement along the “Z” axis. We can control our hand movement in dependently in any or all directions in 3D space. But how does one reconcile the fact that we call the CadMan a “3D controller, and yet also describe it as having 6 degrees of freedom? After all, the example this far demonstrates that our Bat, as described thus far, has freedom on movement in 3 Dimensions. While true, we can extend our example to prove that that freedom to move in 3D is also highly constrained. To demonstrate this, move your hand in 3D space on and above your desktop. However, do so keeping your palm flat, parallel to the desktop with your fingers pointing directly forward. In so doing, you are still moving in 3D. Now, while moving, twist your wrist, while moving the hand, such that your palm is alternatively exposed to the left and right side. This constitutes rotation around the “Y” axis. A fourth DOF. Now add a waving motion to your hand, as if it were a paper airplane diving up and down, while also rocking left and right. But keep your fingers pointing forward. You have now added a fifth DOF, rotation around the “X” axis. Finally, add a twist to your wrist so that your fingers are no longer constrained to pointing forward. This is the sixth degree of freedom, rotation around the “Z” axis. Now don’t be fooled, this exercise could continue. We are not restricted to even six DOF. Imagine doing the above, but where the movement and rotations are measured relative to the Bat’s position and orientation, rather than to the holding/controlling hand, per se. One could imagine the Bat having a scroll wheel, like the one on most mice today. Furthermore, while flying your Bat around in 3D, that wheel could easily be rolled in either forward or backward, and thereby control the size of whatever was being controlled. Hence, with one hand we could assert simultaneous and independent control over 7 DOF in 3D space. This exercise has two intended take-aways. The first is a better working understanding between the notion of Degree of Freedom (DOF) and Dimension in space. Hopefully, the confusion frequently encountered when 3D and 6DOF are used in close context, can now be eliminated. Second, is that, with appropriate sensing, the human hand is capable of exercising control over far more degrees of freedom that six. And if we use the two hands together, the potential number of DOF that one can control goes even further. Finally, it is important to add one more take-away – one which both emerges from, and is frequently encountered when discussing, the previous two. That is, do not equate exercising simultaneous control over a high number of DOF with consciously doing the same number of different things all at once. The example that used to be thrown at me when I started talking about coordinated simultaneously bi-manual action went along the lines of, “Psychology tells us that we cannot do multiple things at once, for example, simultaneously tapping your head and rubbing your stomach. ”Well, first, I can tap my head with one hand while rubbing my stomach with the other. But that is not the point. The whole essence of skill – motor-sensory and cognitive – is “chunking” or task integration. When one appears to be doing many different things at once, if they are skilled, they are consciously doing only one thing. Playing a chord on the piano, for example, or skiing down the hill. Likewise, in flying your imaginary BAT in the previous exercise with the scroll wheel, were you doing 7 things at once, or one thing with 7 DOF? And if you had a Bat in each hand, does that mean you are now doing 14 things at once, or are you doing one thing with 14 DOF? Let me provide a different way of answering this question: if you have ever played air guitar, or “conducted” the orchestra that you are listening to on the radio, you are exercising control over more than 14 DOF. And you are doing exactly what I just said, “playing air guitar” or “conducting an orchestra”. One thing – at the conscious level, which is what matters – despite almost any one thing being able to be deconstructed into hundreds of sub-tasks. As I said the essence of skill: aggregation, or chunking. What is most important for both tool designers and users to be mindful of, is the overwhelming influence that our choice and design of tools impacts the degree to which such integration or chunking can take place. The degree to which the tool matches both the skills that we have already acquired through a lifetime of living in the everyday world, and the demands of the intended task, the more seamless that task can be performed, the more “natural” it will feel, and the less learning will be required. In my experience, it brought particular value when used bimanually, in combination with a mouse, where the preferred hand performed conventional pointing, selection and dragging tasks, while the non-preferred hand could manipulate the parameters of the thing being selected. First variation of the since the 2001 formation of 3Dconnextion. The CadMan came in 5 colours: smoke, orange, red, blue and green. See the notes for the LogiCad3D Magellan for more details on this class of device. It is the “parent” of the CadMan, and despite the change in company name, it comes from the same team.", "__images": [ - "http://localhost:1050/files/images/buxton/upload_bbb130a4-93ca-49da-b3e5-b04085a8feeb.jpeg" + "http://localhost:1050/files/images/buxton/upload_66c8dfe3-2189-4961-ae90-6a3d73fc993a.jpeg" ] }, { @@ -46,11 +46,11 @@ "shortDescription": "The Mini-Touch Keyboard is a surprisingly rare device: a laptop-style, small-footprint keyboard with a centrally mounted touch-pad. .", "longDescription": "First released in 2003 with a PS/2 connector (ACK-540PW & ACK-540PB). USB version released in 2006 in either black (ACK-540UB) or white (ACK-540UW). Marketed under different brands, including SolidTek: http: //www. tigerdirect. com/applications/searchtools/item-details. asp? EdpNo=1472243https: //acecaddigital. com/index. php/products/keyboards/mini-keyboards/kb-540 Deltaco: https: //www. digitalimpuls. no/logitech/116652/deltaco-minitastatur-med-touchpad-usb", "__images": [ - "http://localhost:1050/files/images/buxton/upload_44901fa7-e293-4f27-b3cc-bb7e0415d9d2.jpeg", - "http://localhost:1050/files/images/buxton/upload_58f566f7-8e84-48bf-9e3d-e974b52caa75.jpeg", - "http://localhost:1050/files/images/buxton/upload_7df72145-dc38-4594-bb78-d97f3150cd13.jpeg", - "http://localhost:1050/files/images/buxton/upload_d0abf60d-674e-42c3-a508-aa5edc827d7e.jpeg", - "http://localhost:1050/files/images/buxton/upload_52ef0124-67ae-47f6-8b48-b6cf8b7ebb02.jpeg" + "http://localhost:1050/files/images/buxton/upload_e4d05959-02fd-4ba7-8828-f6ebdaab4cf5.jpeg", + "http://localhost:1050/files/images/buxton/upload_d30328a1-c01f-4e2d-b1d1-5e3bec8301d5.jpeg", + "http://localhost:1050/files/images/buxton/upload_58b128b2-ea2b-43a2-b13c-e50a81bfe59e.jpeg", + "http://localhost:1050/files/images/buxton/upload_2dea0de3-8cb5-4111-89d7-634f8cd337f1.jpeg", + "http://localhost:1050/files/images/buxton/upload_bf6c0689-c0ef-45ee-bdcc-1be5dcf095e2.jpeg" ] }, { @@ -76,17 +76,17 @@ "shortDescription": "The 1958 Braun T3 transistor radio, designed by Dieter Rams Dieter Rams in conjunction with the Ulm Hochschüle fur Gestaltung (School of Design). An excellent example of the international style of design of the mid-20th century, the T3 radio was the inspiration for the design language of the Apple iPod Classic.", "longDescription": "The 1958 Braun T3 transistor radio is a classic of the international design style prevalent in the mid-20th century. By its sparse clean lines, it shares characteristics of the style seen in another familiar example, the font Helvetic, which was designed the previous year. The T3 was designed by Dieter Rams, recruited by Braun in 1955, in collaboration with the Ulm Hochschüle fur Gestaltun. . Its design language had a strong influence on that of the original Apple iPod Classic. The connection is made more obvious if one views the radio rotated 90° clockwise, as in one of the accompanying photographs. Here one can easily see the the similarity of proportions, uniformity of colour, angle of corners, location of display (audio versus visual), and the use of a flush rotary wheel controller.", "__images": [ - "http://localhost:1050/files/images/buxton/upload_48454590-fca2-4c13-9150-cca6ca7fa84c.jpeg", - "http://localhost:1050/files/images/buxton/upload_9c9be169-c20f-4f2a-9e06-42911b15a246.jpeg", - "http://localhost:1050/files/images/buxton/upload_be6e2823-3ca4-4a8f-92d3-ddcca192284f.jpeg", - "http://localhost:1050/files/images/buxton/upload_ee84b638-a549-445a-8e46-3a81de2ee5c6.jpeg", - "http://localhost:1050/files/images/buxton/upload_f8a8d123-6123-4351-906d-8fbcf5103de9.jpeg", - "http://localhost:1050/files/images/buxton/upload_330f5041-58ec-4dc1-9c99-1533571dc4e3.jpeg", - "http://localhost:1050/files/images/buxton/upload_dcb15d54-bc7a-4274-ab44-caab994b23fd.jpeg", - "http://localhost:1050/files/images/buxton/upload_3c4226b8-0974-4b89-96af-1f52fa966e0b.jpeg", - "http://localhost:1050/files/images/buxton/upload_6831d2f6-a1f8-4da6-aa29-44b20a8a9234.jpeg", - "http://localhost:1050/files/images/buxton/upload_8f98f914-fc2b-481a-bf65-ebf061c366a0.jpeg", - "http://localhost:1050/files/images/buxton/upload_4a0c6152-1ad2-4a0c-9fdd-43c135308f59.jpeg" + "http://localhost:1050/files/images/buxton/upload_53aa0503-c47a-4096-b7a3-2cb00fadfb2b.jpeg", + "http://localhost:1050/files/images/buxton/upload_b3375e17-b2e7-46d9-b2fe-0006a2f33248.jpeg", + "http://localhost:1050/files/images/buxton/upload_59a99128-94d3-450d-9087-eabcc843a9e1.jpeg", + "http://localhost:1050/files/images/buxton/upload_89a7386e-529a-40dd-8e4c-2cea9df7397b.jpeg", + "http://localhost:1050/files/images/buxton/upload_8a4b433b-aeb7-4b88-a719-d6902648bb7b.jpeg", + "http://localhost:1050/files/images/buxton/upload_68310009-99b8-464b-8c07-290b0a12b8e9.jpeg", + "http://localhost:1050/files/images/buxton/upload_02bfc038-858b-4907-83bd-2e41a4fddadb.jpeg", + "http://localhost:1050/files/images/buxton/upload_adb25cdb-96f7-48a3-b2c2-945d5a0fdf47.jpeg", + "http://localhost:1050/files/images/buxton/upload_772e252c-2812-422e-9857-a5c2b245ee63.jpeg", + "http://localhost:1050/files/images/buxton/upload_6f714261-c92a-401b-9e4e-f2e2b4b39df9.jpeg", + "http://localhost:1050/files/images/buxton/upload_6c8bbded-57c2-441f-9ffd-86f7c05c9816.jpeg" ] }, { @@ -114,13 +114,13 @@ "shortDescription": "One of the first programable polyphonic (8 simultaneous voices) digital synthesizers for less than $500. 00. Used a form of digital synthesis known as Phase Distortion to obtain a rich variety of dynamic timbres. Could be used with batteries or plugged in to power. This one was given to me at the product launch.", "longDescription": "One of the first programable polyphonic (8 simultaneous voices) digital synthesizers for less than $500. 00. Used a form of digital synthesis known as Phase Distortion to obtain a rich variety of dynamic timbres. Could be used with batteries or plugged in to power. This one was given to me at the product launch. The inclusion of this synthesizer in the collection is as a small reminder of the diversity of keyboard types, and especially, as an example to shed light on chord keyboards. In entering text, for example, chord keyboards are those where more than one key must be simultaneously pressed to enter a single character. Technically, this includes any keyboard with a SHIFT key. Interestingly, piano-type like keyboards like that on the Casio-CZ-101 probably don’t conform to this definition of chording, despite its ability to play musical chords. On the other hand, flutes and trumpets definitely do fall within the definition. Why? With piano-like keyboards, each unique note has a single unique key dedicated to it. When one plays a chord, i. e. , simultaneously presses multiple keys, the result is a chord of notes – the note associated with each depressed key sounds. On the other hand, with trumpet valves or flute keys, only one note is produced at a time. It is the combination of keys pressed (coupled with breath) which determines the pitch of that single note. This is far closer to entering text with a chord keyboard, where each chord enters a single unique character.", "__images": [ - "http://localhost:1050/files/images/buxton/upload_94158aa7-0b43-4cc3-ba77-7785221a7735.jpeg", - "http://localhost:1050/files/images/buxton/upload_be109908-553b-43ed-8e92-464e5323e330.jpeg", - "http://localhost:1050/files/images/buxton/upload_9cb889cb-d5fd-4ec5-841f-cad45657bd48.jpeg", - "http://localhost:1050/files/images/buxton/upload_1fedc58f-1f83-467b-8bc9-855bf40fe44c.jpeg", - "http://localhost:1050/files/images/buxton/upload_a489dc78-2ef2-4293-a18d-f6cd0559c540.jpeg", - "http://localhost:1050/files/images/buxton/upload_05875f1f-e5ea-4731-af4a-9c21faac9494.jpeg", - "http://localhost:1050/files/images/buxton/upload_148e88c1-4a14-4c52-aa61-175908f28a53.jpeg" + "http://localhost:1050/files/images/buxton/upload_df430dd3-a434-46ca-b492-af5f5ba49421.jpeg", + "http://localhost:1050/files/images/buxton/upload_f13396a9-1eaa-470c-93ad-689f667d1b56.jpeg", + "http://localhost:1050/files/images/buxton/upload_f8a7a40d-b90c-4ff8-b806-4f09fbb40a64.jpeg", + "http://localhost:1050/files/images/buxton/upload_7c98bb49-6ce0-41c7-83b3-501c8d056ddf.jpeg", + "http://localhost:1050/files/images/buxton/upload_edb3a794-0589-465d-9dc8-1d159687ebde.jpeg", + "http://localhost:1050/files/images/buxton/upload_8fac6637-f613-4bbf-9ec1-8ac5d4e957e8.jpeg", + "http://localhost:1050/files/images/buxton/upload_0862ad91-7709-43e1-93fb-02d5c6015de4.jpeg" ] }, { @@ -144,20 +144,20 @@ "shortDescription": "This is a plastic shell within which the round Apple iMac G3 “Hockey Puck” mouse can be fit. While the G3 Mouse worked well mechanically, when gripped its round shape gave few cues as to its orientation. Hence, if you moved your hand up, the screen pointer may well have moved diagonally. By reskinning it with the inexpensive Contour UniTrap, the problem went away without the need to buy a whole new mouse.", "longDescription": "Also add back pointers from devices re-skinned", "__images": [ - "http://localhost:1050/files/images/buxton/upload_888eda2f-8bf7-4cb8-b8d2-92bb7a8e3a8d.jpeg", - "http://localhost:1050/files/images/buxton/upload_e174fcc1-d360-4950-969a-ad0f2d3605a9.jpeg", - "http://localhost:1050/files/images/buxton/upload_17c23bfb-1568-48f2-8515-045298243106.jpeg", - "http://localhost:1050/files/images/buxton/upload_3d193a3f-85e2-4228-beee-4dca12dde7fc.jpeg", - "http://localhost:1050/files/images/buxton/upload_2b57c348-ae9e-4ee2-a975-09c7df168c6a.jpeg", - "http://localhost:1050/files/images/buxton/upload_9a56358c-f9a9-4fd4-8b4c-4631622ba8b6.jpeg", - "http://localhost:1050/files/images/buxton/upload_eb885a68-5b68-423e-bc60-2dff2a2743fa.jpeg", - "http://localhost:1050/files/images/buxton/upload_d0d265a9-4b6d-4b11-ac77-f0d6430a2097.jpeg", - "http://localhost:1050/files/images/buxton/upload_5dfcdae9-3a7f-4301-85af-5c7a4ed2d11a.jpeg", - "http://localhost:1050/files/images/buxton/upload_7b154538-17d6-4ae3-8afc-fc2524cbc423.jpeg", - "http://localhost:1050/files/images/buxton/upload_0931bbca-4398-4841-8a53-b385b5f700b6.jpeg", - "http://localhost:1050/files/images/buxton/upload_9b0901b5-4cd7-4d65-a6e3-635b8054957c.jpeg", - "http://localhost:1050/files/images/buxton/upload_a91355d7-8865-442f-ae4a-25698697c01f.jpeg", - "http://localhost:1050/files/images/buxton/upload_66bf6743-d095-4e77-b1a8-196e18cdd97b.jpeg" + "http://localhost:1050/files/images/buxton/upload_bc2ba949-8175-412d-8226-5035fe2eab08.jpeg", + "http://localhost:1050/files/images/buxton/upload_f6aec3a6-223d-4761-b664-c7478dcc115a.jpeg", + "http://localhost:1050/files/images/buxton/upload_7af7ba0a-1e4c-4964-987e-61d164a71c4d.jpeg", + "http://localhost:1050/files/images/buxton/upload_cbc32bae-ca1a-4819-af5f-2875a8896825.jpeg", + "http://localhost:1050/files/images/buxton/upload_39edc984-6a36-4ddf-a35b-d506d245c0b4.jpeg", + "http://localhost:1050/files/images/buxton/upload_041fc0ab-71b5-42ce-8f77-2b4a395a4ed4.jpeg", + "http://localhost:1050/files/images/buxton/upload_7d0eaa3a-42ef-4df7-911e-d6143d3d3c38.jpeg", + "http://localhost:1050/files/images/buxton/upload_dd53fd31-5e09-4ed1-ad4f-7faf4bed7663.jpeg", + "http://localhost:1050/files/images/buxton/upload_3361e3f5-9a29-4f9d-b3db-41f7360d4ca5.jpeg", + "http://localhost:1050/files/images/buxton/upload_50acf910-1036-4bb6-9aa8-3d8431322aed.jpeg", + "http://localhost:1050/files/images/buxton/upload_4db5fc30-3f66-4490-87b5-a4daeae2682f.jpeg", + "http://localhost:1050/files/images/buxton/upload_c354b945-0362-4c7f-b912-c8a44c435633.jpeg", + "http://localhost:1050/files/images/buxton/upload_5b1f1e5d-204b-4aaa-98c9-e0d13945c6f4.jpeg", + "http://localhost:1050/files/images/buxton/upload_75f916b8-3409-45a4-a91e-20cd9e60bf35.jpeg" ] }, { @@ -184,17 +184,17 @@ "shortDescription": "This mouse is one of the first commercially available mice to be sold publicly. It is known as the Swiss mouse, and yes, the roller mechanism was designed by a Swiss watchmaker. Coincidentally, the company that made it, Depraz, is based in Apples, Switzerland. Their success in selling this mouse is what caused Logitech to switch from a software development shop to one of the world’s leading suppliers of mice and other input devices.", "longDescription": "DePraz began manufacturing in 1980, but following design built in 1979. Logitech started selling it in 1982. It was one of the first mass produced mice, one of the first available ball mice, as well as to have an optical shaft encoder – thereby improving linearity. An interesting fact, given its Swiss heritage, is that its designer, André Guignard, was trained as a Swiss watch maker. Unlike most modern mice, the DePraz, or “Swiss” mouse had a quasi-hemispherical shape. Hence, it was held in a so-called “power-grip”, much as one would grip a horizontally held ball – the thumb and small finger applying pressure on each side, with added support from the weight/friction of the palm on the back of the mouse. In this posture, the three middle fingers naturally positioning themselves over the three buttons mounted at the lower edge of the front. Largely freed of grip pressure, by grace of thumb and little finger, the middle fingers had essentially freedom of motion to independently operate the buttons. Each having a dedicated finger, the buttons could be easily pushed independently or in any combination. Like the three valves on a trumpet, this ability to “chord” extended the three physical buttons to have the power of seven. The down-side of this “turtle shell” form factor is that it placed the hand in a posture in which mouse movement relied more of the larger muscle groups of the arm to wrist, rather than wrist to fingers – the latter being the approach taken in most subsequent mice. The original Swiss Mouse was developed at École Polytechnique Fédérale de Lausanne by a project led by Jean-Daniel Nicoud, who was also responsible for the development of its optical shaft encoder. To augment their revenue stream, Logitech, then a software and hardware consulting company for the publishing industry, acquired marketing rights for North America. Mouse revenue quickly overshadowed that from software. In 1983, Logitech acquired DePraz, named the Swiss Mouse the “P4”, and grew to become one of the largest input device manufacturer in the world. One curious coincidence is that they were founded in the town of Apples, Switzerland.", "__images": [ - "http://localhost:1050/files/images/buxton/upload_14617b2b-d1ba-43a8-a180-aba20121bafc.jpeg", - "http://localhost:1050/files/images/buxton/upload_ed4007e9-75fe-44ac-93ed-4c79dc1c895c.jpeg", - "http://localhost:1050/files/images/buxton/upload_95a55eda-ec2b-49a5-96bf-857b1c154c21.jpeg", - "http://localhost:1050/files/images/buxton/upload_9bb45417-f788-4761-bc71-dc152c80ecec.jpeg", - "http://localhost:1050/files/images/buxton/upload_87d92485-1f72-440a-abeb-ea4119797f29.jpeg", - "http://localhost:1050/files/images/buxton/upload_7f593e84-8192-4e7a-9d65-d449e0d27bb6.jpeg", - "http://localhost:1050/files/images/buxton/upload_a330e901-765a-4393-9900-efcabff8a4ee.jpeg", - "http://localhost:1050/files/images/buxton/upload_e64b9efb-8855-49a2-a5bd-c19c2375f291.jpeg", - "http://localhost:1050/files/images/buxton/upload_3510dbe4-1371-4522-9822-944ff86784f8.jpeg", - "http://localhost:1050/files/images/buxton/upload_446bd02f-b6ed-4514-8b9c-01f659ffe9f5.jpeg", - "http://localhost:1050/files/images/buxton/upload_62741842-224d-42ed-a2d2-a7a22051d744.jpeg" + "http://localhost:1050/files/images/buxton/upload_1484cd99-d874-4e99-b24c-aca258ef1ed7.jpeg", + "http://localhost:1050/files/images/buxton/upload_e62cb61a-963d-4e49-9217-b000ac8fe044.jpeg", + "http://localhost:1050/files/images/buxton/upload_bf8ecc55-7b89-466c-810a-3f62b976e00a.jpeg", + "http://localhost:1050/files/images/buxton/upload_5de751a1-2c6b-4867-9107-7056eb3c53b4.jpeg", + "http://localhost:1050/files/images/buxton/upload_6fc85d4b-389a-4eb5-8e55-c1c1bcb90f99.jpeg", + "http://localhost:1050/files/images/buxton/upload_141e7bbf-4228-4ace-94b0-74e302132f2f.jpeg", + "http://localhost:1050/files/images/buxton/upload_62cc6a37-1b40-45b3-ab02-aafbd29ed12b.jpeg", + "http://localhost:1050/files/images/buxton/upload_32ec9dde-ce9b-4516-bd01-41c451835ca4.jpeg", + "http://localhost:1050/files/images/buxton/upload_c91b2995-fe34-4b84-850e-d639c83d11e4.jpeg", + "http://localhost:1050/files/images/buxton/upload_9b4cab52-d6ad-4d8b-baa3-3583ff371f8c.jpeg", + "http://localhost:1050/files/images/buxton/upload_62d2f5ac-0b0c-4317-a3c6-08507f339518.jpeg" ] }, { @@ -223,19 +223,19 @@ "shortDescription": "The TouchStream is a keyboard based on a pair of multi-touch pads. These can sense key taps and finger gestures. The “keys” are graphic. They are flush with the pad and have no mechanical movement. There are however, small raised points to help position the hands on the keyboard eyes-free typing, but these still allow the fingers slide easily on the surface when gesturing, such as when emulating a mouse. . The keyboard is independent of the base. It can be folded in half for compact portability. It can also be placed conveniently over a laptop’s keyboard as a replacement which then also enables the gesture enhancements to be used on the road. Although not obvious to the eye, this is the core technology which, after being acquired by Apple, evolved into the iPhone’s multi-touch capability.", "longDescription": "Named FingerBoard during development, this product was relabeled TouchStream in October 2001 as the release date approached. when finally shipped, was renamed TouchStreamThe very rare original stand for this device was a gift from Sean Gerety, Atlanta, GA.", "__images": [ - "http://localhost:1050/files/images/buxton/upload_3b4e09ce-6c1a-407d-b1da-37b79eee37e9.jpeg", - "http://localhost:1050/files/images/buxton/upload_c7428265-ef33-4743-b51c-ea3c87e27553.jpeg", - "http://localhost:1050/files/images/buxton/upload_7ccaad34-626d-4ffa-a10f-09663700581e.jpeg", - "http://localhost:1050/files/images/buxton/upload_ea9ef52f-796f-4814-aa79-5c9750f5fc25.jpeg", - "http://localhost:1050/files/images/buxton/upload_44fd7f73-4d57-4b57-aada-d9cc4a5b5142.jpeg", - "http://localhost:1050/files/images/buxton/upload_419e04ca-1543-40cf-9003-eb076aa395d9.jpeg", - "http://localhost:1050/files/images/buxton/upload_cf68f667-7169-40cc-a7cd-c6450920a2a3.jpeg", - "http://localhost:1050/files/images/buxton/upload_3558958e-dc6e-4f13-8b5f-b68d7e346c0d.jpeg", - "http://localhost:1050/files/images/buxton/upload_fc9f8745-d165-425c-942e-efc417278f0f.jpeg", - "http://localhost:1050/files/images/buxton/upload_2b59a047-f37e-42bc-9cf3-08561b5d8c23.jpeg", - "http://localhost:1050/files/images/buxton/upload_35599252-adc5-483f-83b8-6a97615c8e9d.jpeg", - "http://localhost:1050/files/images/buxton/upload_947590a1-33ed-4eb1-aba1-d9805bc35ea6.jpeg", - "http://localhost:1050/files/images/buxton/upload_1fb4778f-572f-4834-824a-183094f4e28f.jpeg" + "http://localhost:1050/files/images/buxton/upload_c958ad24-60ee-412e-bf04-de1bd46e89b5.jpeg", + "http://localhost:1050/files/images/buxton/upload_9254afca-6194-4b43-b2f6-b34324302aa1.jpeg", + "http://localhost:1050/files/images/buxton/upload_165396df-d012-4f5c-a94b-a83fe726c7dc.jpeg", + "http://localhost:1050/files/images/buxton/upload_2dd40e3e-3498-4269-ae7c-edfa823550a6.jpeg", + "http://localhost:1050/files/images/buxton/upload_b45f76ee-0761-47b8-8649-bfa3e0f42e8a.jpeg", + "http://localhost:1050/files/images/buxton/upload_5e840ede-823d-413d-99c9-261b84eab8f1.jpeg", + "http://localhost:1050/files/images/buxton/upload_b943f1bc-16a9-4136-b57d-057382b2e439.jpeg", + "http://localhost:1050/files/images/buxton/upload_52a94706-eba2-4763-bf25-e26db067b1d6.jpeg", + "http://localhost:1050/files/images/buxton/upload_6157538d-c52f-4f81-b871-bed3576387e2.jpeg", + "http://localhost:1050/files/images/buxton/upload_061cc221-da33-4777-a605-f47c7615d640.jpeg", + "http://localhost:1050/files/images/buxton/upload_3f9689eb-6a15-4cce-a029-2c6f78255dba.jpeg", + "http://localhost:1050/files/images/buxton/upload_e44bd889-bf3e-4775-88eb-953a00774f32.jpeg", + "http://localhost:1050/files/images/buxton/upload_e017220f-df12-4a1a-8f06-14c73a4b0424.jpeg" ] }, { @@ -263,17 +263,17 @@ "shortDescription": "The OLPC XO-1 is very innovative device that nevertheless raises serious issues about technology and social responsibility. It is included in the collection primarily as a warning against technological hubris, and the fact that no technologies are neutral from a social-cultural perspective.", "longDescription": "IntroductionI have this computer in my collection as a reminder of the delicate relationship between object and purpose, and how no matter how well one does on the former, it will likely have no impact on making a wanting concept achieve the stated (and even valid) purpose any better. I include it in the collection as a cautionary tale of how the object may help sell a concept, regardless how ill-conceived – even to those who should know better, had they applied the most basic critical thinking. For consumers, investors and designers, its story serves as a cautionary reminder to the importance of cultivating and retaining a critical mind and questioning perspective, regardless of how intrinsically seductive or well-intentioned a technology may be. From the perspective of hardware and software, what the One Laptop Per Child (OLPC) project was able to accomplish is impressive. In general, the team delivered a computer that could be produced at a remarkably low price – even if about double that which was targeted. Specifically, the display, for example, is innovative, and stands out due to its ability to work both in the bright sun (reflective) as well as in poorly lit spaces (emissive) – something that goes beyond pretty much anything else that is available on today’s (2017) slate computers or e-readers. In short, some excellent work went into this machine, something that is even more impressive, given the nature of the organization from which it emerged. The industrial design was equally impressive. Undertaken by Yves Behar’s FuseprojectUltimately, however, the machine was a means to an end, not the end itself. Rather than a device, the actual mission of the OLPC project was: … to empower the world's poorest children through education. Yet, as described by in their materials, the computer was intended to play a key role in this: With access to this type of tool [the computer], children are engaged in their own education, and learn, share, and create together. They become connected to each other, to the world and to a brighter future. Hence, making a suitable computer suitable to that purpose and the conditions where it would be used, at a price point that would enable broad distribution, was a key part of the project. The Underlying Belief System of the OLPC ProjectSince they are key to the thinking behind the OLPC project, I believe if fair to frame my discussion around the following four questions: Will giving computers to kids in the developing world improve their education? Will having a thus better-educated youth help bring a society out of poverty? Can that educational improvement be accomplished by giving the computers to the kids, with no special training for teachers? Should this be attempted on a global scale without any advance field trials or pilot studies? From the perspective of the OLPC project, the answer to every one of these questions is an unequivocal “yes”. In fact, as we shall see, any suggestion to the contrary is typically answered by condescension and/or mockery. The answers appear to be viewed as self-evident and not worth even questioning. Those who have not subscribed to this doctrine might call such a viewpoint hubris. What staggers me is how the project got so far without the basic assumptions being more broadly questioned, much less such questions being seriously addressed by the proponents. How did seemingly otherwise people commit to the project, through their labour or financial investment, given the apparently naïve and utopian approach that it took? Does the desire to do good cloud judgment that much? Are we that dazzled by a cool technology or big hairy audacious goal? Or by a charismatic personality? To explain my concern, and what this artifact represents to me, let me just touch on the four assumptions on which the project was founded. Will giving computers to kids in the developing world improve education? The literature on this question is, at best, mixed. What is clear is that one cannot make any assumption that such improvements will occur, regardless of whether one is talking about the developing world or suburban USA. For example, in January 2011, The World Bank published the following study: Can Computers Help Students Learn? From Evidence to Policy, January 2011, Number 4, The World Bank. A public-private partnership in Colombia, called Computers for Education, was created in 2002 to increase the availability of computers in public schools for use in education. Since starting, the program has installed more than 73, 000 computers in over 6, 300 public schools in more than 1, 000 municipalities. By 2008, over 2 million students and 83, 000 teachers had taken part. This document reports on a two-year study to determine the impact of the program on student performance. Students in schools that received the computers and teacher training did not do measurably better on tests than students in the control group. Nor was there a positive effect on other measures of learning. Researchers did not find any difference in test scores when they looked at specific components of math and language studies, such as algebra and geometry, and grammar and paraphrase ability in Spanish. But report also notes that results of such studies are mixed: Studies on the relationship between using computers in the classroom and improved test scores in developing countries give mixed results: A review of Israel’s Tomorrow-98 program in the mid-1990s, which put computers in schools across the country, did not find any impact on math and Hebrew language scores. But in India, a study of a computer-assisted learning program showed a significant positive impact on math scores. One thing researchers agree on, more work is needed in this field. Before moving on, a search of the literature will show that these results are consistent with those that were available in the literature at the time that the project was started. The point that I am making is not that the OLPC project could not be made to work; rather, that it was wrong to assume that it would do so without spending at least as much time designing the process to bring that about, as was expended designing the computer itself. Risk is fine, and something that can be mitigated. But diving in under the assumption that it would just work is not calculated risk, it is gambling - with other people’s lives, education and money. Will a better educated population help bring a society out of poverty? I am largely going to punt on this question. The fact is, I would be hard pressed to argue against education. But let us grant that improving education in the developing world is a good thing. The appropriate question is: is the approach of the OLPC project a reasonable or responsible way to disburse the limited resources that are available to address the educational challenges of the developing world? At the very least, I would suggest that this is a topic worthy of debate. An a priori assumption that giving computers is the right solution is akin to the, “If you build it they will come” approach seen in the movie, Field of Dreams. The problem here is that this is not a movie. There are real lives and futures that are at stake here – lives of those who cannot afford to see the movie, much less have precious resources spent on projects that are not well thought through. Can that improvement be accomplished by just giving the computers to the kids without training teachers? Remarkably, the OLPC Project’s answer is an explicit, “Yes”. In a TED talk filmed in December 2007, the founder of the OLPC initiative, Nicholas Negroponte states: “When people tell me, you know, who’s going to teach the teachers to teach the kids, I say to myself, “What planet do you come from? ” Okay, there’s not a person in this room [the TED Conference], I don’t care how techy you are, there’s not a person in this room that doesn’t give their laptop or cell phone to a kid to help them debug it. Okay, we all need help, even those of us who are very seasoned. ”Let us leave aside the naïvete of this statement stemming from the lack of distinction between ability to use applications and devices versus the ability to create and shape them. A failure of logic remains in that those unseasoned kids are part of “us”, as in “we all need help”. Where do the kids go for help? To other kids? What if they don’t know? Often they won’t. After all, the question may well have to do with a concept in calculus, rather than how to use the computer. What then? No answer is offered. Rather, those who dare raise the serious and legitimate concerns regarding teacher preparation are mockingly dismissed as coming from another planet! Well, perhaps they are. But in that case, there should at least be some debate as to who lives on which planet. Is it the people raising the question or the one dismissing the concern that lives in the real world of responsible thought and action? Can this all be accomplished without any advance field trials? Should one just immediately commit to international deployment of the program? As recently as September 2009, Negroponte took part in a panel discussion where he spoke on this matter. He states: I'd like you to imagine that I told you \"I have a technology that is going to change the quality of life. \" And then I tell you \"Really the right thing to do is to set up a pilot project to test my technology. And then the second thing to do is, once the pilot has been running for some period of time, is to go and measure very carefully the benefits of that technology. \"And then I am to tell you that what we are going to is very scientifically evaluate this technology, with control groups - giving it to some, giving it to others. And this all is very reasonable until I tell you the technology is electricity. And you say \"Wait, you don't have to do that!\"But you don't have to do that with laptops and learning either. And the fact that somebody in the room would say the impact is unclear is to me amazing - unbelievably amazing. There's not a person in this room who hasn't bought a laptop for their child, if they could afford it. And you don't know somebody who hasn't done it, if they can afford it. So there's only one question on the table and that's, “How to afford it? ” That's the only question. There is no other question - it's just the economics. And so, when One Laptop Per Child started, I didn't have the picture quite as clear as that, but we did focus on trying to get the price down. We did focus on those things. Unfortunately, Negroponte demonstrates his lack of understanding of both the history of electricity and education in this example. His historical mistake is this: yes, it was pretty obvious that electricity could bring many benefits to society. But what happened when Edison did exactly what Negroponte advocates? He almost lost his company due to his complete (but mistaken) conviction that DC, rather the AC was the correct technology to pursue. As with electricity, yes, it is rather obvious that education could bring significant benefits to the developing world. But in order to avoid making the same kind of expensive mistake that Edison did, perhaps one might want to do one’s best to make sure that the chosen technology is the AC, rather than DC, of education. A little more research, and a little less hubris might have put the investments in Edison and the OLPC to much better use. But the larger question is this: in what way is it responsible for the wealthy western world to advocate an untested and expensive (in every sense) technological solution on the poorest nations in the world? If history has taught us anything, it has taught us that just because our intentions are good, the same is not necessarily true for consequences of our actions. Later in his presentation, Negroponte states: … our problems are swimming against very naïve views of education. With this, I have to agree. It is just whose views on education are naïve, and how can such views emerge from MIT, no less, much less pass with so little critical scrutiny by the public, the press, participants, and funders? In an interview with Paul Marks, published in the New Scientist in December 2008, we see the how the techno-centric aspect of the project plays into the ostensible human centric purpose of the project. Negroponte’s retort regarding some of the initial skepticism that the project provoked was this: “When we first said we could build a laptop for $100 it was viewed as unrealistic and so 'anti-market' and so 'anti' the current laptops which at the time were around $1000 each, \" Negroponte said. \"It was viewed as pure bravado - but look what happened: the netbook market has developed in our wake. \" The project's demands for cheaper components such as keyboards, and processors nudged the industry into finding ways to cut costs, he says. \"What started off as a revolution became a culture. \"Surprise, yes, computers get smaller, faster, and cheaper over the course of time, and yes, one can even grant that the OLPC project may have accelerated that inevitable move. And, I have already stated my admiration and respect for the quality of the technology that was developed. But in the context of the overall objectives of the project, the best that one can say is, “Congratulations on meeting a milestone. ” However, by the same token, one might also legitimately question if starting with the hardware was not an instance of putting the cart before the horse. Yes, it is obviously necessary to have portable computers in the first place, before one can introduce them into the classroom, home, and donate them to children in the developing world. But it is also the case that small portable computers were already in existence and at the time that the project was initiated. While a factor of ten more expensive than the eventual target price, they were both available and adequate to support limited preliminary testing of the underlying premises of the project in an affordable manner. That is, before launching into a major - albeit well-intentioned – hardware development project, it may have been prudent to have tested the underlying premises of its motivation. Here we have to return to the raison d’être of the initiative: … to empower the world's poorest children through educationHence, the extent to which this is achieved from a given investment must be the primary metric of success, as well as the driving force of the project. Yet, that is clearly not what happened. Driven by a blind Edisonian belief in their un-tested premise, the project’s investments were overwhelmingly on the side of technology rather than pedagogy. Perhaps the nature and extent of the naïve (but well-meaning) utopian dream underlying the project is captured in the last part of the interview, above: Negroponte believes that empowering children and their parents with the educational resources offered by computers and the Internet will lead to informed decisions that improve democracy. Indeed, it has led to some gentle ribbing between himself and his brother: John Negroponte - currently deputy secretary of state in the outgoing Bush administration and the first ever director of national intelligence at the National Security Agency. \"I often joke with John that he can bring democracy his way - and I'll bring it mine, \" he says. Apparently providing inexpensive laptops to children in the developing world is not only going to raise educational standards, eradicate poverty, it is also going to bring democracy! All that, with no mention of the numerous poor non-democratic countries that have literacy levels equal to or higher than the USA (Cuba might be one reasonable example). The words naïve technological-utopianism come to mind. I began by admitting that I was conflicted in terms of this project. From the purely technological perspective, there is much to admire in the project’s accomplishments. Sadly, that was not the project’s primary objective. What appears to be missing throughout is an inability to distinguish between the technology and the purpose to which is was intended to serve. My concern in this regard is reflected in a paper by Warschauer & Ames(2010). The analysis reveals that provision of individual laptops is a utopian vision for the children in the poorest countries, whose educational and social futures could be more effectively improved if the same investments were instead made on more sustainable and proven interventions. Middle- and high-income countries may have a stronger rationale for providing individual laptops to children, but will still want to eschew OLPC’s technocentric vision. In summary, OLPC represents the latest in a long line of technologically utopian development schemes that have unsuccessfully attempted to solve complex social problems with overly simplistic solutions. There is a delicate relationship between technology and society, culture, ethics, and values. What this case study reflects is the fact that technologies are not neutral. They never are. Hence, technological initiatives must be accompanied by appropriate social, cultural and ethical considerations – especially in projects such as this where the technologies are being introduced into particularly vulnerable societies. That did not happen here, The fact that this project got the support that it did, and has gone as far as it has, given the way it was approached, is why this reminder – in the form of this device – is included in the collection. And if anyone ever wonders why I am so vocal about the need for public discourse around technology, one need look no further than the OLPC project.", "__images": [ - "http://localhost:1050/files/images/buxton/upload_fc5aec1a-e3f2-4ea0-a51a-570f237617a4.jpeg", - "http://localhost:1050/files/images/buxton/upload_f1b4db78-fd76-4846-b642-49b5ec12d30d.jpeg", - "http://localhost:1050/files/images/buxton/upload_38099197-acc4-417b-8466-4da054648df9.jpeg", - "http://localhost:1050/files/images/buxton/upload_e9d913c7-d618-4c0c-a665-04679071460e.jpeg", - "http://localhost:1050/files/images/buxton/upload_64a6853c-1977-47a3-a1ef-f132283e5a6a.jpeg", - "http://localhost:1050/files/images/buxton/upload_f78cb0ae-ef4a-4728-843c-59b62d66706b.jpeg", - "http://localhost:1050/files/images/buxton/upload_ae95e94a-6a83-43c8-9245-50ae06026264.jpeg", - "http://localhost:1050/files/images/buxton/upload_b363fec7-6621-4837-a467-d5dce49078bc.jpeg", - "http://localhost:1050/files/images/buxton/upload_93f6b3d9-6279-4be7-8516-cae6c8fd3269.jpeg", - "http://localhost:1050/files/images/buxton/upload_c20c5f01-8e27-4b52-b91d-0fd8eebd7444.jpeg", - "http://localhost:1050/files/images/buxton/upload_4199a275-6283-40df-8af1-ffd33f82da81.jpeg" + "http://localhost:1050/files/images/buxton/upload_8dbbea32-060b-4290-a3c1-3734f4e811bb.jpeg", + "http://localhost:1050/files/images/buxton/upload_a046375e-af84-4ffa-82bb-f9f4e788bf23.jpeg", + "http://localhost:1050/files/images/buxton/upload_457064e1-a811-4d40-84b6-c9da0ccab998.jpeg", + "http://localhost:1050/files/images/buxton/upload_d25d14de-a8db-4a82-b36f-22d56d5a5fd3.jpeg", + "http://localhost:1050/files/images/buxton/upload_1effa15a-0f2a-4120-800c-de151aef3b7c.jpeg", + "http://localhost:1050/files/images/buxton/upload_21805f6e-ece3-4377-beb2-51779908906e.jpeg", + "http://localhost:1050/files/images/buxton/upload_738ed8b9-8d5f-47b2-b037-6cd9e08736aa.jpeg", + "http://localhost:1050/files/images/buxton/upload_e0568181-3e00-4cc5-8666-8f6970ba7bb5.jpeg", + "http://localhost:1050/files/images/buxton/upload_6d8418f8-3a18-41e2-814e-fed6d7e9dc55.jpeg", + "http://localhost:1050/files/images/buxton/upload_2fb42df9-a90e-4df2-ae2e-9bf310ba49cc.jpeg", + "http://localhost:1050/files/images/buxton/upload_586b9617-73b6-4822-9a09-9154b346140a.jpeg" ] }, { @@ -297,29 +297,29 @@ "shortDescription": "On the one hand, this device has the overall footprint of a keyboard, and it is used to enter text. And yet, it is two wide, flat, spring-loaded, self-returning joysticks, which are used to enter characters, rather than the keys that we typically employ. To add to the unconventional nature of this device, one enters text via these two joysticks by means of something called radial menus, one for each hand. And, in keeping with many keyboards, such as those with an integrated touch pad, the OrbiTouch also enables mouse like capabilities, such as pointing and selecting, also by means of one of the joysticks.", "longDescription": "Keyboards, Joysticks and Hierarchic Radial MenusIntroductionWhen you first look at this device, you might guess that it is some kind of keyboard. It even says so on the box and on the device itself. The keyboard-like footprint might reinforce this notion, as might the alphanumeric characters in the grey ring around the circular orb on the right-hand. On the other hand, if this is a keyboard, where are the keys? Reading the labels more carefully sheds light on the paradox: there are none. This is a “keyless keyboard. ” Yes, this is a contradiction in terms. But it is just such curiosities that make devices like this potentially interesting. Hence, we shall take a reasonably deep dive to see what might be revealed. Let’s start by trying to understand what the rationale was for landing on this particular design. The orbiTouch was developed by an industrial engineering doctoral student at the University of Central Florida, Peter McAlindon. His goal was to develop a means of text entry that minimized hand and wrist motion. The intent was to reduce the incidence of repetitive stress injury. A fair bit of research was undertaken between initial concept and commercial release. This can be accessed online, and doing so is a worthwhile exercise. Let us now turn our eye to the physical device in order to get a sense of where all of this landed. The Physical DeviceThe orbiTouch is dominated by two large circular “orbs. ” To my eye, their form initially practically screamed out, “I am a rotary control - Turn me!” However, appearances can be deceptive. Rather than dials, the orbs turn out to be a pair of a joysticks of a particular type. Rather than the stick-tilting motion typical of most, these “joysticks” are operated by moving them along the horizontal plane. In this they are a close cousins of the Altra Felix and KA Design Turbo Puck, both also in the collection. However, in contrast with the Felix and Turbo Puck, whose handles are “floating” (if you let go, they remain in the position where you released your grip), the orbs are “self-centering. ” That is, when released, internal springs return the orbs to their neutral central “home” position. In this, they behave much like the Gravis joystick in the collection, for example. At a finer level of detail, the orbs are specific class of joystick: “8-way joy-switches”. The term”8-way” indicates that only movement along the 8 main axes of the compass are sensed. As to the word “switch”, think of each orb as 8 switches, any one of which can be turned on by moving the orb in one of the 8 directions. (Conversely, they are turned off when the orb is released and returns to home position). Unlike an analogue joystick, such switches do not, and cannot, report how far or fast the orb has moved in any particular direction, nor how much pressure might be applied in the process. While limited, joy-switches provide a less complex and lower cost solution that are appropriate in situations where this additional data is not needed. There are several examples of joy-switches in the collection, especially video game controllers. One of the most iconic examples is the Atari CX-40 controller, which is a 4-way joy-switch. To recap, the orbiTouch is a bi-manual device for entering text by means of two orb-shaped planer-moving 8-way self-centering joy-switches. Having swallowed that mouth-full, let us now explore how text is entered using such a transducer. Entering TextIn general, a character or function is input by moving the two orbs. Which character or function depends on the direction (if any) each of the orbs has moved. For example, if both the left and right orb move west (left), the character “a” is entered. On the other hand, if the right orb again moves west, but the left one east (right), then the character input is “e”. How or why this is the case can be explained with the help of some images. For easier reading, the figure below shows the labels around the orbs in an exploded view. Notice that for both orbs, there is a label segment for each of its 8 directions. Since the example discussed entering an “a” and an “e”, each of which involved the right orb moving west (left) let’s look at the associated label segment in even more detail. Like all of the label segments for the right orb, this one consists of six areas containing text, each with a distinct background colour: red, yellow, green, orange and blue for the letters A through E, respectively, and black for the region containing “BACKSPACE”. Now look again at previous image and notice that each of these colours matches the label associated with one of the directions of the left orb. Text is entered using a two part process. Moving the right orb to the left/west specifies that you are going to enter one of: a, b, c, d, e, or BACKSPACE. (Like most keyboards, despite the labels on the key-caps being upper case, lower-case characters are entered unless the shift key is depressed. )Moving the left orb in the direction whose label corresponds to the background colour of the desired character causes that character to be entered. Hence, with the right orb held in the left/west position, one can enter the sequence, “abcde”, followed by a Backspace, by sequentially moving the left orb west (red), north-west (yellow), north (green), north-east (orange), east (blue) and south (black). The same technique can then be used to access all the characters and commands found in the right orb’s labels. Special ModesThere is one thing to add at this point: While entering printing characters always requires the use of both orbs, some actions can be performed using the left orb only. This can be inferred by the text that accompanies some of the left orb’s labels. For example, moving the left orb north (green) in quick succession (analogous to a double-click on a mouse), indicates that SHIFT will apply to the next character entered. Likewise, doing the same thing in the south-west (grey) direction applies the Caps Lock mode, i. e. , SHIFT will be applied to all subsequent entries until the mode is cancelled. These one-handed special modes/functions are summarized in the image below. Of these, the only one that I want to discuss at the moment is the ability of the orbiTouch to switch from entering text to controlling the screen cursor. This is done by moving the left orb south (black) twice in quick succession. When this is done, the right orb controls the cursor movement – the cursor moves continuously in the direction that you move the orb. In this, any doubts that you had about me characterizing the orbs as joysticks should disappear, since this cursor control is classic joystick behaviour. One issue of note is that the label describes this as “mouse” not “joystick”, which while understandable, is incorrect. Finally, before moving on to the next topic, note that while the right orb controls the movement of the screen cursor in mouse mode, movement of the left or left/west or right/east is taken as a left and right mouse button press, respectively. Remembering that the premise here is that the hands don’t have to move from the orbiTouch in order switch between typing and pointing tasks. But that doesn’t mean that the overhead in switching between the tasks is removed. One type of overhead is just substituted for another. And, the moded nature of the orbiTouch means that the option of parallel pointing-typing actions are eliminated. Rather than criticism, I mention these points to indicate the need to be mindful of the trade-offs and consequences of different design decisions - consequences that the designer should be aware of. Going Meta: What’s Really Going On? I want to approach doing so by stepping back, and approaching the underlying method of “typing” by going “meta”. That is, I want to jump up a lever of abstraction, beyond the physical device (for the moment), and explain what is going on at the conceptual level. The rest of the text is in much rougher form …. What will be revealed, if we do so, is that text is entered by means of the parallel use of two 8-direction radial menus. So what is a radial menu? These are the neglected cousins of the linear menus that populate conventional graphical user interfaces. The difference is that one makes a selection by the direction of movement, rather than the distance (as in the case with linear menus). It turns out that people can learn these quickly if the directions correspond to the 8 main points of the compass. For example, in a program menu, moving up (North) might mean Print, down (South) could mean Save, and moving down to the right (South East), Save As. Like linear menus, these menus can also be hierarchic. So, for example, after moving South East in order to specify Save As, a stroke to the left (West) might mean that it should be saved as a PDF file, whereas it would be saved as a Plain Text file if the secondary connected stroke was to the right (East). The reason for this brief tutorial on radial menus is that they pretty much define at the conceptual level how text is entered using the orbiTouch. The eight directions that you can move the orbs defines the menu item selected. And, by having the actual output depending on the combination of the selection made by each of the two orbs, the device can perhaps be best described as entering text using a two-level hierarchic radial menu, where menu selections are made using two planar moving 8-way joy switches. That is quite a mouth-full, and it has taken all of the text above to bring us to the point where there is a reasonable chance that it makes sense. And we still haven’t gotten into the details! it uses hierarchic (2-level) radial menus, but where the hierarchy is space multiplexed, rather than time multiplexed. That is, rather than doing one menu selection after the other, you do them simultaneously, by using a different hand to articulate the selection from each of the two menus. (While the text on the description is sparse still, look at the training cards, etc. and the photos on the page. )At the level of the mental model, there is no question in my mind (actually, I shouldn’t say that, because I am supposed to be an objective researcher who needs empirical data to inform decisions, but what the hell!) that you could give someone who knew how to use this device two isotonic joysticks, such as used with a video game controller, and they would be able to enter text just as fast as with this device. Furthermore, I am sure that if one had a slate capable of sensing both touch and stylus simultaneously, I am certain that the skill would transfer equally to using a touch radial gesture in the non-dominant hand, and stylus (or touch) radial gesture with the other. At the basic level, it is a 2-level radial menu, but where each level is operated independently and quasi-simultaneously by a different one of the operator’s two hands. Level 1: Right HandThis lets the operator select one of eight regionsThe label for each region consists of 6 characters (5 printing and one “special)In selecting one of the regions, one is not selecting any one of the characters of that region; rather, they are just indicating that the character that they want is one of the six in that regionEach of the characters in a region has a different background colour: blue, orange, green, yellow, red and black. Level 2: Left HandThis lets the operator select one of eight regionsEach region is labeled by a single colourAmong the colours that label the eight regions are the same ones used as character background colours in the regions of the right-hand control: blue, orange, green, yellow, red and blackBy the left hand selecting one of these six colours, one indicates which character is to be entered from among the six characters in the region indicated by the right hand – the selected character being the one whose background colour corresponds to the colour selected by the left hand. Hence, there are two 8-way, single level radial menus used. I believe it fair to say that it is, nevertheless, a 2 level radial menu, since both need to be used in order to enter one token. In actual fact, things are more complex, since none of the above covers issues such as all of the special character, punctuation, etc. , that do not appear on the labels of the right hand. To keep things brief, this is why only 6 of the left-hand menu options are used in what is discussed above. The other two options are needed to fill in the gaps. And, even then, the device resorts to something like double-clicks to get special modes and capabilities. For example, double clicking the black (south) region of the left hand turns the right-hand dome into a pointing device, i. e. , a mouse substitute for pointing, etc. I went through the – as it turned out – interesting exercise of translating the two parallel depth-1 radial menus of the orbiTouch UI into two different depth-2, breadth-8 hierarchic radial menus. You can see them in the attached images. The one assumes that the LH “dome” as the first-level selection, and then make the second-level selection with the right-hand dome. The other does the opposite, i. e. , the right-hand dome selection is the first level. It is interesting to compare the two with each other, as well as with both the labeling on the orbiTouch and the Quickstart documentation: The RH level-1 version seems easier to get rudimentary understanding compared to the LH due to clustering of letters and numbers on outer menus. Likewise, for the special characters that are the upper case of the numbersThe physical device is fine for letting you hunt-and-peck, so to speak, for characters, but it is useless for numbers, and most special characters. The documentation provided with the Quick Start (attached is not especially useful in terms of providing heuristics for memorization. While the orbiTouch certainly uses radial menus, it decidedly does not employ marking menus. One of the key things missing is the ability to check and correct before committing to an input, and the lack of ability to backtrack to the start, and therefore abort without entering anything. One thing that I have learned from this exercise is the difference that results due to having self-returning joysticks. Gestures don’t have that attribute. It matters esp w. r. t. the last point. What I like about this story, is how looking at something seemingly very different at the right level of abstraction, teaches us/me something new about something I was supposed to be an expert in. That is, that 2-level hierarchic marking menus can be achieved by two simultaneous single-level MMs. This is why I have the collection, and why I love what I do. There is still delight, despite being a 63-year-old geezer grandfather. The orbiTouch Keyless Keyboard was first known as the Keybowl, and the company was formerly known as Keybowl Inc. , and then Blue Orb Inc.", "__images": [ - "http://localhost:1050/files/images/buxton/upload_dfef0f64-1ebc-42a1-a12d-8f8b3f20e386.jpeg", - "http://localhost:1050/files/images/buxton/upload_4f9bc83c-7ca0-4e15-8a36-fef0d2d5e2f6.jpeg", - "http://localhost:1050/files/images/buxton/upload_39977ca6-bba3-4d23-80dc-76a19c8ba266.jpeg", - "http://localhost:1050/files/images/buxton/upload_7e3ec33b-d197-472d-95bc-4a41060d94a6.jpeg", - "http://localhost:1050/files/images/buxton/upload_d2a109a4-5d5b-46e5-9212-d0b892f921cc.jpeg", - "http://localhost:1050/files/images/buxton/upload_3959b330-8726-4c50-bc51-6e10bc8e32ae.jpeg", - "http://localhost:1050/files/images/buxton/upload_2f0e4e49-2f28-4104-8574-90f46a2e4855.jpeg", - "http://localhost:1050/files/images/buxton/upload_4b905d83-a94e-4d03-a196-5837ea56a783.jpeg", - "http://localhost:1050/files/images/buxton/upload_30585ddd-e038-455c-899d-7639a640186b.jpeg", - "http://localhost:1050/files/images/buxton/upload_c70dfa1e-2062-4d51-b8f3-7ec6d277d2e8.jpeg", - "http://localhost:1050/files/images/buxton/upload_8190f47e-6988-4914-895c-34fd672eae47.jpeg", - "http://localhost:1050/files/images/buxton/upload_07d68cd3-06ac-4b10-9077-86665cbdbcd2.jpeg", - "http://localhost:1050/files/images/buxton/upload_19e1331d-6362-4506-a1cf-4d9d0586ad19.jpeg", - "http://localhost:1050/files/images/buxton/upload_c2157b91-72f9-455d-8fe9-32dc97ff1ab6.jpeg", - "http://localhost:1050/files/images/buxton/upload_1a2aa338-9328-4324-a790-92f91954390a.jpeg", - "http://localhost:1050/files/images/buxton/upload_0c8e5c33-8885-4b77-89ac-afd0d03dcca8.jpeg", - "http://localhost:1050/files/images/buxton/upload_c06765c2-314f-437e-9bc1-c80af1d0ef63.jpeg", - "http://localhost:1050/files/images/buxton/upload_df004071-9abc-4cca-86e5-ab46b49d4a09.jpeg", - "http://localhost:1050/files/images/buxton/upload_442f0fd1-ed1a-46cc-a808-5fdbc1ca2419.jpeg", - "http://localhost:1050/files/images/buxton/upload_726066c4-4970-4144-9d9f-47b970f31cbd.jpeg", - "http://localhost:1050/files/images/buxton/upload_b0d2972d-e113-4cc4-a2be-efbe9bf6cf72.jpeg", - "http://localhost:1050/files/images/buxton/upload_7910259b-ad52-4f04-a05d-7a0a7f85397c.jpeg", - "http://localhost:1050/files/images/buxton/upload_d1b7f9a2-b69f-402e-ba90-f01756d8d064.jpeg" + "http://localhost:1050/files/images/buxton/upload_8ceb82b6-4959-48ce-a9b4-d3f25bd697f0.jpeg", + "http://localhost:1050/files/images/buxton/upload_3af0878c-3878-4cb7-8bcd-744cd030ef1a.jpeg", + "http://localhost:1050/files/images/buxton/upload_6f1044a8-4019-47ec-aae1-50245bc3d247.jpeg", + "http://localhost:1050/files/images/buxton/upload_e5f16e7e-ce55-45e9-b239-b4abcc661f93.jpeg", + "http://localhost:1050/files/images/buxton/upload_64cf8b2b-4aea-45cb-acdf-e83f941cc5bb.jpeg", + "http://localhost:1050/files/images/buxton/upload_1c2071ff-62c0-4c33-bfb7-1863a27a2c87.jpeg", + "http://localhost:1050/files/images/buxton/upload_33e5d04d-3249-4f92-a283-a618f908c625.jpeg", + "http://localhost:1050/files/images/buxton/upload_c7410f2c-ab97-47db-a3b5-3396408689c6.jpeg", + "http://localhost:1050/files/images/buxton/upload_c97ef775-2214-4ea7-9ec7-6a51224081e3.jpeg", + "http://localhost:1050/files/images/buxton/upload_a58fd409-511f-4f6f-b8f9-8de3e18a5c09.jpeg", + "http://localhost:1050/files/images/buxton/upload_c566620f-61e3-4e16-81d7-eb2bfbbc96ab.jpeg", + "http://localhost:1050/files/images/buxton/upload_587b3aa2-3ea3-4e68-81b6-0392cc22af76.jpeg", + "http://localhost:1050/files/images/buxton/upload_969df21a-4978-4b68-9b63-db4496754fa7.jpeg", + "http://localhost:1050/files/images/buxton/upload_ab12d988-a8e8-40d2-bdc1-69b43a7ddd18.jpeg", + "http://localhost:1050/files/images/buxton/upload_e91c609c-5f45-404b-9826-4d6a89ad44fe.jpeg", + "http://localhost:1050/files/images/buxton/upload_4e364ff1-72bf-4bd0-bace-235d6c7c3658.jpeg", + "http://localhost:1050/files/images/buxton/upload_a89b352a-32af-4b66-9972-b00364a5a942.jpeg", + "http://localhost:1050/files/images/buxton/upload_a483f61c-4f60-4e1b-b333-6f36b44b521a.jpeg", + "http://localhost:1050/files/images/buxton/upload_35946c76-c513-49b5-a730-13d0bca75cb0.jpeg", + "http://localhost:1050/files/images/buxton/upload_0b0a1076-d17e-4b44-960c-e80fd0e0680b.jpeg", + "http://localhost:1050/files/images/buxton/upload_433c21ce-c363-46d5-b193-e1cb9f9dc79a.jpeg", + "http://localhost:1050/files/images/buxton/upload_cf07301d-5776-4478-b42a-0069c25c23e7.jpeg", + "http://localhost:1050/files/images/buxton/upload_9b82fe76-6494-44c1-aa79-cf68986b80ac.jpeg" ] }, { @@ -344,17 +344,17 @@ "shortDescription": "This touch-sensitive keyboard is especially suited for super clean environments, such as hospitals, and those which are just the opposite. The reason is that, being completely flat, there are no crack or gaps where dirt or bacteria can accumulate. This same property enables it to be easily cleaned. However, the reason that I got this keyboard because it was silent – there are no mechanical key-clicks. Hence, for example, it enabled me to soundlessly enter data to my digital musical instrument during a concert or while recording.", "longDescription": "This is a solid-state touch-sensitive keyboard with no moving parts. Because its surface is flat, the only way one knows that it is a QWERTY keyboard is by the graphical representation on its surface. One types by placing one’s fingers on pictures of keys, rather than physical/mechanical keycaps. Because of the lack of the tactile feedback associated with conventional keyboards, as expected, typing speed and/or accuracy will be compromised with this keyboard. And yet, this keyboard brings real value in certain situations, and in so doing, it provides a good example of the rule: Everything is best for something and worst for something else. Because the is especially suited for super clean environments, such as hospitals, and those which are just the opposite. The reason is that, being completely flat, there are no crack or gaps where dirt or bacteria can accumulate. This same property enables it to be easily cleaned. However, the reason that I got this keyboard because it was silent – there are no mechanical key-clicks. Hence, for example, it enabled me to soundlessly enter data to my digital musical instrument during a concert or while recording. This is one of a number of capacitive touch-sensing input devices produced in the period around 1981 by Touch Activated Switch Arrays (TASA). The others included a touch-sensitive linear controller, the Ferinstat, which could function as a linear slider/fader, for applications such as audio or process control. These came in two lengths and are included in the collection. There were also the Model 16 Micro Proximity Keyboards, which were 16-button keyboards, arranged in a 4x4 array of touch-sensitive buttons that included a touch-sensitive numerical keypad. They also demonstrated a small, capacitive touch-sensitive touch pad, not unlike what one sees on today’s laptops, for example.", "__images": [ - "http://localhost:1050/files/images/buxton/upload_9f04bcac-b941-445a-8ffb-63fc840e3987.jpeg", - "http://localhost:1050/files/images/buxton/upload_594e4ee4-5980-4052-b45d-b6a1abbb6e10.jpeg", - "http://localhost:1050/files/images/buxton/upload_18ffbe64-31bc-4538-aab7-bb67c448b525.jpeg", - "http://localhost:1050/files/images/buxton/upload_0667f349-1134-4e93-8a78-3923f1cbf7c5.jpeg", - "http://localhost:1050/files/images/buxton/upload_0f3c6373-b2a1-4038-9d93-331d6112d662.jpeg", - "http://localhost:1050/files/images/buxton/upload_bd97b78b-5f1a-4ea5-a873-bfc29e3bfaad.jpeg", - "http://localhost:1050/files/images/buxton/upload_22e5cb29-ebaa-4693-a8b4-4d4e0af0649b.jpeg", - "http://localhost:1050/files/images/buxton/upload_94892599-f180-43ad-ae59-45fab67a1f9e.jpeg", - "http://localhost:1050/files/images/buxton/upload_1fe042d1-9730-46f4-86dc-564d1b58702a.jpeg", - "http://localhost:1050/files/images/buxton/upload_e501ba75-6eb9-45a6-ba67-f0e05d1cb08f.jpeg", - "http://localhost:1050/files/images/buxton/upload_7a7fe61c-3b8b-48ca-bfb4-cd6983b9476e.jpeg" + "http://localhost:1050/files/images/buxton/upload_15fc2885-b4e3-44b9-a84a-d3fc2e0756d0.jpeg", + "http://localhost:1050/files/images/buxton/upload_777de350-df74-48e7-9b67-faad61ae3a0c.jpeg", + "http://localhost:1050/files/images/buxton/upload_e0847924-8e95-4a17-8642-7b12bcc85d67.jpeg", + "http://localhost:1050/files/images/buxton/upload_a728a4a3-b92f-4cc1-9fe2-e6e4160ca11e.jpeg", + "http://localhost:1050/files/images/buxton/upload_d52a2b3a-1e12-426c-877d-6debbd4739bb.jpeg", + "http://localhost:1050/files/images/buxton/upload_27b07987-f711-4712-b57d-ca15c2718693.jpeg", + "http://localhost:1050/files/images/buxton/upload_ffcaed97-2277-48d2-89d2-edd6474fdcb3.jpeg", + "http://localhost:1050/files/images/buxton/upload_fc2d2acf-5e0b-4c73-9e0d-d73731282b0d.jpeg", + "http://localhost:1050/files/images/buxton/upload_04c91e72-48f9-41e8-820a-15ec4c2e9f26.jpeg", + "http://localhost:1050/files/images/buxton/upload_eba5ecfe-6d48-45df-add5-ffa16670b5c0.jpeg", + "http://localhost:1050/files/images/buxton/upload_c2081958-b9bb-4271-90db-9bf49455ca01.jpeg" ] }, { @@ -385,25 +385,25 @@ "shortDescription": "The Twiddler is a one-hand chord keyboard with integrated pointing capability, which can control the cursor in a joystick-like manner. This was a favourite device of the early Cyborg wearable-computer community.", "longDescription": "……. . Note: Lyons, et al. abstract: An experienced user of the Twiddler, a one--handed chording keyboard, averages speeds of 60 words per minute with letter--by--letter typing of standard test phrases. This fast typing rate coupled with the Twiddler's 3x4 button design, similar to that of a standard mobile telephone, makes it a potential alternative to multi--tap for text entry on mobile phones. Despite this similarity, there is very little data on the Twiddler's performance and learnability. We present a longitudinal study of novice users' learning rates on the Twiddler. Ten participants typed for 20 sessions using two different methods. Each session is composed of 20 minutes of typing with multi--tap and 20 minutes of one--handed chording on the Twiddler. We found that users initially have a faster average typing rate with multi--tap; however, after four sessions the difference becomes negligible, and by the eighth session participants type faster with chording on the Twiddler. Furthermore, after 20 sessions typing rates for the Twiddler are still increasing.", "__images": [ - "http://localhost:1050/files/images/buxton/upload_0d024fc4-3457-4747-98e4-053bf0fdbc38.jpeg", - "http://localhost:1050/files/images/buxton/upload_df7ffdde-83b9-4f3f-b415-6689f72e52a7.jpeg", - "http://localhost:1050/files/images/buxton/upload_b5655623-c9fd-4224-b65f-2c649b1fdf65.jpeg", - "http://localhost:1050/files/images/buxton/upload_a27658f8-df0e-4581-8be7-401771c0fe56.jpeg", - "http://localhost:1050/files/images/buxton/upload_b95be9a7-cd92-4c96-b4a7-ee76417eb79d.jpeg", - "http://localhost:1050/files/images/buxton/upload_24fadac6-21f7-4a41-89ea-7b8f9c1c5c67.jpeg", - "http://localhost:1050/files/images/buxton/upload_2b040c76-a26f-40be-b5ba-585d4ae8d16c.jpeg", - "http://localhost:1050/files/images/buxton/upload_69700a12-61ee-49ee-aa66-de83f409e402.jpeg", - "http://localhost:1050/files/images/buxton/upload_cbbe3548-1bbe-4e8f-a8c3-781dd3304962.jpeg", - "http://localhost:1050/files/images/buxton/upload_83aa7094-daa1-4a11-8bb4-8a6d98dc9d49.jpeg", - "http://localhost:1050/files/images/buxton/upload_945e8830-0472-46a0-8188-8625a5b7168b.jpeg", - "http://localhost:1050/files/images/buxton/upload_a161b8c3-df26-4349-a3d1-0fff68617a21.jpeg", - "http://localhost:1050/files/images/buxton/upload_c3f96de2-8689-4607-b4c2-611530c1699f.jpeg", - "http://localhost:1050/files/images/buxton/upload_c0cfabcf-db94-4ad4-a2fc-1eafdbac596e.jpeg", - "http://localhost:1050/files/images/buxton/upload_dc1c867a-d1a6-4dc4-a20e-8789699a9980.jpeg", - "http://localhost:1050/files/images/buxton/upload_5618f68b-3cb4-433e-a95d-28913ceb73ae.jpeg", - "http://localhost:1050/files/images/buxton/upload_f7b951c8-e9b6-4515-b764-3961cff62740.jpeg", - "http://localhost:1050/files/images/buxton/upload_1a894a0c-3ea2-4cf6-a40a-c1d52e7ff259.jpeg", - "http://localhost:1050/files/images/buxton/upload_01223dfc-e8c8-45b5-868c-fa78c43c5769.jpeg" + "http://localhost:1050/files/images/buxton/upload_190dd80f-de0b-46c4-8003-5611e54c33fb.jpeg", + "http://localhost:1050/files/images/buxton/upload_b81b572f-1a7d-4df0-bfc6-086b8f4d5a2f.jpeg", + "http://localhost:1050/files/images/buxton/upload_0bac332d-a6bb-4749-837e-b3caf313e0cb.jpeg", + "http://localhost:1050/files/images/buxton/upload_b840e602-9dd8-450e-b653-66a587264442.jpeg", + "http://localhost:1050/files/images/buxton/upload_d9464550-a8bc-4827-8a4b-cc43b7292b67.jpeg", + "http://localhost:1050/files/images/buxton/upload_e906aeea-a128-4fa3-8ff3-b95f4f8a0f74.jpeg", + "http://localhost:1050/files/images/buxton/upload_35503582-ec70-4fb9-9ace-52284f33a262.jpeg", + "http://localhost:1050/files/images/buxton/upload_7893f167-d3df-4b38-ad2d-2ad1bbc1de84.jpeg", + "http://localhost:1050/files/images/buxton/upload_bfc5957b-6902-4539-a6dc-3439aeb43735.jpeg", + "http://localhost:1050/files/images/buxton/upload_46cdccd8-bd87-4000-9ad6-84c71cf557a2.jpeg", + "http://localhost:1050/files/images/buxton/upload_2674ee0b-08df-40ec-a886-d98463c7c1a3.jpeg", + "http://localhost:1050/files/images/buxton/upload_298711d6-fa02-46ee-a595-d661a183fc27.jpeg", + "http://localhost:1050/files/images/buxton/upload_9ec8d3df-0e96-44b0-8d09-1ae3ce96394f.jpeg", + "http://localhost:1050/files/images/buxton/upload_7c5c6c37-0e78-43ac-9d00-2c17dfbab9af.jpeg", + "http://localhost:1050/files/images/buxton/upload_402f4ea0-0f70-4f17-b12c-ca0e0bb05ee7.jpeg", + "http://localhost:1050/files/images/buxton/upload_ae56a352-f1ae-451f-b1a9-b6567a734f8b.jpeg", + "http://localhost:1050/files/images/buxton/upload_49401c52-119a-4b2c-9f75-88e79d8ce436.jpeg", + "http://localhost:1050/files/images/buxton/upload_b79b1d12-8931-47cd-82dc-2d593ed88e31.jpeg", + "http://localhost:1050/files/images/buxton/upload_ebd18c49-47bf-4469-81be-75b34f1402b7.jpeg" ] } ] \ No newline at end of file diff --git a/src/server/DashUploadUtils.ts b/src/server/DashUploadUtils.ts index 27c4bf854..26d6423e9 100644 --- a/src/server/DashUploadUtils.ts +++ b/src/server/DashUploadUtils.ts @@ -162,6 +162,11 @@ export namespace DashUploadUtils { type: string; } + export interface ImageResizer { + resizer?: sharp.Sharp; + suffix: SizeSuffix; + } + /** * Based on the url's classification as local or remote, gleans * as much information as possible about the specified image -- cgit v1.2.3-70-g09d2 From 3f3fbcf0c2ea60625f20f3d06388723645e78170 Mon Sep 17 00:00:00 2001 From: Sam Wilkins Date: Mon, 10 Feb 2020 12:07:32 -0500 Subject: server session now local --- package-lock.json | 417 +++------------------ package.json | 1 - src/server/DashSession/DashSessionAgent.ts | 5 +- .../Session/agents/applied_session_agent.ts | 58 +++ src/server/DashSession/Session/agents/monitor.ts | 298 +++++++++++++++ .../Session/agents/process_message_router.ts | 41 ++ .../Session/agents/promisified_ipc_manager.ts | 173 +++++++++ .../DashSession/Session/agents/server_worker.ts | 160 ++++++++ src/server/DashSession/Session/utilities/repl.ts | 128 +++++++ .../Session/utilities/session_config.ts | 129 +++++++ .../DashSession/Session/utilities/utilities.ts | 37 ++ src/server/index.ts | 2 +- 12 files changed, 1072 insertions(+), 377 deletions(-) create mode 100644 src/server/DashSession/Session/agents/applied_session_agent.ts create mode 100644 src/server/DashSession/Session/agents/monitor.ts create mode 100644 src/server/DashSession/Session/agents/process_message_router.ts create mode 100644 src/server/DashSession/Session/agents/promisified_ipc_manager.ts create mode 100644 src/server/DashSession/Session/agents/server_worker.ts create mode 100644 src/server/DashSession/Session/utilities/repl.ts create mode 100644 src/server/DashSession/Session/utilities/session_config.ts create mode 100644 src/server/DashSession/Session/utilities/utilities.ts (limited to 'src/server') diff --git a/package-lock.json b/package-lock.json index 0b8bd140c..f38f23acb 100644 --- a/package-lock.json +++ b/package-lock.json @@ -374,7 +374,8 @@ "@types/chai": { "version": "4.2.7", "resolved": "https://registry.npmjs.org/@types/chai/-/chai-4.2.7.tgz", - "integrity": "sha512-luq8meHGYwvky0O7u0eQZdA7B4Wd9owUCqvbw2m3XCrCU8mplYOujMBbvyS547AxJkC+pGnd0Cm15eNxEUNU8g==" + "integrity": "sha512-luq8meHGYwvky0O7u0eQZdA7B4Wd9owUCqvbw2m3XCrCU8mplYOujMBbvyS547AxJkC+pGnd0Cm15eNxEUNU8g==", + "dev": true }, "@types/classnames": { "version": "2.2.9", @@ -602,7 +603,8 @@ "@types/mocha": { "version": "5.2.7", "resolved": "https://registry.npmjs.org/@types/mocha/-/mocha-5.2.7.tgz", - "integrity": "sha512-NYrtPht0wGzhwe9+/idPaBB+TqkY9AhTvOLMkThm0IoEfLaiVQZwBwyJ5puCkO3AUCWrmcoePjp2mbFocKy4SQ==" + "integrity": "sha512-NYrtPht0wGzhwe9+/idPaBB+TqkY9AhTvOLMkThm0IoEfLaiVQZwBwyJ5puCkO3AUCWrmcoePjp2mbFocKy4SQ==", + "dev": true }, "@types/mongodb": { "version": "3.3.14", @@ -1995,7 +1997,7 @@ }, "util": { "version": "0.10.3", - "resolved": "http://registry.npmjs.org/util/-/util-0.10.3.tgz", + "resolved": "https://registry.npmjs.org/util/-/util-0.10.3.tgz", "integrity": "sha1-evsa/lCAUkZInj23/g7TeTNqwPk=", "dev": true, "requires": { @@ -5417,8 +5419,8 @@ "bundled": true, "optional": true, "requires": { - "delegates": "1.0.0", - "readable-stream": "2.3.6" + "delegates": "^1.0.0", + "readable-stream": "^2.0.6" } }, "balanced-match": { @@ -5501,14 +5503,14 @@ "bundled": true, "optional": true, "requires": { - "aproba": "1.2.0", - "console-control-strings": "1.1.0", - "has-unicode": "2.0.1", - "object-assign": "4.1.1", - "signal-exit": "3.0.2", - "string-width": "1.0.2", - "strip-ansi": "3.0.1", - "wide-align": "1.1.3" + "aproba": "^1.0.3", + "console-control-strings": "^1.0.0", + "has-unicode": "^2.0.0", + "object-assign": "^4.1.0", + "signal-exit": "^3.0.0", + "string-width": "^1.0.1", + "strip-ansi": "^3.0.1", + "wide-align": "^1.1.0" } }, "glob": { @@ -5516,12 +5518,12 @@ "bundled": true, "optional": true, "requires": { - "fs.realpath": "1.0.0", - "inflight": "1.0.6", - "inherits": "2.0.4", - "minimatch": "3.0.4", - "once": "1.4.0", - "path-is-absolute": "1.0.1" + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" } }, "has-unicode": { @@ -5550,8 +5552,8 @@ "bundled": true, "optional": true, "requires": { - "once": "1.4.0", - "wrappy": "1.0.2" + "once": "^1.3.0", + "wrappy": "1" } }, "inherits": { @@ -5683,10 +5685,10 @@ "bundled": true, "optional": true, "requires": { - "are-we-there-yet": "1.1.5", - "console-control-strings": "1.1.0", - "gauge": "2.7.4", - "set-blocking": "2.0.0" + "are-we-there-yet": "~1.1.2", + "console-control-strings": "~1.1.0", + "gauge": "~2.7.3", + "set-blocking": "~2.0.0" } }, "number-is-nan": { @@ -5704,7 +5706,7 @@ "bundled": true, "optional": true, "requires": { - "wrappy": "1.0.2" + "wrappy": "1" } }, "os-homedir": { @@ -5741,10 +5743,10 @@ "bundled": true, "optional": true, "requires": { - "deep-extend": "0.6.0", - "ini": "1.3.5", - "minimist": "1.2.0", - "strip-json-comments": "2.0.1" + "deep-extend": "^0.6.0", + "ini": "~1.3.0", + "minimist": "^1.2.0", + "strip-json-comments": "~2.0.1" }, "dependencies": { "minimist": { @@ -5759,13 +5761,13 @@ "bundled": true, "optional": true, "requires": { - "core-util-is": "1.0.2", - "inherits": "2.0.4", - "isarray": "1.0.0", - "process-nextick-args": "2.0.1", - "safe-buffer": "5.1.2", - "string_decoder": "1.1.1", - "util-deprecate": "1.0.2" + "core-util-is": "~1.0.0", + "inherits": "~2.0.3", + "isarray": "~1.0.0", + "process-nextick-args": "~2.0.0", + "safe-buffer": "~5.1.1", + "string_decoder": "~1.1.1", + "util-deprecate": "~1.0.1" } }, "rimraf": { @@ -5811,9 +5813,9 @@ "bundled": true, "optional": true, "requires": { - "code-point-at": "1.1.0", - "is-fullwidth-code-point": "1.0.0", - "strip-ansi": "3.0.1" + "code-point-at": "^1.0.0", + "is-fullwidth-code-point": "^1.0.0", + "strip-ansi": "^3.0.0" } }, "string_decoder": { @@ -5861,7 +5863,7 @@ "bundled": true, "optional": true, "requires": { - "string-width": "1.0.2" + "string-width": "^1.0.2 || 2" } }, "wrappy": { @@ -12629,11 +12631,6 @@ "resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz", "integrity": "sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns=" }, - "picomatch": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.2.1.tgz", - "integrity": "sha512-ISBaA8xQNmwELC7eOjqFKMESB2VIqt4PPDD0nsS95b/9dZXvVKOlz9keMSnoGGKcOHXfTvDD6WMaRoSc9UuhRA==" - }, "pify": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", @@ -14249,334 +14246,6 @@ "integrity": "sha1-kl0mAdOaxIXgkc8NpcbmlNw9yv8=", "dev": true }, - "resilient-server-session": { - "version": "1.1.9", - "resolved": "https://registry.npmjs.org/resilient-server-session/-/resilient-server-session-1.1.9.tgz", - "integrity": "sha512-XSVujTyJOQMACllXUvWOSHY4GK4JI6aECjCrQR0UBvd2+hdjM1euffspn2b+7M0fepo+bJ71YrAOA9M34ChBZw==", - "requires": { - "@types/chai": "^4.2.7", - "@types/express": "^4.17.2", - "@types/mocha": "^5.2.7", - "@types/node": "^10.12.30", - "@types/request-promise": "^4.1.42", - "@types/uuid": "^3.4.6", - "chai": "^4.2.0", - "colors": "^1.4.0", - "express": "^4.17.1", - "jsonschema": "^1.2.5", - "mocha": "^7.0.0", - "request": "^2.88.0", - "request-promise": "^4.2.5", - "typescript": "^3.7.4", - "uuid": "^3.3.3" - }, - "dependencies": { - "ansi-colors": { - "version": "3.2.3", - "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-3.2.3.tgz", - "integrity": "sha512-LEHHyuhlPY3TmuUYMh2oz89lTShfvgbmzaBcxve9t/9Wuy7Dwf4yoAKcND7KFT1HAQfqZ12qtc+DUrBMeKF9nw==" - }, - "ansi-regex": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.0.tgz", - "integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==" - }, - "ansi-styles": { - "version": "3.2.1", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", - "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", - "requires": { - "color-convert": "^1.9.0" - } - }, - "anymatch": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.1.tgz", - "integrity": "sha512-mM8522psRCqzV+6LhomX5wgp25YVibjh8Wj23I5RPkPppSVSjyKD2A2mBJmWGa+KN7f2D6LNh9jkBCeyLktzjg==", - "requires": { - "normalize-path": "^3.0.0", - "picomatch": "^2.0.4" - } - }, - "binary-extensions": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.0.0.tgz", - "integrity": "sha512-Phlt0plgpIIBOGTT/ehfFnbNlfsDEiqmzE2KRXoX1bLIlir4X/MR+zSyBEkL05ffWgnRSf/DXv+WrUAVr93/ow==" - }, - "braces": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz", - "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==", - "requires": { - "fill-range": "^7.0.1" - } - }, - "camelcase": { - "version": "5.3.1", - "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-5.3.1.tgz", - "integrity": "sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==" - }, - "chokidar": { - "version": "3.3.0", - "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.3.0.tgz", - "integrity": "sha512-dGmKLDdT3Gdl7fBUe8XK+gAtGmzy5Fn0XkkWQuYxGIgWVPPse2CxFA5mtrlD0TOHaHjEUqkWNyP1XdHoJES/4A==", - "requires": { - "anymatch": "~3.1.1", - "braces": "~3.0.2", - "fsevents": "~2.1.1", - "glob-parent": "~5.1.0", - "is-binary-path": "~2.1.0", - "is-glob": "~4.0.1", - "normalize-path": "~3.0.0", - "readdirp": "~3.2.0" - } - }, - "cliui": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/cliui/-/cliui-5.0.0.tgz", - "integrity": "sha512-PYeGSEmmHM6zvoef2w8TPzlrnNpXIjTipYK780YswmIP9vjxmd6Y2a3CB2Ks6/AU8NHjZugXvo8w3oWM2qnwXA==", - "requires": { - "string-width": "^3.1.0", - "strip-ansi": "^5.2.0", - "wrap-ansi": "^5.1.0" - } - }, - "debug": { - "version": "3.2.6", - "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.6.tgz", - "integrity": "sha512-mel+jf7nrtEl5Pn1Qx46zARXKDpBbvzezse7p7LqINmdoIk8PYP5SySaxEmYv6TZ0JyEKA1hsCId6DIhgITtWQ==", - "requires": { - "ms": "^2.1.1" - } - }, - "fill-range": { - "version": "7.0.1", - "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", - "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==", - "requires": { - "to-regex-range": "^5.0.1" - } - }, - "find-up": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/find-up/-/find-up-3.0.0.tgz", - "integrity": "sha512-1yD6RmLI1XBfxugvORwlck6f75tYL+iR0jqwsOrOxMZyGYqUuDhJ0l4AXdO1iX/FTs9cBAMEk1gWSEx1kSbylg==", - "requires": { - "locate-path": "^3.0.0" - } - }, - "fsevents": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.1.2.tgz", - "integrity": "sha512-R4wDiBwZ0KzpgOWetKDug1FZcYhqYnUYKtfZYt4mD5SBz76q0KR4Q9o7GIPamsVPGmW3EYPPJ0dOOjvx32ldZA==", - "optional": true - }, - "get-caller-file": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", - "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==" - }, - "glob": { - "version": "7.1.3", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.3.tgz", - "integrity": "sha512-vcfuiIxogLV4DlGBHIUOwI0IbrJ8HWPc4MU7HzviGeNho/UJDfi6B5p3sHeWIQ0KGIU0Jpxi5ZHxemQfLkkAwQ==", - "requires": { - "fs.realpath": "^1.0.0", - "inflight": "^1.0.4", - "inherits": "2", - "minimatch": "^3.0.4", - "once": "^1.3.0", - "path-is-absolute": "^1.0.0" - } - }, - "glob-parent": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.0.tgz", - "integrity": "sha512-qjtRgnIVmOfnKUE3NJAQEdk+lKrxfw8t5ke7SXtfMTHcjsBfOfWXCQfdb30zfDoZQ2IRSIiidmjtbHZPZ++Ihw==", - "requires": { - "is-glob": "^4.0.1" - } - }, - "he": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/he/-/he-1.2.0.tgz", - "integrity": "sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw==" - }, - "is-binary-path": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz", - "integrity": "sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==", - "requires": { - "binary-extensions": "^2.0.0" - } - }, - "is-fullwidth-code-point": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", - "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=" - }, - "is-number": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", - "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==" - }, - "locate-path": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-3.0.0.tgz", - "integrity": "sha512-7AO748wWnIhNqAuaty2ZWHkQHRSNfPVIsPIfwEOWO22AmaoVrWavlOcMR5nzTLNYvp36X220/maaRsrec1G65A==", - "requires": { - "p-locate": "^3.0.0", - "path-exists": "^3.0.0" - } - }, - "mocha": { - "version": "7.0.1", - "resolved": "https://registry.npmjs.org/mocha/-/mocha-7.0.1.tgz", - "integrity": "sha512-9eWmWTdHLXh72rGrdZjNbG3aa1/3NRPpul1z0D979QpEnFdCG0Q5tv834N+94QEN2cysfV72YocQ3fn87s70fg==", - "requires": { - "ansi-colors": "3.2.3", - "browser-stdout": "1.3.1", - "chokidar": "3.3.0", - "debug": "3.2.6", - "diff": "3.5.0", - "escape-string-regexp": "1.0.5", - "find-up": "3.0.0", - "glob": "7.1.3", - "growl": "1.10.5", - "he": "1.2.0", - "js-yaml": "3.13.1", - "log-symbols": "2.2.0", - "minimatch": "3.0.4", - "mkdirp": "0.5.1", - "ms": "2.1.1", - "node-environment-flags": "1.0.6", - "object.assign": "4.1.0", - "strip-json-comments": "2.0.1", - "supports-color": "6.0.0", - "which": "1.3.1", - "wide-align": "1.1.3", - "yargs": "13.3.0", - "yargs-parser": "13.1.1", - "yargs-unparser": "1.6.0" - } - }, - "ms": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz", - "integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg==" - }, - "node-environment-flags": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/node-environment-flags/-/node-environment-flags-1.0.6.tgz", - "integrity": "sha512-5Evy2epuL+6TM0lCQGpFIj6KwiEsGh1SrHUhTbNX+sLbBtjidPZFAnVK9y5yU1+h//RitLbRHTIMyxQPtxMdHw==", - "requires": { - "object.getownpropertydescriptors": "^2.0.3", - "semver": "^5.7.0" - } - }, - "p-locate": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-3.0.0.tgz", - "integrity": "sha512-x+12w/To+4GFfgJhBEpiDcLozRJGegY+Ei7/z0tSLkMmxGZNybVMSfWj9aJn8Z5Fc7dBUNJOOVgPv2H7IwulSQ==", - "requires": { - "p-limit": "^2.0.0" - } - }, - "readdirp": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.2.0.tgz", - "integrity": "sha512-crk4Qu3pmXwgxdSgGhgA/eXiJAPQiX4GMOZZMXnqKxHX7TaoL+3gQVo/WeuAiogr07DpnfjIMpXXa+PAIvwPGQ==", - "requires": { - "picomatch": "^2.0.4" - } - }, - "require-main-filename": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/require-main-filename/-/require-main-filename-2.0.0.tgz", - "integrity": "sha512-NKN5kMDylKuldxYLSUfrbo5Tuzh4hd+2E8NPPX02mZtn1VuREQToYe/ZdlJy+J3uCpfaiGF05e7B8W0iXbQHmg==" - }, - "string-width": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-3.1.0.tgz", - "integrity": "sha512-vafcv6KjVZKSgz06oM/H6GDBrAtz8vdhQakGjFIvNrHA6y3HCF1CInLy+QLq8dTJPQ1b+KDUqDFctkdRW44e1w==", - "requires": { - "emoji-regex": "^7.0.1", - "is-fullwidth-code-point": "^2.0.0", - "strip-ansi": "^5.1.0" - } - }, - "strip-ansi": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.2.0.tgz", - "integrity": "sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA==", - "requires": { - "ansi-regex": "^4.1.0" - } - }, - "supports-color": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-6.0.0.tgz", - "integrity": "sha512-on9Kwidc1IUQo+bQdhi8+Tijpo0e1SS6RoGo2guUwn5vdaxw8RXOF9Vb2ws+ihWOmh4JnCJOvaziZWP1VABaLg==", - "requires": { - "has-flag": "^3.0.0" - } - }, - "to-regex-range": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", - "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", - "requires": { - "is-number": "^7.0.0" - } - }, - "which-module": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/which-module/-/which-module-2.0.0.tgz", - "integrity": "sha1-2e8H3Od7mQK4o6j6SzHD4/fm6Ho=" - }, - "wrap-ansi": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-5.1.0.tgz", - "integrity": "sha512-QC1/iN/2/RPVJ5jYK8BGttj5z83LmSKmvbvrXPNCLZSEb32KKVDJDl/MOt2N01qU2H/FkzEa9PKto1BqDjtd7Q==", - "requires": { - "ansi-styles": "^3.2.0", - "string-width": "^3.0.0", - "strip-ansi": "^5.0.0" - } - }, - "y18n": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/y18n/-/y18n-4.0.0.tgz", - "integrity": "sha512-r9S/ZyXu/Xu9q1tYlpsLIsa3EeLXXk0VwlxqTcFRfg9EhMW+17kbt9G0NrgCmhGb5vT2hyhJZLfDGx+7+5Uj/w==" - }, - "yargs": { - "version": "13.3.0", - "resolved": "https://registry.npmjs.org/yargs/-/yargs-13.3.0.tgz", - "integrity": "sha512-2eehun/8ALW8TLoIl7MVaRUrg+yCnenu8B4kBlRxj3GJGDKU1Og7sMXPNm1BYyM1DOJmTZ4YeN/Nwxv+8XJsUA==", - "requires": { - "cliui": "^5.0.0", - "find-up": "^3.0.0", - "get-caller-file": "^2.0.1", - "require-directory": "^2.1.1", - "require-main-filename": "^2.0.0", - "set-blocking": "^2.0.0", - "string-width": "^3.0.0", - "which-module": "^2.0.0", - "y18n": "^4.0.0", - "yargs-parser": "^13.1.1" - } - }, - "yargs-parser": { - "version": "13.1.1", - "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-13.1.1.tgz", - "integrity": "sha512-oVAVsHz6uFrg3XQheFII8ESO2ssAf9luWuAd6Wexsu4F3OtIW0o8IribPXYrD4WC24LWtPrJlGy87y5udK+dxQ==", - "requires": { - "camelcase": "^5.0.0", - "decamelize": "^1.2.0" - } - } - } - }, "resize-observer-polyfill": { "version": "1.5.1", "resolved": "https://registry.npmjs.org/resize-observer-polyfill/-/resize-observer-polyfill-1.5.1.tgz", diff --git a/package.json b/package.json index 250509e80..6f54023d6 100644 --- a/package.json +++ b/package.json @@ -222,7 +222,6 @@ "readline": "^1.3.0", "request": "^2.88.0", "request-promise": "^4.2.5", - "resilient-server-session": "^1.1.9", "rimraf": "^3.0.0", "serializr": "^1.5.4", "sharp": "^0.23.4", diff --git a/src/server/DashSession/DashSessionAgent.ts b/src/server/DashSession/DashSessionAgent.ts index d61e9aac1..85bfe14de 100644 --- a/src/server/DashSession/DashSessionAgent.ts +++ b/src/server/DashSession/DashSessionAgent.ts @@ -8,8 +8,11 @@ import { launchServer, onWindows } from ".."; import { readdirSync, statSync, createWriteStream, readFileSync, unlinkSync } from "fs"; import * as Archiver from "archiver"; import { resolve } from "path"; -import { AppliedSessionAgent, MessageHandler, ExitHandler, Monitor, ServerWorker } from "resilient-server-session"; import rimraf = require("rimraf"); +import { AppliedSessionAgent, ExitHandler } from "./Session/agents/applied_session_agent"; +import { ServerWorker } from "./Session/agents/server_worker"; +import { Monitor } from "./Session/agents/monitor"; +import { MessageHandler } from "./Session/agents/promisified_ipc_manager"; /** * If we're the monitor (master) thread, we should launch the monitor logic for the session. diff --git a/src/server/DashSession/Session/agents/applied_session_agent.ts b/src/server/DashSession/Session/agents/applied_session_agent.ts new file mode 100644 index 000000000..46c9e22ed --- /dev/null +++ b/src/server/DashSession/Session/agents/applied_session_agent.ts @@ -0,0 +1,58 @@ +import { isMaster } from "cluster"; +import { Monitor } from "./monitor"; +import { ServerWorker } from "./server_worker"; +import { Utilities } from "../utilities/utilities"; + +export type ExitHandler = (reason: Error | boolean) => void | Promise; + +export abstract class AppliedSessionAgent { + + // the following two methods allow the developer to create a custom + // session and use the built in customization options for each thread + protected abstract async initializeMonitor(monitor: Monitor): Promise; + protected abstract async initializeServerWorker(): Promise; + + private launched = false; + + public killSession = (reason: string, graceful = true, errorCode = 0) => { + const target = isMaster ? this.sessionMonitor : this.serverWorker; + target.killSession(reason, graceful, errorCode); + } + + private sessionMonitorRef: Monitor | undefined; + public get sessionMonitor(): Monitor { + if (!isMaster) { + this.serverWorker.emit("kill", { + graceful: false, + reason: "Cannot access the session monitor directly from the server worker thread.", + errorCode: 1 + }); + throw new Error(); + } + return this.sessionMonitorRef!; + } + + private serverWorkerRef: ServerWorker | undefined; + public get serverWorker(): ServerWorker { + if (isMaster) { + throw new Error("Cannot access the server worker directly from the session monitor thread"); + } + return this.serverWorkerRef!; + } + + public async launch(): Promise { + if (!this.launched) { + this.launched = true; + if (isMaster) { + this.sessionMonitorRef = Monitor.Create() + const sessionKey = await this.initializeMonitor(this.sessionMonitorRef); + this.sessionMonitorRef.finalize(sessionKey); + } else { + this.serverWorkerRef = await this.initializeServerWorker(); + } + } else { + throw new Error("Cannot launch a session thread more than once per process."); + } + } + +} \ No newline at end of file diff --git a/src/server/DashSession/Session/agents/monitor.ts b/src/server/DashSession/Session/agents/monitor.ts new file mode 100644 index 000000000..1d4ea6fb5 --- /dev/null +++ b/src/server/DashSession/Session/agents/monitor.ts @@ -0,0 +1,298 @@ +import { ExitHandler } from "./applied_session_agent"; +import { Configuration, configurationSchema, defaultConfig, Identifiers, colorMapping } from "../utilities/session_config"; +import Repl, { ReplAction } from "../utilities/repl"; +import { isWorker, setupMaster, on, Worker, fork } from "cluster"; +import { manage, MessageHandler } from "./promisified_ipc_manager"; +import { red, cyan, white, yellow, blue } from "colors"; +import { exec, ExecOptions } from "child_process"; +import { validate, ValidationError } from "jsonschema"; +import { Utilities } from "../utilities/utilities"; +import { readFileSync } from "fs"; +import IPCMessageReceiver from "./process_message_router"; +import { ServerWorker } from "./server_worker"; + +/** + * Validates and reads the configuration file, accordingly builds a child process factory + * and spawns off an initial process that will respawn as predecessors die. + */ +export class Monitor extends IPCMessageReceiver { + private static count = 0; + private finalized = false; + private exitHandlers: ExitHandler[] = []; + private readonly config: Configuration; + private activeWorker: Worker | undefined; + private key: string | undefined; + private repl: Repl; + + public static Create() { + if (isWorker) { + ServerWorker.IPCManager.emit("kill", { + reason: "cannot create a monitor on the worker process.", + graceful: false, + errorCode: 1 + }); + process.exit(1); + } else if (++Monitor.count > 1) { + console.error(red("cannot create more than one monitor.")); + process.exit(1); + } else { + return new Monitor(); + } + } + + private constructor() { + super(); + console.log(this.timestamp(), cyan("initializing session...")); + this.configureInternalHandlers(); + this.config = this.loadAndValidateConfiguration(); + this.initializeClusterFunctions(); + this.repl = this.initializeRepl(); + } + + protected configureInternalHandlers = () => { + // handle exceptions in the master thread - there shouldn't be many of these + // the IPC (inter process communication) channel closed exception can't seem + // to be caught in a try catch, and is inconsequential, so it is ignored + process.on("uncaughtException", ({ message, stack }): void => { + if (message !== "Channel closed") { + this.mainLog(red(message)); + if (stack) { + this.mainLog(`uncaught exception\n${red(stack)}`); + } + } + }); + + this.on("kill", ({ reason, graceful, errorCode }) => this.killSession(reason, graceful, errorCode)); + this.on("lifecycle", ({ event }) => console.log(this.timestamp(), `${this.config.identifiers.worker.text} lifecycle phase (${event})`)); + } + + private initializeClusterFunctions = () => { + // determines whether or not we see the compilation / initialization / runtime output of each child server process + const output = this.config.showServerOutput ? "inherit" : "ignore"; + setupMaster({ stdio: ["ignore", output, output, "ipc"] }); + + // a helpful cluster event called on the master thread each time a child process exits + on("exit", ({ process: { pid } }, code, signal) => { + const prompt = `server worker with process id ${pid} has exited with code ${code}${signal === null ? "" : `, having encountered signal ${signal}`}.`; + this.mainLog(cyan(prompt)); + // to make this a robust, continuous session, every time a child process dies, we immediately spawn a new one + this.spawn(); + }); + } + + public finalize = (sessionKey: string): void => { + if (this.finalized) { + throw new Error("Session monitor is already finalized"); + } + this.finalized = true; + this.key = sessionKey; + this.spawn(); + } + + public readonly coreHooks = Object.freeze({ + onCrashDetected: (listener: MessageHandler<{ error: Error }>) => this.on(Monitor.IntrinsicEvents.CrashDetected, listener), + onServerRunning: (listener: MessageHandler<{ isFirstTime: boolean }>) => this.on(Monitor.IntrinsicEvents.ServerRunning, listener) + }); + + /** + * Kill this session and its active child + * server process, either gracefully (may wait + * indefinitely, but at least allows active networking + * requests to complete) or immediately. + */ + public killSession = async (reason: string, graceful = true, errorCode = 0) => { + this.mainLog(cyan(`exiting session ${graceful ? "clean" : "immediate"}ly`)); + this.mainLog(`session exit reason: ${(red(reason))}`); + await this.executeExitHandlers(true); + await this.killActiveWorker(graceful, true); + process.exit(errorCode); + } + + /** + * Execute the list of functions registered to be called + * whenever the process exits. + */ + public addExitHandler = (handler: ExitHandler) => this.exitHandlers.push(handler); + + /** + * Extend the default repl by adding in custom commands + * that can invoke application logic external to this module + */ + public addReplCommand = (basename: string, argPatterns: (RegExp | string)[], action: ReplAction) => { + this.repl.registerCommand(basename, argPatterns, action); + } + + public exec = (command: string, options?: ExecOptions) => { + return new Promise(resolve => { + exec(command, { ...options, encoding: "utf8" }, (error, stdout, stderr) => { + if (error) { + this.execLog(red(`unable to execute ${white(command)}`)); + error.message.split("\n").forEach(line => line.length && this.execLog(red(`(error) ${line}`))); + } else { + let outLines: string[], errorLines: string[]; + if ((outLines = stdout.split("\n").filter(line => line.length)).length) { + outLines.forEach(line => line.length && this.execLog(cyan(`(stdout) ${line}`))); + } + if ((errorLines = stderr.split("\n").filter(line => line.length)).length) { + errorLines.forEach(line => line.length && this.execLog(yellow(`(stderr) ${line}`))); + } + } + resolve(); + }); + }); + } + + /** + * Generates a blue UTC string associated with the time + * of invocation. + */ + private timestamp = () => blue(`[${new Date().toUTCString()}]`); + + /** + * A formatted, identified and timestamped log in color + */ + public mainLog = (...optionalParams: any[]) => { + console.log(this.timestamp(), this.config.identifiers.master.text, ...optionalParams); + } + + /** + * A formatted, identified and timestamped log in color for non- + */ + private execLog = (...optionalParams: any[]) => { + console.log(this.timestamp(), this.config.identifiers.exec.text, ...optionalParams); + } + + /** + * Reads in configuration .json file only once, in the master thread + * and pass down any variables the pertinent to the child processes as environment variables. + */ + private loadAndValidateConfiguration = (): Configuration => { + let config: Configuration; + try { + console.log(this.timestamp(), cyan("validating configuration...")); + config = JSON.parse(readFileSync('./session.config.json', 'utf8')); + const options = { + throwError: true, + allowUnknownAttributes: false + }; + // ensure all necessary and no excess information is specified by the configuration file + validate(config, configurationSchema, options); + config = Utilities.preciseAssign({}, defaultConfig, config); + } catch (error) { + if (error instanceof ValidationError) { + console.log(red("\nSession configuration failed.")); + console.log("The given session.config.json configuration file is invalid."); + console.log(`${error.instance}: ${error.stack}`); + process.exit(0); + } else if (error.code === "ENOENT" && error.path === "./session.config.json") { + console.log(cyan("Loading default session parameters...")); + console.log("Consider including a session.config.json configuration file in your project root for customization."); + config = Utilities.preciseAssign({}, defaultConfig); + } else { + console.log(red("\nSession configuration failed.")); + console.log("The following unknown error occurred during configuration."); + console.log(error.stack); + process.exit(0); + } + } finally { + const { identifiers } = config!; + Object.keys(identifiers).forEach(key => { + const resolved = key as keyof Identifiers; + const { text, color } = identifiers[resolved]; + identifiers[resolved].text = (colorMapping.get(color) || white)(`${text}:`); + }); + return config!; + } + } + + /** + * Builds the repl that allows the following commands to be typed into stdin of the master thread. + */ + private initializeRepl = (): Repl => { + const repl = new Repl({ identifier: () => `${this.timestamp()} ${this.config.identifiers.master.text}` }); + const boolean = /true|false/; + const number = /\d+/; + const letters = /[a-zA-Z]+/; + repl.registerCommand("exit", [/clean|force/], args => this.killSession("manual exit requested by repl", args[0] === "clean", 0)); + repl.registerCommand("restart", [/clean|force/], args => this.killActiveWorker(args[0] === "clean")); + repl.registerCommand("set", [letters, "port", number, boolean], args => this.setPort(args[0], Number(args[2]), args[3] === "true")); + repl.registerCommand("set", [/polling/, number, boolean], args => { + const newPollingIntervalSeconds = Math.floor(Number(args[1])); + if (newPollingIntervalSeconds < 0) { + this.mainLog(red("the polling interval must be a non-negative integer")); + } else { + if (newPollingIntervalSeconds !== this.config.polling.intervalSeconds) { + this.config.polling.intervalSeconds = newPollingIntervalSeconds; + if (args[2] === "true") { + Monitor.IPCManager.emit("updatePollingInterval", { newPollingIntervalSeconds }); + } + } + } + }); + return repl; + } + + private executeExitHandlers = async (reason: Error | boolean) => Promise.all(this.exitHandlers.map(handler => handler(reason))); + + /** + * Attempts to kill the active worker gracefully, unless otherwise specified. + */ + private killActiveWorker = async (graceful = true, isSessionEnd = false): Promise => { + if (this.activeWorker && !this.activeWorker.isDead()) { + if (graceful) { + Monitor.IPCManager.emit("manualExit", { isSessionEnd }); + } else { + await ServerWorker.IPCManager.destroy(); + this.activeWorker.process.kill(); + } + } + } + + /** + * Allows the caller to set the port at which the target (be it the server, + * the websocket, some other custom port) is listening. If an immediate restart + * is specified, this monitor will kill the active child and re-launch the server + * at the port. Otherwise, the updated port won't be used until / unless the child + * dies on its own and triggers a restart. + */ + private setPort = (port: "server" | "socket" | string, value: number, immediateRestart: boolean): void => { + if (value > 1023 && value < 65536) { + this.config.ports[port] = value; + if (immediateRestart) { + this.killActiveWorker(); + } + } else { + this.mainLog(red(`${port} is an invalid port number`)); + } + } + + /** + * Kills the current active worker and proceeds to spawn a new worker, + * feeding in configuration information as environment variables. + */ + private spawn = async (): Promise => { + await this.killActiveWorker(); + const { config: { polling, ports }, key } = this; + this.activeWorker = fork({ + pollingRoute: polling.route, + pollingFailureTolerance: polling.failureTolerance, + serverPort: ports.server, + socketPort: ports.socket, + pollingIntervalSeconds: polling.intervalSeconds, + session_key: key + }); + Monitor.IPCManager = manage(this.activeWorker.process, this.handlers); + this.mainLog(cyan(`spawned new server worker with process id ${this.activeWorker?.process.pid}`)); + } + +} + +export namespace Monitor { + + export enum IntrinsicEvents { + KeyGenerated = "key_generated", + CrashDetected = "crash_detected", + ServerRunning = "server_running" + } + +} \ No newline at end of file diff --git a/src/server/DashSession/Session/agents/process_message_router.ts b/src/server/DashSession/Session/agents/process_message_router.ts new file mode 100644 index 000000000..6cc8aa941 --- /dev/null +++ b/src/server/DashSession/Session/agents/process_message_router.ts @@ -0,0 +1,41 @@ +import { MessageHandler, PromisifiedIPCManager, HandlerMap } from "./promisified_ipc_manager"; + +export default abstract class IPCMessageReceiver { + + protected static IPCManager: PromisifiedIPCManager; + protected handlers: HandlerMap = {}; + + protected abstract configureInternalHandlers: () => void; + + /** + * Add a listener at this message. When the monitor process + * receives a message, it will invoke all registered functions. + */ + public on = (name: string, handler: MessageHandler) => { + const handlers = this.handlers[name]; + if (!handlers) { + this.handlers[name] = [handler]; + } else { + handlers.push(handler); + } + } + + /** + * Unregister a given listener at this message. + */ + public off = (name: string, handler: MessageHandler) => { + const handlers = this.handlers[name]; + if (handlers) { + const index = handlers.indexOf(handler); + if (index > -1) { + handlers.splice(index, 1); + } + } + } + + /** + * Unregister all listeners at this message. + */ + public clearMessageListeners = (...names: string[]) => names.map(name => delete this.handlers[name]); + +} \ No newline at end of file diff --git a/src/server/DashSession/Session/agents/promisified_ipc_manager.ts b/src/server/DashSession/Session/agents/promisified_ipc_manager.ts new file mode 100644 index 000000000..9f0db8330 --- /dev/null +++ b/src/server/DashSession/Session/agents/promisified_ipc_manager.ts @@ -0,0 +1,173 @@ +import { Utilities } from "../utilities/utilities"; +import { ChildProcess } from "child_process"; + +/** + * Convenience constructor + * @param target the process / worker to which to attach the specialized listeners + */ +export function manage(target: IPCTarget, handlers?: HandlerMap) { + return new PromisifiedIPCManager(target, handlers); +} + +/** + * Captures the logic to execute upon receiving a message + * of a certain name. + */ +export type HandlerMap = { [name: string]: MessageHandler[] }; + +/** + * This will always literally be a child process. But, though setting + * up a manager in the parent will indeed see the target as the ChildProcess, + * setting up a manager in the child will just see itself as a regular NodeJS.Process. + */ +export type IPCTarget = NodeJS.Process | ChildProcess; + +/** + * Specifies a general message format for this API + */ +export type Message = { + name: string; + args?: T; +}; +export type MessageHandler = (args: T) => (any | Promise); + +/** + * When a message is emitted, it is embedded with private metadata + * to facilitate the resolution of promises, etc. + */ +interface InternalMessage extends Message { metadata: Metadata } +interface Metadata { isResponse: boolean; id: string } +type InternalMessageHandler = (message: InternalMessage) => (any | Promise); + +/** + * Allows for the transmission of the error's key features over IPC. + */ +export interface ErrorLike { + name?: string; + message?: string; + stack?: string; +} + +/** + * The arguments returned in a message sent from the target upon completion. + */ +export interface Response { + results?: T[]; + error?: ErrorLike; +} + +const destroyEvent = "__destroy__"; + +/** + * This is a wrapper utility class that allows the caller process + * to emit an event and return a promise that resolves when it and all + * other processes listening to its emission of this event have completed. + */ +export class PromisifiedIPCManager { + private readonly target: IPCTarget; + private pendingMessages: { [id: string]: string } = {}; + private isDestroyed = false; + private get callerIsTarget() { + return process.pid === this.target.pid; + } + + constructor(target: IPCTarget, handlers?: HandlerMap) { + this.target = target; + if (handlers) { + handlers[destroyEvent] = [this.destroyHelper]; + this.target.addListener("message", this.generateInternalHandler(handlers)); + } + } + + /** + * This routine uniquely identifies each message, then adds a general + * message listener that waits for a response with the same id before resolving + * the promise. + */ + public emit = async (name: string, args?: any): Promise> => { + if (this.isDestroyed) { + const error = { name: "FailedDispatch", message: "Cannot use a destroyed IPC manager to emit a message." }; + return { error }; + } + return new Promise>(resolve => { + const messageId = Utilities.guid(); + const responseHandler: InternalMessageHandler = ({ metadata: { id, isResponse }, args }) => { + if (isResponse && id === messageId) { + this.target.removeListener("message", responseHandler); + resolve(args); + } + }; + this.target.addListener("message", responseHandler); + const message = { name, args, metadata: { id: messageId, isResponse: false } }; + if (!(this.target.send && this.target.send(message))) { + const error: ErrorLike = { name: "FailedDispatch", message: "Either the target's send method was undefined or the act of sending failed." }; + resolve({ error }); + this.target.removeListener("message", responseHandler); + } + }); + } + + /** + * Invoked from either the parent or the child process, this allows + * any unresolved promises to continue in the target process, but dispatches a dummy + * completion response for each of the pending messages, allowing their + * promises in the caller to resolve. + */ + public destroy = () => { + return new Promise(async resolve => { + if (this.callerIsTarget) { + this.destroyHelper(); + } else { + await this.emit(destroyEvent); + } + resolve(); + }); + } + + /** + * Dispatches the dummy responses and sets the isDestroyed flag to true. + */ + private destroyHelper = () => { + const { pendingMessages } = this; + this.isDestroyed = true; + Object.keys(pendingMessages).forEach(id => { + const error: ErrorLike = { name: "ManagerDestroyed", message: "The IPC manager was destroyed before the response could be returned." }; + const message: InternalMessage = { name: pendingMessages[id], args: { error }, metadata: { id, isResponse: true } }; + this.target.send?.(message) + }); + this.pendingMessages = {}; + } + + /** + * This routine receives a uniquely identified message. If the message is itself a response, + * it is ignored to avoid infinite mutual responses. Otherwise, the routine awaits its completion using whatever + * router the caller has installed, and then sends a response containing the original message id, + * which will ultimately invoke the responseHandler of the original emission and resolve the + * sender's promise. + */ + private generateInternalHandler = (handlers: HandlerMap): MessageHandler => async (message: InternalMessage) => { + const { name, args, metadata } = message; + if (name && metadata && !metadata.isResponse) { + const { id } = metadata; + this.pendingMessages[id] = name; + let error: Error | undefined; + let results: any[] | undefined; + try { + const registered = handlers[name]; + if (registered) { + results = await Promise.all(registered.map(handler => handler(args))); + } + } catch (e) { + error = e; + } + if (!this.isDestroyed && this.target.send) { + const metadata = { id, isResponse: true }; + const response: Response = { results , error }; + const message = { name, args: response , metadata }; + delete this.pendingMessages[id]; + this.target.send(message); + } + } + } + +} \ No newline at end of file diff --git a/src/server/DashSession/Session/agents/server_worker.ts b/src/server/DashSession/Session/agents/server_worker.ts new file mode 100644 index 000000000..976d27226 --- /dev/null +++ b/src/server/DashSession/Session/agents/server_worker.ts @@ -0,0 +1,160 @@ +import { ExitHandler } from "./applied_session_agent"; +import { isMaster } from "cluster"; +import { manage } from "./promisified_ipc_manager"; +import IPCMessageReceiver from "./process_message_router"; +import { red, green, white, yellow } from "colors"; +import { get } from "request-promise"; +import { Monitor } from "./monitor"; + +/** + * Effectively, each worker repairs the connection to the server by reintroducing a consistent state + * if its predecessor has died. It itself also polls the server heartbeat, and exits with a notification + * email if the server encounters an uncaught exception or if the server cannot be reached. + */ +export class ServerWorker extends IPCMessageReceiver { + private static count = 0; + private shouldServerBeResponsive = false; + private exitHandlers: ExitHandler[] = []; + private pollingFailureCount = 0; + private pollingIntervalSeconds: number; + private pollingFailureTolerance: number; + private pollTarget: string; + private serverPort: number; + private isInitialized = false; + + public static Create(work: Function) { + if (isMaster) { + console.error(red("cannot create a worker on the monitor process.")); + process.exit(1); + } else if (++ServerWorker.count > 1) { + ServerWorker.IPCManager.emit("kill", { + reason: "cannot create more than one worker on a given worker process.", + graceful: false, + errorCode: 1 + }); + process.exit(1); + } else { + return new ServerWorker(work); + } + } + + /** + * Allows developers to invoke application specific logic + * by hooking into the exiting of the server process. + */ + public addExitHandler = (handler: ExitHandler) => this.exitHandlers.push(handler); + + /** + * Kill the session monitor (parent process) from this + * server worker (child process). This will also kill + * this process (child process). + */ + public killSession = (reason: string, graceful = true, errorCode = 0) => this.emit("kill", { reason, graceful, errorCode }); + + /** + * A convenience wrapper to tell the session monitor (parent process) + * to carry out the action with the specified message and arguments. + */ + public emit = async (name: string, args?: any) => ServerWorker.IPCManager.emit(name, args); + + private constructor(work: Function) { + super(); + this.configureInternalHandlers(); + ServerWorker.IPCManager = manage(process, this.handlers); + this.lifecycleNotification(green(`initializing process... ${white(`[${process.execPath} ${process.execArgv.join(" ")}]`)}`)); + + const { pollingRoute, serverPort, pollingIntervalSeconds, pollingFailureTolerance } = process.env; + this.serverPort = Number(serverPort); + this.pollingIntervalSeconds = Number(pollingIntervalSeconds); + this.pollingFailureTolerance = Number(pollingFailureTolerance); + this.pollTarget = `http://localhost:${serverPort}${pollingRoute}`; + + work(); + this.pollServer(); + } + + /** + * Set up message and uncaught exception handlers for this + * server process. + */ + protected configureInternalHandlers = () => { + // updates the local values of variables to the those sent from master + this.on("updatePollingInterval", ({ newPollingIntervalSeconds }) => this.pollingIntervalSeconds = newPollingIntervalSeconds); + this.on("manualExit", async ({ isSessionEnd }) => { + await ServerWorker.IPCManager.destroy(); + await this.executeExitHandlers(isSessionEnd); + process.exit(0); + }); + + // one reason to exit, as the process might be in an inconsistent state after such an exception + process.on('uncaughtException', this.proactiveUnplannedExit); + process.on('unhandledRejection', reason => { + const appropriateError = reason instanceof Error ? reason : new Error(`unhandled rejection: ${reason}`); + this.proactiveUnplannedExit(appropriateError); + }); + } + + /** + * Execute the list of functions registered to be called + * whenever the process exits. + */ + private executeExitHandlers = async (reason: Error | boolean) => Promise.all(this.exitHandlers.map(handler => handler(reason))); + + /** + * Notify master thread (which will log update in the console) of initialization via IPC. + */ + public lifecycleNotification = (event: string) => this.emit("lifecycle", { event }); + + /** + * Called whenever the process has a reason to terminate, either through an uncaught exception + * in the process (potentially inconsistent state) or the server cannot be reached. + */ + private proactiveUnplannedExit = async (error: Error): Promise => { + this.shouldServerBeResponsive = false; + // communicates via IPC to the master thread that it should dispatch a crash notification email + this.emit(Monitor.IntrinsicEvents.CrashDetected, { error }); + await this.executeExitHandlers(error); + // notify master thread (which will log update in the console) of crash event via IPC + this.lifecycleNotification(red(`crash event detected @ ${new Date().toUTCString()}`)); + this.lifecycleNotification(red(error.message)); + await ServerWorker.IPCManager.destroy(); + process.exit(1); + } + + /** + * This monitors the health of the server by submitting a get request to whatever port / route specified + * by the configuration every n seconds, where n is also given by the configuration. + */ + private pollServer = async (): Promise => { + await new Promise(resolve => { + setTimeout(async () => { + try { + await get(this.pollTarget); + if (!this.shouldServerBeResponsive) { + // notify monitor thread that the server is up and running + this.lifecycleNotification(green(`listening on ${this.serverPort}...`)); + this.emit(Monitor.IntrinsicEvents.ServerRunning, { isFirstTime: !this.isInitialized }); + this.isInitialized = true; + } + this.shouldServerBeResponsive = true; + } catch (error) { + // if we expect the server to be unavailable, i.e. during compilation, + // the listening variable is false, activeExit will return early and the child + // process will continue + if (this.shouldServerBeResponsive) { + if (++this.pollingFailureCount > this.pollingFailureTolerance) { + this.proactiveUnplannedExit(error); + } else { + this.lifecycleNotification(yellow(`the server has encountered ${this.pollingFailureCount} of ${this.pollingFailureTolerance} tolerable failures`)); + } + } + } finally { + resolve(); + } + }, 1000 * this.pollingIntervalSeconds); + }); + // controlled, asynchronous infinite recursion achieves a persistent poll that does not submit a new request until the previous has completed + this.pollServer(); + } + +} \ No newline at end of file diff --git a/src/server/DashSession/Session/utilities/repl.ts b/src/server/DashSession/Session/utilities/repl.ts new file mode 100644 index 000000000..643141286 --- /dev/null +++ b/src/server/DashSession/Session/utilities/repl.ts @@ -0,0 +1,128 @@ +import { createInterface, Interface } from "readline"; +import { red, green, white } from "colors"; + +export interface Configuration { + identifier: () => string | string; + onInvalid?: (command: string, validCommand: boolean) => string | string; + onValid?: (success?: string) => string | string; + isCaseSensitive?: boolean; +} + +export type ReplAction = (parsedArgs: Array) => any | Promise; +export interface Registration { + argPatterns: RegExp[]; + action: ReplAction; +} + +export default class Repl { + private identifier: () => string | string; + private onInvalid: ((command: string, validCommand: boolean) => string) | string; + private onValid: ((success: string) => string) | string; + private isCaseSensitive: boolean; + private commandMap = new Map(); + public interface: Interface; + private busy = false; + private keys: string | undefined; + + constructor({ identifier: prompt, onInvalid, onValid, isCaseSensitive }: Configuration) { + this.identifier = prompt; + this.onInvalid = onInvalid || this.usage; + this.onValid = onValid || this.success; + this.isCaseSensitive = isCaseSensitive ?? true; + this.interface = createInterface(process.stdin, process.stdout).on('line', this.considerInput); + } + + private resolvedIdentifier = () => typeof this.identifier === "string" ? this.identifier : this.identifier(); + + private usage = (command: string, validCommand: boolean) => { + if (validCommand) { + const formatted = white(command); + const patterns = green(this.commandMap.get(command)!.map(({ argPatterns }) => `${formatted} ${argPatterns.join(" ")}`).join('\n')); + return `${this.resolvedIdentifier()}\nthe given arguments do not match any registered patterns for ${formatted}\nthe list of valid argument patterns is given by:\n${patterns}`; + } else { + const resolved = this.keys; + if (resolved) { + return resolved; + } + const members: string[] = []; + const keys = this.commandMap.keys(); + let next: IteratorResult; + while (!(next = keys.next()).done) { + members.push(next.value); + } + return `${this.resolvedIdentifier()} commands: { ${members.sort().join(", ")} }`; + } + } + + private success = (command: string) => `${this.resolvedIdentifier()} completed local execution of ${white(command)}`; + + public registerCommand = (basename: string, argPatterns: (RegExp | string)[], action: ReplAction) => { + const existing = this.commandMap.get(basename); + const converted = argPatterns.map(input => input instanceof RegExp ? input : new RegExp(input)); + const registration = { argPatterns: converted, action }; + if (existing) { + existing.push(registration); + } else { + this.commandMap.set(basename, [registration]); + } + } + + private invalid = (command: string, validCommand: boolean) => { + console.log(red(typeof this.onInvalid === "string" ? this.onInvalid : this.onInvalid(command, validCommand))); + this.busy = false; + } + + private valid = (command: string) => { + console.log(green(typeof this.onValid === "string" ? this.onValid : this.onValid(command))); + this.busy = false; + } + + private considerInput = async (line: string) => { + if (this.busy) { + console.log(red("Busy")); + return; + } + this.busy = true; + line = line.trim(); + if (this.isCaseSensitive) { + line = line.toLowerCase(); + } + const [command, ...args] = line.split(/\s+/g); + if (!command) { + return this.invalid(command, false); + } + const registered = this.commandMap.get(command); + if (registered) { + const { length } = args; + const candidates = registered.filter(({ argPatterns: { length: count } }) => count === length); + for (const { argPatterns, action } of candidates) { + const parsed: string[] = []; + let matched = true; + if (length) { + for (let i = 0; i < length; i++) { + let matches: RegExpExecArray | null; + if ((matches = argPatterns[i].exec(args[i])) === null) { + matched = false; + break; + } + parsed.push(matches[0]); + } + } + if (!length || matched) { + const result = action(parsed); + const resolve = () => this.valid(`${command} ${parsed.join(" ")}`); + if (result instanceof Promise) { + result.then(resolve); + } else { + resolve(); + } + return; + } + } + this.invalid(command, true); + } else { + this.invalid(command, false); + } + } + +} \ No newline at end of file diff --git a/src/server/DashSession/Session/utilities/session_config.ts b/src/server/DashSession/Session/utilities/session_config.ts new file mode 100644 index 000000000..b0e65dde4 --- /dev/null +++ b/src/server/DashSession/Session/utilities/session_config.ts @@ -0,0 +1,129 @@ +import { Schema } from "jsonschema"; +import { yellow, red, cyan, green, blue, magenta, Color, grey, gray, white, black } from "colors"; + +const colorPattern = /black|red|green|yellow|blue|magenta|cyan|white|gray|grey/; + +const identifierProperties: Schema = { + type: "object", + properties: { + text: { + type: "string", + minLength: 1 + }, + color: { + type: "string", + pattern: colorPattern + } + } +}; + +const portProperties: Schema = { + type: "number", + minimum: 1024, + maximum: 65535 +}; + +export const configurationSchema: Schema = { + id: "/configuration", + type: "object", + properties: { + showServerOutput: { type: "boolean" }, + ports: { + type: "object", + properties: { + server: portProperties, + socket: portProperties + }, + required: ["server"], + additionalProperties: true + }, + identifiers: { + type: "object", + properties: { + master: identifierProperties, + worker: identifierProperties, + exec: identifierProperties + } + }, + polling: { + type: "object", + additionalProperties: false, + properties: { + intervalSeconds: { + type: "number", + minimum: 1, + maximum: 86400 + }, + route: { + type: "string", + pattern: /\/[a-zA-Z]*/g + }, + failureTolerance: { + type: "number", + minimum: 0, + } + } + }, + } +}; + +type ColorLabel = "yellow" | "red" | "cyan" | "green" | "blue" | "magenta" | "grey" | "gray" | "white" | "black"; + +export const colorMapping: Map = new Map([ + ["yellow", yellow], + ["red", red], + ["cyan", cyan], + ["green", green], + ["blue", blue], + ["magenta", magenta], + ["grey", grey], + ["gray", gray], + ["white", white], + ["black", black] +]); + +interface Identifier { + text: string; + color: ColorLabel; +} + +export interface Identifiers { + master: Identifier; + worker: Identifier; + exec: Identifier; +} + +export interface Configuration { + showServerOutput: boolean; + identifiers: Identifiers; + ports: { [description: string]: number }; + polling: { + route: string; + intervalSeconds: number; + failureTolerance: number; + }; +} + +export const defaultConfig: Configuration = { + showServerOutput: false, + identifiers: { + master: { + text: "__monitor__", + color: "yellow" + }, + worker: { + text: "__server__", + color: "magenta" + }, + exec: { + text: "__exec__", + color: "green" + } + }, + ports: { server: 3000 }, + polling: { + route: "/", + intervalSeconds: 30, + failureTolerance: 0 + } +}; \ No newline at end of file diff --git a/src/server/DashSession/Session/utilities/utilities.ts b/src/server/DashSession/Session/utilities/utilities.ts new file mode 100644 index 000000000..eb8de9d7e --- /dev/null +++ b/src/server/DashSession/Session/utilities/utilities.ts @@ -0,0 +1,37 @@ +import { v4 } from "uuid"; + +export namespace Utilities { + + export function guid() { + return v4(); + } + + /** + * At any arbitrary layer of nesting within the configuration objects, any single value that + * is not specified by the configuration is given the default counterpart. If, within an object, + * one peer is given by configuration and two are not, the one is preserved while the two are given + * the default value. + * @returns the composition of all of the assigned objects, much like Object.assign(), but with more + * granularity in the overwriting of nested objects + */ + export function preciseAssign(target: any, ...sources: any[]): any { + for (const source of sources) { + preciseAssignHelper(target, source); + } + return target; + } + + export function preciseAssignHelper(target: any, source: any) { + Array.from(new Set([...Object.keys(target), ...Object.keys(source)])).map(property => { + let targetValue: any, sourceValue: any; + if (sourceValue = source[property]) { + if (typeof sourceValue === "object" && typeof (targetValue = target[property]) === "object") { + preciseAssignHelper(targetValue, sourceValue); + } else { + target[property] = sourceValue; + } + } + }); + } + +} \ No newline at end of file diff --git a/src/server/index.ts b/src/server/index.ts index 2101de1d2..88f5fa3bf 100644 --- a/src/server/index.ts +++ b/src/server/index.ts @@ -24,7 +24,7 @@ import { Logger } from "./ProcessFactory"; import { yellow } from "colors"; import { DashSessionAgent } from "./DashSession/DashSessionAgent"; import SessionManager from "./ApiManagers/SessionManager"; -import { AppliedSessionAgent } from "resilient-server-session"; +import { AppliedSessionAgent } from "./DashSession/Session/agents/applied_session_agent"; export const onWindows = process.platform === "win32"; export let sessionAgent: AppliedSessionAgent; -- cgit v1.2.3-70-g09d2 From 13e02e89660de831860d4e70fa6c474c77d65540 Mon Sep 17 00:00:00 2001 From: server Date: Mon, 10 Feb 2020 14:35:32 -0500 Subject: ignore repl in release server --- solr-8.3.1/server/tmp/start_3204295554151338130.properties | 11 +++++++++++ solr-8.3.1/server/tmp/start_5812170489311981381.properties | 11 +++++++++++ src/server/DashSession/Session/agents/monitor.ts | 6 +++--- 3 files changed, 25 insertions(+), 3 deletions(-) create mode 100644 solr-8.3.1/server/tmp/start_3204295554151338130.properties create mode 100644 solr-8.3.1/server/tmp/start_5812170489311981381.properties (limited to 'src/server') diff --git a/solr-8.3.1/server/tmp/start_3204295554151338130.properties b/solr-8.3.1/server/tmp/start_3204295554151338130.properties new file mode 100644 index 000000000..8ce47f861 --- /dev/null +++ b/solr-8.3.1/server/tmp/start_3204295554151338130.properties @@ -0,0 +1,11 @@ +#start.jar properties +#Wed Jan 08 17:42:54 UTC 2020 +java.version.platform=8 +java.version=1.8.0_211 +java.version.micro=0 +jetty.home=C\:\\Users\\dash\\Documents\\Dash-Web\\solr-8.3.1\\server +java.version.minor=8 +jetty.home.uri=file\:///C\:/Users/dash/Documents/Dash-Web/solr-8.3.1/server +jetty.base=C\:\\Users\\dash\\Documents\\Dash-Web\\solr-8.3.1\\server +java.version.major=1 +jetty.base.uri=file\:///C\:/Users/dash/Documents/Dash-Web/solr-8.3.1/server diff --git a/solr-8.3.1/server/tmp/start_5812170489311981381.properties b/solr-8.3.1/server/tmp/start_5812170489311981381.properties new file mode 100644 index 000000000..c4be08baf --- /dev/null +++ b/solr-8.3.1/server/tmp/start_5812170489311981381.properties @@ -0,0 +1,11 @@ +#start.jar properties +#Thu Jan 16 17:33:01 UTC 2020 +java.version.platform=8 +java.version=1.8.0_211 +java.version.micro=0 +jetty.home=C\:\\Users\\dash\\Documents\\Dash-Web\\solr-8.3.1\\server +java.version.minor=8 +jetty.home.uri=file\:///C\:/Users/dash/Documents/Dash-Web/solr-8.3.1/server +jetty.base=C\:\\Users\\dash\\Documents\\Dash-Web\\solr-8.3.1\\server +java.version.major=1 +jetty.base.uri=file\:///C\:/Users/dash/Documents/Dash-Web/solr-8.3.1/server diff --git a/src/server/DashSession/Session/agents/monitor.ts b/src/server/DashSession/Session/agents/monitor.ts index 1d4ea6fb5..6f8d25614 100644 --- a/src/server/DashSession/Session/agents/monitor.ts +++ b/src/server/DashSession/Session/agents/monitor.ts @@ -22,7 +22,7 @@ export class Monitor extends IPCMessageReceiver { private readonly config: Configuration; private activeWorker: Worker | undefined; private key: string | undefined; - private repl: Repl; + // private repl: Repl; public static Create() { if (isWorker) { @@ -46,7 +46,7 @@ export class Monitor extends IPCMessageReceiver { this.configureInternalHandlers(); this.config = this.loadAndValidateConfiguration(); this.initializeClusterFunctions(); - this.repl = this.initializeRepl(); + // this.repl = this.initializeRepl(); } protected configureInternalHandlers = () => { @@ -119,7 +119,7 @@ export class Monitor extends IPCMessageReceiver { * that can invoke application logic external to this module */ public addReplCommand = (basename: string, argPatterns: (RegExp | string)[], action: ReplAction) => { - this.repl.registerCommand(basename, argPatterns, action); + // this.repl.registerCommand(basename, argPatterns, action); } public exec = (command: string, options?: ExecOptions) => { -- cgit v1.2.3-70-g09d2 From 60a008f635177acccaa9dacb4006491725c93702 Mon Sep 17 00:00:00 2001 From: bob Date: Mon, 10 Feb 2020 15:05:30 -0500 Subject: small cleanups to adding stacking views to contentfittingboxes (like time/pivot). needs to have nativeWidth/Height set. --- src/client/documents/Documents.ts | 4 +++ src/client/util/RichTextRules.ts | 19 ++++++------ src/client/util/RichTextSchema.tsx | 18 +++++------ .../views/collections/CollectionStackingView.tsx | 35 +++++++++------------- src/client/views/collections/CollectionSubView.tsx | 5 +++- .../views/collections/CollectionTimeView.tsx | 3 +- src/client/views/collections/CollectionView.tsx | 6 ++-- .../CollectionFreeFormLayoutEngines.tsx | 2 +- .../collectionFreeForm/CollectionFreeFormView.tsx | 23 +++++++------- .../CollectionMulticolumnView.scss | 2 +- .../CollectionMultirowView.scss | 2 +- src/client/views/nodes/DocumentView.tsx | 20 ++++++++----- src/new_fields/Doc.ts | 17 +++++++++-- .../authentication/models/current_user_utils.ts | 6 ++-- 14 files changed, 87 insertions(+), 75 deletions(-) (limited to 'src/server') diff --git a/src/client/documents/Documents.ts b/src/client/documents/Documents.ts index 6775d2302..29f253115 100644 --- a/src/client/documents/Documents.ts +++ b/src/client/documents/Documents.ts @@ -594,6 +594,10 @@ export namespace Docs { export function MulticolumnDocument(documents: Array, options: DocumentOptions) { return InstanceFromProto(Prototypes.get(DocumentType.COL), new List(documents), { _chromeStatus: "collapsed", schemaColumns: new List([new SchemaHeaderField("title", "#f1efeb")]), ...options, _viewType: CollectionViewType.Multicolumn }); } + export function MultirowDocument(documents: Array, options: DocumentOptions) { + return InstanceFromProto(Prototypes.get(DocumentType.COL), new List(documents), { _chromeStatus: "collapsed", schemaColumns: new List([new SchemaHeaderField("title", "#f1efeb")]), ...options, _viewType: CollectionViewType.Multirow }); + } + export function MasonryDocument(documents: Array, options: DocumentOptions) { return InstanceFromProto(Prototypes.get(DocumentType.COL), new List(documents), { _chromeStatus: "collapsed", schemaColumns: new List([new SchemaHeaderField("title", "#f1efeb")]), ...options, _viewType: CollectionViewType.Masonry }); diff --git a/src/client/util/RichTextRules.ts b/src/client/util/RichTextRules.ts index 3b30b5b3f..1b67b4fe4 100644 --- a/src/client/util/RichTextRules.ts +++ b/src/client/util/RichTextRules.ts @@ -1,17 +1,16 @@ -import { textblockTypeInputRule, smartQuotes, emDash, ellipsis, InputRule } from "prosemirror-inputrules"; -import { schema } from "./RichTextSchema"; -import { wrappingInputRule } from "./prosemirrorPatches"; +import { ellipsis, emDash, InputRule, smartQuotes, textblockTypeInputRule } from "prosemirror-inputrules"; import { NodeSelection, TextSelection } from "prosemirror-state"; -import { StrCast, Cast, NumCast } from "../../new_fields/Types"; -import { Doc, DataSym } from "../../new_fields/Doc"; -import { FormattedTextBox } from "../views/nodes/FormattedTextBox"; -import { Docs, DocUtils } from "../documents/Documents"; +import { DataSym, Doc } from "../../new_fields/Doc"; import { Id } from "../../new_fields/FieldSymbols"; -import { DocServer } from "../DocServer"; +import { ComputedField } from "../../new_fields/ScriptField"; +import { Cast, NumCast } from "../../new_fields/Types"; import { returnFalse, Utils } from "../../Utils"; +import { DocServer } from "../DocServer"; +import { Docs, DocUtils } from "../documents/Documents"; +import { FormattedTextBox } from "../views/nodes/FormattedTextBox"; +import { wrappingInputRule } from "./prosemirrorPatches"; import RichTextMenu from "./RichTextMenu"; -import { RichTextField } from "../../new_fields/RichTextField"; -import { ComputedField } from "../../new_fields/ScriptField"; +import { schema } from "./RichTextSchema"; export const inpRules = { rules: [ diff --git a/src/client/util/RichTextSchema.tsx b/src/client/util/RichTextSchema.tsx index c07ebe2ed..043b277de 100644 --- a/src/client/util/RichTextSchema.tsx +++ b/src/client/util/RichTextSchema.tsx @@ -1,28 +1,26 @@ -import { reaction, IReactionDisposer, observable, runInAction } from "mobx"; +import { IReactionDisposer, observable, reaction, runInAction } from "mobx"; import { baseKeymap, toggleMark } from "prosemirror-commands"; import { redo, undo } from "prosemirror-history"; import { keymap } from "prosemirror-keymap"; import { DOMOutputSpecArray, Fragment, MarkSpec, Node, NodeSpec, Schema, Slice } from "prosemirror-model"; import { bulletList, listItem, orderedList } from 'prosemirror-schema-list'; -import { EditorState, NodeSelection, TextSelection, Plugin } from "prosemirror-state"; +import { EditorState, NodeSelection, Plugin, TextSelection } from "prosemirror-state"; import { StepMap } from "prosemirror-transform"; import { EditorView } from "prosemirror-view"; import * as ReactDOM from 'react-dom'; -import { Doc, WidthSym, HeightSym, DataSym, Field } from "../../new_fields/Doc"; +import { Doc, Field, HeightSym, WidthSym } from "../../new_fields/Doc"; +import { Id } from "../../new_fields/FieldSymbols"; +import { ObjectField } from "../../new_fields/ObjectField"; +import { ComputedField } from "../../new_fields/ScriptField"; +import { BoolCast, NumCast, StrCast } from "../../new_fields/Types"; import { emptyFunction, returnEmptyString, returnFalse, returnOne, Utils } from "../../Utils"; import { DocServer } from "../DocServer"; import { DocumentView } from "../views/nodes/DocumentView"; +import { FormattedTextBox } from "../views/nodes/FormattedTextBox"; import { DocumentManager } from "./DocumentManager"; import ParagraphNodeSpec from "./ParagraphNodeSpec"; import { Transform } from "./Transform"; import React = require("react"); -import { BoolCast, NumCast, StrCast } from "../../new_fields/Types"; -import { FormattedTextBox } from "../views/nodes/FormattedTextBox"; -import { ObjectField } from "../../new_fields/ObjectField"; -import { ComputedField } from "../../new_fields/ScriptField"; -import { observer } from "mobx-react"; -import { Id } from "../../new_fields/FieldSymbols"; -import { OnChangeHandler } from "react-color/lib/components/common/ColorWrap"; const blockquoteDOM: DOMOutputSpecArray = ["blockquote", 0], hrDOM: DOMOutputSpecArray = ["hr"], preDOM: DOMOutputSpecArray = ["pre", ["code", 0]], brDOM: DOMOutputSpecArray = ["br"], ulDOM: DOMOutputSpecArray = ["ul", 0]; diff --git a/src/client/views/collections/CollectionStackingView.tsx b/src/client/views/collections/CollectionStackingView.tsx index d772ace23..21c34d047 100644 --- a/src/client/views/collections/CollectionStackingView.tsx +++ b/src/client/views/collections/CollectionStackingView.tsx @@ -4,25 +4,25 @@ import { CursorProperty } from "csstype"; import { action, computed, IReactionDisposer, observable, reaction, runInAction } from "mobx"; import { observer } from "mobx-react"; import Switch from 'rc-switch'; -import { Doc, HeightSym, WidthSym, DataSym } from "../../../new_fields/Doc"; +import { Doc, HeightSym, WidthSym } from "../../../new_fields/Doc"; import { Id } from "../../../new_fields/FieldSymbols"; import { List } from "../../../new_fields/List"; import { listSpec } from "../../../new_fields/Schema"; import { SchemaHeaderField } from "../../../new_fields/SchemaHeaderField"; -import { BoolCast, Cast, NumCast, StrCast, ScriptCast } from "../../../new_fields/Types"; -import { emptyFunction, Utils } from "../../../Utils"; +import { BoolCast, Cast, NumCast, ScriptCast, StrCast } from "../../../new_fields/Types"; +import { TraceMobx } from "../../../new_fields/util"; +import { Utils } from "../../../Utils"; import { DragManager } from "../../util/DragManager"; import { Transform } from "../../util/Transform"; import { undoBatch } from "../../util/UndoManager"; +import { ContextMenu } from "../ContextMenu"; +import { ContextMenuProps } from "../ContextMenuItem"; import { EditableView } from "../EditableView"; import { ContentFittingDocumentView } from "../nodes/ContentFittingDocumentView"; +import { CollectionMasonryViewFieldRow } from "./CollectionMasonryViewFieldRow"; import "./CollectionStackingView.scss"; import { CollectionStackingViewFieldColumn } from "./CollectionStackingViewFieldColumn"; import { CollectionSubView } from "./CollectionSubView"; -import { ContextMenu } from "../ContextMenu"; -import { ContextMenuProps } from "../ContextMenuItem"; -import { CollectionMasonryViewFieldRow } from "./CollectionMasonryViewFieldRow"; -import { TraceMobx } from "../../../new_fields/util"; import { CollectionViewType } from "./CollectionView"; @observer @@ -55,7 +55,7 @@ export class CollectionStackingView extends CollectionSubView(doc => doc) { this._docXfs.length = 0; return docs.map((d, i) => { const height = () => this.getDocHeight(d); - const width = () => this.widthScale * Math.min(d._nativeWidth && !d.ignoreAspect && !this.props.Document.fillColumn ? d[WidthSym]() : Number.MAX_VALUE, this.columnWidth / this.numGroupColumns); + const width = () => Math.min(d._nativeWidth && !d.ignoreAspect && !this.props.Document.fillColumn ? d[WidthSym]() : Number.MAX_VALUE, this.columnWidth / this.numGroupColumns); const dref = React.createRef(); const dxf = () => this.getDocTransform(d, dref.current!); this._docXfs.push({ dxf: dxf, width: width, height: height }); @@ -376,16 +376,9 @@ export class CollectionStackingView extends CollectionSubView(doc => doc) { } return sections.map(section => this.isStackingView ? this.sectionStacking(section[0], section[1]) : this.sectionMasonry(section[0], section[1])); } - @computed get contentScale() { - const heightExtra = this.heightPercent > 1 ? this.heightPercent : 1; - return Math.min(this.props.Document[WidthSym]() / this.props.PanelWidth(), heightExtra * this.props.Document[HeightSym]() / this.props.PanelHeight()); - } - @computed get widthScale() { - return this.heightPercent < 1 ? Math.max(1, this.contentScale) : 1; - } - @computed get heightPercent() { - return this.props.PanelHeight() / this.layoutDoc[HeightSym](); - } + + @computed get scaling() { return !this.props.Document._nativeWidth ? 1 : this.props.PanelHeight() / NumCast(this.props.Document._nativeHeight); } + render() { TraceMobx(); const editableViewProps = { @@ -399,9 +392,9 @@ export class CollectionStackingView extends CollectionSubView(doc => doc) { ref={this.createRef} style={{ overflowY: this.props.active() ? "auto" : "hidden", - transform: `scale(${Math.min(1, this.heightPercent)})`, - height: `${100 * Math.max(1, this.contentScale)}%`, - width: `${100 * this.widthScale}%`, + transform: `scale(${this.scaling}`, + height: `${1 / this.scaling * 100}%`, + width: `${1 / this.scaling * 100}%`, transformOrigin: "top left", }} onScroll={action((e: React.UIEvent) => this._scroll = e.currentTarget.scrollTop)} diff --git a/src/client/views/collections/CollectionSubView.tsx b/src/client/views/collections/CollectionSubView.tsx index 62b9e8380..d71bad647 100644 --- a/src/client/views/collections/CollectionSubView.tsx +++ b/src/client/views/collections/CollectionSubView.tsx @@ -1,7 +1,7 @@ import { action, computed, IReactionDisposer, reaction, trace } from "mobx"; import * as rp from 'request-promise'; import CursorField from "../../../new_fields/CursorField"; -import { Doc, DocListCast, Opt } from "../../../new_fields/Doc"; +import { Doc, DocListCast, Opt, WidthSym, HeightSym } from "../../../new_fields/Doc"; import { Id } from "../../../new_fields/FieldSymbols"; import { List } from "../../../new_fields/List"; import { listSpec } from "../../../new_fields/Schema"; @@ -167,6 +167,9 @@ export function CollectionSubView(schemaCtor: (doc: Doc) => T) { return true; } let added = false; + if (this.props.Document._freezeOnDrop) { + de.complete.docDragData?.droppedDocuments.forEach(drop => Doc.freezeNativeDimensions(drop, drop[WidthSym](), drop[HeightSym]())); + } if (docDragData.dropAction || docDragData.userDropAction) { added = docDragData.droppedDocuments.reduce((added: boolean, d) => this.props.addDocument(d) || added, false); } else if (docDragData.moveDocument) { diff --git a/src/client/views/collections/CollectionTimeView.tsx b/src/client/views/collections/CollectionTimeView.tsx index 6058f4e1d..db176d0bc 100644 --- a/src/client/views/collections/CollectionTimeView.tsx +++ b/src/client/views/collections/CollectionTimeView.tsx @@ -2,7 +2,7 @@ import { faEdit } from "@fortawesome/free-solid-svg-icons"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { action, computed, observable, runInAction, trace } from "mobx"; import { observer } from "mobx-react"; -import { Doc, DocListCast, Field } from "../../../new_fields/Doc"; +import { Doc, DocListCast, Field, WidthSym, HeightSym } from "../../../new_fields/Doc"; import { List } from "../../../new_fields/List"; import { ObjectField } from "../../../new_fields/ObjectField"; import { RichTextField } from "../../../new_fields/RichTextField"; @@ -31,6 +31,7 @@ export class CollectionTimeView extends CollectionSubView(doc => doc) { @observable _layoutEngine = "pivot"; componentDidMount() { + this.props.Document._freezeOnDrop = true; const childDetailed = this.props.Document.childDetailed; // bcz: needs to be here to make sure the childDetailed layout template has been loaded when the first item is clicked; if (!this.props.Document._facetCollection) { const facetCollection = Docs.Create.TreeDocument([], { title: "facetFilters", _yMargin: 0, treeViewHideTitle: true, treeViewHideHeaderFields: true }); diff --git a/src/client/views/collections/CollectionView.tsx b/src/client/views/collections/CollectionView.tsx index 2f27e5273..c081649cc 100644 --- a/src/client/views/collections/CollectionView.tsx +++ b/src/client/views/collections/CollectionView.tsx @@ -7,7 +7,7 @@ import * as React from 'react'; import Lightbox from 'react-image-lightbox-with-rotate'; import 'react-image-lightbox-with-rotate/style.css'; // This only needs to be imported once in your app import { DateField } from '../../../new_fields/DateField'; -import { Doc, DocListCast } from '../../../new_fields/Doc'; +import { Doc, DocListCast, DataSym } from '../../../new_fields/Doc'; import { Id } from '../../../new_fields/FieldSymbols'; import { listSpec } from '../../../new_fields/Schema'; import { BoolCast, Cast, StrCast, NumCast } from '../../../new_fields/Types'; @@ -133,7 +133,7 @@ export class CollectionView extends Touchable { @action.bound addDocument(doc: Doc): boolean { - const targetDataDoc = Doc.GetProto(this.props.DataDoc || this.props.Document); // bcz: shouldn't this be Doc.Layout(this.props.Document)? Right now, that causes problems with Buxton layout & adding things to a SLideView + const targetDataDoc = this.props.Document[DataSym]; Doc.AddDocToList(targetDataDoc, this.props.fieldKey, doc); targetDataDoc[this.props.fieldKey + "-lastModified"] = new DateField(new Date(Date.now())); Doc.GetProto(doc).lastOpened = new DateField; @@ -144,7 +144,7 @@ export class CollectionView extends Touchable { removeDocument(doc: Doc): boolean { const docView = DocumentManager.Instance.getDocumentView(doc, this.props.ContainingCollectionView); docView && SelectionManager.DeselectDoc(docView); - const value = Cast(Doc.GetProto(this.props.DataDoc || this.props.Document)[this.props.fieldKey], listSpec(Doc), []); + const value = Cast(this.props.Document[DataSym][this.props.fieldKey], listSpec(Doc), []); let index = value.reduce((p, v, i) => (v instanceof Doc && v === doc) ? i : p, -1); index = index !== -1 ? index : value.reduce((p, v, i) => (v instanceof Doc && Doc.AreProtosEqual(v, doc)) ? i : p, -1); diff --git a/src/client/views/collections/collectionFreeForm/CollectionFreeFormLayoutEngines.tsx b/src/client/views/collections/collectionFreeForm/CollectionFreeFormLayoutEngines.tsx index baf09fe5b..da4dc0270 100644 --- a/src/client/views/collections/collectionFreeForm/CollectionFreeFormLayoutEngines.tsx +++ b/src/client/views/collections/collectionFreeForm/CollectionFreeFormLayoutEngines.tsx @@ -186,7 +186,7 @@ export function computePivotLayout( const maxColHeight = pivotAxisWidth * expander * Math.ceil(maxInColumn / numCols); const dividers = sortedPivotKeys.map((key, i) => - ({ type: "div", color: "lightGray", x: i * pivotAxisWidth * (numCols * expander + gap), y: -maxColHeight + pivotAxisWidth, width: pivotAxisWidth * numCols * expander, height: maxColHeight, payload: pivotColumnGroups.get(key)!.filters })); + ({ type: "div", color: "lightGray", x: i * pivotAxisWidth * (numCols * expander + gap) - pivotAxisWidth * (expander - 1) / 2, y: -maxColHeight + pivotAxisWidth, width: pivotAxisWidth * numCols * expander, height: maxColHeight, payload: pivotColumnGroups.get(key)!.filters })); groupNames.push(...dividers); return normalizeResults(panelDim, max_text, childPairs, docMap, poolData, viewDefsToJSX, groupNames, 0, [], childDocs.filter(c => !filterDocs.includes(c))); } diff --git a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx index c78a2a2cf..07a5a2c7b 100644 --- a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx +++ b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx @@ -1,20 +1,22 @@ import { library } from "@fortawesome/fontawesome-svg-core"; import { faEye } from "@fortawesome/free-regular-svg-icons"; import { faBraille, faChalkboard, faCompass, faCompressArrowsAlt, faExpandArrowsAlt, faFileUpload, faPaintBrush, faTable, faUpload } from "@fortawesome/free-solid-svg-icons"; -import { action, computed, observable, ObservableMap, reaction, runInAction, IReactionDisposer, trace } from "mobx"; +import { action, computed, IReactionDisposer, observable, reaction, runInAction } from "mobx"; import { observer } from "mobx-react"; -import { Doc, DocListCast, HeightSym, Opt, WidthSym, DocListCastAsync, Field } from "../../../../new_fields/Doc"; +import { computedFn } from "mobx-utils"; +import { Doc, DocListCast, HeightSym, Opt, WidthSym } from "../../../../new_fields/Doc"; import { documentSchema, positionSchema } from "../../../../new_fields/documentSchemas"; import { Id } from "../../../../new_fields/FieldSymbols"; -import { InkTool, InkField, InkData } from "../../../../new_fields/InkField"; -import { createSchema, makeInterface, listSpec } from "../../../../new_fields/Schema"; +import { InkTool } from "../../../../new_fields/InkField"; +import { createSchema, listSpec, makeInterface } from "../../../../new_fields/Schema"; import { ScriptField } from "../../../../new_fields/ScriptField"; -import { BoolCast, Cast, DateCast, NumCast, StrCast, ScriptCast } from "../../../../new_fields/Types"; +import { Cast, NumCast, ScriptCast, StrCast } from "../../../../new_fields/Types"; +import { TraceMobx } from "../../../../new_fields/util"; +import { GestureUtils } from "../../../../pen-gestures/GestureUtils"; import { CurrentUserUtils } from "../../../../server/authentication/models/current_user_utils"; -import { aggregateBounds, emptyFunction, intersectRect, returnOne, Utils } from "../../../../Utils"; +import { aggregateBounds, intersectRect, returnOne, Utils } from "../../../../Utils"; import { DocServer } from "../../../DocServer"; -import { Docs, DocUtils } from "../../../documents/Documents"; -import { DocumentType } from "../../../documents/DocumentTypes"; +import { Docs } from "../../../documents/Documents"; import { DocumentManager } from "../../../util/DocumentManager"; import { DragManager } from "../../../util/DragManager"; import { HistoryUtil } from "../../../util/History"; @@ -32,15 +34,12 @@ import { FormattedTextBox } from "../../nodes/FormattedTextBox"; import { pageSchema } from "../../nodes/ImageBox"; import PDFMenu from "../../pdf/PDFMenu"; import { CollectionSubView } from "../CollectionSubView"; -import { computePivotLayout, ViewDefResult, computeTimelineLayout, PoolData, ViewDefBounds } from "./CollectionFreeFormLayoutEngines"; +import { computePivotLayout, computeTimelineLayout, PoolData, ViewDefBounds, ViewDefResult } from "./CollectionFreeFormLayoutEngines"; import { CollectionFreeFormRemoteCursors } from "./CollectionFreeFormRemoteCursors"; import "./CollectionFreeFormView.scss"; import MarqueeOptionsMenu from "./MarqueeOptionsMenu"; import { MarqueeView } from "./MarqueeView"; import React = require("react"); -import { computedFn } from "mobx-utils"; -import { TraceMobx } from "../../../../new_fields/util"; -import { GestureUtils } from "../../../../pen-gestures/GestureUtils"; library.add(faEye as any, faTable, faPaintBrush, faExpandArrowsAlt, faCompressArrowsAlt, faCompass, faUpload, faBraille, faChalkboard, faFileUpload); diff --git a/src/client/views/collections/collectionMulticolumn/CollectionMulticolumnView.scss b/src/client/views/collections/collectionMulticolumn/CollectionMulticolumnView.scss index 0c74b8ddb..821c8d804 100644 --- a/src/client/views/collections/collectionMulticolumn/CollectionMulticolumnView.scss +++ b/src/client/views/collections/collectionMulticolumn/CollectionMulticolumnView.scss @@ -1,8 +1,8 @@ .collectionMulticolumnView_contents { display: flex; + overflow: hidden; width: 100%; height: 100%; - overflow: hidden; .document-wrapper { display: flex; diff --git a/src/client/views/collections/collectionMulticolumn/CollectionMultirowView.scss b/src/client/views/collections/collectionMulticolumn/CollectionMultirowView.scss index 64f607680..a7e2c5707 100644 --- a/src/client/views/collections/collectionMulticolumn/CollectionMultirowView.scss +++ b/src/client/views/collections/collectionMulticolumn/CollectionMultirowView.scss @@ -1,8 +1,8 @@ .collectionMultirowView_contents { display: flex; + overflow: hidden; width: 100%; height: 100%; - overflow: hidden; flex-direction: column; .document-wrapper { diff --git a/src/client/views/nodes/DocumentView.tsx b/src/client/views/nodes/DocumentView.tsx index 1199ed7ee..080b01df2 100644 --- a/src/client/views/nodes/DocumentView.tsx +++ b/src/client/views/nodes/DocumentView.tsx @@ -610,13 +610,17 @@ export class DocumentView extends DocComponent(Docu } @undoBatch - @action - freezeNativeDimensions = (): void => { - this.layoutDoc._autoHeight = false; - this.layoutDoc.ignoreAspect = !this.layoutDoc.ignoreAspect; - if (!this.layoutDoc.ignoreAspect && !this.layoutDoc._nativeWidth) { - this.layoutDoc._nativeWidth = this.props.PanelWidth(); - this.layoutDoc._nativeHeight = this.props.PanelHeight(); + public static unfreezeNativeDimensions = action((layoutDoc: Doc): void => { + layoutDoc._nativeWidth = undefined; + layoutDoc._nativeHeight = undefined; + }); + + toggleNativeDimensions = () => { + if (this.Document._nativeWidth || this.Document._nativeHeight) { + DocumentView.unfreezeNativeDimensions(this.layoutDoc); + } + else { + Doc.freezeNativeDimensions(this.layoutDoc, this.props.PanelWidth(), this.props.PanelHeight()); } } @@ -730,7 +734,7 @@ export class DocumentView extends DocComponent(Docu layoutItems.push({ description: `${this.Document._chromeStatus !== "disabled" ? "Hide" : "Show"} Chrome`, event: () => this.Document._chromeStatus = (this.Document._chromeStatus !== "disabled" ? "disabled" : "enabled"), icon: "project-diagram" }); layoutItems.push({ description: `${this.Document._autoHeight ? "Variable Height" : "Auto Height"}`, event: () => this.layoutDoc._autoHeight = !this.layoutDoc._autoHeight, icon: "plus" }); - layoutItems.push({ description: this.Document.ignoreAspect || !this.Document._nativeWidth || !this.Document._nativeHeight ? "Freeze" : "Unfreeze", event: this.freezeNativeDimensions, icon: "snowflake" }); + layoutItems.push({ description: !this.Document._nativeWidth || !this.Document._nativeHeight ? "Freeze" : "Unfreeze", event: this.toggleNativeDimensions, icon: "snowflake" }); layoutItems.push({ description: this.Document.lockedPosition ? "Unlock Position" : "Lock Position", event: this.toggleLockPosition, icon: BoolCast(this.Document.lockedPosition) ? "unlock" : "lock" }); layoutItems.push({ description: this.Document.lockedTransform ? "Unlock Transform" : "Lock Transform", event: this.toggleLockTransform, icon: BoolCast(this.Document.lockedTransform) ? "unlock" : "lock" }); layoutItems.push({ description: "Center View", event: () => this.props.focus(this.props.Document, false), icon: "crosshairs" }); diff --git a/src/new_fields/Doc.ts b/src/new_fields/Doc.ts index 3baab119f..a28c6f58f 100644 --- a/src/new_fields/Doc.ts +++ b/src/new_fields/Doc.ts @@ -14,7 +14,7 @@ import { ComputedField, ScriptField } from "./ScriptField"; import { BoolCast, Cast, FieldValue, NumCast, StrCast, ToConstructor } from "./Types"; import { deleteProperty, getField, getter, makeEditable, makeReadOnly, setter, updateFunction } from "./util"; import { intersectRect } from "../Utils"; -import { UndoManager } from "../client/util/UndoManager"; +import { UndoManager, undoBatch } from "../client/util/UndoManager"; import { computedFn } from "mobx-utils"; import { RichTextField } from "./RichTextField"; import { Script } from "vm"; @@ -178,7 +178,7 @@ export class Doc extends RefField { private [SelfProxy]: any; public [WidthSym] = () => NumCast(this[SelfProxy]._width); public [HeightSym] = () => NumCast(this[SelfProxy]._height); - public get [DataSym]() { return Cast(this[SelfProxy].resolvedDataDoc, Doc, null) || this[SelfProxy]; } + public get [DataSym]() { return Cast(Doc.Layout(this[SelfProxy]).resolvedDataDoc, Doc, null) || this[SelfProxy]; } public get [LayoutSym]() { return this[SelfProxy].__LAYOUT__; } @computed get __LAYOUT__() { const templateLayoutDoc = Cast(Doc.LayoutField(this[SelfProxy]), Doc, null); @@ -842,6 +842,17 @@ export namespace Doc { } } } + + @undoBatch + @action + export function freezeNativeDimensions(layoutDoc: Doc, width: number, height: number): void { + layoutDoc._autoHeight = false; + layoutDoc.ignoreAspect = false; + if (!layoutDoc.ignoreAspect && !layoutDoc._nativeWidth) { + layoutDoc._nativeWidth = NumCast(layoutDoc._width, width); + layoutDoc._nativeHeight = NumCast(layoutDoc._height, height); + } + } } Scripting.addGlobal(function renameAlias(doc: any, n: any) { return StrCast(Doc.GetProto(doc).title).replace(/\([0-9]*\)/, "") + `(${n})`; }); @@ -867,4 +878,4 @@ Scripting.addGlobal(function selectedDocs(container: Doc, excludeCollections: bo return docs.length ? new List(docs) : prevValue; }); Scripting.addGlobal(function setDocFilter(container: Doc, key: string, value: any, modifiers?: string) { Doc.setDocFilter(container, key, value, modifiers); }); -Scripting.addGlobal(function setDocFilterRange(container: Doc, key: string, range: number) { Doc.setDocFilterRange(container, key, range); }); \ No newline at end of file +Scripting.addGlobal(function setDocFilterRange(container: Doc, key: string, range: number[]) { Doc.setDocFilterRange(container, key, range); }); \ No newline at end of file diff --git a/src/server/authentication/models/current_user_utils.ts b/src/server/authentication/models/current_user_utils.ts index efee42f63..ea7a4999c 100644 --- a/src/server/authentication/models/current_user_utils.ts +++ b/src/server/authentication/models/current_user_utils.ts @@ -234,12 +234,12 @@ export class CurrentUserUtils { /// sets up the default list of buttons to be shown in the expanding button menu at the bottom of the Dash window static setupExpandingButtons(doc: Doc) { - const slideTemplate = Docs.Create.StackingDocument( + const slideTemplate = Docs.Create.MultirowDocument( [ - Docs.Create.MulticolumnDocument([], { title: "images", _height: 200, _xMargin: 10, _yMargin: 10 }), + Docs.Create.MulticolumnDocument([], { title: "images", _height: 200 }), Docs.Create.TextDocument("", { title: "contents", _height: 100 }) ], - { _width: 400, _height: 300, title: "slide", _chromeStatus: "disabled", backgroundColor: "lightGray", _autoHeight: true }); + { _width: 400, _height: 300, title: "slideView", _chromeStatus: "disabled", _xMargin: 3, _yMargin: 3, backgroundColor: "lightGray", _autoHeight: true }); slideTemplate.isTemplateDoc = makeTemplate(slideTemplate); const iconDoc = Docs.Create.TextDocument("", { title: "icon", _width: 150, _height: 30, isTemplateDoc: true, onClick: ScriptField.MakeScript("setNativeView(this)") }); -- cgit v1.2.3-70-g09d2 From 51a82fddf79e0c838ed2e506d295edb7d9a9bd7b Mon Sep 17 00:00:00 2001 From: Bob Zeleznik Date: Tue, 11 Feb 2020 01:00:51 -0500 Subject: fixes to presentation display box, and timeline min/max/span requests. --- package-lock.json | 49 +++------ .../views/collections/CollectionTimeView.tsx | 4 +- src/client/views/collections/CollectionView.tsx | 3 +- .../CollectionFreeFormLayoutEngines.tsx | 10 +- src/client/views/nodes/DocumentView.scss | 1 - src/client/views/nodes/DocumentView.tsx | 2 +- src/client/views/nodes/PresBox.scss | 8 +- src/client/views/nodes/PresBox.tsx | 111 +++++++++------------ .../authentication/models/current_user_utils.ts | 4 +- 9 files changed, 80 insertions(+), 112 deletions(-) (limited to 'src/server') diff --git a/package-lock.json b/package-lock.json index c487b11c8..a09df33da 100644 --- a/package-lock.json +++ b/package-lock.json @@ -657,7 +657,7 @@ }, "@types/passport": { "version": "1.0.2", - "resolved": "https://registry.npmjs.org/@types/passport/-/passport-1.0.2.tgz", + "resolved": "https://registry.npmjs.org/@types/passport/-/passport-1.0.0.tgz", "integrity": "sha512-Pf39AYKf8q+YoONym3150cEwfUD66dtwHJWvbeOzKxnA0GZZ/vAXhNWv9vMhKyRQBQZiQyWQnhYBEBlKW6G8wg==", "requires": { "@types/express": "*" @@ -5406,8 +5406,7 @@ }, "ansi-regex": { "version": "2.1.1", - "bundled": true, - "optional": true + "bundled": true }, "aproba": { "version": "1.2.0", @@ -5425,13 +5424,11 @@ }, "balanced-match": { "version": "1.0.0", - "bundled": true, - "optional": true + "bundled": true }, "brace-expansion": { "version": "1.1.11", "bundled": true, - "optional": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -5444,18 +5441,15 @@ }, "code-point-at": { "version": "1.1.0", - "bundled": true, - "optional": true + "bundled": true }, "concat-map": { "version": "0.0.1", - "bundled": true, - "optional": true + "bundled": true }, "console-control-strings": { "version": "1.1.0", - "bundled": true, - "optional": true + "bundled": true }, "core-util-is": { "version": "1.0.2", @@ -5558,8 +5552,7 @@ }, "inherits": { "version": "2.0.4", - "bundled": true, - "optional": true + "bundled": true }, "ini": { "version": "1.3.5", @@ -5569,7 +5562,6 @@ "is-fullwidth-code-point": { "version": "1.0.0", "bundled": true, - "optional": true, "requires": { "number-is-nan": "^1.0.0" } @@ -5582,20 +5574,17 @@ "minimatch": { "version": "3.0.4", "bundled": true, - "optional": true, "requires": { "brace-expansion": "^1.1.7" } }, "minimist": { "version": "0.0.8", - "bundled": true, - "optional": true + "bundled": true }, "minipass": { "version": "2.9.0", "bundled": true, - "optional": true, "requires": { "safe-buffer": "^5.1.2", "yallist": "^3.0.0" @@ -5612,7 +5601,6 @@ "mkdirp": { "version": "0.5.1", "bundled": true, - "optional": true, "requires": { "minimist": "0.0.8" } @@ -5693,8 +5681,7 @@ }, "number-is-nan": { "version": "1.0.1", - "bundled": true, - "optional": true + "bundled": true }, "object-assign": { "version": "4.1.1", @@ -5704,7 +5691,6 @@ "once": { "version": "1.4.0", "bundled": true, - "optional": true, "requires": { "wrappy": "1" } @@ -5780,8 +5766,7 @@ }, "safe-buffer": { "version": "5.1.2", - "bundled": true, - "optional": true + "bundled": true }, "safer-buffer": { "version": "2.1.2", @@ -5811,7 +5796,6 @@ "string-width": { "version": "1.0.2", "bundled": true, - "optional": true, "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0", @@ -5829,7 +5813,6 @@ "strip-ansi": { "version": "3.0.1", "bundled": true, - "optional": true, "requires": { "ansi-regex": "^2.0.0" } @@ -5868,13 +5851,11 @@ }, "wrappy": { "version": "1.0.2", - "bundled": true, - "optional": true + "bundled": true }, "yallist": { "version": "3.1.1", - "bundled": true, - "optional": true + "bundled": true } } }, @@ -13925,7 +13906,7 @@ }, "readable-stream": { "version": "2.3.6", - "resolved": "http://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", "integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==", "requires": { "core-util-is": "~1.0.0", @@ -15529,7 +15510,7 @@ }, "strip-ansi": { "version": "3.0.1", - "resolved": "http://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", "requires": { "ansi-regex": "^2.0.0" @@ -17770,7 +17751,7 @@ }, "wrap-ansi": { "version": "2.1.0", - "resolved": "http://registry.npmjs.org/wrap-ansi/-/wrap-ansi-2.1.0.tgz", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-2.1.0.tgz", "integrity": "sha1-2Pw9KE3QV5T+hJc8rs3Rz4JP3YU=", "requires": { "string-width": "^1.0.1", diff --git a/src/client/views/collections/CollectionTimeView.tsx b/src/client/views/collections/CollectionTimeView.tsx index db176d0bc..de7fa5ed2 100644 --- a/src/client/views/collections/CollectionTimeView.tsx +++ b/src/client/views/collections/CollectionTimeView.tsx @@ -190,6 +190,7 @@ export class CollectionTimeView extends CollectionSubView(doc => doc) { const minReq = NumCast(this.props.Document[this.props.fieldKey + "-timelineMinReq"], NumCast(this.props.Document[this.props.fieldKey + "-timelineMin"], 0)); const maxReq = NumCast(this.props.Document[this.props.fieldKey + "-timelineMaxReq"], NumCast(this.props.Document[this.props.fieldKey + "-timelineMax"], 10)); this.props.Document[this.props.fieldKey + "-timelineMinReq"] = minReq + (maxReq - minReq) * delta / this.props.PanelWidth(); + this.props.Document[this.props.fieldKey + "-timelineSpan"] = undefined; } onMinUp = (e: PointerEvent) => { document.removeEventListener("pointermove", this.onMinMove); @@ -212,6 +213,7 @@ export class CollectionTimeView extends CollectionSubView(doc => doc) { const minReq = NumCast(this.props.Document[this.props.fieldKey + "-timelineMinReq"], NumCast(this.props.Document[this.props.fieldKey + "-timelineMin"], 0)); const maxReq = NumCast(this.props.Document[this.props.fieldKey + "-timelineMaxReq"], NumCast(this.props.Document[this.props.fieldKey + "-timelineMax"], 10)); this.props.Document[this.props.fieldKey + "-timelineMaxReq"] = maxReq + (maxReq - minReq) * delta / this.props.PanelWidth(); + this.props.Document[this.props.fieldKey + "-timelineSpan"] = undefined; } onMaxUp = (e: PointerEvent) => { document.removeEventListener("pointermove", this.onMaxMove); @@ -331,7 +333,7 @@ export class CollectionTimeView extends CollectionSubView(doc => doc) {
- - + const mode = NumCast(this.props.Document._viewType, CollectionViewType.Invalid); + this.initializeScaleViews(this.childDocs, mode); + return
+
+ + + + +
+
+ {mode !== CollectionViewType.Invalid ? + + : (null) + }
- :
-
- - - - - {this.props.Document.inOverlay ? (null) : -
- -
} -
); +
; } } \ No newline at end of file diff --git a/src/server/authentication/models/current_user_utils.ts b/src/server/authentication/models/current_user_utils.ts index ea7a4999c..3a2a0f513 100644 --- a/src/server/authentication/models/current_user_utils.ts +++ b/src/server/authentication/models/current_user_utils.ts @@ -48,7 +48,7 @@ export class CurrentUserUtils { // setup the "creator" buttons for the sidebar-- eg. the default set of draggable document creation tools static setupCreatorButtons(doc: Doc, buttons?: string[]) { const notes = CurrentUserUtils.setupNoteTypes(doc); - const emptyPresentation = Docs.Create.PresDocument(new List(), { title: "Presentation", _viewType: CollectionViewType.Stacking, showTitle: "title", boxShadow: "0 0" }); + const emptyPresentation = Docs.Create.PresDocument(new List(), { title: "Presentation", _viewType: CollectionViewType.Stacking, _chromeStatus: "enabled", showTitle: "title", boxShadow: "0 0" }); const emptyCollection = Docs.Create.FreeformDocument([], { _nativeWidth: undefined, _nativeHeight: undefined, _LODdisable: true, _width: 150, _height: 100, title: "freeform" }); doc.noteTypes = Docs.Create.TreeDocument(notes, { title: "Note Types", _height: 75 }); doc.activePen = doc; @@ -270,7 +270,7 @@ export class CurrentUserUtils { // the initial presentation Doc to use static setupDefaultPresentation(doc: Doc) { - doc.curPresentation = Docs.Create.PresDocument(new List(), { title: "Presentation", _viewType: CollectionViewType.Stacking, showTitle: "title", boxShadow: "0 0" }); + doc.curPresentation = Docs.Create.PresDocument(new List(), { title: "Presentation", _viewType: CollectionViewType.Stacking, _chromeStatus: "enabled", showTitle: "title", boxShadow: "0 0" }); } static setupMobileUploads(doc: Doc) { -- cgit v1.2.3-70-g09d2 From 4af6916f1f68b879e11e38b4d2a3f9a0708ac979 Mon Sep 17 00:00:00 2001 From: Sam Wilkins Date: Tue, 11 Feb 2020 06:21:39 -0500 Subject: factored out image resizing, fixed back button, importer script, tooltips on range sliders --- src/client/documents/Documents.ts | 21 +- src/client/util/SettingsManager.scss | 2 +- .../views/collections/CollectionTimeView.scss | 17 +- .../views/collections/CollectionTimeView.tsx | 12 +- src/client/views/nodes/ImageBox.tsx | 2 +- src/client/views/nodes/SliderBox-components.tsx | 10 +- src/client/views/nodes/SliderBox.tsx | 27 +- src/scraping/buxton/final/BuxtonImporter.ts | 180 ++++---- src/scraping/buxton/final/json/buxton.json | 490 ++++++++++----------- src/server/DashUploadUtils.ts | 108 +++-- 10 files changed, 447 insertions(+), 422 deletions(-) (limited to 'src/server') diff --git a/src/client/documents/Documents.ts b/src/client/documents/Documents.ts index 027d7129e..49d1820f5 100644 --- a/src/client/documents/Documents.ts +++ b/src/client/documents/Documents.ts @@ -355,13 +355,18 @@ export namespace Docs { _LODdisable: true }); Networking.FetchFromServer("/buxton").then(response => { - const parentProto = Doc.GetProto(parent); - parentProto.data = new List(); const devices = JSON.parse(response); if (!Array.isArray(devices)) { - alert("Improper Buxton import formatting!"); + if ("error" in devices) { + loading.title = devices.error; + } else { + console.log(devices); + alert("The importer returned an unexpected import format. Check the console."); + } return; } + const parentProto = Doc.GetProto(parent); + parentProto.data = new List(); devices.forEach(device => { const { __images } = device; delete device.__images; @@ -370,9 +375,9 @@ export namespace Docs { const constructed = __images.map(relative => Utils.prepend(relative)); const deviceImages = constructed.map((url, i) => ImageDocument(url, { title: `image${i}.${extname(url)}` })); const doc = StackingDocument(deviceImages, { title: device.title, _LODdisable: true }); - const protoDoc = Doc.GetProto(doc); - protoDoc.hero = new ImageField(constructed[0]); - Docs.Get.DocumentHierarchyFromJson(device, undefined, protoDoc); + const deviceProto = Doc.GetProto(doc); + deviceProto.hero = new ImageField(constructed[0]); + Docs.Get.DocumentHierarchyFromJson(device, undefined, deviceProto); Doc.AddDocToList(parentProto, "data", doc); } }); @@ -507,10 +512,6 @@ export namespace Docs { return doc; } - export function IconDocument(icon: string, options: DocumentOptions = {}) { - return InstanceFromProto(Prototypes.get(DocumentType.ICON), new IconField(icon), options); - } - export function PdfDocument(url: string, options: DocumentOptions = {}) { return InstanceFromProto(Prototypes.get(DocumentType.PDF), new PdfField(new URL(url)), options); } diff --git a/src/client/util/SettingsManager.scss b/src/client/util/SettingsManager.scss index 7a0fb0741..6513cb223 100644 --- a/src/client/util/SettingsManager.scss +++ b/src/client/util/SettingsManager.scss @@ -1,6 +1,6 @@ @import "../views/globalCssVariables"; -.dialogue-box { +.settings-interface { background-color: whitesmoke !important; color: grey; width: 450px; diff --git a/src/client/views/collections/CollectionTimeView.scss b/src/client/views/collections/CollectionTimeView.scss index 02ef4e2d2..2dffb3ea0 100644 --- a/src/client/views/collections/CollectionTimeView.scss +++ b/src/client/views/collections/CollectionTimeView.scss @@ -1,21 +1,26 @@ -.collectionTimeView, .collectionTimeView-pivot { +.collectionTimeView, +.collectionTimeView-pivot { display: flex; flex-direction: row; position: absolute; height: 100%; width: 100%; overflow: hidden; + .collectionTimeView-backBtn { background: green; display: inline; margin-right: 20px; } + .collectionFreeform-customText { text-align: left; } + .collectionFreeform-customDiv { position: absolute; } + .collectionTimeView-thumb { position: absolute; width: 30px; @@ -28,14 +33,17 @@ border-radius: 9px; opacity: 0.25; } + .collectionTimeView-thumb-min { - margin-left:25%; + margin-left: 25%; } + .collectionTimeView-thumb-max { - margin-left:75%; + margin-left: 75%; } + .collectionTimeView-thumb-mid { - margin-left:50%; + margin-left: 50%; } .collectionTimeView-flyout { @@ -118,6 +126,7 @@ left: -10px; } } + .collectionTimeView-pivot { .collectionFreeform-customText { text-align: center; diff --git a/src/client/views/collections/CollectionTimeView.tsx b/src/client/views/collections/CollectionTimeView.tsx index db176d0bc..808144c18 100644 --- a/src/client/views/collections/CollectionTimeView.tsx +++ b/src/client/views/collections/CollectionTimeView.tsx @@ -46,7 +46,7 @@ export class CollectionTimeView extends CollectionSubView(doc => doc) { this.props.Document._fitToBox = true; } if (!this.props.Document.onViewDefClick) { - this.props.Document.onViewDefDivClick = ScriptField.MakeScript("pivotColumnClick(this,payload)", { payload: "any" }) + this.props.Document.onViewDefDivClick = ScriptField.MakeScript("pivotColumnClick(this,payload)", { payload: "any" }); } } @@ -164,7 +164,7 @@ export class CollectionTimeView extends CollectionSubView(doc => doc) { typeof (pair.layout[fieldKey]) === "string").map(fieldKey => keySet.add(fieldKey))); Array.from(keySet).map(fieldKey => docItems.push({ description: ":" + fieldKey, event: () => this.props.Document._pivotField = fieldKey, icon: "compress-arrows-alt" })); - docItems.push({ description: ":(null)", event: () => this.props.Document._pivotField = undefined, icon: "compress-arrows-alt" }) + docItems.push({ description: ":(null)", event: () => this.props.Document._pivotField = undefined, icon: "compress-arrows-alt" }); ContextMenu.Instance.addItem({ description: "Pivot Fields ...", subitems: docItems, icon: "eye" }); const pt = this.props.ScreenToLocalTransform().inverse().transformPoint(x, y); ContextMenu.Instance.displayMenu(x, y, ":"); @@ -282,9 +282,9 @@ export class CollectionTimeView extends CollectionSubView(doc => doc) { const layoutItems: ContextMenuProps[] = []; const doc = this.props.Document; - layoutItems.push({ description: "Force Timeline", event: () => { doc._forceRenderEngine = "timeline" }, icon: "compress-arrows-alt" }); - layoutItems.push({ description: "Force Pivot", event: () => { doc._forceRenderEngine = "pivot" }, icon: "compress-arrows-alt" }); - layoutItems.push({ description: "Auto Time/Pivot layout", event: () => { doc._forceRenderEngine = undefined }, icon: "compress-arrows-alt" }); + layoutItems.push({ description: "Force Timeline", event: () => { doc._forceRenderEngine = "timeline"; }, icon: "compress-arrows-alt" }); + layoutItems.push({ description: "Force Pivot", event: () => { doc._forceRenderEngine = "pivot"; }, icon: "compress-arrows-alt" }); + layoutItems.push({ description: "Auto Time/Pivot layout", event: () => { doc._forceRenderEngine = undefined; }, icon: "compress-arrows-alt" }); layoutItems.push({ description: "Sync with presentation", event: () => CollectionTimeView.SyncTimelineToPresentation(doc), icon: "compress-arrows-alt" }); ContextMenu.Instance.addItem({ description: "Pivot/Time Options ...", subitems: layoutItems, icon: "eye" }); @@ -331,7 +331,7 @@ export class CollectionTimeView extends CollectionSubView(doc => doc) {
-
; } diff --git a/src/new_fields/documentSchemas.ts b/src/new_fields/documentSchemas.ts index 1707524cb..aac6d4e3e 100644 --- a/src/new_fields/documentSchemas.ts +++ b/src/new_fields/documentSchemas.ts @@ -10,22 +10,24 @@ export const documentSchema = createSchema({ title: "string", // document title (can be on either data document or layout) dropAction: "string", // override specifying what should happen when this document is dropped (can be "alias" or "copy") childDropAction: "string", // specify the override for what should happen when the child of a collection is dragged from it and dropped (can be "alias" or "copy") - _nativeWidth: "number", // native width of document which determines how much document contents are scaled when the document's width is set - _nativeHeight: "number", // " - _width: "number", // width of document in its container's coordinate system - _height: "number", // " + _nativeWidth: "number", // native width of document which determines how much document contents are scaled when the document's width is set + _nativeHeight: "number", // " + _width: "number", // width of document in its container's coordinate system + _height: "number", // " _freeformLayoutEngine: "string",// the string ID for the layout engine to use to layout freeform view documents - _LODdisable: "boolean", // whether to disbale LOD switching for CollectionFreeFormViews + _LODdisable: "boolean", // whether to disbale LOD switching for CollectionFreeFormViews _pivotField: "string", // specifies which field should be used as the timeline/pivot axis + _replacedChrome: "string", // what the default chrome is replaced with. Currently only supports the value of 'replaced' for PresBox's. + _chromeStatus: "string", // determines the state of the collection chrome. values allowed are 'replaced', 'enabled', 'disabled', 'collapsed' color: "string", // foreground color of document backgroundColor: "string", // background color of document opacity: "number", // opacity of document - creationDate: DateField, // when the document was created + creationDate: DateField, // when the document was created links: listSpec(Doc), // computed (readonly) list of links associated with this document removeDropProperties: listSpec("string"), // properties that should be removed from the alias/copy/etc of this document when it is dropped onClick: ScriptField, // script to run when document is clicked (can be overriden by an onClick prop) - onPointerDown: ScriptField, // script to run when document is clicked (can be overriden by an onClick prop) - onPointerUp: ScriptField, // script to run when document is clicked (can be overriden by an onClick prop) + onPointerDown: ScriptField, // script to run when document is clicked (can be overriden by an onClick prop) + onPointerUp: ScriptField, // script to run when document is clicked (can be overriden by an onClick prop) onDragStart: ScriptField, // script to run when document is dragged (without being selected). the script should return the Doc to be dropped. dragFactory: Doc, // the document that serves as the "template" for the onDragStart script. ie, to drag out copies of the dragFactory document. ignoreAspect: "boolean", // whether aspect ratio should be ignored when laying out or manipulating the document @@ -36,7 +38,7 @@ export const documentSchema = createSchema({ treeViewOpen: "boolean", // flag denoting whether the documents sub-tree (contents) is visible or hidden treeViewExpandedView: "string", // name of field whose contents are being displayed as the document's subtree preventTreeViewOpen: "boolean", // ignores the treeViewOpen flag (for allowing a view to not be slaved to other views of the document) - currentTimecode: "number", // current play back time of a temporal document (video / audio) + currentTimecode: "number", // current play back time of a temporal document (video / audio) maximizeLocation: "string", // flag for where to place content when following a click interaction (e.g., onRight, inPlace, inTab) lockedPosition: "boolean", // whether the document can be moved (dragged) lockedTransform: "boolean", // whether the document can be panned/zoomed diff --git a/src/server/authentication/models/current_user_utils.ts b/src/server/authentication/models/current_user_utils.ts index 3a2a0f513..0185017ec 100644 --- a/src/server/authentication/models/current_user_utils.ts +++ b/src/server/authentication/models/current_user_utils.ts @@ -48,7 +48,7 @@ export class CurrentUserUtils { // setup the "creator" buttons for the sidebar-- eg. the default set of draggable document creation tools static setupCreatorButtons(doc: Doc, buttons?: string[]) { const notes = CurrentUserUtils.setupNoteTypes(doc); - const emptyPresentation = Docs.Create.PresDocument(new List(), { title: "Presentation", _viewType: CollectionViewType.Stacking, _chromeStatus: "enabled", showTitle: "title", boxShadow: "0 0" }); + const emptyPresentation = Docs.Create.PresDocument(new List(), { title: "Presentation", _viewType: CollectionViewType.Stacking, _chromeStatus: "replaced", showTitle: "title", boxShadow: "0 0" }); const emptyCollection = Docs.Create.FreeformDocument([], { _nativeWidth: undefined, _nativeHeight: undefined, _LODdisable: true, _width: 150, _height: 100, title: "freeform" }); doc.noteTypes = Docs.Create.TreeDocument(notes, { title: "Note Types", _height: 75 }); doc.activePen = doc; @@ -270,7 +270,7 @@ export class CurrentUserUtils { // the initial presentation Doc to use static setupDefaultPresentation(doc: Doc) { - doc.curPresentation = Docs.Create.PresDocument(new List(), { title: "Presentation", _viewType: CollectionViewType.Stacking, _chromeStatus: "enabled", showTitle: "title", boxShadow: "0 0" }); + doc.curPresentation = Docs.Create.PresDocument(new List(), { title: "Presentation", _viewType: CollectionViewType.Stacking, _chromeStatus: "replaced", showTitle: "title", boxShadow: "0 0" }); } static setupMobileUploads(doc: Doc) { -- cgit v1.2.3-70-g09d2 From dd6937f8eaeb9abd45061a572fcb75586b5f5ef7 Mon Sep 17 00:00:00 2001 From: Sam Wilkins Date: Tue, 11 Feb 2020 12:11:59 -0500 Subject: google doc fixes --- src/new_fields/RichTextUtils.ts | 9 +++------ src/scraping/buxton/final/BuxtonImporter.ts | 2 +- src/server/ApiManagers/GooglePhotosManager.ts | 11 +++++------ 3 files changed, 9 insertions(+), 13 deletions(-) (limited to 'src/server') diff --git a/src/new_fields/RichTextUtils.ts b/src/new_fields/RichTextUtils.ts index c50f8cc48..2fedac53e 100644 --- a/src/new_fields/RichTextUtils.ts +++ b/src/new_fields/RichTextUtils.ts @@ -123,9 +123,7 @@ export namespace RichTextUtils { const objects = Object.keys(inlineObjects).map(objectId => inlineObjects[objectId]); const mediaItems: MediaItem[] = objects.map(object => { const embeddedObject = object.inlineObjectProperties!.embeddedObject!; - const baseUrl = embeddedObject.imageProperties!.contentUri!; - const filename = `upload_${Utils.GenerateGuid()}.png`; - return { baseUrl, filename }; + return { baseUrl: embeddedObject.imageProperties!.contentUri! }; }); const uploads = await Networking.PostToServer("/googlePhotosMediaDownload", { mediaItems }); @@ -136,11 +134,11 @@ export namespace RichTextUtils { for (let i = 0; i < objects.length; i++) { const object = objects[i]; - const { fileNames } = uploads[i]; + const { clientAccessPath } = uploads[i]; const embeddedObject = object.inlineObjectProperties!.embeddedObject!; const size = embeddedObject.size!; const width = size.width!.magnitude!; - const url = Utils.fileUrl(fileNames.clean); + const url = Utils.prepend(clientAccessPath); inlineObjectMap.set(object.objectId!, { title: embeddedObject.title || `Imported Image from ${document.title}`, @@ -156,7 +154,6 @@ export namespace RichTextUtils { interface MediaItem { baseUrl: string; - filename: string; } export const Import = async (documentId: GoogleApiClientUtils.Docs.DocumentId, textNote: Doc): Promise> => { diff --git a/src/scraping/buxton/final/BuxtonImporter.ts b/src/scraping/buxton/final/BuxtonImporter.ts index 66d1e761a..6e3c66690 100644 --- a/src/scraping/buxton/final/BuxtonImporter.ts +++ b/src/scraping/buxton/final/BuxtonImporter.ts @@ -285,7 +285,7 @@ async function writeImages(zip: any): Promise { continue; } - const ext = `.${type}`; + const ext = `.${type}`.toLowerCase(); const generatedFileName = `upload_${Utils.GenerateGuid()}${ext}`; await DashUploadUtils.outputResizedImages(streamImage, imageDir, generatedFileName, ext); diff --git a/src/server/ApiManagers/GooglePhotosManager.ts b/src/server/ApiManagers/GooglePhotosManager.ts index 1727cc5a6..157f6bdca 100644 --- a/src/server/ApiManagers/GooglePhotosManager.ts +++ b/src/server/ApiManagers/GooglePhotosManager.ts @@ -21,7 +21,6 @@ interface GooglePhotosUploadFailure { } interface MediaItem { baseUrl: string; - filename: string; } interface NewMediaItem { description: string; @@ -83,12 +82,12 @@ export default class GooglePhotosManager extends ApiManager { method: Method.POST, subscription: "/googlePhotosMediaDownload", secureHandler: async ({ req, res }) => { - const contents: { mediaItems: MediaItem[] } = req.body; + const { mediaItems } = req.body as { mediaItems: MediaItem[] }; let failed = 0; - if (contents) { + if (mediaItems) { const completed: Opt[] = []; - for (const item of contents.mediaItems) { - const results = await DashUploadUtils.InspectImage(item.baseUrl); + for (const { baseUrl } of mediaItems) { + const results = await DashUploadUtils.InspectImage(baseUrl); if (results instanceof Error) { failed++; continue; @@ -96,7 +95,7 @@ export default class GooglePhotosManager extends ApiManager { const { contentSize, ...attributes } = results; const found: Opt = await Database.Auxiliary.QueryUploadHistory(contentSize); if (!found) { - const upload = await DashUploadUtils.UploadInspectedImage({ contentSize, ...attributes }, item.filename, prefix).catch(error => _error(res, downloadError, error)); + const upload = await DashUploadUtils.UploadInspectedImage({ contentSize, ...attributes }, undefined, prefix).catch(error => _error(res, downloadError, error)); if (upload) { completed.push(upload); await Database.Auxiliary.LogUpload(upload); -- cgit v1.2.3-70-g09d2 From ed947b320de772d63e7b462e78910db11c0a8fd3 Mon Sep 17 00:00:00 2001 From: Sam Wilkins Date: Tue, 11 Feb 2020 12:57:34 -0500 Subject: goole docs fixed except for uploading embedded images --- src/client/apis/google_docs/GoogleApiClientUtils.ts | 2 +- src/client/util/RichTextSchema.tsx | 2 +- src/new_fields/RichTextUtils.ts | 6 ++++-- src/server/ApiManagers/GooglePhotosManager.ts | 2 +- src/server/DashUploadUtils.ts | 4 ++-- 5 files changed, 9 insertions(+), 7 deletions(-) (limited to 'src/server') diff --git a/src/client/apis/google_docs/GoogleApiClientUtils.ts b/src/client/apis/google_docs/GoogleApiClientUtils.ts index d2a79f189..0d44ee8e0 100644 --- a/src/client/apis/google_docs/GoogleApiClientUtils.ts +++ b/src/client/apis/google_docs/GoogleApiClientUtils.ts @@ -248,7 +248,7 @@ export namespace GoogleApiClientUtils { return undefined; } requests.push(...options.content.requests); - const replies: any = await update({ documentId: documentId, requests }); + const replies: any = await update({ documentId, requests }); if ("errors" in replies) { console.log("Write operation failed:"); console.log(replies.errors.map((error: any) => error.message)); diff --git a/src/client/util/RichTextSchema.tsx b/src/client/util/RichTextSchema.tsx index 269a045a0..f12b3632c 100644 --- a/src/client/util/RichTextSchema.tsx +++ b/src/client/util/RichTextSchema.tsx @@ -883,7 +883,7 @@ export class DashFieldView { e.stopPropagation(); if ((e.key === "a" && e.ctrlKey) || (e.key === "a" && e.metaKey)) { if (window.getSelection) { - var range = document.createRange(); + const range = document.createRange(); range.selectNodeContents(self._fieldSpan); window.getSelection()!.removeAllRanges(); window.getSelection()!.addRange(range); diff --git a/src/new_fields/RichTextUtils.ts b/src/new_fields/RichTextUtils.ts index 2fedac53e..016bcc4ca 100644 --- a/src/new_fields/RichTextUtils.ts +++ b/src/new_fields/RichTextUtils.ts @@ -1,5 +1,5 @@ import { EditorState, Transaction, TextSelection } from "prosemirror-state"; -import { Node, Fragment, Mark, MarkType } from "prosemirror-model"; +import { Node, Fragment, Mark } from "prosemirror-model"; import { RichTextField } from "./RichTextField"; import { docs_v1 } from "googleapis"; import { GoogleApiClientUtils } from "../client/apis/google_docs/GoogleApiClientUtils"; @@ -17,6 +17,7 @@ import { Id } from "./FieldSymbols"; import { DocumentView } from "../client/views/nodes/DocumentView"; import { AssertionError } from "assert"; import { Networking } from "../client/Network"; +import { extname } from "path"; export namespace RichTextUtils { @@ -138,7 +139,8 @@ export namespace RichTextUtils { const embeddedObject = object.inlineObjectProperties!.embeddedObject!; const size = embeddedObject.size!; const width = size.width!.magnitude!; - const url = Utils.prepend(clientAccessPath); + const ext = extname(clientAccessPath); + const url = Utils.prepend(clientAccessPath.replace(ext, "_m" + ext)); inlineObjectMap.set(object.objectId!, { title: embeddedObject.title || `Imported Image from ${document.title}`, diff --git a/src/server/ApiManagers/GooglePhotosManager.ts b/src/server/ApiManagers/GooglePhotosManager.ts index 157f6bdca..3236d1ee2 100644 --- a/src/server/ApiManagers/GooglePhotosManager.ts +++ b/src/server/ApiManagers/GooglePhotosManager.ts @@ -95,7 +95,7 @@ export default class GooglePhotosManager extends ApiManager { const { contentSize, ...attributes } = results; const found: Opt = await Database.Auxiliary.QueryUploadHistory(contentSize); if (!found) { - const upload = await DashUploadUtils.UploadInspectedImage({ contentSize, ...attributes }, undefined, prefix).catch(error => _error(res, downloadError, error)); + const upload = await DashUploadUtils.UploadInspectedImage({ contentSize, ...attributes }, undefined, prefix, false).catch(error => _error(res, downloadError, error)); if (upload) { completed.push(upload); await Database.Auxiliary.LogUpload(upload); diff --git a/src/server/DashUploadUtils.ts b/src/server/DashUploadUtils.ts index 4e6bbaa3f..83a0064e8 100644 --- a/src/server/DashUploadUtils.ts +++ b/src/server/DashUploadUtils.ts @@ -223,7 +223,7 @@ export namespace DashUploadUtils { }); } - export const UploadInspectedImage = async (metadata: InspectionResults, filename?: string, prefix = ""): Promise => { + export const UploadInspectedImage = async (metadata: InspectionResults, filename?: string, prefix = "", cleanUp = true): Promise => { const { requestable, source, ...remaining } = metadata; const extension = `.${remaining.contentType.split("/")[1].toLowerCase()}`; const resolved = filename || `${prefix}upload_${Utils.GenerateGuid()}${extension}`; @@ -237,7 +237,7 @@ export namespace DashUploadUtils { for (const suffix of Object.keys(writtenFiles)) { information.serverAccessPaths[suffix] = serverPathToFile(Directory.images, writtenFiles[suffix]); } - if (isLocal().test(source)) { + if (isLocal().test(source) && cleanUp) { unlinkSync(source); } return information; -- cgit v1.2.3-70-g09d2 From be02a5529f472507512a127cd8de5cde300eff88 Mon Sep 17 00:00:00 2001 From: bob Date: Tue, 11 Feb 2020 14:19:56 -0500 Subject: added ability to pass a Layout as a prop. changed presentations to use layout props. fixed creating a template for just an empty collection representing one field. --- src/client/util/DropConverter.ts | 7 +- src/client/views/DocComponent.tsx | 5 +- .../views/collections/CollectionStackingView.tsx | 20 +++-- .../CollectionFreeFormLayoutEngines.tsx | 9 ++- .../views/nodes/ContentFittingDocumentView.tsx | 6 +- src/client/views/nodes/DocumentContentsView.tsx | 4 +- src/client/views/nodes/DocumentView.tsx | 3 +- src/client/views/nodes/FieldView.tsx | 1 + src/client/views/nodes/PresBox.tsx | 28 +------ .../views/presentationview/PresElementBox.tsx | 90 +++++++++++----------- src/new_fields/Doc.ts | 7 +- .../authentication/models/current_user_utils.ts | 5 +- 12 files changed, 94 insertions(+), 91 deletions(-) (limited to 'src/server') diff --git a/src/client/util/DropConverter.ts b/src/client/util/DropConverter.ts index d0f1d86cb..3c7caa60b 100644 --- a/src/client/util/DropConverter.ts +++ b/src/client/util/DropConverter.ts @@ -8,7 +8,7 @@ import { ScriptField, ComputedField } from "../../new_fields/ScriptField"; import { RichTextField } from "../../new_fields/RichTextField"; import { ImageField } from "../../new_fields/URLField"; -export function makeTemplate(doc: Doc): boolean { +export function makeTemplate(doc: Doc, first: boolean = true): boolean { const layoutDoc = doc.layout instanceof Doc && doc.layout.isTemplateForField ? doc.layout : doc; const layout = StrCast(layoutDoc.layout).match(/fieldKey={'[^']*'}/)![0]; const fieldKey = layout.replace("fieldKey={'", "").replace(/'}$/, ""); @@ -18,9 +18,12 @@ export function makeTemplate(doc: Doc): boolean { if (!StrCast(d.title).startsWith("-")) { any = Doc.MakeMetadataFieldTemplate(d, Doc.GetProto(layoutDoc)) || any; } else if (d.type === DocumentType.COL || d.data instanceof RichTextField) { - any = makeTemplate(d) || any; + any = makeTemplate(d, false) || any; } }); + if (!docs.length && first) { + any = Doc.MakeMetadataFieldTemplate(doc, Doc.GetProto(layoutDoc)) || any; + } if (layoutDoc[fieldKey] instanceof RichTextField || layoutDoc[fieldKey] instanceof ImageField) { if (!StrCast(layoutDoc.title).startsWith("-")) { any = Doc.MakeMetadataFieldTemplate(layoutDoc, Doc.GetProto(layoutDoc)); diff --git a/src/client/views/DocComponent.tsx b/src/client/views/DocComponent.tsx index ce48e1215..0bf944f22 100644 --- a/src/client/views/DocComponent.tsx +++ b/src/client/views/DocComponent.tsx @@ -1,4 +1,4 @@ -import { Doc } from '../../new_fields/Doc'; +import { Doc, Opt } from '../../new_fields/Doc'; import { Touchable } from './Touchable'; import { computed, action, observable } from 'mobx'; import { Cast } from '../../new_fields/Types'; @@ -11,12 +11,13 @@ import { PositionDocument } from '../../new_fields/documentSchemas'; /// DocComponent returns a generic React base class used by views that don't have any data extensions (e.g.,CollectionFreeFormDocumentView, DocumentView, ButtonBox) interface DocComponentProps { Document: Doc; + LayoutDoc?: () => Opt; } export function DocComponent

(schemaCtor: (doc: Doc) => T) { class Component extends Touchable

{ //TODO This might be pretty inefficient if doc isn't observed, because computed doesn't cache then @computed get Document(): T { return schemaCtor(this.props.Document); } - @computed get layoutDoc() { return PositionDocument(Doc.Layout(this.props.Document)); } + @computed get layoutDoc() { return PositionDocument(Doc.Layout(this.props.Document, this.props.LayoutDoc?.())); } } return Component; } diff --git a/src/client/views/collections/CollectionStackingView.tsx b/src/client/views/collections/CollectionStackingView.tsx index 21c34d047..d21ae32bc 100644 --- a/src/client/views/collections/CollectionStackingView.tsx +++ b/src/client/views/collections/CollectionStackingView.tsx @@ -55,7 +55,7 @@ export class CollectionStackingView extends CollectionSubView(doc => doc) { this._docXfs.length = 0; return docs.map((d, i) => { const height = () => this.getDocHeight(d); - const width = () => Math.min(d._nativeWidth && !d.ignoreAspect && !this.props.Document.fillColumn ? d[WidthSym]() : Number.MAX_VALUE, this.columnWidth / this.numGroupColumns); + const width = () => this.getDocWidth(d); const dref = React.createRef(); const dxf = () => this.getDocTransform(d, dref.current!); this._docXfs.push({ dxf: dxf, width: width, height: height }); @@ -154,11 +154,12 @@ export class CollectionStackingView extends CollectionSubView(doc => doc) { @computed get onClickHandler() { return ScriptCast(this.Document.onChildClick); } getDisplayDoc(doc: Doc, dataDoc: Doc | undefined, dxf: () => Transform, width: () => number) { - const layoutDoc = Doc.Layout(doc); + const layoutDoc = Doc.Layout(doc, this.props.childLayoutTemplate?.()); const height = () => this.getDocHeight(doc); return doc) { pinToPres={this.props.pinToPres}> ; } + + getDocWidth(d?: Doc) { + if (!d) return 0; + const layoutDoc = Doc.Layout(d, this.props.childLayoutTemplate?.()); + const nw = NumCast(layoutDoc._nativeWidth); + return Math.min(nw && !d.ignoreAspect && !this.props.Document.fillColumn ? d[WidthSym]() : Number.MAX_VALUE, this.columnWidth / this.numGroupColumns); + } getDocHeight(d?: Doc) { if (!d) return 0; - const layoutDoc = Doc.Layout(d); + let layoutDoc = Doc.Layout(d, this.props.childLayoutTemplate?.()); const nw = NumCast(layoutDoc._nativeWidth); const nh = NumCast(layoutDoc._nativeHeight); let wid = this.columnWidth / (this.isStackingView ? this.numGroupColumns : 1); if (!layoutDoc.ignoreAspect && !layoutDoc._fitWidth && nw && nh) { const aspect = nw && nh ? nh / nw : 1; - if (!(d._nativeWidth && !layoutDoc.ignoreAspect && this.props.Document.fillColumn)) wid = Math.min(layoutDoc[WidthSym](), wid); + if (!(!layoutDoc.ignoreAspect && this.props.Document.fillColumn)) wid = Math.min(layoutDoc[WidthSym](), wid); return wid * aspect; } - return layoutDoc._fitWidth ? !layoutDoc._nativeHeight ? this.props.PanelHeight() - 2 * this.yMargin : - Math.min(wid * NumCast(layoutDoc.scrollHeight, NumCast(layoutDoc._nativeHeight)) / NumCast(layoutDoc._nativeWidth, 1), this.props.PanelHeight() - 2 * this.yMargin) : layoutDoc[HeightSym](); + return layoutDoc._fitWidth ? !nh ? this.props.PanelHeight() - 2 * this.yMargin : + Math.min(wid * NumCast(layoutDoc.scrollHeight, nh) / (nw || 1), this.props.PanelHeight() - 2 * this.yMargin) : layoutDoc[HeightSym](); } columnDividerDown = (e: React.PointerEvent) => { diff --git a/src/client/views/collections/collectionFreeForm/CollectionFreeFormLayoutEngines.tsx b/src/client/views/collections/collectionFreeForm/CollectionFreeFormLayoutEngines.tsx index b86cbbdbd..050ca8347 100644 --- a/src/client/views/collections/collectionFreeForm/CollectionFreeFormLayoutEngines.tsx +++ b/src/client/views/collections/collectionFreeForm/CollectionFreeFormLayoutEngines.tsx @@ -43,6 +43,9 @@ export interface ViewDefResult { bounds?: ViewDefBounds; } function toLabel(target: FieldResult) { + if (typeof target === "number" || Number(target)) { + return Number(target).toFixed(2).toString(); + } if (target instanceof ObjectField || target instanceof RefField) { return target[ToString](); } @@ -254,10 +257,10 @@ export function computeTimelineLayout( let prevKey = Math.floor(minTime); if (sortedKeys.length && scaling * (sortedKeys[0] - prevKey) > 25) { - groupNames.push({ type: "text", text: prevKey.toString(), x: x, y: 0, height: fontHeight, fontSize, payload: undefined }); + groupNames.push({ type: "text", text: toLabel(prevKey), x: x, y: 0, height: fontHeight, fontSize, payload: undefined }); } if (!sortedKeys.length && curTime !== undefined) { - groupNames.push({ type: "text", text: curTime.toString(), x: (curTime - minTime) * scaling, zIndex: 1000, color: "orange", y: 0, height: fontHeight, fontSize, payload: undefined }); + groupNames.push({ type: "text", text: toLabel(curTime), x: (curTime - minTime) * scaling, zIndex: 1000, color: "orange", y: 0, height: fontHeight, fontSize, payload: undefined }); } const pivotAxisWidth = NumCast(pivotDoc.pivotTimeWidth, panelDim[1] / 2.5); @@ -265,7 +268,7 @@ export function computeTimelineLayout( let zind = 0; sortedKeys.forEach(key => { if (curTime !== undefined && curTime > prevKey && curTime <= key) { - groupNames.push({ type: "text", text: curTime.toString(), x: (curTime - minTime) * scaling, y: 0, zIndex: 1000, color: "orange", height: fontHeight, fontSize, payload: key }); + groupNames.push({ type: "text", text: toLabel(curTime), x: (curTime - minTime) * scaling, y: 0, zIndex: 1000, color: "orange", height: fontHeight, fontSize, payload: key }); } const keyDocs = pivotDateGroups.get(key)!; x += scaling * (key - prevKey); diff --git a/src/client/views/nodes/ContentFittingDocumentView.tsx b/src/client/views/nodes/ContentFittingDocumentView.tsx index bd1b6166f..671f5b96e 100644 --- a/src/client/views/nodes/ContentFittingDocumentView.tsx +++ b/src/client/views/nodes/ContentFittingDocumentView.tsx @@ -2,7 +2,7 @@ import React = require("react"); import { action, computed } from "mobx"; import { observer } from "mobx-react"; import "react-table/react-table.css"; -import { Doc } from "../../../new_fields/Doc"; +import { Doc, Opt } from "../../../new_fields/Doc"; import { ComputedField, ScriptField } from "../../../new_fields/ScriptField"; import { NumCast, StrCast } from "../../../new_fields/Types"; import { emptyFunction, returnEmptyString, returnOne } from "../../../Utils"; @@ -18,6 +18,7 @@ import { TraceMobx } from "../../../new_fields/util"; interface ContentFittingDocumentViewProps { Document?: Doc; DataDocument?: Doc; + LayoutDoc?: () => Opt; LibraryPath: Doc[]; childDocs?: Doc[]; renderDepth: number; @@ -42,7 +43,7 @@ interface ContentFittingDocumentViewProps { @observer export class ContentFittingDocumentView extends React.Component{ public get displayName() { return "DocumentView(" + this.props.Document?.title + ")"; } // this makes mobx trace() statements more descriptive - private get layoutDoc() { return this.props.Document && Doc.Layout(this.props.Document); } + private get layoutDoc() { return this.props.Document && (this.props.LayoutDoc?.() || Doc.Layout(this.props.Document)); } private get nativeWidth() { return NumCast(this.layoutDoc?._nativeWidth, this.props.PanelWidth()); } private get nativeHeight() { return NumCast(this.layoutDoc?._nativeHeight, this.props.PanelHeight()); } @computed get scaling() { @@ -97,6 +98,7 @@ export class ContentFittingDocumentView extends React.Component; Document: Doc; DataDoc?: Doc; + LayoutDoc?: () => Opt; LibraryPath: Doc[]; fitToBox?: boolean; onClick?: ScriptField; @@ -834,6 +834,7 @@ export class DocumentView extends DocComponent(Docu ContainingCollectionDoc={this.props.ContainingCollectionDoc} Document={this.props.Document} DataDoc={this.props.DataDoc} + LayoutDoc={this.props.LayoutDoc} fitToBox={this.props.fitToBox} LibraryPath={this.props.LibraryPath} addDocument={this.props.addDocument} diff --git a/src/client/views/nodes/FieldView.tsx b/src/client/views/nodes/FieldView.tsx index 7544a5b77..8250f41f3 100644 --- a/src/client/views/nodes/FieldView.tsx +++ b/src/client/views/nodes/FieldView.tsx @@ -43,6 +43,7 @@ export interface FieldViewProps { setVideoBox?: (player: VideoBox) => void; ContentScaling: () => number; ChromeHeight?: () => number; + childLayoutTemplate?: () => Opt; } @observer diff --git a/src/client/views/nodes/PresBox.tsx b/src/client/views/nodes/PresBox.tsx index 85017d3d4..d4a47c159 100644 --- a/src/client/views/nodes/PresBox.tsx +++ b/src/client/views/nodes/PresBox.tsx @@ -20,6 +20,7 @@ import { ContextMenuProps } from "../ContextMenuItem"; import { InkingControl } from "../InkingControl"; import { FieldView, FieldViewProps } from './FieldView'; import "./PresBox.scss"; +import { PrefetchProxy } from "../../../new_fields/Proxy"; library.add(faArrowLeft); library.add(faArrowRight); @@ -34,35 +35,14 @@ library.add(faEdit); export class PresBox extends React.Component { public static LayoutString(fieldKey: string) { return FieldView.LayoutString(PresBox, fieldKey); } _childReaction: IReactionDisposer | undefined; - _slideshowReaction: IReactionDisposer | undefined; @observable _isChildActive = false; - componentDidMount() { - const userDoc = CurrentUserUtils.UserDocument; this.props.Document._forceRenderEngine = "timeline"; this.props.Document._replacedChrome = "replaced"; - this._slideshowReaction = reaction(() => this.props.Document._viewType, - (slideshow) => { - if (slideshow === CollectionViewType.Stacking || slideshow === undefined) { - let presTemp = Cast(userDoc.presentationTemplate, Doc); - if (presTemp instanceof Promise) { - presTemp.then(presTemp => this.props.Document.childLayout = presTemp); - } - else if (presTemp === undefined) { - presTemp = userDoc.presentationTemplate = Docs.Create.PresElementBoxDocument({ backgroundColor: "transparent", _xMargin: 5, isTemplateDoc: true, isTemplateForField: "data" }); - } - else { - this.props.Document.childLayout = presTemp; - } - } else { - this.props.Document.childLayout = undefined; - } - }, { fireImmediately: true }); this._childReaction = reaction(() => this.childDocs.slice(), (children) => children.forEach((child, i) => child.presentationIndex = i), { fireImmediately: true }); } componentWillUnmount() { this._childReaction?.(); - this._slideshowReaction?.(); } @computed get childDocs() { return DocListCast(this.props.Document[this.props.fieldKey]); } @@ -376,7 +356,6 @@ export class PresBox extends React.Component { doc.presBox = this.props.Document; doc.presBoxKey = this.props.fieldKey; doc.collapsedHeight = hgt; - doc._nativeWidth = doc._nativeHeight = undefined; const curScale = NumCast(doc.viewScale, null); if (curScale === undefined) { doc.viewScale = 1; @@ -402,6 +381,8 @@ export class PresBox extends React.Component { this.props.Document._viewType = Number(e.target.selectedOptions[0].value); this.updateMinimize(e, Number(this.props.Document._viewType)); }); + + childLayoutTemplate = () => this.props.Document._viewType === CollectionViewType.Stacking ? Cast(Doc.UserDoc().presentationTemplate, Doc, null) : undefined; render() { const mode = NumCast(this.props.Document._viewType, CollectionViewType.Invalid); this.initializeScaleViews(this.childDocs, mode); @@ -425,8 +406,7 @@ export class PresBox extends React.Component {

{mode !== CollectionViewType.Invalid ? - : (null) } diff --git a/src/client/views/presentationview/PresElementBox.tsx b/src/client/views/presentationview/PresElementBox.tsx index 52773d466..888707ee3 100644 --- a/src/client/views/presentationview/PresElementBox.tsx +++ b/src/client/views/presentationview/PresElementBox.tsx @@ -2,19 +2,18 @@ import { library } from '@fortawesome/fontawesome-svg-core'; import { faFile as fileRegular } from '@fortawesome/free-regular-svg-icons'; import { faArrowDown, faArrowUp, faFile as fileSolid, faFileDownload, faLocationArrow, faSearch } from '@fortawesome/free-solid-svg-icons'; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; -import { action, computed, reaction, IReactionDisposer } from "mobx"; +import { action, computed, IReactionDisposer, reaction } from "mobx"; import { observer } from "mobx-react"; -import { Doc, DocListCast } from "../../../new_fields/Doc"; +import { Doc } from "../../../new_fields/Doc"; import { documentSchema } from '../../../new_fields/documentSchemas'; import { Id } from "../../../new_fields/FieldSymbols"; import { createSchema, makeInterface } from '../../../new_fields/Schema'; -import { Cast, NumCast, StrCast } from "../../../new_fields/Types"; -import { emptyFunction, returnFalse, emptyPath } from "../../../Utils"; -import { DocumentType } from "../../documents/DocumentTypes"; +import { Cast, NumCast } from "../../../new_fields/Types"; +import { emptyFunction, emptyPath, returnFalse } from "../../../Utils"; import { Transform } from "../../util/Transform"; import { CollectionViewType } from '../collections/CollectionView'; +import { DocExtendableComponent } from '../DocComponent'; import { ContentFittingDocumentView } from '../nodes/ContentFittingDocumentView'; -import { DocComponent, DocExtendableComponent } from '../DocComponent'; import { FieldView, FieldViewProps } from '../nodes/FieldView'; import "./PresElementBox.scss"; import React = require("react"); @@ -50,15 +49,16 @@ export class PresElementBox extends DocExtendableComponent [this.originalLayout.embedOpen, this.originalLayout.collapsedHeight], - params => this.originalLayout._height = NumCast(params[1]) + (Number(params[0]) ? 100 : 0), { fireImmediately: true }); + this._heightDisposer = reaction(() => [this.presElementDoc.embedOpen, this.presElementDoc.collapsedHeight], + params => this.presLayoutDoc._height = NumCast(params[1]) + (Number(params[0]) ? 100 : 0), { fireImmediately: true }); } componentWillUnmount() { this._heightDisposer?.(); @@ -71,13 +71,13 @@ export class PresElementBox extends DocExtendableComponent { e.stopPropagation(); - this.originalLayout.hideTillShownButton = !this.originalLayout.hideTillShownButton; - if (!this.originalLayout.hideTillShownButton) { + this.presElementDoc.hideTillShownButton = !this.presElementDoc.hideTillShownButton; + if (!this.presElementDoc.hideTillShownButton) { if (this.indexInPres >= this.currentIndex && this.targetDoc) { this.targetDoc.opacity = 1; } } else { - if (this.presentationDoc.presStatus && this.indexInPres > this.currentIndex && this.targetDoc) { + if (this.presBoxDoc.presStatus && this.indexInPres > this.currentIndex && this.targetDoc) { this.targetDoc.opacity = 0; } } @@ -91,14 +91,14 @@ export class PresElementBox extends DocExtendableComponent { e.stopPropagation(); - this.originalLayout.hideAfterButton = !this.originalLayout.hideAfterButton; - if (!this.originalLayout.hideAfterButton) { + this.presElementDoc.hideAfterButton = !this.presElementDoc.hideAfterButton; + if (!this.presElementDoc.hideAfterButton) { if (this.indexInPres <= this.currentIndex && this.targetDoc) { this.targetDoc.opacity = 1; } } else { - if (this.originalLayout.fadeButton) this.originalLayout.fadeButton = false; - if (this.presentationDoc.presStatus && this.indexInPres < this.currentIndex && this.targetDoc) { + if (this.presElementDoc.fadeButton) this.presElementDoc.fadeButton = false; + if (this.presBoxDoc.presStatus && this.indexInPres < this.currentIndex && this.targetDoc) { this.targetDoc.opacity = 0; } } @@ -112,14 +112,14 @@ export class PresElementBox extends DocExtendableComponent { e.stopPropagation(); - this.originalLayout.fadeButton = !this.originalLayout.fadeButton; - if (!this.originalLayout.fadeButton) { + this.presElementDoc.fadeButton = !this.presElementDoc.fadeButton; + if (!this.presElementDoc.fadeButton) { if (this.indexInPres <= this.currentIndex && this.targetDoc) { this.targetDoc.opacity = 1; } } else { - this.originalLayout.hideAfterButton = false; - if (this.presentationDoc.presStatus && (this.indexInPres < this.currentIndex) && this.targetDoc) { + this.presElementDoc.hideAfterButton = false; + if (this.presBoxDoc.presStatus && (this.indexInPres < this.currentIndex) && this.targetDoc) { this.targetDoc.opacity = 0.5; } } @@ -131,11 +131,11 @@ export class PresElementBox extends DocExtendableComponent { e.stopPropagation(); - this.originalLayout.navButton = !this.originalLayout.navButton; - if (this.originalLayout.navButton) { - this.originalLayout.showButton = false; + this.presElementDoc.navButton = !this.presElementDoc.navButton; + if (this.presElementDoc.navButton) { + this.presElementDoc.showButton = false; if (this.currentIndex === this.indexInPres) { - this.props.focus(this.originalLayout); + this.props.focus(this.presElementDoc); } } } @@ -147,13 +147,13 @@ export class PresElementBox extends DocExtendableComponent { e.stopPropagation(); - this.originalLayout.showButton = !this.originalLayout.showButton; - if (!this.originalLayout.showButton) { - this.originalLayout.viewScale = 1; + this.presElementDoc.showButton = !this.presElementDoc.showButton; + if (!this.presElementDoc.showButton) { + this.presElementDoc.viewScale = 1; } else { - this.originalLayout.navButton = false; + this.presElementDoc.navButton = false; if (this.currentIndex === this.indexInPres) { - this.props.focus(this.originalLayout); + this.props.focus(this.presElementDoc); } } } @@ -162,14 +162,14 @@ export class PresElementBox extends DocExtendableComponent [xCord, yCord]; - embedHeight = () => this.props.PanelHeight() - NumCast(this.originalLayout.collapsedHeight); + embedHeight = () => this.props.PanelHeight() - NumCast(this.presElementDoc.collapsedHeight); embedWidth = () => this.props.PanelWidth() - 20; /** * The function that is responsible for rendering the a preview or not for this * presentation element. */ renderEmbeddedInline = () => { - return !this.originalLayout.embedOpen || !this.targetDoc ? (null) : + return !this.presElementDoc.embedOpen || !this.targetDoc ? (null) :
{ this.props.focus(this.originalLayout); e.stopPropagation(); }}> + onClick={e => { this.props.focus(this.presElementDoc); e.stopPropagation(); }}> {treecontainer ? (null) : <> {`${this.indexInPres + 1}. ${this.targetDoc?.title}`} - +
} - - - - - - - + + + + + + +
{this.renderEmbeddedInline()} diff --git a/src/new_fields/Doc.ts b/src/new_fields/Doc.ts index 1636f4ee7..447dbe3b0 100644 --- a/src/new_fields/Doc.ts +++ b/src/new_fields/Doc.ts @@ -701,8 +701,11 @@ export namespace Doc { } // the document containing the view layout information - will be the Document itself unless the Document has - // a layout field. In that case, all layout information comes from there unless overriden by Document - export function Layout(doc: Doc): Doc { return doc[LayoutSym] || doc; } + // a layout field or 'layout' is given. + export function Layout(doc: Doc, layout?: Doc): Doc { + const overrideLayout = layout && Cast(doc["data-layout[" + layout[Id] + "]"], Doc, null); + return overrideLayout || doc[LayoutSym] || doc; + } export function SetLayout(doc: Doc, layout: Doc | string) { doc[StrCast(doc.layoutKey, "layout")] = layout; } export function LayoutField(doc: Doc) { return doc[StrCast(doc.layoutKey, "layout")]; } export function LayoutFieldKey(doc: Doc): string { return StrCast(Doc.Layout(doc).layout).split("'")[1]; } diff --git a/src/server/authentication/models/current_user_utils.ts b/src/server/authentication/models/current_user_utils.ts index 0185017ec..ce4f94d83 100644 --- a/src/server/authentication/models/current_user_utils.ts +++ b/src/server/authentication/models/current_user_utils.ts @@ -48,7 +48,7 @@ export class CurrentUserUtils { // setup the "creator" buttons for the sidebar-- eg. the default set of draggable document creation tools static setupCreatorButtons(doc: Doc, buttons?: string[]) { const notes = CurrentUserUtils.setupNoteTypes(doc); - const emptyPresentation = Docs.Create.PresDocument(new List(), { title: "Presentation", _viewType: CollectionViewType.Stacking, _chromeStatus: "replaced", showTitle: "title", boxShadow: "0 0" }); + const emptyPresentation = Docs.Create.PresDocument(new List(), { title: "Presentation", _viewType: CollectionViewType.Stacking, _LODdisable: true, _chromeStatus: "replaced", showTitle: "title", boxShadow: "0 0" }); const emptyCollection = Docs.Create.FreeformDocument([], { _nativeWidth: undefined, _nativeHeight: undefined, _LODdisable: true, _width: 150, _height: 100, title: "freeform" }); doc.noteTypes = Docs.Create.TreeDocument(notes, { title: "Note Types", _height: 75 }); doc.activePen = doc; @@ -270,7 +270,8 @@ export class CurrentUserUtils { // the initial presentation Doc to use static setupDefaultPresentation(doc: Doc) { - doc.curPresentation = Docs.Create.PresDocument(new List(), { title: "Presentation", _viewType: CollectionViewType.Stacking, _chromeStatus: "replaced", showTitle: "title", boxShadow: "0 0" }); + doc.presentationTemplate = new PrefetchProxy(Docs.Create.PresElementBoxDocument({ backgroundColor: "transparent", _xMargin: 5, _height: 46, isTemplateDoc: true, isTemplateForField: "data" })); + doc.curPresentation = Docs.Create.PresDocument(new List(), { title: "Presentation", _viewType: CollectionViewType.Stacking, _LODdisable: true, _chromeStatus: "replaced", showTitle: "title", boxShadow: "0 0" }); } static setupMobileUploads(doc: Doc) { -- cgit v1.2.3-70-g09d2 From ec5c878fb4c5f7e03fdd214c0841cf2ebf983e8c Mon Sep 17 00:00:00 2001 From: Sam Wilkins Date: Tue, 11 Feb 2020 15:48:06 -0500 Subject: refactored image upload data response format, google docs working for specific interactions --- .../util/Import & Export/DirectoryImportBox.tsx | 4 +- src/client/util/RichTextSchema.tsx | 1 + src/client/views/collections/CollectionSubView.tsx | 8 +- src/client/views/nodes/DocumentView.tsx | 4 +- src/client/views/nodes/ImageBox.tsx | 4 +- src/new_fields/RichTextUtils.ts | 30 ++--- src/scraping/buxton/final/json/buxton.json | 130 ++++++++++----------- src/server/ApiManagers/DownloadManager.ts | 2 +- src/server/DashUploadUtils.ts | 37 ++++-- src/server/apis/google/GooglePhotosUploadUtils.ts | 3 +- 10 files changed, 121 insertions(+), 102 deletions(-) (limited to 'src/server') diff --git a/src/client/util/Import & Export/DirectoryImportBox.tsx b/src/client/util/Import & Export/DirectoryImportBox.tsx index 071015193..d04f56e57 100644 --- a/src/client/util/Import & Export/DirectoryImportBox.tsx +++ b/src/client/util/Import & Export/DirectoryImportBox.tsx @@ -120,8 +120,8 @@ export default class DirectoryImportBox extends React.Component runInAction(() => this.completed += batch.length); }); - await Promise.all(uploads.map(async ({ name, type, clientAccessPath, exifData }) => { - const path = Utils.prepend(clientAccessPath); + await Promise.all(uploads.map(async ({ name, type, accessPaths, exifData }) => { + const path = Utils.prepend(accessPaths.agnostic.client); const document = await Docs.Get.DocumentFromType(type, path, { _width: 300, title: name }); const { data, error } = exifData; if (document) { diff --git a/src/client/util/RichTextSchema.tsx b/src/client/util/RichTextSchema.tsx index f12b3632c..3cf0561dc 100644 --- a/src/client/util/RichTextSchema.tsx +++ b/src/client/util/RichTextSchema.tsx @@ -133,6 +133,7 @@ export const nodes: { [index: string]: NodeSpec } = { inline: true, attrs: { src: {}, + agnostic: { default: null }, width: { default: 100 }, alt: { default: null }, title: { default: null }, diff --git a/src/client/views/collections/CollectionSubView.tsx b/src/client/views/collections/CollectionSubView.tsx index 293a8491a..20941493f 100644 --- a/src/client/views/collections/CollectionSubView.tsx +++ b/src/client/views/collections/CollectionSubView.tsx @@ -232,8 +232,8 @@ export function CollectionSubView(schemaCtor: (doc: Doc) => T) { const split = img.split("src=\"")[1].split("\"")[0]; let source = split; if (split.startsWith("data:image") && split.includes("base64")) { - const [{ clientAccessPath }] = await Networking.PostToServer("/uploadRemoteImage", { sources: [split] }); - source = Utils.prepend(clientAccessPath); + const [{ accessPaths }] = await Networking.PostToServer("/uploadRemoteImage", { sources: [split] }); + source = Utils.prepend(accessPaths.agnostic.client); } const doc = Docs.Create.ImageDocument(source, { ...options, _width: 300 }); ImageUtils.ExtractExif(doc); @@ -312,9 +312,9 @@ export function CollectionSubView(schemaCtor: (doc: Doc) => T) { const dropFileName = file ? file.name : "-empty-"; promises.push(Networking.PostFormDataToServer("/uploadFormData", formData).then(results => { results.map(action((result: any) => { - const { clientAccessPath, nativeWidth, nativeHeight, contentSize } = result; + const { accessPaths, nativeWidth, nativeHeight, contentSize } = result; const full = { ...options, _width: 300, title: dropFileName }; - const pathname = Utils.prepend(clientAccessPath); + const pathname = Utils.prepend(accessPaths.agnostic.client); Docs.Get.DocumentFromType(type, pathname, full).then(doc => { if (doc) { const proto = Doc.GetProto(doc); diff --git a/src/client/views/nodes/DocumentView.tsx b/src/client/views/nodes/DocumentView.tsx index e4ab3e746..5c5a87cb9 100644 --- a/src/client/views/nodes/DocumentView.tsx +++ b/src/client/views/nodes/DocumentView.tsx @@ -277,7 +277,7 @@ export class DocumentView extends DocComponent(Docu } preventDefault && e.preventDefault(); } - }) + }); buttonClick = async (altKey: boolean, ctrlKey: boolean) => { const linkDocs = DocListCast(this.props.Document.links); @@ -636,7 +636,7 @@ export class DocumentView extends DocComponent(Docu if (StrCast(tempDoc.title) === layout) { foundLayout = tempDoc; } - }) + }); DocumentView. makeCustomViewClicked(this.props.Document, this.props.DataDoc, Docs.Create.StackingDocument, layout, foundLayout); } else { diff --git a/src/client/views/nodes/ImageBox.tsx b/src/client/views/nodes/ImageBox.tsx index db9800de4..c0e102195 100644 --- a/src/client/views/nodes/ImageBox.tsx +++ b/src/client/views/nodes/ImageBox.tsx @@ -321,12 +321,12 @@ export class ImageBox extends DocAnnotatableComponent this.uploadIcon = loading); - const [{ clientAccessPath }] = await Networking.PostToServer("/uploadRemoteImage", { sources: [primary] }); + const [{ accessPaths }] = await Networking.PostToServer("/uploadRemoteImage", { sources: [primary] }); dataDoc.originalUrl = primary; let succeeded = true; let data: ImageField | undefined; try { - data = new ImageField(Utils.prepend(clientAccessPath)); + data = new ImageField(Utils.prepend(accessPaths.agnostic.client)); } catch { succeeded = false; } diff --git a/src/new_fields/RichTextUtils.ts b/src/new_fields/RichTextUtils.ts index 016bcc4ca..7c1fc39d8 100644 --- a/src/new_fields/RichTextUtils.ts +++ b/src/new_fields/RichTextUtils.ts @@ -114,6 +114,7 @@ export namespace RichTextUtils { width: number; title: string; url: string; + agnostic: string; } const parseInlineObjects = async (document: docs_v1.Schema$Document): Promise> => { @@ -135,17 +136,17 @@ export namespace RichTextUtils { for (let i = 0; i < objects.length; i++) { const object = objects[i]; - const { clientAccessPath } = uploads[i]; + const { accessPaths } = uploads[i]; + const { agnostic, _m } = accessPaths; const embeddedObject = object.inlineObjectProperties!.embeddedObject!; const size = embeddedObject.size!; const width = size.width!.magnitude!; - const ext = extname(clientAccessPath); - const url = Utils.prepend(clientAccessPath.replace(ext, "_m" + ext)); inlineObjectMap.set(object.objectId!, { title: embeddedObject.title || `Imported Image from ${document.title}`, width, - url + url: Utils.prepend(_m.client), + agnostic: Utils.prepend(agnostic.client) }); } } @@ -267,19 +268,19 @@ export namespace RichTextUtils { }; const imageNode = (schema: any, image: ImageTemplate, textNote: Doc) => { - const { url: src, width } = image; + const { url: src, width, agnostic } = image; let docid: string; - const guid = Utils.GenerateDeterministicGuid(src); + const guid = Utils.GenerateDeterministicGuid(agnostic); const backingDocId = StrCast(textNote[guid]); if (!backingDocId) { - const backingDoc = Docs.Create.ImageDocument(src, { _width: 300, _height: 300 }); + const backingDoc = Docs.Create.ImageDocument(agnostic, { _width: 300, _height: 300 }); DocumentView.makeCustomViewClicked(backingDoc, undefined, Docs.Create.FreeformDocument); docid = backingDoc[Id]; textNote[guid] = docid; } else { docid = backingDocId; } - return schema.node("image", { src, width, docid, float: null, location: "onRight" }); + return schema.node("image", { src, agnostic, width, docid, float: null, location: "onRight" }); }; const textNode = (schema: any, run: docs_v1.Schema$TextRun) => { @@ -435,7 +436,7 @@ export namespace RichTextUtils { const width = attrs.width; requests.push(await EncodeImage({ startIndex: position + nodeSize - 1, - uri: attrs.src, + uri: attrs.agnostic, width: Number(typeof width === "string" ? width.replace("px", "") : width) })); } @@ -498,15 +499,18 @@ export namespace RichTextUtils { }; }; - const EncodeImage = async (information: ImageInformation) => { - const source = [Docs.Create.ImageDocument(information.uri)]; + const EncodeImage = async ({ uri, width, startIndex }: ImageInformation) => { + if (!uri) { + return {}; + } + const source = [Docs.Create.ImageDocument(uri)]; const baseUrls = await GooglePhotos.Transactions.UploadThenFetch(source); if (baseUrls) { return { insertInlineImage: { uri: baseUrls[0], - objectSize: { width: { magnitude: information.width, unit: "PT" } }, - location: { index: information.startIndex } + objectSize: { width: { magnitude: width, unit: "PT" } }, + location: { index: startIndex } } }; } diff --git a/src/scraping/buxton/final/json/buxton.json b/src/scraping/buxton/final/json/buxton.json index 5c2e2c90c..16b28916b 100644 --- a/src/scraping/buxton/final/json/buxton.json +++ b/src/scraping/buxton/final/json/buxton.json @@ -18,9 +18,9 @@ "3DCad_Brochure.jpg" ], "__images": [ - "/files/images/buxton/upload_19ce4ebd-f207-4724-b8bf-610c8e1cf322.png", - "/files/images/buxton/upload_4dde8de0-f1ec-4ffb-b7cc-57b8c4ae6c94.png", - "/files/images/buxton/upload_825e8ed8-063c-428b-917d-eb62ea218f05.png" + "/files/images/buxton/upload_793981b0-d7da-45d1-a643-596cc3834166.png", + "/files/images/buxton/upload_6259e28a-055e-4b02-b547-e72c5e6fa3c0.png", + "/files/images/buxton/upload_4f4fb80f-467a-41e7-9bf5-1b1f377b2ec4.png" ], "title": "3Dconnexion CadMan 3D Motion Controller", "company": "3Dconnexion", @@ -63,11 +63,11 @@ "SpaceMouse_Plus_Info_Sheet.jpg" ], "__images": [ - "/files/images/buxton/upload_f84cb54e-9bdb-4fbc-9503-6cfa8ddd65be.jpg", - "/files/images/buxton/upload_506b5361-a9fd-4440-a19b-5b4af461878a.png", - "/files/images/buxton/upload_60380383-3603-4624-98cf-50a0d4afe4c9.png", - "/files/images/buxton/upload_2fad6fb2-f1e1-4fe3-915b-33586f05fcad.png", - "/files/images/buxton/upload_effcd815-49eb-4cd4-82cf-2519e58eb729.png" + "/files/images/buxton/upload_4a6cbfa8-964b-41d3-9f24-7d1aed22cd79.jpg", + "/files/images/buxton/upload_8c33d572-07da-4599-944c-eb2370b16a63.png", + "/files/images/buxton/upload_9afc5cca-6208-4944-a0f6-1c3fcd41fdcf.png", + "/files/images/buxton/upload_74e79798-9c9e-4c54-b42f-5813f218bc63.png", + "/files/images/buxton/upload_2bea6876-dc4e-4681-a1d3-433caec163c1.png" ], "title": "3Dconnexion Magellan/SpaceMouse Plus", "company": "3Dconnexion", @@ -114,13 +114,13 @@ "SpaceBall_5000_Data_Sheet.jpg" ], "__images": [ - "/files/images/buxton/upload_81972990-8cad-4299-926a-fe5d49711a80.jpg", - "/files/images/buxton/upload_04103620-72e4-431f-b34f-61d0f158277a.png", - "/files/images/buxton/upload_9bfe7c5a-1c5e-46e3-8f8d-4e0eec3e38e3.png", - "/files/images/buxton/upload_77da85f5-6575-4a8d-acb6-52f2df3307b0.png", - "/files/images/buxton/upload_1c041a33-b258-42d1-b9f2-d610a4838fb3.jpg", - "/files/images/buxton/upload_841f0d98-27d7-4298-a71d-c5cba72a262a.jpg", - "/files/images/buxton/upload_0e0eaf99-f8bb-4f02-ad46-651cd67c13b1.jpg" + "/files/images/buxton/upload_94e39580-5cca-46e9-ae49-ab6cd2fe3cad.jpg", + "/files/images/buxton/upload_eacee8a5-9849-4401-9c38-aa46fc0f517b.png", + "/files/images/buxton/upload_9b0b1f35-ac7c-4160-8806-8d243223872b.png", + "/files/images/buxton/upload_cf0c6e39-9ae6-48ce-90bd-d9f335503439.png", + "/files/images/buxton/upload_b4285b9f-26cd-4de5-8e37-c4e563c3e7f6.jpg", + "/files/images/buxton/upload_5b6ff31b-81b2-4a74-8591-27730c24225b.jpg", + "/files/images/buxton/upload_64dcea06-3b35-4979-bf40-5dfa5d4668b1.jpg" ], "title": "3Dconnexion Spaceball 5000", "company": "3Dconnexion", @@ -171,13 +171,13 @@ "SpaceNavigator_Press_Release.jpg" ], "__images": [ - "/files/images/buxton/upload_b44ec511-334e-46c0-a315-63d90fac8117.jpg", - "/files/images/buxton/upload_734ae360-faaf-4c78-89b4-a3f120fe233e.png", - "/files/images/buxton/upload_d20bbf6a-7310-407a-8b85-c607e9cf7f73.png", - "/files/images/buxton/upload_e9236600-dd5f-4805-92ca-805d5a301aa1.jpg", - "/files/images/buxton/upload_c85c977d-ef99-44be-b55c-8e8dde124e83.png", - "/files/images/buxton/upload_a6034d66-7de6-4d4b-bd64-ea95cc00ae8a.png", - "/files/images/buxton/upload_07415a65-964a-4936-aa6e-79861e8ebcbf.png" + "/files/images/buxton/upload_73511beb-f2bf-4f28-a1ea-64ef52a00426.jpg", + "/files/images/buxton/upload_4e088fb4-e5ff-4a1b-ba88-5f4575c86fe3.png", + "/files/images/buxton/upload_876a9921-3eb1-4c35-99e3-b82924fb88c4.png", + "/files/images/buxton/upload_d23c2886-c2b9-4558-9bfb-966aca7be20e.jpg", + "/files/images/buxton/upload_aef9171b-2e19-4fcb-b2dc-2281e89d498b.png", + "/files/images/buxton/upload_bbdaf252-1689-4680-8b19-ec5e79088e44.png", + "/files/images/buxton/upload_4cf49440-cf6b-484d-8391-3a2b0fae2b7e.png" ], "title": "3Dconnexion SpaceNavigator ", "company": "3Dconnexion", @@ -222,12 +222,12 @@ "3M_2006_Catalogue_p18.jpg" ], "__images": [ - "/files/images/buxton/upload_52b83c2a-5fe4-42aa-a488-5667b0a5beae.jpg", - "/files/images/buxton/upload_e05d8710-d82b-4f3b-8940-3745db1c855c.jpg", - "/files/images/buxton/upload_557c6fc7-04a3-4698-acde-4e53ceb6793c.jpg", - "/files/images/buxton/upload_d9723beb-bfe3-4556-b17d-aedf2db59777.jpg", - "/files/images/buxton/upload_5cb15815-3cab-406f-bf95-f9410997b4f4.jpg", - "/files/images/buxton/upload_a7fc91e0-7672-4f81-a8f3-66072997bd44.jpg" + "/files/images/buxton/upload_02df5121-8eff-452c-a52b-a44238afc06d.jpg", + "/files/images/buxton/upload_169aa4ee-4c34-43a2-8302-48bb3b7a01b6.jpg", + "/files/images/buxton/upload_a4d11c27-e4fa-4912-96da-3d971ec49ca0.jpg", + "/files/images/buxton/upload_7e9e1862-72e7-4f0d-8451-36de8c1bbe9c.jpg", + "/files/images/buxton/upload_76fa705f-2470-439c-acf6-03482d7a9570.jpg", + "/files/images/buxton/upload_7b6dd2c9-b88f-4958-a4d0-94bb42172e26.jpg" ], "title": "3M EM500 Ergonomic Mouse", "company": "3M", @@ -268,13 +268,13 @@ "Abaton_ProPoint_Brochure.jpg" ], "__images": [ - "/files/images/buxton/upload_f6f038a9-3583-4d21-9a43-f762e1df0b52.jpg", - "/files/images/buxton/upload_ad5f2bbd-66be-4dde-afe4-60e353a63f74.jpg", - "/files/images/buxton/upload_2e384260-5d2b-47a4-9508-028462a5a1e7.jpg", - "/files/images/buxton/upload_4dfcd3af-f06d-4c3e-8dff-7c43acd79a16.jpg", - "/files/images/buxton/upload_19eea9af-abec-4617-8b8d-fcb6637420de.jpg", - "/files/images/buxton/upload_89702b8a-fcb5-426d-b5af-c58e62d1c8ff.jpg", - "/files/images/buxton/upload_44419996-994e-471c-8dc7-cda22b00ac24.jpg" + "/files/images/buxton/upload_37169968-d329-40c5-9483-6bc198edc43c.jpg", + "/files/images/buxton/upload_64731ea4-a3aa-43ec-a56d-d4f6ecba7cf0.jpg", + "/files/images/buxton/upload_c41feac8-3b98-4d85-b9c7-79b3482a0695.jpg", + "/files/images/buxton/upload_5f67807b-f61b-4816-b93f-6d88c95b2418.jpg", + "/files/images/buxton/upload_a3e3cab8-48ab-43c2-bed9-5cc0ce68928d.jpg", + "/files/images/buxton/upload_4c3ac379-6703-4c87-a4a0-ca450a1151d2.jpg", + "/files/images/buxton/upload_8df14dc0-d75d-41f0-9e70-a221598d3df3.jpg" ], "title": "Abaton ProPoint Optical Trackball", "company": "Abaton", @@ -305,8 +305,8 @@ "Active_Book_Brochure_p1.jpg" ], "__images": [ - "/files/images/buxton/upload_2159da7b-9ebd-41ed-8b60-9eb36a6c6685.jpg", - "/files/images/buxton/upload_6d470914-fc41-4151-858b-f945807e62a2.png" + "/files/images/buxton/upload_9c8aa6a2-570f-4915-b840-504c8531c341.jpg", + "/files/images/buxton/upload_fbb7ad12-2a5d-4f76-89a9-ec30d7260031.png" ], "title": "Active Book Company Active Book Prototype", "company": "Active Book Company", @@ -342,11 +342,11 @@ "Adesso_ACK-540PW_June 21_2003.jpg" ], "__images": [ - "/files/images/buxton/upload_189469a3-1133-4a4f-8720-19c04f29684e.jpg", - "/files/images/buxton/upload_73f5d066-f9b5-41ce-9ce3-e27253ef51e7.jpg", - "/files/images/buxton/upload_498e5cbd-d65e-4b01-bed2-bcb2723ffee5.jpg", - "/files/images/buxton/upload_97ee9d03-07e0-448c-89f6-6ac61948de68.jpg", - "/files/images/buxton/upload_661e7387-dcd7-4ca1-8493-2e94f8803ef7.jpg" + "/files/images/buxton/upload_967656ff-44d7-4693-bcb0-dc0eab204413.jpg", + "/files/images/buxton/upload_9ffd4ccb-8ca5-4926-8fa2-38277b2ccfb6.jpg", + "/files/images/buxton/upload_22399981-f8c0-46e0-953c-89f7eb043ad2.jpg", + "/files/images/buxton/upload_15ad02a9-123f-4e7e-94c5-d959076520f0.jpg", + "/files/images/buxton/upload_8905097a-3568-4d37-9ad3-126a0e429f12.jpg" ], "title": "Adesso ACK-540PB PS/2 Mini PS/2 Touchpad Keyboard", "company": "Adesso", @@ -405,17 +405,17 @@ "Adesso_KP_Mouse_11_Product.JPG" ], "__images": [ - "/files/images/buxton/upload_0a127e30-9014-4300-bade-07945fba940f.jpg", - "/files/images/buxton/upload_ca20611c-9061-4e56-9d72-4c4a3c798d3f.jpg", - "/files/images/buxton/upload_12b46021-eeef-47f0-9e55-ca9e9b76f9e4.jpg", - "/files/images/buxton/upload_5e86ad07-77af-4d3e-a82e-eaa9cafdbbe4.jpg", - "/files/images/buxton/upload_4be64833-53e9-4216-b7ec-d521e0b87933.jpg", - "/files/images/buxton/upload_7cb731b5-5c52-47e0-a33b-c113530478f2.jpg", - "/files/images/buxton/upload_b20407b3-3578-4fa5-8f16-e0bf729e4daa.jpg", - "/files/images/buxton/upload_bee2fcb8-702a-46aa-9ec3-eb9b50ef1ba7.jpg", - "/files/images/buxton/upload_0ee0f6d5-34fc-41f3-9c8e-cf462dbcc40b.jpg", - "/files/images/buxton/upload_8f442582-b901-4a38-8df6-5a9b3195df9f.jpg", - "/files/images/buxton/upload_3f96763c-c3af-46a7-8831-3206c8bc460e.jpg" + "/files/images/buxton/upload_5bc99192-0935-4f6d-8d6c-a2218d55b359.jpg", + "/files/images/buxton/upload_52a6212e-c79d-4ec6-86a0-a3ca4ea54387.jpg", + "/files/images/buxton/upload_997acb64-0e08-4af2-b0e3-0b86a18bace5.jpg", + "/files/images/buxton/upload_00586980-0a08-43e1-9721-c2f5dcd1079e.jpg", + "/files/images/buxton/upload_3f695b11-dc1d-4d54-abec-eacfac80bdc7.jpg", + "/files/images/buxton/upload_161f1420-9594-4dca-ba62-1ca32e9a2028.jpg", + "/files/images/buxton/upload_a8b4ea6e-f1f8-47db-a796-72f566e60e6f.jpg", + "/files/images/buxton/upload_b6365e4e-4656-4bbf-aec6-feb920be6df9.jpg", + "/files/images/buxton/upload_1a0e9061-39e1-4dec-8add-5cc1abd110b5.jpg", + "/files/images/buxton/upload_d9bba544-f2b1-4a15-81e5-0d10e60d7881.jpg", + "/files/images/buxton/upload_56d486df-d7bb-44b0-80ad-c41c63590bae.jpg" ], "title": "Adesso 2-in-1 Optical Keypad Calculator Mouse AKP-170", "company": "Adesso Inc", @@ -477,18 +477,18 @@ "NB75D_Mouse_Manual.jpg" ], "__images": [ - "/files/images/buxton/upload_dae8f950-38bf-4fdf-8db0-153e3cae9cae.jpg", - "/files/images/buxton/upload_3e054d83-d01f-4d3d-aad2-fa8ee1d22a97.jpg", - "/files/images/buxton/upload_e9c2ddb0-0684-4bb4-a88c-5ee8074e456e.jpg", - "/files/images/buxton/upload_9c829a69-7d45-4d25-b906-98153aa03001.jpg", - "/files/images/buxton/upload_4faa425c-a100-4ce4-869c-a6c6705779ee.jpg", - "/files/images/buxton/upload_ed20ac31-69f6-45b8-b8e0-b8ad829ba002.jpg", - "/files/images/buxton/upload_f3d3d8f5-01cf-4cd1-9d1c-0a11a8c3e239.jpg", - "/files/images/buxton/upload_af1fa3b6-4537-416a-b626-34bed1154f35.jpg", - "/files/images/buxton/upload_5127f377-b697-4ad7-9fb3-fd6f82017c3c.jpg", - "/files/images/buxton/upload_061ae6a2-e083-492a-bc8a-826c4be00790.jpg", - "/files/images/buxton/upload_32e91966-7f1b-4cd7-858b-9cdb63affd13.jpg", - "/files/images/buxton/upload_ccc9de21-b047-4f9c-89c6-08fb3d206c7a.jpg" + "/files/images/buxton/upload_2db5c520-b370-4f03-8481-908e42428466.jpg", + "/files/images/buxton/upload_b28643eb-57a0-4602-b7cc-c41d553628b9.jpg", + "/files/images/buxton/upload_2478a89a-4eea-4e4c-af83-ecd292f44f3d.jpg", + "/files/images/buxton/upload_113d7356-f550-4491-849d-f69087c73918.jpg", + "/files/images/buxton/upload_44c40c44-ade6-499d-951c-4b436131e66e.jpg", + "/files/images/buxton/upload_d91f9756-09bc-447f-8f04-dc78344a5f11.jpg", + "/files/images/buxton/upload_b8c51011-5f93-43f3-85aa-b611a3b3cf93.jpg", + "/files/images/buxton/upload_483544a3-c3f7-4c8f-a236-def10d32f4f0.jpg", + "/files/images/buxton/upload_ea048294-3f57-42c3-b5b4-27062a5755dc.jpg", + "/files/images/buxton/upload_8eb1b9b1-9ca3-49c8-9bd4-7302a9c1f07e.jpg", + "/files/images/buxton/upload_029aa1d6-056d-4cf0-8eaf-b23b3d0e4317.jpg", + "/files/images/buxton/upload_3acc0955-da14-4a53-ac58-2e494e04ca78.jpg" ], "title": "A4 Tech BatteryFREE Wireless Optical Mouse Model NB-75D", "company": "A4Tech", diff --git a/src/server/ApiManagers/DownloadManager.ts b/src/server/ApiManagers/DownloadManager.ts index fad5e6789..01d2dfcad 100644 --- a/src/server/ApiManagers/DownloadManager.ts +++ b/src/server/ApiManagers/DownloadManager.ts @@ -254,7 +254,7 @@ async function writeHierarchyRecursive(file: Archiver.Archiver, hierarchy: Hiera // and dropped in the browser and thus hosted remotely) so we upload it // to our server and point the zip file to it, so it can bundle up the bytes const information = await DashUploadUtils.UploadImage(result); - path = information instanceof Error ? "" : information.serverAccessPaths[SizeSuffix.Original]; + path = information instanceof Error ? "" : information.accessPaths[SizeSuffix.Original].server; } // write the file specified by the path to the directory in the // zip file given by the prefix. diff --git a/src/server/DashUploadUtils.ts b/src/server/DashUploadUtils.ts index 83a0064e8..0f1758c26 100644 --- a/src/server/DashUploadUtils.ts +++ b/src/server/DashUploadUtils.ts @@ -61,13 +61,16 @@ export namespace DashUploadUtils { const type = "content-type"; export interface ImageUploadInformation { - clientAccessPath: string; - serverAccessPaths: { [key: string]: string }; + accessPaths: AccessPathInfo; exifData: EnrichedExifData; contentSize?: number; contentType?: string; } + export interface AccessPathInfo { + [suffix: string]: { client: string, server: string }; + } + const { imageFormats, videoFormats, applicationFormats } = AcceptibleMedia; export async function upload(file: File): Promise { @@ -94,7 +97,7 @@ export namespace DashUploadUtils { } console.log(red(`Ignoring unsupported file (${name}) with upload type (${type}).`)); - return { clientAccessPath: undefined }; + return { accessPaths: undefined }; } async function UploadPdf(absolutePath: string) { @@ -213,29 +216,40 @@ export namespace DashUploadUtils { }; }; - export async function MoveParsedFile(absolutePath: string, destination: Directory): Promise<{ clientAccessPath: Opt }> { - return new Promise<{ clientAccessPath: Opt }>(resolve => { + export async function MoveParsedFile(absolutePath: string, destination: Directory): Promise> { + return new Promise>(resolve => { const filename = basename(absolutePath); const destinationPath = serverPathToFile(destination, filename); rename(absolutePath, destinationPath, error => { - resolve({ clientAccessPath: error ? undefined : clientPathToFile(destination, filename) }); + resolve(error ? undefined : { + agnostic: getAccessPaths(destination, filename) + }); }); }); } + function getAccessPaths(directory: Directory, fileName: string) { + return { + client: clientPathToFile(directory, fileName), + server: serverPathToFile(directory, fileName) + }; + } + export const UploadInspectedImage = async (metadata: InspectionResults, filename?: string, prefix = "", cleanUp = true): Promise => { const { requestable, source, ...remaining } = metadata; const extension = `.${remaining.contentType.split("/")[1].toLowerCase()}`; const resolved = filename || `${prefix}upload_${Utils.GenerateGuid()}${extension}`; + const { images } = Directory; const information: ImageUploadInformation = { - clientAccessPath: clientPathToFile(Directory.images, resolved), - serverAccessPaths: {}, + accessPaths: { + agnostic: getAccessPaths(images, resolved) + }, ...remaining }; const outputPath = pathToDirectory(Directory.images); const writtenFiles = await outputResizedImages(() => request(requestable), outputPath, resolved, extension); for (const suffix of Object.keys(writtenFiles)) { - information.serverAccessPaths[suffix] = serverPathToFile(Directory.images, writtenFiles[suffix]); + information.accessPaths[suffix] = getAccessPaths(images, writtenFiles[suffix]); } if (isLocal().test(source) && cleanUp) { unlinkSync(source); @@ -270,10 +284,9 @@ export namespace DashUploadUtils { export async function outputResizedImages(readStreamSource: () => ReadStreamLike | Promise, outputPath: string, fileName: string, ext: string) { const writtenFiles: { [suffix: string]: string } = {}; for (const { resizer, suffix } of resizers(ext)) { - const resizedPath = path.resolve(outputPath, InjectSize(fileName, suffix)); - writtenFiles[suffix] = resizedPath; + const resolved = writtenFiles[suffix] = InjectSize(fileName, suffix); await new Promise(async (resolve, reject) => { - const writeStream = createWriteStream(resizedPath); + const writeStream = createWriteStream(path.resolve(outputPath, resolved)); let readStream: ReadStreamLike; const source = readStreamSource(); if (source instanceof Promise) { diff --git a/src/server/apis/google/GooglePhotosUploadUtils.ts b/src/server/apis/google/GooglePhotosUploadUtils.ts index 8ae63caa3..d305eed0a 100644 --- a/src/server/apis/google/GooglePhotosUploadUtils.ts +++ b/src/server/apis/google/GooglePhotosUploadUtils.ts @@ -84,6 +84,7 @@ export namespace GooglePhotosUploadUtils { if (!DashUploadUtils.validateExtension(url)) { return undefined; } + const body = await request(url, { encoding: null }); // returns a readable stream with the unencoded binary image data const parameters = { method: 'POST', uri: prepend('uploads'), @@ -92,7 +93,7 @@ export namespace GooglePhotosUploadUtils { 'X-Goog-Upload-File-Name': filename || path.basename(url), 'X-Goog-Upload-Protocol': 'raw' }, - body: await request(url, { encoding: null }) // returns a readable stream with the unencoded binary image data + body }; return new Promise((resolve, reject) => request(parameters, (error, _response, body) => { if (error) { -- cgit v1.2.3-70-g09d2 From ddd7696c15fa26b99650dd09a2738885063f7f61 Mon Sep 17 00:00:00 2001 From: Sam Wilkins Date: Tue, 11 Feb 2020 16:52:28 -0500 Subject: added secure backdoor delete route --- src/server/ApiManagers/SessionManager.ts | 9 +++++++++ src/server/DashSession/DashSessionAgent.ts | 1 + 2 files changed, 10 insertions(+) (limited to 'src/server') diff --git a/src/server/ApiManagers/SessionManager.ts b/src/server/ApiManagers/SessionManager.ts index f1629b8f0..cd8d19778 100644 --- a/src/server/ApiManagers/SessionManager.ts +++ b/src/server/ApiManagers/SessionManager.ts @@ -53,6 +53,15 @@ export default class SessionManager extends ApiManager { }) }); + register({ + method: Method.GET, + subscription: this.secureSubscriber("delete"), + secureHandler: this.authorizedAction(({ res }) => { + sessionAgent.serverWorker.emit("delete"); + res.redirect("/home"); + }) + }); + } } \ No newline at end of file diff --git a/src/server/DashSession/DashSessionAgent.ts b/src/server/DashSession/DashSessionAgent.ts index 85bfe14de..1ed98cdbe 100644 --- a/src/server/DashSession/DashSessionAgent.ts +++ b/src/server/DashSession/DashSessionAgent.ts @@ -37,6 +37,7 @@ export class DashSessionAgent extends AppliedSessionAgent { monitor.addReplCommand("debug", [/\S+\@\S+/], async ([to]) => this.dispatchZippedDebugBackup(to)); monitor.on("backup", this.backup); monitor.on("debug", async ({ to }) => this.dispatchZippedDebugBackup(to)); + monitor.on("delete", WebSocket.deleteFields); monitor.coreHooks.onCrashDetected(this.dispatchCrashReport); return sessionKey; } -- cgit v1.2.3-70-g09d2 From 84fd5c047fa33bf529c19a1bda03eaeab47b6489 Mon Sep 17 00:00:00 2001 From: Sam Wilkins Date: Tue, 11 Feb 2020 16:55:23 -0500 Subject: backdoor async --- src/server/ApiManagers/SessionManager.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/server') diff --git a/src/server/ApiManagers/SessionManager.ts b/src/server/ApiManagers/SessionManager.ts index cd8d19778..bcaa6598f 100644 --- a/src/server/ApiManagers/SessionManager.ts +++ b/src/server/ApiManagers/SessionManager.ts @@ -56,9 +56,9 @@ export default class SessionManager extends ApiManager { register({ method: Method.GET, subscription: this.secureSubscriber("delete"), - secureHandler: this.authorizedAction(({ res }) => { - sessionAgent.serverWorker.emit("delete"); - res.redirect("/home"); + secureHandler: this.authorizedAction(async ({ res }) => { + const { error } = await sessionAgent.serverWorker.emit("delete"); + res.send(error ? error.message : "Your request was successful: the server successfully deleted the database. Return to /home."); }) }); -- cgit v1.2.3-70-g09d2 From 307e011a5fbe0433b75cd3d00c0d4d50d578fea0 Mon Sep 17 00:00:00 2001 From: Sam Wilkins <35748010+samwilkins333@users.noreply.github.com> Date: Wed, 12 Feb 2020 03:35:02 -0500 Subject: fixed bugs and intentional behaviors of importer, namely destroying the size stream and making DOF and price optional fields, respectively --- src/client/documents/Documents.ts | 4 +++- src/scraping/buxton/final/BuxtonImporter.ts | 22 ++++++++++++---------- src/server/ApiManagers/UtilManager.ts | 5 ++++- 3 files changed, 19 insertions(+), 12 deletions(-) (limited to 'src/server') diff --git a/src/client/documents/Documents.ts b/src/client/documents/Documents.ts index 49d1820f5..b00a1a91d 100644 --- a/src/client/documents/Documents.ts +++ b/src/client/documents/Documents.ts @@ -373,10 +373,12 @@ export namespace Docs { const { ImageDocument, StackingDocument } = Docs.Create; if (Array.isArray(__images)) { const constructed = __images.map(relative => Utils.prepend(relative)); + const hero = constructed[0]; + constructed.splice(0, 1); const deviceImages = constructed.map((url, i) => ImageDocument(url, { title: `image${i}.${extname(url)}` })); const doc = StackingDocument(deviceImages, { title: device.title, _LODdisable: true }); const deviceProto = Doc.GetProto(doc); - deviceProto.hero = new ImageField(constructed[0]); + deviceProto.hero = new ImageField(hero); Docs.Get.DocumentHierarchyFromJson(device, undefined, deviceProto); Doc.AddDocToList(parentProto, "data", doc); } diff --git a/src/scraping/buxton/final/BuxtonImporter.ts b/src/scraping/buxton/final/BuxtonImporter.ts index 3e067bc6a..3d7421e90 100644 --- a/src/scraping/buxton/final/BuxtonImporter.ts +++ b/src/scraping/buxton/final/BuxtonImporter.ts @@ -84,7 +84,6 @@ namespace Utilities { if (error) { reject(error); } - console.log(stream); stream.on('data', (chunk: any) => body += chunk.toString()); stream.on('end', () => resolve(body)); }); @@ -121,17 +120,20 @@ const RegexMap = new Map>([ transformer: raw => ({ transformed: Utilities.collectUniqueTokens(raw).transformed[0] }), }], ["originalPrice", { - exp: /Original Price \(USD\)\:\s+(\$[0-9]+\.[0-9]+|NFS)/, + exp: /Original Price \(USD\)\:\s+(\$[0-9\,]+\.[0-9]+|NFS)/, transformer: (raw: string) => { + raw = raw.replace(/\,/g, ""); if (raw === "NFS") { return { transformed: -1 }; } return Utilities.numberValue(raw.slice(1)); - } + }, + required: false }], ["degreesOfFreedom", { exp: /Degrees of Freedom:\s+([0-9]+)/, - transformer: Utilities.numberValue + transformer: Utilities.numberValue, + required: false }], ["dimensions", { exp: /Dimensions\s+\(L x W x H\):\s+([0-9\.]+\s+x\s+[0-9\.]+\s+x\s+[0-9\.]+\s\([A-Za-z]+\))/, @@ -226,9 +228,7 @@ const hyperlinkXPath = '//*[name()="Relationship" and contains(@Type, "hyperlink async function extractFileContents(pathToDocument: string): Promise { console.log('Extracting text...'); const zip = new StreamZip({ file: pathToDocument, storeEntries: true }); - console.log(zip); await new Promise(resolve => zip.on('ready', resolve)); - console.log("Zip ready!"); // extract the body of the document and, specifically, its captions const document = await Utilities.readAndParseXml(zip, "word/document.xml"); @@ -276,20 +276,22 @@ async function writeImages(zip: any): Promise { const imageUrls: string[] = []; for (const mediaPath of imageEntries) { - console.log(`Considering ${mediaPath}`); const streamImage = () => new Promise((resolve, reject) => { zip.stream(mediaPath, (error: any, stream: any) => error ? reject(error) : resolve(stream)); }); const { width, height, type } = await new Promise(async resolve => { - const sizeStream = createImageSizeStream().on('size', resolve); - (await streamImage()).pipe(sizeStream); + const sizeStream = createImageSizeStream().on('size', (dimensions: Dimensions) => { + readStream.destroy(); + resolve(dimensions) + }); + const readStream = await streamImage(); + readStream.pipe(sizeStream); }); if (Math.abs(width - height) < 10) { continue; } - console.log(`Streaming!`); const ext = `.${type}`.toLowerCase(); const generatedFileName = `upload_${Utils.GenerateGuid()}${ext}`; diff --git a/src/server/ApiManagers/UtilManager.ts b/src/server/ApiManagers/UtilManager.ts index 4cb57a4e7..5aac8261e 100644 --- a/src/server/ApiManagers/UtilManager.ts +++ b/src/server/ApiManagers/UtilManager.ts @@ -42,7 +42,10 @@ export default class UtilManager extends ApiManager { register({ method: Method.GET, subscription: "/buxton", - secureHandler: async ({ res }) => res.send(await executeImport()) + secureHandler: async ({ req, res }) => { + req.setTimeout(300000); + res.send(await executeImport()); + } }); register({ -- cgit v1.2.3-70-g09d2 From 2daa348eb760dfd322a271bf3f9f69ebb713a91c Mon Sep 17 00:00:00 2001 From: Sam Wilkins <35748010+samwilkins333@users.noreply.github.com> Date: Wed, 12 Feb 2020 04:36:31 -0500 Subject: switched importer to websocket for continual updates --- src/client/documents/Documents.ts | 52 +++++++++++++++-------------- src/scraping/buxton/final/BuxtonImporter.ts | 52 ++++++++++++++++++----------- src/server/ApiManagers/UtilManager.ts | 9 ----- src/server/Message.ts | 5 ++- src/server/Websocket/Websocket.ts | 7 ++++ 5 files changed, 70 insertions(+), 55 deletions(-) (limited to 'src/server') diff --git a/src/client/documents/Documents.ts b/src/client/documents/Documents.ts index b00a1a91d..cc18dc0a6 100644 --- a/src/client/documents/Documents.ts +++ b/src/client/documents/Documents.ts @@ -55,6 +55,7 @@ import { InkingControl } from "../views/InkingControl"; import { RichTextField } from "../../new_fields/RichTextField"; import { Networking } from "../Network"; import { extname } from "path"; +import { MessageStore } from "../../server/Message"; const requestImageSize = require('../util/request-image-size'); const path = require('path'); @@ -346,6 +347,7 @@ export namespace Docs { export namespace Create { export function Buxton() { + let responded = false; const loading = new Doc; loading.title = "Please wait for the import script..."; const parent = TreeDocument([loading], { @@ -354,36 +356,36 @@ export namespace Docs { _height: 400, _LODdisable: true }); - Networking.FetchFromServer("/buxton").then(response => { - const devices = JSON.parse(response); - if (!Array.isArray(devices)) { - if ("error" in devices) { - loading.title = devices.error; - } else { - console.log(devices); - alert("The importer returned an unexpected import format. Check the console."); - } - return; + const parentProto = Doc.GetProto(parent); + const { _socket } = DocServer; + Utils.AddServerHandler(_socket, MessageStore.BuxtonDocumentResult, ({ device, errors }) => { + if (!responded) { + responded = true; + parentProto.data = new List(); } - const parentProto = Doc.GetProto(parent); - parentProto.data = new List(); - devices.forEach(device => { + if (device) { const { __images } = device; delete device.__images; const { ImageDocument, StackingDocument } = Docs.Create; - if (Array.isArray(__images)) { - const constructed = __images.map(relative => Utils.prepend(relative)); - const hero = constructed[0]; - constructed.splice(0, 1); - const deviceImages = constructed.map((url, i) => ImageDocument(url, { title: `image${i}.${extname(url)}` })); - const doc = StackingDocument(deviceImages, { title: device.title, _LODdisable: true }); - const deviceProto = Doc.GetProto(doc); - deviceProto.hero = new ImageField(hero); - Docs.Get.DocumentHierarchyFromJson(device, undefined, deviceProto); - Doc.AddDocToList(parentProto, "data", doc); - } - }); + const constructed = __images.map(relative => Utils.prepend(relative)); + const deviceImages = constructed.map((url, i) => ImageDocument(url, { title: `image${i}.${extname(url)}` })); + const doc = StackingDocument(deviceImages, { title: device.title, _LODdisable: true }); + const deviceProto = Doc.GetProto(doc); + deviceProto.hero = new ImageField(constructed[0]); + Docs.Get.DocumentHierarchyFromJson(device, undefined, deviceProto); + Doc.AddDocToList(parentProto, "data", doc); + } else if (errors) { + console.log(errors); + } else { + alert("A Buxton document import was completely empty (??)"); + } + }); + Utils.AddServerHandler(_socket, MessageStore.BuxtonImportComplete, ({ deviceCount, errorCount }) => { + _socket.off(MessageStore.BuxtonDocumentResult.Message); + _socket.off(MessageStore.BuxtonImportComplete.Message); + alert(`Successfully imported ${deviceCount} device${deviceCount === 1 ? "" : "s"}, with ${errorCount} error${errorCount === 1 ? "" : "s"}.`); }); + Utils.Emit(_socket, MessageStore.BeginBuxtonImport, ""); return parent; } diff --git a/src/scraping/buxton/final/BuxtonImporter.ts b/src/scraping/buxton/final/BuxtonImporter.ts index 3d7421e90..d9d48d68c 100644 --- a/src/scraping/buxton/final/BuxtonImporter.ts +++ b/src/scraping/buxton/final/BuxtonImporter.ts @@ -8,7 +8,6 @@ const StreamZip = require('node-stream-zip'); const createImageSizeStream = require("image-size-stream"); import { parseXml } from "libxmljs"; import { strictEqual } from "assert"; -import { BatchedArray, TimeUnit } from "array-batcher"; interface DocumentContents { body: string; @@ -24,21 +23,33 @@ export interface DeviceDocument { longDescription: string; company: string; year: number; - originalPrice: number; - degreesOfFreedom: number; + originalPrice?: number; + degreesOfFreedom?: number; dimensions?: string; primaryKey: string; secondaryKey: string; attribute: string; + __images: string[]; + hyperlinks: string[]; + captions: string[]; + embeddedFileNames: string[]; } -interface AnalysisResult { +export interface AnalysisResult { device?: DeviceDocument; - errors?: any; + errors?: { [key: string]: string }; } type Transformer = (raw: string) => { transformed?: T, error?: string }; +export interface ImportResults { + deviceCount: number, + errorCount: number +} + +type ResultCallback = (result: AnalysisResult) => void; +type TerminatorCallback = (result: ImportResults) => void; + interface Processor { exp: RegExp; matchIndex?: number; @@ -168,7 +179,7 @@ const successOut = "buxton.json"; const failOut = "incomplete.json"; const deviceKeys = Array.from(RegexMap.keys()); -export default async function executeImport() { +export default async function executeImport(emitter: ResultCallback, terminator: TerminatorCallback) { try { const contents = readdirSync(sourceDir); const wordDocuments = contents.filter(file => /.*\.docx?$/.test(file)).map(file => `${sourceDir}/${file}`); @@ -176,7 +187,7 @@ export default async function executeImport() { rimraf.sync(dir); mkdirSync(dir); }); - return parseFiles(wordDocuments); + return parseFiles(wordDocuments, emitter, terminator); } catch (e) { const message = [ "Unable to find a source directory.", @@ -188,23 +199,22 @@ export default async function executeImport() { } } -async function parseFiles(wordDocuments: string[]): Promise { - const imported = await BatchedArray.from(wordDocuments, { batchSize: 8 }).batchedMapPatientInterval<{ fileName: string, contents: DocumentContents }>({ magnitude: 10, unit: TimeUnit.Seconds }, async (batch, collector) => { - for (const filePath of batch) { - const fileName = path.basename(filePath).replace("Bill_Notes_", ""); - console.log(cyan(`\nExtracting contents from ${fileName}...`)); - collector.push({ fileName, contents: await extractFileContents(filePath) }); - } - }); - console.log(yellow("\nAnalyzing the extracted document text...\n")); - const results = imported.map(({ fileName, contents }) => analyze(fileName, contents)); +async function parseFiles(wordDocuments: string[], emitter: ResultCallback, terminator: TerminatorCallback): Promise { + const results: AnalysisResult[] = []; + for (const filePath of wordDocuments) { + const fileName = path.basename(filePath).replace("Bill_Notes_", ""); + console.log(cyan(`\nExtracting contents from ${fileName}...`)); + const result = analyze(fileName, await extractFileContents(filePath)); + emitter(result); + results.push(result); + } const masterDevices: DeviceDocument[] = []; - const masterErrors: any[] = []; + const masterErrors: { [key: string]: string }[] = []; results.forEach(({ device, errors }) => { if (device) { masterDevices.push(device); - } else { + } else if (errors) { masterErrors.push(errors); } }); @@ -219,6 +229,8 @@ async function parseFiles(wordDocuments: string[]): Promise { await writeOutputFile(failOut, masterErrors, total, false); console.log(); + terminator({ deviceCount: masterDevices.length, errorCount: masterErrors.length }); + return masterDevices; } @@ -311,7 +323,7 @@ function analyze(fileName: string, contents: DocumentContents): AnalysisResult { embeddedFileNames, __images: imageUrls }; - const errors: any = { fileName }; + const errors: { [key: string]: string } = { fileName }; for (const key of deviceKeys) { const { exp, transformer, matchIndex, required } = RegexMap.get(key)!; diff --git a/src/server/ApiManagers/UtilManager.ts b/src/server/ApiManagers/UtilManager.ts index 5aac8261e..8adc3da81 100644 --- a/src/server/ApiManagers/UtilManager.ts +++ b/src/server/ApiManagers/UtilManager.ts @@ -39,15 +39,6 @@ export default class UtilManager extends ApiManager { } }); - register({ - method: Method.GET, - subscription: "/buxton", - secureHandler: async ({ req, res }) => { - req.setTimeout(300000); - res.send(await executeImport()); - } - }); - register({ method: Method.GET, subscription: "/version", diff --git a/src/server/Message.ts b/src/server/Message.ts index 79b6fa1e0..2a03e2311 100644 --- a/src/server/Message.ts +++ b/src/server/Message.ts @@ -1,4 +1,5 @@ import { Utils } from "../Utils"; +import { AnalysisResult, ImportResults } from "../scraping/buxton/final/BuxtonImporter"; export class Message { private _name: string; @@ -56,6 +57,9 @@ export namespace MessageStore { export const GetDocument = new Message("Get Document"); export const DeleteAll = new Message("Delete All"); export const ConnectionTerminated = new Message("Connection Terminated"); + export const BeginBuxtonImport = new Message("Begin Buxton Import"); + export const BuxtonDocumentResult = new Message("Buxton Document Result"); + export const BuxtonImportComplete = new Message("Buxton Import Complete"); export const GetRefField = new Message("Get Ref Field"); export const GetRefFields = new Message("Get Ref Fields"); @@ -65,5 +69,4 @@ export namespace MessageStore { export const DeleteField = new Message("Delete field"); export const DeleteFields = new Message("Delete fields"); - } diff --git a/src/server/Websocket/Websocket.ts b/src/server/Websocket/Websocket.ts index ba7ca8f35..724221be1 100644 --- a/src/server/Websocket/Websocket.ts +++ b/src/server/Websocket/Websocket.ts @@ -12,6 +12,7 @@ import { timeMap } from "../ApiManagers/UserManager"; import { green } from "colors"; import { networkInterfaces, type } from "os"; import { object } from "serializr"; +import executeImport from "../../scraping/buxton/final/BuxtonImporter"; export namespace WebSocket { @@ -106,6 +107,12 @@ export namespace WebSocket { Utils.AddServerHandler(socket, MessageStore.DeleteFields, ids => DeleteFields(socket, ids)); Utils.AddServerHandlerCallback(socket, MessageStore.GetRefField, GetRefField); Utils.AddServerHandlerCallback(socket, MessageStore.GetRefFields, GetRefFields); + Utils.AddServerHandler(socket, MessageStore.BeginBuxtonImport, () => { + executeImport( + deviceOrError => Utils.Emit(socket, MessageStore.BuxtonDocumentResult, deviceOrError), + results => Utils.Emit(socket, MessageStore.BuxtonImportComplete, results) + ); + }); disconnect = () => { socket.broadcast.emit("connection_terminated", Date.now()); -- cgit v1.2.3-70-g09d2 From 44808c5ffc4ed9d3859dfd28cd59f7f3b3621cfc Mon Sep 17 00:00:00 2001 From: Sam Wilkins <35748010+samwilkins333@users.noreply.github.com> Date: Wed, 12 Feb 2020 04:37:44 -0500 Subject: one line cleanup --- src/server/Websocket/Websocket.ts | 1 - 1 file changed, 1 deletion(-) (limited to 'src/server') diff --git a/src/server/Websocket/Websocket.ts b/src/server/Websocket/Websocket.ts index 724221be1..6ee571395 100644 --- a/src/server/Websocket/Websocket.ts +++ b/src/server/Websocket/Websocket.ts @@ -11,7 +11,6 @@ import { logPort } from "../ActionUtilities"; import { timeMap } from "../ApiManagers/UserManager"; import { green } from "colors"; import { networkInterfaces, type } from "os"; -import { object } from "serializr"; import executeImport from "../../scraping/buxton/final/BuxtonImporter"; export namespace WebSocket { -- cgit v1.2.3-70-g09d2 From 736dde96336c5a00d3761f0894157b51a26081cc Mon Sep 17 00:00:00 2001 From: Sam Wilkins <35748010+samwilkins333@users.noreply.github.com> Date: Wed, 12 Feb 2020 16:32:48 -0500 Subject: standardized upload file response, particularly as it applies to video --- src/client/views/collections/CollectionSubView.tsx | 4 ++-- src/server/DashUploadUtils.ts | 10 ++++++---- 2 files changed, 8 insertions(+), 6 deletions(-) (limited to 'src/server') diff --git a/src/client/views/collections/CollectionSubView.tsx b/src/client/views/collections/CollectionSubView.tsx index acab45078..32480ad4e 100644 --- a/src/client/views/collections/CollectionSubView.tsx +++ b/src/client/views/collections/CollectionSubView.tsx @@ -315,9 +315,9 @@ export function CollectionSubView(schemaCtor: (doc: Doc) => T) { const dropFileName = file ? file.name : "-empty-"; promises.push(Networking.PostFormDataToServer("/uploadFormData", formData).then(results => { results.map(action((result: any) => { - const { agnostic, accessPaths, nativeWidth, nativeHeight, contentSize } = result; + const { accessPaths, nativeWidth, nativeHeight, contentSize } = result; const full = { ...options, _width: 300, title: dropFileName }; - const pathname = Utils.prepend(accessPaths?.agnostic.client || agnostic.client); + const pathname = Utils.prepend(accessPaths.agnostic.client); Docs.Get.DocumentFromType(type, pathname, full).then(doc => { if (doc) { const proto = Doc.GetProto(doc); diff --git a/src/server/DashUploadUtils.ts b/src/server/DashUploadUtils.ts index 0f1758c26..9ccc860f1 100644 --- a/src/server/DashUploadUtils.ts +++ b/src/server/DashUploadUtils.ts @@ -97,7 +97,7 @@ export namespace DashUploadUtils { } console.log(red(`Ignoring unsupported file (${name}) with upload type (${type}).`)); - return { accessPaths: undefined }; + return { accessPaths: {} }; } async function UploadPdf(absolutePath: string) { @@ -216,13 +216,15 @@ export namespace DashUploadUtils { }; }; - export async function MoveParsedFile(absolutePath: string, destination: Directory): Promise> { - return new Promise>(resolve => { + export async function MoveParsedFile(absolutePath: string, destination: Directory): Promise> { + return new Promise(resolve => { const filename = basename(absolutePath); const destinationPath = serverPathToFile(destination, filename); rename(absolutePath, destinationPath, error => { resolve(error ? undefined : { - agnostic: getAccessPaths(destination, filename) + accessPaths: { + agnostic: getAccessPaths(destination, filename) + } }); }); }); -- cgit v1.2.3-70-g09d2