From e5f5fb1038f40c17e97c2ad98d2c59f288eb3350 Mon Sep 17 00:00:00 2001 From: Bobby Wibowo Date: Tue, 24 Apr 2018 02:58:44 +0700 Subject: [PATCH] Updates * You can now disable using icons in home's footer links by setting "home_icons" to false in _globals.njk. * Renamed "meta" block to "opengraph" in _layout.njk, since the block only represents opengraph tags anyways. * Moved noscript warning to its own file at views/_partial/noscript.njk. It's also now being included in dashboard and auth pages. * No-JS uploader will no longer use icons in its footer links. It will also no longer load fontello.css. * Updated static files' version string in _globals.njk. * Some other tweaks, mainly to get no-icons mode to work properly. --- database/db.js | 2 +- public/css/home.css | 5 +++++ views/_globals.njk | 9 ++++++--- views/_layout.njk | 3 ++- views/_partial/links.njk | 13 +++++++++---- views/_partial/noscript.njk | 18 ++++++++++++++++++ views/album.njk | 2 +- views/auth.njk | 2 ++ views/dashboard.njk | 2 ++ views/home.njk | 12 +----------- views/nojs.njk | 2 +- 11 files changed, 48 insertions(+), 22 deletions(-) create mode 100644 views/_partial/noscript.njk diff --git a/database/db.js b/database/db.js index 23ddd4b..2a1a14a 100644 --- a/database/db.js +++ b/database/db.js @@ -42,7 +42,7 @@ const init = function (db) { table.integer('enabled') table.integer('timestamp') }).then(() => { - db.table('users').where({username: 'root'}).then((user) => { + db.table('users').where({ username: 'root' }).then((user) => { if (user.length > 0) { return } require('bcrypt').hash('root', 10, function (error, hash) { diff --git a/public/css/home.css b/public/css/home.css index 8c329c5..5ccc1fd 100644 --- a/public/css/home.css +++ b/public/css/home.css @@ -161,3 +161,8 @@ img[data-dz-thumbnail] { padding-left: 0.25rem; padding-right: 0.25rem; } + +#linksColumn>span { + padding: 0 0.3rem; + color: #7f8c8d; +} diff --git a/views/_globals.njk b/views/_globals.njk index e943356..2e8e82b 100644 --- a/views/_globals.njk +++ b/views/_globals.njk @@ -7,14 +7,17 @@ {% set home_subtitle = "A modern self-hosted file upload service" %} {# - This will be appended to all CSS and JS files, and should be changed on every updates to make sure clients load the very latest version of them. + This will be appended to all CSS and JS files, + and should be changed on every updates to make sure clients load the very latest version of them. #} -{% set v = "hEmd7tjh6Q" %} +{% set v = "8HSPG0eoRX" %} {# These will be the links in the homepage and the No-JS uploader. - You may remove icons by removing "icon" property. It will then automatically use "attrs.title" as the display text. + You may remove icons by changing "home_icons" to false. + It will then automatically use "attrs.title" as the display text. #} +{% set home_icons = true %} {% set home_links = [ { attrs: { diff --git a/views/_layout.njk b/views/_layout.njk index be37d6c..4fcd550 100644 --- a/views/_layout.njk +++ b/views/_layout.njk @@ -15,7 +15,7 @@ {% endblock %} - {% block meta %} + {% block opengraph %} @@ -51,6 +51,7 @@ {% block content %}{% endblock %} + {% block scripts %} {% endblock %} diff --git a/views/_partial/links.njk b/views/_partial/links.njk index 517ee3f..6dc0478 100644 --- a/views/_partial/links.njk +++ b/views/_partial/links.njk @@ -1,3 +1,7 @@ +{% if plain_links or not globals.home_icons %} +{% set separator = (joiner('|')) %} +{% endif %} + {% macro attrs(obj) %} {% set space = joiner(' ') %} {% for id, val in obj -%} @@ -8,16 +12,17 @@
-
+
{% for link in globals.home_links -%} + {{ (separator() | safe) if separator }} diff --git a/views/_partial/noscript.njk b/views/_partial/noscript.njk new file mode 100644 index 0000000..a285f0a --- /dev/null +++ b/views/_partial/noscript.njk @@ -0,0 +1,18 @@ +{# + I thought of making a redirect with http-equiv="refresh", but it's too quick that people + barely have any time to read the message which explains why the redirect is necessary. + So yeah, I decided to stick with making people click on the link which leads to + the No-JS uploader, if they really want to use the service. +#} + + diff --git a/views/album.njk b/views/album.njk index dd28e26..b1880fd 100644 --- a/views/album.njk +++ b/views/album.njk @@ -15,7 +15,7 @@ {% endblock %} -{% block meta %} +{% block opengraph %} diff --git a/views/auth.njk b/views/auth.njk index 1eb7de3..e5928c3 100644 --- a/views/auth.njk +++ b/views/auth.njk @@ -61,4 +61,6 @@
+ +{% include "_partial/noscript.njk" %} {% endblock %} diff --git a/views/dashboard.njk b/views/dashboard.njk index 1178623..1336626 100644 --- a/views/dashboard.njk +++ b/views/dashboard.njk @@ -96,4 +96,6 @@
+ +{% include "_partial/noscript.njk" %} {% endblock %} diff --git a/views/home.njk b/views/home.njk index 89514d4..dda9307 100644 --- a/views/home.njk +++ b/views/home.njk @@ -77,15 +77,5 @@ - +{% include "_partial/noscript.njk" %} {% endblock %} diff --git a/views/nojs.njk b/views/nojs.njk index 0e5734d..08d63f1 100644 --- a/views/nojs.njk +++ b/views/nojs.njk @@ -2,7 +2,6 @@ {% block stylesheets %} {{ super() }} - {% endblock %} @@ -68,6 +67,7 @@ {%- endif %} + {% set plain_links = true %} {% include "_partial/links.njk" %}