feat: move to npm fontawesome dependency and support fa pro (#11820)

* feat: move to npm fontawesome dependency

* feat: move shims to a separate file

* fix: thin style prefix

* feat: proper style and FA pro handling in icon selector

* docs: add fontawesome properties to openAPI

* fix: default for styles

* feat: select all styles by default

Turns out browsers lazy-load fonts.
So since the actual CSS for each style is small, there is no perf reason for defaulting to free styles for FA pro users.
This means they'll have to only change one setting.

Still, the option to select styles remains for those who want it.

* fix: remove console.log
isekai-main
Opliko 1 year ago committed by GitHub
parent e38fe06fa9
commit b709ed9e63
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -31,6 +31,7 @@
"@adactive/bootstrap-tagsinput": "0.8.2",
"@fontsource/inter": "5.0.5",
"@fontsource/poppins": "5.0.5",
"@fortawesome/fontawesome-free": "6.4.0",
"@isaacs/ttlcache": "1.4.1",
"@popperjs/core": "2.11.8",
"ace-builds": "1.23.4",

@ -275,3 +275,14 @@ get:
type: boolean
composer-default:
type: object
fontawesome:
type: object
properties:
pro:
type: boolean
styles:
type: array
items:
type: string
version:
type: string

@ -1,7 +0,0 @@
$fa-font-path: "vendor/fontawesome/webfonts/6.2.0";
@import "../public/vendor/fontawesome/scss/fontawesome";
@import "../public/vendor/fontawesome/scss/regular";
@import "../public/vendor/fontawesome/scss/solid";
@import "../public/vendor/fontawesome/scss/brands";
@import "../public/vendor/fontawesome/scss/v4-shims";
@import "../public/vendor/fontawesome/scss/nodebb-shims";

@ -0,0 +1,4 @@
$fa-font-path: "./vendor/fontawesome/webfonts";
@import "fontawesome";
@import "v4-shims";
@import "nodebb-shims";

@ -1,5 +1,5 @@
@import "_variables.scss";
// NodeBB backwards compatibility shims
@font-face {
font-family: 'FontAwesome';
font-style: normal;

@ -0,0 +1 @@
@import "brands";

@ -0,0 +1,2 @@
@import "duotone";
@import "_duotone-icons";

@ -0,0 +1 @@
@import "light";

@ -0,0 +1 @@
@import "regular";

@ -0,0 +1 @@
@import "sharp-light";

@ -0,0 +1 @@
@import "sharp-regular";

@ -0,0 +1 @@
@import "sharp-solid";

@ -0,0 +1,3 @@
@import "sharp-light";
@import "sharp-regular";
@import "sharp-solid";

@ -0,0 +1 @@
@import "solid";

@ -0,0 +1 @@
@import "thin";

@ -2,6 +2,7 @@
define('iconSelect', ['benchpress', 'bootbox'], function (Benchpress, bootbox) {
const fontawesome_license = config.fontawesome.pro ? 'pro' : 'free';
const iconSelect = {};
const initialIcons = [
{ id: 'nbb-none', label: 'None (NodeBB)', style: 'nodebb' },
@ -223,15 +224,16 @@ define('iconSelect', ['benchpress', 'bootbox'], function (Benchpress, bootbox) {
];
iconSelect.init = function (el, onModified) {
onModified = onModified || function () { };
let selected = cleanFAClass(el.attr('class'));
let selected = cleanFAClass(el[0].classList);
$('#icons .selected').removeClass('selected');
if (selected) {
if (selected.icon) {
try {
$('#icons .nbb-fa-icons .fa.' + selected).addClass('selected');
$(`#icons .nbb-fa-icons ${selected.styles.length ? '.' + selected.styles.join('.') : ''}.${selected.icon}`).addClass('selected');
} catch (err) {
selected = '';
selected = {
icon: '',
style: '',
};
}
}
@ -250,26 +252,39 @@ define('iconSelect', ['benchpress', 'bootbox'], function (Benchpress, bootbox) {
label: 'No Icon',
className: 'btn-default',
callback: function () {
el.removeClass(selected);
el.removeClass(selected.icon);
// eslint-disable-next-line no-restricted-syntax
for (const style of selected.styles) {
el.removeClass(style);
}
el.val('');
el.attr('value', '');
onModified(el, '');
onModified(el, '', []);
},
},
success: {
label: 'Select',
className: 'btn-primary',
callback: function () {
const iconClass = $('.bootbox .selected').attr('class') || `fa fa-${$('.bootbox #fa-filter').val()}`;
const newIconClass = cleanFAClass(iconClass);
if (newIconClass) {
el.removeClass(selected).addClass(newIconClass);
el.val(newIconClass);
el.attr('value', newIconClass);
const iconClass = $('.bootbox .selected')[0]?.classList || [`fa-${$('.bootbox #fa-filter').val()}`];
const newIcon = cleanFAClass(iconClass);
if (newIcon.icon) {
el.removeClass(selected.icon).addClass(newIcon.icon);
// eslint-disable-next-line no-restricted-syntax
for (const style of selected.styles || []) {
el.removeClass(style);
}
// eslint-disable-next-line no-restricted-syntax
for (const style of newIcon.styles || []) {
el.addClass(style);
}
// Simple workaround for lack of style information in icons by just adding the style class to the value
const newValue = newIcon.icon + (newIcon.styles.length ? ' ' + newIcon.styles.join(' ') : '');
el.val(newValue);
el.attr('value', newValue);
}
onModified(el, newIconClass);
onModified(el, newIcon.icon, newIcon.styles);
},
},
},
@ -279,9 +294,9 @@ define('iconSelect', ['benchpress', 'bootbox'], function (Benchpress, bootbox) {
const modalEl = $(this);
const searchEl = modalEl.find('input');
if (selected) {
modalEl.find('.' + selected).addClass('selected');
searchEl.val(selected.replace('fa-', ''));
if (selected.icon) {
modalEl.find('.' + selected.icon).addClass('selected');
searchEl.val(selected.icon.replace('fa-', ''));
}
}).modal('show');
@ -298,8 +313,8 @@ define('iconSelect', ['benchpress', 'bootbox'], function (Benchpress, bootbox) {
if (newSelection) {
newSelection.addClass('selected');
} else if (searchEl.val().length === 0) {
if (selected) {
modalEl.find('.' + selected).addClass('selected');
if (selected.icon) {
modalEl.find('.' + selected.icon).addClass('selected');
}
} else {
modalEl.find('i:visible').first().addClass('selected');
@ -310,7 +325,7 @@ define('iconSelect', ['benchpress', 'bootbox'], function (Benchpress, bootbox) {
searchEl.selectRange(0, searchEl.val().length);
modalEl.find('.icon-container').on('click', 'i', function () {
searchEl.val(cleanFAClass($(this).attr('class')).replace('fa-', ''));
searchEl.val(cleanFAClass($(this)[0].classList).icon.replace('fa-', ''));
changeSelection($(this));
});
const debouncedSearch = utils.debounce(async () => {
@ -323,7 +338,7 @@ define('iconSelect', ['benchpress', 'bootbox'], function (Benchpress, bootbox) {
}
icons.remove();
iconData.forEach((iconData) => {
iconContainer.append($(`<i class="fa fa-xl fa-${iconData.style} fa-${iconData.id} rounded-1" data-label="${iconData.label}"></i>`));
iconContainer.append($(`<i class="fa fa-xl fa-${iconData.style}${iconData.family !== 'classic' ? ` fa-${iconData.family}` : ''} fa-${iconData.id} rounded-1" data-label="${iconData.label}"></i>`));
});
icons = modalEl.find('.nbb-fa-icons i');
changeSelection();
@ -340,13 +355,54 @@ define('iconSelect', ['benchpress', 'bootbox'], function (Benchpress, bootbox) {
});
};
// turns "fa fa-2x fa-solid fa-heart" into "fa-heart"
function cleanFAClass(className) {
className = className.replace(/fa-(solid|regular|brands|light|thin|duotone|nodebb) /, '');
const filterNames = ['fa-2x', 'fa-xl', 'fa', 'fa-'];
return className.split(' ')
.filter(c => !filterNames.includes(c))
.filter(c => c && c.startsWith('fa-')).join('');
const excludedClassList = [
'nodebb',
'fw',
'\\d{1,2}?[xsl][smgl]',
'rotate-(\\d+|horizontal|vertical|both|by)',
'flip-(\\d+|horizontal|vertical|both)',
'beat',
'fade',
'beat-fade',
'bounce',
'flip',
'shake',
'spin',
'spin-pulse',
'spin-reverse',
'border',
'pull-(left|right)',
'stack(-\\dx)?',
'inverse',
'layers(-text)?(-counter)?',
'ul',
'li',
'border',
'swap-opacity',
'sr-only(-focusable)?',
];
const excludedClassRegex = RegExp(`\\bfa-(${excludedClassList.join('|')})\\b`, 'i');
const styleRegex = /fa-(solid|regular|brands|light|thin|duotone|sharp)/;
// turns 'fa fa-2x fa-solid fa-heart' into 'fa-heart'
function cleanFAClass(classList) {
const styles = [];
let icon;
// eslint-disable-next-line no-restricted-syntax
for (const className of classList) {
if (className.startsWith('fa-') && !excludedClassRegex.test(className)) {
if (styleRegex.test(className)) {
styles.push(className);
} else {
icon = className;
}
}
}
return {
icon,
styles,
};
}
iconSelect.findIcons = async function (searchString) {
@ -357,26 +413,35 @@ define('iconSelect', ['benchpress', 'bootbox'], function (Benchpress, bootbox) {
},
body: JSON.stringify({
query: `query {
search(version: "6.2.0", query: "${searchString}", first: 200) {
search(version: "${config.fontawesome.version}", query: "${searchString}", first: 200) {
id,
label,
familyStylesByLicense {
free {
style
${fontawesome_license} {
style,
family
}
}
}
}`,
}`.replace(/(\n| {2,}|\t{2,})/g, ''), // very simple minification
}),
});
const response = await request.json();
const icons = response.data.search.filter(icon => icon.familyStylesByLicense.free.length > 0).flatMap((icon) => {
const result = [];
icon.familyStylesByLicense.free.forEach((style) => {
icon.familyStylesByLicense[fontawesome_license].forEach((style) => {
let familyStyle = style.style;
if (style.family !== 'classic') {
familyStyle = `${style.family}-${familyStyle}`;
}
if (!config.fontawesome.styles.includes(familyStyle)) {
return;
}
result.push({
id: icon.id,
label: `${icon.label} (${style.style})`,
style: style.style,
family: style.family,
});
});
return result;

@ -1,29 +0,0 @@
*.pyc
*.egg-info
*.db
*.db.old
*.swp
*.db-journal
.coverage
.DS_Store
.installed.cfg
.idea/*
.svn/*
src/website/static/*
src/website/media/*
bin
build
cfcache
develop-eggs
dist
downloads
eggs
parts
tmp
.sass-cache
src/website/settingslocal.py
stunnel.log

@ -1,165 +0,0 @@
Fonticons, Inc. (https://fontawesome.com)
--------------------------------------------------------------------------------
Font Awesome Free License
Font Awesome Free is free, open source, and GPL friendly. You can use it for
commercial projects, open source projects, or really almost whatever you want.
Full Font Awesome Free license: https://fontawesome.com/license/free.
--------------------------------------------------------------------------------
# Icons: CC BY 4.0 License (https://creativecommons.org/licenses/by/4.0/)
The Font Awesome Free download is licensed under a Creative Commons
Attribution 4.0 International License and applies to all icons packaged
as SVG and JS file types.
--------------------------------------------------------------------------------
# Fonts: SIL OFL 1.1 License
In the Font Awesome Free download, the SIL OFL license applies to all icons
packaged as web and desktop font files.
Copyright (c) 2022 Fonticons, Inc. (https://fontawesome.com)
with Reserved Font Name: "Font Awesome".
This Font Software is licensed under the SIL Open Font License, Version 1.1.
This license is copied below, and is also available with a FAQ at:
http://scripts.sil.org/OFL
SIL OPEN FONT LICENSE
Version 1.1 - 26 February 2007
PREAMBLE
The goals of the Open Font License (OFL) are to stimulate worldwide
development of collaborative font projects, to support the font creation
efforts of academic and linguistic communities, and to provide a free and
open framework in which fonts may be shared and improved in partnership
with others.
The OFL allows the licensed fonts to be used, studied, modified and
redistributed freely as long as they are not sold by themselves. The
fonts, including any derivative works, can be bundled, embedded,
redistributed and/or sold with any software provided that any reserved
names are not used by derivative works. The fonts and derivatives,
however, cannot be released under any other type of license. The
requirement for fonts to remain under this license does not apply
to any document created using the fonts or their derivatives.
DEFINITIONS
"Font Software" refers to the set of files released by the Copyright
Holder(s) under this license and clearly marked as such. This may
include source files, build scripts and documentation.
"Reserved Font Name" refers to any names specified as such after the
copyright statement(s).
"Original Version" refers to the collection of Font Software components as
distributed by the Copyright Holder(s).
"Modified Version" refers to any derivative made by adding to, deleting,
or substituting — in part or in whole — any of the components of the
Original Version, by changing formats or by porting the Font Software to a
new environment.
"Author" refers to any designer, engineer, programmer, technical
writer or other person who contributed to the Font Software.
PERMISSION & CONDITIONS
Permission is hereby granted, free of charge, to any person obtaining
a copy of the Font Software, to use, study, copy, merge, embed, modify,
redistribute, and sell modified and unmodified copies of the Font
Software, subject to the following conditions:
1) Neither the Font Software nor any of its individual components,
in Original or Modified Versions, may be sold by itself.
2) Original or Modified Versions of the Font Software may be bundled,
redistributed and/or sold with any software, provided that each copy
contains the above copyright notice and this license. These can be
included either as stand-alone text files, human-readable headers or
in the appropriate machine-readable metadata fields within text or
binary files as long as those fields can be easily viewed by the user.
3) No Modified Version of the Font Software may use the Reserved Font
Name(s) unless explicit written permission is granted by the corresponding
Copyright Holder. This restriction only applies to the primary font name as
presented to the users.
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
Software shall not be used to promote, endorse or advertise any
Modified Version, except to acknowledge the contribution(s) of the
Copyright Holder(s) and the Author(s) or with their explicit written
permission.
5) The Font Software, modified or unmodified, in part or in whole,
must be distributed entirely under this license, and must not be
distributed under any other license. The requirement for fonts to
remain under this license does not apply to any document created
using the Font Software.
TERMINATION
This license becomes null and void if any of the above conditions are
not met.
DISCLAIMER
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
OTHER DEALINGS IN THE FONT SOFTWARE.
--------------------------------------------------------------------------------
# Code: MIT License (https://opensource.org/licenses/MIT)
In the Font Awesome Free download, the MIT license applies to all non-font and
non-icon files.
Copyright 2022 Fonticons, Inc.
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in the
Software without restriction, including without limitation the rights to use, copy,
modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
and to permit persons to whom the Software is furnished to do so, subject to the
following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
--------------------------------------------------------------------------------
# Attribution
Attribution is required by MIT, SIL OFL, and CC BY licenses. Downloaded Font
Awesome Free files already contain embedded comments with sufficient
attribution, so you shouldn't need to do anything additional when using these
files normally.
We've kept attribution comments terse, so we ask that you do not actively work
to remove them from files, especially code. They're a great way for folks to
learn about Font Awesome.
--------------------------------------------------------------------------------
# Brand Icons
All brand icons are trademarks of their respective owners. The use of these
trademarks does not indicate endorsement of the trademark holder by Font
Awesome, nor vice versa. **Please do not use brand logos for any purpose except
to represent the company, product, or service to which they refer.**

@ -1,3 +0,0 @@
console.log(`Font Awesome Free 6.2.0 by @fontawesome - https://fontawesome.com
License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License)
`)

@ -1,153 +0,0 @@
// animating icons
// --------------------------
.#{$fa-css-prefix}-beat {
animation-name: #{$fa-css-prefix}-beat;
animation-delay: var(--#{$fa-css-prefix}-animation-delay, 0s);
animation-direction: var(--#{$fa-css-prefix}-animation-direction, normal);
animation-duration: var(--#{$fa-css-prefix}-animation-duration, 1s);
animation-iteration-count: var(--#{$fa-css-prefix}-animation-iteration-count, infinite);
animation-timing-function: var(--#{$fa-css-prefix}-animation-timing, ease-in-out);
}
.#{$fa-css-prefix}-bounce {
animation-name: #{$fa-css-prefix}-bounce;
animation-delay: var(--#{$fa-css-prefix}-animation-delay, 0s);
animation-direction: var(--#{$fa-css-prefix}-animation-direction, normal);
animation-duration: var(--#{$fa-css-prefix}-animation-duration, 1s);
animation-iteration-count: var(--#{$fa-css-prefix}-animation-iteration-count, infinite);
animation-timing-function: var(--#{$fa-css-prefix}-animation-timing, cubic-bezier(0.280, 0.840, 0.420, 1));
}
.#{$fa-css-prefix}-fade {
animation-name: #{$fa-css-prefix}-fade;
animation-delay: var(--#{$fa-css-prefix}-animation-delay, 0s);
animation-direction: var(--#{$fa-css-prefix}-animation-direction, normal);
animation-duration: var(--#{$fa-css-prefix}-animation-duration, 1s);
animation-iteration-count: var(--#{$fa-css-prefix}-animation-iteration-count, infinite);
animation-timing-function: var(--#{$fa-css-prefix}-animation-timing, cubic-bezier(.4,0,.6,1));
}
.#{$fa-css-prefix}-beat-fade {
animation-name: #{$fa-css-prefix}-beat-fade;
animation-delay: var(--#{$fa-css-prefix}-animation-delay, 0s);
animation-direction: var(--#{$fa-css-prefix}-animation-direction, normal);
animation-duration: var(--#{$fa-css-prefix}-animation-duration, 1s);
animation-iteration-count: var(--#{$fa-css-prefix}-animation-iteration-count, infinite);
animation-timing-function: var(--#{$fa-css-prefix}-animation-timing, cubic-bezier(.4,0,.6,1));
}
.#{$fa-css-prefix}-flip {
animation-name: #{$fa-css-prefix}-flip;
animation-delay: var(--#{$fa-css-prefix}-animation-delay, 0s);
animation-direction: var(--#{$fa-css-prefix}-animation-direction, normal);
animation-duration: var(--#{$fa-css-prefix}-animation-duration, 1s);
animation-iteration-count: var(--#{$fa-css-prefix}-animation-iteration-count, infinite);
animation-timing-function: var(--#{$fa-css-prefix}-animation-timing, ease-in-out);
}
.#{$fa-css-prefix}-shake {
animation-name: #{$fa-css-prefix}-shake;
animation-delay: var(--#{$fa-css-prefix}-animation-delay, 0s);
animation-direction: var(--#{$fa-css-prefix}-animation-direction, normal);
animation-duration: var(--#{$fa-css-prefix}-animation-duration, 1s);
animation-iteration-count: var(--#{$fa-css-prefix}-animation-iteration-count, infinite);
animation-timing-function: var(--#{$fa-css-prefix}-animation-timing, linear);
}
.#{$fa-css-prefix}-spin {
animation-name: #{$fa-css-prefix}-spin;
animation-delay: var(--#{$fa-css-prefix}-animation-delay, 0s);
animation-direction: var(--#{$fa-css-prefix}-animation-direction, normal);
animation-duration: var(--#{$fa-css-prefix}-animation-duration, 2s);
animation-iteration-count: var(--#{$fa-css-prefix}-animation-iteration-count, infinite);
animation-timing-function: var(--#{$fa-css-prefix}-animation-timing, linear);
}
.#{$fa-css-prefix}-spin-reverse {
--#{$fa-css-prefix}-animation-direction: reverse;
}
.#{$fa-css-prefix}-pulse,
.#{$fa-css-prefix}-spin-pulse {
animation-name: #{$fa-css-prefix}-spin;
animation-direction: var(--#{$fa-css-prefix}-animation-direction, normal);
animation-duration: var(--#{$fa-css-prefix}-animation-duration, 1s);
animation-iteration-count: var(--#{$fa-css-prefix}-animation-iteration-count, infinite);
animation-timing-function: var(--#{$fa-css-prefix}-animation-timing, steps(8));
}
// if agent or operating system prefers reduced motion, disable animations
// see: https://www.smashingmagazine.com/2020/09/design-reduced-motion-sensitivities/
// see: https://developer.mozilla.org/en-US/docs/Web/CSS/@media/prefers-reduced-motion
@media (prefers-reduced-motion: reduce) {
.#{$fa-css-prefix}-beat,
.#{$fa-css-prefix}-bounce,
.#{$fa-css-prefix}-fade,
.#{$fa-css-prefix}-beat-fade,
.#{$fa-css-prefix}-flip,
.#{$fa-css-prefix}-pulse,
.#{$fa-css-prefix}-shake,
.#{$fa-css-prefix}-spin,
.#{$fa-css-prefix}-spin-pulse {
animation-delay: -1ms;
animation-duration: 1ms;
animation-iteration-count: 1;
transition-delay: 0s;
transition-duration: 0s;
}
}
@keyframes #{$fa-css-prefix}-beat {
0%, 90% { transform: scale(1); }
45% { transform: scale(var(--#{$fa-css-prefix}-beat-scale, 1.25)); }
}
@keyframes #{$fa-css-prefix}-bounce {
0% { transform: scale(1,1) translateY(0); }
10% { transform: scale(var(--#{$fa-css-prefix}-bounce-start-scale-x, 1.1),var(--#{$fa-css-prefix}-bounce-start-scale-y, 0.9)) translateY(0); }
30% { transform: scale(var(--#{$fa-css-prefix}-bounce-jump-scale-x, 0.9),var(--#{$fa-css-prefix}-bounce-jump-scale-y, 1.1)) translateY(var(--#{$fa-css-prefix}-bounce-height, -0.5em)); }
50% { transform: scale(var(--#{$fa-css-prefix}-bounce-land-scale-x, 1.05),var(--#{$fa-css-prefix}-bounce-land-scale-y, 0.95)) translateY(0); }
57% { transform: scale(1,1) translateY(var(--#{$fa-css-prefix}-bounce-rebound, -0.125em)); }
64% { transform: scale(1,1) translateY(0); }
100% { transform: scale(1,1) translateY(0); }
}
@keyframes #{$fa-css-prefix}-fade {
50% { opacity: var(--#{$fa-css-prefix}-fade-opacity, 0.4); }
}
@keyframes #{$fa-css-prefix}-beat-fade {
0%, 100% {
opacity: var(--#{$fa-css-prefix}-beat-fade-opacity, 0.4);
transform: scale(1);
}
50% {
opacity: 1;
transform: scale(var(--#{$fa-css-prefix}-beat-fade-scale, 1.125));
}
}
@keyframes #{$fa-css-prefix}-flip {
50% {
transform: rotate3d(var(--#{$fa-css-prefix}-flip-x, 0), var(--#{$fa-css-prefix}-flip-y, 1), var(--#{$fa-css-prefix}-flip-z, 0), var(--#{$fa-css-prefix}-flip-angle, -180deg));
}
}
@keyframes #{$fa-css-prefix}-shake {
0% { transform: rotate(-15deg); }
4% { transform: rotate(15deg); }
8%, 24% { transform: rotate(-18deg); }
12%, 28% { transform: rotate(18deg); }
16% { transform: rotate(-22deg); }
20% { transform: rotate(22deg); }
32% { transform: rotate(-12deg); }
36% { transform: rotate(12deg); }
40%, 100% { transform: rotate(0deg); }
}
@keyframes #{$fa-css-prefix}-spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}

@ -1,20 +0,0 @@
// bordered + pulled icons
// -------------------------
.#{$fa-css-prefix}-border {
border-color: var(--#{$fa-css-prefix}-border-color, #{$fa-border-color});
border-radius: var(--#{$fa-css-prefix}-border-radius, #{$fa-border-radius});
border-style: var(--#{$fa-css-prefix}-border-style, #{$fa-border-style});
border-width: var(--#{$fa-css-prefix}-border-width, #{$fa-border-width});
padding: var(--#{$fa-css-prefix}-border-padding, #{$fa-border-padding});
}
.#{$fa-css-prefix}-pull-left {
float: left;
margin-right: var(--#{$fa-css-prefix}-pull-margin, #{$fa-pull-margin});
}
.#{$fa-css-prefix}-pull-right {
float: right;
margin-left: var(--#{$fa-css-prefix}-pull-margin, #{$fa-pull-margin});
}

@ -1,43 +0,0 @@
// base icon class definition
// -------------------------
.#{$fa-css-prefix} {
font-family: var(--#{$fa-css-prefix}-style-family, '#{$fa-style-family}');
font-weight: var(--#{$fa-css-prefix}-style, #{$fa-style});
}
.#{$fa-css-prefix},
.#{$fa-css-prefix}-classic,
.#{$fa-css-prefix}-sharp,
.fas,
.#{$fa-css-prefix}-solid,
.far,
.#{$fa-css-prefix}-regular,
.fab,
.#{$fa-css-prefix}-brands {
-moz-osx-font-smoothing: grayscale;
-webkit-font-smoothing: antialiased;
display: var(--#{$fa-css-prefix}-display, #{$fa-display});
font-style: normal;
font-variant: normal;
line-height: 1;
text-rendering: auto;
}
.fas,
.#{$fa-css-prefix}-classic,
.#{$fa-css-prefix}-solid,
.far,
.#{$fa-css-prefix}-regular {
font-family: 'Font Awesome 6 Free';
}
.fab,
.#{$fa-css-prefix}-brands {
font-family: 'Font Awesome 6 Brands';
}
%fa-icon {
@include fa-icon;
}

@ -1,7 +0,0 @@
// fixed-width icons
// -------------------------
.#{$fa-css-prefix}-fw {
text-align: center;
width: $fa-fw-width;
}

@ -1,57 +0,0 @@
// functions
// --------------------------
// fa-content: convenience function used to set content property
@function fa-content($fa-var) {
@return unquote("\"#{ $fa-var }\"");
}
// fa-divide: Originally obtained from the Bootstrap https://github.com/twbs/bootstrap
//
// Licensed under: The MIT License (MIT)
//
// Copyright (c) 2011-2021 Twitter, Inc.
// Copyright (c) 2011-2021 The Bootstrap Authors
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
@function fa-divide($dividend, $divisor, $precision: 10) {
$sign: if($dividend > 0 and $divisor > 0, 1, -1);
$dividend: abs($dividend);
$divisor: abs($divisor);
$quotient: 0;
$remainder: $dividend;
@if $dividend == 0 {
@return 0;
}
@if $divisor == 0 {
@error "Cannot divide by 0";
}
@if $divisor == 1 {
@return $dividend;
}
@while $remainder >= $divisor {
$quotient: $quotient + 1;
$remainder: $remainder - $divisor;
}
@if $remainder > 0 and $precision > 0 {
$remainder: fa-divide($remainder * 10, $divisor, $precision - 1) * .1;
}
@return ($quotient + $remainder) * $sign;
}

@ -1,9 +0,0 @@
// specific icon class definition
// -------------------------
/* Font Awesome uses the Unicode Private Use Area (PUA) to ensure screen
readers do not read off random characters that represent icons */
@each $name, $icon in $fa-icons {
.#{$fa-css-prefix}-#{$name}::before { content: unquote("\"#{ $icon }\""); }
}

@ -1,24 +0,0 @@
// Icon Sizes
// -------------------------
@use "sass:math";
// makes the font 33% larger relative to the icon container
.#{$fa-css-prefix}-lg {
font-size: math.div(4em, 3);
line-height: math.div(3em, 4);
vertical-align: -.0667em;
}
.#{$fa-css-prefix}-xs {
font-size: .75em;
}
.#{$fa-css-prefix}-sm {
font-size: .875em;
}
@for $i from 1 through 10 {
.#{$fa-css-prefix}-#{$i}x {
font-size: $i * 1em;
}
}

@ -1,18 +0,0 @@
// icons in a list
// -------------------------
.#{$fa-css-prefix}-ul {
list-style-type: none;
margin-left: var(--#{$fa-css-prefix}-li-margin, #{$fa-li-margin});
padding-left: 0;
> li { position: relative; }
}
.#{$fa-css-prefix}-li {
left: calc(var(--#{$fa-css-prefix}-li-width, #{$fa-li-width}) * -1);
position: absolute;
text-align: center;
width: var(--#{$fa-css-prefix}-li-width, #{$fa-li-width});
line-height: inherit;
}

@ -1,75 +0,0 @@
// mixins
// --------------------------
// base rendering for an icon
@mixin fa-icon {
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
display: inline-block;
font-style: normal;
font-variant: normal;
font-weight: normal;
line-height: 1;
}
// sets relative font-sizing and alignment (in _sizing)
@mixin fa-size ($font-size) {
font-size: fa-divide($font-size, $fa-size-scale-base) * 1em; // converts step in sizing scale into an em-based value that's relative to the scale's base
line-height: fa-divide(1, $font-size) * 1em; // sets the line-height of the icon back to that of it's parent
vertical-align: (fa-divide(6, $font-size) - fa-divide(3, 8)) * 1em; // vertically centers the icon taking into account the surrounding text's descender
}
// only display content to screen readers
// see: https://www.a11yproject.com/posts/2013-01-11-how-to-hide-content/
// see: https://hugogiraudel.com/2016/10/13/css-hide-and-seek/
@mixin fa-sr-only() {
position: absolute;
width: 1px;
height: 1px;
padding: 0;
margin: -1px;
overflow: hidden;
clip: rect(0, 0, 0, 0);
white-space: nowrap;
border-width: 0;
}
// use in conjunction with .sr-only to only display content when it's focused
@mixin fa-sr-only-focusable() {
&:not(:focus) {
@include fa-sr-only();
}
}
// sets a specific icon family to use alongside style + icon mixins
// convenience mixins for declaring pseudo-elements by CSS variable,
// including all style-specific font properties, and both the ::before
// and ::after elements in the duotone case.
@mixin fa-icon-solid($fa-var) {
@extend %fa-icon;
@extend .fa-solid;
&::before {
content: unquote("\"#{ $fa-var }\"");
}
}
@mixin fa-icon-regular($fa-var) {
@extend %fa-icon;
@extend .fa-regular;
&::before {
content: unquote("\"#{ $fa-var }\"");
}
}
@mixin fa-icon-brands($fa-var) {
@extend %fa-icon;
@extend .fa-brands;
&::before {
content: unquote("\"#{ $fa-var }\"");
}
}

@ -1,31 +0,0 @@
// rotating + flipping icons
// -------------------------
.#{$fa-css-prefix}-rotate-90 {
transform: rotate(90deg);
}
.#{$fa-css-prefix}-rotate-180 {
transform: rotate(180deg);
}
.#{$fa-css-prefix}-rotate-270 {
transform: rotate(270deg);
}
.#{$fa-css-prefix}-flip-horizontal {
transform: scale(-1, 1);
}
.#{$fa-css-prefix}-flip-vertical {
transform: scale(1, -1);
}
.#{$fa-css-prefix}-flip-both,
.#{$fa-css-prefix}-flip-horizontal.#{$fa-css-prefix}-flip-vertical {
transform: scale(-1, -1);
}
.#{$fa-css-prefix}-rotate-by {
transform: rotate(var(--#{$fa-css-prefix}-rotate-angle, none));
}

@ -1,14 +0,0 @@
// screen-reader utilities
// -------------------------
// only display content to screen readers
.sr-only,
.#{$fa-css-prefix}-sr-only {
@include fa-sr-only;
}
// use in conjunction with .sr-only to only display content when it's focused
.sr-only-focusable,
.#{$fa-css-prefix}-sr-only-focusable {
@include fa-sr-only-focusable;
}

File diff suppressed because it is too large Load Diff

@ -1,16 +0,0 @@
// sizing icons
// -------------------------
// literal magnification scale
@for $i from 1 through 10 {
.#{$fa-css-prefix}-#{$i}x {
font-size: $i * 1em;
}
}
// step-based scale (with alignment)
@each $size, $value in $fa-sizes {
.#{$fa-css-prefix}-#{$size} {
@include fa-size($value);
}
}

@ -1,32 +0,0 @@
// stacking icons
// -------------------------
.#{$fa-css-prefix}-stack {
display: inline-block;
height: 2em;
line-height: 2em;
position: relative;
vertical-align: $fa-stack-vertical-align;
width: $fa-stack-width;
}
.#{$fa-css-prefix}-stack-1x,
.#{$fa-css-prefix}-stack-2x {
left: 0;
position: absolute;
text-align: center;
width: 100%;
z-index: var(--#{$fa-css-prefix}-stack-z-index, #{$fa-stack-z-index});
}
.#{$fa-css-prefix}-stack-1x {
line-height: inherit;
}
.#{$fa-css-prefix}-stack-2x {
font-size: 2em;
}
.#{$fa-css-prefix}-inverse {
color: var(--#{$fa-css-prefix}-inverse, #{$fa-inverse});
}

File diff suppressed because it is too large Load Diff

@ -1,30 +0,0 @@
/*!
* Font Awesome Free 6.2.0 by @fontawesome - https://fontawesome.com
* License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License)
* Copyright 2022 Fonticons, Inc.
*/
@import 'functions';
@import 'variables';
:root, :host {
--#{$fa-css-prefix}-style-family-brands: 'Font Awesome 6 Brands';
--#{$fa-css-prefix}-font-brands: normal 400 1em/1 'Font Awesome 6 Brands';
}
@font-face {
font-family: 'Font Awesome 6 Brands';
font-style: normal;
font-weight: 400;
font-display: $fa-font-display;
src: url('#{$fa-font-path}/fa-brands-400.woff2') format('woff2'),
url('#{$fa-font-path}/fa-brands-400.ttf') format('truetype');
}
.fab,
.#{$fa-css-prefix}-brands {
font-weight: 400;
}
@each $name, $icon in $fa-brand-icons {
.#{$fa-css-prefix}-#{$name}:before { content: unquote("\"#{ $icon }\""); }
}

@ -1,21 +0,0 @@
/*!
* Font Awesome Free 6.2.0 by @fontawesome - https://fontawesome.com
* License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License)
* Copyright 2022 Fonticons, Inc.
*/
// Font Awesome core compile (Web Fonts-based)
// -------------------------
@import 'functions';
@import 'variables';
@import 'mixins';
@import 'core';
@import 'sizing';
@import 'fixed-width';
@import 'list';
@import 'bordered-pulled';
@import 'animated';
@import 'rotated-flipped';
@import 'stacked';
@import 'icons';
@import 'screen-reader';

@ -1,26 +0,0 @@
/*!
* Font Awesome Free 6.2.0 by @fontawesome - https://fontawesome.com
* License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License)
* Copyright 2022 Fonticons, Inc.
*/
@import 'functions';
@import 'variables';
:root, :host {
--#{$fa-css-prefix}-style-family-classic: '#{ $fa-style-family }';
--#{$fa-css-prefix}-font-regular: normal 400 1em/1 '#{ $fa-style-family }';
}
@font-face {
font-family: 'Font Awesome 6 Free';
font-style: normal;
font-weight: 400;
font-display: $fa-font-display;
src: url('#{$fa-font-path}/fa-regular-400.woff2') format('woff2'),
url('#{$fa-font-path}/fa-regular-400.ttf') format('truetype');
}
.far,
.#{$fa-css-prefix}-regular {
font-weight: 400;
}

@ -1,26 +0,0 @@
/*!
* Font Awesome Free 6.2.0 by @fontawesome - https://fontawesome.com
* License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License)
* Copyright 2022 Fonticons, Inc.
*/
@import 'functions';
@import 'variables';
:root, :host {
--#{$fa-css-prefix}-style-family-classic: '#{ $fa-style-family }';
--#{$fa-css-prefix}-font-solid: normal 900 1em/1 '#{ $fa-style-family }';
}
@font-face {
font-family: 'Font Awesome 6 Free';
font-style: normal;
font-weight: 900;
font-display: $fa-font-display;
src: url('#{$fa-font-path}/fa-solid-900.woff2') format('woff2'),
url('#{$fa-font-path}/fa-solid-900.ttf') format('truetype');
}
.fas,
.#{$fa-css-prefix}-solid {
font-weight: 900;
}

@ -1,11 +0,0 @@
/*!
* Font Awesome Free 6.2.0 by @fontawesome - https://fontawesome.com
* License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License)
* Copyright 2022 Fonticons, Inc.
*/
// V4 shims compile (Web Fonts-based)
// -------------------------
@import 'functions';
@import 'variables';
@import 'shims';

@ -10,6 +10,7 @@ const plugins = require('../plugins');
const translator = require('../translator');
const languages = require('../languages');
const { generateToken } = require('../middleware/csrf');
const utils = require('../utils');
const apiController = module.exports;
@ -19,6 +20,9 @@ const asset_base_url = nconf.get('asset_base_url');
const socketioTransports = nconf.get('socket.io:transports') || ['polling', 'websocket'];
const socketioOrigins = nconf.get('socket.io:origins');
const websocketAddress = nconf.get('socket.io:address') || '';
const fontawesome_pro = nconf.get('fontawesome:pro') || false;
const fontawesome_styles = utils.getFontawesomeStyles();
const fontawesome_version = utils.getFontawesomeVersion();
apiController.loadConfig = async function (req) {
const config = {
@ -86,6 +90,11 @@ apiController.loadConfig = async function (req) {
iconBackgrounds: await user.getIconBackgrounds(req.uid),
emailPrompt: meta.config.emailPrompt,
useragent: req.useragent,
fontawesome: {
pro: fontawesome_pro,
styles: fontawesome_styles,
version: fontawesome_version,
},
};
let settings = config;

@ -10,6 +10,7 @@ const plugins = require('../plugins');
const db = require('../database');
const file = require('../file');
const minifier = require('./minifier');
const utils = require('../utils');
const CSS = module.exports;
@ -35,7 +36,8 @@ const buildImports = {
'@import "admin/overrides";',
'@import "bootstrap/scss/bootstrap";',
'@import "mixins";',
'@import "fontawesome";',
'@import "fontawesome/loader";',
getFontawesomeStyle(),
'@import "@adactive/bootstrap-tagsinput/src/bootstrap-tagsinput";',
'@import "generics";',
'@import "responsive-utilities";',
@ -119,7 +121,9 @@ function boostrapImport(themeData) {
'@import "bootstrap/scss/utilities/api";',
// scss-docs-end import-stack
'@import "fontawesome";',
'@import "fontawesome/loader";',
getFontawesomeStyle(),
'@import "mixins";', // core mixins
'@import "generics";',
'@import "client";', // core page styles
@ -128,6 +132,12 @@ function boostrapImport(themeData) {
].join('\n');
}
function getFontawesomeStyle() {
const styles = utils.getFontawesomeStyles();
return styles.map(style => `@import "fontawesome/style-${style}";`).join('\n');
}
async function filterMissingFiles(filepaths) {
const exists = await Promise.all(
filepaths.map(async (filepath) => {
@ -176,6 +186,7 @@ async function getBundleMetadata(target) {
path.join(__dirname, '../../node_modules'),
path.join(__dirname, '../../public/scss'),
path.join(__dirname, '../../public/vendor/fontawesome/scss'),
path.join(utils.getFontawesomePath(), 'scss'),
];
// Skin support

@ -58,6 +58,10 @@ function loadConfig(configFile) {
isCluster: false,
isPrimary: true,
jobsDisabled: false,
fontawesome: {
pro: false,
styles: '*',
},
});
// Explicitly cast as Bool, loader.js passes in isCluster as string 'true'/'false'

@ -9,6 +9,7 @@ const meta = require('../meta');
const controllers = require('../controllers');
const controllerHelpers = require('../controllers/helpers');
const plugins = require('../plugins');
const utils = require('../utils');
const authRoutes = require('./authentication');
const writeRoutes = require('./write');
@ -172,6 +173,7 @@ function addCoreRoutes(app, router, middleware, mounts) {
const statics = [
{ route: '/assets', path: path.join(__dirname, '../../build/public') },
{ route: '/assets', path: path.join(__dirname, '../../public') },
{ route: '/assets/vendor/fontawesome/webfonts', path: path.join(utils.getFontawesomePath(), 'webfonts') },
];
const staticOptions = {
maxAge: app.enabled('cache') ? 5184000000 : 0,

@ -1,6 +1,8 @@
'use strict';
const crypto = require('crypto');
const nconf = require('nconf');
const path = require('node:path');
process.profile = function (operation, start) {
console.log('%s took %d milliseconds', operation, process.elapsedTimeSince(start));
@ -38,4 +40,36 @@ utils.getSass = function () {
}
};
utils.getFontawesomePath = function () {
let packageName = '@fortawesome/fontawesome-free';
if (nconf.get('fontawesome:pro') === true) {
packageName = '@fortawesome/fontawesome-pro';
}
const pathToMainFile = require.resolve(packageName);
// main file will be in `js/fontawesome.js` - we need to go up two directories to get to the root of the package
const fontawesomePath = path.dirname(path.dirname(pathToMainFile));
return fontawesomePath;
};
utils.getFontawesomeStyles = function () {
let styles = nconf.get('fontawesome:styles') || '*';
// "*" is a special case, it means all styles, spread is used to support both string and array (["*"])
if ([...styles][0] === '*') {
styles = ['solid', 'brands', 'regular'];
if (nconf.get('fontawesome:pro')) {
styles.push('light', 'thin', 'sharp', 'duotone');
}
}
if (!Array.isArray(styles)) {
styles = [styles];
}
return styles;
};
utils.getFontawesomeVersion = function () {
const fontawesomePath = utils.getFontawesomePath();
const packageJson = require(path.join(fontawesomePath, 'package.json'));
return packageJson.version;
};
module.exports = utils;

Loading…
Cancel
Save