Skip to content

Commit

Permalink
Merge branch 'owid:master' into db-dots
Browse files Browse the repository at this point in the history
  • Loading branch information
toni-sharpe authored Sep 20, 2024
2 parents 9a7717d + c0a3d7f commit 2bba625
Show file tree
Hide file tree
Showing 128 changed files with 5,197 additions and 1,380 deletions.
2 changes: 1 addition & 1 deletion .bundlewatch.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
},
{
"path": "./dist/assets/owid.css",
"maxSize": "430KB"
"maxSize": "450KB"
}
],
"defaultCompression": "none"
Expand Down
2 changes: 2 additions & 0 deletions .dev.vars.example
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,5 @@ MAILGUN_SENDING_KEY=
# optional
SLACK_BOT_OAUTH_TOKEN=
SLACK_ERROR_CHANNEL_ID=C016H0BNNB1 #bot-testing channel

GRAPHER_CONFIG_R2_BUCKET_PATH=devs/YOURNAME
6 changes: 3 additions & 3 deletions .env.devcontainer
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ GDOCS_CLIENT_ID=''
GDOCS_BASIC_ARTICLE_TEMPLATE_URL=''
GDOCS_SHARED_DRIVE_ID=''

IMAGE_HOSTING_R2_ENDPOINT=''
R2_ENDPOINT=''
IMAGE_HOSTING_R2_CDN_URL=''
IMAGE_HOSTING_R2_BUCKET_PATH=''
IMAGE_HOSTING_R2_ACCESS_KEY_ID=''
IMAGE_HOSTING_R2_SECRET_ACCESS_KEY=''
R2_ACCESS_KEY_ID=''
R2_SECRET_ACCESS_KEY=''
14 changes: 10 additions & 4 deletions .env.example-full
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,21 @@ GDOCS_BASIC_ARTICLE_TEMPLATE_URL=
GDOCS_SHARED_DRIVE_ID=
GDOCS_DONATE_FAQS_DOCUMENT_ID= # optional

IMAGE_HOSTING_R2_ENDPOINT= # optional
R2_ENDPOINT= # optional
IMAGE_HOSTING_R2_CDN_URL=
IMAGE_HOSTING_R2_BUCKET_PATH=
IMAGE_HOSTING_R2_ACCESS_KEY_ID= # optional
IMAGE_HOSTING_R2_SECRET_ACCESS_KEY= # optional
R2_ACCESS_KEY_ID= # optional
R2_SECRET_ACCESS_KEY= # optional
# These two GRAPHER_CONFIG_ settings are used to store grapher configs in an R2 bucket.
# The cloudflare workers for thumbnail rendering etc use these settings to fetch the grapher configs.
# This means that for most local dev it is not necessary to set these.
GRAPHER_CONFIG_R2_BUCKET= # optional - for local dev set it to "owid-grapher-configs-staging"
GRAPHER_CONFIG_R2_BUCKET_PATH= # optional - for local dev set it to "devs/YOURNAME"


OPENAI_API_KEY=

GRAPHER_DYNAMIC_THUMBNAIL_URL= # optional; can set this to https://ourworldindata.org/grapher/thumbnail to use the live thumbnail worker
GRAPHER_DYNAMIC_THUMBNAIL_URL= # optional; can set this to https://ourworldindata.org/grapher to use the live thumbnail worker

# enable search (readonly)
ALGOLIA_ID= # optional
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,4 @@ dist/
.nx/workspace-data
.dev.vars
**/tsup.config.bundled*.mjs
cfstorage/
1 change: 1 addition & 0 deletions adminSiteClient/ChartEditor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ export class ChartEditor extends AbstractChartEditor<ChartEditorManager> {
const chartJson = { ...patchConfig }
delete chartJson.id
delete chartJson.isPublished
delete chartJson.slug

// Need to open intermediary tab before AJAX to avoid popup blockers
const w = window.open("/", "_blank") as Window
Expand Down
16 changes: 2 additions & 14 deletions adminSiteClient/EditorExportTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ type ExportSettings = Required<
| "hideTitle"
| "forceHideAnnotationFieldsInTitle"
| "hideSubtitle"
| "hideLogo"
| "hideNote"
| "hideOriginUrl"
| "shouldIncludeDetailsInStaticExport"
Expand All @@ -28,7 +27,6 @@ type OriginalGrapher = Pick<
| "shouldAddEntitySuffixToTitle"
| "shouldAddTimeSuffixToTitle"
| "currentSubtitle"
| "hideLogo"
| "note"
| "originUrl"
| "shouldIncludeDetailsInStaticExport"
Expand All @@ -49,7 +47,6 @@ const DEFAULT_SETTINGS: ExportSettings = {
time: false,
},
hideSubtitle: false,
hideLogo: false,
hideNote: false,
hideOriginUrl: false,
shouldIncludeDetailsInStaticExport: false,
Expand Down Expand Up @@ -118,7 +115,6 @@ export class EditorExportTab<
forceHideAnnotationFieldsInTitle:
this.grapher.forceHideAnnotationFieldsInTitle,
hideSubtitle: this.grapher.hideSubtitle,
hideLogo: this.grapher.hideLogo,
hideNote: this.grapher.hideNote,
hideOriginUrl: this.grapher.hideOriginUrl,
shouldIncludeDetailsInStaticExport:
Expand All @@ -134,7 +130,6 @@ export class EditorExportTab<
this.grapher.shouldAddEntitySuffixToTitle,
shouldAddTimeSuffixToTitle: this.grapher.shouldAddTimeSuffixToTitle,
currentSubtitle: this.grapher.currentSubtitle,
hideLogo: this.grapher.hideLogo,
note: this.grapher.note,
originUrl: this.grapher.originUrl,
shouldIncludeDetailsInStaticExport:
Expand Down Expand Up @@ -202,6 +197,8 @@ export class EditorExportTab<
grapher = new Grapher({
...this.grapher,
staticFormat: format,
selectedEntityNames:
this.grapher.selection.selectedEntityNames,
})
}
const { blob: pngBlob, svgBlob } = await grapher.rasterize()
Expand Down Expand Up @@ -266,15 +263,6 @@ export class EditorExportTab<
}
/>
)}
{!this.originalGrapher.hideLogo && (
<Toggle
label="Logo"
value={!this.settings.hideLogo}
onValue={(value) =>
(this.settings.hideLogo = !value)
}
/>
)}
{this.originalGrapher.note && (
<Toggle
label="Note"
Expand Down
9 changes: 0 additions & 9 deletions adminSiteClient/EditorScatterTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,6 @@ export class EditorScatterTab extends React.Component<{ grapher: Grapher }> {
this.props.grapher.hideTimeline = value || undefined
}

@action.bound onToggleHideLinesOutsideTolerance(value: boolean) {
this.props.grapher.hideLinesOutsideTolerance = value || undefined
}

@action.bound onToggleHideScatterLabels(value: boolean) {
this.props.grapher.hideScatterLabels = value || undefined
}
Expand Down Expand Up @@ -146,11 +142,6 @@ export class EditorScatterTab extends React.Component<{ grapher: Grapher }> {
value={!!grapher.hideTimeline}
onValue={this.onToggleHideTimeline}
/>
<Toggle
label="Hide entities without data for full time span (within tolerance)"
value={!!grapher.hideLinesOutsideTolerance}
onValue={this.onToggleHideLinesOutsideTolerance}
/>
<Toggle
label="Hide connected scatter lines"
value={!!grapher.hideConnectedScatterLines}
Expand Down
2 changes: 1 addition & 1 deletion adminSiteClient/GrapherConfigGridEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1096,7 +1096,7 @@ export class GrapherConfigGridEditor extends React.Component<GrapherConfigGridEd

async getFieldDefinitions() {
const json = await fetch(
"https://files.ourworldindata.org/schemas/grapher-schema.004.json"
"https://files.ourworldindata.org/schemas/grapher-schema.005.json"
).then((response) => response.json())
const fieldDescriptions = extractFieldDescriptionsFromSchema(json)
runInAction(() => {
Expand Down
36 changes: 36 additions & 0 deletions adminSiteClient/gdocsValidation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
OwidGdocDataInsightInterface,
checkIsAuthor,
OwidGdocAuthorInterface,
getFilenameExtension,
} from "@ourworldindata/utils"

function validateTitle(gdoc: OwidGdoc, errors: OwidGdocErrorMessage[]) {
Expand Down Expand Up @@ -198,6 +199,40 @@ function validateGrapherUrl(
}
}

function validateDataInsightImage(
gdoc: OwidGdocDataInsightInterface,
errors: OwidGdocErrorMessage[]
) {
const image = gdoc.content.body.find((block) => block.type === "image")
if (!image) {
errors.push({
property: "body",
type: OwidGdocErrorMessageType.Warning,
message: `Data insight is missing an image.`,
})
} else {
for (const property of ["filename", "smallFilename"] as const) {
if (!image[property]) {
errors.push({
property: "body",
type: OwidGdocErrorMessageType.Error,
message: `Data insight image is missing ${property}`,
})
}
if (
image[property] &&
getFilenameExtension(image[property]) !== "png"
) {
errors.push({
property: "body",
type: OwidGdocErrorMessageType.Warning,
message: `Data insight ${property} should be a PNG`,
})
}
}
}
}

function validateAtomFields(
gdoc: OwidGdocPostInterface,
errors: OwidGdocErrorMessage[]
Expand Down Expand Up @@ -262,6 +297,7 @@ export const getErrors = (gdoc: OwidGdoc): OwidGdocErrorMessage[] => {
} else if (checkIsDataInsight(gdoc)) {
validateApprovedBy(gdoc, errors)
validateGrapherUrl(gdoc, errors)
validateDataInsightImage(gdoc, errors)
} else if (checkIsAuthor(gdoc)) {
validateSocials(gdoc, errors)
}
Expand Down
Loading

0 comments on commit 2bba625

Please sign in to comment.