Make social network share work without javascript

parent 591290c2
Pipeline #1447 passed with stage
in 37 seconds
#!/usr/bin/env node
const fs = require('fs');
const querystring = require('querystring');
const express = require('express');
const Canvas = require('canvas');
const Image = Canvas.Image;
......@@ -32,7 +33,22 @@ for (let i in fonts) {
}
Canvas.registerFont('./static/fonts/FiraSans-Bold.otf', {family: 'FiraSans', weight: 'bold'});
function buildUrl(req) {
delete req.query.target;
return encodeURIComponent(req.protocol + '://'
+ req.headers.host + '/'
+ (config.subdir || '')
+ '?'
+ querystring.stringify(req.query));
}
app.get('/generate.png', function (req, res) {
if (req.query.target === 'facebook') {
return res.redirect('https://www.facebook.com/sharer/sharer.php?u=' + buildUrl(req));
}
else if (req.query.target === 'twitter') {
return res.redirect('https://twitter.com/intent/tweet?text=Soutenez La Quadrature du Net ! ' + buildUrl(req));
}
let bgColor = req.query['bg-color'] || '#f54358';
let fgColor = req.query['fg-color'] || '#ffd201';
let fillText = req.query.text ? req.query.text.trim() : 'démocratie';
......
......@@ -6,10 +6,11 @@ html {
box-sizing: inherit;
}
body {
body, form {
margin: auto;
color: #497ed5;
min-height: 100vh;
max-width: 100%;
font-family: 'FiraSans';
background-color: #ebf3ff;
}
......@@ -213,7 +214,7 @@ div.navButtons {
margin-top: 2em;
}
body {
body, form {
display: flex;
flex-direction: row;
}
......@@ -223,7 +224,7 @@ body {
display: none;
}
body {
body, form {
flex-direction: column;
}
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment