wordpress-markdown-blog-loader 1.2.0__tar.gz → 1.3.1__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.
Files changed (23) hide show
  1. {wordpress-markdown-blog-loader-1.2.0 → wordpress_markdown_blog_loader-1.3.1}/PKG-INFO +21 -6
  2. {wordpress-markdown-blog-loader-1.2.0 → wordpress_markdown_blog_loader-1.3.1}/README.md +19 -4
  3. {wordpress-markdown-blog-loader-1.2.0 → wordpress_markdown_blog_loader-1.3.1}/setup.py +2 -2
  4. {wordpress-markdown-blog-loader-1.2.0 → wordpress_markdown_blog_loader-1.3.1}/src/wordpress_markdown_blog_loader/api.py +39 -9
  5. {wordpress-markdown-blog-loader-1.2.0 → wordpress_markdown_blog_loader-1.3.1}/src/wordpress_markdown_blog_loader/upload.py +1 -1
  6. {wordpress-markdown-blog-loader-1.2.0 → wordpress_markdown_blog_loader-1.3.1}/src/wordpress_markdown_blog_loader.egg-info/PKG-INFO +21 -6
  7. {wordpress-markdown-blog-loader-1.2.0 → wordpress_markdown_blog_loader-1.3.1}/src/wordpress_markdown_blog_loader.egg-info/requires.txt +1 -1
  8. {wordpress-markdown-blog-loader-1.2.0 → wordpress_markdown_blog_loader-1.3.1}/LICENSE +0 -0
  9. {wordpress-markdown-blog-loader-1.2.0 → wordpress_markdown_blog_loader-1.3.1}/setup.cfg +0 -0
  10. {wordpress-markdown-blog-loader-1.2.0 → wordpress_markdown_blog_loader-1.3.1}/src/wordpress_markdown_blog_loader/__init__.py +0 -0
  11. {wordpress-markdown-blog-loader-1.2.0 → wordpress_markdown_blog_loader-1.3.1}/src/wordpress_markdown_blog_loader/__main__.py +0 -0
  12. {wordpress-markdown-blog-loader-1.2.0 → wordpress_markdown_blog_loader-1.3.1}/src/wordpress_markdown_blog_loader/blog.py +0 -0
  13. {wordpress-markdown-blog-loader-1.2.0 → wordpress_markdown_blog_loader-1.3.1}/src/wordpress_markdown_blog_loader/check_links.py +0 -0
  14. {wordpress-markdown-blog-loader-1.2.0 → wordpress_markdown_blog_loader-1.3.1}/src/wordpress_markdown_blog_loader/download.py +0 -0
  15. {wordpress-markdown-blog-loader-1.2.0 → wordpress_markdown_blog_loader-1.3.1}/src/wordpress_markdown_blog_loader/name_to_email.py +0 -0
  16. {wordpress-markdown-blog-loader-1.2.0 → wordpress_markdown_blog_loader-1.3.1}/src/wordpress_markdown_blog_loader/new.py +0 -0
  17. {wordpress-markdown-blog-loader-1.2.0 → wordpress_markdown_blog_loader-1.3.1}/src/wordpress_markdown_blog_loader/remove_newlines.py +0 -0
  18. {wordpress-markdown-blog-loader-1.2.0 → wordpress_markdown_blog_loader-1.3.1}/src/wordpress_markdown_blog_loader.egg-info/SOURCES.txt +0 -0
  19. {wordpress-markdown-blog-loader-1.2.0 → wordpress_markdown_blog_loader-1.3.1}/src/wordpress_markdown_blog_loader.egg-info/dependency_links.txt +0 -0
  20. {wordpress-markdown-blog-loader-1.2.0 → wordpress_markdown_blog_loader-1.3.1}/src/wordpress_markdown_blog_loader.egg-info/entry_points.txt +0 -0
  21. {wordpress-markdown-blog-loader-1.2.0 → wordpress_markdown_blog_loader-1.3.1}/src/wordpress_markdown_blog_loader.egg-info/not-zip-safe +0 -0
  22. {wordpress-markdown-blog-loader-1.2.0 → wordpress_markdown_blog_loader-1.3.1}/src/wordpress_markdown_blog_loader.egg-info/top_level.txt +0 -0
  23. {wordpress-markdown-blog-loader-1.2.0 → wordpress_markdown_blog_loader-1.3.1}/tests/test_blog.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: wordpress-markdown-blog-loader
3
- Version: 1.2.0
3
+ Version: 1.3.1
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
@@ -25,7 +25,7 @@ Requires-Dist: python-frontmatter
25
25
  Requires-Dist: click
26
26
  Requires-Dist: pytz
27
27
  Requires-Dist: Pillow
28
- Requires-Dist: binx-og-image-generator>=1.2.5
28
+ Requires-Dist: binx-og-image-generator>=1.2.6
29
29
  Requires-Dist: markdownify
30
30
  Requires-Dist: bs4
31
31
  Requires-Dist: html5lib
@@ -73,12 +73,21 @@ host = xebia.com
73
73
 
74
74
  [xebia.com]
75
75
  username = <your wordpress username>
76
- password = <your application password>
77
76
  ```
78
- Note that the application password is different from the password you use to login to your WordPress installation.
79
77
 
78
+ ## api host
80
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.
81
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
+
82
91
  ## Never touch the WP editor again
83
92
 
84
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,
@@ -89,8 +98,14 @@ in the actual blog content. It will look like your uploaded changes are not appl
89
98
  To use the docker image as a command line utility, create the following alias:
90
99
 
91
100
  ```bash
92
- alias wp-md='docker run -v $HOME:$HOME -v $HOME/.wordpress.ini:/root/.wordpress.ini -v $PWD:/$PWD -w $PWD ghcr.io/binxio/wordpress-markdown-blog-loader:1.2.0
93
- ```
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.1
107
+ ```'
108
+ Assuming that your WordPress app password is stored in the 1password Private vault under the name `wordpress app password`
94
109
 
95
110
  ## start a new blog
96
111
  To start a new blog, type:
@@ -37,12 +37,21 @@ 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,
@@ -53,8 +62,14 @@ in the actual blog content. It will look like your uploaded changes are not appl
53
62
  To use the docker image as a command line utility, create the following alias:
54
63
 
55
64
  ```bash
56
- alias wp-md='docker run -v $HOME:$HOME -v $HOME/.wordpress.ini:/root/.wordpress.ini -v $PWD:/$PWD -w $PWD ghcr.io/binxio/wordpress-markdown-blog-loader:1.2.0
57
- ```
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.1
71
+ ```'
72
+ Assuming that your WordPress app password is stored in the 1password Private vault under the name `wordpress app password`
58
73
 
59
74
  ## start a new blog
60
75
  To start a new blog, type:
@@ -11,7 +11,7 @@ dependencies = [
11
11
  "click",
12
12
  "pytz",
13
13
  "Pillow",
14
- "binx-og-image-generator>=1.2.5",
14
+ "binx-og-image-generator>=1.2.6",
15
15
  "markdownify",
16
16
  "bs4",
17
17
  "html5lib",
@@ -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.2.0",
30
+ version="1.3.1",
31
31
  url="https://github.com/binxio/wordpress-markdown-blog-loader",
32
32
  license="APL2",
33
33
  author="Mark van Holsteijn",
@@ -1,20 +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 io import BytesIO
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
- from functools import cache
13
-
14
13
 
15
14
  import pytz
16
15
  import requests
17
- from PIL import Image
18
16
 
19
17
 
20
18
  def get_default_host() -> Optional[str]:
@@ -25,6 +23,31 @@ def get_default_host() -> Optional[str]:
25
23
  config.read(expanduser("~/.wordpress.ini"))
26
24
  return config.defaults().get("host")
27
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
+
28
51
 
29
52
  class WordpressEndpoint:
30
53
  def __init__(self, **kwargs):
@@ -40,13 +63,20 @@ class WordpressEndpoint:
40
63
  config = configparser.ConfigParser()
41
64
  config.read(expanduser("~/.wordpress.ini"))
42
65
 
43
- self.host = host if host else config.defaults().get("host")
44
- assert host, "no host specified and no default host found"
45
66
 
67
+ if not host:
68
+ host = config.defaults().get("host")
69
+ assert host, "no host specified and no default host found"
70
+
71
+ self.host = host
46
72
  self.api_host = config.get(host, "api_host", fallback=self.host)
47
73
  self.url = f"https://{self.api_host}/wp-json/wp/v2"
74
+
48
75
  self.username = config.get(host, "username")
49
- self.password = config.get(host, "password")
76
+ self.password = get_password(host)
77
+ if not self.password:
78
+ logging.warning("taking plain text app password from configuration file, use WP_APP_PASSWORD environment variable instead!")
79
+ self.password = config.get(host, "password")
50
80
 
51
81
  def is_host_for(self, url: Union[str, ParseResult]) -> bool:
52
82
  result = url if isinstance(url, ParseResult) else urlparse(url)
@@ -68,7 +68,7 @@ def upsert_post(wp: Wordpress, blog: Blog) -> int:
68
68
 
69
69
  @click.command(name="upload")
70
70
  @click.option(
71
- "--host", type=str, required=True, nargs=1, help="wordpress host to upload to"
71
+ "--host", type=str, required=False, nargs=1, help="wordpress host to upload to"
72
72
  )
73
73
  @click.option(
74
74
  "--regenerate-og-image",
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: wordpress-markdown-blog-loader
3
- Version: 1.2.0
3
+ Version: 1.3.1
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
@@ -25,7 +25,7 @@ Requires-Dist: python-frontmatter
25
25
  Requires-Dist: click
26
26
  Requires-Dist: pytz
27
27
  Requires-Dist: Pillow
28
- Requires-Dist: binx-og-image-generator>=1.2.5
28
+ Requires-Dist: binx-og-image-generator>=1.2.6
29
29
  Requires-Dist: markdownify
30
30
  Requires-Dist: bs4
31
31
  Requires-Dist: html5lib
@@ -73,12 +73,21 @@ host = xebia.com
73
73
 
74
74
  [xebia.com]
75
75
  username = <your wordpress username>
76
- password = <your application password>
77
76
  ```
78
- Note that the application password is different from the password you use to login to your WordPress installation.
79
77
 
78
+ ## api host
80
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.
81
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
+
82
91
  ## Never touch the WP editor again
83
92
 
84
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,
@@ -89,8 +98,14 @@ in the actual blog content. It will look like your uploaded changes are not appl
89
98
  To use the docker image as a command line utility, create the following alias:
90
99
 
91
100
  ```bash
92
- alias wp-md='docker run -v $HOME:$HOME -v $HOME/.wordpress.ini:/root/.wordpress.ini -v $PWD:/$PWD -w $PWD ghcr.io/binxio/wordpress-markdown-blog-loader:1.2.0
93
- ```
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.1
107
+ ```'
108
+ Assuming that your WordPress app password is stored in the 1password Private vault under the name `wordpress app password`
94
109
 
95
110
  ## start a new blog
96
111
  To start a new blog, type:
@@ -4,7 +4,7 @@ python-frontmatter
4
4
  click
5
5
  pytz
6
6
  Pillow
7
- binx-og-image-generator>=1.2.5
7
+ binx-og-image-generator>=1.2.6
8
8
  markdownify
9
9
  bs4
10
10
  html5lib