Minor updates

This commit is contained in:
Tony Air 2019-12-18 03:43:28 +07:00
parent 5678bb0aee
commit 3f199f5cec
15 changed files with 130 additions and 75 deletions

View File

@ -9,8 +9,8 @@ SilverStripe\Admin\LeftAndMain:
SilverStripe\SiteConfig\SiteConfig: SilverStripe\SiteConfig\SiteConfig:
extensions: extensions:
- Site\Extensions\SiteConfigExtension
- Site\Extensions\SocialExtension - Site\Extensions\SocialExtension
- Site\Extensions\SiteConfigExtension
SilverStripe\CMS\Model\SiteTree: SilverStripe\CMS\Model\SiteTree:
extensions: extensions:
@ -31,6 +31,8 @@ SilverStripe\Core\Injector\Injector:
class: Site\Extensions\LostPasswordHandlerExtension class: Site\Extensions\LostPasswordHandlerExtension
Sheadawson\Linkable\Forms\EmbeddedObjectField: Sheadawson\Linkable\Forms\EmbeddedObjectField:
class: Site\Extensions\EmbedObjectField class: Site\Extensions\EmbedObjectField
SilverStripe\Forms\CompositeField:
class: Site\Extensions\CompositeFieldExtension
# User Forms module # User Forms module
SilverStripe\UserForms\Form\UserForm: SilverStripe\UserForms\Form\UserForm:

View File

@ -1,11 +1,12 @@
--- ---
Name: 'webapp-requirements' Name: 'webapp-requirements'
--- ---
Site\Templates\DeferedRequirements: Site\Templates\DeferredRequirements:
nojquery: false nojquery: false
nofontawesome: false nofontawesome: false
version: false version: false
static_domain: false static_domain: false
deferred: true
SilverStripe\View\Requirements: SilverStripe\View\Requirements:
disable_flush_combined: true disable_flush_combined: true

View 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;
}
}

View File

@ -56,12 +56,12 @@ class SiteConfigExtension extends DataExtension
'PrivacyPolicyID', 'PrivacyPolicyID',
'Privacy Policy Page', 'Privacy Policy Page',
SiteTree::get()->map()->toArray() SiteTree::get()->map()->toArray()
), )->setEmptyString('(Select one)'),
DropdownField::create( DropdownField::create(
'SitemapID', 'SitemapID',
'Sitemap Page', 'Sitemap Page',
SitemapPage::get()->map()->toArray() SitemapPage::get()->map()->toArray()
), )->setEmptyString('(Select one)'),
]); ]);
$mapTab = $fields->findOrMakeTab('Root.Maps'); $mapTab = $fields->findOrMakeTab('Root.Maps');

View File

@ -107,7 +107,7 @@ class DeferredRequirements implements TemplateGlobalProvider
public static function loadCSS($css): void public static function loadCSS($css): void
{ {
$external = (mb_strpos($css, '//') === 0 || mb_strpos($css, 'http') === 0); $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; self::$css[] = $css;
} else { } else {
WebpackTemplateProvider::loadCSS($css); WebpackTemplateProvider::loadCSS($css);
@ -117,9 +117,9 @@ class DeferredRequirements implements TemplateGlobalProvider
public static function loadJS($js): void public static function loadJS($js): void
{ {
/*$external = (mb_substr($js, 0, 2) === '//' || mb_substr($js, 0, 4) === 'http'); /*$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 // webpack supposed to load external JS
if (self::$deferred && !self::_webpackActive()) { if (self::getDeferred() && !self::_webpackActive()) {
self::$js[] = $js; self::$js[] = $js;
} else { } else {
WebpackTemplateProvider::loadJS($js); WebpackTemplateProvider::loadJS($js);
@ -128,26 +128,34 @@ class DeferredRequirements implements TemplateGlobalProvider
protected static function _webpackActive(): bool protected static function _webpackActive(): bool
{ {
return class_exists('WebpackTemplateProvider') && WebpackTemplateProvider::isActive(); return WebpackTemplateProvider::isActive();
} }
public static function setDeferred($bool): void 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 public static function forTemplate(): string
{ {
$result = ''; $result = '';
self::$css = array_unique(self::$css);
foreach (self::$css as $css) { foreach (self::$css as $css) {
$result .= '<i class="defer-cs" data-load="' . self::get_url($css) . '"></i>'; $result .= '<i class="defer-cs" data-load="' . self::get_url($css) . '"></i>';
} }
self::$js = array_unique(self::$js);
foreach (self::$js as $js) { foreach (self::$js as $js) {
$result .= '<i class="defer-sc" data-load="' . self::get_url($js) . '"></i>'; $result .= '<i class="defer-sc" data-load="' . self::get_url($js) . '"></i>';
} }
$result .= $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.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)}' .':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)}))}' .'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 = $config['static_domain'];
//$static_domain = $static_domain ?: ''; //$static_domain = $static_domain ?: '';
return $url.$version; return WebpackTemplateProvider::toPublicPath($url.$version);
} }
public static function config(): array public static function config(): array

View File

@ -65,7 +65,7 @@ class WebpackTemplateProvider implements TemplateGlobalProvider
*/ */
public static function loadJS($path): void public static function loadJS($path): void
{ {
Requirements::javascript(self::_getPath($path)); Requirements::javascript(self::_getPath($path), ['type' => '']);
} }
public static function projectName(): string public static function projectName(): string
@ -102,7 +102,7 @@ class WebpackTemplateProvider implements TemplateGlobalProvider
{ {
return self::isActive() && strpos($path, '//') === false ? return self::isActive() && strpos($path, '//') === false ?
self::_toDevServerPath($path) : self::_toDevServerPath($path) :
self::_toPublicPath($path); self::toPublicPath($path);
} }
protected static function _toDevServerPath($path): string 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(); $cfg = self::config();
return strpos($path, '//') === false ? return strpos($path, '//') === false ?
Controller::join_links( Controller::join_links(
RESOURCES_DIR,
self::projectName(), self::projectName(),
$cfg['DIST'], $cfg['DIST'],
(strpos($path, '.css') ? 'css' : 'js'), (strpos($path, '.css') ? 'css' : 'js'),

View File

@ -3,7 +3,6 @@
$Title $Title
</h1> </h1>
<div class="page-content">
<% if $CurrentElement %> <% if $CurrentElement %>
$CurrentElement $CurrentElement
<% else %> <% else %>
@ -11,16 +10,14 @@
<% end_if %> <% end_if %>
<% if $Form %> <% if $Form %>
<div class="container"> <div class="element $DefaultContainer">
$Form $Form
</div> </div>
<% end_if %> <% end_if %>
<% if $ExtraCode %> <% if $ExtraCode %>
<div class="extra-code extra-code-page"> <div class="element $DefaultContainer extra-code extra-code-page">
$ExtraCode $ExtraCode
</div> </div>
<% end_if %> <% end_if %>
</div> </div>
</div>

View File

@ -4,7 +4,7 @@
<div class="row"> <div class="row">
<div class="col-sm-6"> <div class="col-sm-6">
<a href="/" class="logo2"> <a href="/" class="logo2">
<img src="$ResourcesURL('logo2.png')" alt="National Children's Alliance" /> <img src="$ResourcesURL('logo2.png')" alt="{$Title}" />
</a> </a>
<div class="field"> <div class="field">
@ -28,12 +28,7 @@
<% include Objects\SocialLinks %> <% include Objects\SocialLinks %>
</div> </div>
<div class="col-sm-6 text-right"> <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> </div>
</div> </div>
@ -41,10 +36,7 @@
<div class="copyright footer"> <div class="copyright footer">
<div class="container"> <div class="container">
<div class="text-right hotline"> <div class="row">
Child Abuse Hotline <a href="calto:+18003423720" class="tel">1-800-342-3720</a>
</div>
<%-- div class="row">
<div class="col-sm-6"> <div class="col-sm-6">
Copyright &copy; {$Top.CurrentTime.Format("Y")} {$Title} All rights reserved. Copyright &copy; {$Top.CurrentTime.Format("Y")} {$Title} All rights reserved.
</div> </div>
@ -56,7 +48,7 @@
<a href="$Sitemap.Link">$Sitemap.Title</a> <a href="$Sitemap.Link">$Sitemap.Title</a>
<% end_if %> <% end_if %>
</div> </div>
</div --%> </div>
</div> </div>
</div> </div>
<% end_with %> <% end_with %>

View 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>

View File

@ -56,6 +56,6 @@ $MetaTags
<meta content="yes" name="apple-mobile-web-app-capable" /> <meta content="yes" name="apple-mobile-web-app-capable" />
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" /> <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" /> <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 %> <% include Prestyling %>

View File

@ -4,9 +4,12 @@
$Video.EmbedHTML.RAW $Video.EmbedHTML.RAW
</div> </div>
<% else %> <% else %>
<% if $Image %> <% if $Image || $ImageURL %>
<span class="img"> <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> </span>
<% end_if %> <% end_if %>
@ -16,13 +19,18 @@
<span class="sr-only">$Title</span> <span class="sr-only">$Title</span>
</a> </a>
<% end_with %> <% 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 %> <% end_if %>
<% end_if %> <% end_if %>
<% if $Content || $Headline || $Description || $SlideLinkID %> <% if $Content || $Headline || $Description || $SlideLinkID %>
<div class="carousel-caption container"> <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 $Headline %><h2 class="carousel-title">$Headline</h2><% end_if %>
<% if $Content %> <% if $Content %>

View File

@ -2,8 +2,23 @@
class="mapAPI-map-container" class="mapAPI-map-container"
data-map-zoom="$MapZoom" data-map-zoom="$MapZoom"
data-key="$MapAPIKey" data-key="$MapAPIKey"
data-map-style="<% if $MapStyle %>$MapStyle<% else %>$SiteConfig.MapStyle<% end_if %>" data-map-style="<% if $MapStyle %>$MapStyle.XML<% else %>$SiteConfig.MapStyle.XML<% end_if %>"
data-geojson="$GeoJSON.XML" <% 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-marker="true"
data-fly-to-bounds="false" data-fly-to-bounds="false"
> >

View File

@ -2,31 +2,31 @@
<% if $Facebook %> <% if $Facebook %>
<a href="$Facebook.URL" title="Facebook" target="_blank"> <a href="$Facebook.URL" title="Facebook" target="_blank">
<i class="fab fa-facebook"></i> <i class="fab fa-facebook"></i>
<i class="d-none">Facebook</i> <i class="sr-only">Facebook</i>
</a> </a>
<% end_if %> <% end_if %>
<% if $LinkedIn %> <% if $LinkedIn %>
<a href="$LinkedIn.URL" title="LinkedIn" target="_blank"> <a href="$LinkedIn.URL" title="LinkedIn" target="_blank">
<i class="fab fa-linkedin"></i> <i class="fab fa-linkedin"></i>
<i class="d-none">LinkedIn</i> <i class="sr-only">LinkedIn</i>
</a> </a>
<% end_if %> <% end_if %>
<% if $GooglePlus %> <% if $GooglePlus %>
<a href="$GooglePlus.URL" title="Google+" target="_blank"> <a href="$GooglePlus.URL" title="Google+" target="_blank">
<i class="fab fa-google-plus-g"></i> <i class="fab fa-google-plus-g"></i>
<i class="d-none">Google+</i> <i class="sr-only">Google+</i>
</a> </a>
<% end_if %> <% end_if %>
<% if $Instagram %> <% if $Instagram %>
<a href="$Instagram.URL" title="Instagram" target="_blank"> <a href="$Instagram.URL" title="Instagram" target="_blank">
<i class="fab fa-instagram"></i> <i class="fab fa-instagram"></i>
<i class="d-none">Instagram</i> <i class="sr-only">Instagram</i>
</a> </a>
<% end_if %> <% end_if %>
<% if $Twitter %> <% if $Twitter %>
<a href="$Twitter.URL" title="Twitter" target="_blank"> <a href="$Twitter.URL" title="Twitter" target="_blank">
<i class="fab fa-twitter"></i> <i class="fab fa-twitter"></i>
<i class="d-none">Twitter</i> <i class="sr-only">Twitter</i>
</a> </a>
<% end_if %> <% end_if %>
</div> </div>

View File

@ -43,21 +43,6 @@
<% include Footer %> <% include Footer %>
</footer> </footer>
<div class="hidden-print"> <% include Last %>
$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>
</body> </body>
</html> </html>

View File

@ -58,11 +58,21 @@ let plugins = [
//assetNameRegExp: /\.optimize\.css$/g, //assetNameRegExp: /\.optimize\.css$/g,
cssProcessor: require('cssnano'), cssProcessor: require('cssnano'),
cssProcessorPluginOptions: { 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: { discardComments: {
removeAll: true removeAll: true
} },
}],
}, },
canPrint: true canPrint: true
}), }),