Some tweaks and fixes

Fixed typo in migration. Fixed some accessibility stuff. Added footer.
This commit is contained in:
Jonatan Nilsson 2019-09-16 16:47:29 +00:00
parent e4a4330f82
commit 2f9a34ef0a
20 changed files with 167 additions and 15 deletions

View file

@ -4,7 +4,7 @@
display: flex; display: flex;
flex-direction: column; flex-direction: column;
background: $primary-bg; background: $primary-bg;
padding: 0 20px 20px; padding: 0 20px 50px;
} }
.admin-actions { .admin-actions {

View file

@ -240,6 +240,7 @@ table {
} }
@import 'menu/menu'; @import 'menu/menu';
@import 'footer/footer';
@import 'login/login'; @import 'login/login';
@import 'admin/admin'; @import 'admin/admin';
@import 'widgets/common'; @import 'widgets/common';

View file

@ -55,7 +55,7 @@ const Article = {
this.article.media this.article.media
? m('a.cover', { ? m('a.cover', {
href: this.article.media.url, href: this.article.media.url,
}, m('img', { src: this.article.media.medium_url })) }, m('img', { src: this.article.media.medium_url, alt: 'Cover image for ' + this.article.name }))
: null, : null,
this.article.description ? m.trust(this.article.description) : null, this.article.description ? m.trust(this.article.description) : null,
(this.article.files && this.article.files.length (this.article.files && this.article.files.length
@ -76,3 +76,26 @@ const Article = {
} }
module.exports = Article module.exports = Article
/*
<div id="disqus_thread"></div>
<script>
/**
* RECOMMENDED CONFIGURATION VARIABLES: EDIT AND UNCOMMENT THE SECTION BELOW TO INSERT DYNAMIC VALUES FROM YOUR PLATFORM OR CMS.
* LEARN WHY DEFINING THESE VARIABLES IS IMPORTANT: https://disqus.com/admin/universalcode/#configuration-variables*/
/*
var disqus_config = function () {
this.page.url = PAGE_URL; // Replace PAGE_URL with your page's canonical URL variable
this.page.identifier = PAGE_IDENTIFIER; // Replace PAGE_IDENTIFIER with your page's unique identifier variable
};
/
(function() { // DON'T EDIT BELOW THIS LINE
var d = document, s = d.createElement('script');
s.src = 'https://nfp-moe.disqus.com/embed.js';
s.setAttribute('data-timestamp', +new Date());
(d.head || d.body).appendChild(s);
})();
</script>
<noscript>Please enable JavaScript to view the <a href="https://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
*/

View file

@ -1,6 +1,6 @@
article.article { article.article {
background: white; background: white;
padding: 0 0 20px; padding: 0 0 40px;
header { header {
text-align: center; text-align: center;

41
app/footer/footer.js Normal file
View file

@ -0,0 +1,41 @@
const m = require('mithril')
const { Tree } = require('../api/page')
const Authentication = require('../authentication')
const Footer = {
oninit: function(vnode) {
this.year = new Date().getFullYear()
},
view: function() {
console.log(Tree)
return [
m('div.sitemap', [
m('div', 'Sitemap'),
m(m.route.Link, { class: 'root', href: '/' }, 'Home'),
Tree.map(function(page) {
return [
m(m.route.Link, { class: 'root', href: '/page/' + page.path }, page.name),
(page.children.length
? m('ul', page.children.map(function(subpage) {
return m('li', m(m.route.Link, { class: 'child', href: '/page/' + subpage.path }, subpage.name))
}))
: null),
]
}),
!Authentication.currentUser
? m(m.route.Link, { class: 'root', href: '/login' }, 'Login')
: null,
m('div.meta', ['©'
+ this.year
+ ' NFP Encodes - nfp@nfp.moe - ',
m('a', { href: 'https://www.iubenda.com/privacy-policy/31076050', target: '_blank' }, 'Privacy Policy'),
' (Fuck EU)',
])
]),
m('div.footer-logo'),
]
},
}
module.exports = Footer

60
app/footer/footer.scss Normal file
View file

@ -0,0 +1,60 @@
footer {
margin-top: 0px;
border-top: 1px solid $border;
display: flex;
padding: 20px;
background: $border;
.sitemap {
display: flex;
flex: 2 1 auto;
flex-direction: column;
text-align: center;
align-items: center;
font-size: 11px;
font-weight: bold;
a {
text-decoration: none;
color: #8f3c00;
}
a.root {
display: block;
margin: 2px;
padding: 2px 0 0;
}
ul {
margin: 2px 0 0;
display: flex;
padding: 0;
li {
padding: 2px 5px;
list-style-type: disc;
list-style-position: inside;
}
}
}
.footer-logo {
background: url('./img/tsun.png') center no-repeat transparent;
background-size: contain;
width: 119px;
height: 150px;
}
.meta {
flex-grow: 2;
display: flex;
flex-wrap: wrap;
padding-top: 5px;
align-items: flex-end;
text-align: center;
justify-content: center;
a { margin: 0 3px; }
}
}

View file

@ -52,11 +52,25 @@ module.exports = {
}, },
view: function(vnode) { view: function(vnode) {
var bannerPath = ''
if (this.featured && this.featured.banner) {
var deviceWidth = window.innerWidth
var pixelRatio = window.devicePixelRatio || 1
if (deviceWidth < 400 && pixelRatio <= 1) {
bannerPath = this.featured.banner.small_url
} else if ((deviceWidth < 800 && pixelRatio <= 1)
|| (deviceWidth < 600 && pixelRatio > 1)) {
bannerPath = this.featured.banner.medium_url
} else {
bannerPath = this.featured.banner.url
}
}
return [ return [
(this.featured && this.featured.banner (this.featured && this.featured.banner
? m('a.frontpage-banner', { ? m('a.frontpage-banner', {
href: '/article/' + this.featured.path, href: '/article/' + this.featured.path,
style: { 'background-image': 'url("' + this.featured.banner.url + '")' }, style: { 'background-image': 'url("' + bannerPath + '")' },
}, },
this.featured.name this.featured.name
) )

View file

@ -23,7 +23,7 @@ frontpage {
flex-direction: column; flex-direction: column;
align-self: center; align-self: center;
margin: 0 20px; margin: 0 20px;
padding: 0 20px; padding: 0 20px 40px;
width: calc(100% - 40px); width: calc(100% - 40px);
max-width: 1000px; max-width: 1000px;
flex: 2 0 0; flex: 2 0 0;

View file

@ -3,6 +3,7 @@ const m = require('mithril')
m.route.prefix = '' m.route.prefix = ''
const Menu = require('./menu/menu') const Menu = require('./menu/menu')
const Footer = require('./footer/footer')
const Frontpage = require('./frontpage/frontpage') const Frontpage = require('./frontpage/frontpage')
const Login = require('./login/login') const Login = require('./login/login')
const Logout = require('./login/logout') const Logout = require('./login/logout')
@ -17,6 +18,7 @@ const EditStaff = require('./admin/editstaff')
const menuRoot = document.getElementById('nav') const menuRoot = document.getElementById('nav')
const mainRoot = document.getElementById('main') const mainRoot = document.getElementById('main')
const footerRoot = document.getElementById('footer')
m.route(mainRoot, '/', { m.route(mainRoot, '/', {
'/': Frontpage, '/': Frontpage,
@ -32,3 +34,4 @@ m.route(mainRoot, '/', {
'/admin/staff/:id': EditStaff, '/admin/staff/:id': EditStaff,
}) })
m.mount(menuRoot, Menu) m.mount(menuRoot, Menu)
m.mount(footerRoot, Footer)

View file

@ -106,6 +106,7 @@ const Login = {
view: function(vnode) { view: function(vnode) {
return [ return [
m('div.login-wrapper', [ m('div.login-wrapper', [
m('div.login-icon'),
m('article.login', [ m('article.login', [
m('header', [ m('header', [
m('h1', 'NFP.moe login'), m('h1', 'NFP.moe login'),

View file

@ -6,6 +6,15 @@
flex-direction: column; flex-direction: column;
justify-content: center; justify-content: center;
background: $border; background: $border;
padding: 40px 0;
.login-icon {
background: url('./img/login.png') center no-repeat transparent;
background-size: contain;
width: 106px;
height: 130px;
align-self: center;
}
} }
article.login { article.login {

View file

@ -54,9 +54,7 @@ const Menu = {
]) ])
: null : null
), ),
] : [ ] : null),
m(m.route.Link, { href: '/login' }, 'Login'),
]),
]), ]),
m('nav', [ m('nav', [
m(m.route.Link, { m(m.route.Link, {

View file

@ -90,7 +90,7 @@ const Page = {
: null, : null,
this.page.description this.page.description
? m('.fr-view', [ ? m('.fr-view', [
this.page.media ? m('img.page-cover', { src: this.page.media.url } ) : null, this.page.media ? m('img.page-cover', { src: this.page.media.url, alt: 'Cover image for ' + this.page.name } ) : null,
m.trust(this.page.description), m.trust(this.page.description),
this.news.length && this.page.description this.news.length && this.page.description
? m('aside.news', [ ? m('aside.news', [
@ -107,7 +107,7 @@ const Page = {
]) ])
: this.news.length : this.news.length
? m('aside.news.single', [ ? m('aside.news.single', [
this.page.media ? m('img.page-cover', { src: this.page.media.url } ) : null, this.page.media ? m('img.page-cover', { src: this.page.media.url, alt: 'Cover image for ' + this.page.name } ) : null,
m('h4', 'Latest posts under ' + this.page.name + ':'), m('h4', 'Latest posts under ' + this.page.name + ':'),
this.loadingnews ? m('div.loading-spinner') : this.news.map(function(article) { this.loadingnews ? m('div.loading-spinner') : this.news.map(function(article) {
return m(Newsentry, article) return m(Newsentry, article)
@ -118,7 +118,7 @@ const Page = {
}), }),
]) ])
: this.page.media : this.page.media
? m('img.page-cover.single', { src: this.page.media.url } ) ? m('img.page-cover.single', { src: this.page.media.url, alt: 'Cover image for ' + this.page.name } )
: null, : null,
]), ]),
Authentication.currentUser Authentication.currentUser

View file

@ -1,6 +1,6 @@
article.page { article.page {
background: white; background: white;
padding: 0 0 20px; padding: 0 0 40px;
header { header {
text-align: center; text-align: center;

View file

@ -17,7 +17,7 @@ const Newsentry = {
vnode.attrs.media vnode.attrs.media
? m('a.cover', { ? m('a.cover', {
href: '/article/' + vnode.attrs.path, href: '/article/' + vnode.attrs.path,
}, m('img', { src: vnode.attrs.media.small_url })) }, m('img', { src: vnode.attrs.media.small_url, alt: 'Article image for ' + vnode.attrs.name }))
: m('a.cover.nobg'), : m('a.cover.nobg'),
m('div.entrycontent', [ m('div.entrycontent', [
m('div.title', [ m('div.title', [

View file

@ -3,6 +3,7 @@ const Fileinfo = require('./fileinfo')
const Newsitem = { const Newsitem = {
view: function(vnode) { view: function(vnode) {
var pixelRatio = window.devicePixelRatio || 1
return m('newsitem', [ return m('newsitem', [
m(m.route.Link, m(m.route.Link,
{ href: '/article/' + vnode.attrs.path, class: 'title' }, { href: '/article/' + vnode.attrs.path, class: 'title' },
@ -12,7 +13,7 @@ const Newsitem = {
vnode.attrs.media vnode.attrs.media
? m('a.cover', { ? m('a.cover', {
href: '/article/' + vnode.attrs.path, href: '/article/' + vnode.attrs.path,
}, m('img', { src: vnode.attrs.media.medium_url })) }, m('img', { alt: 'Image for news item ' + vnode.attrs.name, src: pixelRatio > 1 ? vnode.attrs.media.medium_url : vnode.attrs.media.small_url }))
: m('a.cover.nobg'), : m('a.cover.nobg'),
m('div.entrycontent', [ m('div.entrycontent', [
(vnode.attrs.description (vnode.attrs.description

View file

@ -79,7 +79,7 @@ exports.up = function up(knex, Promise) {
}), }),
knex.schema.createTable('files', function(table) { knex.schema.createTable('files', function(table) {
table.increments() table.increments()
table.integer('articdle_id') table.integer('article_id')
.references('articles.id') .references('articles.id')
table.text('filename') table.text('filename')
table.text('filetype') table.text('filetype')

BIN
public/assets/img/login.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

BIN
public/assets/img/tsun.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 88 KiB

View file

@ -13,6 +13,7 @@
<div class="maincontainer"> <div class="maincontainer">
<div id="nav"></div> <div id="nav"></div>
<main id="main"></main> <main id="main"></main>
<footer id="footer"></footer>
</div> </div>
<script type="text/javascript" src="/assets/app.js?v=2"></script> <script type="text/javascript" src="/assets/app.js?v=2"></script>
</body> </body>