Tidy dependencies and update README

This commit is contained in:
Gabriel Garrido 2024-08-03 09:24:08 +02:00
parent 41663032f9
commit 15074344dc
3 changed files with 20 additions and 3 deletions

View file

@ -16,13 +16,13 @@ This program essentially wraps the Mastodon API with a command line interface wi
- Optionally persist fetched post id cursors - Optionally persist fetched post id cursors
- Optionally set authorization token to fetch private posts - Optionally set authorization token to fetch private posts
I use this tool to create an archive of my Mastodon posts and [syndicate them to my own site](https://garrido.io/microblog/), per IndieWeb's [PESOS philosophy](https://indieweb.org/PESOS). [Read more about this](https://garrido.io/notes/archiving-and-syndicating-mastodon-posts/) on my site. I use this tool to create an archive of my Mastodon posts and [syndicate them to my own site](https://garrido.io/microblog/), per IndieWeb's [PESOS philosophy](https://indieweb.org/PESOS). [Read more about this](https://garrido.io/notes/archiving-and-syndicating-mastodon-posts/) on my site.
This repository [is mirrored in Codeberg](https://codeberg.org/ggpsv/mastodon-markdown-archive). For any issues or questions, please [contact me via email](mailto:hello@garrido.io?subject=Re:mastodon-markdown-archive) or [Mastodon](https://social.coop/@ggpsv). This repository [is mirrored in Codeberg](https://codeberg.org/ggpsv/mastodon-markdown-archive). For any issues or questions, please [contact me via email](mailto:hello@garrido.io?subject=Re:mastodon-markdown-archive) or [Mastodon](https://social.coop/@ggpsv).
## Table of contents ## Table of contents
* [Installation](#installation) * [Installation](#installation)
* [Dependencies](#dependencies)
* [Usage](#usage) * [Usage](#usage)
* [Environment variables](#environment-variables) * [Environment variables](#environment-variables)
* [Examples](#examples) * [Examples](#examples)
@ -43,6 +43,7 @@ This repository [is mirrored in Codeberg](https://codeberg.org/ggpsv/mastodon-ma
* [Text only](#text-only) * [Text only](#text-only)
* [Post media](#post-media) * [Post media](#post-media)
* [Bundling](#bundling) * [Bundling](#bundling)
* [Known issues](#known-issues)
## Installation ## Installation
@ -50,6 +51,14 @@ This repository [is mirrored in Codeberg](https://codeberg.org/ggpsv/mastodon-ma
You can clone this repo and run `go build main.go` in the repository's directory, or you can run `go install git.garrido.io/gabriel/mastodon-markdown-archive@latest` to install a binary of the latest version. You can clone this repo and run `go build main.go` in the repository's directory, or you can run `go install git.garrido.io/gabriel/mastodon-markdown-archive@latest` to install a binary of the latest version.
## Dependencies
This tool has only two direct dependencies, which are included to provide useful, though largely optional, functionality in templates:
- [sprig](https://github.com/Masterminds/sprig/tree/master)
- [html-to-markdown](https://github.com/JohannesKaufmann/html-to-markdown/tree/master)
The default template makes use of `html-to-markdown` to transform the post's HTML content to markdown.
## Usage ## Usage
``` ```
Usage of mastodon-markdown-archive: Usage of mastodon-markdown-archive:
@ -383,3 +392,7 @@ You can use `--download-media=bundle` to save the post media in a single directo
For example, `--download-media="bundle" --filename='{{ .Post.CreatedAt | date "2006-01-02" }}-{{.Post.Id}}.md'` will create a `YYYY-MM-DD-<post id>/` directory, with the post saved as `YYYY-MM-DD-<post id>/index.md` and media saved as `YYYY-MM-DD-<post id>/<media id>.<media ext>`. For example, `--download-media="bundle" --filename='{{ .Post.CreatedAt | date "2006-01-02" }}-{{.Post.Id}}.md'` will create a `YYYY-MM-DD-<post id>/` directory, with the post saved as `YYYY-MM-DD-<post id>/index.md` and media saved as `YYYY-MM-DD-<post id>/<media id>.<media ext>`.
This is done specifically to support Hugo [page bundles](https://gohugo.io/content-management/page-bundles). This is done specifically to support Hugo [page bundles](https://gohugo.io/content-management/page-bundles).
### Known issues
1. A reply post may still appear in the list of posts despite using `--exclude-replies`. This happens when the post in question is a reply to a post that has since been deleted. It looks like Mastodon's API stops treating the reply as a reply. It no longer points to another post, and thus is not affected by the `exclude_replies` parameter.

6
go.mod
View file

@ -2,12 +2,14 @@ module git.garrido.io/gabriel/mastodon-markdown-archive
go 1.21.6 go 1.21.6
require github.com/JohannesKaufmann/html-to-markdown v1.5.0 require (
github.com/JohannesKaufmann/html-to-markdown v1.5.0
github.com/Masterminds/sprig/v3 v3.2.3
)
require ( require (
github.com/Masterminds/goutils v1.1.1 // indirect github.com/Masterminds/goutils v1.1.1 // indirect
github.com/Masterminds/semver/v3 v3.2.0 // indirect github.com/Masterminds/semver/v3 v3.2.0 // indirect
github.com/Masterminds/sprig/v3 v3.2.3 // indirect
github.com/PuerkitoBio/goquery v1.8.1 // indirect github.com/PuerkitoBio/goquery v1.8.1 // indirect
github.com/andybalholm/cascadia v1.3.1 // indirect github.com/andybalholm/cascadia v1.3.1 // indirect
github.com/google/uuid v1.1.1 // indirect github.com/google/uuid v1.1.1 // indirect

2
go.sum
View file

@ -11,6 +11,7 @@ github.com/PuerkitoBio/goquery v1.8.1/go.mod h1:Q8ICL1kNUJ2sXGoAhPGUdYDJvgQgHzJs
github.com/andybalholm/cascadia v1.3.1 h1:nhxRkql1kdYCc8Snf7D5/D3spOX+dBgjA6u8x004T2c= github.com/andybalholm/cascadia v1.3.1 h1:nhxRkql1kdYCc8Snf7D5/D3spOX+dBgjA6u8x004T2c=
github.com/andybalholm/cascadia v1.3.1/go.mod h1:R4bJ1UQfqADjvDa4P6HZHLh/3OxWWEqc0Sk8XGwHqvA= github.com/andybalholm/cascadia v1.3.1/go.mod h1:R4bJ1UQfqADjvDa4P6HZHLh/3OxWWEqc0Sk8XGwHqvA=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/google/uuid v1.1.1 h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY= github.com/google/uuid v1.1.1 h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY=
github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
@ -41,6 +42,7 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/stretchr/testify v1.5.1 h1:nOGnQDM7FYENwehXlg/kFVnos3rEvtKTjRvOWSzb6H4=
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
github.com/yuin/goldmark v1.6.0 h1:boZcn2GTjpsynOsC0iJHnBWa4Bi0qzfJjthwauItG68= github.com/yuin/goldmark v1.6.0 h1:boZcn2GTjpsynOsC0iJHnBWa4Bi0qzfJjthwauItG68=