1
0
mirror of https://github.com/e107inc/e107.git synced 2025-01-16 20:28:28 +01:00

Closes #4969, Fixes #5008, Fixes #4498 - FontAwesome6 support.

This commit is contained in:
camer0n 2023-11-17 11:18:23 -08:00
parent bf3ba04430
commit 34ba78023c
13 changed files with 216 additions and 61 deletions

View File

@ -2211,10 +2211,10 @@ class media_admin_ui extends e_admin_ui
$md = e107::getMedia();
if($this->fontawesome === 5)
if($this->fontawesome > 4) // Fontawesome 5 and 6
{
// e107::getParser()->setFontAwesome(5);
$fab = e107::getMedia()->getGlyphs('fab');
$fab = e107::getMedia()->getGlyphs('fa'.$this->fontawesome.'-fab');
foreach($fab as $val)
{
@ -2224,13 +2224,13 @@ class media_admin_ui extends e_admin_ui
'saveValue' => 'fab-'.$val.'.glyph',
'thumbUrl' => 'fab-'.$val,
'title' => 'FA5 fa-'.$val,
'slideCaption' => 'Font-Awesome 5 (brand)',
'slideCaption' => "Font-Awesome $this->fontawesome (brand)",
'slideCategory' => 'font-awesome'
);
}
$fas = e107::getMedia()->getGlyphs('fas');
$fas = e107::getMedia()->getGlyphs('fa'.$this->fontawesome.'-fas');
foreach($fas as $val)
{
@ -2240,13 +2240,13 @@ class media_admin_ui extends e_admin_ui
'saveValue' => 'fas-'.$val.'.glyph',
'thumbUrl' => 'fas-'.$val,
'title' => 'FA5 fa-'.$val,
'slideCaption' => 'Font-Awesome 5 (solid)',
'slideCaption' => "Font-Awesome $this->fontawesome (solid)",
'slideCategory' => 'font-awesome'
);
}
$far = e107::getMedia()->getGlyphs('far');
$far = e107::getMedia()->getGlyphs('fa'.$this->fontawesome.'-far');
foreach($far as $val)
{
@ -2256,7 +2256,7 @@ class media_admin_ui extends e_admin_ui
'saveValue' => 'far-'.$val.'.glyph',
'thumbUrl' => 'far-'.$val,
'title' => 'FA5 far-'.$val,
'slideCaption' => 'Font-Awesome 5 (regular)',
'slideCaption' => "Font-Awesome $this->fontawesome (regular)",
'slideCategory' => 'font-awesome'
);

View File

@ -3973,6 +3973,7 @@ class e_parse
$cat = '';
$name = '';
list($id) = explode('.glyph', $text, 2); // trim .glyph from the end.
$origID = $id;
if (strpos($id, '-') !== false)
{
list($cat, $name) = explode('-', $id, 2);
@ -4031,10 +4032,11 @@ class e_parse
default:
if ($this->fontawesome === 5 || $this->fontawesome === 6)
{
$fab = e107::getMedia()->getGlyphs('fab');
$fas = e107::getMedia()->getGlyphs('fas');
$far = e107::getMedia()->getGlyphs('far');
$shims = e107::getMedia()->getGlyphs('fa5-shims');
$vr = 'fa'.$this->fontawesome.'-';
$fab = e107::getMedia()->getGlyphs($vr.'fab');
$fas = e107::getMedia()->getGlyphs($vr.'fas');
$far = e107::getMedia()->getGlyphs($vr.'far');
$shims = e107::getMedia()->getGlyphs($vr.'shims');
$fa4 = e107::getMedia()->getGlyphs('fa4');
list($tmp) = explode('-', $id);
@ -4051,7 +4053,7 @@ class e_parse
}
elseif (isset($fas[$code]))
{
$prefix = 'fas ';
$prefix = 'fas '; // 'fa-solid' for fa6?
$id = 'fa-' . $code;
}
elseif (in_array($code, $far))
@ -4125,6 +4127,7 @@ class e_parse
{
$prefix = $glyphConfig['class'] . ' ';
$tag = $glyphConfig['tag'];
$id = $origID;
continue;
}
}

View File

@ -192,6 +192,7 @@ class core_library
// Override library path.
'library_path' => '{e_WEB}lib/jquery-once',
'version' => '2.2.3',
'path' => '',
);
// jQuery UI (CDN).
@ -713,6 +714,7 @@ class core_library
// Override library path.
'library_path' => '{e_WEB}js/bootstrap3-editable',
'version' => '1.5.1',
'path' => '',
);
// Bootstrap Switch (CDN).
@ -934,7 +936,7 @@ class core_library
'version' => '5.15.4',
);
// Font-Awesome (local).
// Font-Awesome 5 (local).
$libraries['fontawesome5'] = array(
'name' => 'Font-Awesome 5 (local)',
'vendor_url' => 'https://fontawesome.com/',
@ -1038,7 +1040,7 @@ class core_library
'variants' => array(),
'library_path' => '{e_WEB}lib/font-awesome',
'path' => '6',
'version' => '6.2.1',
'version' => '6.4.2',
);
@ -1076,9 +1078,9 @@ class core_library
),
'variants' => array(),
// Override library path to CDN.
'library_path' => 'https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.2.1',
'library_path' => 'https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.2',
'path' => '',
'version' => '6.2.1',
'version' => '6.4.2',
);
@ -1655,7 +1657,7 @@ class e_library_manager
public function getPath($library, $mode=null)
{
$path = self::getProperty($library, 'library_path').'/'. self::getProperty($library, 'path');
return e107::getParser()->replaceConstants($path,$mode).'/';
return trim(e107::getParser()->replaceConstants($path,$mode),'/') .'/';
}

File diff suppressed because one or more lines are too long

View File

@ -24,7 +24,7 @@
}
catch(Exception $e)
{
$this->assertTrue(false, $e->getMessage());
$this->fail($e->getMessage());
}
@ -34,7 +34,7 @@
}
catch(Exception $e)
{
$this->assertTrue(false, $e->getMessage());
$this->fail($e->getMessage());
}
$coreLibraries = $this->corelib->config();
@ -60,7 +60,7 @@
foreach($lookups as $name)
{
$this->assertFalse(true, "'version' key is missing in core_library:config() -- ".$name);
$this->fail("'version' key is missing in core_library:config() -- " . $name);
}
@ -71,17 +71,18 @@
foreach($this->libraries as $name)
{
echo $name."\n";
$coded = $this->lib->detect($name);
$detected = $this->lib->detect($name, true);
if(empty($coded['version']))
{
$this->assertTrue(false, "No coded version returned in core_library:config() -- ".$name);
$this->fail("No coded version returned in core_library:config() -- " . $name);
}
if(empty($detected['version']))
{
$this->assertTrue(false, "No looked-up version in core_library:config() -- ".$name);
$this->fail("No looked-up version in core_library:config() -- " . $name);
}
$this->assertSame($coded['version'],$detected['version'], 'Version mismatch in core_library:config() -- '.$name);
@ -90,6 +91,81 @@
}
public function testCoreLibraryPresence()
{
$coreLibraries = $this->corelib->config();
foreach($coreLibraries as $id => $item)
{
$path = $this->lib->getPath($id);
if(strpos($path, 'http') === 0) // Remote
{
if(!empty($item['files']))
{
foreach($item['files'] as $k=>$v)
{
foreach($v as $file => $info)
{
$url = $path.$file;
$valid = $this->isValidURL($url);
$this->assertTrue($valid, $url.' is not valid. (404)');
}
}
}
}
else // Local
{
if(!empty($item['files']))
{
foreach($item['files'] as $k=>$v)
{
foreach($v as $file => $info)
{
$this->assertStringNotContainsString('//',$path);
$this->assertFileExists($path.$file);
}
}
}
}
}
}
private function isValidURL($url)
{
if(empty($url))
{
return false;
}
if(!$headers = get_headers($url))
{
return false;
}
if(!empty($headers[0]) && strpos($headers[0], 'OK') !== false)
{
return true;
}
return false;
}
/*
public function testInfo()
{

View File

@ -241,9 +241,9 @@
}
*/
private function compileFontAwesome5Meta()
private function compileFontAwesomeMeta($version)
{
$raw = file_get_contents(e_WEB."lib/font-awesome/5/metadata/icons.json");
$raw = file_get_contents(e_WEB."lib/font-awesome/$version/metadata/icons.json");
$icons = e107::unserialize($raw);
$ret = [];
@ -261,15 +261,19 @@
}
$ret['fa5-shims'] = $this->compileFontAwesome5Shims();
$ret['fa'.$version.'-shims'] = $this->compileFontAwesomeShims($version);
return $ret;
}
private function compileFontAwesome5Shims()
/**
* @param string $version (major version number. eg. 5 or 6)
* @return array
*/
private function compileFontAwesomeShims($version)
{
$raw = file_get_contents(e_WEB."lib/font-awesome/5/metadata/shims.json");
$raw = file_get_contents(e_WEB."lib/font-awesome/$version/metadata/shims.json");
$icons = e107::unserialize($raw);
$ret = [];
@ -289,7 +293,7 @@
{
// @todo uncomment to rebuild getGlyphs() arrays for fontawesome. (requires 'metadata' folder)
// $meta = $this->compileFontAwesome5Meta();
// $meta = $this->compileFontAwesomeMeta(6);
// var_export($meta);
// $far = $this->md->getGlyphs('far');
// $this->assertSame($meta['far'], $far);
@ -299,19 +303,25 @@
// $this->assertSame($meta['fab'], $fab);
// Check that FontAwesome 5 meta arrays are up-to-date.
// FontAwesome 6
$fa6_fas = $this->md->getGlyphs('fa6-fas');
$this->assertContains('wine-glass-empty', $fa6_fas);
$fa6Shims = $this->md->getGlyphs('fa6-shims');
$this->assertArrayHasKey('glass', $fa6Shims);
// FontAwesome 5
$fab = $this->md->getGlyphs('fab');
$fab = $this->md->getGlyphs('fa5-fab');
$this->assertContains('500px', $fab);
$fas = $this->md->getGlyphs('fas');
$fas = $this->md->getGlyphs('fa5-fas');
$this->assertContains('address-book', $fas);
$far = $this->md->getGlyphs('far');
$far = $this->md->getGlyphs('fa5-far');
$this->assertContains('arrow-alt-circle-down', $far);
// Check FontAwesome 4
$fa4 = $this->md->getGlyphs('fas');
$fa4 = $this->md->getGlyphs('fa5-fas');
$this->assertContains('heart', $fa4);
// Check Bootstrap 3
@ -319,11 +329,11 @@
$this->assertNotEmpty($result['adjust']);
$this->assertNotEmpty($result['zoom-out']);
// Check FontAweomse 5 Shims
// Check FontAwesome 5 Shims
$fa5Shims = $this->md->getGlyphs('fa5-shims');
$this->assertArrayHasKey('glass', $fa5Shims);
$prefixTest = $this->md->getGlyphs('fab', 'myprefix-');
$prefixTest = $this->md->getGlyphs('fa5-fab', 'myprefix-');
$this->assertContains('myprefix-500px', $prefixTest);
}

View File

@ -2140,6 +2140,13 @@ EXPECTED;
$expected = "<i class='fab fa-mailchimp' ></i> ";
$this->assertEquals($expected, $result);
$this->tp->setFontAwesome(6);
$result = $this->tp->toGlyph('fa-wine-glass-empty');
$expected = "<i class='fas fa-wine-glass-empty' ></i> ";
$this->assertSame($expected, $result);
$result = $this->tp->toGlyph('fa-virus-covid');
$this->assertSame("<i class='fas fa-virus-covid' ></i> ", $result);
$this->tp->setFontAwesome(4);
@ -2249,6 +2256,19 @@ EXPECTED;
$this->tp->setFontAwesome(5);
$result = $this->tp->toGlyph('fa-paypal.glyph');
$this->assertSame("<i class='fab fa-paypal' ></i> ", $result);
$this->tp->setFontAwesome(6);
$result = $this->tp->toGlyph('fa-paypal.glyph');
$this->assertSame("<i class='fab fa-paypal' ></i> ", $result);
$result = $this->tp->toGlyph('fa-clock.glyph');
$this->assertSame("<i class='fas fa-clock' ></i> ", $result);
$result = $this->tp->toGlyph('clock.glyph');
$this->assertSame("<i class='fas fa-clock' ></i> ", $result);
$this->tp->setFontAwesome(5);
}
/*

View File

@ -1,7 +1,7 @@
/*!
* Font Awesome Free 6.2.1 by @fontawesome - https://fontawesome.com
* Font Awesome Free 6.4.2 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.
* Copyright 2023 Fonticons, Inc.
*/
.fa {
font-family: var(--fa-style-family, "Font Awesome 6 Free");
@ -258,7 +258,9 @@
animation-duration: 1ms;
-webkit-animation-iteration-count: 1;
animation-iteration-count: 1;
-webkit-transition-delay: 0s;
transition-delay: 0s;
-webkit-transition-duration: 0s;
transition-duration: 0s; } }
@-webkit-keyframes fa-beat {
@ -491,6 +493,7 @@
/* Font Awesome uses the Unicode Private Use Area (PUA) to ensure screen
readers do not read off random characters that represent icons */
.fa-0::before {
content: "\30"; }
@ -6547,6 +6550,9 @@ readers do not read off random characters that represent icons */
.fa-edge:before {
content: "\f282"; }
.fa-threads:before {
content: "\e618"; }
.fa-napster:before {
content: "\f3d2"; }
@ -6715,6 +6721,9 @@ readers do not read off random characters that represent icons */
.fa-scribd:before {
content: "\f28a"; }
.fa-debian:before {
content: "\e60b"; }
.fa-openid:before {
content: "\f19b"; }
@ -6955,6 +6964,9 @@ readers do not read off random characters that represent icons */
.fa-neos:before {
content: "\f612"; }
.fa-square-threads:before {
content: "\e619"; }
.fa-hackerrank:before {
content: "\f5f7"; }
@ -7297,6 +7309,9 @@ readers do not read off random characters that represent icons */
.fa-erlang:before {
content: "\f39d"; }
.fa-x-twitter:before {
content: "\e61b"; }
.fa-cotton-bureau:before {
content: "\f89e"; }
@ -7744,6 +7759,9 @@ readers do not read off random characters that represent icons */
.fa-internet-explorer:before {
content: "\f26b"; }
.fa-stubber:before {
content: "\e5c7"; }
.fa-telegram:before {
content: "\f2c6"; }
@ -7753,6 +7771,9 @@ readers do not read off random characters that represent icons */
.fa-old-republic:before {
content: "\f510"; }
.fa-odysee:before {
content: "\e5c6"; }
.fa-square-whatsapp:before {
content: "\f40c"; }
@ -7786,6 +7807,9 @@ readers do not read off random characters that represent icons */
.fa-quora:before {
content: "\f2c4"; }
.fa-square-x-twitter:before {
content: "\e61a"; }
.fa-reacteurope:before {
content: "\f75d"; }

File diff suppressed because one or more lines are too long

View File

@ -1,7 +1,7 @@
/*!
* Font Awesome Free 6.2.1 by @fontawesome - https://fontawesome.com
* Font Awesome Free 6.4.2 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.
* Copyright 2023 Fonticons, Inc.
*/
.fa.fa-glass:before {
content: "\f000"; }

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long