IMPR: Offline functionality

This commit is contained in:
Tony Air 2020-04-02 07:20:17 +07:00
parent c4797a678c
commit 26340ad3cd
5 changed files with 61 additions and 61 deletions

View File

@ -83,6 +83,16 @@ import '@a2nt/meta-lightbox/src/js/index';
import '@a2nt/ss-bootstrap-ui-webpack-boilerplate/src/js/_main';
import './_layout';
// Register service worker
if ('serviceWorker' in navigator) {
var baseHref = (document.getElementsByTagName('base')[0] || {}).href;
if (baseHref) {
navigator.serviceWorker.register(`${baseHref}sw.js`).then(() => {
console.log('Service Worker Registered');
});
}
}
function importAll(r) {
return r.keys().map(r);
}

View File

@ -1,14 +1,13 @@
<% base_tag %>
$MetaTags
<meta name="theme-color" content="#000000" />
<meta name="msapplication-navbutton-color" content="#000000" />
<meta name="apple-mobile-web-app-status-bar-style" content="#000000" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="mobile-web-app-capable" content="yes" />
<%-- OpenGraph --%>
<meta property="og:url" content="{$AbsoluteLink}" />
<meta property="og:url" content="{$AbsoluteBaseURL}" />
<meta property="og:site_name" content="{$SiteConfig.Title}" />
<meta property="og:locale" content="$ContentLocale.ATT" />
@ -23,13 +22,9 @@ $MetaTags
<% if $MetaDescription %>
<meta property="og:description" content="{$MetaDescription}" />
<% end_if %>
<% if $MetaImage %>
<meta property="og:image" content="{$MetaImage.Link}" />
<% else_if $MetaImageLink %>
<meta property="og:image" content="{$MetaImageLink}" />
<% end_if %>
<% if $FacebookAppID %>
<meta property="fb:app_id" content="{$FacebookAppID}" />
<% end_if %>
@ -41,23 +36,10 @@ $MetaTags
<link rel="author" type="text/plain" href="{$AbsoluteBaseURL}humans.txt" />
<link rel="sitemap" type="application/xml" title="Sitemap" href="{$AbsoluteBaseURL}sitemap.xml" />
<link rel="dns-prefetch" href="https://fonts.gstatic.com" />
<link rel="dns-prefetch" href="https://use.fontawesome.com" />
<link rel="dns-prefetch" href="https://ajax.googleapis.com" />
<link rel="dns-prefetch" href="https:///www.google-analytics.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link rel="preconnect" href="https://use.fontawesome.com" crossorigin />
<link rel="preconnect" href="https://ajax.googleapis.com" crossorigin />
<link rel="preconnect" href="https:///www.google-analytics.com" crossorigin />
<link rel="dns-prefetch" href="https://csi.gstatic.com" />
<link rel="dns-prefetch" href="https://maps.google.com" />
<link rel="dns-prefetch" href="https://maps.googleapis.com" />
<link rel="preconnect" href="https://csi.gstatic.com" />
<link rel="preconnect" href="https://maps.google.com" />
<link rel="preconnect" href="https://ajax.googleapis.com" />
<link rel="preconnect" href="https://csi.gstatic.com" />
<link rel="preconnect" href="https://maps.googleapis.com" />
<link rel="preconnect" href="https://www.youtube.com" />
@ -66,7 +48,6 @@ $MetaTags
<link rel="preconnect" href="https://s.ytimg.com" />
<link rel="shortcut icon" type="image/x-icon" href="{$AbsoluteBaseURL}resources/app/client/dist/icons/favicon.ico" />
<link rel="icon" sizes="144x144" type="image/png" href="{$AbsoluteBaseURL}resources/app/client/dist/icons/android-chrome-144x144.png" />
<link rel="apple-touch-icon" href="{$AbsoluteBaseURL}resources/app/client/dist/icons/apple-touch-icon.png" />
<link rel="apple-touch-icon-precomposed" href="{$AbsoluteBaseURL}resources/app/client/dist/icons/apple-touch-icon-precomposed.png" />
<link rel="manifest" href="/manifest.json" />
@ -78,6 +59,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, initial-scale=1, shrink-to-fit=no" />
<meta name="viewport" content="width=device-width,user-scalable=no,initial-scale=1,maximum-scale=1" />
<% include Prestyling %>

View File

@ -1,3 +1,7 @@
<div class="alert alert-fixed-top alert-danger alert-offline">
The Internet connection is missing right now, but you're able to browse previously opened pages offline.
</div>
<% if $SiteWideMessage %>
<div class="alert alert-fixed-top alert-{$Type}">
{$Message}
@ -6,4 +10,4 @@
<% with $SiteConfig %>
<% include Site\Objects\NotificationsList %>
<% end_with %>
<% end_with %>

View File

@ -2,7 +2,10 @@
"name": "a2nt/silverstripe-webpack",
"type": "silverstripe-recipe",
"description": "SilverStripe WebPack boilerplate + Basics of JS/CSS UI",
"keywords": ["silverstripe", "webpack"],
"keywords": [
"silverstripe",
"webpack"
],
"license": "BSD-3-Clause",
"require": {
"php": ">=7.1.0",
@ -37,19 +40,23 @@
"silverstripe/widgets": "^2.0",
"a2nt/silverstripe-font-awesome-field": "dev-master",
"a2nt/silverstripe-mapboxfield": "dev-master",
"a2nt/silverstripe-progressivewebapp": "dev-master",
"bummzack/sortablefile": "*"
},
"require-dev": {
"phpunit/phpunit": "^5.7",
"lekoala/silverstripe-debugbar": "dev-master"
},
"repositories": [{
"type": "vcs",
"url": "https://github.com/a2nt/silverstripe-font-awesome"
}, {
"type": "vcs",
"url": "https://github.com/a2nt/silverstripe-mapboxfield"
}],
"repositories": [
{
"type": "vcs",
"url": "https://github.com/a2nt/silverstripe-font-awesome"
},
{
"type": "vcs",
"url": "https://github.com/a2nt/silverstripe-mapboxfield"
}
],
"extra": {
"expose": [
"app/client/dist"

View File

@ -30,20 +30,20 @@
"ie>=11"
],
"dependencies": {
"@a2nt/meta-lightbox": "^1.2.2",
"@a2nt/ss-bootstrap-ui-webpack-boilerplate": "^1.7.6",
"browserslist": "^4.8.6",
"caniuse-lite": "^1.0.30001025",
"inputmask": "^5.0.3",
"@a2nt/meta-lightbox": "^1.2.4",
"@a2nt/ss-bootstrap-ui-webpack-boilerplate": "^1.8.7",
"browserslist": "^4.11.1",
"caniuse-lite": "^1.0.30001038",
"font-awesome": "^4.7.0",
"yarn": "^1.22.0"
"inputmask": "^5.0.3",
"yarn": "^1.22.4"
},
"devDependencies": {
"@a2nt/image-sprite-webpack-plugin": "^0.2.5",
"@babel/core": "^7.8.4",
"@babel/plugin-proposal-object-rest-spread": "^7.8.3",
"@babel/plugin-transform-react-jsx": "^7.8.3",
"@babel/preset-env": "^7.8.4",
"@babel/plugin-transform-react-jsx": "^7.9.4",
"@babel/preset-env": "^7.9.0",
"@google/markerclusterer": "^1.0.3",
"animate.css": "^3.7.0",
"autoprefixer": "^9.7.4",
@ -53,7 +53,7 @@
"bootstrap-confirmation2": "^4.1.0",
"bootstrap-datepicker": "^1.9.0",
"bootstrap-offcanvas": "^1.0.0",
"bootstrap-table": "^1.15.3",
"bootstrap-table": "^1.16.0",
"bootstrap-timepicker": "^0.5.2",
"browser-sync": "^2.24.5",
"browser-sync-webpack-plugin": "^2.2.2",
@ -62,22 +62,24 @@
"core-util-is": "^1.0.2",
"croppie": "^2.6.4",
"cross-env": "^5.2.1",
"css-loader": "^3.4.2",
"eslint": "^4.18.1",
"eslint-plugin-import": "^2.20.1",
"eslint-plugin-import": "^2.20.2",
"eslint-plugin-jquery": "^1.5.1",
"eslint-plugin-react": "^7.18.3",
"eslint-plugin-react": "^7.19.0",
"exif-js": "^2.3.0",
"exports-loader": "^0.7.0",
"favicons-webpack-plugin": "0.0.9",
"file-loader": "^5.1.0",
"font-awesome": "^4.7.0",
"foundation-emails": "^2.2.1",
"gijgo": "^1.9.13",
"hard-source-webpack-plugin": "^0.13.1",
"html-webpack-plugin": "^4.0.0-beta.11",
"html-webpack-plugin": "^4.0.3",
"imagemin-gifsicle": "^7.0.0",
"imagemin-jpegtran": "^6.0.0",
"imagemin-optipng": "^7.1.0",
"imagemin-svgo": "^7.0.0",
"imagemin-svgo": "^7.1.0",
"imagemin-webpack": "^5.1.1",
"jquery": "^3.4.1",
"jquery-hammerjs": "^2.0.0",
@ -87,45 +89,41 @@
"laravel-mix": "^4.1.2",
"loglevel": "^1.6.7",
"lost": "^8.3.1",
"mapbox-gl": "^1.6.1",
"mapbox-gl": "^1.9.0",
"material-design-color": "^2.3.2",
"mini-css-extract-plugin": "^0.9.0",
"node-sass": "^4.13.1",
"object-assign": "^4.1.1",
"offcanvas-bootstrap": "^2.5.2",
"optimize-css-assets-webpack-plugin": "^5.0.3",
"popper.js": "^1.16.0",
"postcss-loader": "^3.0.0",
"pouchdb": "^6.4.3",
"quill": "^1.3.7",
"react": "^16.12.0",
"react": "^16.13.1",
"react-bootstrap4-form-validation": "^1.0.10",
"react-dom": "^16.12.0",
"react-dom": "^16.13.1",
"react-hot-loader": "^3.1.3",
"redux": "^3.7.2",
"redux-devtools-extension": "^2.13.8",
"resolve-url-loader": "^3.1.1",
"rimraf": "^2.7.1",
"routie": "0.0.1",
"sass-lint": "^1.13.1",
"sass-lint-fix": "^1.12.1",
"sass-loader": "^8.0.2",
"script-ext-html-webpack-plugin": "^2.1.4",
"select2": "^4.0.8",
"smooth-scroll": "^14.2.1",
"style-loader": "^0.19.0",
"svg-url-loader": "^2.3.3",
"terser-webpack-plugin": "^2.3.2",
"terser-webpack-plugin": "^2.3.5",
"url-loader": "^0.6.2",
"webpack": "^4.41.5",
"webpack-cli": "^3.3.10",
"webpack": "^4.42.1",
"webpack-cli": "^3.3.11",
"webpack-dev-server": "^3.10.3",
"webpack-manifest-plugin": "^1.3.2",
"webpack-merge": "^4.2.2",
"@a2nt/image-sprite-webpack-plugin": "^0.2.5",
"css-loader": "^3.4.2",
"file-loader": "^5.1.0",
"mini-css-extract-plugin": "^0.9.0",
"node-sass": "^4.13.1",
"postcss-loader": "^3.0.0",
"resolve-url-loader": "^3.1.1",
"sass-loader": "^8.0.2",
"hard-source-webpack-plugin": "^0.13.1"
"webpack-merge": "^4.2.2"
},
"stylelint": {
"rules": {