55- Setup the google access-token + refresh token, save it to disk
66
77 ```
8- Init -Blogger -clientId -clientSecret -redirectUri -code
8+ Initialize -Blogger -clientId -clientSecret -redirectUri -code
99 ```
1010
1111 And if we could host a weblistener, we could launch the browser and wait for the auth-flow
1212
13- ```
14- Connect-Blogger
15- ```
16-
1713We want configuration settings to store default values.
1814
1915- Get configuration settings. This returns an object with settings to use.
@@ -25,7 +21,7 @@ We want configuration settings to store default values.
2521- Set Configuration settings. You can pass individual settings. Set to "" to erase
2622
2723 ```
28- Set-BloggerConfig
24+ Set-BloggerConfig -Name <parameter> -Value
2925 ```
3026
3127
@@ -37,54 +33,75 @@ We want configuration settings to store default values.
3733 Get-BloggerBlogs
3834 ```
3935
40- - Get a list of blogger posts and save to disk
36+ - Get a list of blogger posts
4137
4238 ```
43- Get-BloggerPosts -blogid -directory
39+ Get-BloggerPosts -BlogId < blogid> -All
4440 ```
4541
4642- Publish to Blogger. We also need to consider 'publishing' or scheduling a publish
4743
4844 ```
49- Publish-BloggerPost -blogid -content -title -draft
50- Publish-BloggerPost -blogid -postid - title
45+ Publish-BloggerPost -blogid <blogid> -content <html> -title "First Post" -draft
46+ Publish-BloggerPost -blogid <blogid> -postid <postid> -content <html> - title "First Post"
5147 ```
5248
5349## Google Drive
5450
5551We need the ability to upload images to google drive. The upload process would read the images from the markdown and if the backing URL isn't Google Drive, it uploads to google and then updates the markdown. You should be able to publish the images independently of the blog.
5652
57- - Test if an image exists in GDrive
53+ - Get all items from Google Drive
54+
55+ ```
56+ Get-GoogleDriveItems -ResultType All
57+ ```
58+
59+ - Find if an image exists in Google Drive
60+
61+ ```
62+ $folder = Get-GoogleDriveItems -ResultType Folders -Title "PSBlogger"
63+ Get-GoogleDriveItem -ResultType Files -Title image.jpg -Folder $folder.id
64+ ```
65+
66+ - Upload an image to Google Drive
5867
5968 ```
60- Test-GDriveImage
69+ Add-GoogleDriveFile -FilePath "c:\image.jpg" -TargetFolderName "PSBlogger"
6170 ```
6271
63- - Upload an image to GDrive
72+ - Make an image publicly accessible to the internet
6473
6574 ```
66- Send-GDriveImage -file
75+ $folder = Get-GoogleDriveItems -ResultType Folders -Title "PSBlogger"
76+ $file = Get-GoogleDriveItem -ResultType Files -Title image.jpg -Folder $folder.id
77+ $permission = New-GoogleDriveFilePermission -role "reader" -type "anyone"
78+ Set-GoogleDriveFilePermission -FileId $file.id -PermissionData $permission
6779 ```
6880
6981## Markdown
7082
71- - Related to finding images in the markdown and uploading , we want:
83+ - Related to finding images in the markdown, we want:
7284
73- ```
74- Get-MarkdownLinks - file
75- ```
85+ ```
86+ $imageMappings = Find-MarkdownImages -File .\ file.md
87+ ```
7688
77- and
89+ - After uploading these images, we update the mappings and then update the file:
7890
79- ```
80- Update-MarkdownLink - file -path -url
81- ```
91+ ```
92+ Update-MarkdownImages -File .\ file.md -ImageMappings $imageMappings
93+ ```
8294
8395- We'll also need to get the meta-data from the markdown
8496
8597 ```
86- Show-MarkdownFrontMatter
98+ Get-MarkdownFrontMatter -File .\file.md
99+ ```
100+
101+ - And the ability to update the meta-data
102+
87103 ```
104+ Set-MarkdownFrontMatter -file .\file.md -Update [ordered]@{ postid = "123" }
88105
89106## Pandoc
90107
@@ -96,39 +113,30 @@ The conversion of markdown to HTML will use pandoc with some custom extensions t
96113 ConvertTo-HtmlFromMarkdown -file something.md
97114 ```
98115
116+ ...which is equivalent to:
117+
99118 ```
100119 pandoc test.md -f markdown -t html -o test.html
101120 ```
102121
103122- Upload the images in the markdown to Google Drive. This involves:
104123
105- - Find all the images in the markdown that need to be uploaded
106- - Upload the files in the markdown to google drive
107- - Update the markdown with the values
108-
109- ```
110- Publish-GDriveImages -file something.md
111- ```
112-
113- - Update the local files for a post if they've been updated. This involves:
114-
115- - find all the referenced images in the markdown
116- - get the modified date from the local file
117- - get the modified date from google drive
118- - upload newer files to google drive
124+ - Find all the images in the markdown that need to be uploaded `Find-MarkdownImages`
125+ - Upload the files in the markdown to google drive `Add-GoogleDriveFile`
126+ - Update the markdown with the values `Update-MarkdownIamges`
119127
120128 ```
121- Update-GDriveImages -file something.md
129+ Publish-MarkdownDriveImages -file something.md
122130 ```
123131
124132- The "money shot" is performing the work of converting the markdown and publishing to blogger. Assuming this involves:
125133
126- - Publish-GDriveImages
127- - Update-GDriveImages
134+ - Publish-MarkdownDriveImages
128135 - ConvertTo-HtmlFromMarkDown
129136 - Get-MarkdownFrontMatter
130137 - Publish-BloggerPost
138+ - Set-MarkdownFrontMatter
131139
132140 ```
133- Publish-MarkdownToBlog -file post.md
141+ Publish-MarkdownBloggerPost -file post.md
134142 ```
0 commit comments