Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
generateur-slogans
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
2
Issues
2
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
LQDN Adminsys
generateur-slogans
Commits
2bd670b9
Verified
Commit
2bd670b9
authored
Nov 21, 2017
by
Thibaut Broggi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move sharing message management into a lib
parent
f6392734
Pipeline
#1701
passed with stages
in 2 minutes and 18 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
54 additions
and
52 deletions
+54
-52
shareMessage.js
shareMessage.js
+52
-0
srv.js
srv.js
+2
-52
No files found.
shareMessage.js
0 → 100644
View file @
2bd670b9
const
querystring
=
require
(
'
querystring
'
);
module
.
exports
=
function
(
req
)
{
let
_req
=
req
;
let
_
=
req
.
i18n
.
_
;
let
_lqdnName
=
"
@laquadrature
"
;
this
.
getUrl
=
function
()
{
return
_req
.
protocol
+
'
://
'
+
_req
.
headers
.
host
+
'
/
'
+
(
global
.
config
.
subdir
||
''
)
+
'
?
'
+
querystring
.
stringify
(
_req
.
args
)
+
'
&lang=
'
+
_req
.
i18n
.
getLocale
();
}
this
.
getTitle
=
function
()
{
return
(
_req
.
args
.
signature
?
_
(
'
Faites comme
'
)
+
encodeURIComponent
(
_req
.
args
.
signature
)
+
'
, s
'
:
'
S
'
)
+
_
(
'
outenez
'
)
+
_lqdnName
+
'
! #LQDoN
'
;
}
this
.
getContent
=
function
()
{
return
_req
.
protocol
+
"
://
"
+
_req
.
headers
.
host
;
}
this
.
getTwitterLink
=
function
()
{
return
'
https://twitter.com/intent/tweet?text=
'
+
encodeURIComponent
(
this
.
getTitle
()
+
'
'
+
this
.
getContent
()
+
'
'
+
this
.
getUrl
());
}
this
.
getFacebookLink
=
function
()
{
return
'
https://www.facebook.com/sharer/sharer.php?u=
'
+
encodeURIComponent
(
this
.
getUrl
());
}
this
.
getDiasporaLink
=
function
()
{
_lqdnName
=
"
La Quadrature du Net
"
;
return
'
https://share.diasporafoundation.org/?title=
'
+
encodeURIComponent
(
this
.
getTitle
()
+
'
'
+
this
.
getContent
())
+
'
&url=
'
+
encodeURIComponent
(
this
.
getUrl
());
}
this
.
getMastodonLink
=
function
()
{
return
'
https://mamot.fr/share?text=
'
+
encodeURIComponent
(
this
.
getTitle
()
+
'
'
+
this
.
getContent
()
+
'
'
+
this
.
getUrl
());
}
}
srv.js
View file @
2bd670b9
...
...
@@ -6,8 +6,9 @@ const express = require('express');
const
Canvas
=
require
(
'
canvas
'
);
const
Image
=
Canvas
.
Image
;
const
app
=
express
();
const
config
=
require
(
'
./config.json
'
);
global
.
config
=
require
(
'
./config.json
'
);
const
i18n
=
require
(
'
./i18n.js
'
);
const
ShareMessage
=
require
(
'
./shareMessage.js
'
);
app
.
set
(
'
trust proxy
'
,
true
);
app
.
set
(
'
x-powered-by
'
,
false
);
...
...
@@ -83,57 +84,6 @@ for (let i in fonts) {
}
Canvas
.
registerFont
(
'
./static/fonts/FiraSans-Bold.otf
'
,
{
family
:
'
FiraSans
'
,
weight
:
'
bold
'
});
function
ShareMessage
(
req
)
{
let
_req
=
req
;
let
_
=
req
.
i18n
.
_
;
let
_lqdnName
=
"
@laquadrature
"
;
this
.
getUrl
=
function
()
{
return
_req
.
protocol
+
'
://
'
+
_req
.
headers
.
host
+
'
/
'
+
(
config
.
subdir
||
''
)
+
'
?
'
+
querystring
.
stringify
(
_req
.
args
)
+
'
&lang=
'
+
_req
.
i18n
.
getLocale
();
}
this
.
getTitle
=
function
()
{
return
(
_req
.
args
.
signature
?
_
(
'
Faites comme
'
)
+
encodeURIComponent
(
_req
.
args
.
signature
)
+
'
, s
'
:
'
S
'
)
+
_
(
'
outenez
'
)
+
_lqdnName
+
'
! #LQDoN
'
;
}
this
.
getContent
=
function
()
{
return
_req
.
protocol
+
"
://
"
+
_req
.
headers
.
host
;
}
this
.
getTwitterLink
=
function
()
{
return
'
https://twitter.com/intent/tweet?text=
'
+
encodeURIComponent
(
this
.
getTitle
()
+
'
'
+
this
.
getContent
()
+
'
'
+
this
.
getUrl
());
}
this
.
getFacebookLink
=
function
()
{
return
'
https://www.facebook.com/sharer/sharer.php?u=
'
+
encodeURIComponent
(
this
.
getUrl
());
}
this
.
getDiasporaLink
=
function
()
{
_lqdnName
=
"
La Quadrature du Net
"
;
return
'
https://share.diasporafoundation.org/?title=
'
+
encodeURIComponent
(
this
.
getTitle
()
+
'
'
+
this
.
getContent
())
+
'
&url=
'
+
encodeURIComponent
(
this
.
getUrl
());
}
this
.
getMastodonLink
=
function
()
{
return
'
https://mamot.fr/share?text=
'
+
encodeURIComponent
(
this
.
getTitle
()
+
'
'
+
this
.
getContent
()
+
'
'
+
this
.
getUrl
());
}
}
app
.
get
(
'
/generate.png
'
,
function
(
req
,
res
)
{
let
_
=
req
.
i18n
.
_
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment