mirror of
https://github.com/a2nt/silverstripe-webpack.git
synced 2024-10-22 17:05:31 +02:00
Minor updates
This commit is contained in:
parent
5678bb0aee
commit
3f199f5cec
@ -9,8 +9,8 @@ SilverStripe\Admin\LeftAndMain:
|
||||
|
||||
SilverStripe\SiteConfig\SiteConfig:
|
||||
extensions:
|
||||
- Site\Extensions\SiteConfigExtension
|
||||
- Site\Extensions\SocialExtension
|
||||
- Site\Extensions\SiteConfigExtension
|
||||
|
||||
SilverStripe\CMS\Model\SiteTree:
|
||||
extensions:
|
||||
@ -31,6 +31,8 @@ SilverStripe\Core\Injector\Injector:
|
||||
class: Site\Extensions\LostPasswordHandlerExtension
|
||||
Sheadawson\Linkable\Forms\EmbeddedObjectField:
|
||||
class: Site\Extensions\EmbedObjectField
|
||||
SilverStripe\Forms\CompositeField:
|
||||
class: Site\Extensions\CompositeFieldExtension
|
||||
|
||||
# User Forms module
|
||||
SilverStripe\UserForms\Form\UserForm:
|
||||
|
@ -1,11 +1,12 @@
|
||||
---
|
||||
Name: 'webapp-requirements'
|
||||
---
|
||||
Site\Templates\DeferedRequirements:
|
||||
Site\Templates\DeferredRequirements:
|
||||
nojquery: false
|
||||
nofontawesome: false
|
||||
version: false
|
||||
static_domain: false
|
||||
deferred: true
|
||||
|
||||
SilverStripe\View\Requirements:
|
||||
disable_flush_combined: true
|
||||
|
20
app/src/Extensions/CompositeFieldExtension.php
Normal file
20
app/src/Extensions/CompositeFieldExtension.php
Normal file
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Site\Extensions;
|
||||
|
||||
use SilverStripe\Blog\Forms\GridField\GridFieldConfigBlogPost;
|
||||
use SilverStripe\Core\Extension;
|
||||
use SilverStripe\Forms\CompositeField;
|
||||
use SilverStripe\Forms\FieldList;
|
||||
use SilverStripe\ORM\DataExtension;
|
||||
|
||||
class CompositeFieldExtension extends CompositeField
|
||||
{
|
||||
public function getAttributes()
|
||||
{
|
||||
$attrs = parent::getAttributes();
|
||||
unset($attrs['name'], $attrs['type'], $attrs['disabled'], $attrs['readonly'], $attrs['autofocus']);
|
||||
return $attrs;
|
||||
}
|
||||
}
|
@ -56,12 +56,12 @@ class SiteConfigExtension extends DataExtension
|
||||
'PrivacyPolicyID',
|
||||
'Privacy Policy Page',
|
||||
SiteTree::get()->map()->toArray()
|
||||
),
|
||||
)->setEmptyString('(Select one)'),
|
||||
DropdownField::create(
|
||||
'SitemapID',
|
||||
'Sitemap Page',
|
||||
SitemapPage::get()->map()->toArray()
|
||||
),
|
||||
)->setEmptyString('(Select one)'),
|
||||
]);
|
||||
|
||||
$mapTab = $fields->findOrMakeTab('Root.Maps');
|
||||
|
@ -107,7 +107,7 @@ class DeferredRequirements implements TemplateGlobalProvider
|
||||
public static function loadCSS($css): void
|
||||
{
|
||||
$external = (mb_strpos($css, '//') === 0 || mb_strpos($css, 'http') === 0);
|
||||
if ($external || (self::$deferred && !self::_webpackActive())) {
|
||||
if ($external || (self::getDeferred() && !self::_webpackActive())) {
|
||||
self::$css[] = $css;
|
||||
} else {
|
||||
WebpackTemplateProvider::loadCSS($css);
|
||||
@ -117,9 +117,9 @@ class DeferredRequirements implements TemplateGlobalProvider
|
||||
public static function loadJS($js): void
|
||||
{
|
||||
/*$external = (mb_substr($js, 0, 2) === '//' || mb_substr($js, 0, 4) === 'http');
|
||||
if ($external || (self::$defered && !self::_webpackActive())) {*/
|
||||
if ($external || (self::getDeferred() && !self::_webpackActive())) {*/
|
||||
// webpack supposed to load external JS
|
||||
if (self::$deferred && !self::_webpackActive()) {
|
||||
if (self::getDeferred() && !self::_webpackActive()) {
|
||||
self::$js[] = $js;
|
||||
} else {
|
||||
WebpackTemplateProvider::loadJS($js);
|
||||
@ -128,26 +128,34 @@ class DeferredRequirements implements TemplateGlobalProvider
|
||||
|
||||
protected static function _webpackActive(): bool
|
||||
{
|
||||
return class_exists('WebpackTemplateProvider') && WebpackTemplateProvider::isActive();
|
||||
return WebpackTemplateProvider::isActive();
|
||||
}
|
||||
|
||||
public static function setDeferred($bool): void
|
||||
{
|
||||
self::$deferred = $bool;
|
||||
Config::inst()->set(__CLASS__, 'deferred', $bool);
|
||||
}
|
||||
|
||||
public static function getDeferred(): bool
|
||||
{
|
||||
return self::config()['deferred'];
|
||||
}
|
||||
|
||||
public static function forTemplate(): string
|
||||
{
|
||||
$result = '';
|
||||
self::$css = array_unique(self::$css);
|
||||
foreach (self::$css as $css) {
|
||||
$result .= '<i class="defer-cs" data-load="' . self::get_url($css) . '"></i>';
|
||||
}
|
||||
|
||||
self::$js = array_unique(self::$js);
|
||||
foreach (self::$js as $js) {
|
||||
$result .= '<i class="defer-sc" data-load="' . self::get_url($js) . '"></i>';
|
||||
}
|
||||
|
||||
$result .=
|
||||
'<script type="text/javascript">function lsc(a,b){var c=document.createElement("script");c.type="text/javascript",c.readyState'
|
||||
'<script>function lsc(a,b){var c=document.createElement("script");c.readyState'
|
||||
.'?c.onreadystatechange=function(){"loaded"!=c.readyState&&"complete"!=c.readyState||(c.onreadystatechange=null,b())}'
|
||||
.':c.onload=function(){b()},c.src=a,document.getElementsByTagName("body")[0].appendChild(c)}'
|
||||
.'function lscd(a){a<s.length-1&&(a++,lsc(s.item(a).getAttribute("data-load"),function(){lscd(a)}))}'
|
||||
@ -178,7 +186,7 @@ class DeferredRequirements implements TemplateGlobalProvider
|
||||
//$static_domain = $config['static_domain'];
|
||||
//$static_domain = $static_domain ?: '';
|
||||
|
||||
return $url.$version;
|
||||
return WebpackTemplateProvider::toPublicPath($url.$version);
|
||||
}
|
||||
|
||||
public static function config(): array
|
||||
|
@ -65,7 +65,7 @@ class WebpackTemplateProvider implements TemplateGlobalProvider
|
||||
*/
|
||||
public static function loadJS($path): void
|
||||
{
|
||||
Requirements::javascript(self::_getPath($path));
|
||||
Requirements::javascript(self::_getPath($path), ['type' => '']);
|
||||
}
|
||||
|
||||
public static function projectName(): string
|
||||
@ -102,7 +102,7 @@ class WebpackTemplateProvider implements TemplateGlobalProvider
|
||||
{
|
||||
return self::isActive() && strpos($path, '//') === false ?
|
||||
self::_toDevServerPath($path) :
|
||||
self::_toPublicPath($path);
|
||||
self::toPublicPath($path);
|
||||
}
|
||||
|
||||
protected static function _toDevServerPath($path): string
|
||||
@ -117,11 +117,12 @@ class WebpackTemplateProvider implements TemplateGlobalProvider
|
||||
);
|
||||
}
|
||||
|
||||
protected static function _toPublicPath($path): string
|
||||
public static function toPublicPath($path): string
|
||||
{
|
||||
$cfg = self::config();
|
||||
return strpos($path, '//') === false ?
|
||||
Controller::join_links(
|
||||
RESOURCES_DIR,
|
||||
self::projectName(),
|
||||
$cfg['DIST'],
|
||||
(strpos($path, '.css') ? 'css' : 'js'),
|
||||
|
@ -3,7 +3,6 @@
|
||||
$Title
|
||||
</h1>
|
||||
|
||||
<div class="page-content">
|
||||
<% if $CurrentElement %>
|
||||
$CurrentElement
|
||||
<% else %>
|
||||
@ -11,16 +10,14 @@
|
||||
<% end_if %>
|
||||
|
||||
<% if $Form %>
|
||||
<div class="container">
|
||||
<div class="element $DefaultContainer">
|
||||
$Form
|
||||
</div>
|
||||
<% end_if %>
|
||||
|
||||
<% if $ExtraCode %>
|
||||
<div class="extra-code extra-code-page">
|
||||
<div class="element $DefaultContainer extra-code extra-code-page">
|
||||
$ExtraCode
|
||||
</div>
|
||||
<% end_if %>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
@ -4,7 +4,7 @@
|
||||
<div class="row">
|
||||
<div class="col-sm-6">
|
||||
<a href="/" class="logo2">
|
||||
<img src="$ResourcesURL('logo2.png')" alt="National Children's Alliance" />
|
||||
<img src="$ResourcesURL('logo2.png')" alt="{$Title}" />
|
||||
</a>
|
||||
|
||||
<div class="field">
|
||||
@ -28,12 +28,7 @@
|
||||
<% include Objects\SocialLinks %>
|
||||
</div>
|
||||
<div class="col-sm-6 text-right">
|
||||
<a href="/" target="_blank" class="external-link">
|
||||
<img src="$ResourcesURL('logo-alliance.png')" alt="National Children's Alliance" />
|
||||
</a>
|
||||
<a href="/" target="_blank" class="external-link">
|
||||
<img src="$ResourcesURL('logo-regional.png')" alt="National Children's Alliance" />
|
||||
</a>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -41,10 +36,7 @@
|
||||
|
||||
<div class="copyright footer">
|
||||
<div class="container">
|
||||
<div class="text-right hotline">
|
||||
Child Abuse Hotline <a href="calto:+18003423720" class="tel">1-800-342-3720</a>
|
||||
</div>
|
||||
<%-- div class="row">
|
||||
<div class="row">
|
||||
<div class="col-sm-6">
|
||||
Copyright © {$Top.CurrentTime.Format("Y")} {$Title} All rights reserved.
|
||||
</div>
|
||||
@ -56,7 +48,7 @@
|
||||
<a href="$Sitemap.Link">$Sitemap.Title</a>
|
||||
<% end_if %>
|
||||
</div>
|
||||
</div --%>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<% end_with %>
|
||||
|
16
app/templates/Includes/Last.ss
Normal file
16
app/templates/Includes/Last.ss
Normal file
@ -0,0 +1,16 @@
|
||||
<div class="hidden-print">
|
||||
$BetterNavigator
|
||||
</div>
|
||||
|
||||
<%-- Require CSS+JS from /public/resourses/[js,css]/[ClassName].[js,css] --%>
|
||||
$AutoRequirements($ClassName).RAW
|
||||
|
||||
<%-- Mapbox
|
||||
<script src="https://api.tiles.mapbox.com/mapbox-gl-js/v0.48.0/mapbox-gl.js"></script>
|
||||
<link href="https://api.tiles.mapbox.com/mapbox-gl-js/v0.48.0/mapbox-gl.css" rel="stylesheet" />--%>
|
||||
|
||||
<link href="https://fonts.googleapis.com/css?family=Open+Sans:400,400i,700,700i|Roboto:400,400i,700,700i&display=swap&subset=latin-ext" rel="stylesheet" />
|
||||
<%-- place extra requirements after this line --%>
|
||||
<div class="extra-code extra-code-site">
|
||||
$SiteConfig.ExtraCode
|
||||
</div>
|
@ -56,6 +56,6 @@ $MetaTags
|
||||
<meta content="yes" name="apple-mobile-web-app-capable" />
|
||||
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||
<meta name="viewport" content="width=device-width,user-scalable=no,initial-scale=1,maximum-scale=1" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
|
||||
|
||||
<% include Prestyling %>
|
||||
|
@ -4,9 +4,12 @@
|
||||
$Video.EmbedHTML.RAW
|
||||
</div>
|
||||
<% else %>
|
||||
<% if $Image %>
|
||||
<% if $Image || $ImageURL %>
|
||||
<span class="img">
|
||||
<img class="d-block w-100" src="$Image.Fill(1400,650).URL" alt="<% if $Headline %>$Headline<% end_if %>">
|
||||
<img class="d-block w-100"
|
||||
src="<% if $ImageURL %>$ImageURL<% else %>$Image.Fill(1400,650).URL<% end_if %>"
|
||||
alt="<% if $Headline %>$Headline.XML<% end_if %>"
|
||||
/>
|
||||
</span>
|
||||
<% end_if %>
|
||||
|
||||
@ -16,13 +19,18 @@
|
||||
<span class="sr-only">$Title</span>
|
||||
</a>
|
||||
<% end_with %>
|
||||
<% else_if $SlideLinkURL %>
|
||||
<a href="$SlideLinkURL" title="$Headline.XML" class="stretched-link">
|
||||
<span class="sr-only">$Headline</span>
|
||||
</a>
|
||||
<% end_if %>
|
||||
|
||||
<% end_if %>
|
||||
<% end_if %>
|
||||
|
||||
<% if $Content || $Headline || $Description || $SlideLinkID %>
|
||||
<div class="carousel-caption container">
|
||||
<div class="carousel-caption-container typography col-md-6">
|
||||
<div class="carousel-caption-container typography">
|
||||
<% if $Headline %><h2 class="carousel-title">$Headline</h2><% end_if %>
|
||||
|
||||
<% if $Content %>
|
||||
|
@ -2,8 +2,23 @@
|
||||
class="mapAPI-map-container"
|
||||
data-map-zoom="$MapZoom"
|
||||
data-key="$MapAPIKey"
|
||||
data-map-style="<% if $MapStyle %>$MapStyle<% else %>$SiteConfig.MapStyle<% end_if %>"
|
||||
data-geojson="$GeoJSON.XML"
|
||||
data-map-style="<% if $MapStyle %>$MapStyle.XML<% else %>$SiteConfig.MapStyle.XML<% end_if %>"
|
||||
<% if $GeoJSON %>data-geojson="$GeoJSON.XML"<% end_if %>
|
||||
<% if $ID %>
|
||||
data-id="$ID"
|
||||
<% end_if %>
|
||||
<% if $MapIcon %>
|
||||
data-icon="$Icon.XML"
|
||||
<% end_if %>
|
||||
<% if $MapTitle %>
|
||||
data-content="$MapTitle.XML"
|
||||
<% end_if %>
|
||||
<% if $Lat && $Lng %>
|
||||
data-lat="$Lat"
|
||||
data-lng="$Lng"
|
||||
<% else_if $Address %>
|
||||
data-address="$Address.XML"
|
||||
<% end_if %>
|
||||
data-fly-to-marker="true"
|
||||
data-fly-to-bounds="false"
|
||||
>
|
||||
|
@ -2,31 +2,31 @@
|
||||
<% if $Facebook %>
|
||||
<a href="$Facebook.URL" title="Facebook" target="_blank">
|
||||
<i class="fab fa-facebook"></i>
|
||||
<i class="d-none">Facebook</i>
|
||||
<i class="sr-only">Facebook</i>
|
||||
</a>
|
||||
<% end_if %>
|
||||
<% if $LinkedIn %>
|
||||
<a href="$LinkedIn.URL" title="LinkedIn" target="_blank">
|
||||
<i class="fab fa-linkedin"></i>
|
||||
<i class="d-none">LinkedIn</i>
|
||||
<i class="sr-only">LinkedIn</i>
|
||||
</a>
|
||||
<% end_if %>
|
||||
<% if $GooglePlus %>
|
||||
<a href="$GooglePlus.URL" title="Google+" target="_blank">
|
||||
<i class="fab fa-google-plus-g"></i>
|
||||
<i class="d-none">Google+</i>
|
||||
<i class="sr-only">Google+</i>
|
||||
</a>
|
||||
<% end_if %>
|
||||
<% if $Instagram %>
|
||||
<a href="$Instagram.URL" title="Instagram" target="_blank">
|
||||
<i class="fab fa-instagram"></i>
|
||||
<i class="d-none">Instagram</i>
|
||||
<i class="sr-only">Instagram</i>
|
||||
</a>
|
||||
<% end_if %>
|
||||
<% if $Twitter %>
|
||||
<a href="$Twitter.URL" title="Twitter" target="_blank">
|
||||
<i class="fab fa-twitter"></i>
|
||||
<i class="d-none">Twitter</i>
|
||||
<i class="sr-only">Twitter</i>
|
||||
</a>
|
||||
<% end_if %>
|
||||
</div>
|
||||
|
@ -43,21 +43,6 @@
|
||||
<% include Footer %>
|
||||
</footer>
|
||||
|
||||
<div class="hidden-print">
|
||||
$BetterNavigator
|
||||
</div>
|
||||
|
||||
<%-- Require CSS+JS from /public/resourses/[js,css]/[ClassName].[js,css] --%>
|
||||
$AutoRequirements($ClassName).RAW
|
||||
|
||||
<%-- Mapbox
|
||||
<script src="https://api.tiles.mapbox.com/mapbox-gl-js/v0.48.0/mapbox-gl.js"></script>
|
||||
<link href="https://api.tiles.mapbox.com/mapbox-gl-js/v0.48.0/mapbox-gl.css" rel="stylesheet" />--%>
|
||||
|
||||
<link href="https://fonts.googleapis.com/css?family=Open+Sans:400,400i,700,700i|Roboto:400,400i,700,700i&display=swap&subset=latin-ext" rel="stylesheet" />
|
||||
<%-- place extra requirements after this line --%>
|
||||
<div class="extra-code extra-code-site">
|
||||
$SiteConfig.ExtraCode
|
||||
</div>
|
||||
<% include Last %>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -58,11 +58,21 @@ let plugins = [
|
||||
//assetNameRegExp: /\.optimize\.css$/g,
|
||||
cssProcessor: require('cssnano'),
|
||||
cssProcessorPluginOptions: {
|
||||
preset: ['default', {
|
||||
preset: ['default'],
|
||||
},
|
||||
cssProcessorOptions: {
|
||||
zindex: true,
|
||||
cssDeclarationSorter: true,
|
||||
reduceIdents: false,
|
||||
mergeIdents: true,
|
||||
mergeRules: true,
|
||||
mergeLonghand: true,
|
||||
discardUnused: true,
|
||||
discardOverridden: true,
|
||||
discardDuplicates: true,
|
||||
discardComments: {
|
||||
removeAll: true
|
||||
}
|
||||
}],
|
||||
},
|
||||
},
|
||||
canPrint: true
|
||||
}),
|
||||
|
Loading…
Reference in New Issue
Block a user