SVG Template by Xon 2.6.2

XF 2.1 / 2.2 / 2.3 SVG Template by Xon 2.6.2

  • Auteur de la discussion Auteur de la discussion laurent68
  • Date de début Date de début

Add-on xenforo 2

Ressources et modules complémentaires pour XenForo 2

Styles xenforo 2

Styles / Thèmes et apparence pour xenforo 2

Templates xenforo 2

Codes pour modifier les templates sur xenforo 2

Section Premium

Add-on et Styles pour membre Premium
SVG Template by Xon 2.6.2

XF 2.1 / 2.2 / 2.3 SVG Template by Xon 2.6.2

  • Auteur de la discussion Auteur de la discussion laurent68
  • Date de début Date de début
Catégorie Catégorie Add-Ons
Titre du sujet Titre du sujet SVG Template by Xon 2.6.2
Auteur de la discussion Auteur de la discussion laurent68
Date de début Date de début
Réponses Réponses 21
Affichages Affichages 1 303
Réaction Réaction 0
Dernier message par Dernier message par laurent68

laurent68

Fondateur

Staff
fondateur
Réputation: 100%
Discussions
4 644
Messages
12 049
Solutions
81
J'aime
7 606
Points
198
Depending on configuration, this add-on requires webserver URL rewrite support!

SVG Template
Depending on configuration, this add-on requires webserver URL rewrite support!

Allows SVG (Scalable Vector Graphics) images to be stored as templates. This creates a new svg.php file in the XF root directory.

To generate a link to an SVG template (The template must have .svg at the end of the name!) ;

Code:
{{ getSvgUrl('tempate.svg') }}
Under Board information, if "Use Full Friendly URLs" (useFriendlyUrls) is set the URL generated is :
Code:
/data/svg/<style_id>/<langauge_id>/<style_last_modified>/<templateName.svg>
Otherwise
Code:
svg.php?svg=<templateName>&s=<style_id>&l=<langauge_id>&d=<style_last_modified>

Render to PNG
Rendering SVGs to PNGs requires external support, and depending on OS this may result in odd limitations or poor rendering.

php-imagick support
It is not recommended to use Imagick if it can be helped!

Ubuntu (using https://launchpad.net/~ondrej/+archive/ubuntu/php PPA);
Code:
sudo apt install php7.4-imagick libmagickcore-6.q16-3-extra
sudo systemctl restart php7.4-fpm
Note; some distro's require libmagickcore-6.q16-3-extra to be installed to enable SVG support.

Older versions of Imagick have poor SVG support, on top of Imagick's poor security reputation.

CLI support
This is a generic escape hatch to plug in arbitrary png conversion, using proc_open in php.

Configure Render using proc_open option with;
Code:
<CLI-binary> {destFile} {sourceFile}
{sourceFile} is the source SVG written as a temp file {destFile} is the destination PNG file as a temp file

Alternatively input/output can be done via pipes

Note; template names are only alpha-numeric strings, which is enforced by validation before the CLI option is called

resvg CLI support
Example using resvg, configure CLI command with;
Code:
/usr/local/bin/resvg --quiet {sourceFile} {destFile}
Precompiled binary
Pre-compiled linux x86_64 binary has been made available here. Compiled on CentOS 7, works on Ubuntu 18.04/20.04

Compiling
Compiling may bind to newer versions of glibc which can cause portability issues
Code:
curl https://sh.rustup.rs -sSf | sh
source $HOME/.cargo/env
cargo install resvg
cp ~/.cargo/bin/resvg /usr/local/bin/resvg
chmod +x /usr/local/bin/resvg
Inkscape CLI support
Note; use snap as otherwise it is likely to have too old an instance !
Code:
sudo snap install inkscape
Configure CLI PIPE command with;
Code:
inkscape --export-type=png -p
Features
Conditional rendering SVGs to PNG (for CSS/LESS)

An example of conditional CSS to use the png over the svg for mobile clients
Less:
.mod_interrupt--svg.mod_interrupt
{
    &--stop
    {
        &:before
        {
          content: url({{ getSvgUrl('sv_bbcode_modinterrupt_stop.svg') }}) !important;
        }
        <xf:if is="$xf.svg.as.png">
        .is-tablet &:before,
        .is-mobile &:before
        {
          content: url({{ getSvgUrlAs('sv_bbcode_modinterrupt_stop.svg', 'png') }}) !important;
        }
        </xf:if>
    }
}
Explicit usage in templates;
XML:
<xf:if is="$xf.svg.enabled">
    <xf:if is="$xf.svg.as.png and $xf.mobileDetect and $xf.mobileDetect.isMobile()">
        <img src="{{ getSvgUrlAs('example.svg', 'png') }}"/>
    <xf:else />
        <img src="{{ getSvgUrlAs('example.svg', 'svg') }}"/>
    </xf:if>
<xf:else />
    <i class="fa fa-stop" />
</xf:if>
XenForo 2 routing integration
While webserver rewrite rules are recommended, this add-on supports extending XenForo's routing system to provide zero-configuration support for SVG Templates

Nginx URL rewrite config
Code:
location ^~ /data/svg/ {
   access_log off;
   rewrite ^/data/svg/([^/]+)/([^/]+)/([^/]+)/([^\.]+\..*)$ /svg.php?svg=$4&s=$1&l=$2&d=$3$args last;
   return 403;
}
Apache URL rewrite config
Add the rule before the final index.php;
Code:
RewriteRule ^data/svg/([^/]+)/([^/]+)/([^/]+)/([^\.]+\..*)$ svg.php?svg=$4&s=$1&l=$2&d=$3 [B,NC,L,QSA]
ie, should look similar to;
Code:
    #    If you are having problems with the rewrite rules, remove the "#" from the
    #    line that begins "RewriteBase" below. You will also have to change the path
    #    of the rewrite to reflect the path to your XenForo installation.
    #RewriteBase /xenforo

    RewriteCond %{REQUEST_FILENAME} -f [OR]
    RewriteCond %{REQUEST_FILENAME} -l [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule ^.*$ - [NC,L]
    RewriteRule ^(data/|js/|styles/|install/|favicon\.ico|crossdomain\.xml|robots\.txt) - [NC,L]
    RewriteRule ^data/svg/([^/]+)/([^/]+)/([^/]+)/([^\.]+\..*)$ svg.php?svg=$4&s=$1&l=$2&d=$3 [B,NC,L,QSA]
    RewriteRule ^.*$ index.php [NC,L]

Télécharger V2.1.6 :
Vous devez répondre avant de pouvoir voir le contenu des données cachées.
Version 2.2.0 - Maintainance update :

Require php 7+
Require XenForo 2.1+
Conform XF2.2 support
Minor php 7.0/7.1 compatibility fix

Version 2.2.1 - Bugfix update : Fix "Support SVG url's in XF routing layer" option

Télécharger V2.2.1 :
Vous devez répondre avant de pouvoir voir le contenu des données cachées.
Version 2.2.2 : Minor code cleanup, avoid connecting to master redis instance to only connect to a replica instance on rendering cached output

Télécharger V2.2.2 :
Vous devez répondre avant de pouvoir voir le contenu des données cachées.
Version 2.3.0 - Feature update :

Add basic validation that an SVG template should render correctly
Add an optimization pass for SVG's. Prunes pruning whitespace and nodes/attributes known to be safe to remove. Includes minifying any inline css.
Support LESS/CSS in SVG's <style> element.
Add option "Render SVG's as PNG for mobile devices", this supports rewriting calls to getSvgUrl from .svg to .png
Requires Brower Detection v2.1.0+ add-on
Requires updating webserver URL rewrite urls to support PNGs
Caching requires explicitly defining a caching context with the name "sv-svg-img" or "css".
Supports Imagick or CLI executables as a back-end to render SVGs to PNGs.
Using Imagick is not recommended
Example using resvg, as a CLI-executable back-end;
/usr/local/bin/resvg --quiet {sourceFile} {destFile}
This requires compiling using Rust, or use the pre-compiled linux x86_64 binary here.
Compiling can be done with;

Code:
curl https://sh.rustup.rs -sSf | sh
source $HOME/.cargo/env
cargo install resvg
cp ~/.cargo/bin/resvg /usr/local/bin/resvg
chmod +x /usr/local/bin/resvg

Télécharger V2.3.0 :
Vous devez répondre avant de pouvoir voir le contenu des données cachées.
Version 2.3.2 - Bugfix update

Require Standard Lib by Xon v1.1.0+
Force usage of global functions so php can optimize them into special bytecode instead of function calls
Fix disabling generating png links if svg => png is not configured
Improve installer to report svg => svg conditions which can block usage
Use "canonical" URL before XF2.2.3 as "full" doesn't work as expected in all contexts

Version 2.3.3 - Maintenance update : Reject attempting to save an SVG template with no elements

Télécharger V2.3.3 :
Vous devez répondre avant de pouvoir voir le contenu des données cachées.
Version 2.3.4 - Maintenance update : Support getSvgUrlAs('tenplate.svg', 'png') in style properties

Télécharger V2.3.4 :
Vous devez répondre avant de pouvoir voir le contenu des données cachées.
Version 2.3.5 - Maintenance update :

Work-around for non-desirable caching behaviour when CloudFlare (or similar) is forced to cache svg.php output
Prevent polluting of caches if the time-stamp is in the future

Télécharger V2.3.5 :
Vous devez répondre avant de pouvoir voir le contenu des données cachées.
Version 2.4.1 - Maintenance update :

Require XenForo 2.2+
Require StandardLib v1.11.0+
Improve support for rendering templates in the mail & api contexts by correctly injecting template filters/functions into multiple rendering contexts
Compat fix when zlib output compression is enabled for PHP8.0.17+/PHP8.1.4+

Télécharger V2.4.1 :
Vous devez répondre avant de pouvoir voir le contenu des données cachées.
Version 2.4.2 - Bugfix update :

Fix "XFCP_TemplaterHelper not found" error when upgrading the StandardLib add-on via the GUI
If this has happened, upload the files for this add-on. Then rebuild StandardLib add-on, then run the updater this add-on.

Télécharger V2.4.2 :
Vous devez répondre avant de pouvoir voir le contenu des données cachées.
Version 2.4.3 - Bugfix update :

Fix issue using getSvgUrl/[getSvgUrlAs in style properties with a template without an extension would cause CSS to fail to render
Fix for race condition when creating temp files when encoding svg => png using resvg.
Update README.md to link to updated precompiled binary for resvg (v0.14.1 => v0.23.0)

Télécharger V2.4.3 :
Vous devez répondre avant de pouvoir voir le contenu des données cachées.
Version 2.4.4 - Maintenance update : Improve error messages when saving invalid SVGs as templates.

Télécharger V2.4.4 :
Vous devez répondre avant de pouvoir voir le contenu des données cachées.
Version 2.4.5 Bugfix update : Compatibility update with SV/StandardLib v1.14+, still compatible with SV/StandardLib v1.11+

Télécharger V2.4.5 :
Vous devez répondre avant de pouvoir voir le contenu des données cachées.
Version 2.4.6 Bugfix update :

- Fix template validation ran on the master style instead of the current selected style
- Fix for upcoming XF2.3 compatibility, as Doctrine Cache been documented as being removed.

Télécharger V2.4.6 :
Vous devez répondre avant de pouvoir voir le contenu des données cachées.
Version 2.4.8 - Bugfix update :

- Fix error running "xf:rebuild-master-data" when the exact template directory structure is missing and the SVG template is the first template compiled for that style.
- Fix possible compatibility issues with other add-ons extending SV/StandardLib's template helper code

Télécharger V2.4.8 :
Vous devez répondre avant de pouvoir voir le contenu des données cachées.
Version 2.4.9 - Bugfix update :
- Fix SVG template validation was broken which could result in preventing adding a language or style from working correctly (or rebuilding master data)

Télécharger V2.4.9 :
Vous devez répondre avant de pouvoir voir le contenu des données cachées.
Version 2.5.0 - Maintenance update :

This add-on is now avaliable on atelieraphelion.com
  • Require php 7.2+
  • Require StandardLib v1.18.0+
  • If using resvg support, recommend updating to v0.35.0.
    Pre-compiled linux x86_64 binary has been made available here.
    Compiled on CentOS 7, works on Ubuntu 18.04/20.04/22.04
  • Document using resvg v0.35.0+ with "CLI - Pipe" mode, which avoid temporary files when converting SVGs to PNGs
    Example using resvg v0.35.0+, configure CLI - Pipe command with;
Code:
/usr/local/bin/resvg --quiet --resources-dir=/tmp/ - -c
Télécharger V2.5.0 :
Vous devez répondre avant de pouvoir voir le contenu des données cachées.
Version 2.5.1 - Bugfix update :
- Fix internal server error being generated instead of a 404 when requesting an invalid svg.

Télécharger V2.5.1 :
Vous devez répondre avant de pouvoir voir le contenu des données cachées.
Version 2.5.2 - Bugfix update :
- Fix "[E_DEPRECATED] strlen(): Passing null to parameter #1 ($string) of type string is deprecated" when attempting to save a new template with an invalid name

Télécharger V2.5.2 :
Vous devez répondre avant de pouvoir voir le contenu des données cachées.
Version 2.6.0; XF2.3 Compatibility update
  • Requires StandardLib v1.19.0+
  • If installed, requires Redis Cache 2.17.0+
  • XF2.3 compatibility update
  • php 8.4 compatibility fix
Télécharger V2.6.0 :
Vous devez répondre avant de pouvoir voir le contenu des données cachées.
Version 2.6.1 - Bugfix update :
- Fix XF2.3 style variations support for getSvgUrl() in style properties

Télécharger V2.6.1 :
Vous devez répondre avant de pouvoir voir le contenu des données cachées.
Version 2.6.2 - Bugfix update : Provide a better error message when getSvgUrl is used to request a png of an svg when svg => png rendering isn't setup

Télécharger V2.6.2 :
Vous devez répondre avant de pouvoir voir le contenu des données cachées.
 
Dernière édition par un modérateur:
Ajout de la version 2.2.2 :)
 
Ajout de la version 2.3.0 :)
 
Ajout de la version 2.3.3 :)
 
Ajout de la version 2.3.4 :)
 
Ajout de la version 2.3.5 :)
 
Ajout de la version 2.4.1 :)
 
Ajout de la version 2.4.2 :)
 
Ajout de la version 2.4.3 :)
 
Ajout de la version 2.4.5 :)
 
Ajout de la version 2.4.6 :)
 
Ajout de la version 2.4.8 :)
 
Ajout de la version 2.4.9 :)
 
Ajout de la version 2.5.1 :)
 
Ajout de la version 2.5.2 :)
 
Ajout de la version 2.6.1 :)
 
Sujets similaires Les plus vues Voir plus
Retour
Haut Bas