GithubHelp home page GithubHelp logo

cmb69 / fa_xh Goto Github PK

View Code? Open in Web Editor NEW
3.0 4.0 4.0 1.5 MB

Font Awesome for CMSimple_XH

License: GNU General Public License v3.0

PHP 29.43% CSS 0.17% HTML 47.76% JavaScript 22.64%
cmsimple-xh font-awesome

fa_xh's Introduction

Fa_XH

Fa_XH provides Font Awesome for CMSimple_XH templates, plugins and content. The plugin has been created for similar reasons as the jQuery4CMSimple plugin, namely to avoid clashes when Font Awesome is used by multiple components. For instance, a template may include a certain Font Awesome version, but a plugin another one. If all components rely on Fa_XH, all will use the same version.

Furthermore Fa_XH delivers editor plugins to ease the use of Font Awesome icons in the content, if this is desired. Currently, TinyMCE 4 and CKEditor are supported.

Table of Contents

Requirements

Fa_XH is a plugin for CMSimple_XH ≥ 1.7.0. It requires PHP ≥ 5.3.0.

Download

The lastest release is available for download on Github.

Installation

The installation is done as with many other CMSimple_XH plugins. See the CMSimple_XH wiki for further details.

  1. Backup the data on your server.
  2. Unzip the distribution on your computer.
  3. Upload the whole directory fa/ to your server into the plugins/ directory of CMSimple_XH.
  4. Set write permissions for the subdirectories config/, css/ and languages/.
  5. Navigate to PluginsFa in the back-end to check if all requirements are fulfilled.

Settings

The configuration of the plugin is done as with many other CMSimple_XH plugins in the back-end of the website. Select PluginsFa.

You can change the default settings of Fa_XH under Config. Hints for the options will be displayed when hovering over the help icon with your mouse.

Localization is done under Language. You can translate the character strings to your own language if there is no appropriate language file available, or customize them according to your needs.

The look of Fa_XH can be customized under Stylesheet.

Usage

End Users

If you want to use Font Awesome icons in the content, simply enable the configuration option RequireAuto.

TinyMCE 4

You need a recent version of TinyMCE 4 to use the fontawesome plugin, in which case TinyMCE 4 loads the plugin automatically, if the fontawesome init is chosen in its configuration.

Use the new toolbar button Font Awesome to select and insert the desired Font Awesome icon.

The fontawesome plugin for TinyMCE 4 supports only icons marked up as <span>. Icons inserted in the HTML source code view with the more common <i> will be removed!

TinyMCE 5

You need a recent version of TinyMCE 5 to use the fontawesome plugin, in which case TinyMCE 5 loads the plugin automatically, if the chosen init supports it in its configuration.

Use ToolsFont Awesome to select and insert the desired Font Awesome icon.

The fontawesome plugin for TinyMCE 5 supports only icons marked up as <span>. Icons inserted in the HTML source code view with the more common <i> will be removed!

CKEditor

You need at least CKEditor 2.2 to use the fontawesome plugin, in which case CKEditor loads the plugin automatically.

Use the toolbar button Insert Font Awesome to select, manipulate and insert the desired Font Awesome icon. Double-click an already inserted icon to edit it.

The fontawesome plugin for CKEditor supports only icons marked up as <span>. Icons inserted in the HTML source code view with the more common <i> will be removed!

Template Designers

If a template wants to use Font Awesome, you should document that Fa_XH has to be installed, and you have to require Font Awesome early in the template (that is before <?php echo head()?>:

<?php fa_require()?>

If you want to cater to users who do not read the documentation, you can check whether the function is available, and emit an error message otherwise:

<?php
if (function_exists('fa_require')) {
    fa_require();
} else {
    die('This template requires the Fa_XH plugin. See the documentation for details.');
}
?>

Plugin Developers

If a plugins wants to use Font Awesome, you should document that Fa_XH has to be installed, and you have to require Font Awesome before you are going to actually use it. Simply calling fa_require() is not guaranteed to work when called from a plugin, as the function may not have been defined, so you have to execute the RequireCommand directly:

<?php
$command = new Fa\RequireCommand;
$command->execute();
?>

If your plugin requires PHP 5.4.0 or higher anyway, you can shorten:

<?php (new Fa\RequireCommand)->execute()?>

To check whether Fa_XH is installed:

<?php $fa_installed = class_exists('Fa\\RequireCommand')?>

Cheatsheet

See Font Awesome Cheatsheet.

Limitations

The TinyMCE 4 Font Awesome plugin requires a contempary browser; IE ≤ 8 is not supported.

TinyMCE 4 has a bug regarding block level elements which contain only other elements, but no actual content. So adding only a Font Awesome icon to an otherwise empty paragraph would not retain the icon. The TinyMCE 4 Font Awesome plugin has a workaround for this issue (namely to also insert a non-breaking space), but importing content from another editor which does not implement this workaround, is not catered to, so you may loose some icons. It is recommended to stick with the same editor, anyway, so you can ignore this issue.

Troubleshooting

Report bugs and ask for support either on Github or in the CMSimple_XH Forum.

License

Fa_XH is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

Fa_XH is distributed in the hope that it will be useful, but without any warranty; without even the implied warranty of merchantibility or fitness for a particular purpose. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with Fa_XH. If not, see https://www.gnu.org/licenses/.

© 2017-2021 Christoph M. Becker

Credits

This plugin is powered by Font Awesome by Dave Gandy. Many thanks for making this great iconic font and CSS toolkit available under a GPL friendly license.

This plugin contains an adapted version of the TinyMCE-FontAwesome-Plugin by josh18. Thanks for publishing this TinyMCE plugin under MIT license.

This plugin contains an updated version of the Font Awesome plugin for CKEditor by Michael Janea. Thanks for publishing this CKEDitor plugin under GPL.

Fa_XH has been inspired by frase. Many thanks!

Many thanks to the community at the CMSimple_XH forum for tips, suggestions and testing. Especially, I like to thank lck and frase for early testing and feedback, manu for helping with the TinyMCE 4 plugin, and Holger for helping with the CKEditor plugin.

And last but not least many thanks to Peter Harteg, the “father” of CMSimple, and all developers of CMSimple_XH without whom this amazing CMS would not exist.

fa_xh's People

Contributors

cmb69 avatar manu37 avatar olape-git avatar tn03 avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

fa_xh's Issues

fontawesome.min.css not found

TinyMCE 4 reports that fontawesome.min.css is not found, if the fontawesome plugin is enabled. Other than that everything works as expected, though.

Don't use short open tags

The info.php view is shipped with short open tags which are not necessarily available on PHP 5.3.

Translate to German

At least the German localization should be available, and it would be nice to have a German user manual, too.

Installation instructions are misleading

The installation instructions regarding TinyMCE 4 state:

replace all occurances of %CMSIMPLE_ROOT% with the absolute path of the CMSimple_XH installation folder.

That suggests that the filesystem path of the CMSimple_XH installation is referred to, what is also supported by the wording of the following examples. However, this is about the URL path, not the filesystem path.

Early plugins can't call fa_link()

fa_link() is defined in index.php, so plugins which are loaded earlier may not be able to call the function. It might be best to make the function a static member of a class, and rely on autoloading.

init_fontawesome.js should be ready to use for "normal" installations

The TinyMCE integration requires to edit init_fontawesome.js, but that might be tough to get right for unexperienced webmasters. However, those are likely to have installed CMSimple_XH in the web root anyway, so it might be best to ship a init_fontawesome.js which already caters to this, and to require modifications only for those who have installed CMSimple_XH in a subfolder.

Optionally load from CDN

Delivering Font Awesome by a CDN clearly has advantages, so we should offer this feature. However, CDNs also have disadvantages, and it seems best to leave the choice to the admin. We have to decide what shall be the default, however. Hm…

Anyhow, see https://cdnjs.com/libraries/font-awesome/ for suitable CDN URLs.

FontAwesome icon not shown when using CDN variant

When using CDN version of TinyMCE, tinymce.baseURL becomes CDN(ex.http://cdnjs.cloudflare.com/...)
If use fontawesome/fontawesome.png
Now(1.0rc2)

    editor.addButton('fontawesome', {
        image: tinymce.baseURL + '/../../fa/editors/tinymce4/fontawesome/fontawesome.png',

to

    editor.addButton('fontawesome', {
//        image: tinymce.baseURL + '/../../fa/editors/tinymce4/fontawesome/fontawesome.png',
        image: url + '/fontawesome.png',

and

    editor.addMenuItem('fontawesome', {
        image: tinymce.baseURL + '/../../fa/editors/tinymce4/fontawesome/fontawesome.png',

to

    editor.addMenuItem('fontawesome', {
//        image: tinymce.baseURL + '/../../fa/editors/tinymce4/fontawesome/fontawesome.png',
        image: url + '/fontawesome.png',

But, already have web fonts, so do not use fontawesome.png I think that the following is good.

  editor.addButton('fontawesome', {
       icon: 'fort-awesome',
       tooltip: 'Font Awesome', // or translate('Font Awesome') ,and Add/Edit lang/*.js
       onclick: showDialog 
   });

   editor.addMenuItem('fontawesome', {
       icon: 'fort-awesome',
       text: 'Font Awesome', //or translate('Font Awesome') ,and Add/Edit lang/*.js
       onclick: showDialog,
       context: 'insert'
   });

and Add to editors/tinymce4/fontawesome/css/fontawesome.min.css

.mce-i-fort-awesome{font-family:FontAwesome !important;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;font-size:15px}.mce-i-fort-awesome:before{content:"\f286"}

Considering the future,
I think that it is good to keep the code of josh18.

    editor.addButton('fontawesome', {
        icon: 'flag',
        text: translate('Icons'),
        tooltip: translate('Icons'),
        onclick: showDialog
    });

    editor.addMenuItem('fontawesome', {
        icon: 'flag',
        text: translate('Icons'),
        onclick: showDialog,
        context: 'insert'
});

😓 I am sorry that I am not good at English.

missing language files

While setup the demo page I noticed the three missing language files of the most common C_XH languages: cs, da and sk. Just setup these langfiles (with en content?) might suffice. Otherwise Tiny4 throws an error message.

FA5 - problem

If i choose FA5 in the FA-plugin then Tinymce4 has no icons - difficult to patch - perhaps with a fontawesome - vplugin or else ?
I would personally drop FA4.7 and adapt the plugins

  • I nearly fixed it in my XC - Version by updating the \fa\editors\tinymce4\fontawesome with the v5 version of the josh18-master.
    But then FA4.7 isnt functioning (i dont need it).
    A switch with query what was selected in the FA plug-in is probaly a bit extravagant (but possible).

P.S. : Fixed it in my version (only FA5.15.4). Just the var iconList in line 10 of plugin.js has to be updated to Fa5.15.4 ( is in FA free web under /metadata ::: Just found a " solution for 15.4 " .
Or var icons = { --> so evtl. var iconlist = JSON.parse {}.... as in ckeditorfa.js

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.