Skip to content
Permalink
Browse files

better font retrieval

  • Loading branch information...
y-a-v-a committed Sep 28, 2019
1 parent 196083a commit fe491978428386e50c280b437e9d160560c5926c
Showing with 29 additions and 24 deletions.
  1. +13 βˆ’3 app.js
  2. +2 βˆ’10 fetch.js
  3. +1 βˆ’0 font-version
  4. BIN public/fonts/OnKawara-Regular-0.0.3.otf
  5. +0 βˆ’5 public/stylesheets/style.css
  6. +8 βˆ’5 routes/index.js
  7. +1 βˆ’1 views/download.pug
  8. +4 βˆ’0 views/layout.pug
16 app.js
@@ -4,12 +4,23 @@ var favicon = require('serve-favicon');
var logger = require('morgan');
var cookieParser = require('cookie-parser');
var bodyParser = require('body-parser');
var fs = require('fs');

var app = express();

var fontVersionFile = './font-version';
var fontVersion = '0.0.0';
try {
var fontVersion = fs.readFileSync(fontVersionFile);
app.set('font-version', `-${fontVersion}`);
} catch(e) {
console.log(`Unable to read file: ${fontVersionFile}`);
process.exit(1);
}

var routes = require('./routes/index');
var themes = require('./themes');

var app = express();

// view engine setup
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'pug');
@@ -36,7 +47,6 @@ app.use(function(req, res, next) {
next(err);
});


// error handlers

// development error handler
@@ -64,20 +64,12 @@ async function main() {
debug(`Duplicated ${targetPath} to ${baseName}, express.static cannot serve symlinks...(?)`);

debug('Done');

fs.writeFileSync('./font-version', newVersion);
}
});

// // cleanup symlink
// debug('Unlink original symlink');
// fs.unlinkSync(baseName);

// // create new symlink
// fs.symlinkSync(targetPath, baseName);

// debug('Done');
}
});

}

// call main function
@@ -0,0 +1 @@
0.0.3
Binary file not shown.
@@ -1,8 +1,3 @@
@font-face {
font-family: OnKawara;
src: url("/fonts/OnKawara-Regular.otf") format("opentype");
}

:focus {
outline: #f1f1f1 auto 5px;
}
@@ -11,26 +11,29 @@ var title = 'On Kawara font';

/* GET home page. */
router.get('/', function(req, res, next) {
var today = (new Date()).toLocaleDateString('en-US', localizeOptions).replace(/ /g, '');
const today = (new Date()).toLocaleDateString('en-US', localizeOptions).replace(/ /g, '');

const responseData = {
title: title,
title,
date: today,
theme: res.locals.theme
theme: res.locals.theme,
fontVersion: req.app.get('font-version')
};

res.render('index', responseData);
});

router.get('/about', function(req, res, next) {
res.render('about', {
title: `${title} about`
title: `${title} about`,
fontVersion: req.app.get('font-version')
});
});

router.get('/download', function(req, res, next) {
res.render('download', {
title: `${title} download`
title: `${title} download`,
fontVersion: req.app.get('font-version')
});
});

@@ -3,7 +3,7 @@ extends layout
block content
.canvas
h1
a(href='/fonts/OnKawara-Regular.otf') Download
a(href='/fonts/OnKawara-Regular#{fontVersion}.otf') Download
.meta
p Download the On Kawara font via clicking 'Download'
p
@@ -5,6 +5,10 @@ html(lang='en-US')
title= title
link(rel='stylesheet', href='/stylesheets/style.css')
style.
@font-face {
font-family: OnKawara;
src: url("/fonts/OnKawara-Regular#{fontVersion}.otf") format("opentype");
}
body, a, a:visited, a:active { color: !{theme.fg}; }
body { background-color: !{theme.bg}; }
a:hover { color: #aaa; }

0 comments on commit fe49197

Please sign in to comment.
You can’t perform that action at this time.