<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[8981] sites/trunk/wordcamp.org/public_html/wp-content/mu-plugins: Offline Template: Initial commit.</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { white-space: pre-line; overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta" style="font-size: 105%">
<dt style="float: left; width: 6em; font-weight: bold">Revision</dt> <dd><a style="font-weight: bold" href="http://meta.trac.wordpress.org/changeset/8981">8981</a><script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","description":"Review this Commit","action":{"@type":"ViewAction","url":"http://meta.trac.wordpress.org/changeset/8981","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>iandunn</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2019-06-20 20:24:14 +0000 (Thu, 20 Jun 2019)</dd>
</dl>

<pre style='padding-left: 1em; margin: 2em 0; border-left: 2px solid #ccc; line-height: 1.25; font-size: 105%; font-family: sans-serif'>Offline Template: Initial commit.

Props westonruter, iandunn.

See https://make.wordpress.org/community/2019/04/30/wordcamp-pwa-an-update/
See https://github.com/wceu/wordcamp-pwa-page/issues/9</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#sitestrunkwordcamporgpublic_htmlwpcontentmuplugins3helpersmiscphp">sites/trunk/wordcamp.org/public_html/wp-content/mu-plugins/3-helpers-misc.php</a></li>
<li><a href="#sitestrunkwordcamporgpublic_htmlwpcontentmupluginsserviceworkercachingphp">sites/trunk/wordcamp.org/public_html/wp-content/mu-plugins/service-worker-caching.php</a></li>
<li><a href="#sitestrunkwordcamporgpublic_htmlwpcontentmupluginsthemetemplatesbootstrapphp">sites/trunk/wordcamp.org/public_html/wp-content/mu-plugins/theme-templates/bootstrap.php</a></li>
<li><a href="#sitestrunkwordcamporgpublic_htmlwpcontentmupluginsthemetemplatestemplatesdayofeventsrccomponentsmaincontrollerjs">sites/trunk/wordcamp.org/public_html/wp-content/mu-plugins/theme-templates/templates/day-of-event/src/components/main-controller.js</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li>sites/trunk/wordcamp.org/public_html/wp-content/mu-plugins/theme-templates/parts/</li>
<li><a href="#sitestrunkwordcamporgpublic_htmlwpcontentmupluginsthemetemplatespartsdatesphp">sites/trunk/wordcamp.org/public_html/wp-content/mu-plugins/theme-templates/parts/dates.php</a></li>
<li><a href="#sitestrunkwordcamporgpublic_htmlwpcontentmupluginsthemetemplatespartslocationphp">sites/trunk/wordcamp.org/public_html/wp-content/mu-plugins/theme-templates/parts/location.php</a></li>
<li><a href="#sitestrunkwordcamporgpublic_htmlwpcontentmupluginsthemetemplatestemplatesofflinephp">sites/trunk/wordcamp.org/public_html/wp-content/mu-plugins/theme-templates/templates/offline.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="sitestrunkwordcamporgpublic_htmlwpcontentmuplugins3helpersmiscphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: sites/trunk/wordcamp.org/public_html/wp-content/mu-plugins/3-helpers-misc.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- sites/trunk/wordcamp.org/public_html/wp-content/mu-plugins/3-helpers-misc.php     2019-06-20 20:24:08 UTC (rev 8980)
+++ sites/trunk/wordcamp.org/public_html/wp-content/mu-plugins/3-helpers-misc.php       2019-06-20 20:24:14 UTC (rev 8981)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -129,3 +129,30 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        <?php
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+/**
+ * Get the URL of Jetpack's Custom CSS file.
+ *
+ * Core normally just prints the CSS inline, but Jetpack enqueues it if it's longer than 2k characters. Jetpack
+ * doesn't provide a function to access the URL, though, and duplicating the logic in `Jetpack_Custom_CSS_Enhancements::wp_custom_css_cb()`
+ * wouldn't be resilient or future-proof. So, we have to jump through some hoops to get it safely.
+ *
+ * @return bool|string
+ */
+function wcorg_get_custom_css_url() {
+       /*
+        * This has side-effects because `add_hooks()` is called immediately, but it doesn't seem problematic because
+        * it gets loaded on every front/back-end page anyway.
+        */
+       require_once( WP_PLUGIN_DIR . '/jetpack/modules/custom-css/custom-css-4.7.php' );
+
+       ob_start();
+       Jetpack_Custom_CSS_Enhancements::wp_custom_css_cb();
+       $markup = ob_get_clean();
+
+       $dom = new DOMDocument();
+       $dom->loadHTML( $markup );
+       $element = $dom->getElementById( 'wp-custom-css' );
+
+       return $element instanceof DOMElement ? $element->getAttribute( 'href' ) : false;
+}
</ins></span></pre></div>
<a id="sitestrunkwordcamporgpublic_htmlwpcontentmupluginsserviceworkercachingphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: sites/trunk/wordcamp.org/public_html/wp-content/mu-plugins/service-worker-caching.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- sites/trunk/wordcamp.org/public_html/wp-content/mu-plugins/service-worker-caching.php     2019-06-20 20:24:08 UTC (rev 8980)
+++ sites/trunk/wordcamp.org/public_html/wp-content/mu-plugins/service-worker-caching.php       2019-06-20 20:24:14 UTC (rev 8981)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -12,7 +12,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> add_action( 'wp_front_service_worker',    __NAMESPACE__ . '\set_navigation_caching_strategy' );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-// is prompt to save offline automatically showing on mobile?
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+// todo is prompt to save offline automatically showing on mobile?
</ins><span class="cx" style="display: block; padding: 0 10px">         // if so, not sure we want it to
</span><span class="cx" style="display: block; padding: 0 10px">        // not really related to this file, but nothing closer at the moment
</span><span class="cx" style="display: block; padding: 0 10px">        // maybe want it to be eventually, but not until we do more work to really make the site use pwa features well?
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -42,10 +42,37 @@
</span><span class="cx" style="display: block; padding: 0 10px">         *          Or maybe cache all routes, but then add an extra route that caches Tagregator less often?
</span><span class="cx" style="display: block; padding: 0 10px">         * All of this needs to be tested to verify that it's working as intended.
</span><span class="cx" style="display: block; padding: 0 10px">         *      What's the best way to do that? Document it here if it's not obvious.
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         * need to explicitly remove older revisions of custom-css (and other assets?) from the cache when they change?
</ins><span class="cx" style="display: block; padding: 0 10px">          */
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+        $custom_css_url_parts = wp_parse_url( wcorg_get_custom_css_url() );
+
+       $static_asset_route_params = array(
+               'strategy'  => WP_Service_Worker_Caching_Routes::STRATEGY_CACHE_FIRST,
+               'cacheName' => 'assets',
+               'plugins'   => [
+                       'expiration' => [
+                               'maxEntries'    => 60,
+                               'maxAgeSeconds' => DAY_IN_SECONDS,
+                       ],
+               ],
+       );
+
</ins><span class="cx" style="display: block; padding: 0 10px">         wp_register_service_worker_caching_route(
</span><span class="cx" style="display: block; padding: 0 10px">                '/wp-(content|includes)/.*\.(?:png|gif|jpg|jpeg|svg|webp|css|js)(\?.*)?$',
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                $static_asset_route_params
+       );
+
+       if ( isset( $custom_css_url_parts['path'], $custom_css_url_parts['query'] ) ) {
+               wp_register_service_worker_caching_route(
+                       $custom_css_url_parts['path'] . $custom_css_url_parts['query'] . '$',
+                       $static_asset_route_params
+               );
+       }
+       // todo test url being false/null
+
+       wp_register_service_worker_caching_route(
+               '/wp-(content|includes)/.*\.(?:png|gif|jpg|jpeg|svg|webp|css|js)(\?.*)?$',
</ins><span class="cx" style="display: block; padding: 0 10px">                 [
</span><span class="cx" style="display: block; padding: 0 10px">                        'strategy'  => WP_Service_Worker_Caching_Routes::STRATEGY_CACHE_FIRST,
</span><span class="cx" style="display: block; padding: 0 10px">                        'cacheName' => 'assets',
</span></span></pre></div>
<a id="sitestrunkwordcamporgpublic_htmlwpcontentmupluginsthemetemplatesbootstrapphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: sites/trunk/wordcamp.org/public_html/wp-content/mu-plugins/theme-templates/bootstrap.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- sites/trunk/wordcamp.org/public_html/wp-content/mu-plugins/theme-templates/bootstrap.php  2019-06-20 20:24:08 UTC (rev 8980)
+++ sites/trunk/wordcamp.org/public_html/wp-content/mu-plugins/theme-templates/bootstrap.php    2019-06-20 20:24:14 UTC (rev 8981)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -21,7 +21,10 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px"> add_filter( 'theme_page_templates',            __NAMESPACE__ . '\register_page_templates' );
</span><span class="cx" style="display: block; padding: 0 10px"> add_filter( 'template_include',                __NAMESPACE__ . '\set_page_template_locations' );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+add_filter( 'template_include',                __NAMESPACE__ . '\inject_offline_template', 20 );  // After others because being offline transcends other templates.
</ins><span class="cx" style="display: block; padding: 0 10px"> add_action( 'wp_enqueue_scripts',              __NAMESPACe__ . '\enqueue_template_assets' );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+add_filter( 'wp_offline_error_precache_entry', __NAMESPACE__ . '\add_offline_template_cachebuster' );
+add_action( 'wp_front_service_worker',         __NAMESPACE__ . '\precache_offline_template_assets' );
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -132,3 +135,85 @@
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+/**
+ * Inject the offline template when the service worker pre-caches the response to offline requests.
+ *
+ * This is a dynamic template like search, 404, etc, rather than a page template.
+ *
+ * @param string $template_path
+ *
+ * @return string
+ */
+function inject_offline_template( $template_path ) {
+       if ( is_offline() || is_500() ) {
+               $template_path = __DIR__ . '/templates/offline.php';
+       }
+
+       return $template_path;
+}
+
+/**
+ * Add a cache-buster to the offline template's pre-cache entry.
+ *
+ * @param string
+ *
+ * @return string
+ */
+function add_offline_template_cachebuster( $entry ) {
+       $entry['revision'] .= ';' . filemtime( __DIR__ . '/templates/offline.php' );    // todo test that this is working. doesn't seem like it is, WB_REVISION is 0.2.0 (pwa plugin version), rather than this.
+
+       return $entry;
+}
+
+/**
+ * Precache the current theme's stylesheet
+ *
+ * @param WP_Service_Worker_Scripts $scripts
+ */
+function precache_offline_template_assets( WP_Service_Worker_Scripts $scripts ) {
+       $asset = get_custom_css_precache_details();
+
+       /*
+        * If we don't have a URL, that's probably because the custom CSS is empty or short enough to be printed
+        * inline instead of enqueued. In that case, the offline template will have it printed from the `wp_head()`
+        * call anyway.
+        */
+       if ( ! $asset ) {
+               return;
+               // todo test
+       }
+
+       $scripts->precaching_routes()->register(
+               $asset['url'],
+               array( 'revision' => $asset['revision'] )
+       );
+}
+
+/**
+ * Get the URL and revision for the custom CSS stylesheet.
+ *
+ * @return array|bool
+ */
+function get_custom_css_precache_details() {
+       $url = wcorg_get_custom_css_url();
+
+       wp_parse_str(
+               wp_parse_url( $url, PHP_URL_QUERY ),
+               $url_query_params
+       );
+
+       // todo precache header image too, but can't for wceu b/c they're specifying in CSS bg image, rather than using Core functions.
+
+       return array(
+               'url' => $url,
+
+               /*
+                * This could probably be anything, since `$url` actually contains a cachebuster, but a unique revision
+                * is set just for completeness.
+                *
+                * Jetpack stores the cachebuster in the `custom-css` query parameter.
+                */
+               'revision' => $url_query_params['custom-css'],
+       );
+}
</ins></span></pre></div>
<a id="sitestrunkwordcamporgpublic_htmlwpcontentmupluginsthemetemplatespartsdatesphp"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: sites/trunk/wordcamp.org/public_html/wp-content/mu-plugins/theme-templates/parts/dates.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- sites/trunk/wordcamp.org/public_html/wp-content/mu-plugins/theme-templates/parts/dates.php                                (rev 0)
+++ sites/trunk/wordcamp.org/public_html/wp-content/mu-plugins/theme-templates/parts/dates.php  2019-06-20 20:24:14 UTC (rev 8981)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -0,0 +1,10 @@
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+<?php
+
+namespace WordCamp\Theme_Templates;
+
+defined( 'WPINC' ) || die();
+
+// todo add dates
+       // pull from `wordcamp` post type
+
+// include from day-of-event template and offline template
</ins><span class="cx" style="display: block; padding: 0 10px">\ No newline at end of file
</span></span></pre></div>
<a id="sitestrunkwordcamporgpublic_htmlwpcontentmupluginsthemetemplatespartslocationphp"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: sites/trunk/wordcamp.org/public_html/wp-content/mu-plugins/theme-templates/parts/location.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- sites/trunk/wordcamp.org/public_html/wp-content/mu-plugins/theme-templates/parts/location.php                             (rev 0)
+++ sites/trunk/wordcamp.org/public_html/wp-content/mu-plugins/theme-templates/parts/location.php       2019-06-20 20:24:14 UTC (rev 8981)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -0,0 +1,13 @@
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+<?php
+
+namespace WordCamp\Theme_Templates;
+
+defined( 'WPINC' ) || die();
+
+// todo location of venue, directions, etc
+// how to get without hardcoding?
+       // can pull address from `wordcamp` post type, maybe create a link to Google Maps driving directions with the starting place blank so they type that
+       // it'd be nice to pull in content from the Location page, but don't have a way to programatically detect that, and could have lots of non-essential content mixed in with it
+
+// include from day-of-event template and offline template
+       // link to gmaps wouldn't make sense in offline scenario, though. maybe detect which template it's being included from and show link or not based on that
</ins><span class="cx" style="display: block; padding: 0 10px">\ No newline at end of file
</span></span></pre></div>
<a id="sitestrunkwordcamporgpublic_htmlwpcontentmupluginsthemetemplatestemplatesdayofeventsrccomponentsmaincontrollerjs"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: sites/trunk/wordcamp.org/public_html/wp-content/mu-plugins/theme-templates/templates/day-of-event/src/components/main-controller.js</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- sites/trunk/wordcamp.org/public_html/wp-content/mu-plugins/theme-templates/templates/day-of-event/src/components/main-controller.js       2019-06-20 20:24:08 UTC (rev 8980)
+++ sites/trunk/wordcamp.org/public_html/wp-content/mu-plugins/theme-templates/templates/day-of-event/src/components/main-controller.js 2019-06-20 20:24:14 UTC (rev 8981)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -24,7 +24,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px"> // todo also unfinished comments on https://github.com/wceu/wordcamp-pwa-page/pull/11
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-// todo run linter on everything after removing all the todos, refactoring, etc
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+// todo run php/css/js linters on everything after removing all the todos, refactoring, etc
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px"> // todo reduce bundle size, 10k is way too big for a small thing like this
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span></span></pre></div>
<a id="sitestrunkwordcamporgpublic_htmlwpcontentmupluginsthemetemplatestemplatesofflinephp"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: sites/trunk/wordcamp.org/public_html/wp-content/mu-plugins/theme-templates/templates/offline.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- sites/trunk/wordcamp.org/public_html/wp-content/mu-plugins/theme-templates/templates/offline.php                          (rev 0)
+++ sites/trunk/wordcamp.org/public_html/wp-content/mu-plugins/theme-templates/templates/offline.php    2019-06-20 20:24:14 UTC (rev 8981)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -0,0 +1,86 @@
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+<?php
+
+/**
+ * Template Name: Offline Notice
+ *
+ * The service worker will show this template to visitors who are browsing offline.
+ *
+ * To test changes to it, you'll need to
+ * temporarily enable the `Bypass for network` setting in dev tools.
+ *             ^ doesn't work when using `offline` in chrome dev tools
+ *             maybe when using urls directly?
+ *
+ * See https://github.com/xwp/pwa-wp/issues/167#issuecomment-501004695
+ */
+
+namespace WordCamp\Theme_Templates;
+
+get_header();
+
+/*
+ * todo
+ *
+ * test this across themes
+ * test with child themes to make sure parent theme stylesheet is cached too
+ *             should theoretically pre-cache all stylesheets, but don't need to in practice b/c caching route takes care of?
+ *             can't hurt. maybe needed if regular cached assets are evicted to free up space, whereas precached ones wouldn't be?
+ * test with themes replacing and extending the theme stylesheet (via jetpack/remote-css)
+ * add date/time, location, schedule, etc -- https://github.com/wceu/wordcamp-pwa-page/issues/9
+ * Should we add `{{{error_details_iframe}}}` ?
+ * Should we add `wp_service_worker_error_details_template()` ?
+ * Maybe list all of the pages that are available offline, ala https://chrisruppel.com/travel/
+ *             Maybe do that instead of the regular navigation menu?
+ * include sidebar?
+ */
+
+?>
+
+       <main>
+               <h1>
+                       <?php echo esc_html( _x( 'Offline', 'Page Title', 'wordcamporg' ) ); ?>
+               </h1>
+
+               <p>
+                       <?php esc_html_e( "This page couldn't be loaded because you appear to be offline. Please try again once you have a network connection.", 'wordcamporg' ); ?>
+               </p>
+
+               <div>
+                       <?php
+                       // todo repeats "please try again..." from above hardcoded string in some cases, but not all.
+                       // need to detect when and avoid saying it twice?
+                       // or just don't call this b/c it doesn't provide detailed error message that'd be useful to user?
+                       // -- wp_service_worker_error_message_placeholder();
+                       // ?>
+               </div>
+
+               <p>
+                       <?php _e( "In the mean time, hopefully this information is useful:", 'wordcamporg' );
+                       // todo that string needs a lot of work
+                       ?>
+               </p>
+
+               <?php
+                       require_once( dirname( __DIR__ ) . '/parts/dates.php' );
+                       require_once( dirname( __DIR__ ) . '/parts/location.php' );
+               ?>
+
+               <h3>
+                       <?php esc_html_e( 'Schedule' ); ?>
+               </h3>
+
+               <?php
+               /*
+                * todo
+                *
+                * maybe need to specify params to show all days/all tracks/etc
+                * disable "favorites" b/c it won't work? well, some parts will and some parts won't. probably better to leave it, but think about in more detail
+                * replace w/ Schedule block once that's available, but use feature flag for back-compat
+                */
+               echo do_shortcode( '[schedule]' );
+
+               ?>
+       </main>
+
+<?php
+
+get_footer();
</ins></span></pre>
</div>
</div>

</body>
</html>