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

Commit

Permalink
Remove use of shot.ogTitle, in preference for shot.openGraph.title
Browse files Browse the repository at this point in the history
  • Loading branch information
ianb committed Mar 8, 2017
1 parent 9fae30d commit 80512a2
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 16 deletions.
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
2 changes: 1 addition & 1 deletion server/src/servershot.js
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ Shot.get = function (backend, id) {
if (! json.url && rawValue.url) {
json.url = rawValue.url;
}
let jsonTitle = json.userTitle || json.ogTitle || (json.openGraph && json.openGraph.title) || json.docTitle;
let jsonTitle = json.userTitle || (json.openGraph && json.openGraph.title) || json.docTitle;
if (! jsonTitle) {
json.docTitle = rawValue.title;
}
Expand Down
19 changes: 5 additions & 14 deletions shared/shot.js
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,6 @@ class AbstractShot {
this._id = id;
this.url = attrs.url;
this.docTitle = attrs.docTitle || null;
this.ogTitle = attrs.ogTitle || null;
this.userTitle = attrs.userTitle || null;
this.createdDate = attrs.createdDate || Date.now();
this.createdDevice = attrs.createdDevice || null;
Expand Down Expand Up @@ -476,15 +475,6 @@ ${options.addBody || ""}
}
// FIXME: no delete, nor comment editing

// FIXME: deprecate
get ogTitle() {
return this._ogTitle;
}
set ogTitle(val) {
assert(val === null || typeof val == "string", "Bad ogTitle:", val);
this._ogTitle = val;
}

get openGraph() {
return this._openGraph || null;
}
Expand Down Expand Up @@ -522,7 +512,8 @@ ${options.addBody || ""}
get title() {
// FIXME: we shouldn't support both openGraph.title and ogTitle
let ogTitle = this.openGraph && this.openGraph.title;
let title = this.userTitle || this.ogTitle || ogTitle || this.docTitle || this.url;
let twitterTitle = this.twitterCard && this.twitterCard.title;
let title = this.userTitle || ogTitle || twitterTitle || this.docTitle || this.url;
if (Array.isArray(title)) {
title = title[0];
}
Expand Down Expand Up @@ -762,19 +753,19 @@ ${options.addBody || ""}
}

AbstractShot.prototype.REGULAR_ATTRS = (`
deviceId url docTitle ogTitle userTitle createdDate createdDevice favicon
deviceId url docTitle userTitle createdDate createdDevice favicon
comments hashtags images readable head body htmlAttrs bodyAttrs
headAttrs siteName openGraph twitterCard documentSize
fullScreenThumbnail isPublic resources showPage abTests
`).split(/\s+/g);

// Attributes that will be accepted in the constructor, but ignored/dropped
AbstractShot.prototype.DEPRECATED_ATTRS = (`
microdata history
microdata history ogTitle
`).split(/\s+/g);

AbstractShot.prototype.RECALL_ATTRS = (`
deviceId url docTitle ogTitle userTitle createdDate createdDevice favicon
deviceId url docTitle userTitle createdDate createdDevice favicon
openGraph twitterCard images fullScreenThumbnail
`).split(/\s+/g);

Expand Down

0 comments on commit 80512a2

Please # to comment.