Git Product home page Git Product logo

webpage-micropub-to-github's Introduction

Micropub to GitHub

IndieWeb js-semistandard-style Follow @voxpelli@mastodon.social

An endpoint that accepts Micropub requests, formats them into Jekyll posts before pushing them to a configured GitHub repository. This enables updating a Jekyll blog through a Micropub client.

Early alpha

Supported:

  • Creation of posts
  • Uploading of media
  • Replacing an existing post with a new version

Unsupported:

  • Partial update
  • Deletes

Requirements

Requires at least Node.js 14.0.0.

Installation

Install as a normal Node.js application. Add the required configuration values via environment variables or similar mechanism. Or deploy to Heroku:

Deploy

Endpoint discovery

Once deployed, your Micropub endpoint can be found at /micropub/main e.g. https://example.com/micropub/main.

If you specified more than one site using the MICROPUB_SITES_JSON variable, then each endpoint will be available under the name of its respective key, i.e. /micropub/key-name.

To enable automatic discovery for your Micropub endpoint and token endpoint, you will need to add the following values to your site's <head>:

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

Configuration

Required values

The following variables are required to enable a Micropub client to push content to your GitHub repository.

Variable Description
MICROPUB_TOKEN_ENDPOINT URL to verify Micropub token. Example: https://tokens.indieauth.com/token
MICROPUB_TOKEN_ME URL to identify Micropub user. Example: https://johndoe.example
MICROPUB_GITHUB_TOKEN GitHub access token to grant access to repository. Example: 12345abcde67890fghij09876klmno54321pqrst
MICROPUB_GITHUB_USER Username/organisation that owns repository. Example: johndoe
MICROPUB_SITE_GITHUB_REPO GitHub repository in which site files are found. Example: johndoe.github.io
MICROPUB_SITE_URL URL where site is published. Example: https://johndoe.example

Syndication

The following variables can be used to set syndication target(s).

Variable Description
MICROPUB_SITE_SYNDICATE_TO_UID Unique identifier of syndication target. Example: https://social.example/johndoe
MICROPUB_SITE_SYNDICATE_TO_NAME User readable name of syndication target. Example: @johndoe on Example Social Network
MICROPUB_SITE_SYNDICATE_TO Complex syndication target. Provided as a JSON array, e.g.: [{"uid":"https://social.example/johndoe","name":"@johndoe on Example Social Network","service":{"name":"Example Social Network","url":"https://social.example/","photo":"https://social.example/icon.png"},"user":{"name":"johndoe","url":"https://social.example/johndoe","photo":"https://social.example/johndoe/photo.jpg"}}]. Not compatible with MICROPUB_SITES_JSON.

Output style

The following variables allow you to configure the name and destination for files pushed to your repository. These variables will also accept conditional values (described below).

Variable Description
MICROPUB_FILENAME_STYLE File name and path for post. Example: _posts/:year-:month-:day-:slug
MICROPUB_MEDIA_FILES_STYLE File name and path for media files. Example: media/:year-:month-:slug/:filesslug
MICROPUB_PERMALINK_STYLE Jekyll permalink style. Example: /:categories/:year/:month/:title/
MICROPUB_LAYOUT_NAME The name of the Jekyll layout to use for the posts. Set to false to have no layout be added. Defaults to microblogpost
MICROPUB_OPTION_DERIVE_CATEGORY Override the default category
MICROPUB_GITHUB_BRANCH Branch to use for pushes. Useful to test out if things end up where you want them to. Example: micropub

Complex output styles

These configuration options can all be given different values for different types of content by setting up conditions under which each configuration applies. See conditional values.

Complex configuration

Variable Description
MICROPUB_SITES_JSON Complex settings and/or multiple sites (including their syndication targets) provided as JSON, e.g.: '{"site1":{"url":"https://site1.example/","github":{"repo":"site1"},"token":[{"endpoint":"https://tokens.indieauth.com/token","me":"https://site1.example/"}]},"site2":{"url":"http://site2.example/","github":{"repo":"site2"},"token":[{"endpoint":"https://tokens.indieauth.com/token","me":"http://site2.example/"}]}}'
MICROPUB_OPTION_NO_AUTO_CONFIGURE Auto-configure permalink status from the Jekyll repo config. Boolean
MICROPUB_OPTION_DERIVE_LANGUAGES Comma separated list of language codes to auto-detect. Example eng,swe
MICROPUB_HOST Domain name to enforce. Will redirect requests to all other domain names and IP addresses that the endpoint can be accessed on.
MICROPUB_ENCODE_HTML (non-standard) Option to opt out of HTML-encoding of text content if set to false. Defaults to true.

Conditional values

Conditions are set up by assessing the environment variables using a JSON object of the format:

[
  {
    "condition": "bookmark OR name",
    "value": "value-one"
  },
  {
    "condition": "bookmark OR name",
    "value": "value-two"
  }
]

Conditions are fulfills expressions that apply to the properties of the document being saved. Pretty much any property that can be inserted into a YAML front matter can be matched against. All values explicitly set in the Micropub request are available, but some defaults and derived values may not be available, depending on the option configured.

Please open an issue and let me know what conditions you would like to set up.

Modules used

  • micropub-express – an Express Micropub endpoint that accepts and verifies Micropub requests and calls a callback with a parsed micropubDocument.
  • format-microformat – a module that takes a micropubDocument as its input, and converts this data into a standard that can be published elsewhere. Currently supports the Jekyll format.
  • github-publish – a module that takes a filename and content and publishes it to a GitHub repository. The formatted data generated by format-microformat can be published to a Jekyll blog hosted on a GitHub, or a GitHub Pages site.

Related

webpage-micropub-to-github's People

Contributors

am1t avatar dependabot[bot] avatar etiennewan avatar fossabot avatar keithjgrant avatar lildude avatar maxandersen avatar miklb avatar paulrobertlloyd avatar renovate-bot avatar renovate[bot] avatar rosemaryorchard avatar voxpelli avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

webpage-micropub-to-github's Issues

Support for other git hosting

I know this project is named as what it does on the tin. However, it would be great if other git hosting were supported. Specifically it would be great if Bitbucket were supported.

Override category value

I'm trying to use MICROPUB_OPTION_DERIVE_CATEGORY to override the social and article values written by default (using Quill). My goal is to have these values replaced for status when there's no title and post for articles.

I've used the following values for the env variable:

[  
  {  
    "condition": "title = '' ",  
    "category": "status"  
  },  
 {   
    "condition": "title != '' ",  
    "category": "post"  
  }  
]

and also

[  
  {  
    "condition": "title = '' ",  
    "value": "status"  
  },  
 {  
    "condition": "title != '' ",  
    "value": "post"  
  }  
]

But it doesn't work. Is there something I am missing in the documentation? Is there another way to accomplish this?

Thanks.

Add support for Syndication Targets

per w3c recommendation 3.7.3:

To return a list of supported syndication targets, set the q parameter to syndicate-to.
GET /micropub?q=syndicate-to
The endpoint must return the response in [JSON] format, with a key of syndicate-to and the values being objects descriptive of the supported syndication targets. If no endpoints are defined, the value of the syndicate-to object should be an empty JSON array [].

more useful commit message

I find it a bit underwhelming that the commit message is just "uploading " which means when looking at commit logs you can't really easily see what got uploaded.

I made a quick fix that makes it commit message like this:

micropublished article to _posts/2019-01-04-here-we-go.md

following the format:

micropublished <category> to <path>

I can submit PR with the minor change but it is for some reason not passing tests due to changed message and I haven't found an easy way to figure out how the comparison fails.

Errors uploading media to github

This is strange, because media uploads have worked for me, even in the past few days. But today, I’ve had multiple errors when I try to post with a photo attached. The post content is committed to GitHub, but the media file is not.

Error log on Heroku looks as follows:

2018-09-14T13:00:28.887685+00:00 app[web.1]: GitHub Error { message: 'Invalid request.\n\n"sha" wasn\'t supplied.',
2018-09-14T13:00:28.887691+00:00 app[web.1]:   documentation_url: 'https://developer.github.com/v3/repos/contents/#update-a-file' }
2018-09-14T13:00:28.887795+00:00 app[web.1]: Failed to upload media

It might be relevant that this started happening after I tried uploading a large image and got an out of memory error on Heroku. Is it possible the git repository on Heroku is out of sync? I don’t really know how to check that, though I’ve tried re-starting my dynos and even re-deploying the app.

Configuring layout value

Hello again Pelle. Great news! I have finally got this running on my own site, meaning I can post from MicroPub clients, especially Micro.blog. I love it! Now, to refine things a little.

Currently, posts are created with layout: micropubpost, but I would like to change this, ideally omit it (and use a default defined in my config), or change it to layout: note. Is this something that’s possible to do via MICROPUB_OPTION_DERIVE_CATEGORY (which still confuses me), or does this require a feature request?

Thanks again,

Paul

Action Required: Fix Renovate Configuration

There is an error with this repository's Renovate configuration that needs to be fixed. As a precaution, Renovate will stop PRs until it is resolved.

Error type: Preset name not found within published preset config (@voxpelli)

Document Deploying to Netlify

I am freshening up Jekyll Indieweb and am going to document using it to setup a site on Netlify (So can use latest version of Jekyll mainly) with Micropub (also on Netlify) and publish on commit. The Jekyll Webmentions Plugin has been getting a lot of work and thought it would be a good time hook it all up.

I've been building some small sites with Eleventy and eventually want to port the theme to Eleventy and the rest of the steps would be the same.

Support Multiple Categories

Per conversation in IRC, add ability to have multiple, configurable categories. I would assume it could be done based on type of interaction.

Ability to configure front matter values

Possible alternative to #17

I would like to override the default front matter values, but there is currently no way to override these that I can see. For example, I don’t need to set layout: micropubpost, as I have front matter defaults set to configure my layouts. Might it be possible to set front matter defaults in a config value?

(I also don't need to set slug and title, FYI)

Can't publish posts due to duplicate key error

Hello,

First of all, thanks for this project. I'm trying it out using the provided Heroku button, and whenever I try to use one of the micropub clients online, I received the following message:

Logs
2018-09-07T01:22:03.594889+00:00 app[web.1]: { micropubDocument:

2018-09-07T01:22:03.594916+00:00 app[web.1]:    '{\n  "properties": {\n    "name": [\n      "hehehe"\n    ],\n    "content": [\n      {\n        "html": "<p>\\n  heheheheheh\\n  <br />\\n</p>"\n      }\n    ]\n  },\n  "type": [\n    "h-entry"\n  ]\n}',

2018-09-07T01:22:03.594919+00:00 app[web.1]:   date:

2018-09-07T01:22:03.594921+00:00 app[web.1]:    'Fri Sep 07 2018 01:22:03 GMT+0000 (Coordinated Universal Time)' } 'Received a Micropub document'

2018-09-07T01:22:03.596198+00:00 app[web.1]: VError: Error in post handling: duplicated mapping key at line 54, column -32:

2018-09-07T01:22:03.596201+00:00 app[web.1]:     kramdown:

2018-09-07T01:22:03.596203+00:00 app[web.1]:     ^

2018-09-07T01:22:03.596205+00:00 app[web.1]:     at Promise.resolve.then.then.catch.err (/app/node_modules/micropub-express/index.js:391:14)

2018-09-07T01:22:03.596206+00:00 app[web.1]:     at process._tickCallback (internal/process/next_tick.js:68:7)

I didn't have much time yet to drill down what could lead to this issue, but I thought of documenting it anyway. I'll see if I can debug this latter and send some contribution if I find why this is failing.

Thanks!

Updating this service on Heroku

I have no experience with Heroku, but as the simplest way of setting up this service, I clicked on the Deploy to Heroku button, and got going. Yet when the package was updated on GitHub, it wasn’t clear how to get the latest updates. Is there a recommended method for doing so?

So, to get the latest updates, I cloned the repo, installed Heroku CLI, pulled your upstream changes, and then pushed to my Heroko app. Given that I don't intend to make any changes, this seems a roundabout way of keeping the service up-to-date.

Configurable post folders

Currently this service writes files to a _posts folder, but I use Jekyll’s collections feature to publish different post types to different collections. Is this something that could be configured (perhaps via Jekyll’s config file)?

In the simplest case, the ability to change the default post folder location would be great, but further improvements may allow users to configure multiple folder locations, perhaps based on post type?

Enable use of formatter contentSlug

The options forwarded to the formatter should enable one to make use of the contentSlug option (see https://github.com/voxpelli/node-format-microformat#options):

.then(options => new MicropubFormatter({
relativeTo: siteUrl,
deriveCategory: categoryDeriver,
deriveLanguages: options.deriveLanguages,
permalinkStyle: options.permalinkStyle,
filenameStyle: options.filenameStyle,
filesStyle: options.mediaFilesStyle,
layoutName: options.layoutName
}))

That should solve juandpinto/node-format-microformat@bf9ad7b#commitcomment-31828341 and allow eg. a post like https://voxpelli.com/social/2018/12/40669/ / https://github.com/voxpelli/voxpelli.github.com/blob/master/_posts/2018-12-16-40669.md to have a content based slug

Ping @juandpinto

Problem with authentication, no idea where to look for the answer

I'm fascinated by the ideas around the IndieWeb and I wanted to see what's possible with Micropub on my own Jekyll blog on Github pages. I've implemented the script on Heroku but for some reason I can't get it to work.
I try the server tests on micropub.rocks but I get the error

HTTP/1.1 403 Forbidden
Server: Cowboy
Connection: keep-alive
Content-Type: application/json; charset=utf-8
Content-Length: 129
Etag: W/"81-jYBiFMfHPVqIaQiWqkputjODRRY"
Date: Sun, 05 Nov 2017 19:43:18 GMT
Via: 1.1 vegur

{
    "error": "forbidden",
    "error_description": "Token \"me\" didn't match any valid reference. Got: \"http://diggingthedigital.com/\""
}

I don't know what is going wroing and what to fix where. Any pointers would be helpful. Thanks!

Frank

Slug value is ignored

Setting a value for slug in a Micropub client (tested with https://quill.p3k.io and https://micropublish.net), the value gets ignored, and instead a number is assigned, appearing both in a front matter slug property, and in the generated file path.

So, if I set the slug as my-great-slug, and with the following config MICROPUB_FILENAME_STYLE="src/_posts/notes/:year-:month-:day-:slug":

Expected result:

File path: src/_posts/notes/2017-07-15-my-great-slug.md
YAML frontmatter property: slug: 'my-great-slug'

Actual result

File path: src/_posts/notes/2017-07-15-74902.md
YAML frontmatter property: slug: '74902'

Make linking easy in notes. Autolinking?

As pointed out by @miklb and as experienced by myself as well – there's no autolinking of links currently and that's especially a problem in plain text notes. Autolinking or allowing Kramdown links through or something similar would be desirable.

Permalinks don't seem to be working

Hi! I used this package today at indie web camp with https://www.ownyourgram.com. Out of the box it works fine but I wanted to be able to customise the permalink. So my posts would be like https://www.ohhelloana.blog/my-post-name and my instagram posts would have something like https://www.ohhelloana.blog/photos/:slug.

So I tried to replace MICROPUB_PERMALINK_STYLE while being aware about issue #19. Unfortunately it doesn't appear to work.

I had a friend helping out me and it looks like the permalink isn't being added to the content (we made a fork and added logs to check out).
screen shot 2018-11-04 at 13 54 09

Is setting permalinkStyle meant to set the url\permalink front matter property in the post? It appears this is not what the code is doing. Is there another way I can do this?

Support custom permalinks

Hey Pelle. Love this. I've successfully got it working using a test repo on my GitHub and Heroku accounts and can post via Micropublish and Quill. 👍

Small issue: after a successful post, the Location header followed a /:categories/:year/:month/:title/ permalink method which doesn't match my GitHub Pages config. I was taken to the 404 page because my (default?) config uses /:year/:month/:day/:title.html.

So you may want to allow the permalink method to be specified via a Heroku config key.

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

github-actions
.github/workflows/codeql-analysis.yml
.github/workflows/dependency-review.yml
.github/workflows/lint.yml
.github/workflows/nodejs.yml
npm
package.json
  • bunyan-adaptor ^4.0.0
  • dotenv ^8.2.0
  • express ^4.17.1
  • format-microformat ^0.11.1
  • fulfills ^2.1.0
  • github-publish ^3.0.0
  • js-yaml ^3.12.1
  • micropub-express ^0.8.1
  • @voxpelli/eslint-config ^4.0.0
  • chai ^4.2.0
  • chai-as-promised ^7.1.1
  • dependency-check ^4.1.0
  • eslint ^6.8.0
  • eslint-config-standard ^14.1.0
  • eslint-plugin-import ^2.18.2
  • eslint-plugin-jsdoc ^21.0.0
  • eslint-plugin-node ^11.0.0
  • eslint-plugin-promise ^4.2.1
  • eslint-plugin-standard ^4.0.0
  • ghat ^0.14.0
  • husky ^4.3.8
  • installed-check ^7.0.0
  • mocha ^7.0.1
  • nock ^11.7.2
  • npm-run-all2 ^6.0.5
  • nyc ^15.0.0
  • sinon ^8.1.1
  • node >=14.0.0

  • Check this box to trigger a request for Renovate to run again on this repository

better docs for conditionals

I'm trying to setup so i get different collections for each type of posting, i.e. social/, bookmarks/, etc. but no luck.

Tried using condtionals but it does not seem to have any effect - any chance of a more specific example on how this is meant to be configured ?

Configurable location for Jekyll config file location

This project is fascinating, and opening my eyes to the myriad possibilities of publishing directly to/from my GitHub repos, so thanks so much for putting this together!

Right now I have my repo set-up such that posts are located within src/_posts/ and my config is located at etc/jekyll/config.yml. If I could point this service to the location of my config file, my thinking is the source location for content (src) could then be detected, posts written to the correct folder, rather than defaulting to root of my repo.

Tests failing

I was unable to push up my changes to Heroku, as the prepush script calls npm test which for me was failing. I’m not sure why… I wonder if it’s because the test script uses dummy authentication values? i.e.:

const token = 'abc123';
const user = 'username';
const repo = 'repo';

filename = filename || '_posts/2015-06-30-awesomeness-is-awesome.md';

I had to delete the prepush command in order to push my changes to Heroku.

This is the error I get:

> [email protected] test /Users/paulrobertlloyd/Sites/paulrobertlloyd-micropub
> installed-check -e && eslint . && npm run dependency-check && npm run mocha


> [email protected] dependency-check /Users/paulrobertlloyd/Sites/paulrobertlloyd-micropub
> JS_FILES="lib/*.js test/*.js" && dependency-check . $JS_FILES && dependency-check . $JS_FILES --unused --no-dev

Success! All dependencies used in the code are listed in package.json
Success! All dependencies in package.json are used in the code

> [email protected] mocha /Users/paulrobertlloyd/Sites/paulrobertlloyd-micropub
> NODE_ENV=test DOTENV_FILE=test/test.env istanbul cover _mocha -- -u exports -R spec test/**/*.spec.js



  Handler
    main
      1) should format and send content
      2) should upload files prior to content
      ✓ should override existing content if matching URL
GitHub Error {}
      ✓ should not override existing content if no matching URL
      3) should set a custom commit message when formatter returns a category
      4) should format HTML to Markdown and send content
      5) should support category deriving
      6) should support callback based permalink style
      7) should support callback based filename style


  2 passing (66ms)
  7 failing

  1) Handler main should format and send content:
     VError: Failed to call GitHub: request to https://api.github.com/repos/username/repo/contents/_posts/2015-06-30-awesomeness-is-awesome.md failed, reason: Nock: No match for request {
  "method": "PUT",
  "url": "https://api.github.com/repos/username/repo/contents/_posts/2015-06-30-awesomeness-is-awesome.md",
  "headers": {
    "content-type": [
      "application/json"
    ],
    "authorization": [
      "Bearer abc123"
    ],
    "accept": [
      "application/vnd.github.v3+json"
    ],
    "user-agent": [
      "username"
    ],
    "accept-encoding": [
      "gzip,deflate"
    ],
    "connection": [
      "close"
    ],
    "content-length": [
      236
    ]
  },
  "body": "{\"message\":\"uploading article\",\"content\":\"LS0tCmxheW91dDogbWljcm9wdWJwb3N0CmRhdGU6ICcyMDE1LTA2LTMwVDE0OjE5OjQ1LjAwMFonCnRpdGxlOiBhd2Vzb21lbmVzcyBpcyBhd2Vzb21lCmxhbmc6IGVuCnNsdWc6IGF3ZXNvbWVuZXNzLWlzLWF3ZXNvbWUKLS0tCmhlbGxvIHdvcmxkCg==\"}"
}
      at putRequest.then.then.catch.err (node_modules/github-publish/index.js:118:34)
      at <anonymous>
      at process._tickCallback (internal/process/next_tick.js:169:7)

  2) Handler main should upload files prior to content:
     VError: Failed to call GitHub: request to https://api.github.com/repos/username/repo/contents/media/2015-06-awesomeness-is-awesome/foo.jpg failed, reason: Nock: No match for request {
  "method": "PUT",
  "url": "https://api.github.com/repos/username/repo/contents/media/2015-06-awesomeness-is-awesome/foo.jpg",
  "headers": {
    "content-type": [
      "application/json"
    ],
    "authorization": [
      "Bearer abc123"
    ],
    "accept": [
      "application/vnd.github.v3+json"
    ],
    "user-agent": [
      "username"
    ],
    "accept-encoding": [
      "gzip,deflate"
    ],
    "connection": [
      "close"
    ],
    "content-length": [
      50
    ]
  },
  "body": "{\"message\":\"uploading media\",\"content\":\"YWJjMTIz\"}"
}
      at putRequest.then.then.catch.err (node_modules/github-publish/index.js:118:34)
      at <anonymous>
      at process._tickCallback (internal/process/next_tick.js:169:7)

  3) Handler main should set a custom commit message when formatter returns a category:
     VError: Failed to call GitHub: request to https://api.github.com/repos/username/repo/contents/_posts/2015-06-30-51585.md failed, reason: Nock: No match for request {
  "method": "PUT",
  "url": "https://api.github.com/repos/username/repo/contents/_posts/2015-06-30-51585.md",
  "headers": {
    "content-type": [
      "application/json"
    ],
    "authorization": [
      "Bearer abc123"
    ],
    "accept": [
      "application/vnd.github.v3+json"
    ],
    "user-agent": [
      "username"
    ],
    "accept-encoding": [
      "gzip,deflate"
    ],
    "connection": [
      "close"
    ],
    "content-length": [
      223
    ]
  },
  "body": "{\"message\":\"uploading social interaction\",\"content\":\"LS0tCmxheW91dDogbWljcm9wdWJwb3N0CmRhdGU6ICcyMDE1LTA2LTMwVDE0OjE5OjQ1LjAwMFonCnRpdGxlOiAnJwpsYW5nOiBlbgpzbHVnOiAnNTE1ODUnCmNhdGVnb3J5OiBzb2NpYWwKLS0tCmhlbGxvIHdvcmxkCg==\"}"
}
      at putRequest.then.then.catch.err (node_modules/github-publish/index.js:118:34)
      at <anonymous>
      at process._tickCallback (internal/process/next_tick.js:169:7)

  4) Handler main should format HTML to Markdown and send content:
     VError: Failed to call GitHub: request to https://api.github.com/repos/username/repo/contents/_posts/2015-06-30-awesomeness-is-awesome.md failed, reason: Nock: No match for request {
  "method": "PUT",
  "url": "https://api.github.com/repos/username/repo/contents/_posts/2015-06-30-awesomeness-is-awesome.md",
  "headers": {
    "content-type": [
      "application/json"
    ],
    "authorization": [
      "Bearer abc123"
    ],
    "accept": [
      "application/vnd.github.v3+json"
    ],
    "user-agent": [
      "username"
    ],
    "accept-encoding": [
      "gzip,deflate"
    ],
    "connection": [
      "close"
    ],
    "content-length": [
      240
    ]
  },
  "body": "{\"message\":\"uploading article\",\"content\":\"LS0tCmxheW91dDogbWljcm9wdWJwb3N0CmRhdGU6ICcyMDE1LTA2LTMwVDE0OjE5OjQ1LjAwMFonCnRpdGxlOiBhd2Vzb21lbmVzcyBpcyBhd2Vzb21lCmxhbmc6IGVuCnNsdWc6IGF3ZXNvbWVuZXNzLWlzLWF3ZXNvbWUKLS0tCioqaGVsbG8gd29ybGQqKgo=\"}"
}
      at putRequest.then.then.catch.err (node_modules/github-publish/index.js:118:34)
      at <anonymous>
      at process._tickCallback (internal/process/next_tick.js:169:7)

  5) Handler main should support category deriving:
     VError: Failed to call GitHub: request to https://api.github.com/repos/username/repo/contents/_posts/2015-06-30-awesomeness-is-awesome.md failed, reason: Nock: No match for request {
  "method": "PUT",
  "url": "https://api.github.com/repos/username/repo/contents/_posts/2015-06-30-awesomeness-is-awesome.md",
  "headers": {
    "content-type": [
      "application/json"
    ],
    "authorization": [
      "Bearer abc123"
    ],
    "accept": [
      "application/vnd.github.v3+json"
    ],
    "user-agent": [
      "username"
    ],
    "accept-encoding": [
      "gzip,deflate"
    ],
    "connection": [
      "close"
    ],
    "content-length": [
      248
    ]
  },
  "body": "{\"message\":\"uploading xyz\",\"content\":\"LS0tCmxheW91dDogbWljcm9wdWJwb3N0CmRhdGU6ICcyMDE1LTA2LTMwVDE0OjE5OjQ1LjAwMFonCnRpdGxlOiBhd2Vzb21lbmVzcyBpcyBhd2Vzb21lCmxhbmc6IGVuCnNsdWc6IGF3ZXNvbWVuZXNzLWlzLWF3ZXNvbWUKY2F0ZWdvcnk6IHh5egotLS0KaGVsbG8gd29ybGQK\"}"
}
      at putRequest.then.then.catch.err (node_modules/github-publish/index.js:118:34)
      at <anonymous>
      at process._tickCallback (internal/process/next_tick.js:169:7)

  6) Handler main should support callback based permalink style:
     VError: Failed to call GitHub: request to https://api.github.com/repos/username/repo/contents/_posts/2015-06-30-awesomeness-is-awesome.md failed, reason: Nock: No match for request {
  "method": "PUT",
  "url": "https://api.github.com/repos/username/repo/contents/_posts/2015-06-30-awesomeness-is-awesome.md",
  "headers": {
    "content-type": [
      "application/json"
    ],
    "authorization": [
      "Bearer abc123"
    ],
    "accept": [
      "application/vnd.github.v3+json"
    ],
    "user-agent": [
      "username"
    ],
    "accept-encoding": [
      "gzip,deflate"
    ],
    "connection": [
      "close"
    ],
    "content-length": [
      236
    ]
  },
  "body": "{\"message\":\"uploading article\",\"content\":\"LS0tCmxheW91dDogbWljcm9wdWJwb3N0CmRhdGU6ICcyMDE1LTA2LTMwVDE0OjE5OjQ1LjAwMFonCnRpdGxlOiBhd2Vzb21lbmVzcyBpcyBhd2Vzb21lCmxhbmc6IGVuCnNsdWc6IGF3ZXNvbWVuZXNzLWlzLWF3ZXNvbWUKLS0tCmhlbGxvIHdvcmxkCg==\"}"
}
      at putRequest.then.then.catch.err (node_modules/github-publish/index.js:118:34)
      at <anonymous>
      at process._tickCallback (internal/process/next_tick.js:169:7)

  7) Handler main should support callback based filename style:
     VError: Failed to call GitHub: request to https://api.github.com/repos/username/repo/contents/second/awesomeness-is-awesome.md failed, reason: Nock: No match for request {
  "method": "PUT",
  "url": "https://api.github.com/repos/username/repo/contents/second/awesomeness-is-awesome.md",
  "headers": {
    "content-type": [
      "application/json"
    ],
    "authorization": [
      "Bearer abc123"
    ],
    "accept": [
      "application/vnd.github.v3+json"
    ],
    "user-agent": [
      "username"
    ],
    "accept-encoding": [
      "gzip,deflate"
    ],
    "connection": [
      "close"
    ],
    "content-length": [
      236
    ]
  },
  "body": "{\"message\":\"uploading article\",\"content\":\"LS0tCmxheW91dDogbWljcm9wdWJwb3N0CmRhdGU6ICcyMDE1LTA2LTMwVDE0OjE5OjQ1LjAwMFonCnRpdGxlOiBhd2Vzb21lbmVzcyBpcyBhd2Vzb21lCmxhbmc6IGVuCnNsdWc6IGF3ZXNvbWVuZXNzLWlzLWF3ZXNvbWUKLS0tCmhlbGxvIHdvcmxkCg==\"}"
}
      at putRequest.then.then.catch.err (node_modules/github-publish/index.js:118:34)
      at <anonymous>
      at process._tickCallback (internal/process/next_tick.js:169:7)



=============================================================================
Writing coverage object [/Users/paulrobertlloyd/Sites/paulrobertlloyd-micropub/coverage/coverage.json]
Writing coverage reports at [/Users/paulrobertlloyd/Sites/paulrobertlloyd-micropub/coverage]
=============================================================================

=============================== Coverage summary ===============================
Statements   : 64.47% ( 49/76 )
Branches     : 52.78% ( 19/36 )
Functions    : 80% ( 4/5 )
Lines        : 66.67% ( 48/72 )
================================================================================
npm ERR! code ELIFECYCLE
npm ERR! errno 7
npm ERR! [email protected] mocha: `NODE_ENV=test DOTENV_FILE=test/test.env istanbul cover _mocha -- -u exports -R spec test/**/*.spec.js`
npm ERR! Exit status 7
npm ERR! 
npm ERR! Failed at the [email protected] mocha script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/paulrobertlloyd/.npm/_logs/2017-07-08T19_29_47_292Z-debug.log
npm ERR! Test failed.  See above for more details.

Create separate permalink option for media files

I host my site's source files in src/, so my media filename env var is:
MICROPUB_MEDIA_FILES_STYLE=\"src/assets/microblog/:year-:month-:day-:filesslug\"

but when the site is compiled, the media files are available via URL at this kind of format:
https://example.com/assets/microblog/:year-:month-:day-:filesslug

The current implementation assumes that these two are equivalent and uses the former in the YAML frontmatter of the post file that it generates, when I would like it to use the latter. It would be nice if there were two options (similar to MICROPUB_FILENAME_STYLE and MICROPUB_PERMALINK_STYLE) for media files... One for the filename (used when uploading media) and one for the permalink (used for referencing the files via URL after the site is deployed).

Support AWS Lambda

As suggested in https://twitter.com/mothersele/status/751012678655696896 it would be interesting to look into supporting AWS Lambda for this project.

Micropub requests fits the model of spinning up a server for each one and I between the requests have no servers running at all.

Some adjustments likely needs to take place. Both in how requests are accepted from the AWS API Gateway and how to configure the code.

Configurable Location for Media Files

Currently images and video are set to a /media directory. Would be nice to be able to define that path, especially for use with jekyll-assets gem.

Missing authorization header or body parameter

I tried to configure this the best I could, but I'm getting nothing. When I run the app on Heroku it just comes up as cannot GET / and when I try to access the endpoint I get {"error":"invalid_request","error_description":"Missing \"Authorization\" header or body parameter."}

This is my first Heroku app, so I'm also rather confused by their interface. I successfully adjusted my github repo URL (just to test whether or not that needed a full URL) but have NO idea how to force Heroku to rebuild.

Once again foiled by IndieWeb. :(

Heroku environmental variables require extra quotes around values

The environmental variables MICROPUB_PERMALINK_STYLE, MICROPUB_MEDIA_FILES_STYLE, MICROPUB_FILENAME_STYLE require quotes around the values in the Heroku configuration, though the rest don't. This manifests as "app crashed" in the Heroku logs if you do not include them.

I'm guessing it's because the values are parsed as JSON as their first step. It may be worth documenting these keys as requiring the extra quotes because it took me a little while to figure it out. At the very least, hopefully this issue is discoverable.

Option to not provide a category (and a question about the condition property)

I’m looking at the configuration variable MICROPUB_OPTION_DERIVE_CATEGORY, and have two questions:

  1. Is it possible with this config variable to state that I don’t want to add a category? In my particular instance, I have front matter defaults set up, which makes setting a category on individual posts unnecessary (and harder to change in the future).

  2. What are the conditions I should be testing for? The example provided ([{"value":"category-name","condition":"bookmark OR name"}]) doesn't make this very clear. What is bookmark and name?

Thanks!

Improve documentation for .env settings

Hey, thanks for making this. I'm working on setting it up now.

Maybe it's just me, but I'm a little confused on what the correct values are to enter for each setting. Maybe some comments or a link to another page would help? I'll try digging through the code and figure some of them out.

Tracking: Collaboration with other Node.js Micropub projects

This is a tracking issue for collaboration work in my part of the Node.js IndieWeb ecosystem.

Issues in other repos

My Micropub-related modules

  • micropub-express – an Express Micropub endpoint that accepts and verifies Micropub requests and calls a callback with a parsed micropubDocument.
  • format-microformat – a module that takes a micropubDocument as its input, and converts this data into a standard that can be published elsewhere. Currently supports the Jekyll format.
  • github-publish – a module that takes a filename and content and publishes it to a GitHub repository. The formatted data generated by format-microformat can be published to a Jekyll blog hosted on a GitHub, or a GitHub Pages site.

Other IndieWeb projects of mine

Collaboration opportunities found so far

Authenticates but won't post

I'm struggling here. If anyone can help. I can authenticate without any trouble, but I can't get any further with Quill or Micropub.rocks. I'm using Netlify, if that makes any difference?

This is a problem with formatting though, right?

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: Sat, 01 Sep 2018 03:48:50 GMT
Via: 1.1 vegur

Bad Request

Any help appreciated, I'll send you a chocolate fish. No seriously, if you want one.

Support for OwnYourGram

Not sure if it would be more for the node express module, but discussing with @aaronpk today in IRC about ability to to have a syndicate-to link for OYG so you could POSSE the OYG post to other silos.

He suggested could add logic to micropub endpoint and that he includes client_id in the login flow to help with that.

Any thoughts on how that could work?

Tags as YAML list

I need to have the tags as a YAML list so looking like

tags:
 - tag1
 - tag2

But I can't understand how to do it.
Thanks for the help

Does the library support the Micropub Media Endpoint?

I'm trying to use Micro.Blog to post via my endpoint hosted on Heroku. But the micro.blog app keep asking for a Media Endpoint which the Heroku endpoint doesn't provide.

Does the library support it? Or am I doing something wrong?

Thanks.

support alt text

It looks like alt text isn't getting added to the front matter (from Quill at least)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.