wordpress-markdown-blog-loader 1.1.4__tar.gz → 1.3.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- wordpress_markdown_blog_loader-1.3.0/LICENSE +202 -0
- {wordpress-markdown-blog-loader-1.1.4 → wordpress_markdown_blog_loader-1.3.0}/PKG-INFO +74 -25
- {wordpress-markdown-blog-loader-1.1.4 → wordpress_markdown_blog_loader-1.3.0}/README.md +58 -24
- {wordpress-markdown-blog-loader-1.1.4 → wordpress_markdown_blog_loader-1.3.0}/setup.py +1 -1
- {wordpress-markdown-blog-loader-1.1.4 → wordpress_markdown_blog_loader-1.3.0}/src/wordpress_markdown_blog_loader/api.py +65 -10
- {wordpress-markdown-blog-loader-1.1.4 → wordpress_markdown_blog_loader-1.3.0}/src/wordpress_markdown_blog_loader/blog.py +18 -4
- {wordpress-markdown-blog-loader-1.1.4 → wordpress_markdown_blog_loader-1.3.0}/src/wordpress_markdown_blog_loader/new.py +17 -3
- {wordpress-markdown-blog-loader-1.1.4 → wordpress_markdown_blog_loader-1.3.0}/src/wordpress_markdown_blog_loader.egg-info/PKG-INFO +74 -25
- {wordpress-markdown-blog-loader-1.1.4 → wordpress_markdown_blog_loader-1.3.0}/src/wordpress_markdown_blog_loader.egg-info/SOURCES.txt +1 -0
- {wordpress-markdown-blog-loader-1.1.4 → wordpress_markdown_blog_loader-1.3.0}/setup.cfg +0 -0
- {wordpress-markdown-blog-loader-1.1.4 → wordpress_markdown_blog_loader-1.3.0}/src/wordpress_markdown_blog_loader/__init__.py +0 -0
- {wordpress-markdown-blog-loader-1.1.4 → wordpress_markdown_blog_loader-1.3.0}/src/wordpress_markdown_blog_loader/__main__.py +0 -0
- {wordpress-markdown-blog-loader-1.1.4 → wordpress_markdown_blog_loader-1.3.0}/src/wordpress_markdown_blog_loader/check_links.py +0 -0
- {wordpress-markdown-blog-loader-1.1.4 → wordpress_markdown_blog_loader-1.3.0}/src/wordpress_markdown_blog_loader/download.py +0 -0
- {wordpress-markdown-blog-loader-1.1.4 → wordpress_markdown_blog_loader-1.3.0}/src/wordpress_markdown_blog_loader/name_to_email.py +0 -0
- {wordpress-markdown-blog-loader-1.1.4 → wordpress_markdown_blog_loader-1.3.0}/src/wordpress_markdown_blog_loader/remove_newlines.py +0 -0
- {wordpress-markdown-blog-loader-1.1.4 → wordpress_markdown_blog_loader-1.3.0}/src/wordpress_markdown_blog_loader/upload.py +0 -0
- {wordpress-markdown-blog-loader-1.1.4 → wordpress_markdown_blog_loader-1.3.0}/src/wordpress_markdown_blog_loader.egg-info/dependency_links.txt +0 -0
- {wordpress-markdown-blog-loader-1.1.4 → wordpress_markdown_blog_loader-1.3.0}/src/wordpress_markdown_blog_loader.egg-info/entry_points.txt +0 -0
- {wordpress-markdown-blog-loader-1.1.4 → wordpress_markdown_blog_loader-1.3.0}/src/wordpress_markdown_blog_loader.egg-info/not-zip-safe +0 -0
- {wordpress-markdown-blog-loader-1.1.4 → wordpress_markdown_blog_loader-1.3.0}/src/wordpress_markdown_blog_loader.egg-info/requires.txt +0 -0
- {wordpress-markdown-blog-loader-1.1.4 → wordpress_markdown_blog_loader-1.3.0}/src/wordpress_markdown_blog_loader.egg-info/top_level.txt +0 -0
- {wordpress-markdown-blog-loader-1.1.4 → wordpress_markdown_blog_loader-1.3.0}/tests/test_blog.py +0 -0
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "{}"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2020 - Binx.io B.V.
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
|
202
|
+
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: wordpress-markdown-blog-loader
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.3.0
|
|
4
4
|
Summary: load markdown blogs into wordpress
|
|
5
5
|
Home-page: https://github.com/binxio/wordpress-markdown-blog-loader
|
|
6
6
|
Author: Mark van Holsteijn
|
|
@@ -18,6 +18,21 @@ Classifier: Operating System :: Microsoft :: Windows
|
|
|
18
18
|
Classifier: Programming Language :: Python :: 3
|
|
19
19
|
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
20
20
|
Description-Content-Type: text/markdown
|
|
21
|
+
License-File: LICENSE
|
|
22
|
+
Requires-Dist: requests
|
|
23
|
+
Requires-Dist: markdown
|
|
24
|
+
Requires-Dist: python-frontmatter
|
|
25
|
+
Requires-Dist: click
|
|
26
|
+
Requires-Dist: pytz
|
|
27
|
+
Requires-Dist: Pillow
|
|
28
|
+
Requires-Dist: binx-og-image-generator>=1.2.5
|
|
29
|
+
Requires-Dist: markdownify
|
|
30
|
+
Requires-Dist: bs4
|
|
31
|
+
Requires-Dist: html5lib
|
|
32
|
+
Requires-Dist: lxml
|
|
33
|
+
Requires-Dist: python-slugify
|
|
34
|
+
Requires-Dist: unidecode
|
|
35
|
+
Requires-Dist: stopwords
|
|
21
36
|
|
|
22
37
|
# wordpress-markdown-blog-loader
|
|
23
38
|
This utility loads markdown blogs into Wordpress as a post. It allows you to work on your blog
|
|
@@ -58,35 +73,39 @@ host = xebia.com
|
|
|
58
73
|
|
|
59
74
|
[xebia.com]
|
|
60
75
|
username = <your wordpress username>
|
|
61
|
-
password = <your application password>
|
|
62
76
|
```
|
|
63
|
-
Note that the application password is different from the password you use to login to your WordPress installation.
|
|
64
77
|
|
|
78
|
+
## api host
|
|
65
79
|
If the site is served through a CDN, you can also set the `api_host` which will be used as the hostname to invoke the WP REST API.
|
|
66
80
|
|
|
81
|
+
## password
|
|
82
|
+
To authenticate you need an [application password](https://wordpress.com/support/security/two-step-authentication/application-specific-passwords/), which is different from the user password.
|
|
83
|
+
|
|
84
|
+
We recommend to store your application password in 1password and set the environment variable
|
|
85
|
+
WP_APP_PASSWORD using the [1password CLI](https://developer.1password.com/docs/cli):
|
|
86
|
+
|
|
87
|
+
```shell
|
|
88
|
+
WP_APP_PASSWORD="$(op read "op://Private/wordpress app password/password")" wp-md ...
|
|
89
|
+
```
|
|
90
|
+
|
|
67
91
|
## Never touch the WP editor again
|
|
68
92
|
|
|
69
93
|
Once you start to manage your blogs via this uploader, *do not edit* the blog via one of the WP editors. The editors are weird,
|
|
70
94
|
because it appears to make a copy of the content on which you get a WYSIWIG viewer. Unfortunately, it does not detect changes
|
|
71
95
|
in the actual blog content. It will look like your uploaded changes are not applied (but they are).
|
|
72
96
|
|
|
73
|
-
## Using the image
|
|
74
|
-
To use the docker image, you have to login using a GitHub container registry access token:
|
|
75
|
-
|
|
76
|
-
1. Browse to https://github.com/settings/tokens
|
|
77
|
-
2. Create new token with 'read:packages' permission
|
|
78
|
-
3. Copy the token
|
|
79
|
-
4. login to ghcr.io with Docker.
|
|
80
|
-
|
|
81
|
-
`pbpaste | docker login ghcr.io -u <github username> --password-stdin`
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
## set an alias
|
|
97
|
+
## Using the docker image
|
|
85
98
|
To use the docker image as a command line utility, create the following alias:
|
|
86
99
|
|
|
87
100
|
```bash
|
|
88
|
-
alias wp-md='docker run
|
|
101
|
+
alias wp-md='docker run
|
|
102
|
+
-e WP_APP_PASSWORD=$("$(op read "op://Private/wordpress app password/password")")
|
|
103
|
+
-v $HOME:$HOME
|
|
104
|
+
-v $HOME/.wordpress.ini:/root/.wordpress.ini
|
|
105
|
+
-v $PWD:/$PWD
|
|
106
|
+
-w $PWD ghcr.io/binxio/wordpress-markdown-blog-loader:1.3.0
|
|
89
107
|
```
|
|
108
|
+
Assuming that your WordPress app password is stored in the 1password Private vault under the name `wordpress app password`
|
|
90
109
|
|
|
91
110
|
## start a new blog
|
|
92
111
|
To start a new blog, type:
|
|
@@ -96,7 +115,8 @@ $ wp-md posts new \
|
|
|
96
115
|
--title "How to create a WordPress blog without touching WordPress" \
|
|
97
116
|
--subtitle "using the wp-md utility" \
|
|
98
117
|
--author "Mark van Holsteijn" \
|
|
99
|
-
--image ~/Downloads/background-image.jpg
|
|
118
|
+
--image ~/Downloads/background-image.jpg \
|
|
119
|
+
--image-credits "image by xyz"
|
|
100
120
|
INFO: resizing 1920x1920 to 1200x1200
|
|
101
121
|
INFO: cropping to maximum height of 630px
|
|
102
122
|
INFO: start editing index.md in ./how-to-create-a-wordpress-blog-without-touching-wordpress
|
|
@@ -104,6 +124,28 @@ INFO: start editing index.md in ./how-to-create-a-wordpress-blog-without-touchin
|
|
|
104
124
|
|
|
105
125
|
A skaffold frontmatter blog is created, and you can start writing in the index.md.
|
|
106
126
|
|
|
127
|
+
## frontmatter properties
|
|
128
|
+
You can set the following properties in the frontmatter:
|
|
129
|
+
|
|
130
|
+
| Name | description |
|
|
131
|
+
|----------------|-------------------------------------------------------------------------|
|
|
132
|
+
| title | of the blog |
|
|
133
|
+
| subtitle | of the blog, used in the og.image |
|
|
134
|
+
| focus-keywords | the SEO focus keywords
|
|
135
|
+
| excerpt | excerpt of the blog |
|
|
136
|
+
| author | display name of the author in Wordpress |
|
|
137
|
+
| categories | list of wordpress categories for this blog |
|
|
138
|
+
| slug | slug of the blog |
|
|
139
|
+
| date | on which the blog should be published ISO timestamp format |
|
|
140
|
+
| status | draft or publish. if publish, the blog will be published on the `date` |
|
|
141
|
+
| canonical | url of the blog, to be used in cross posts |
|
|
142
|
+
| image | the banner image of the blog |
|
|
143
|
+
| og.image | the open graph image of the blog, used in links from social media |
|
|
144
|
+
| og.description | the open graph description of the blog, used in links from social media |
|
|
145
|
+
| guid | the physical URL of the blog. Written by wp-md on upload and download |
|
|
146
|
+
| brand | xebia.com or xebia.com. defaults to xebia.com |
|
|
147
|
+
|
|
148
|
+
|
|
107
149
|
## adding images
|
|
108
150
|
To add an image to your blog, add the images in the ./images subdirectory and add a relative reference in markdown. For instance:
|
|
109
151
|
|
|
@@ -115,7 +157,7 @@ To add an image to your blog, add the images in the ./images subdirectory and ad
|
|
|
115
157
|
To upload a blog, type:
|
|
116
158
|
|
|
117
159
|
```
|
|
118
|
-
$ wp-md posts upload --host
|
|
160
|
+
$ wp-md posts upload --host xebia.com .
|
|
119
161
|
INFO: generating og:image based on images/banner.jpg
|
|
120
162
|
INFO: generating new image in how-to-create-a-wordpress-blog-without-touching-wordpress/images/og-banner.jpg
|
|
121
163
|
INFO: add logo
|
|
@@ -123,9 +165,9 @@ INFO: add title
|
|
|
123
165
|
INFO: add subtitle
|
|
124
166
|
INFO: add author
|
|
125
167
|
INFO: og image saved to how-to-create-a-wordpress-blog-without-touching-wordpress/images/og-banner.jpg
|
|
126
|
-
INFO: uploaded blog 'How to create a WordPress blog without touching WordPress' as post https://
|
|
127
|
-
INFO: updating opengraph image to https://
|
|
128
|
-
INFO: post available at https://
|
|
168
|
+
INFO: uploaded blog 'How to create a WordPress blog without touching WordPress' as post https://xebia.com/?p=9625
|
|
169
|
+
INFO: updating opengraph image to https://xebia.com/wp-content/uploads/2023/01/how-to-create-a-wordpress-blog-without-touching-wordpress-og-banner.jpg
|
|
170
|
+
INFO: post available at https://xebia.com/?p=9625
|
|
129
171
|
INFO: uploading image as how-to-create-a-wordpress-blog-without-touching-wordpress-og-banner.jpg
|
|
130
172
|
INFO: uploading image as how-to-create-a-wordpress-blog-without-touching-wordpress-banner.jpg
|
|
131
173
|
```
|
|
@@ -135,16 +177,23 @@ You can update the blog, by uploading it again. If you change the status to 'pu
|
|
|
135
177
|
the blog will be published on the specified date.
|
|
136
178
|
|
|
137
179
|
```
|
|
138
|
-
$ wp-md posts upload --host
|
|
180
|
+
$ wp-md posts upload --host xebia.com .
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
## updating banner and open graph images
|
|
184
|
+
You can update the banner and open graph images as follows:
|
|
185
|
+
|
|
186
|
+
```
|
|
187
|
+
$ wp-md posts update-banner . new-banner.jpg
|
|
139
188
|
```
|
|
140
189
|
|
|
141
190
|
## downloading an existing blog
|
|
142
191
|
to download an existing blog and convert it to markdown, type:
|
|
143
192
|
|
|
144
193
|
```
|
|
145
|
-
$ wp-md posts download --host
|
|
146
|
-
INFO: downloading https://
|
|
147
|
-
INFO: downloading https://
|
|
194
|
+
$ wp-md posts download --host xebia.com --directory /tmp 9625
|
|
195
|
+
INFO: downloading https://xebia.com/wp-content/uploads/2023/01/how-to-create-a-wordpress-blog-without-touching-wordpress-banner.jpg as banner.jpg
|
|
196
|
+
INFO: downloading https://xebia.com/wp-content/uploads/2023/01/how-to-create-a-wordpress-blog-without-touching-wordpress-og-banner.jpg as og-banner.jpg
|
|
148
197
|
INFO: writing /tmp/2023/01/how-to-create-a-wordpress-blog-without-touching-wordpress/index.md
|
|
149
198
|
```
|
|
150
199
|
|
|
@@ -37,35 +37,39 @@ host = xebia.com
|
|
|
37
37
|
|
|
38
38
|
[xebia.com]
|
|
39
39
|
username = <your wordpress username>
|
|
40
|
-
password = <your application password>
|
|
41
40
|
```
|
|
42
|
-
Note that the application password is different from the password you use to login to your WordPress installation.
|
|
43
41
|
|
|
42
|
+
## api host
|
|
44
43
|
If the site is served through a CDN, you can also set the `api_host` which will be used as the hostname to invoke the WP REST API.
|
|
45
44
|
|
|
45
|
+
## password
|
|
46
|
+
To authenticate you need an [application password](https://wordpress.com/support/security/two-step-authentication/application-specific-passwords/), which is different from the user password.
|
|
47
|
+
|
|
48
|
+
We recommend to store your application password in 1password and set the environment variable
|
|
49
|
+
WP_APP_PASSWORD using the [1password CLI](https://developer.1password.com/docs/cli):
|
|
50
|
+
|
|
51
|
+
```shell
|
|
52
|
+
WP_APP_PASSWORD="$(op read "op://Private/wordpress app password/password")" wp-md ...
|
|
53
|
+
```
|
|
54
|
+
|
|
46
55
|
## Never touch the WP editor again
|
|
47
56
|
|
|
48
57
|
Once you start to manage your blogs via this uploader, *do not edit* the blog via one of the WP editors. The editors are weird,
|
|
49
58
|
because it appears to make a copy of the content on which you get a WYSIWIG viewer. Unfortunately, it does not detect changes
|
|
50
59
|
in the actual blog content. It will look like your uploaded changes are not applied (but they are).
|
|
51
60
|
|
|
52
|
-
## Using the image
|
|
53
|
-
To use the docker image, you have to login using a GitHub container registry access token:
|
|
54
|
-
|
|
55
|
-
1. Browse to https://github.com/settings/tokens
|
|
56
|
-
2. Create new token with 'read:packages' permission
|
|
57
|
-
3. Copy the token
|
|
58
|
-
4. login to ghcr.io with Docker.
|
|
59
|
-
|
|
60
|
-
`pbpaste | docker login ghcr.io -u <github username> --password-stdin`
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
## set an alias
|
|
61
|
+
## Using the docker image
|
|
64
62
|
To use the docker image as a command line utility, create the following alias:
|
|
65
63
|
|
|
66
64
|
```bash
|
|
67
|
-
alias wp-md='docker run
|
|
65
|
+
alias wp-md='docker run
|
|
66
|
+
-e WP_APP_PASSWORD=$("$(op read "op://Private/wordpress app password/password")")
|
|
67
|
+
-v $HOME:$HOME
|
|
68
|
+
-v $HOME/.wordpress.ini:/root/.wordpress.ini
|
|
69
|
+
-v $PWD:/$PWD
|
|
70
|
+
-w $PWD ghcr.io/binxio/wordpress-markdown-blog-loader:1.3.0
|
|
68
71
|
```
|
|
72
|
+
Assuming that your WordPress app password is stored in the 1password Private vault under the name `wordpress app password`
|
|
69
73
|
|
|
70
74
|
## start a new blog
|
|
71
75
|
To start a new blog, type:
|
|
@@ -75,7 +79,8 @@ $ wp-md posts new \
|
|
|
75
79
|
--title "How to create a WordPress blog without touching WordPress" \
|
|
76
80
|
--subtitle "using the wp-md utility" \
|
|
77
81
|
--author "Mark van Holsteijn" \
|
|
78
|
-
--image ~/Downloads/background-image.jpg
|
|
82
|
+
--image ~/Downloads/background-image.jpg \
|
|
83
|
+
--image-credits "image by xyz"
|
|
79
84
|
INFO: resizing 1920x1920 to 1200x1200
|
|
80
85
|
INFO: cropping to maximum height of 630px
|
|
81
86
|
INFO: start editing index.md in ./how-to-create-a-wordpress-blog-without-touching-wordpress
|
|
@@ -83,6 +88,28 @@ INFO: start editing index.md in ./how-to-create-a-wordpress-blog-without-touchin
|
|
|
83
88
|
|
|
84
89
|
A skaffold frontmatter blog is created, and you can start writing in the index.md.
|
|
85
90
|
|
|
91
|
+
## frontmatter properties
|
|
92
|
+
You can set the following properties in the frontmatter:
|
|
93
|
+
|
|
94
|
+
| Name | description |
|
|
95
|
+
|----------------|-------------------------------------------------------------------------|
|
|
96
|
+
| title | of the blog |
|
|
97
|
+
| subtitle | of the blog, used in the og.image |
|
|
98
|
+
| focus-keywords | the SEO focus keywords
|
|
99
|
+
| excerpt | excerpt of the blog |
|
|
100
|
+
| author | display name of the author in Wordpress |
|
|
101
|
+
| categories | list of wordpress categories for this blog |
|
|
102
|
+
| slug | slug of the blog |
|
|
103
|
+
| date | on which the blog should be published ISO timestamp format |
|
|
104
|
+
| status | draft or publish. if publish, the blog will be published on the `date` |
|
|
105
|
+
| canonical | url of the blog, to be used in cross posts |
|
|
106
|
+
| image | the banner image of the blog |
|
|
107
|
+
| og.image | the open graph image of the blog, used in links from social media |
|
|
108
|
+
| og.description | the open graph description of the blog, used in links from social media |
|
|
109
|
+
| guid | the physical URL of the blog. Written by wp-md on upload and download |
|
|
110
|
+
| brand | xebia.com or xebia.com. defaults to xebia.com |
|
|
111
|
+
|
|
112
|
+
|
|
86
113
|
## adding images
|
|
87
114
|
To add an image to your blog, add the images in the ./images subdirectory and add a relative reference in markdown. For instance:
|
|
88
115
|
|
|
@@ -94,7 +121,7 @@ To add an image to your blog, add the images in the ./images subdirectory and ad
|
|
|
94
121
|
To upload a blog, type:
|
|
95
122
|
|
|
96
123
|
```
|
|
97
|
-
$ wp-md posts upload --host
|
|
124
|
+
$ wp-md posts upload --host xebia.com .
|
|
98
125
|
INFO: generating og:image based on images/banner.jpg
|
|
99
126
|
INFO: generating new image in how-to-create-a-wordpress-blog-without-touching-wordpress/images/og-banner.jpg
|
|
100
127
|
INFO: add logo
|
|
@@ -102,9 +129,9 @@ INFO: add title
|
|
|
102
129
|
INFO: add subtitle
|
|
103
130
|
INFO: add author
|
|
104
131
|
INFO: og image saved to how-to-create-a-wordpress-blog-without-touching-wordpress/images/og-banner.jpg
|
|
105
|
-
INFO: uploaded blog 'How to create a WordPress blog without touching WordPress' as post https://
|
|
106
|
-
INFO: updating opengraph image to https://
|
|
107
|
-
INFO: post available at https://
|
|
132
|
+
INFO: uploaded blog 'How to create a WordPress blog without touching WordPress' as post https://xebia.com/?p=9625
|
|
133
|
+
INFO: updating opengraph image to https://xebia.com/wp-content/uploads/2023/01/how-to-create-a-wordpress-blog-without-touching-wordpress-og-banner.jpg
|
|
134
|
+
INFO: post available at https://xebia.com/?p=9625
|
|
108
135
|
INFO: uploading image as how-to-create-a-wordpress-blog-without-touching-wordpress-og-banner.jpg
|
|
109
136
|
INFO: uploading image as how-to-create-a-wordpress-blog-without-touching-wordpress-banner.jpg
|
|
110
137
|
```
|
|
@@ -114,16 +141,23 @@ You can update the blog, by uploading it again. If you change the status to 'pu
|
|
|
114
141
|
the blog will be published on the specified date.
|
|
115
142
|
|
|
116
143
|
```
|
|
117
|
-
$ wp-md posts upload --host
|
|
144
|
+
$ wp-md posts upload --host xebia.com .
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
## updating banner and open graph images
|
|
148
|
+
You can update the banner and open graph images as follows:
|
|
149
|
+
|
|
150
|
+
```
|
|
151
|
+
$ wp-md posts update-banner . new-banner.jpg
|
|
118
152
|
```
|
|
119
153
|
|
|
120
154
|
## downloading an existing blog
|
|
121
155
|
to download an existing blog and convert it to markdown, type:
|
|
122
156
|
|
|
123
157
|
```
|
|
124
|
-
$ wp-md posts download --host
|
|
125
|
-
INFO: downloading https://
|
|
126
|
-
INFO: downloading https://
|
|
158
|
+
$ wp-md posts download --host xebia.com --directory /tmp 9625
|
|
159
|
+
INFO: downloading https://xebia.com/wp-content/uploads/2023/01/how-to-create-a-wordpress-blog-without-touching-wordpress-banner.jpg as banner.jpg
|
|
160
|
+
INFO: downloading https://xebia.com/wp-content/uploads/2023/01/how-to-create-a-wordpress-blog-without-touching-wordpress-og-banner.jpg as og-banner.jpg
|
|
127
161
|
INFO: writing /tmp/2023/01/how-to-create-a-wordpress-blog-without-touching-wordpress/index.md
|
|
128
162
|
```
|
|
129
163
|
|
|
@@ -27,7 +27,7 @@ with open(path.join(this_directory, "README.md"), encoding="utf-8") as f:
|
|
|
27
27
|
|
|
28
28
|
setup(
|
|
29
29
|
name="wordpress-markdown-blog-loader",
|
|
30
|
-
version="1.
|
|
30
|
+
version="1.3.0",
|
|
31
31
|
url="https://github.com/binxio/wordpress-markdown-blog-loader",
|
|
32
32
|
license="APL2",
|
|
33
33
|
author="Mark van Holsteijn",
|
|
@@ -1,19 +1,18 @@
|
|
|
1
1
|
import configparser
|
|
2
2
|
import logging
|
|
3
|
+
import mimetypes
|
|
4
|
+
import os
|
|
5
|
+
import re
|
|
3
6
|
from datetime import datetime
|
|
4
|
-
from
|
|
7
|
+
from functools import cache
|
|
5
8
|
from os.path import expanduser
|
|
6
9
|
from pathlib import Path
|
|
7
10
|
from typing import List, Dict, Iterator
|
|
8
11
|
from typing import Optional, Union
|
|
9
12
|
from urllib.parse import urlparse, ParseResult
|
|
10
|
-
import mimetypes
|
|
11
|
-
import numpy
|
|
12
|
-
|
|
13
13
|
|
|
14
14
|
import pytz
|
|
15
15
|
import requests
|
|
16
|
-
from PIL import Image
|
|
17
16
|
|
|
18
17
|
|
|
19
18
|
def get_default_host() -> Optional[str]:
|
|
@@ -24,6 +23,31 @@ def get_default_host() -> Optional[str]:
|
|
|
24
23
|
config.read(expanduser("~/.wordpress.ini"))
|
|
25
24
|
return config.defaults().get("host")
|
|
26
25
|
|
|
26
|
+
def get_password(host: str) -> Optional[str]:
|
|
27
|
+
"""
|
|
28
|
+
Returns a password from the environment variable for the specified host.
|
|
29
|
+
|
|
30
|
+
The default environment variable is WP_APP_PASSWORD. A password for a specific host can be
|
|
31
|
+
specified by setting an environment variable WP_APP_PASSWORD_<host> where
|
|
32
|
+
the host name is all uppercase and non characters and digits replaced with _.
|
|
33
|
+
|
|
34
|
+
If not set, None is returned.
|
|
35
|
+
|
|
36
|
+
>>> os.environ["WP_APP_PASSWORD_XEBIA_COM"] = "host_password"
|
|
37
|
+
>>> get_password('xebia.com')
|
|
38
|
+
'host_password'
|
|
39
|
+
>>> get_password('binx.io') is None
|
|
40
|
+
True
|
|
41
|
+
>>> os.environ["WP_APP_PASSWORD"] = "default_password"
|
|
42
|
+
>>> get_password('binx.io')
|
|
43
|
+
'default_password'
|
|
44
|
+
"""
|
|
45
|
+
h = re.sub(r"[^a-zA-Z-0-9]", "_", host).upper()
|
|
46
|
+
if result := os.getenv(f"WP_APP_PASSWORD_{h}"):
|
|
47
|
+
return result
|
|
48
|
+
|
|
49
|
+
return os.getenv("WP_APP_PASSWORD")
|
|
50
|
+
|
|
27
51
|
|
|
28
52
|
class WordpressEndpoint:
|
|
29
53
|
def __init__(self, **kwargs):
|
|
@@ -44,8 +68,12 @@ class WordpressEndpoint:
|
|
|
44
68
|
|
|
45
69
|
self.api_host = config.get(host, "api_host", fallback=self.host)
|
|
46
70
|
self.url = f"https://{self.api_host}/wp-json/wp/v2"
|
|
71
|
+
|
|
47
72
|
self.username = config.get(host, "username")
|
|
48
|
-
self.password =
|
|
73
|
+
self.password = get_password(host)
|
|
74
|
+
if not self.password:
|
|
75
|
+
logging.warning("taking plain text app password from configuration file, use WP_APP_PASSWORD environment variable instead!")
|
|
76
|
+
self.password = config.get(host, "password")
|
|
49
77
|
|
|
50
78
|
def is_host_for(self, url: Union[str, ParseResult]) -> bool:
|
|
51
79
|
result = url if isinstance(url, ParseResult) else urlparse(url)
|
|
@@ -165,6 +193,10 @@ class Post(dict):
|
|
|
165
193
|
def categories(self) -> list[id]:
|
|
166
194
|
return self.get("categories", [])
|
|
167
195
|
|
|
196
|
+
@property
|
|
197
|
+
def tags(self) -> list[int]:
|
|
198
|
+
return self.get("tags", [])
|
|
199
|
+
|
|
168
200
|
@property
|
|
169
201
|
def author(self) -> int:
|
|
170
202
|
return self["author"]
|
|
@@ -232,7 +264,6 @@ class Wordpress(object):
|
|
|
232
264
|
self.endpoint = WordpressEndpoint.load(host)
|
|
233
265
|
|
|
234
266
|
self._media: List[Medium] = {}
|
|
235
|
-
self._categories: Dict[str, int] = {}
|
|
236
267
|
self.headers = {
|
|
237
268
|
"accept": "application/json",
|
|
238
269
|
"User-Agent": "Wordpress markdown blog loader - Python",
|
|
@@ -337,10 +368,24 @@ class Wordpress(object):
|
|
|
337
368
|
return self._media
|
|
338
369
|
|
|
339
370
|
@property
|
|
371
|
+
@cache
|
|
340
372
|
def categories(self) -> Dict[str, int]:
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
373
|
+
return {c["slug"]: c["id"] for c in self.get_all("categories")}
|
|
374
|
+
@property
|
|
375
|
+
@cache
|
|
376
|
+
def categories_by_id(self) -> Dict[int, str]:
|
|
377
|
+
return {id: slug for slug,id in self.categories.items()}
|
|
378
|
+
|
|
379
|
+
@property
|
|
380
|
+
@cache
|
|
381
|
+
def tags(self) -> Dict[str, int]:
|
|
382
|
+
return {c["slug"]: c["id"] for c in self.get_all("tags")}
|
|
383
|
+
|
|
384
|
+
@property
|
|
385
|
+
@cache
|
|
386
|
+
def tags_by_id(self) -> Dict[int, str]:
|
|
387
|
+
return {id: slug for slug, id in self.tags.items()}
|
|
388
|
+
|
|
344
389
|
|
|
345
390
|
def search_for_image_by_slug(self, slug) -> Optional[Medium]:
|
|
346
391
|
response = self.session.get(
|
|
@@ -489,3 +534,13 @@ class Wordpress(object):
|
|
|
489
534
|
category, ",\n ".join(self.categories.keys())
|
|
490
535
|
)
|
|
491
536
|
)
|
|
537
|
+
|
|
538
|
+
def get_tag_id_by_name(self, tag: str) -> str:
|
|
539
|
+
if tag in self.tags:
|
|
540
|
+
return self.tags[tag]
|
|
541
|
+
|
|
542
|
+
raise ValueError(
|
|
543
|
+
"invalid tag '{}' try one of\n {}".format(
|
|
544
|
+
tag, ",\n ".join(self.tags.keys())
|
|
545
|
+
)
|
|
546
|
+
)
|
|
@@ -188,6 +188,14 @@ class Blog(object):
|
|
|
188
188
|
def categories(self, categories: list[str]):
|
|
189
189
|
self.blog.metadata["categories"] = categories
|
|
190
190
|
|
|
191
|
+
@property
|
|
192
|
+
def tags(self):
|
|
193
|
+
return self.blog.metadata.get("tags", [])
|
|
194
|
+
|
|
195
|
+
@tags.setter
|
|
196
|
+
def tags(self, tags: list[str]):
|
|
197
|
+
self.blog.metadata["tags"] = tags
|
|
198
|
+
|
|
191
199
|
@property
|
|
192
200
|
def guid(self):
|
|
193
201
|
return self.blog.metadata.get("guid")
|
|
@@ -357,6 +365,7 @@ class Blog(object):
|
|
|
357
365
|
"status": self.status,
|
|
358
366
|
"author": author.id,
|
|
359
367
|
"categories": [wp.get_category_id_by_name(c) for c in self.categories],
|
|
368
|
+
"tags": [wp.get_tag_id_by_name(c) for c in self.tags],
|
|
360
369
|
"acf": {"show_header_image": bool(self.image)},
|
|
361
370
|
}
|
|
362
371
|
|
|
@@ -369,7 +378,12 @@ class Blog(object):
|
|
|
369
378
|
)
|
|
370
379
|
|
|
371
380
|
metadesc = self.og_description if self.og_description else self.excerpt
|
|
372
|
-
result["meta"] = {
|
|
381
|
+
result["meta"] = {
|
|
382
|
+
"yoast_wpseo_metadesc": metadesc,
|
|
383
|
+
"yoast_wpseo_opengraph-description": metadesc,
|
|
384
|
+
"yoast_wpseo_twitter-description": metadesc,
|
|
385
|
+
}
|
|
386
|
+
|
|
373
387
|
if self.canonical:
|
|
374
388
|
result["meta"]["yoast_wpseo_canonical"] = self.canonical
|
|
375
389
|
|
|
@@ -385,8 +399,6 @@ class Blog(object):
|
|
|
385
399
|
"""
|
|
386
400
|
convert a Wordpress post to a FrontMatter post
|
|
387
401
|
"""
|
|
388
|
-
categories = {id: name for name, id in wordpress.categories.items()}
|
|
389
|
-
|
|
390
402
|
blog = Blog()
|
|
391
403
|
blog.dir = (
|
|
392
404
|
Path(base_directory)
|
|
@@ -402,7 +414,9 @@ class Blog(object):
|
|
|
402
414
|
blog.title = post.title
|
|
403
415
|
blog.author = wordpress.get_user_by_id(post.author).name
|
|
404
416
|
blog.guid = post.guid
|
|
405
|
-
blog.categories = [
|
|
417
|
+
blog.categories = [wordpress.categories_by_id[c] for c in post.categories]
|
|
418
|
+
if post.tags:
|
|
419
|
+
blog.tags = [wordpress.tags_by_id[t] for t in post.tags]
|
|
406
420
|
blog.date = post.date
|
|
407
421
|
blog.slug = post.slug
|
|
408
422
|
blog.status = post.status
|
|
@@ -41,6 +41,7 @@ class ImageType(click.ParamType):
|
|
|
41
41
|
@click.option("--author", required=True, help="of the blog")
|
|
42
42
|
@click.option("--email", required=False, help="of the author")
|
|
43
43
|
@click.option("--image", required=False, type=ImageType(), help="for the banner")
|
|
44
|
+
@click.option("--image-credits", required=False, type=str, help="for the used image")
|
|
44
45
|
@click.option(
|
|
45
46
|
"--brand",
|
|
46
47
|
type=click.Choice(["xebia.com", "binx.io"]),
|
|
@@ -48,7 +49,7 @@ class ImageType(click.ParamType):
|
|
|
48
49
|
default="xebia.com",
|
|
49
50
|
help="of the banner",
|
|
50
51
|
)
|
|
51
|
-
def command(title, subtitle, author, image, brand, email):
|
|
52
|
+
def command(title, subtitle, author, image, brand, email, image_credits):
|
|
52
53
|
"""
|
|
53
54
|
a new frontmatter blog
|
|
54
55
|
|
|
@@ -65,8 +66,8 @@ def command(title, subtitle, author, image, brand, email):
|
|
|
65
66
|
blog = Blog()
|
|
66
67
|
blog.dir = directory
|
|
67
68
|
blog.path = directory.joinpath("index.md")
|
|
68
|
-
blog.title = title
|
|
69
|
-
blog.subtitle = subtitle
|
|
69
|
+
blog.title = title.strip()
|
|
70
|
+
blog.subtitle = subtitle.strip()
|
|
70
71
|
blog.focus_keywords = " ".join(stopwords.clean(title.lower().split(), "en"))
|
|
71
72
|
blog.status = "draft"
|
|
72
73
|
blog.slug = slug
|
|
@@ -76,9 +77,22 @@ def command(title, subtitle, author, image, brand, email):
|
|
|
76
77
|
blog.date = (datetime.now().astimezone() + timedelta(days=7)).replace(
|
|
77
78
|
hour=0, minute=0, second=0, microsecond=0
|
|
78
79
|
)
|
|
80
|
+
|
|
81
|
+
if not blog.title:
|
|
82
|
+
click.echo("a title is required", err=True)
|
|
83
|
+
exit(1)
|
|
84
|
+
|
|
79
85
|
if image:
|
|
80
86
|
image_path = save_og_image(image, directory.joinpath("images/banner"))
|
|
81
87
|
blog.image = image_path.relative_to(directory).as_posix()
|
|
88
|
+
|
|
89
|
+
blog.og_description = (
|
|
90
|
+
blog.title.lstrip().lower()[0]
|
|
91
|
+
+ blog.title[1:]
|
|
92
|
+
+ (", " + blog.subtitle if blog.subtitle else "")
|
|
93
|
+
)
|
|
94
|
+
if image_credits:
|
|
95
|
+
blog.content = f"\n\n___\n{image_credits}"
|
|
82
96
|
blog.save()
|
|
83
97
|
logging.info("start editing index.md in %s", blog.dir)
|
|
84
98
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: wordpress-markdown-blog-loader
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.3.0
|
|
4
4
|
Summary: load markdown blogs into wordpress
|
|
5
5
|
Home-page: https://github.com/binxio/wordpress-markdown-blog-loader
|
|
6
6
|
Author: Mark van Holsteijn
|
|
@@ -18,6 +18,21 @@ Classifier: Operating System :: Microsoft :: Windows
|
|
|
18
18
|
Classifier: Programming Language :: Python :: 3
|
|
19
19
|
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
20
20
|
Description-Content-Type: text/markdown
|
|
21
|
+
License-File: LICENSE
|
|
22
|
+
Requires-Dist: requests
|
|
23
|
+
Requires-Dist: markdown
|
|
24
|
+
Requires-Dist: python-frontmatter
|
|
25
|
+
Requires-Dist: click
|
|
26
|
+
Requires-Dist: pytz
|
|
27
|
+
Requires-Dist: Pillow
|
|
28
|
+
Requires-Dist: binx-og-image-generator>=1.2.5
|
|
29
|
+
Requires-Dist: markdownify
|
|
30
|
+
Requires-Dist: bs4
|
|
31
|
+
Requires-Dist: html5lib
|
|
32
|
+
Requires-Dist: lxml
|
|
33
|
+
Requires-Dist: python-slugify
|
|
34
|
+
Requires-Dist: unidecode
|
|
35
|
+
Requires-Dist: stopwords
|
|
21
36
|
|
|
22
37
|
# wordpress-markdown-blog-loader
|
|
23
38
|
This utility loads markdown blogs into Wordpress as a post. It allows you to work on your blog
|
|
@@ -58,35 +73,39 @@ host = xebia.com
|
|
|
58
73
|
|
|
59
74
|
[xebia.com]
|
|
60
75
|
username = <your wordpress username>
|
|
61
|
-
password = <your application password>
|
|
62
76
|
```
|
|
63
|
-
Note that the application password is different from the password you use to login to your WordPress installation.
|
|
64
77
|
|
|
78
|
+
## api host
|
|
65
79
|
If the site is served through a CDN, you can also set the `api_host` which will be used as the hostname to invoke the WP REST API.
|
|
66
80
|
|
|
81
|
+
## password
|
|
82
|
+
To authenticate you need an [application password](https://wordpress.com/support/security/two-step-authentication/application-specific-passwords/), which is different from the user password.
|
|
83
|
+
|
|
84
|
+
We recommend to store your application password in 1password and set the environment variable
|
|
85
|
+
WP_APP_PASSWORD using the [1password CLI](https://developer.1password.com/docs/cli):
|
|
86
|
+
|
|
87
|
+
```shell
|
|
88
|
+
WP_APP_PASSWORD="$(op read "op://Private/wordpress app password/password")" wp-md ...
|
|
89
|
+
```
|
|
90
|
+
|
|
67
91
|
## Never touch the WP editor again
|
|
68
92
|
|
|
69
93
|
Once you start to manage your blogs via this uploader, *do not edit* the blog via one of the WP editors. The editors are weird,
|
|
70
94
|
because it appears to make a copy of the content on which you get a WYSIWIG viewer. Unfortunately, it does not detect changes
|
|
71
95
|
in the actual blog content. It will look like your uploaded changes are not applied (but they are).
|
|
72
96
|
|
|
73
|
-
## Using the image
|
|
74
|
-
To use the docker image, you have to login using a GitHub container registry access token:
|
|
75
|
-
|
|
76
|
-
1. Browse to https://github.com/settings/tokens
|
|
77
|
-
2. Create new token with 'read:packages' permission
|
|
78
|
-
3. Copy the token
|
|
79
|
-
4. login to ghcr.io with Docker.
|
|
80
|
-
|
|
81
|
-
`pbpaste | docker login ghcr.io -u <github username> --password-stdin`
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
## set an alias
|
|
97
|
+
## Using the docker image
|
|
85
98
|
To use the docker image as a command line utility, create the following alias:
|
|
86
99
|
|
|
87
100
|
```bash
|
|
88
|
-
alias wp-md='docker run
|
|
101
|
+
alias wp-md='docker run
|
|
102
|
+
-e WP_APP_PASSWORD=$("$(op read "op://Private/wordpress app password/password")")
|
|
103
|
+
-v $HOME:$HOME
|
|
104
|
+
-v $HOME/.wordpress.ini:/root/.wordpress.ini
|
|
105
|
+
-v $PWD:/$PWD
|
|
106
|
+
-w $PWD ghcr.io/binxio/wordpress-markdown-blog-loader:1.3.0
|
|
89
107
|
```
|
|
108
|
+
Assuming that your WordPress app password is stored in the 1password Private vault under the name `wordpress app password`
|
|
90
109
|
|
|
91
110
|
## start a new blog
|
|
92
111
|
To start a new blog, type:
|
|
@@ -96,7 +115,8 @@ $ wp-md posts new \
|
|
|
96
115
|
--title "How to create a WordPress blog without touching WordPress" \
|
|
97
116
|
--subtitle "using the wp-md utility" \
|
|
98
117
|
--author "Mark van Holsteijn" \
|
|
99
|
-
--image ~/Downloads/background-image.jpg
|
|
118
|
+
--image ~/Downloads/background-image.jpg \
|
|
119
|
+
--image-credits "image by xyz"
|
|
100
120
|
INFO: resizing 1920x1920 to 1200x1200
|
|
101
121
|
INFO: cropping to maximum height of 630px
|
|
102
122
|
INFO: start editing index.md in ./how-to-create-a-wordpress-blog-without-touching-wordpress
|
|
@@ -104,6 +124,28 @@ INFO: start editing index.md in ./how-to-create-a-wordpress-blog-without-touchin
|
|
|
104
124
|
|
|
105
125
|
A skaffold frontmatter blog is created, and you can start writing in the index.md.
|
|
106
126
|
|
|
127
|
+
## frontmatter properties
|
|
128
|
+
You can set the following properties in the frontmatter:
|
|
129
|
+
|
|
130
|
+
| Name | description |
|
|
131
|
+
|----------------|-------------------------------------------------------------------------|
|
|
132
|
+
| title | of the blog |
|
|
133
|
+
| subtitle | of the blog, used in the og.image |
|
|
134
|
+
| focus-keywords | the SEO focus keywords
|
|
135
|
+
| excerpt | excerpt of the blog |
|
|
136
|
+
| author | display name of the author in Wordpress |
|
|
137
|
+
| categories | list of wordpress categories for this blog |
|
|
138
|
+
| slug | slug of the blog |
|
|
139
|
+
| date | on which the blog should be published ISO timestamp format |
|
|
140
|
+
| status | draft or publish. if publish, the blog will be published on the `date` |
|
|
141
|
+
| canonical | url of the blog, to be used in cross posts |
|
|
142
|
+
| image | the banner image of the blog |
|
|
143
|
+
| og.image | the open graph image of the blog, used in links from social media |
|
|
144
|
+
| og.description | the open graph description of the blog, used in links from social media |
|
|
145
|
+
| guid | the physical URL of the blog. Written by wp-md on upload and download |
|
|
146
|
+
| brand | xebia.com or xebia.com. defaults to xebia.com |
|
|
147
|
+
|
|
148
|
+
|
|
107
149
|
## adding images
|
|
108
150
|
To add an image to your blog, add the images in the ./images subdirectory and add a relative reference in markdown. For instance:
|
|
109
151
|
|
|
@@ -115,7 +157,7 @@ To add an image to your blog, add the images in the ./images subdirectory and ad
|
|
|
115
157
|
To upload a blog, type:
|
|
116
158
|
|
|
117
159
|
```
|
|
118
|
-
$ wp-md posts upload --host
|
|
160
|
+
$ wp-md posts upload --host xebia.com .
|
|
119
161
|
INFO: generating og:image based on images/banner.jpg
|
|
120
162
|
INFO: generating new image in how-to-create-a-wordpress-blog-without-touching-wordpress/images/og-banner.jpg
|
|
121
163
|
INFO: add logo
|
|
@@ -123,9 +165,9 @@ INFO: add title
|
|
|
123
165
|
INFO: add subtitle
|
|
124
166
|
INFO: add author
|
|
125
167
|
INFO: og image saved to how-to-create-a-wordpress-blog-without-touching-wordpress/images/og-banner.jpg
|
|
126
|
-
INFO: uploaded blog 'How to create a WordPress blog without touching WordPress' as post https://
|
|
127
|
-
INFO: updating opengraph image to https://
|
|
128
|
-
INFO: post available at https://
|
|
168
|
+
INFO: uploaded blog 'How to create a WordPress blog without touching WordPress' as post https://xebia.com/?p=9625
|
|
169
|
+
INFO: updating opengraph image to https://xebia.com/wp-content/uploads/2023/01/how-to-create-a-wordpress-blog-without-touching-wordpress-og-banner.jpg
|
|
170
|
+
INFO: post available at https://xebia.com/?p=9625
|
|
129
171
|
INFO: uploading image as how-to-create-a-wordpress-blog-without-touching-wordpress-og-banner.jpg
|
|
130
172
|
INFO: uploading image as how-to-create-a-wordpress-blog-without-touching-wordpress-banner.jpg
|
|
131
173
|
```
|
|
@@ -135,16 +177,23 @@ You can update the blog, by uploading it again. If you change the status to 'pu
|
|
|
135
177
|
the blog will be published on the specified date.
|
|
136
178
|
|
|
137
179
|
```
|
|
138
|
-
$ wp-md posts upload --host
|
|
180
|
+
$ wp-md posts upload --host xebia.com .
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
## updating banner and open graph images
|
|
184
|
+
You can update the banner and open graph images as follows:
|
|
185
|
+
|
|
186
|
+
```
|
|
187
|
+
$ wp-md posts update-banner . new-banner.jpg
|
|
139
188
|
```
|
|
140
189
|
|
|
141
190
|
## downloading an existing blog
|
|
142
191
|
to download an existing blog and convert it to markdown, type:
|
|
143
192
|
|
|
144
193
|
```
|
|
145
|
-
$ wp-md posts download --host
|
|
146
|
-
INFO: downloading https://
|
|
147
|
-
INFO: downloading https://
|
|
194
|
+
$ wp-md posts download --host xebia.com --directory /tmp 9625
|
|
195
|
+
INFO: downloading https://xebia.com/wp-content/uploads/2023/01/how-to-create-a-wordpress-blog-without-touching-wordpress-banner.jpg as banner.jpg
|
|
196
|
+
INFO: downloading https://xebia.com/wp-content/uploads/2023/01/how-to-create-a-wordpress-blog-without-touching-wordpress-og-banner.jpg as og-banner.jpg
|
|
148
197
|
INFO: writing /tmp/2023/01/how-to-create-a-wordpress-blog-without-touching-wordpress/index.md
|
|
149
198
|
```
|
|
150
199
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{wordpress-markdown-blog-loader-1.1.4 → wordpress_markdown_blog_loader-1.3.0}/tests/test_blog.py
RENAMED
|
File without changes
|