1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-01-02 12:47:41 +02:00

Doc: add donate button

This commit is contained in:
Laurent Cozic 2021-03-15 16:27:45 +00:00
parent 76c143e8b0
commit 1aca81b584
3 changed files with 23 additions and 2 deletions

View File

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="86" height="20" role="img" aria-label="Donate: IBAN"><title>Donate: IBAN</title><linearGradient id="s" x2="0" y2="100%"><stop offset="0" stop-color="#bbb" stop-opacity=".1"/><stop offset="1" stop-opacity=".1"/></linearGradient><clipPath id="r"><rect width="86" height="20" rx="3" fill="#fff"/></clipPath><g clip-path="url(#r)"><rect width="49" height="20" fill="#555"/><rect x="49" width="37" height="20" fill="#007ec6"/><rect width="86" height="20" fill="url(#s)"/></g><g fill="#fff" text-anchor="middle" font-family="Verdana,Geneva,DejaVu Sans,sans-serif" text-rendering="geometricPrecision" font-size="110"><text aria-hidden="true" x="255" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="390">Donate</text><text x="255" y="140" transform="scale(.1)" fill="#fff" textLength="390">Donate</text><text aria-hidden="true" x="665" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="270">IBAN</text><text x="665" y="140" transform="scale(.1)" fill="#fff" textLength="270">IBAN</text></g></svg>

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@ -1,4 +1,6 @@
[![Donate](https://joplinapp.org/images/badges/Donate-PayPal-green.svg)](https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=E8JMYD2LQ8MMA&lc=GB&item_name=Joplin+Development&currency_code=EUR&bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHosted) [![Sponsor on GitHub](https://joplinapp.org/images/badges/GitHub-Badge.svg)](https://github.com/sponsors/laurent22/) [![Become a patron](https://joplinapp.org/images/badges/Patreon-Badge.svg)](https://www.patreon.com/joplin) <!-- DONATELINKS -->
[![Donate using PayPal](https://joplinapp.org/images/badges/Donate-PayPal-green.svg)](https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=E8JMYD2LQ8MMA&lc=GB&item_name=Joplin+Development&currency_code=EUR&bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHosted) [![Sponsor on GitHub](https://joplinapp.org/images/badges/GitHub-Badge.svg)](https://github.com/sponsors/laurent22/) [![Become a patron](https://joplinapp.org/images/badges/Patreon-Badge.svg)](https://www.patreon.com/joplin) [![Donate using IBAN](https://joplinapp.org/images/badges/Donate-IBAN.svg)](https://joplinapp.org/donate/#donations)
<!-- DONATELINKS -->
* * * * * *

View File

@ -541,6 +541,16 @@ function tocMd() {
return tocMd_; return tocMd_;
} }
const donateLinksRegex_ = /<!-- DONATELINKS -->([^]*)<!-- DONATELINKS -->/;
async function getDonateLinks() {
const md = await fs.readFile(`${rootDir}/README.md`, 'utf8');
const matches = md.match(donateLinksRegex_, '');
if (!matches) throw new Error('Cannot fetch donate links');
return matches[1].trim();
}
function replaceGitHubByJoplinAppLinks(md) { function replaceGitHubByJoplinAppLinks(md) {
// let output = md.replace(/https:\/\/github.com\/laurent22\/joplin\/blob\/master\/readme\/(.*?)\/index\.md(#[^\s)]+|)/g, 'https://joplinapp.org/$1'); // let output = md.replace(/https:\/\/github.com\/laurent22\/joplin\/blob\/master\/readme\/(.*?)\/index\.md(#[^\s)]+|)/g, 'https://joplinapp.org/$1');
return md.replace(/https:\/\/github.com\/laurent22\/joplin\/blob\/dev\/readme\/(.*?)\.md(#[^\s)]+|)/g, 'https://joplinapp.org/$1/$2'); return md.replace(/https:\/\/github.com\/laurent22\/joplin\/blob\/dev\/readme\/(.*?)\.md(#[^\s)]+|)/g, 'https://joplinapp.org/$1/$2');
@ -577,6 +587,10 @@ function renderMdToHtml(md, targetPath, templateParams) {
md = replaceGitHubByJoplinAppLinks(md); md = replaceGitHubByJoplinAppLinks(md);
if (templateParams.donateLinksMd) {
md = `${templateParams.donateLinksMd}\n\n* * *\n\n${md}`;
}
templateParams.pageTitle = title.join(' | '); templateParams.pageTitle = title.join(' | ');
const html = markdownToHtml(md, templateParams); const html = markdownToHtml(md, templateParams);
@ -626,11 +640,15 @@ async function main() {
}).map(f => f.substr(rootDir.length + 1)); }).map(f => f.substr(rootDir.length + 1));
const sources = []; const sources = [];
const donateLinksMd = await getDonateLinks();
for (const mdFile of mdFiles) { for (const mdFile of mdFiles) {
const title = await readmeFileTitle(`${rootDir}/${mdFile}`); const title = await readmeFileTitle(`${rootDir}/${mdFile}`);
const targetFilePath = `${mdFile.replace(/\.md/, '').replace(/readme\//, 'docs/')}/index.html`; const targetFilePath = `${mdFile.replace(/\.md/, '').replace(/readme\//, 'docs/')}/index.html`;
sources.push([mdFile, targetFilePath, { title: title }]); sources.push([mdFile, targetFilePath, {
title: title,
donateLinksMd: donateLinksMd,
}]);
} }
const path = require('path'); const path = require('path');