Code Monkey home page Code Monkey logo

webpage-webmentions's Introduction

A WebMention Endpoint

IndieWeb js-semistandard-style Types in JS Follow @voxpelli@mastodon.social

A site that receives and embeds WebMentions for other sites. makes the WebMentions embeddable through a javascript, similar to how eg. Disqus works.

A live deploy of this can be found on webmention.herokuapp.com. One can also sign up to that one rather than deploying ones own if one likes.

Deploying it yourself?

Then please let me know. So far I'm easiest to reach on Twitter as @voxpelli.

To install

Locally

  1. Set up a new PostgreSQL database
  2. Run npm run install-schema to set up the tables
  3. Set up the environment variables by eg. copying sample.env to .env
  4. Run foreman start or npm start

Heroku

  1. Set up a new application
  2. Set up a database for the new application
  3. Set up environment variables using heroku config
  4. Push up the code
  5. Use a One-Off Dyno to set up the tables: heroku run npm run install-schema

To update

Locally

Just run npm run migrate-schema.

Heroku

  1. Before you push any code you may want to activate the Maintenance Mode if it is a breaking update
  2. Push the new code and let Heroku deploy it
  3. Use a One-Off Dyno to do the migration: heroku run npm run migrate-schema
  4. If you activated the Maintenance Mode – then remember to deactivate it as well

Revert an update

Just run npm run rollback-schema locally or, if on Heroku, use a One-Off Dyno to do the rollback: heroku run npm run rollback-schema And afterwards – of course make sure that you also revert your code to a version that matches the schema – but you already knew that of course :)

Environment variables

You can set these up locally by simply copying sample.env to .env and changing the values in that file.

Required

  • DATABASE_URL - a configuration URL for the PostgreSQL database
  • WEBMENTIONS_COOKIE_SECRET - a secret for the cookie that will make sure a user stays logged in
  • WEBMENTIONS_GITHUB_ID - a GitHub OAuth consumer id, used for logging in with GitHub
  • WEBMENTIONS_GITHUB_SECRET - a GitHub OAuth consumer secret
  • WEBMENTIONS_HOSTNAME - the hostname of the place your hosting the application on. Used when eg. constructing the callback URL sent to the GitHub API.

Optional

  • WEBMENTIONS_USER_LIMIT - the total maximum of users you want to be able to use your application. Defaults to 6.
  • WEBMENTIONS_DEV_THROTTLING – in a development environment, enables throttling for local pings made by eg. webmention-testpinger – needed to test throttling mechanism
  • WEBMENTIONS_DEV_SIGINT_CLEANUP – enables graceful shutdown on SIGINT command
  • NEW_RELIC_LICENSE_KEY - the license key for New Relic, if you want to use that
  • NEW_RELIC_ENABLED - set to true if you want to use New Relic

Requirements

  • Node.js
  • PostgreSQL (or possibly any other Knex-compatible database like MySQL/MariaDB, SQLite)
  • (Foreman – optional, but recommended in a development environment as this project is built around the Procfile and .env files that it and Heroku uses. Currently only one process is used though and a backup .env parser is provided so not needed.)

Try it out locally

Install webmention-testpinger then do:

webmention-testpinger --endpoint=http://127.0.0.1:5000/api/webmention --target=http://127.0.0.1:5000/

webpage-webmentions's People

Contributors

dependabot[bot] avatar fossabot avatar kevinmarks avatar renovate-bot avatar renovate[bot] avatar sknebel avatar stuartlangridge 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

Watchers

 avatar  avatar  avatar  avatar  avatar

webpage-webmentions's Issues

Identify why some Bridgy posts seems to get duplicated

First pointed out by @kevinmarks on: http://www.kevinmarks.com/decentralweb2016-06-08.html

Then also discovered on @miklb's blog: https://miklb.com/jekyll-and-microblogging Update: Not using my endpoint, but instead webmention.io, but has a duplication problem as well which points to Bridgy being part of the problem maybe.

This happened before the deploy of 0.11.x so it means that the cause has to be outside of this service, but it could very well be due to me interpreting something wrong. Will have to dig into it.

Support Salmentions

With #18 fixed and the comments now being curlable the next step would be to utilize that curlability by becoming part of the salmentions ecosystem and both receive salmentions from others and forward them.

This moves this endpoint closer to be able to take part in a SWAT0 dance.

  • Fetch the WebMention pinged target site if it isn't already in the database and store it in entries and especially ensure to save its interaction targets
  • Fetch all the interaction targets found that isn't already in the database and extract their WebMention endpoints. Save these as entries just like all other entries?
  • Parse the comments included in the WebMention pinged source
  • Fetch each found comment that isn't already in the database and save them as entries and mentions. If they are not targeted at a registered site, then maybe mark them as "external" or something
  • Present the full comment tree – mentions of mentions of mentions – at least in the embed type created in #18 and especially on the standalone page
  • Ensure that a too deep comment tree doesn't break presentation – look at how eg. Disqus does it – after X many levels don't indent the additional levels anymore. This is a pure styling issue.
  • Whenever all comments has been fetched, if any new were found – send a WebMention to each interaction target of the original WebMention pinged target
  • Ensure that if an earlier post updates to mention a post later in the chain that no infinite salmentioning will happen – this is probably more of a problem in the presentation part than in the pinging part. If the relation gets circular then any attempt at trying to fetch a tree representation of that relation will be infinitely deep. A graph database would really make sense here – fetching an entire tree in PostgreSQL isn't really that optimal – one would really need one JOIN per level
  • Make it opt-in? So only those using the embed from #18 actually get Salmentions sent as the rest won't support it anyway?
  • Ping person-tags – important – critical part of SWAT0
  • Ensure pings are only sent on updates and try to avoid getting into a circular pinging exercise where you ping others and therefore they ping you, so therefore you ping them again and so on
  • Ensure pings are only sent when the data presented on the u-responses page has changed – we should not ping when the receiver has no way of detecting any actual change
  • Do some caching – don't refetch everything always
  • On an update: Diff the content and only ping and refetch what has actually changed – true especially for comments
  • Add support for if-modified-since and etag to check for fresh content
  • Update the js-embed to also show the full comment tree
  • Add a way to actually opt-in in the UI – and require IndieAuthing (related to #30) with the domain to verify ownership or something before allowing it
  • Support sending Salmentions for non-interactions, for the mentions, without pinging hundreds of URL:s – a tricky one

So this more or less means that rather than just simply fetching a single page, the source, per WebMention the script would, in the worst case scenario, have to fetch four different types of pages: The source, the target, all comments included in the source and all targets of the target.

And when all that is done it has to send WebMentions to all the WebMentions endpoints of the targets targets.

So a source with a single comment on a target with a single target would mean fetching 4 pages and doing 1 WebMention rather than just fetching 1 page as is done today. And 4 times the metadata will be stored. This metadata will be possible to use to better present reply-context and such on eg. the standalone embed pages and such though and could perhaps be used in other ways as well.

Add paging and count limits

Eventually someone will get very many mentions and it will be unfeasible to show them all at once. Paging should be introduced both in the embeds and in the curlable views introduced in #18.

In the embeds the count should be configurable. On the standalone page it should probably have a fixed, high default – like eg. 100 – which would probably be the highest maximum to allow anywhere.

Add a HTML success page

Just like there's now a HTML page for GET requests to the endpoint itself it would be nice to have a HTML page for the response of a POST so that HTML forms posting to the page can end up somewhere nice.

As we know the target we can also provide a nice link pointing back to he target so that the page doesn't become a dead end for people.

Tasks needed for this:

  • basic layout system to make the layout of the page reusable (perhaps through the use of node-tema?)
  • success page
  • error page

Add a log of failed pings

Nobody is perfect and neither is this app – it will fail, but it should save the necessary data to be able to recover as well as possible once the failing link in our chain of events has been identified.

By logging (to a reasonably degree) all unexpectedly failed errors into a table of its own (there's already one called failurelog) it will get easier to both identify errors (the log services at Heroku currently just keeps 7 days worth of logs) and to rerun them if we find that a bug in the code was the failing factor.

Add some kind of working push notificiations

Until eg. snarfed/granary#31 is completed an RSS/Atom-feed of mentions which one can feed into eg. IFTTT to get notifications from would be great. And it needs to be PuSH-enabled to get push notifications.

This is a requirement for SWAT0.

  • Create Atom feed
  • Add PuSH to h-feed and Atom feed

Relax the throttling queue limit and add a retry mechanism

As the endpoint equivalent of pfefferle/wordpress-webmention#30 we should be as tolerant of clients as the clients are of the servers – that issue is about making a client retry its pings when a server fail and likewise we should also retry a ping confirmation when a client fails to deliver a source page and also be very relaxed in how many pings we accept within a limited timeframe.

This would require that pings are saved in the database before they are confirmed so that they can survive a restart or crash. One reason to not accept more pings right now than we do is that they will all get lost if eg. the Heroku instance goes to sleep so first move would be to solve that. Saving them to the database will also enabled retries over a long timespan as well – as discussed in the other issue.

And lastly: Document the final solution on http://indiewebcamp.com/webmention#retrying

Dedupe based on h-entry u-url

As a follow up to #35 and following the thoughts written down in the wiki at https://indieweb.org/Webmention-brainstorming#de-duplication it probably makes sense to do some more sophisticated deduping than the current one and have the u-url be a basis for deduping as well and when a u-url is used for deduping have the source "closest" to that u-url be the winner (exact match, host match etc).

This will avoid the situation that appeared in #35 from happening again:

2016-07-13 at 18 26

Node 6.x

I was just trying to set this up on my server when I realized that it wanted iojs 3.x. I was just wondering if you had any plans to update it to use node 6. Thanks!

Query per domain

As there is no way to export the webmentions, an easy way to implement that is to query per domain and retrieve all mentions for it.

Basically is doing WHERE LIKE instead of WHERE =

Resolve external h-cards

Posts on my site https://jeremycherfas.net point to the home page for author. There is an h-card on the home page, but it does not get picked up at the moment.

Meanwhile, I'll try to add the h-card to individual posts.

Malicious webmentions

Hi,

thanks again fro your app, that's amazing :)
I just checked with checkmention, and I noticed the malicious one were passing by.. Here is an example.
when I'll have time, I'll have a look, I open the issue more to get it logged.

Thanks!

wildcards or n-scripts

What do you think about a request on a "base" url or a list of urls to get all mentions of these urls.

Why I ask: I have a "contact" section on the http://pfefferle.github.io/openwebicons/ and I want to show every mention there, independent from the specific mentioned URL.

Post title is being appended to URL, resulting in invalid URL

Mention URLs are being appended with a post's title as seen in the mention at this URL: https://prettygoodhat.com/note/letsencrypt-pair/; the correct mention URL is https://prettygoodhat.com/post/further-indieweb-adventures/; the URL linked in the mention is https://prettygoodhat.com/post/further-indieweb-adventures/Further%20adventures%20in%20IndieWeb -- the extra string is the title of the source post.

I apologize if this is a usage question and I've made a mistake in my formatting; but I'm honestly not sure how I could be mis-specifying the URL in this way. I don't see that url representation in my page source, anyway. Maybe this is a bug somewhere?

A portion of the JSON for that mention is below:

{"source":"https://prettygoodhat.com/post/further-indieweb-adventures/","target":"https://prettygoodhat.com/note/letsencrypt-pair/","data":{"url":"https://prettygoodhat.com/post/further-indieweb-adventures/Further%20adventures%20in%20IndieWeb","name":"Further adventures in IndieWeb","published":1520780017032,"summary":"[...]","author":{"name":"Alan S.","photo":"https://prettygoodhat.com/pics/u-photo.png","url":"https://prettygoodhat.com/"}}},

Add a moderation tool

If someone finds an unwanted webmention then they should be able to remove it. Kind of a critical feature and without it a version 1.0.0 can't really be claimed to be achieved.

When manual moderation is possible, automatic one can also be added on top – such as spam-protection – but many such mechanisms needs to be possible to audit by users and therefore the manual interface has to come first.

Supporting posting received comments to Micropub endpoint

For those who don't want to rely on javascript for displaying their received WebMentions and neither wants to pull them themselves from any of the API:s provided already a standard support for pushing them to a Micropub endpoint would be great.

It's something that @aaronpk is already more or less doing in his endpoint: https://github.com/aaronpk/webmention.io/blob/master/helpers/formats.rb#L80 Almost Micropub, but not really.

Would be great if our two endpoints supported the same API as eg. @dshanske was intrigued by that for use with WordPress. See chat logs: https://chat.indieweb.org/dev/2016-08-15#t1471278307859000

Enable a single-user mode and make it the default

It's great that people can use my endpoint, but in the spirit of the indieweb they should of course be able to host it on their own as well.

So it should be possible to activate a single user mode where people can't sign up but where rather everything is configured like it is in https://github.com/voxpelli/webpage-micropub-to-github

It should also be possible to easily deploy the project, using an Heroku button or any of the other buttons that have been suggested for that project: voxpelli/webpage-micropub-to-github#26

Do however note below such a button that unlike the Micropub endpoint a Webmention endpoint will need to pretty much run 24/7 as long as people interacts with oneself 24/7 and with scripts embedded on one sites that's very likely to happen. With a future #37 the need would be less, but still – every mention or Salmention would activate ones server and that would quickly eat up the free server time one has on Heroku

Release domain name from old GitHub account

I changed GitHub accounts recently and my domain is still associated with the old account, which has been deleted. Is there any way I can get the domain released so I can add it to my current account?

Dependency Dashboard

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

Other Branches

These updates are pending. To force PRs open, click the checkbox below.

  • Update dependency express to v4.19.2 [SECURITY]
  • Update dependency grunt to v1.5.3 [SECURITY]
  • Update dependency moment to v2.29.4 [SECURITY]

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/ci.yml
.github/workflows/codeql-analysis.yml
.github/workflows/dependency-review.yml
.github/workflows/lint.yml
npm
package.json
  • @voxpelli/metadataparser ^2.0.0
  • @voxpelli/metadataparser-mf2 ^0.4.0
  • @voxpelli/passport-dummy ^1.0.0
  • body-parser ^1.18.3
  • cors ^2.5.2
  • express ^4.16.3
  • express-session ^1.17.0
  • faker ^2.1.1
  • fetch-politely ^2.0.0-3
  • knex ^0.15.2
  • knex-migrator-extension ^0.1.4
  • lodash.clonedeep ^4.5.0
  • lodash.escape ^4.0.1
  • lodash.intersection ^4.4.0
  • lodash.isempty ^4.4.0
  • lodash.omit ^4.5.0
  • lodash.pick ^4.4.0
  • lodash.union ^4.6.0
  • lodash.uniq ^4.5.0
  • lodash.values ^4.3.0
  • moment ^2.22.2
  • passport ^0.4.0
  • passport-github ^1.1.0
  • pg ^7.4.3
  • pg-pubsub ^0.5.0
  • request ^2.86.0
  • tema ^0.3.1
  • verror ^1.10.0
  • @types/chai ^4.2.4
  • @types/chai-as-promised ^7.1.2
  • @types/express ^4.17.2
  • @types/knex ^0.15.2
  • @types/lodash.clonedeep ^4.5.6
  • @types/mocha ^5.2.7
  • @types/request ^2.48.3
  • @types/sinon ^7.5.0
  • @types/supertest ^2.0.8
  • @types/verror ^1.10.3
  • chai ^4.1.2
  • chai-as-promised ^7.1.1
  • coveralls ^3.0.7
  • dependency-check ^4.1.0
  • dotenv ^8.2.0
  • eslint ^6.6.0
  • eslint-config-standard ^14.1.0
  • eslint-plugin-es ^2.0.0
  • eslint-plugin-import ^2.18.2
  • eslint-plugin-node ^10.0.0
  • eslint-plugin-promise ^4.2.1
  • eslint-plugin-security ^1.4.0
  • eslint-plugin-standard ^4.0.1
  • eslint-plugin-unicorn ^12.1.0
  • grunt ^1.0.2
  • grunt-contrib-concat ^1.0.1
  • grunt-contrib-uglify ^1.0.2
  • husky ^3.0.9
  • installed-check ^3.0.0
  • mocha ^6.2.2
  • nock ^11.7.0
  • npm-run-all ^4.1.5
  • nyc ^14.1.1
  • sinon ^7.5.0
  • supertest ^4.0.2
  • typescript ^3.7.2
  • webmention-testpinger ^0.7.0
  • node ^10.0.0 || ^12.0.0

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

Support all CRUD operations

The main blocker for a 1.0.0 release I think is supporting full CRUD operations. To be a good citizen with in the IndieWeb community one should respect peoples changes to and removal of posts and the current code of this app only accepts the very first initial creation ping and considers all subsequent pings as weird duplicates and that has to change.

Related IndieWeb wiki pages: http://indiewebcamp.com/CRUD

  • update of entry and mention on repeated ping
  • removal of entry and mention on new ping from same source
  • removal of entry (and probably mentions) when source is tombstoned
  • removal of entry and mention when source is completely gone (eg. 410)
  • sync implementation with the flow described in the wiki
  • add any meaningful documentation of this implementation to the wiki

Enable test for content on a page

It would be nice if I could decide whether to display the webmention block on my site depending on whether there is any content to display. If it were possible to test that the script will return anything, that would be great.

Feature: persistent webmention delete

Since the service collects received webmentions, there needs to be a way (authenticated API or UI) to persistently delete a received webmention. That is:

  • notify the service via UI or API) that a particular received webmention should be deleted from webmention.io's collection (that is, no longer returned in any API calls etc.)
  • if the service receives another webmention with that same 'source', it should reject it (hence the "persistent delete"j)

This is essential for removing specific abusive webmentions (whether comments, or likes/reposts by abusive accounts).

Support a block list

As discussed in snarfed/bridgy#473 it would be useful to be able to import a Twitter block list, or any block list, to automatically block some mentions (so one doesn't have to manually block them though #28).

This endpoint should be able to consume and subscribe to such block lists (and ideally discover them from a user profile when someone eg. signs in using IndieAuth, #30)

Related wiki pages:

Provide a non-js fallback – make curlable

Per discussion on IRC this morning, base the embeds on rel=response links that links to an h-entry-list of mentions so that mentions are discoverable without having to execute any javascript.

This makes the mentions degrade gracefully + makes the mentions curlable and thus possible for clients to find them.

Bonus fix: This also enables multiple embeds on the same page.

IRC-links: http://indiewebcamp.com/irc/2015-05-05/line/1430814384495

Things to consider as follow ups:

double slash at end of christopheducamp.com instance

somehow, the script when embedded on christopheducamp.com, was trying to use https://webmention.herokuapp.com/api/embed?url=http%3A%2F%2Fchristopheducamp.com%2F2014%2F01%2F11%2FWebmentions-Jekyll%2F%2F instead of https://webmention.herokuapp.com/api/embed?url=http%3A%2F%2Fchristopheducamp.com%2F2014%2F01%2F11%2FWebmentions-Jekyll%2F

I edited the script tag to put a work-around in place:

    sn.src = sn.src.substring(0, sn.src.length - 3);

and now it works on http://christopheducamp.com/2014/01/11/Webmentions-Jekyll/ but it does seem like this is some sort of bug in how it determines the url.

Accepting more users?

Hello,

I was reading this post, and was trying to set up receiving of webmentions on my site scripter.co too..

But looks like this service is maxed out at 150 users?

Is there a plan to allow more users?

Thanks.

Passing site=whatever does not say which page a mention was for

Examine the output of https://webmention.herokuapp.com/api/mentions?site=voxpelli.com :

[
  {"name":"New service: WebMentions for static pages",
   "published":1388833302000,
   "summary":"Want to implement webmentions but you’re using static pages a-la Jekyll? No problem. Pelle’s got you covered.",
   "author":{"name":null,"photo":null,"url":null},
   "url":"http://adactio.com/links/6625"
  }, ...]

Note that this describes a mention and where the mention came from, but not the page at which the mention was targeted! This means that it's not possible to fetch all the mentions for one's static site in one go; instead, one has to pass url=fullurl for each individual post to get the details, which takes one site=whatever request and makes it into (for my site) 1,700 url=whatever/full/url requests. Which is not good for anyone's bandwidth. :) Adding a target_url member to returned data would solve this problem.

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.