#dev 2021-08-14

2021-08-14 UTC
nertzy, rockorager, Seirdy, hendursaga, jeremycherfas, hendursa1, tetov-irc and diegov joined the channel
#
capjamesg[d]
Suppose I want to support micropub on my static site. I'm thinking about making a git commit every time I want to upload a post. Is that acceptable?
#
capjamesg[d]
I was thinking of using os.system() in Python (with appropriate security precautions taken to clean input).
#
capjamesg[d]
(using os.system() to commit the file, not for anything else)
#
Zegnat
Pretty sure there have been micropub-to-git things before, seems fairly common because of how many static sites integrate with git in some way :)
#
Zegnat
Micropub itself does not care about what storage is used at all, it only describes the HTTP communications between clients and server. So if git fits your server/CMS/site, go for it!
#
sknebel
I would use the subprocess apis, not os.system when calling commands. Involving a shell is a bad sign
#
capjamesg[d]
Perfect! Thanks Zegnat.
#
capjamesg[d]
sknebel good call.
#
sknebel
(or some git library, but the state of those wasn't great last I looked)
#
capjamesg[d]
I am very new to Micropub (although calumryan gave an excellent introduction at HWC a few weeks ago calumryan++).
#
capjamesg[d]
Yeah, there aren't many good Python git libraries.
#
capjamesg[d]
Which is a shame.
#
capjamesg[d]
Also, for authentication. Because this is my own micropub endpoint, can I just do user/password auth rather than setting up IndieAuth for my site?
#
sknebel
Existing clients will all expect indieauth
#
Zegnat
Theoretically, yes, but in practice no because of clients
#
Zegnat
Sniped :D
#
capjamesg[d]
What if I am building my own 😄
#
capjamesg[d]
I only want to support micropub for sharing what coffees I am drinking on my blog.
#
capjamesg[d]
Thus, I'm happy creating the web form for that. And I already have boilerplate user/password auth from other applications.
#
Zegnat
A spec-compliant Micropub endpoint must accept a bearer token: https://micropub.spec.indieweb.org/#authentication-and-authorization But where that token comes from, or if it is just some sort of preshared user/password combination (like basic auth is Base64 of user:password) is not something the spec cares about.
#
capjamesg[d]
Good to know. I have the spec open now but I haven't gotten to authentication.
#
Zegnat
It is just that existing clients will try the IndieAuth flow to get ahold of a token. You could also make your client just prompt someone to write in the token they want to use and skip indieauth completely.
#
capjamesg[d]
I would like to look at IndieAuth but I need to really sit down and focus on it.
#
capjamesg[d]
Regarding token, that's interesting.
#
capjamesg[d]
I hadn't thought about that.
#
capjamesg[d]
So I could have something like user / pass auth to secure the client web page(s) and include a "token" in the form that must be submitted to the client.
#
Zegnat
Probably. It all depends on who/what you are building for. If you are limiting access to the client itself, and if the client only ever posts to your own micropub endpoint, you could also hardcode the token that it needs to send to your endpoint
nertzy and rockorager joined the channel
#
rockorager
capjamesg: Are you committing locally or to something like Github?
#
rockorager
The github API is pretty easy to navigate, if for some reason you need to commit multiple files in a single commit though it's a little tricky
#
Zegnat
There is a Micropub server that uses the GitHub API, I think... https://github.com/voxpelli/webpage-micropub-to-github
#
rockorager
Basically you create a blob for each file, add it to an array (called a tree), create the tree in github through the API, create a commit that references current commit SHA and new tree SHA, and then update the HEAD ref
#
Loqi
[voxpelli] webpage-micropub-to-github: Self-hosteable Micropub endpoint that publishes to Jekyll by committing to GitHub
#
rockorager
But for creating or updating a single file, there is only one API call (CreateOrUpdateFileContents i think)
rockorager, chenghiz_ and jamietanna joined the channel
#
jamietanna
I know GitLab's API allows updating multiple files - it'd be a shame if GitHub's didn't and required them to be separate commits
#
capjamesg[d]
PyGithub is amazing for uploading files.
#
capjamesg[d]
You can create a file in one line of code (after configuring PyGithub, of course).
#
sknebel
Does anyone know if any of the more lightweight selfhosted things have a useful api for that?
#
jamietanna
Useful API for what, sknebel? :)
#
sknebel
See discussion before - editing git repos
unrelentingtech, hendursa1, jeremycherfas, mgdm, jjuran, KartikPrabhu, tetov-irc and hendursaga joined the channel