Code Monkey home page Code Monkey logo

mastr-cntrl's Introduction

About

Mastr Cntrl is a part of a Microservices suite of IndieWeb tools.

  • Mastr Cntrl is the Microservice responsible for recieving Micropub and social content.
  • MC Webmention is the webmention service. Designed to send and recieve Webmentions.
  • MC Syndication is the syndication service. Designed to syndicate content to other platforms.

Purpose

The service: - Recieves Micropub content, and transform the JSON in to a Markdown file with associated frontmatter. - POST's transformed content in to a Github Repo (via the API) to a designated location. - Recieves Media content and POST in to a Github Repo (via the API) to a designated location. - Recieves 3rd party Social content (in development at the moment).

Install

  1. Download the content and install with npm install.
  2. Create your .env file and use the sample.env as your guide.
  3. Run with npm start

Dependencies

Timezone

You will need to specify your timezone using this timezone list in the .env file. Use the sample.env as your guide.

The timezone is used to generate the blog post frontmatter and is also used on my blog to generate URLs. You may also do the same, so I recommend setting it to a 24 local timezone to avoid clashes in a 12 hour period or to avoid posts published at random times, instead of your local time.

It is also advantageous to do this so you are not constrained where you host Mastr-Cntrl. You can host it in one part of the world and post using your local time if you like.

Optional extras

Slack

If you wish to use additional Slack logging:

  1. Create an 'Incoming WebHooks app', over on Slack.
  2. Copy the webhook key., generated.
  3. Paste the key in to your .env file following the sample.env file as a guide.

Syndicating to Twitter

Mastr-Cntrl doesn't syndicate to Twitter (but mc-syndication does). However if you are creating a Micropub post and wish to syndicate to Twitter, the Micropub client needs to know your Twitter details, so they can be saved alongside the post in the frontmatter.

Add your twitter username in the .env file following the sample.env file as a guide and it will appear in the micropub client as an option.

mastr-cntrl's People

Contributors

dependabot[bot] avatar fossabot avatar snyk-bot avatar vipickering 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

Watchers

 avatar  avatar

Forkers

fossabot dz4k

mastr-cntrl's Issues

Views

Make views return either a nice formatted page, or a json array.

POSSE (POST to 3rd Party such as Medium/Twitter/Micro.blog etc)

I need a way to identify if a post is published, then fire a webhook to initiate Micropub to GET content from Github and POST to source.

  • On git push vincentp.me fire web hook from Github.
  • Web hook pings Micropub API, to get latest post.
  • Micropub API does a GET on Github Repo /posts folder where X matches X for latest date.
  • GET latest post(s) content as above and publish to external source.

Handle Emoji

Currently when Emoji are used in comments they get garbled in the conversion.

This is because I am not handling escaping or conversion of anything. Just processing as plain text.

Better Micropub Error responses

3.8 Error Response

If there was an error with the request, the endpoint must return an appropriate HTTP status code, typically 400, 401, or 403, and may include a description of the error. If an error body is returned, the response body must be encoded as a [JSON] object and include at least a single property named error. The following error codes are defined:

HTTP 403: "error":"forbidden" - The authenticated user does not have permission to perform this request.
HTTP 401: "error":"unauthorized" - No access token was provided in the request. Note that this is different from the HTTP 403 response, as the 403 response should only be used when an access token is provided and the user does not have permission to perform the request.
HTTP 401: "error":"insufficient_scope" - The scope of this token does not meet the requirements for this request. The client may wish to re-authorize the user to obtain the necessary scope. The response may include the "scope" attribute with the scope necessary to successfully perform this request.
HTTP 400: "error":"invalid_request" - The request is missing a required parameter, or there was a problem with a value of one of the parameters
Clients should treat unexpected error strings as a generic error. The response body may also contain an error_description property with a human-readable description of the error message, used to assist the client developer in understanding the error. This is not meant to be shown to the end user.

I need to return more granular errors if possible.

A more efficient build process

Instead of adding the data to a JSON file (though we can still do that to keep a record).

The data needs to be written directly in to the post some way.

I need to think around how I add data to the templates to do this.

Sending Webmentions

Expand webmentions so that:

  1. Any posts modified or updated are added to the webmention queue, along with new posts. (vincentp site)
  2. Loop through all the items in the JSON array and POST each one to Telegraph.
  3. Update date in Github again.

output multiple images on notes/replies

The media endpoint supports multiple imagery and will return stings for location in an array.

The frontmatter supports this.

The layout does not. It will only output the first image.

Accept ownyourgram content

  • Successfully get content for test post and send correct response
  • Format content being injected in to Github with correct filename

tagging is broken

It looks like we are iterating over the tags array incorrectly.

Instead of accessibility, it outputs a c c e s s i b i l i t y for example.

Build _data files for web mentions

  • Build data file instead of using webmention.io on vincentp.me
  • Make vincentp.me use data file
  • Write to file directly from API (this works on a test file)

Double webmention bug/Missing Webmentions

Posting on swarm and backfeeding is suddenly resulting in occasional double posting of webmentions or dropped mentions

I have also spotted a failed attempt to update the webmention.json file.

Add some extra logging around all webmention functionality and track behaviour to analyse why this is happening.

From the archive tweets

It would be nice if each week at a certain time the API published a "from the archives" tweet linking to an article.

Standardise Post formatting

Really, I don't need separate format-type.js files.

Instead I need to isolate the differences and append them to a standard format.

I already have the logic to identify separate sources so I can reuse this to apply the differences and normalise the rest of the code, removing the duplication.

Accept Twitter posts

I can use Zapier to push my Twitter content over to the API.

This can then be formatted, and added for webmentions.

I'll need slightly different designs for tweets, replies, retweets and likes.

Build Webmention endpoint

  • Create webmention endpoint URL
  • Validate incoming
  • Take Webmention and formate to JSON.
  • Perform PATCH operation to Github and update data file
  • Send outcome status (200/404 etc)
  • Support Create New
  • Support Update

Accept last.fm content

I can either pull this data myself from last.fm. Or use some 3rd party service to get the data summaries.

Use webmention.io webhook

Use the webmention.io webhook and callback secret instead of Zapier.

Replace the webmention-update (GET) route with a webmention(POST) route.

The new route will need to check the token validity and if OK, format the webmention and push it in to the JSON file.

Is there a better way to store webmention statically?

I've been thinking that perhaps a single JSON file is not the best way to store this content.

If it's in one file a static build site needs to loop through it all multiple times to get all the right content in the right places as it builds.

Would it be quicker if the webmention was stored in front-matter for the blog post it is related to?

  • This could introduce a number of challenges, including referencing the right file.
  • An alternative would be for each post to have an attached webmention file to read/enter. Although this could simply re-introduce the longer build time in a different manner.

Recommend trying a spike to see how inserting in the front matter affects performance.

Syndication mention is broken

If I syndicate to another site, then unless it is Medium it is not output.

I need to make this iterate over an array or list of items. Articles in the future could be syndicated to multiple sources.

Handle Syndication targets

When Micropubbing.

Once we select a syndication target, the system needs to handle syndicating the content.

Content is returned from Quill (best example) in this format.

{
"mp-syndicate-to":["https://twitter.com/vincentlistens/"]
}

On receiving the package we need to look for the existence of this item, and if it exists handle sending the json content to each provider on the list. We should get the destination of each item as it is posted, so they can be added to the array of data posted to the Github API and output as "syndicated to: xxx, xxx,xxx" etc.

Content not found error (and error response unable to be sent)

Hi Vincent,

Hope you don't mind, but been playing around with this micro service to see if I can use it for my own purposes. However, I have run across a few issues, so thought best to report them here.

The first is that it seems that even though JSON is being sent with the content value populated, mastr-cntrl is reporting there being no content. In addition to this, on attempting to send a 400 error response, res is not defined:

11:45 PM
23:45:43.134Z  INFO micropubAPI: json body {"h":"entry","access_token":"TOKEN_WOZ_HERE","content":"This is my content","category":["test"],"mp-slug":"test"}
11:45 PM
23:45:43.521Z  INFO micropubAPI: {"me":"https://micropub.paulrobertlloyd.com/","issued_by":"https://tokens.indieauth.com/token","client_id":"https://quill.p3k.io/","issued_at":1545080991,"scope":"create update media","nonce":287327756}
11:45 PM
23:45:43.523Z  INFO micropubAPI: Service Is: https://quill.p3k.io/
11:45 PM
23:45:43.523Z  INFO micropubAPI: Payload JSON: {"h":"entry","access_token":"TOKEN_WOZ_HERE","content":"This is my content","category":["test"],"mp-slug":"test"}
11:45 PM
23:45:43.523Z  INFO micropubAPI: Service Quill. Creating Note
11:45 PM
23:45:43.523Z  INFO micropubAPI: Note JSON: {"h":"entry","access_token":"TOKEN_WOZ_HERE","content":"This is my content","category":["test"],"mp-slug":"test"}
11:45 PM
23:45:43.523Z  INFO micropubAPI: No Content. Ending
11:45 PM
23:45:43.526Z ERROR micropubAPI: res is not defined
11:45 PM
    ReferenceError: res is not defined
11:45 PM
        at Object.note (/app/app/functions/formatters/note.js:29:9)
11:45 PM
        at authAction (/app/app/routes/post/micropub.js:109:34)
11:45 PM
        at process._tickCallback (internal/process/next_tick.js:68:7)

I also noticed that in app/routes/post/micropub.js you use response as a parameter for the sendtoGithub function , but then res inside it. Changing that caused further issues (logger.info(JSON.stringify(json)) on line 63 returned a circular JSON error message) at which point I thought I'd stop fiddling and file this issue.

(N.B. Currently running this app on Glitch, if that helps debug this issue.)

Microformats

I haven't done a good job implementing the MF code for post entries.

This needs reviewing and checking against a parser.

Support Webmention Replies

I can now accept Webmention reply strings from Quill or another 3rd party.

Outstanding is

  • to send a webmention on publish
  • to format the reply text. Get the domain.com instead of dumping the full string.

Accept incoming web feeds

  1. I need to accept an incoming feed.
  2. Classify it in to a format
  3. Save/Create in memory the file
  4. Submit it to Github somehow.

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.