Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Config for web monetization #7529

Closed
SethFalco opened this issue Apr 23, 2022 · 1 comment · Fixed by #7534
Closed

Config for web monetization #7529

SethFalco opened this issue Apr 23, 2022 · 1 comment · Fixed by #7534
Assignees
Labels
enhancement Adding or requesting a new feature.
Milestone

Comments

@SethFalco
Copy link
Contributor

SethFalco commented Apr 23, 2022

Describe the problem

I think it'd be great if Web Monetization was more established, and if hosts of Weblate servers could receive additional support from users.

Web Monetization is a proposed W3C standard for monetization on the internet.

TL;DR: Creators and websites who choose to create an Interledger Payment Pointer can embed it in the <head> element of a webpage, and users who opt-in to support such websites can stream micropayments to financially support it.

It's like Brave Rewards (for creators) except Web Monetization is a proposed W3 standard, so it's not bound to a particular browser or account.

Describe the solution you'd like

There should be a new setting where users can configure a list of payment pointers.
If specified, Weblate will add this list in the <head> of the document.

When there is only one payment pointer, it's as simple as adding:

<meta name="monetization" content="$alice.example">

If the config supports multiple payment points, which is a use-case that's officially documented on the Web Monetization site, it requires some extra JavaScript/PHP. Something to the effect of:

<head>
  <script>
    // Interledger Payment Pointer mapped to weight
    const pointers = {
      '$alice.example': 50,
      '$bob.example': 40,
      '$connie.example': 9.5,
      '$dave.example': 0.5
    }

    function pickPointer () {
      const sum = Object.values(pointers).reduce((sum, weight) => sum + weight, 0);
      let choice = Math.random() * sum;
      
      for (const pointer in pointers) {
        const weight = pointers[pointer]
        if ((choice -= weight) <= 0) {
          return pointer
        }
      }
    }

    window.addEventListener('load', () => {
      const monetizationTag = document.createElement('meta')
      monetizationTag.name = 'monetization'
      monetizationTag.content = pickPointer()

      document.head.appendChild(monetizationTag)
    })
  </script>
</head>

https://webmonetization.org/docs/probabilistic-rev-sharing#code

Describe alternatives you've considered

Instead of calculating the probabilistic revenue sharing yourself, it could be easier to use the API Web Monetization provide for it.

Suppose a config like, where the values are the Interledger Payment Pointer, weight, and a name:

[
  [
    "$alice.example",
    1,
    "Alice"
  ],
  [
    "$bob.example",
    1,
    "Bob"
  ]
]

Just minify, stringify, and base64 encode (padding can be removed) it.
W1siJGFsaWNlLmV4YW1wbGUiLDEsIkFsaWNlIl0sWyIkYm9iLmV4YW1wbGUiLDEsIkJvYiJdXQ

With this, you can create a valid payment pointer where webmonetization.org handles the revenue sharing for you.

<meta name="monetization" content="$webmonetization.org/api/revshare/pay/W1siJGFsaWNlLmV4YW1wbGUiLDEsIkFsaWNlIl0sWyIkYm9iLmV4YW1wbGUiLDEsIkJvYiJdXQ">

More info: https://webmonetization.org/prob-revshare

I wouldn't recommend this though, it'd be an unnecessary dependency on another service.

Screenshots

No response

Additional context

I'd be happy to work on this, just wanted to note it here already in case the idea isn't favorable.

@nijel nijel added this to the 4.12.1 milestone Apr 26, 2022
@nijel nijel added the enhancement Adding or requesting a new feature. label Apr 26, 2022
@github-actions
Copy link

The issue you have reported is now resolved. If you don’t feel it’s right, please follow its labels to get a clue for further steps.

  • In case you see a similar problem, please open a separate issue.
  • If you are happy with the outcome, don’t hesitate to support Weblate by making a donation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Adding or requesting a new feature.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants