2019-02-20 16:10:37 +00:00
|
|
|
const m = require('mithril')
|
2022-08-05 14:26:29 +00:00
|
|
|
const Authentication = require('./authentication')
|
|
|
|
const AdminResolver = require('./admin_loader')
|
|
|
|
const Header = require('./header')
|
|
|
|
const Footer = require('./footer')
|
|
|
|
const Login = require('./site_login')
|
|
|
|
const SitePage = require('./site_page')
|
|
|
|
const SiteArticle = require('./site_article')
|
2019-10-01 03:45:44 +00:00
|
|
|
window.m = m
|
2019-02-20 16:10:37 +00:00
|
|
|
|
2019-10-02 17:55:00 +00:00
|
|
|
m.route.setOrig = m.route.set
|
|
|
|
m.route.set = function(path, data, options){
|
|
|
|
m.route.setOrig(path, data, options)
|
|
|
|
window.scrollTo(0, 0)
|
|
|
|
}
|
|
|
|
|
|
|
|
m.route.linkOrig = m.route.link
|
|
|
|
m.route.link = function(vnode){
|
|
|
|
m.route.linkOrig(vnode)
|
|
|
|
window.scrollTo(0, 0)
|
|
|
|
}
|
|
|
|
|
2019-10-01 17:18:20 +00:00
|
|
|
m.route.prefix = ''
|
|
|
|
|
|
|
|
const allRoutes = {
|
2022-08-05 14:26:29 +00:00
|
|
|
'/': SitePage, // Frontpage
|
2019-10-01 17:18:20 +00:00
|
|
|
'/login': Login,
|
2022-08-05 14:26:29 +00:00
|
|
|
'/page/:id': SitePage,
|
|
|
|
'/article/:id': SiteArticle,
|
2019-10-01 17:18:20 +00:00
|
|
|
'/admin/:path': AdminResolver,
|
|
|
|
'/admin/:path/:id': AdminResolver,
|
|
|
|
}
|
|
|
|
|
2021-01-05 19:12:10 +00:00
|
|
|
// Wait until we finish checking avif support, some views render immediately and will ask for this immediately before the callback gets called.
|
|
|
|
|
|
|
|
/*
|
|
|
|
* imgsupport.js from leechy/imgsupport
|
|
|
|
*/
|
|
|
|
const AVIF = new Image();
|
|
|
|
AVIF.onload = AVIF.onerror = function () {
|
|
|
|
window.supportsavif = (AVIF.height === 2)
|
|
|
|
document.body.className = document.body.className + ' ' + (window.supportsavif ? 'avifsupport' : 'jpegonly')
|
|
|
|
|
2022-08-05 14:26:29 +00:00
|
|
|
m.mount(document.getElementById('header'), Header)
|
|
|
|
m.route(document.getElementById('main'), '/', allRoutes)
|
|
|
|
m.mount(document.getElementById('footer'), Footer)
|
2021-01-05 19:12:10 +00:00
|
|
|
}
|
|
|
|
AVIF.src = 'data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAAB0AAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAIAAAACAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQ0MAAAAABNjb2xybmNseAACAAIAAYAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAACVtZGF0EgAKCBgANogQEAwgMg8f8D///8WfhwB8+ErK42A=';
|