Skip to content
Permalink
Browse files

Add favicons

  • Loading branch information...
thesephist committed Apr 1, 2019
1 parent 8fb4110 commit 8de4afd09868253b7063e4ad71298ebbd27f08db
@@ -1,4 +1,4 @@
module.exports = {
PORT: 4556,
PORT: process.env.PORT || 4556,
DATABASE: 'db',
}
@@ -11,19 +11,34 @@ app.use(bodyParser.text({

const api = require('./api.js');

const CONTENT_TYPES = {
'.js': 'text/javascript',
'.html': 'text/html',
'.ico': 'image/x-icon',
}

// STATIC ASSETS
const STATIC_PATHS = {
'/': 'index.html',
'/new': 'editor.html',
'/favicon.ico': 'assets/favicon.ico',
'/h/:htmlFrameHash/j/:jsFrameHash/edit': 'editor.html',
}
const respondWith = (res, static_path) => {
fs.readFile(`static/${static_path}`, 'utf8', (err, data) => {
fs.readFile(`static/${static_path}`, (err, data) => {
if (err) {
throw err;
}

res.set('Content-Type', 'text/html');
let contentType = 'text/html';
for (const [ending, type] of Object.entries(CONTENT_TYPES)) {
if (static_path.endsWith(ending)) {
contentType = type;
break;
}
}

res.set('Content-Type', contentType);
res.set('X-Frame-Options', 'SAMEORIGIN');
res.send(data);
});
@@ -48,10 +63,6 @@ app.get('/f/:htmlFrameHash/:jsFrameHash.html/edit', (req, res) => {
});

// API
const CONTENT_TYPES = {
'.js': 'text/javascript',
'.html': 'text/html',
}
const API_PATHS = {
'GET /api/frame/:frameHash': api.frame.get,
'POST /api/frame/': api.frame.post,
@@ -72,6 +83,7 @@ for (const [spec, handler] of Object.entries(API_PATHS)) {
for (const [ending, type] of Object.entries(CONTENT_TYPES)) {
if (route.endsWith(ending)) {
contentType = type;
break;
}
}

Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -7,6 +7,8 @@
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Codeframe Editor</title>
<link rel="stylesheet" href="/static/css/main.css">
<link rel="icon" type="image/png" href="/static/assets/favicon-32x32.png" sizes="32x32" />
<link rel="icon" type="image/png" href="/static/assets/favicon-16x16.png" sizes="16x16" />
</head>

<body>
@@ -8,7 +8,9 @@
<title>Codeframe | A Playground for the Web</title>
<link rel="stylesheet" href="/static/css/main.css">
<link rel="stylesheet" href="/static/css/index.css">
</head>
<link rel="icon" type="image/png" href="/static/assets/favicon-32x32.png" sizes="32x32" />
<link rel="icon" type="image/png" href="/static/assets/favicon-16x16.png" sizes="16x16" />
</head>

<body>
<header>

0 comments on commit 8de4afd

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