Browse Source

add some placeholder stuff for ttf files

Andrew Dolgov 1 year ago
parent
commit
4d108431dd
5 changed files with 23 additions and 6 deletions
  1. 1 0
      .gitignore
  2. 11 3
      css/reader.css
  3. 5 2
      index.php
  4. 0 0
      lib/fonts/.empty
  5. 6 1
      worker.js

+ 1 - 0
.gitignore

@@ -1,4 +1,5 @@
 config.php
+lib/fonts/*.ttf
 db/*.db
 sessions/*
 /tags

+ 11 - 3
css/reader.css

@@ -13,20 +13,28 @@ a:focus {
 	text-decoration: underline;
 }
 
+/* ugly hack: this assumes default prefix used for epube - /books/ 
+ * since CSS is loaded inline, relative urls won't work properly so 
+ * it's hardcoded for the time being (the alternative is pointing to 
+ * website root) */
+
+/* fonts below are freely available although license is likely proprietary
+ * so i'm not bundling the files */
+
 @font-face {
 	font-family: Caecilia;
-	src: local('PMN Caecilia 55');
+	src: local('PMN Caecilia 55'), url('/books/lib/fonts/pmn-caecilia-55.ttf') format('truetype');
 	font-weight : normal;
 }
 
 @font-face {
 	font-family: Caecilia;
-	src: local('PMN Caecilia 75');
+	src: local('PMN Caecilia 75'), url('/books/lib/fonts/pmn-caecilia-75.ttf') format('truetype');
 	font-weight : bold;
 }
 
 @font-face {
 	font-family: Caecilia;
-	src: local('PMN Caecilia 56');
+	src: local('PMN Caecilia 56'), url('/books/lib/fonts/pmn-caecilia-56.ttf') format('truetype');
 	font-style : italic;
 }

+ 5 - 2
index.php

@@ -143,9 +143,12 @@
 			  });
 
 			 navigator.serviceWorker.addEventListener('message', function(event) {
-			   // not used yet
+				// invoked by service worker
 				if (event.data == 'client-reload') {
-					window.location.reload();
+					console.log('reloading in a moment...');
+					window.setTimeout(function() {
+						window.location.reload()
+					}, 1500);
 				}
 			 });
 		} else {

+ 0 - 0
lib/fonts/.empty


+ 6 - 1
worker.js

@@ -32,7 +32,10 @@ const CACHE_URLS = [
 			'lib/bootstrap/v3/css/bootstrap.min.css',
 			'lib/bootstrap/v3/js/jquery.js',
 			'lib/bootstrap/v3/js/bootstrap.min.js',
-			'lib/bootstrap/v3/fonts/glyphicons-halflings-regular.woff2'
+			'lib/bootstrap/v3/fonts/glyphicons-halflings-regular.woff2',
+			'lib/fonts/pmn-caecilia-55.ttf',
+			'lib/fonts/pmn-caecilia-56.ttf',
+			'lib/fonts/pmn-caecilia-75.ttf'
 		];
 
 self.addEventListener('install', function(event) {
@@ -126,6 +129,8 @@ this.addEventListener('fetch', function(event) {
 				return caches.match("offline.html");
 			}
 
+			console.log('cache miss for', req.url);
+
 			return fetch(req).then(function(resp) {
 
 				if (resp.status == 200) {