Serve Google Fonts locally
authorTim Düsterhus <duesterhus@woltlab.com>
Wed, 15 Jul 2020 09:29:44 +0000 (11:29 +0200)
committerTim Düsterhus <duesterhus@woltlab.com>
Wed, 15 Jul 2020 10:17:34 +0000 (12:17 +0200)
see #3394

com.woltlab.wcf/package.xml
com.woltlab.wcf/templates/headInclude.tpl
wcfsetup/install/files/acp/templates/styleAdd.tpl
wcfsetup/install/files/lib/acp/form/StyleAddForm.class.php
wcfsetup/install/files/lib/system/style/StyleCompiler.class.php
wcfsetup/install/lang/de.xml
wcfsetup/install/lang/en.xml
wcfsetup/setup/db/install.sql

index c149ef0066190201aecb09eae317f9ed66e63aa5..dec2c8c9bdcce2354c47c7dc5085451fe7351592 100644 (file)
@@ -52,6 +52,7 @@
 
        <instructions type="update" fromversion="5.2.*">
                <!-- Delete wcfsetup/install/files/lib/form/MailForm.class.php during the upgrade to make it 100% non-functional. -->
+               <!-- Remove useGoogleFont style variable. -->
        </instructions>
 
        <instructions type="update" fromversion="3.1.*">
index 51a29c2ebcd0c590b03b6c52a323a2b3ff4d2c98..f54caa9768120fe4600666513cb453503dd05702 100644 (file)
@@ -6,9 +6,6 @@
 {event name='metaTags'}
 
 <!-- Stylesheets -->
-{if $__wcf->getStyleHandler()->getStyle()->getVariable('useGoogleFont')}
-       <link href='//fonts.googleapis.com/css?family={$__wcf->getStyleHandler()->getStyle()->getVariable('wcfFontFamilyGoogle')|urlencode}:400,300,600' rel='stylesheet' type='text/css'>
-{/if}
 {@$__wcf->getStyleHandler()->getStylesheet()}
 {event name='stylesheets'}
 
index a4778a18c7b10c89cfe6e89f4552eec505c9a06c..fc5cea273a912b378430a2c363c6f4d46c6531e2 100644 (file)
                new AcpUiStyleImageUpload({if $action == 'add'}0{else}{@$style->styleID}{/if}, '{$tmpHash}', false);
                new AcpUiStyleImageUpload({if $action == 'add'}0{else}{@$style->styleID}{/if}, '{$tmpHash}', true);
                
-               new UiToggleInput('input[name="useGoogleFont"]', {
-                       show: ['#wcfFontFamilyGoogleContainer']
-               });
-               
                {if $action === 'edit'}
                        new AcpUiStyleFaviconUpload({@$style->styleID});
                        
                                        </dd>
                                </dl>
                                
-                               <dl>
-                                       <dt></dt>
-                                       <dd><label>
-                                               <input type="checkbox" id="useGoogleFont" name="useGoogleFont" value="1"{if !$variables[useGoogleFont]|empty} checked{/if}>
-                                               <span>{lang}wcf.acp.style.globals.useGoogleFont{/lang}</span>
-                                       </label></dd>
-                               </dl>
                                <dl id="wcfFontFamilyGoogleContainer"{if $errorField == 'wcfFontFamilyGoogle'} class="formError"{/if}>
                                        <dt><label for="wcfFontFamilyGoogle">{lang}wcf.acp.style.globals.fontFamilyGoogle{/lang}</label></dt>
                                        <dd>
index de23403372af297ef26a22294c077bc9e5570e1e..96488ae62d565703e180728167ba32d525667085 100644 (file)
@@ -275,7 +275,6 @@ class StyleAddForm extends AbstractForm {
                        }
                }
                $this->variables['useFluidLayout'] = isset($_POST['useFluidLayout']) ? 1 : 0;
-               $this->variables['useGoogleFont'] = isset($_POST['useGoogleFont']) ? 1 : 0;
                
                // style data
                if (isset($_POST['authorName'])) $this->authorName = StringUtil::trim($_POST['authorName']);
@@ -574,7 +573,6 @@ class StyleAddForm extends AbstractForm {
                        'pageLogoHeight',
                        'pageLogoMobile',
                        'useFluidLayout',
-                       'useGoogleFont',
                        'wcfFontFamilyGoogle',
                        'wcfFontFamilyFallback'
                ];
index 48f19613379cad1d4bc05531bd0a6b4f2bffa923..534d696a9b1d3f38a8c84f307fdd3229ce43280c 100644 (file)
@@ -274,6 +274,14 @@ class StyleCompiler extends SingletonFactory {
                        $content .= $this->prepareFile($mixin);
                }
                
+               // add google fonts
+               if (!empty($variables['wcfFontFamilyGoogle'])) {
+                       $cssFile = FontManager::getInstance()->getCssFilename(substr($variables['wcfFontFamilyGoogle'], 1, -1));
+                       if (is_readable($cssFile)) {
+                               $content .= file_get_contents($cssFile);
+                       }
+               }
+               
                return $content;
        }
        
index 7f735aabc84fc9f4daf5aec9c2b3c057d5d1fb4c..09cf35b7fc8234d9d8c5d4c23461501ac3479bb9 100644 (file)
@@ -2947,7 +2947,6 @@ Kein Abschnitt darf leer sein und alle Abschnitten dürfen nur folgende Zeichen
                <item name="wcf.acp.style.globals.fontSizeHeadline"><![CDATA[Schriftgröße (Überschrift)]]></item>
                <item name="wcf.acp.style.globals.fontSizeSection"><![CDATA[Schriftgröße (Sektions-Überschrift)]]></item>
                <item name="wcf.acp.style.globals.fontSizeTitle"><![CDATA[Schriftgröße (Seiten-Titel)]]></item>
-               <item name="wcf.acp.style.globals.useGoogleFont"><![CDATA[Google-Schriftart aktivieren]]></item>
                <item name="wcf.acp.style.globals.fontFamilyGoogle"><![CDATA[Schriftart]]></item>
                <item name="wcf.acp.style.globals.fontFamilyGoogle.description"><![CDATA[Die angegebene Schriftart wird beim Speichern des Stils heruntergeladen und anschließend den Benutzern anschließend ohne externe Verbindungen als Webfont zur Verfügung gestellt.]]></item>
                <item name="wcf.acp.style.globals.fontFamilyGoogle.error.downloadFailed"><![CDATA[Der Download der Schriftart ist fehlgeschlagen.]]></item>
index 00edddeb3bcb8662a382fd748e22bc3cd871b8de..f87eec7a04c3ad4f0a7ef112b08388c6b0b4d9a3 100644 (file)
@@ -2875,7 +2875,6 @@ If you have <strong>already bought the licenses for the listed apps</strong>, th
                <item name="wcf.acp.style.globals.fontSizeHeadline"><![CDATA[Font Size (Headline)]]></item>
                <item name="wcf.acp.style.globals.fontSizeSection"><![CDATA[Font Size (Section)]]></item>
                <item name="wcf.acp.style.globals.fontSizeTitle"><![CDATA[Font Size (Page Title)]]></item>
-               <item name="wcf.acp.style.globals.useGoogleFont"><![CDATA[Use Google font face]]></item>
                <item name="wcf.acp.style.globals.fontFamilyGoogle"><![CDATA[Font Face]]></item>
                <item name="wcf.acp.style.globals.fontFamilyGoogle.description"><![CDATA[The given font face will be downloaded when saving the style and afterwards will be delivered as a web font without connecting to external services.]]></item>
                <item name="wcf.acp.style.globals.fontFamilyGoogle.error.downloadFailed"><![CDATA[Downloading the given font face failed.]]></item>
index 77d05ecdc790ebfa9541e3c1148cc8682411df87..56a4a06e11b1ed7a871929d3b9c459ff22df4c1a 100644 (file)
@@ -2263,7 +2263,6 @@ INSERT INTO wcf1_style_variable (variableName, defaultValue) VALUES ('pageLogoWi
 INSERT INTO wcf1_style_variable (variableName, defaultValue) VALUES ('pageLogoHeight', '40');
 INSERT INTO wcf1_style_variable (variableName, defaultValue) VALUES ('pageLogoMobile', '');
 INSERT INTO wcf1_style_variable (variableName, defaultValue) VALUES ('useFluidLayout', '1');
-INSERT INTO wcf1_style_variable (variableName, defaultValue) VALUES ('useGoogleFont', '1');
 INSERT INTO wcf1_style_variable (variableName, defaultValue) VALUES ('wcfButtonBackground', 'rgba(207, 216, 220, 1)');
 INSERT INTO wcf1_style_variable (variableName, defaultValue) VALUES ('wcfButtonBackgroundActive', 'rgba(120, 144, 156, 1)');
 INSERT INTO wcf1_style_variable (variableName, defaultValue) VALUES ('wcfButtonDisabledBackground', 'rgba(223, 223, 223, 1)');