Skip to content

Commit c313949

Browse files
committed
Merge branch 'dev'
2 parents 4909b27 + 17a7378 commit c313949

11 files changed

Lines changed: 66 additions & 15 deletions

File tree

.github/workflows/ci.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,15 @@ jobs:
6464
- name: Test unit
6565
run: make test-unit
6666

67+
- uses: actions/cache@v3
68+
name: Setup assets cache
69+
with:
70+
path: apps/docs/tmp/
71+
# The `raw` DSFR is scrapped with a fixed URL so you have to delete the CI/CD cache if you want a new version of it
72+
key: ${{ runner.os }}-assets-${{ hashFiles('apps/docs/scripts/assets.ts') }}
73+
restore-keys: |
74+
${{ runner.os }}-assets-
75+
6776
- name: Prepare building
6877
run: make build-prepare
6978

apps/docs/scripts/assets.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// All assets to download are into this file to ease caching into the CI/CD based on source links
2+
// (scraping and downloading them are consuming)
3+
4+
export const assetsUrls = {
5+
raw: 'https://main--ds-gouv.netlify.app/example/',
6+
bootstrapV5: 'https://github.com/twbs/bootstrap/archive/refs/tags/v5.3.0-alpha3.zip',
7+
infimaV1: 'https://github.com/facebookincubator/infima/archive/refs/tags/v0.2.0-alpha.43.zip',
8+
muiV5: 'https://github.com/mui/material-ui/archive/refs/tags/v5.13.4.zip',
9+
vuetifyV3: 'https://github.com/vuetifyjs/vuetify/archive/refs/tags/v3.3.1.zip',
10+
};

apps/docs/scripts/bootstrap-v5/actions.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,21 @@ import { glob } from 'glob';
44
import handlebars from 'handlebars';
55
import path from 'path';
66

7+
import { assetsUrls } from '@dsfrc/docs/scripts/assets';
78
import { getFrameworkFolderPath } from '@dsfrc/docs/utils';
89
import { downloadFile } from '@dsfrc/docs/utils';
910

1011
const framework: string = path.basename(__dirname);
11-
const zipUrl = 'https://github.com/twbs/bootstrap/archive/refs/tags/v5.3.0-alpha3.zip';
12+
const zipUrl = assetsUrls.bootstrapV5;
1213

1314
export async function downloadAndExtract() {
1415
const zipDestination = path.resolve(__dirname, `../../tmp/${framework}.zip`);
1516
const extractionFolderPath = path.resolve(__dirname, `../../tmp/${framework}`);
1617

1718
if (!(await fs.pathExists(zipDestination))) {
1819
await downloadFile(zipUrl, zipDestination);
20+
} else {
21+
console.warn(`${framework} assets downloads skipped since present locally`);
1922
}
2023

2124
const zip = new AdmZip(zipDestination);

apps/docs/scripts/infima-v1/actions.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,21 @@ import { glob } from 'glob';
44
import handlebars from 'handlebars';
55
import path from 'path';
66

7+
import { assetsUrls } from '@dsfrc/docs/scripts/assets';
78
import { getFrameworkFolderPath } from '@dsfrc/docs/utils';
89
import { downloadFile } from '@dsfrc/docs/utils';
910

1011
const framework: string = path.basename(__dirname);
11-
const zipUrl = 'https://github.com/facebookincubator/infima/archive/refs/tags/v0.2.0-alpha.43.zip';
12+
const zipUrl = assetsUrls.infimaV1;
1213

1314
export async function downloadAndExtract() {
1415
const zipDestination = path.resolve(__dirname, `../../tmp/${framework}.zip`);
1516
const extractionFolderPath = path.resolve(__dirname, `../../tmp/${framework}`);
1617

1718
if (!(await fs.pathExists(zipDestination))) {
1819
await downloadFile(zipUrl, zipDestination);
20+
} else {
21+
console.warn(`${framework} assets downloads skipped since present locally`);
1922
}
2023

2124
const zip = new AdmZip(zipDestination);

apps/docs/scripts/mui-v5/actions.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,21 @@ import { glob } from 'glob';
44
import handlebars from 'handlebars';
55
import path from 'path';
66

7+
import { assetsUrls } from '@dsfrc/docs/scripts/assets';
78
import { getFrameworkFolderPath } from '@dsfrc/docs/utils';
89
import { downloadFile } from '@dsfrc/docs/utils';
910

1011
const framework: string = path.basename(__dirname);
11-
const zipUrl = 'https://github.com/mui/material-ui/archive/refs/tags/v5.13.4.zip';
12+
const zipUrl = assetsUrls.muiV5;
1213

1314
export async function downloadAndExtract() {
1415
const zipDestination = path.resolve(__dirname, `../../tmp/${framework}.zip`);
1516
const extractionFolderPath = path.resolve(__dirname, `../../tmp/${framework}`);
1617

1718
if (!(await fs.pathExists(zipDestination))) {
1819
await downloadFile(zipUrl, zipDestination);
20+
} else {
21+
console.warn(`${framework} assets downloads skipped since present locally`);
1922
}
2023

2124
const zip = new AdmZip(zipDestination);

apps/docs/scripts/raw/actions.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,22 @@ import { JSDOM } from 'jsdom';
77
import path from 'path';
88
import urlToolkit from 'url-toolkit';
99

10+
import { assetsUrls } from '@dsfrc/docs/scripts/assets';
11+
1012
const framework: string = path.basename(__dirname);
1113

12-
const mainPageUrl = new URL('https://main--ds-gouv.netlify.app/example/');
14+
const mainPageUrl = new URL(assetsUrls.raw);
1315
const baseUrl = mainPageUrl.toString();
1416
const outputFolder = path.resolve(__dirname, `../../tmp/${framework}`);
1517
const visitedUrls = new Set();
1618

1719
export async function downloadAndExtract() {
18-
// We do our own crawling because there is no good library to do recursive lookup simply
19-
await startCrawling();
20+
if (!(await fs.pathExists(outputFolder))) {
21+
// We do our own crawling because there is no good library to do recursive lookup simply
22+
await startCrawling();
23+
} else {
24+
console.warn(`${framework} assets downloads skipped since present locally`);
25+
}
2026
}
2127

2228
export async function build() {

apps/docs/scripts/vuetify-v3/actions.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,21 @@ import { glob } from 'glob';
44
import handlebars from 'handlebars';
55
import path from 'path';
66

7+
import { assetsUrls } from '@dsfrc/docs/scripts/assets';
78
import { getFrameworkFolderPath } from '@dsfrc/docs/utils';
89
import { downloadFile } from '@dsfrc/docs/utils';
910

1011
const framework: string = path.basename(__dirname);
11-
const zipUrl = 'https://github.com/vuetifyjs/vuetify/archive/refs/tags/v3.3.1.zip';
12+
const zipUrl = assetsUrls.vuetifyV3;
1213

1314
export async function downloadAndExtract() {
1415
const zipDestination = path.resolve(__dirname, `../../tmp/${framework}.zip`);
1516
const extractionFolderPath = path.resolve(__dirname, `../../tmp/${framework}`);
1617

1718
if (!(await fs.pathExists(zipDestination))) {
1819
await downloadFile(zipUrl, zipDestination);
20+
} else {
21+
console.warn(`${framework} assets downloads skipped since present locally`);
1922
}
2023

2124
const zip = new AdmZip(zipDestination);

apps/docs/stories/usage/mastodon-v4.mdx

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,11 @@ Si vous avez une instance [Mastodon](https://github.com/mastodon/mastodon) nous
2525

2626
## Prérequis communs
2727

28+
### Les polices
29+
2830
Comme indiqué dans [les prérequis généraux](/?path=/docs/dsfr-connect-prérequis--docs) il peut être bon de mettre les assets d'un thème sur "votre propre serveur". En l'occurence du fait de la génération particulière du thème Mastodon, vous êtes obligés de le faire car sinon les polices officielles du DSFR ne seront pas chargées.
2931

30-
Pour commencer, Si vous ne les avez pas déjà téléchargez les polices [sur le site du DSFR](https://www.systeme-de-design.gouv.fr/elements-d-interface/fondamentaux-de-l-identite-de-l-etat/typographie/).
32+
Pour commencer, si vous ne les avez pas déjà téléchargez les polices [sur le site du DSFR](https://www.systeme-de-design.gouv.fr/elements-d-interface/fondamentaux-de-l-identite-de-l-etat/typographie/).
3133

3234
Ensuite, allez sur l'instance Mastodon et créez le dossier `/public/assets/fonts/` pour y mettre toutes les polices. Vous devriez avoir au final :
3335

@@ -54,6 +56,13 @@ Ensuite, allez sur l'instance Mastodon et créez le dossier `/public/assets/font
5456
/public/assets/fonts/Spectral-Regular.woff2
5557
```
5658

59+
### Les images
60+
61+
Suivant les besoins vous pouvez :
62+
63+
- Changer le `favicon` par défaut de Mastodon, en téléchargeant [https://unpkg.com/@gouvfr/dsfr@latest/dist/favicon/favicon.ico](https://unpkg.com/@gouvfr/dsfr@latest/dist/favicon/favicon.ico) pour remplacer l'icône Mastodon située à `/public/favicon.ico`
64+
- Ajouter un logo depuis l'interface d'administration, en choisissant un fond blanc pour le logo pour qu'il soit lisible aussi bien en `light` que `dark` mode
65+
5766
## Méthodes d'installation du thème
5867

5968
### Installation avec les privilèges administrateur **(recommandée)**
@@ -77,18 +86,18 @@ _À noter qu'une fois configuré entièrement vous pourriez a priori supprimer `
7786
Maintenant il faut recompiler les assets Mastodon pour que l'indexation se fasse :
7887
`RAILS_ENV=production OTP_SECRET=precompile_placeholder SECRET_KEY_BASE=precompile_placeholder bundle exec rails assets:precompile`
7988

80-
La dernière étape est d'appliquer ce thème à tous les utilisateurs du site. Allez dans `Préférences > Administration > Paramètres serveur > Apparence` (ou directement via https://mon-instance-mastodon-xxxxx.com/admin/settings/appearance) puis configurer `Thème du site` sur la valeur `dsfr`.
89+
La dernière étape est d'appliquer ce thème à tous les utilisateurs du site. Allez dans `Préférences > Administration > Paramètres serveur > Apparence` (ou directement via https://mon-instance-mastodon-xxxxx.com/admin/settings/appearance) puis configurez `Thème du site` sur la valeur `dsfr`.
8190

8291
_Si votre instance ne liste pas le thème nommé `dsfr`, n'hésitez pas à redémarrer l'instance comme vous le faites d'habitude (cela varie en fonction de votre installation initiale)._
8392

8493
### Installation sans privilège **(déconseillée)**
8594

86-
Si vous n'avez pas la possibilité d'exécuter des commandes sur instance Mastodon, il est toujours possible de s'approcher d'une configuration complète en configurant un style CSS via l'interface. Mais il faut garder à l'esprit que c'est comme faire un "patch" par-dessus le thème actuel :
95+
Si vous n'avez pas la possibilité d'exécuter des commandes sur votre instance Mastodon, il est toujours possible de s'approcher d'une configuration complète en configurant un style CSS via l'interface. Mais il faut garder à l'esprit que c'est comme faire un "patch" par-dessus le thème actuel :
8796

8897
- Il peut y avoir des conflits de style avec le thème utilisé par votre instance Mastodon
8998
- Cela peut diminuer les performances et temps de chargement comparé à l'autre méthode
9099

91100
Tout d'abord allez dans `Préférences > Administration > Paramètres serveur > Apparence` (ou directement via https://mon-instance-mastodon-xxxxx.com/admin/settings/appearance), puis :
92101

93-
1. Veuillez à configurer le thème par défaut sur `Mastodon (Dark)` _(le thème DSFR est basé sur celui-ci, donc en "patchant" celui-ci nous évitons de potentiels conflits avec le style des autres thèmes)_
102+
1. Veuillez configurer le thème par défaut sur `Mastodon (Dark)` _(le thème DSFR est basé sur celui-ci, donc en "patchant" celui-ci nous évitons de potentiels conflits avec le style des autres thèmes)_
94103
2. Dans le champ `CSS personnalisé` veuillez y copier-coller le contenu du fichier https://unpkg.com/dsfr-connect@latest/dist/mastodon-v4/index.css

packages/dsfr-connect/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"module": "./dist/index.js",
1616
"types": "./dist/index.d.ts",
1717
"scripts": {
18-
"postinstall": "ts-node -r tsconfig-paths/register ./scripts/setup.ts",
18+
"prepare": "ts-node -r tsconfig-paths/register ./scripts/setup.ts",
1919
"build": "pnpm run build:script && pnpm run build:json && pnpm run build:style",
2020
"build:script": "tsup",
2121
"build:style": "ts-node -r tsconfig-paths/register ./compile-style-files.ts",

packages/dsfr-connect/src/mastodon-v4/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ _It should have been easy by customizing main variables in a few hours... But Ma
1212

1313
### Get the official theme
1414

15-
Since our theme is based on the official one, we need to get it. We made the fetching automatic when you install dependencies of this repository. But if needed you can run it a new time from `/packages/dsfr-connect` with:
16-
`pnpm run postinstall`
15+
Since our theme is based on the official one, we need to get it. We made the fetching automatic when you install dependencies of this repository (only when developing, not when installing the package from the NPM registry). But if needed you can run it a new time from `/packages/dsfr-connect` with:
16+
`pnpm run prepare`
1717

18-
_Note: if you want to upgrade the official Mastodon theme, modify the version into `/packages/dsfr-connect/src/mastodon-v4/settings.ts`, delete the folder `/packages/dsfr-connect/src/mastodon-v4/mastodon/` and run again the `postinstall` command._
18+
_Note: if you want to upgrade the official Mastodon theme, modify the version into `/packages/dsfr-connect/src/mastodon-v4/settings.ts`, delete the folder `/packages/dsfr-connect/src/mastodon-v4/mastodon/` and run again the `prepare` command._
1919

2020
### Launch
2121

0 commit comments

Comments
 (0)