Browse Source

Fixes csp issues with the GitLens icon font

main
Eric Amodio 2 years ago
parent
commit
766ad96ea0
11 changed files with 55 additions and 23 deletions
  1. +1
    -0
      .fantasticonrc.js
  2. +12
    -5
      images/icons/template/styles.hbs
  3. +11
    -3
      src/webviews/apps/commitDetails/commitDetails.html
  4. +2
    -1
      src/webviews/apps/home/home.html
  5. +9
    -1
      src/webviews/apps/plus/graph/graph.html
  6. +2
    -1
      src/webviews/apps/plus/timeline/timeline.html
  7. +2
    -1
      src/webviews/apps/rebase/rebase.html
  8. +2
    -1
      src/webviews/apps/settings/settings.html
  9. +12
    -5
      src/webviews/apps/shared/glicons.scss
  10. +2
    -1
      src/webviews/apps/welcome/welcome.html
  11. +0
    -4
      webpack.config.js

+ 1
- 0
.fantasticonrc.js View File

@ -7,6 +7,7 @@ const config = {
codepoints: require('./images/icons/template/mapping.json'),
inputDir: './images/icons',
outputDir: './dist',
fontsUrl: '#{root}/dist',
// @ts-ignore
fontTypes: ['woff2'],
normalize: true,

+ 12
- 5
images/icons/template/styles.hbs View File

@ -1,8 +1,15 @@
@font-face {
font-family: '{{ name }}';
font-display: block;
src: {{{ fontSrc }}};
}
/*
Must be placed at the end of body in the HTML file of any webview that needs it (because of CSP)
<style nonce="#{cspNonce}">
@font-face {
font-family: '{{ name }}';
font-display: block;
src: {{{ fontSrc }}};
}
</style>
*/
.glicon {
font: normal normal normal 16px/1 {{ name }};

+ 11
- 3
src/webviews/apps/commitDetails/commitDetails.html View File

@ -66,8 +66,8 @@
href="#"
data-action="commit-actions"
data-action-type="graph"
aria-label="Show Commit on Commit Graph"
title="Show Commit on Commit Graph"
aria-label="Show in Commit Graph"
title="Show in Commit Graph"
><code-icon icon="graph"></code-icon
></a>
<a
@ -133,7 +133,15 @@
<style nonce="#{cspNonce}">
@font-face {
font-family: 'codicon';
src: url('#{webroot}/codicon.ttf?404cbc4fe3a64b9a93064eef76704c79') format('truetype');
font-display: block;
src: url('#{webroot}/codicon.ttf?0e5b0adf625a37fbcd638d31f0fe72aa') format('truetype');
}
</style>
<style nonce="#{cspNonce}">
@font-face {
font-family: 'glicons';
font-display: block;
src: url("#{root}/dist/glicons.woff2?2e51fe40df2abdf6a27fbae6c29587b1") format("woff2");
}
</style>
</body>

+ 2
- 1
src/webviews/apps/home/home.html View File

@ -19,7 +19,8 @@
<style nonce="#{cspNonce}">
@font-face {
font-family: 'codicon';
src: url('#{webroot}/codicon.ttf?404cbc4fe3a64b9a93064eef76704c79') format('truetype');
font-display: block;
src: url('#{webroot}/codicon.ttf?0e5b0adf625a37fbcd638d31f0fe72aa') format('truetype');
}
</style>
</body>

+ 9
- 1
src/webviews/apps/plus/graph/graph.html View File

@ -12,7 +12,15 @@
<style nonce="#{cspNonce}">
@font-face {
font-family: 'codicon';
src: url('#{webroot}/codicon.ttf?404cbc4fe3a64b9a93064eef76704c79') format('truetype');
font-display: block;
src: url('#{webroot}/codicon.ttf?0e5b0adf625a37fbcd638d31f0fe72aa') format('truetype');
}
</style>
<style nonce="#{cspNonce}">
@font-face {
font-family: 'glicons';
font-display: block;
src: url('#{root}/dist/glicons.woff2?2e51fe40df2abdf6a27fbae6c29587b1') format('woff2');
}
</style>
</body>

+ 2
- 1
src/webviews/apps/plus/timeline/timeline.html View File

@ -51,7 +51,8 @@
<style nonce="#{cspNonce}">
@font-face {
font-family: 'codicon';
src: url('#{root}/dist/webviews/codicon.ttf?669d352dfabff8f6eaa466c8ae820e43') format('truetype');
font-display: block;
src: url('#{webroot}/codicon.ttf?0e5b0adf625a37fbcd638d31f0fe72aa') format('truetype');
}
</style>
</body>

+ 2
- 1
src/webviews/apps/rebase/rebase.html View File

@ -58,7 +58,8 @@
<style nonce="#{cspNonce}">
@font-face {
font-family: 'codicon';
src: url('#{webroot}/codicon.ttf?404cbc4fe3a64b9a93064eef76704c79') format('truetype');
font-display: block;
src: url('#{webroot}/codicon.ttf?0e5b0adf625a37fbcd638d31f0fe72aa') format('truetype');
}
</style>
</body>

+ 2
- 1
src/webviews/apps/settings/settings.html View File

@ -327,7 +327,8 @@
<style nonce="#{cspNonce}">
@font-face {
font-family: 'codicon';
src: url('#{webroot}/codicon.ttf?404cbc4fe3a64b9a93064eef76704c79') format('truetype');
font-display: block;
src: url('#{webroot}/codicon.ttf?0e5b0adf625a37fbcd638d31f0fe72aa') format('truetype');
}
</style>
</body>

+ 12
- 5
src/webviews/apps/shared/glicons.scss View File

@ -1,8 +1,15 @@
@font-face {
font-family: 'glicons';
font-display: block;
src: url("./glicons.woff2?2e51fe40df2abdf6a27fbae6c29587b1") format("woff2");
}
/*
Must be placed at the end of body in the HTML file of any webview that needs it (because of CSP)
<style nonce="#{cspNonce}">
@font-face {
font-family: 'glicons';
font-display: block;
src: url("#{root}/dist/glicons.woff2?2e51fe40df2abdf6a27fbae6c29587b1") format("woff2");
}
</style>
*/
.glicon {
font: normal normal normal 16px/1 glicons;

+ 2
- 1
src/webviews/apps/welcome/welcome.html View File

@ -526,7 +526,8 @@
<style nonce="#{cspNonce}">
@font-face {
font-family: 'codicon';
src: url('#{webroot}/codicon.ttf?404cbc4fe3a64b9a93064eef76704c79') format('truetype');
font-display: block;
src: url('#{webroot}/codicon.ttf?0e5b0adf625a37fbcd638d31f0fe72aa') format('truetype');
}
</style>
</body>

+ 0
- 4
webpack.config.js View File

@ -315,10 +315,6 @@ function getWebviewsConfig(mode, env) {
),
to: path.posix.join(__dirname.replace(/\\/g, '/'), 'dist', 'webviews'),
},
{
from: path.posix.join(__dirname.replace(/\\/g, '/'), 'dist', 'glicons.woff2'),
to: path.posix.join(__dirname.replace(/\\/g, '/'), 'dist', 'webviews'),
},
],
}),
];

Loading…
Cancel
Save