Skip to content

Commit

Permalink
Web app guidelines and shit, offline support
Browse files Browse the repository at this point in the history
  • Loading branch information
markasoftware committed Jan 12, 2018
1 parent f89a043 commit 7d997a3
Show file tree
Hide file tree
Showing 10 changed files with 40 additions and 8 deletions.
14 changes: 9 additions & 5 deletions build/build.bash
Expand Up @@ -2,17 +2,21 @@

# doesn't work with process substitution for some reason, so this will do
echo 'Combining specs...'
node build/gen-specs.js specs /tmp/specs.js public/generated/sitemap.txt
node build/gen-specs.js specs /tmp/specs.js public/sitemap.txt
[[ $1 == 'production' ]] && cssMini='csso' || cssMini='cat'
echo 'Bundling scripts...'
# TODO: maybe add --noparse /tmp/specs.js but last time i tried it didn't make a noticeable difference (but mithril did)
browserify -r /tmp/specs.js:spec-data --noparse mithril --debug src/js/entry.js > public/generated/bundle.js
browserify -r /tmp/specs.js:spec-data --noparse mithril --debug src/js/entry.js > public/bundle.js
if [[ $1 == 'production' ]]
then
echo 'Compiling and minifying scripts...'
babel public/generated/bundle.js | uglifyjs --compress --mangle --screw-ie8 > /tmp/bundle.js
mv /tmp/bundle.js public/generated/bundle.js
# we have to write it to tmp first then move because doing it all at once causes babel to freak the fuck out
# the file is truncated before babel has fully read it
babel public/bundle.js | uglifyjs -cmo public/bundle.js
echo 'Generating service worker...'
sw-precache --root=public --sw-file=sw.js --static-file-globs='public/*'
uglifyjs -cmo public/sw.js public/sw.js 2> /dev/null
fi
echo 'Bundling styles...'
cat src/css/*.css | $cssMini > public/generated/all.css
cat src/css/*.css | $cssMini > public/all.css
echo 'Build complete'
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -21,6 +21,7 @@
"js-yaml": "^3",
"mithril": "^1",
"natural-compare": "^1.4.0",
"sw-precache": "^5.2.0",
"tap-spec": "*",
"tape": "^4",
"uglify-js": "^2"
Expand Down
1 change: 1 addition & 0 deletions public/generated/.gitignore → public/.gitignore
Expand Up @@ -2,3 +2,4 @@ all.css
bundle.js
specs.json
sitemap.txt
sw.js
Binary file added public/favicon.ico
Binary file not shown.
Binary file added public/icon-192.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/icon-512.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 4 additions & 2 deletions public/index.html
Expand Up @@ -4,11 +4,13 @@
<title>SpecDB — View and Compare Graphics Cards and CPUs</title>
<meta name='description' content="Designed as an AMD equivalent of Intel's ARK, SpecDB is the definitive source for AMD hardware specifications">
<meta name='viewport' content='initial-scale=0.8, user-scalable=no, width=device-width'>
<meta name='theme-color' content='#ff4545'>
<meta charset='utf8'>
<script src='generated/bundle.js' defer></script>
<script src='bundle.js' defer></script>
<link rel='dns-prefetch' href='//fonts.gstatic.com'>
<link href="https://fonts.googleapis.com/css?family=Open+Sans:400,600|Quicksand:300,400" rel="stylesheet">
<link rel='stylesheet' href='generated/all.css'>
<link rel='stylesheet' href='all.css'>
<link rel='manifest' href='manifest.json'>
</head>
<body>
<div id='error-wrapper'>
Expand Down
18 changes: 18 additions & 0 deletions public/manifest.json
@@ -0,0 +1,18 @@
{
"name": "SpecDB",
"short_name": "SpecDB",
"description": "View and compare graphics cards, CPUs, and APUs manufactured by AMD",
"start_url": ".",
"theme_color": "#ff4545",
"background_color": "#eee",
"display": "standalone",
"icons": [{
"src": "icon-192.png",
"type": "image/png",
"sizes": "192x192"
}, {
"src": "icon-512.png",
"type": "image/png",
"sizes": "512x512"
}]
}
2 changes: 1 addition & 1 deletion public/robots.txt
@@ -1 +1 @@
Sitemap: https://specdb.info/generated/sitemap.txt
Sitemap: https://specdb.info/sitemap.txt
6 changes: 6 additions & 0 deletions src/js/entry.js
Expand Up @@ -10,4 +10,10 @@ m.mount(document.getElementById('part-selector'), require('./part-selector.js'))
// extend part selector if no parts are selected on mobile
if(hash.getList().length === 0) {
document.getElementById('mobile-toggle').checked = true;
}

// service worker registration
if('serviceWorker' in navigator) {
navigator.serviceWorker.register('sw.js')
.catch(() => console.log('Service worker registration failed, make sure you are in production mode'));
}

0 comments on commit 7d997a3

Please sign in to comment.