diff --git a/scripts/build-frontend.js b/scripts/build-frontend.js
index 3da863c..2fcfb84 100644
--- a/scripts/build-frontend.js
+++ b/scripts/build-frontend.js
@@ -1,7 +1,9 @@
'use strict';
-const glob = require('glob');
const fs = require('fs');
+const glob = require('glob');
+const path = require('path');
+const util = require('util');
function getConfig() {
const ini = require('ini');
@@ -36,18 +38,35 @@ function getConfig() {
return config;
}
-function bundleHtml() {
+function bundleHtml(config) {
const minify = require('html-minifier').minify;
- const html = fs.readFileSync('./static/html/index.htm', 'utf-8');
- fs.writeFileSync(
- './public/index.htm',
- minify(html, {removeComments: true, collapseWhitespace: true}));
- console.info('Bundled HTML');
+ const baseHtml = fs.readFileSync('./static/html/index.htm', 'utf-8');
+ glob('static/html/**/*.tpl', {}, (er, files) => {
+ let templatesHtml = '';
+ for (const file of files) {
+ templatesHtml += util.format(
+ '%s',
+ path.basename(file, '.tpl').replace('_', '-'),
+ fs.readFileSync(file));
+ }
+
+ const finalHtml = baseHtml
+ .replace(/(<\/head>)/, templatesHtml + '$1')
+ .replace(
+ /(
)(.*)(<\/title>)/,
+ util.format('$1%s$3', config.basic.name));
+
+ fs.writeFileSync(
+ './public/index.htm',
+ minify(
+ finalHtml, {removeComments: true, collapseWhitespace: true}));
+ console.info('Bundled HTML');
+ });
}
function bundleCss() {
const minify = require('cssmin');
- glob('static/**/*.css', {}, (er, files) => {
+ glob('static/css/**/*.css', {}, (er, files) => {
let css = '';
for (const file of files) {
css += fs.readFileSync(file);
@@ -78,6 +97,6 @@ function bundleConfig(config) {
const config = getConfig();
bundleConfig(config);
-bundleHtml();
+bundleHtml(config);
bundleCss();
bundleJs();
diff --git a/static/html/index.htm b/static/html/index.htm
index 543d50c..81c1043 100644
--- a/static/html/index.htm
+++ b/static/html/index.htm
@@ -1,71 +1,15 @@
- szurubooru
+
-
-
-
-
-
-
-
-
Registration
-
-
-
-
Registered users can:
-
- - upload new posts
- - mark them as favorite
- - add comments
- - vote up/down on posts and comments
-
-
Your e-mail will be used to show your Gravatar and for password reminders only. Leave blank for random Gravatar.
-
-
-
-
-
+
diff --git a/static/html/top_navigation.tpl b/static/html/top_navigation.tpl
new file mode 100644
index 0000000..92da560
--- /dev/null
+++ b/static/html/top_navigation.tpl
@@ -0,0 +1,11 @@
+
diff --git a/static/html/user_registration.tpl b/static/html/user_registration.tpl
new file mode 100644
index 0000000..5f992cd
--- /dev/null
+++ b/static/html/user_registration.tpl
@@ -0,0 +1,38 @@
+
+
Registration
+
+
+
+
Registered users can:
+
+ - upload new posts
+ - mark them as favorite
+ - add comments
+ - vote up/down on posts and comments
+
+
Your e-mail will be used to show your Gravatar and for password reminders only. Leave blank for random Gravatar.
+
+
diff --git a/static/js/views/top_navigation_view.js b/static/js/views/top_navigation_view.js
index e7a6d0e..45c440d 100644
--- a/static/js/views/top_navigation_view.js
+++ b/static/js/views/top_navigation_view.js
@@ -5,7 +5,7 @@ const BaseView = require('./base_view.js');
class TopNavigationView extends BaseView {
constructor(handlebars) {
super(handlebars);
- this.template = this.getTemplate('top-nav-template');
+ this.template = this.getTemplate('top-navigation-template');
this.navHolder = document.getElementById('top-nav-holder');
}