Skip to content
This repository has been archived by the owner on Jan 17, 2023. It is now read-only.

Clean up shot.js #2330

Merged
merged 11 commits into from
Mar 10, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
85 changes: 0 additions & 85 deletions bin/analyze-page

This file was deleted.

2 changes: 0 additions & 2 deletions bin/load_test_exercise.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,6 @@ def make_example_shot():
createdDate=int(time.time()*1000),
favicon=None,
siteName="test site",
isPublic=True,
showPage=False,
clips={
make_uuid(): dict(
createdDate=int(time.time()*1000),
Expand Down
17 changes: 2 additions & 15 deletions docs/testing-the-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,24 +76,15 @@ Authenticated. Creates or updates a shot. Takes a JSON body. Looks like:
"y": 383
},
"title": null,
"alt": "my_shots",
"isReadable": false
"alt": "my_shots"
}
],
"head": "<title>...",
"body": "<div>...",
"htmlAttrs": [["attrname", "attrvalue"]],
"bodyAttrs": [["attrname", "attrvalue"]],
"headAttrs": [],
"siteName": "GitHub",
"documentSize": {
"width": 1127,
"height": 2086
},
"fullScreenThumbnail": "data:...",
"isPublic": true,
"resources": {},
"showPage": false,
"clips": {
"cplocgk9m1nc": {
"createdDate": 1468983771992,
Expand Down Expand Up @@ -148,16 +139,12 @@ Then you get a response back that converts the `data:...` URLs to other URLs, li

`GET /data/{random_id}/{domain}`

Not authenticated. Gets the JSON back, but with `head` and `body` removed.
Not authenticated. Gets the JSON back.

`POST /api/delete-shot`

Authenticated. Takes only one parameter, `id` (the `"{random_id}/{domain}"`)

`POST /api/add-saved-shot-data/{random_id}/{domain}`

Authenticated. Takes a JSON body, with keys `head`, `body`, `headAttrs`, `bodyAttrs`, and `htmlAttrs`

`POST /api/set-expiration`

Authenticated. Takes URL encoded parameters, `id` and `expiration` (milliseconds)
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
"convict": "2.0.0",
"cookies": "0.6.2",
"core-js": "2.4.1",
"domino": "1.0.28",
"envc": "2.4.1",
"escape-html": "1.0.3",
"express": "4.14.1",
Expand Down
2 changes: 2 additions & 0 deletions server/db-patches/patch-13-14.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ALTER TABLE data DROP COLUMN head;
ALTER TABLE data DROP COLUMN body;
2 changes: 2 additions & 0 deletions server/db-patches/patch-14-13.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ALTER TABLE data ADD COLUMN head TEXT;
ALTER TABLE data ADD COLUMN body TEXT;
7 changes: 3 additions & 4 deletions server/schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ CREATE TABLE data (
deviceid character varying(200),
created timestamp without time zone DEFAULT now(),
value text NOT NULL,
head text,
body text,
url text NOT NULL,
expire_time timestamp without time zone DEFAULT (now() + '14 days'::interval),
deleted boolean DEFAULT false NOT NULL,
Expand All @@ -25,7 +23,8 @@ CREATE TABLE devices (
last_login timestamp without time zone,
created timestamp without time zone DEFAULT now(),
session_count integer DEFAULT 0,
secret_hashed text
secret_hashed text,
ab_tests text
);
CREATE TABLE images (
id character varying(200) NOT NULL,
Expand Down Expand Up @@ -73,4 +72,4 @@ ALTER TABLE ONLY images
ADD CONSTRAINT images_shotid_fkey FOREIGN KEY (shotid) REFERENCES data(id) ON DELETE CASCADE;
ALTER TABLE ONLY states
ADD CONSTRAINT states_deviceid_fkey FOREIGN KEY (deviceid) REFERENCES devices(id) ON DELETE CASCADE;
-- pg-patch version: 12
-- pg-patch version: 14
81 changes: 0 additions & 81 deletions server/src/contentcheck.js

This file was deleted.

2 changes: 1 addition & 1 deletion server/src/dbschema.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const pgpatcher = require("pg-patcher");
const path = require("path");
const mozlog = require("mozlog")("dbschema");

const MAX_DB_LEVEL = exports.MAX_DB_LEVEL = 13;
const MAX_DB_LEVEL = exports.MAX_DB_LEVEL = 14;

exports.forceDbVersion = function (version) {
mozlog.info("forcing-db-version", {db: db.constr, version});
Expand Down
45 changes: 0 additions & 45 deletions server/src/pages/shot/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -179,51 +179,6 @@ function sendShowElement(clipId) {
}
}

/*
function requestHasSavedShot(id) {
let event = document.createEvent("CustomEvent");
event.initCustomEvent("has-saved-shot", true, true, id);
document.dispatchEvent(event);
}

exports.requestSavedShot = function () {
let event = document.createEvent("CustomEvent");
event.initCustomEvent("request-saved-shot", true, true, model.shot.id);
document.dispatchEvent(event);
};

function addSavedShotData(data) {
if (! data) {
model.hasSavedShot = false;
exports.render();
return;
}
for (let attr in data) {
if (! data[attr]) {
delete data[attr];
}
}
data.showPage = true;
model.shot.update(data);
model.hasSavedShot = false;
let url = model.backend + "/api/add-saved-shot-data/" + model.shot.id;
let req = new XMLHttpRequest();
req.onload = function () {
if (req.status >= 300) {
window.alert("Error saving expiration: " + req.status + " " + req.statusText);
return;
}
let event = document.createEvent("CustomEvent");
event.initCustomEvent("remove-saved-shot", true, true, model.shot.id);
document.dispatchEvent(event);
exports.render();
};
req.open("POST", url);
req.setRequestHeader("content-type", "application/json");
req.send(JSON.stringify(data));
}
*/

exports.setTitle = function (title) {
title = title || null;
let url = model.backend + "/api/set-title/" + model.shot.id;
Expand Down
2 changes: 1 addition & 1 deletion server/src/pages/shot/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ class Head extends React.Component {
if (! this.props.shot) {
return null;
}
let title = this.props.shot.ogTitle ||
let title = (this.props.shot.openGraph && this.props.shot.openGraph.title) ||
(this.props.shot.twitterCard && this.props.shot.twitterCard.title) ||
this.props.shot.title;
let og = [
Expand Down