Skip to content

Commit

Permalink
Stop adding Max as an extra author
Browse files Browse the repository at this point in the history
  • Loading branch information
rakyi committed Jan 8, 2025
1 parent c8cf78e commit e9d0253
Show file tree
Hide file tree
Showing 9 changed files with 4 additions and 46 deletions.
2 changes: 1 addition & 1 deletion adminSiteServer/apiRouter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3467,7 +3467,7 @@ getRouteWithROTransaction(apiRouter, "/all-work", async (req, res, trx) => {
>
type GdocRecord = Pick<DbRawPostGdoc, "id" | "publishedAt">

const author = req.query.author || "Max Roser"
const author = req.query.author
const gdocs = await db.knexRaw<GdocRecord>(
trx,
`-- sql
Expand Down
11 changes: 1 addition & 10 deletions db/migrateWpPostsToArchieMl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import {
adjustHeadingLevels,
findMinimumHeadingLevel,
} from "./model/Gdoc/htmlToEnriched.js"
import { getPostRelatedCharts, isPostSlugCitable } from "./model/Post.js"
import { getPostRelatedCharts } from "./model/Post.js"
import { enrichedBlocksToMarkdown } from "./model/Gdoc/enrichedToMarkdown.js"

// slugs from all the linear entries we want to migrate from @edomt
Expand Down Expand Up @@ -131,15 +131,6 @@ const migrate = async (trx: db.KnexReadWriteTransaction): Promise<void> => {
relatedCharts = await getPostRelatedCharts(trx, post.id)
}

const shouldIncludeMaxAsAuthor = isPostSlugCitable(post.slug)
if (
shouldIncludeMaxAsAuthor &&
post.authors &&
!post.authors.includes("Max Roser")
) {
post.authors.push("Max Roser")
}

// We don't get the first and last nodes if they are comments.
// This can cause issues with the wp:components so here we wrap
// everything in a div
Expand Down
5 changes: 0 additions & 5 deletions packages/@ourworldindata/utils/src/metadataHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,16 +73,11 @@ export const getETLPathComponents = (path: string): ETLPathComponents => {

export const formatAuthors = ({
authors,
requireMax,
forBibtex,
}: {
authors: string[]
requireMax?: boolean
forBibtex?: boolean
}): string => {
if (requireMax && !authors.includes("Max Roser"))
authors = [...authors, "Max Roser"]

let authorsText = authors.slice(0, -1).join(forBibtex ? " and " : ", ")
if (authorsText.length === 0) authorsText = authors[0]
else authorsText += ` and ${last(authors)}`
Expand Down
3 changes: 0 additions & 3 deletions site/Byline.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@ import { formatAuthors } from "./clientFormatting.js"

export const Byline = ({
authors,
withMax,
override,
}: {
authors: string[]
withMax: boolean
override?: string
}) => {
return (
Expand All @@ -20,7 +18,6 @@ export const Byline = ({
) : (
<a href="/team">{`by ${formatAuthors({
authors,
requireMax: withMax,
})}`}</a>
)}
</div>
Expand Down
7 changes: 1 addition & 6 deletions site/CitationMeta.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,7 @@ export const CitationMeta = (props: {
date: Date
canonicalUrl: string
}) => {
const { title, date, canonicalUrl } = props
let { authors } = props

if (authors.indexOf("Max Roser") === -1)
authors = authors.concat(["Max Roser"])

const { authors, title, date, canonicalUrl } = props
return (
<Fragment>
<meta name="citation_title" content={title} />
Expand Down
3 changes: 0 additions & 3 deletions site/LongFormPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,11 @@ export const LongFormPage = (props: {

const citationText = `${formatAuthors({
authors: citationAuthors,
requireMax: true,
})} (${citationPublishedYear}) - "${citationTitle}". Published online at OurWorldinData.org. Retrieved from: '${citationCanonicalUrl}' [Online Resource]`

const bibtex = `@article{owid${citationSlug.replace(/-/g, "")},
author = {${formatAuthors({
authors: citationAuthors,
requireMax: true,
forBibtex: true,
})}},
title = {${citationTitle}},
Expand Down Expand Up @@ -169,7 +167,6 @@ export const LongFormPage = (props: {
{!formattingOptions.hideAuthors && (
<Byline
authors={post.authors}
withMax={withCitation}
override={post.byline}
/>
)}
Expand Down
5 changes: 0 additions & 5 deletions site/clientFormatting.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,11 @@ import { last } from "@ourworldindata/utils"

export const formatAuthors = ({
authors,
requireMax,
forBibtex,
}: {
authors: string[]
requireMax?: boolean
forBibtex?: boolean
}) => {
if (requireMax && !authors.includes("Max Roser"))
authors = [...authors, "Max Roser"]

let authorsText = authors.slice(0, -1).join(forBibtex ? " and " : ", ")
if (authorsText.length === 0) authorsText = authors[0]
else authorsText += ` and ${last(authors)}`
Expand Down
8 changes: 0 additions & 8 deletions site/formatting.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,17 +162,9 @@ describe(formatAuthors, () => {
"Author 1, Author 2 and Author 3"
)

expect(formatAuthors({ authors, requireMax: true })).toEqual(
"Author 1, Author 2, Author 3 and Max Roser"
)

expect(formatAuthors({ authors: ["Author 1"] })).toEqual("Author 1")
expect(formatAuthors({ authors: ["Author 1", "Author 2"] })).toEqual(
"Author 1 and Author 2"
)

expect(
formatAuthors({ authors, requireMax: true, forBibtex: true })
).toEqual("Author 1 and Author 2 and Author 3 and Max Roser")
})
})
6 changes: 1 addition & 5 deletions site/formatting.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -336,11 +336,7 @@ const addPostHeader = (cheerioEl: CheerioStatic, post: FormattedPost) => {
ReactDOMServer.renderToStaticMarkup(
<div className="article-meta">
{post.excerpt && <div className="excerpt">{post.excerpt}</div>}
<Byline
authors={post.authors}
withMax={false}
override={post.byline}
/>
<Byline authors={post.authors} override={post.byline} />

<div className="published-updated">
<time>{publishedDate}</time>
Expand Down

0 comments on commit e9d0253

Please sign in to comment.