|
10 months ago | |
---|---|---|
targets | 10 months ago | |
.editorconfig | 1 year ago | |
.gitignore | 10 months ago | |
Pipfile | 11 months ago | |
Pipfile.lock | 11 months ago | |
README.md | 10 months ago | |
licence | 1 year ago | |
main.py | 10 months ago |
README.md
Sync a collection from https://getcockpit.com/ to Wordpress.
Handles the following cases:
change - does it exist create - its new delete - was it deleted
Config
[{
"enabled": true,
"language": "en", // defaults to whatever is cockpits default
"targets": ["wordpress", "devto"],
"cockpit_url": "https://cockpit.YOURSITE.eu",
"cockpit_token": "...",
"cockpit_basicauth": "user:pass",
"cockpit_collection_posts": "Articles",
"cockpit_post_date_field": {
"name": "publishDate",
"format": "%Y-%m-%d" // or "timestamp" for unix timestamp
},
"wordpress": {
"http_timeout": 5, // if you host wordpress on a slow server you may want to increase the timeout
"url": "https://YOURWORDPRESSSITE",
"user": "...",
"pass": "...", // application spesific password
"categories": { // optional map cockpit categorie to wp categories
"somecategory": 1,
"othercategory": 2
}
},
"devto": {
"api_key": "...",
"canonical_base": "https://yoursite.fr" // withot trailing slash (currenlty the slug has to be in the form YYYY/MMM/DDD/your-slug)
}
}]
Post Targets
A post target is a site this tool can sync a post to.
Wordpress
Setup categories
In settings.json create a new section "categories" with the categorie name from cockpit as the key and the id for the coresponding categorie in WP as the value.
To find the value of categories in WP query curl https://YOURWP.fr/wp-json/wp/v2/categories or look at the table wp_terms
in the database.
Markdown supports
- Idented code blocks with (https://facelessuser.github.io/pymdown-extensions/extensions/superfences/)
- Footnotes
- Abbreviations with (https://python-markdown.github.io/extensions/abbreviations/)
- Taskslists with (https://facelessuser.github.io/pymdown-extensions/extensions/tasklist/)
- Tilde with (https://facelessuser.github.io/pymdown-extensions/extensions/tilde/)
- Auto detecting links with (https://facelessuser.github.io/pymdown-extensions/extensions/magiclink/)
- Code hightlighing. Requires additional setup.
Code highligting setup
For code highlighting to work the Pygments CSS file needs to be available on the website. Add this CSS to the website somehow (for example with a plugin) https://raw.githubusercontent.com/rasbt/python_reference/master/tutorials/markdown_syntax_highlighting/codehilite.css
helpful source: https://sebastianraschka.com/Articles/2014_markdown_syntax_color.html
Dev.to
A developer blogging site.
Development
- Clone this repo
pip install pipenv --dev
pipenv install
- Run the code with
pipenv run python3 main.py
- Run tests with
pipenv run pytest