bmann / microglue

A small glue API server to create a micropub endpoint that can publish to Jekyll and other static sites via git
MIT License
6 stars 0 forks source link

Getting micropub working #5

Open bmann opened 6 years ago

bmann commented 6 years ago

Alright, here are some rough notes on getting https://github.com/voxpelli/webpage-micropub-to-github working with my blog, which is live at https://blog.bmannconsulting.com

I used the deploy to Heroku button, got it running right away.

There were a bunch of things I needed to add to my site to work with this stuff. First, there's this:

<link rel="micropub" href="https://example.com/micropub/main">
<link rel="token_endpoint" href="https://tokens.indieauth.com/token">

Instead of example.com, that's bmcblog-micropub.herokuapp.com.

For the indieauth steps you're going to have to do, you'll need to add at least one auth provider. For me, Github was the only one that worked. So, you need to edit your Github profile so that the link in your profile links to your blog. Then you'll need to add somewhere on your web page (doesn't have to be visible), the following:

A visible link: <a href="https://github.com/bmann" rel="me">

Or header link: <link href="https://github.com/bmann" rel="me" />

As said elsewhere, trying to get Instagram posting to your own site is super useful and will walk you through the whole process:

You'll also want to use IndieAuth, so one more custom header:

<link rel="authorization_endpoint" href="https://indieauth.com/auth">

At this point, I got through OWG, authenticated with my Github account (the only one that still seems to work).

I'm getting an error:

HTTP/1.1 100 Continue

HTTP/1.1 400 Bad Request
Server: Cowboy
Connection: keep-alive
Content-Type: text/plain; charset=utf-8
Content-Length: 11
Etag: W/"b-EFiDB1U+dmqzx9Mo2UjcZ1SJPO8"
Date: Fri, 28 Sep 2018 05:51:27 GMT
Via: 1.1 vegur

Bad Request

Now that I had indieauth working correctly, I discovered that https://micropublish.net/ is something else I could sign into with my blog (again, using Github auth).

I can see from Heroku logs that, signed in with IndieAuth to my blog.bmannconsulting.com, it is reading the micropub endpoint and passing it on to the server.

Github is giving an error, which is almost certainly about the wrong path.

Success! https://github.com/bmann/bmcblog/commit/b0c1a44830850498b63eb130ea2fd77f97258a88 (which is private, but trust me!)

OK, so figured it out -- the MICROPUB_SITE_GITHUB_REPO value needs to be just nameOfYourRepo -- e.g. if your username is bmann, then not bmann/nameOfYourRepo.

bmann commented 6 years ago

Changing MICROPUB_LAYOUT_NAME to be single which is what I use.

MICROPUB_OPTION_DERIVE_CATEGORY I'm going to set to "Micro"

MICROPUB_MEDIA_FILES_STYLE to images/:year-:month-:slug/:filesslug

bmann commented 6 years ago

OK. Adding those causes it to crash. Now downloading a local copy to investigate env entry crashing.

bmann commented 6 years ago

only this causes a crash locally? MICROPUB_MEDIA_FILES_STYLE="images/:year-:month-:day/:filesslug"

But on Heroku, if you delete the config var, then it crashes on layout name.

OK, let's go into handler.js and hardcode a few things!

OK, it still posts the default "social" category, so I'm not any farther ahead than when I first got it working.

Because of that social category, it makes it into my "main" feed, which does get posted to Twitter -- but also to LinkedIn and Medium! So fixing that category is going to have to happen.

And MicroBlog iOS still doesn't recognize the endpoint.

bmann commented 6 years ago

I will need to look through https://github.com/voxpelli/webpage-micropub-to-github/issues/28 and https://github.com/voxpelli/node-micropub-express/issues/11 as I'm not going to get any farther without that endpoint.

Likely other issues there worth looking through.

bmann commented 6 years ago

I ended up just changing the category I treat as micro posts to be called “social” in my jekyll config. I’ll document what different micropub tools end up posting in separate threads.

rianvdm commented 5 years ago

Did you ever get OwnYourGram to work with this endpoint?

bmann commented 5 years ago

@rianvdm yep, works no problem. Changing variables seems to cause problems so I just used the out of the box settings and changed my layout.

infominer33 commented 5 years ago

idk what I'm doing wrong... likely anything to do with the github access token or (more likely), how I set up the heroku app

{"error":"invalid_request","error_description":"Missing \"Authorization\" header or body parameter."}
bmann commented 5 years ago

@infominer33 feel free to open a new issue here with as much detail as possible and I’ll try to help.

The OwnYourGram helped me debug. You need to add a ton of stuff to the HTML of your site. And GitHub identities are the only ones that work.