Skip to content

Commit

Permalink
🧹 remove the remaining wordpress pieces (#3520)
Browse files Browse the repository at this point in the history
Removes all leftovers of wordpress in our grapher codebase

---------

Co-authored-by: Matthieu Bergel <[email protected]>
  • Loading branch information
danyx23 and mlbrgl authored May 8, 2024
1 parent a2a4adb commit 9ba839d
Show file tree
Hide file tree
Showing 142 changed files with 67 additions and 21,878 deletions.
14 changes: 1 addition & 13 deletions .env.example-full
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,6 @@ GRAPHER_TEST_DB_PASS=graphertest
GRAPHER_TEST_DB_HOST=127.0.0.1
GRAPHER_TEST_DB_PORT=3308

WORDPRESS_DB_NAME=wordpress
WORDPRESS_DB_USER=wordpress
WORDPRESS_DB_PASS=wordpress
WORDPRESS_DB_HOST=127.0.0.1
# Should be the same as GRAPHER_DB_PORT in almost all cases
WORDPRESS_DB_PORT=3307

# Enable linkage between grapher and wordpress
WORDPRESS_URL=http://localhost:8080
[email protected]
WORDPRESS_API_PASS=admin

GDOCS_PRIVATE_KEY=''
GDOCS_CLIENT_EMAIL=''
GDOCS_CLIENT_ID=''
Expand All @@ -53,4 +41,4 @@ ALGOLIA_INDEX_PREFIX='' # optional
ALGOLIA_SECRET_KEY='' # optional
ALGOLIA_INDEXING=false # optional

DATA_API_URL='' # optional
DATA_API_URL='' # optional
6 changes: 0 additions & 6 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,6 @@ jest.config.js
knexfile.ts
ormconfig.js
postcss.config.js
wordpress/web/wp/wp-includes/**
wordpress/web/wp/wp-admin/**
wordpress/web/app/plugins/**
wordpress/web/wp/wp-content/**
!wordpress/web/app/plugins/owid/**/*.js
wordpress/vendor/**
packages/@ourworldindata/*/dist/
dist/
.vscode/
5 changes: 0 additions & 5 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,6 @@ itsJustJavascript
package.json
/.storybook/build
coverage
/wordpress/vendor
/wordpress/web/wp
/wordpress/web/app/plugins/*
!/wordpress/web/app/plugins/owid
/wordpress/web/app/uploads
packages/@ourworldindata/*/dist/
dist/
grapherData/
Expand Down
1 change: 0 additions & 1 deletion .rsync-ignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ tmp
*.test.tsx
.queue
.pending
/wordpress
.env
clientSettings.json
serverSettings.json
Expand Down
17 changes: 0 additions & 17 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -111,22 +111,5 @@
"request": "attach",
"restart": true
},
{
"name": "Listen for XDebug",
"type": "php",
"request": "launch",
"port": 9003,
"pathMappings": {
"/app/": "${workspaceFolder}/wordpress"
}
},
{
"name": "Launch currently open script",
"type": "php",
"request": "launch",
"program": "${file}",
"cwd": "${fileDirname}",
"port": 9000
}
]
}
36 changes: 8 additions & 28 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@
"label": "startTscServer",
"type": "shell",
"command": "yarn startTscServer",
"problemMatcher": ["$tsc-watch"],
"problemMatcher": [
"$tsc-watch"
],
"isBackground": true,
"presentation": {
"group": "watch"
Expand All @@ -39,7 +41,11 @@
},
{
"label": "start (remote)",
"dependsOn": ["buildLerna", "startTscServer", "startSiteFront"],
"dependsOn": [
"buildLerna",
"startTscServer",
"startSiteFront"
],
"dependsOrder": "sequence",
"problemMatcher": []
},
Expand All @@ -54,32 +60,6 @@
"dependsOrder": "sequence",
"problemMatcher": []
},
{
"label": "download wordpress database",
"type": "shell",
"command": "./devTools/docker/download-wordpress-mysql.sh"
},
{
"label": "download wordpress uploads",
"type": "shell",
"command": "./devTools/docker/download-wordpress-uploads.sh"
},
{
// This tasks refreshes the wordpress DB as well as wordpress uploads.
// Common scenarios:
// option 1 (default): download new db dump and refresh local db. Download uploads.
// option 2: partial fast refresh (update DB only)
// - comment out "download wordpress uploads" below
"label": "refresh wordpress",
"type": "shell",
"command": "docker compose -f docker-compose.full.yml run --rm db-load-data /app/refresh-wordpress-data.sh",
"dependsOrder": "parallel",
"dependsOn": [
// "download wordpress database"
// "download wordpress uploads"
],
"problemMatcher": []
},
{
"label": "download grapher metadata",
"type": "shell",
Expand Down
39 changes: 7 additions & 32 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,15 @@ help:
@echo ' make down stop any services still running'
@echo ' make refresh (while up) download a new grapher snapshot and update MySQL'
@echo ' make refresh.pageviews (while up) download and load pageviews from the private datasette instance'
@echo ' make refresh.full (while up) run refresh and refresh.pageviews and sync images from R2'
@echo ' make migrate (while up) run any outstanding db migrations'
@echo ' make test run full suite (except db tests) of CI checks including unit tests'
@echo ' make dbtest run db test suite that needs a running mysql db'
@echo ' make svgtest compare current rendering against reference SVGs'
@echo
@echo ' GRAPHER + WORDPRESS (staff-only)'
@echo ' GRAPHER + CLOUDFLARE (staff-only)'
@echo ' make up.full start dev environment via docker-compose and tmux'
@echo ' make down.full stop any services still running'
@echo ' make refresh.wp download a new wordpress snapshot and update MySQL'
@echo ' make refresh.full do a full MySQL update of both wordpress and grapher'
@echo ' make sync-images sync all images from the remote master'
@echo ' make update.chart-entities update the charts_x_entities join table'
@echo ' make reindex reindex (or initialise) search in Algolia'
Expand Down Expand Up @@ -103,19 +102,18 @@ up.devcontainer: create-if-missing.env.devcontainer tmp-downloads/owid_metadata.

up.full: export DEBUG = 'knex:query'

up.full: require create-if-missing.env.full ../owid-content wordpress/.env tmp-downloads/owid_metadata.sql.gz tmp-downloads/live_wordpress.sql.gz wordpress/web/app/uploads/2022
up.full: require create-if-missing.env.full ../owid-content tmp-downloads/owid_metadata.sql.gz
@make validate.env.full
@make check-port-3306

@echo '==> Building grapher'
yarn install
yarn lerna run build
yarn run tsc -b
yarn buildWordpressPlugin

@echo '==> Starting dev environment'
tmux new-session -s grapher \
-n docker 'docker compose -f docker-compose.full.yml up' \; \
-n docker 'docker compose -f docker-compose.grapher.yml up' \; \
set remain-on-exit on \; \
set-option -g default-shell $(SCRIPT_SHELL) \; \
new-window -n admin \
Expand All @@ -138,8 +136,6 @@ migrate:
@echo '==> Running DB migrations'
rm -rf itsJustJavascript && yarn && yarn buildLerna && yarn buildTsc && yarn runDbMigrations

refresh.full: refresh refresh.wp sync-images

refresh:
@echo '==> Downloading chart data'
./devTools/docker/download-grapher-metadata-mysql.sh
Expand All @@ -154,22 +150,13 @@ refresh.pageviews:
@echo '==> Refreshing pageviews'
yarn && yarn buildLerna && yarn buildTsc && yarn refreshPageviews

refresh.wp:
@echo '==> Downloading wordpress data'
./devTools/docker/download-wordpress-mysql.sh

@echo '==> Updating wordpress data'
@. ./.env && DATA_FOLDER=tmp-downloads ./devTools/docker/refresh-wordpress-data.sh

@echo '!!! WARNING !!!'
@echo 'If you run this for staging WP, you have to set !Account password! for'
@echo '[email protected] user to the value from `.env:WORDPRESS_API_PASS`'
@echo 'at https://staging.owid.cloud/wp/wp-admin/user-edit.php?user_id=35'

sync-images: sync-images.preflight-check
@echo '==> Syncing images to R2'
@. ./.env && ./devTools/docker/sync-s3-images.sh

refresh.full: refresh refresh.pageviews sync-images
@echo '==> Full refresh completed'

sync-images.preflight-check:
@echo '==> Checking for rclone'
@which rclone >/dev/null 2>&1 || (echo "ERROR: please install rclone -- e.g. brew install rclone"; exit 1)
Expand Down Expand Up @@ -239,18 +226,6 @@ tmp-downloads/owid_metadata.sql.gz:
@echo '==> Downloading metadata'
./devTools/docker/download-grapher-metadata-mysql.sh

tmp-downloads/live_wordpress.sql.gz:
@echo '==> Downloading wordpress data'
./devTools/docker/download-wordpress-mysql.sh

wordpress/.env:
@echo 'Copying wordpress/.env.example --> wordpress/.env'
@cp -f wordpress/.env.example wordpress/.env

wordpress/web/app/uploads/2022:
@echo '==> Downloading wordpress uploads'
./devTools/docker/download-wordpress-uploads.sh

deploy:
@echo '==> Starting from a clean slate...'
rm -rf itsJustJavascript
Expand Down
14 changes: 2 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,29 +46,19 @@ Each explorer can be configured via a [panel](explorerAdminServer/) in the admin

- A [server-side](adminSiteServer/) project that manages the MySQL database used by graphers.

### [WordPress](wordpress/)

The CMS we use to manage articles published on Our World in Data. It's a relatively stock setup, with a custom plugin to provide additional blocks for the Gutenberg editor.

Our Wordpress content and configuration is stored in a MySQL database, which currently isn't shared publicly.

We are currently in the process of migrating off of WordPress to a publishing flow based on [ArchieML](https://archieml.org) with Google Docs. See the [Site README](site/README.md) for more information.

### [Baker](baker/)

A [PM2](https://github.com/Unitech/pm2) project that builds a static copy of the Our World in Data website by merging the content authored in Wordpress with the grapher charts created in Grapher Admin.
A [PM2](https://github.com/Unitech/pm2) project that builds a static copy of the Our World in Data website by merging the content authored in Gdocs with the grapher charts created in Grapher Admin.

### [Site](site/)

The React code for rendering our content in pages, used by the Grapher Admin and Baker.

As of March 2023, code exists for rendering both WordPress posts and Google Docs as we work on the transition away from WordPress.

## Tooling

Much of our code is based around [reactive programming](https://en.wikipedia.org/wiki/Reactive_programming) using [React](https://reactjs.org/) and [Mobx](http://github.com/mobxjs/mobx).

All non-WordPress code is written in [TypeScript](https://www.typescriptlang.org/).
All code is written in [TypeScript](https://www.typescriptlang.org/).

If you want to enable pre-commit hooks, run `yarn husky`.

Expand Down
9 changes: 0 additions & 9 deletions adminSiteClient/AdminLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,15 +107,6 @@ export class AdminLayout extends React.Component<{
FAQ
</a>
</li>
<li className="nav-item">
<a
className="nav-link"
href="/wp/wp-admin"
target="_blank"
>
Wordpress
</a>
</li>
</ul>
<ul className="navbar-nav ml-auto">
<li className="nav-item">
Expand Down
15 changes: 3 additions & 12 deletions adminSiteClient/PostsIndexPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { AdminLayout } from "./AdminLayout.js"
import { SearchField, FieldsRow, Timeago } from "./Forms.js"
import { EditableTags } from "./EditableTags.js"
import { AdminAppContext, AdminAppContextType } from "./AdminAppContext.js"
import { ADMIN_BASE_URL, WORDPRESS_URL } from "../settings/clientSettings.js"
import { ADMIN_BASE_URL } from "../settings/clientSettings.js"
import { match } from "ts-pattern"

import { FontAwesomeIcon } from "@fortawesome/react-fontawesome/index.js"
Expand All @@ -35,7 +35,7 @@ interface PostIndexMeta {
status: string
authors: string[] | null
slug: string
updatedAtInWordpress: string | null
updated_at_in_wordpress: string | null
tags: DbChartTagJoin[] | null
gdocSuccessorId: string | undefined
gdocSuccessorPublished: boolean
Expand Down Expand Up @@ -220,15 +220,7 @@ class PostRow extends React.Component<PostRowProps> {
/>
</td>
<td>
<Timeago time={post.updatedAtInWordpress} />
</td>
<td>
<a
href={`${WORDPRESS_URL}/wp/wp-admin/post.php?post=${post.id}&action=edit`}
className="btn btn-primary"
>
Edit
</a>
<Timeago time={post.updated_at_in_wordpress} />
</td>
<td>
<a
Expand Down Expand Up @@ -332,7 +324,6 @@ export class PostsIndexPage extends React.Component {
<th>Slug</th>
<th>Tags</th>
<th>Last Updated</th>
<th></th>
<th>WP vs Archie compare view</th>
<th>Gdoc</th>
</tr>
Expand Down
4 changes: 0 additions & 4 deletions adminSiteServer/apiRouter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import * as lodash from "lodash"
import * as db from "../db/db.js"
import { DEPRECATEDgetTopics } from "../db/DEPRECATEDwpdb.js"
import {
UNCATEGORIZED_TAG_ID,
BAKE_ON_CHANGE,
Expand Down Expand Up @@ -606,9 +605,6 @@ getRouteWithROTransaction(
}
)

apiRouter.get("/topics.json", async (req, res) => ({
topics: await DEPRECATEDgetTopics(),
}))
getRouteWithROTransaction(
apiRouter,
"/editorData/variables.json",
Expand Down
24 changes: 0 additions & 24 deletions adminSiteServer/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import {
ENV,
} from "../settings/serverSettings.js"
import * as db from "../db/db.js"
import * as wpdb from "../db/wpdb.js"
import { IndexPage } from "./IndexPage.js"
import {
authCloudflareSSOMiddleware,
Expand Down Expand Up @@ -238,29 +237,6 @@ export class OwidAdminApp {
)
}
}

if (wpdb.isWordpressDBEnabled) {
try {
await wpdb.singleton.connect()
} catch (error) {
if (!this.options.quiet) {
console.error(error)
console.warn(
"Could not connect to Wordpress database. Continuing without Wordpress..."
)
}
}
} else if (!this.options.quiet) {
console.log(
"WORDPRESS_DB_NAME is not configured -- continuing without Wordpress DB"
)
}

if (!wpdb.isWordpressAPIEnabled && !this.options.quiet) {
console.log(
"WORDPRESS_API_URL is not configured -- continuing without Wordpress API"
)
}
}
}

Expand Down
Loading

0 comments on commit 9ba839d

Please sign in to comment.