Add markdown transformation support.
This commit is contained in:
		
							parent
							
								
									54723b3455
								
							
						
					
					
						commit
						8053b966f5
					
				| @ -7,7 +7,7 @@ CLI tool for submitting posts to WordPress through its REST API using curl. | |||||||
| Install [Application Passwords](https://wordpress.org/plugins/application-passwords/) plugin and follow its installation steps (i.e. create a new passowrd for your user). | Install [Application Passwords](https://wordpress.org/plugins/application-passwords/) plugin and follow its installation steps (i.e. create a new passowrd for your user). | ||||||
| 
 | 
 | ||||||
| ### Local shell | ### Local shell | ||||||
| Make sure you have `curl` installed. | Make sure you have `curl` installed. If you want to enter text in markdown format, install `python-markdown2`. | ||||||
| 
 | 
 | ||||||
| Create a config file `~/.config/wordpress-rest-curl/config.sh` from the `config.sh.template` file. | Create a config file `~/.config/wordpress-rest-curl/config.sh` from the `config.sh.template` file. | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -1,5 +1,6 @@ | |||||||
| #!/bin/bash | #!/bin/bash | ||||||
| EDITOR=vim | EDITOR=vim | ||||||
|  | TRANSFORM="" # '' / 'markdown' | ||||||
| USER="" # WP user to create the post | USER="" # WP user to create the post | ||||||
| PASSWORD="" # application password generated for your WP user | PASSWORD="" # application password generated for your WP user | ||||||
| SERVER="" # server hostname, optionally with subdirectories | SERVER="" # server hostname, optionally with subdirectories | ||||||
|  | |||||||
							
								
								
									
										15
									
								
								post.sh
									
									
									
									
									
								
							
							
						
						
									
										15
									
								
								post.sh
									
									
									
									
									
								
							| @ -3,6 +3,7 @@ | |||||||
| 
 | 
 | ||||||
| # config: | # config: | ||||||
| EDITOR=vim | EDITOR=vim | ||||||
|  | TRANSFORM="" # '' / 'markdown' | ||||||
| USER="" # WP user to create the post | USER="" # WP user to create the post | ||||||
| PASSWORD="" # application password generated for your WP user | PASSWORD="" # application password generated for your WP user | ||||||
| SERVER="" # server hostname, optionally with subdirectories | SERVER="" # server hostname, optionally with subdirectories | ||||||
| @ -15,10 +16,18 @@ source ~/.config/wordpress-rest-curl/config.sh | |||||||
| 
 | 
 | ||||||
| # let the user create the post | # let the user create the post | ||||||
| $EDITOR $TMPFILE || exit 1 | $EDITOR $TMPFILE || exit 1 | ||||||
| 
 |  | ||||||
| # load the file if it exists |  | ||||||
| [[ -e $TMPFILE ]] || exit 1 | [[ -e $TMPFILE ]] || exit 1 | ||||||
| CONTENT=`cat $TMPFILE` | 
 | ||||||
|  | # transformations | ||||||
|  | if [[ $TRANSFORM -eq "markdown" ]]; then | ||||||
|  |     python >$TMPFILE.trans <<EOF | ||||||
|  | import markdown2 | ||||||
|  | print(markdown2.markdown_path('$TMPFILE')) | ||||||
|  | EOF | ||||||
|  |     CONTENT=`cat $TMPFILE.trans` | ||||||
|  | else | ||||||
|  |     CONTENT=`cat $TMPFILE` | ||||||
|  | fi | ||||||
| 
 | 
 | ||||||
| echo "--- START POST ---" | echo "--- START POST ---" | ||||||
| echo $CONTENT | echo $CONTENT | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user