1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-27 08:14:46 +02:00

Added option for themes to load only the css or js portion of a library via theme.xml attribute. See bootstrap5/theme.xml for an example.

Empty comments in glyphs removed due to conflict with Fontawesome JS. Tests updated.
This commit is contained in:
Cameron
2021-10-11 12:33:59 -07:00
parent da219c31ae
commit 7755dd1743
14 changed files with 217 additions and 92 deletions

View File

@@ -735,25 +735,48 @@ class e107Test extends \Codeception\Test\Unit
$e107 = $this->e107;
$expected = array (
'js' =>
array (
0 => '{e_WEB}lib/font-awesome/5/js/all.min.js',
1 => '{e_WEB}lib/font-awesome/5/js/v4-shims.min.js',
),
'css' =>
array (
0 => '{e_WEB}lib/font-awesome/5/css/all.min.css',
1 => '{e_WEB}lib/font-awesome/5/css/v4-shims.min.css',
),
);
$result = $e107::library('files', 'fontawesome5');
$this->assertSame($expected, $result);
// -------------------
// Expecting only the JS portion of the library.
$expected = array (
'css' =>
'js' =>
array (
0 => '{e_WEB}lib/bootstrap/5/css/bootstrap.min.css',
0 => '{e_WEB}lib/font-awesome/5/js/all.min.js',
1 => '{e_WEB}lib/font-awesome/5/js/v4-shims.min.js',
),
);
$result = $e107::library('files', 'fontawesome5', null, ['js']);
$this->assertSame($expected, $result);
// -------------------
$expected = array (
'js' =>
array (
0 => '{e_WEB}lib/bootstrap/5/js/bootstrap.bundle.min.js',
),
'css' =>
array (
0 => '{e_WEB}lib/bootstrap/5/css/bootstrap.min.css',
),
);
$result = $e107::library('files', 'bootstrap5');

File diff suppressed because one or more lines are too long

View File

@@ -2035,24 +2035,24 @@ while($row = $sql->fetch())
$this->tp->setFontAwesome(4);
$result = $this->tp->toGlyph('fa-envelope.glyph');
$expected = "<i class='fa fa-envelope' ><!-- --></i> ";
$expected = "<i class='fa fa-envelope' ></i> ";
$this->assertEquals($expected,$result);
$this->tp->setFontAwesome(5);
$result = $this->tp->toGlyph('fa-mailchimp');
$expected = "<i class='fab fa-mailchimp' ><!-- --></i> ";
$expected = "<i class='fab fa-mailchimp' ></i> ";
$this->assertEquals($expected, $result);
$this->tp->setFontAwesome(4);
$result = $this->tp->toGlyph('fab-mailchimp'); // spefific call
$expected = "<i class='fab fa-mailchimp' ><!-- --></i> ";
$expected = "<i class='fab fa-mailchimp' ></i> ";
$this->assertEquals($expected, $result);
$result = $this->tp->toGlyph('fas-camera'); // spefific call
$this->assertSame( "<i class='fas fa-camera' ><!-- --></i> ", $result);
$this->assertSame( "<i class='fas fa-camera' ></i> ", $result);
// test core, shims and old identifiers with FontAwesome 5 installed.
$this->tp->setFontAwesome(5);
@@ -2060,17 +2060,17 @@ while(&#036;row = &#036;sql-&gt;fetch())
$tests = array(
'e-database-16' => "<i class='S16 e-database-16'></i>",
'e-database-32' => "<i class='S32 e-database-32'></i>",
'fa-sun-o' => "<i class='far fa-sun' ><!-- --></i> ",
'fa-comments-o' => "<i class='far fa-comments' ><!-- --></i> ",
'fa-file-text-o' => "<i class='far fa-file-alt' ><!-- --></i> ",
'fa-bank' => "<i class='fa fa-university' ><!-- --></i> ",
'fa-warning' => "<i class='fa fa-exclamation-triangle' ><!-- --></i> ",
'glyphicon-star' => "<i class='fas fa-star' ><!-- --></i> ",
'icon-star' => "<i class='fas fa-star' ><!-- --></i> ",
'floppy-disk' => "<i class='glyphicon glyphicon-floppy-disk' ><!-- --></i> ",
'icon-user' => "<i class='fas fa-user' ><!-- --></i> ",
'user' => "<i class='fas fa-user' ><!-- --></i> ",
'flag' => "<i class='fas fa-flag' ><!-- --></i> ",
'fa-sun-o' => "<i class='far fa-sun' ></i> ",
'fa-comments-o' => "<i class='far fa-comments' ></i> ",
'fa-file-text-o' => "<i class='far fa-file-alt' ></i> ",
'fa-bank' => "<i class='fa fa-university' ></i> ",
'fa-warning' => "<i class='fa fa-exclamation-triangle' ></i> ",
'glyphicon-star' => "<i class='fas fa-star' ></i> ",
'icon-star' => "<i class='fas fa-star' ></i> ",
'floppy-disk' => "<i class='glyphicon glyphicon-floppy-disk' ></i> ",
'icon-user' => "<i class='fas fa-user' ></i> ",
'user' => "<i class='fas fa-user' ></i> ",
'flag' => "<i class='fas fa-flag' ></i> ",
'fa-' => null,
);
@@ -2088,17 +2088,17 @@ while(&#036;row = &#036;sql-&gt;fetch())
$tests = array(
'e-database-16' => "<i class='S16 e-database-16'></i>",
'e-database-32' => "<i class='S32 e-database-32'></i>",
'fa-sun-o' => "<i class='fa fa-sun-o' ><!-- --></i> ",
'fa-comments-o' => "<i class='fa fa-comments-o' ><!-- --></i> ",
'fa-file-text-o' => "<i class='fa fa-file-text-o' ><!-- --></i> ",
'fa-bank' => "<i class='fa fa-bank' ><!-- --></i> ",
'fa-warning' => "<i class='fa fa-warning' ><!-- --></i> ",
'glyphicon-star' => "<i class='fa fa-star' ><!-- --></i> ",
'icon-star' => "<i class='fa fa-star' ><!-- --></i> ",
'floppy-disk' => "<i class='glyphicon glyphicon-floppy-disk' ><!-- --></i> ",
'icon-user' => "<i class='fa fa-user' ><!-- --></i> ",
'user' => "<i class='glyphicon glyphicon-user' ><!-- --></i> ",
'flag' => "<i class='glyphicon glyphicon-flag' ><!-- --></i> ",
'fa-sun-o' => "<i class='fa fa-sun-o' ></i> ",
'fa-comments-o' => "<i class='fa fa-comments-o' ></i> ",
'fa-file-text-o' => "<i class='fa fa-file-text-o' ></i> ",
'fa-bank' => "<i class='fa fa-bank' ></i> ",
'fa-warning' => "<i class='fa fa-warning' ></i> ",
'glyphicon-star' => "<i class='fa fa-star' ></i> ",
'icon-star' => "<i class='fa fa-star' ></i> ",
'floppy-disk' => "<i class='glyphicon glyphicon-floppy-disk' ></i> ",
'icon-user' => "<i class='fa fa-user' ></i> ",
'user' => "<i class='glyphicon glyphicon-user' ></i> ",
'flag' => "<i class='glyphicon glyphicon-flag' ></i> ",
'fa-' => null,
);
@@ -2118,7 +2118,7 @@ while(&#036;row = &#036;sql-&gt;fetch())
{
$this->tp->setFontAwesome(5);
$result = $this->tp->toGlyph('fa-paypal.glyph');
$this->assertSame("<i class='fab fa-paypal' ><!-- --></i> ", $result);
$this->assertSame("<i class='fab fa-paypal' ></i> ", $result);
}
/*
public function testToBadge()
@@ -2448,7 +2448,7 @@ Your browser does not support the audio tag.
// -----
$result = $tp->makeClickable($email, 'email', array('sub' => 'fa-envelope.glyph'));
$this->assertStringContainsString("fa-envelope' ><!-- --></i></a>", $result);
$this->assertStringContainsString("fa-envelope' ></i></a>", $result);
// links standard.
$tests = array(

View File

@@ -513,7 +513,7 @@ class e_parse_shortcodeTest extends \Codeception\Test\Unit
'=extended' => '<!-- bbcode-html-start --><p><strong>Extended Body</strong></p><!-- bbcode-html-end -->',
),
'newscommentlink' => array(
': class=me' => "<a title='0 Comments' class='e-tip me' href='".e107::url('news/view/item', ['news_id'=>1, 'news_sef'=>'welcome-to-e107-me-again-x'])."'><i class='fas fa-comment' ><!-- --></i></a>"
': class=me' => "<a title='0 Comments' class='e-tip me' href='".e107::url('news/view/item', ['news_id'=>1, 'news_sef'=>'welcome-to-e107-me-again-x'])."'><i class='fas fa-comment' ></i></a>"
),
@@ -1726,7 +1726,7 @@ class e_parse_shortcodeTest extends \Codeception\Test\Unit
{
$tp = e107::getParser();
$result = $tp->parseTemplate('{GLYPH=fa-user}');
$this->assertSame("<i class='fas fa-user' ><!-- --></i>", $result);
$this->assertSame("<i class='fas fa-user' ></i>", $result);
}

View File

@@ -86,7 +86,7 @@ class e_themeTest extends \Codeception\Test\Unit
'bootstrap.editable' =>
array(
'name' => 'bootstrap.editable',
'version' => '',
// 'version' => '',
),
)
),
@@ -108,7 +108,7 @@ class e_themeTest extends \Codeception\Test\Unit
'bootstrap.editable' =>
array(
'name' => 'bootstrap.editable',
'version' => '',
// 'version' => '',
),
)
),
@@ -256,14 +256,15 @@ class e_themeTest extends \Codeception\Test\Unit
$expected = array(
0 =>
array(
'js' =>
array(
0 => '{e_WEB}lib/bootstrap/3/js/bootstrap.min.js',
),
'css' =>
array(
0 => '{e_WEB}lib/bootstrap/3/css/bootstrap.min.css',
),
'js' =>
array(
0 => '{e_WEB}lib/bootstrap/3/js/bootstrap.min.js',
),
),
1 =>
array(
@@ -272,6 +273,7 @@ class e_themeTest extends \Codeception\Test\Unit
0 => '{e_WEB}lib/font-awesome/5/css/all.min.css',
1 => '{e_WEB}lib/font-awesome/5/css/v4-shims.min.css',
),
),
);
@@ -283,14 +285,15 @@ class e_themeTest extends \Codeception\Test\Unit
$expected = array(
0 =>
array(
'js' =>
array(
0 => '{e_WEB}lib/bootstrap/3/js/bootstrap.min.js',
),
'css' =>
array(
0 => '{e_WEB}lib/bootstrap/3/css/bootstrap.min.css',
),
'js' =>
array(
0 => '{e_WEB}lib/bootstrap/3/js/bootstrap.min.js',
),
),
1 =>
array(
@@ -299,6 +302,7 @@ class e_themeTest extends \Codeception\Test\Unit
0 => '{e_WEB}lib/font-awesome/5/css/all.min.css',
1 => '{e_WEB}lib/font-awesome/5/css/v4-shims.min.css',
),
),
);
@@ -315,6 +319,42 @@ class e_themeTest extends \Codeception\Test\Unit
// $result = e107::getTheme('bootstrap5')->getThemeFiles('css', 'wysiwyg');
/** Expecting bootstrap 5 files fontawesome 5 (js only) */
$expected = array (
0 =>
array (
'js' =>
array (
0 => '{e_WEB}lib/bootstrap/5/js/bootstrap.bundle.min.js',
),
'css' =>
array (
0 => '{e_WEB}lib/bootstrap/5/css/bootstrap.min.css',
),
),
1 =>
array (
'js' =>
array (
0 => '{e_WEB}lib/font-awesome/5/js/all.min.js',
1 => '{e_WEB}lib/font-awesome/5/js/v4-shims.min.js',
),
),
2 =>
array (
'css' =>
array (
0 => '{e_WEB}lib/animate.css/animate.min.css',
),
),
);
$result = e107::getTheme('bootstrap5')->getThemeFiles('library', 'front');
$this->assertSame($expected, $result);
}
@@ -337,6 +377,11 @@ class e_themeTest extends \Codeception\Test\Unit
'scope' => 'front',
'expected' => ['bootstrap', 'fontawesome']
),
3 => array(
'theme' => 'bootstrap5',
'scope' => 'front',
'expected' => ['bootstrap5', 'fontawesome5', 'animate.css']
),
);
@@ -374,7 +419,7 @@ class e_themeTest extends \Codeception\Test\Unit
2 =>
array(
'name' => 'bootstrap.editable',
'version' => '',
// 'version' => '',
'scope' => 'admin',
),
)
@@ -398,7 +443,7 @@ class e_themeTest extends \Codeception\Test\Unit
2 =>
array(
'name' => 'bootstrap.editable',
'version' => '',
// 'version' => '',
'scope' => 'admin',
),
)
@@ -579,7 +624,7 @@ class e_themeTest extends \Codeception\Test\Unit
2 =>
array (
'name' => 'bootstrap.editable',
'version' => '',
// 'version' => '',
'scope' => 'admin',
),
)
@@ -598,10 +643,11 @@ class e_themeTest extends \Codeception\Test\Unit
'name' => 'fontawesome',
'version' => '5',
'scope' => 'front',
'files' => 'js',
),
2 => array (
'name' => 'animate.css',
'version' => '',
// 'version' => '',
'scope' => 'front',
)
),

View File

@@ -132,12 +132,9 @@
{
}
*/
public function testParse_theme_xml()
{
}
/*
public function testThemeUpload()
{