Compare commits

..

No commits in common. "5e126ebcaf0540c7e25bdd865c8dd953945619f3" and "2f663f0e08cf3bbb2b93888ff737f818c05c716d" have entirely different histories.

5 changed files with 21 additions and 171 deletions

View file

@ -4,8 +4,7 @@
"exports": {
".": "./mod.ts",
"./cli": "./cli.ts",
"./types": "./types.ts",
"./templates": "./templates/mod.ts"
"./types": "./types.ts"
},
"tasks": {
"compile": "deno compile --allow-read --allow-env --allow-net=0.0.0.0 --allow-sys=osRelease,networkInterfaces --allow-run=/usr/sbin/sendmail,whoami --output=bin/cohamail --target=x86_64-unknown-linux-gnu ./cli.ts",

View file

@ -1,140 +0,0 @@
import {
Body,
Button,
Container,
Heading,
Html,
Preview,
Section,
Text,
} from 'jsx-email'
import { Signature } from './components/Signature.tsx'
import type { Template } from '../types.ts'
import type { JSX } from 'preact'
import {
bodyCss,
buttonCss,
headingCss,
messageCss,
rootCss,
textCss,
} from './styles/base.tsx'
import { BaseStyle } from './styles/base.tsx'
function MagicLink(
{ message, device, ip, endpoint }: {
message?: string
device?: string
ip?: string
endpoint: string
},
) {
return (
<Html lang='fr' style={{ fontSize: '14px' }}>
<BaseStyle />
<Preview>Nouveau lien de connection</Preview>
<Body style={bodyCss}>
<Container style={messageCss}>
<Section>
<Heading as='h1' style={headingCss}>
Nouveau lien de connection
</Heading>
<Text style={textCss}>
Une nouvelle demande de connection à é effectuée sur votre
compte.
</Text>
<Text style={detailsCss}>
<span>
<span style={{ fontWeight: 'bolder' }}>{'Date : '}</span>
{dateNow()}
</span>
<br />
<span>
<span style={{ fontWeight: 'bolder' }}>{'Appareil : '}</span>
{device?.length ? device : 'Iconnue'}
</span>
<br />
<span>
<span style={{ fontWeight: 'bolder' }}>{'Ip : '}</span>
{ip?.length ? ip : 'Inconnue'}
</span>
</Text>
{message?.length ? <Text style={textCss}>{message}</Text> : ''}
<Text style={infoCss}>
Si vous n'êtes pas à l'origine de cette demande vous pouvez
ignorer ce mail en toute sécurité.
</Text>
<Container
style={{ width: '100%', textAlign: 'center', padding: '1rem' }}
>
<Button href={endpoint} style={buttonCss}>Me connecter</Button>
</Container>
</Section>
</Container>
<Signature />
</Body>
</Html>
)
}
function dateNow() {
return new Date().toLocaleString('fr', {
weekday: 'long',
day: 'numeric',
month: 'long',
year: 'numeric',
hour: 'numeric',
minute: 'numeric',
})
}
const infoCss: JSX.CSSProperties = {
...textCss,
opacity: 0.7,
}
const detailsCss: JSX.CSSProperties = {
...textCss,
backgroundColor: rootCss.backgroundColor,
padding: '0.5rem',
borderRadius: '0.4rem',
}
const template: Template<typeof MagicLink, Parameters<typeof MagicLink>[0]> = {
props: [
{
name: 'Message',
description: "Message à afficher à l'utilisateur.",
required: false,
multiline: false,
tag: 'message',
},
{
name: 'Device',
description: 'User-Agent (ou equiv.) de la demande.',
required: false,
multiline: false,
tag: 'device',
},
{
name: 'Ip',
description: 'Addresse ip de la demande.',
required: false,
multiline: false,
tag: 'ip',
},
{
name: 'Endpoint',
description: 'Endpoint du lien "Me connecter".',
required: true,
multiline: false,
tag: 'endpoint',
},
],
name: 'magic-link',
description: 'Coh@bit connection magic link.',
builder: MagicLink,
}
export default template

View file

@ -12,14 +12,7 @@ import {
import { Signature } from './components/Signature.tsx'
import type { Template } from '../types.ts'
import type { JSX } from 'preact'
import {
bodyCss,
buttonCss,
headingCss,
messageCss,
rootCss,
textCss,
} from './styles/base.tsx'
import { bodyCss, messageCss, rootCss, textCss } from './styles/base.tsx'
import { BaseStyle } from './styles/base.tsx'
function Welcome(
@ -97,7 +90,9 @@ function Welcome(
style={{ width: '100%', textAlign: 'center', padding: '1rem' }}
>
<Button
href={endpoint?.length ? endpoint : 'https://cohabit.fr/profil'}
href={(endpoint && endpoint.length > 1)
? endpoint
: 'https://cohabit.fr/profil'}
style={buttonCss}
>
Accéder à mon compte
@ -111,6 +106,14 @@ function Welcome(
)
}
const headingCss: JSX.CSSProperties = {
fontFamily: 'Garamond, serif',
color: rootCss.accentColor,
textAlign: 'center',
margin: '-1rem 0 3rem',
fontSize: '2.5rem',
}
const preCss: JSX.CSSProperties = {
fontFamily: 'monospace',
fontSize: '1rem',
@ -119,11 +122,18 @@ const preCss: JSX.CSSProperties = {
backgroundColor: rootCss.backgroundColor,
}
const buttonCss: JSX.CSSProperties = {
color: 'white',
padding: '1rem',
borderRadius: '0.4rem',
fontSize: '1.2rem',
backgroundColor: rootCss.accentColor,
}
const imgCss: JSX.CSSProperties = {
display: 'inline',
padding: '1rem',
transform: 'translateY(40%)',
maxHeight: '3rem',
}
const template: Template<typeof Welcome, Parameters<typeof Welcome>[0]> = {

View file

@ -1,3 +0,0 @@
export { default as magicLinkTemplate } from './MagicLink.tsx'
export { default as messageTemplate } from './Message.tsx'
export { default as welcomeTemplate } from './Welcome.tsx'

View file

@ -19,26 +19,10 @@ export const messageCss: JSX.CSSProperties = {
textWrap: 'balance',
}
export const headingCss: JSX.CSSProperties = {
fontFamily: 'Garamond, serif',
color: rootCss.accentColor,
textAlign: 'center',
margin: '-1rem 0 3rem',
fontSize: '2.5rem',
}
export const textCss: JSX.CSSProperties = {
fontSize: '1rem',
}
export const buttonCss: JSX.CSSProperties = {
color: 'white',
padding: '1rem',
borderRadius: '0.4rem',
fontSize: '1.2rem',
backgroundColor: rootCss.accentColor,
}
export const rawCss = `
a {
color: ${rootCss.accentColor};