Skip to content

Export Wordpress #25

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 24 commits into
base: master
Choose a base branch
from
Open

Export Wordpress #25

wants to merge 24 commits into from

Conversation

nyccto-rapicastillo
Copy link
Collaborator

Background

Allows exporting translations to Wordpress .

Two components:

  • Flask endpoint - this endpoint gets triggered to send the request to add a translation in Wordpress
  • Wordpress Plugin - processes the trigger so it can create the translated content.

Sample Flask Request

You would need to run ~/ingestion/ingest-wordpress.py in order to execute this.

POST /wp-export

JSON
{
    "id": 1,
    "lang": "fr",
    "content": "<p>Bonjour le monde! Je suis Rapi Castillo</p>",
    "title": "Bonjour le monde!",
    "excerpt": "Hello this is a french translation xx",
    "status": "publish"
}

TODO

  • Enable update in Wordpress for an already existing translation

liquidsteves and others added 24 commits September 10, 2020 11:48
Use Flask to listen for REST notifications when a wordpress website is updated.
Then pull in the current version of the website posts via standard wordpress
REST api. Write the info out as json in shared_directory/lang directories.
Push to git.
Use Flask to listen for REST notifications when a wordpress website is updated.
Then pull in the current version of the website posts via standard wordpress
REST api. Write the info out as json in shared_directory/lang directories.
Push to git.
Update steve/ingest-wordpress from master
Comment on lines +98 to +110
def post(self):

post_data = request.json
id=post_data.get("id")
lang=post_data.get("lang")
message = {
"content": post_data.get("content"),
"title": post_data.get("title"),
"excerpt": post_data.get("excerpt"),
"status": post_data.get("status")
}

return do_export(id, lang, message)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than receiving the text of the message from a post() parameter, we need to get it from the file system. For instance, here are some examples of spanish (es) output files.
https://github.com/nyc-cto/tms-data/tree/aditya/development/local/source_files/es
I've been using the "wp" prefix to indicate wordpress files. Can you read the json from them?

In our Docker setup, this tms-data git branch gets checked out under /var/tms-data/source_files.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re: actually triggering the code to run -- Ideally we need our Serge wrapper to hit your rest api here. Can you ask Aditya about the best place for the call to happen? If there's no good place to put the hook, we can instead use a celery/cron-ish timer to run your code periodically

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That sounds good. I'll check in with Aditya.

@@ -208,7 +208,7 @@ jobs
# plugin for more information.
data
{
path_matches \/(about|title|description)$
path_matches \/(about|wptitle|content|description)$
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you remove this? You inherited this from my branch, but I took it out.

@@ -0,0 +1,118 @@
<?php
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So are Cyber Command / DoITT ok with us installing this custom code on our wpengine instance? What is the approval process? Do we need to go through an approval process every time we change the code?

If I wanted to add my own custom php function (say, manually building my own simple "webhook" by hitting a hard coded endpoint every time a wordpress post is edited), would that be ok?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, according to @jisaf the process of having this go through Cyber would be more streamlined compared to if we are to use plugins that are not within WPEngine because it's worked by an unapproved third party

@liquidsteves
Copy link
Collaborator

When you rebase against master, ingestion/ingest_wordpress.py will have moved to import_export/import_wordpress.py

Can you make a new file export_wordpress.py and move your py code there?

@jisaf
Copy link
Contributor

jisaf commented Feb 25, 2021

@nyccto-rapicastillo is this PR still valid or should it be closed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants