diff --git a/main.go b/main.go index 3e1d008d..9ac7089e 100644 --- a/main.go +++ b/main.go @@ -24,6 +24,10 @@ func main() { // CSS app.SetStyle(components.CSS()) + // HTTPS + app.Security.Certificate, _ = ioutil.ReadFile("security/fullchain.pem") + app.Security.Key, _ = ioutil.ReadFile("security/privkey.pem") + // Layout app.Layout = func(ctx *aero.Context, content string) string { return components.Layout(content) diff --git a/pages/anime/anime.js b/pages/anime/anime.js new file mode 100644 index 00000000..9aca2d10 --- /dev/null +++ b/pages/anime/anime.js @@ -0,0 +1 @@ +console.log("Hello Typescript"); diff --git a/pages/profile/profile.scarlet b/pages/profile/profile.scarlet index da4b6647..7f632ac2 100644 --- a/pages/profile/profile.scarlet +++ b/pages/profile/profile.scarlet @@ -6,7 +6,7 @@ profile-boot-duration = 2s position relative left calc(content-padding * -1) - top calc(content-padding * -1) + top calc(content-padding-top * -1) min-width calc(100% + content-padding * 2) padding calc(content-padding * 2) diff --git a/run.sh b/run.sh deleted file mode 100755 index 3bbaf011..00000000 --- a/run.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -pack && go build && ./notify.moe diff --git a/scripts/admin.ts b/scripts/admin.ts deleted file mode 100644 index 089a0404..00000000 --- a/scripts/admin.ts +++ /dev/null @@ -1,12 +0,0 @@ -document.addEventListener('keydown', e => { - // Alt + A = Staff info - if(e.keyCode === 65 && e.altKey) { - let staffInfo = $('staff-info') - - if(staffInfo.style.display !== 'block') { - staffInfo.style.display = 'block' - } else { - staffInfo.style.display = 'none' - } - } -}) \ No newline at end of file diff --git a/scripts/aqua.ts b/scripts/aqua.ts deleted file mode 100644 index d57fd596..00000000 --- a/scripts/aqua.ts +++ /dev/null @@ -1,21 +0,0 @@ -function find(id: string) { - return document.getElementById(id) -} - -function get(url: string, body?: Object): Promise { - return new Promise(function(resolve, reject) { - resolve("") - }) -} - -function post(url: string, body?: Object): Promise { - return new Promise(function(resolve, reject) { - resolve("") - }) -} - -export { - find, - get, - post -} \ No newline at end of file diff --git a/scripts/avatars.ts b/scripts/avatars.ts deleted file mode 100644 index 0a7ef545..00000000 --- a/scripts/avatars.ts +++ /dev/null @@ -1,31 +0,0 @@ -$.updateAvatars = function() { - let images = document.querySelectorAll('.user-image') - - for(let i = 0; i < images.length; ++i) { - let img = images[i] - - if(img.naturalWidth === 0) { - img.onload = function() { - this.style.opacity = '1.0' - } - - img.onerror = function() { - this.src = '/images/elements/no-gravatar.svg' - this.style.opacity = '1.0' - } - } else { - img.style.opacity = '1.0' - } - } - - // Tooltips - // let links = document.querySelectorAll('.user') - // - // for(let i = 0; i < links.length; ++i) { - // let link = links[i] - // - // link.classList.add('tooltip') - // link.setAttribute('data-tooltip', link.title) - // link.title = '' - // } -} \ No newline at end of file diff --git a/scripts/init.ts b/scripts/init.ts new file mode 100644 index 00000000..b8c57fe7 --- /dev/null +++ b/scripts/init.ts @@ -0,0 +1 @@ +console.log("Hello World") \ No newline at end of file diff --git a/scripts/main.ts b/scripts/main.ts deleted file mode 100644 index 5eebba08..00000000 --- a/scripts/main.ts +++ /dev/null @@ -1,10 +0,0 @@ -// Fix Facebook login hash in URL -if(window.location.hash && window.location.hash === '#_=_') { - window.history.pushState('', document.title, window.location.pathname) -} - -// Fade out loading animation -document.addEventListener('DOMContentLoaded', function(event) { - $.loadingAnimation.classList.add('fade-out') - $.updateAvatars() -}) \ No newline at end of file diff --git a/scripts/posts.ts b/scripts/posts.ts deleted file mode 100644 index f5f8f539..00000000 --- a/scripts/posts.ts +++ /dev/null @@ -1,46 +0,0 @@ -import * as $ from './aqua' - -function like(type, id) { - $.post(`/api/${type}/like/` + id) - $.find('like-' + id).style.display = 'none' - $.find('unlike-' + id).style.display = 'inline-block' - - let likes = $.find('likes-' + id) - likes.innerHTML = (parseInt(likes.textContent) + 1).toString() -} - -function unlike(type, id) { - $.post(`/api/${type}/unlike/` + id) - $.find('like-' + id).style.display = 'inline-block' - $.find('unlike-' + id).style.display = 'none' - - let likes = $.find('likes-' + id) - likes.innerHTML = (parseInt(likes.textContent) - 1).toString() -} - -function edit(id) { - $.find('source-' + id).style.display = 'block' - $.find('save-' + id).style.display = 'block' - $.find('render-' + id).style.display = 'none' - $.find('toolbar-' + id).style.display = 'none' -} - -function cancelEdit(id) { - $.find('source-' + id).style.display = 'none' - $.find('save-' + id).style.display = 'none' - $.find('render-' + id).style.display = '' - $.find('toolbar-' + id).style.display = '' -} - -function saveEdit(type, id) { - let source = $.find('source-' + id) - let text = source.value - - $.post(`/api/${type}/edit/` + id, { - id, - text - }).then(response => { - $.find('render-' + id).innerHTML = response - cancelEdit(id) - }) -} \ No newline at end of file diff --git a/scripts/push-notifications.ts b/scripts/push-notifications.ts deleted file mode 100644 index 34c21240..00000000 --- a/scripts/push-notifications.ts +++ /dev/null @@ -1,204 +0,0 @@ -var isPushEnabled = false - -declare var ServiceWorkerRegistration: any -declare var Notification: any -interface Navigator { - serviceWorker: any -} - -function subscribeOnServer(subscription) { - console.log('Send subscription to server...') - console.log(subscription) - - $.post('/api/notifications/subscribe', subscription).then(function(response) { - console.log(response) - }) -} - -function unsubscribeOnServer(subscription) { - console.log('Send unsubscription to server...') - console.log(subscription) - - $.post('/api/notifications/unsubscribe', subscription).then(function(response) { - console.log(response) - }) -} - -function sendTestNotification() { - console.log('Sending test notification...') - - $.get('/api/notifications/test').then(function(response) { - // ... - }) -} - -function subscribe() { - // Disable the button so it can't be changed while - // we process the permission request - let pushButton = document.querySelector('.push-button') - - if(pushButton) - pushButton.disabled = true - - navigator.serviceWorker.ready.then(function(serviceWorkerRegistration) { - serviceWorkerRegistration.pushManager.subscribe({ - userVisibleOnly: true - // applicationServerKey: new TextEncoder('binary').encode('BLxjquZGLvRnYGkV_xlkuAIilZzHJLDdGUZAmvq4pqev5uQHBmYRxJqfbFQFQn2kYfe5SRBwiNfuiakHn-3KR_k') - }).then(function(subscription) { - // The subscription was successful - isPushEnabled = true - if(pushButton) { - pushButton.textContent = 'Disable Notifications' - pushButton.disabled = false - } - - let testButton = document.querySelector('.test-notification') - - if(testButton) - testButton.disabled = false - - // TODO: Send the subscription.endpoint to your server - // and save it to send a push message at a later date - return subscribeOnServer(subscription) - }).catch(function(e) { - if(Notification.permission === 'denied') { - // The user denied the notification permission which - // means we failed to subscribe and the user will need - // to manually change the notification permission to - // subscribe to push messages - console.warn('Permission for Notifications was denied') - if(pushButton) - pushButton.disabled = true - } else { - // A problem occurred with the subscription common reasons - // include network errors, and lacking gcm_sender_id and/or - // gcm_user_visible_only in the manifest. - console.error('Unable to subscribe to push.', e) - if(pushButton) { - pushButton.disabled = false - pushButton.textContent = 'Enable Notifications' - } - } - }) - }) -} - -function unsubscribe() { - let pushButton = document.querySelector('.push-button') - - if(pushButton) - pushButton.disabled = true - - let testButton = document.querySelector('.test-notification') - - if(testButton) - testButton.disabled = true - - navigator.serviceWorker.ready.then(function(serviceWorkerRegistration) { - // To unsubscribe from push messaging, you need get the - // subscription object, which you can call unsubscribe() on. - serviceWorkerRegistration.pushManager.getSubscription().then(function(pushSubscription) { - // Check we have a subscription to unsubscribe - if(!pushSubscription) { - // No subscription object, so set the state - // to allow the user to subscribe to push - isPushEnabled = false - if(pushButton) { - pushButton.disabled = false - pushButton.textContent = 'Enable Notifications' - } - return - } - - unsubscribeOnServer(pushSubscription) - - // We have a subscription, so call unsubscribe on it - pushSubscription.unsubscribe().then(function(successful) { - if(pushButton) { - pushButton.disabled = false - pushButton.textContent = 'Enable Notifications' - } - isPushEnabled = false - }).catch(function(e) { - // We failed to unsubscribe, this can lead to - // an unusual state, so may be best to remove - // the users data from your data store and - // inform the user that you have done so - - console.log('Unsubscription error: ', e) - if(pushButton) { - pushButton.disabled = false - pushButton.textContent = 'Enable Notifications' - } - }) - }).catch(function(e) { - console.error('Error thrown while unsubscribing from push messaging.', e) - }) - }) -} - -// Once the service worker is registered set the initial state -function initialiseState(registration) { - console.log('Initialise state...') - console.log('Scope:', registration.scope) - - // Are Notifications supported in the service worker? - if(!('showNotification' in ServiceWorkerRegistration.prototype)) { - console.warn('Notifications aren\'t supported.') - return - } - - // Check the current Notification permission. - // If its denied, it's a permanent block until the - // user changes the permission - if(Notification.permission === 'denied') { - console.warn('The user has blocked notifications.') - return - } - - // Check if push messaging is supported - if(!('PushManager' in window)) { - console.warn('Push messaging isn\'t supported.') - return - } - - // We need the service worker registration to check for a subscription - navigator.serviceWorker.ready.then(function(serviceWorkerRegistration) { - console.log('Get subscription...') - - // Do we already have a push message subscription? - serviceWorkerRegistration.pushManager.getSubscription().then(function(subscription) { - console.log('Enable Push UI...') - - // Enable any UI which subscribes / unsubscribes from - // push messages. - let pushButton = document.querySelector('.push-button') - - if(pushButton) - pushButton.disabled = false - - if(!subscription) { - // We aren't subscribed to push, so set UI - // to allow the user to enable push - return - } - - // Keep your server in sync with the latest subscriptionId - subscribeOnServer(subscription) - - // Set your UI to show they have subscribed for - // push messages - if(pushButton) - pushButton.textContent = 'Disable Notifications' - isPushEnabled = true - - // Enable test notifications - let testButton = document.querySelector('.test-notification') - - if(testButton) - testButton.disabled = false - }).catch(function(err) { - console.warn('Error during getSubscription()', err) - }) - }) -} \ No newline at end of file diff --git a/scripts/save-on-change.ts b/scripts/save-on-change.ts deleted file mode 100644 index 5b0cf822..00000000 --- a/scripts/save-on-change.ts +++ /dev/null @@ -1,61 +0,0 @@ -function makeSaveable(apiEndpoint: string, postSaveCallback?: (string, any) => void) { - $.save = function(e) { - var item = e.target; - - if($.saving) - return; - - $.saving = true; - - var key = item.id; - var value = item.value ? item.value : ''; - var old = item.dataset.old ? item.dataset.old : ''; - - item.classList.add('saving'); - $.content.style.cursor = 'wait'; - - $.post(apiEndpoint, { - function: 'save', - key: key, - value: value, - old: old - }).then(function(response) { - if(postSaveCallback) - postSaveCallback(key, response); - }).catch(function(error) { - console.error(error); - }).then(function() { - $.get('/_' + location.pathname).then(function(newPageCode) { - var focusedElementId = document.activeElement.id; - var focusedElementValue = ( document.activeElement).value; - - $.setContent(newPageCode); - - // Re-focus previously selected element - if(focusedElementId) { - var focusedElement = $(focusedElementId); - - if(focusedElement) { - focusedElement.value = focusedElementValue; - - if(focusedElement.select) - focusedElement.select(); - else if(focusedElement.focus) - focusedElement.focus(); - } - } - - $.content.style.cursor = 'auto'; - $.saving = false; - }); - }); - }; - - var myNodeList = document.querySelectorAll('.save-on-change'); - - for(var i = 0; i < myNodeList.length; ++i) { - var element = myNodeList[i]; - element.onchange = $.save; - element.dataset['old'] = element.value; - } -} \ No newline at end of file diff --git a/styles/base.scarlet b/styles/base.scarlet index 05f76101..6dd9d375 100644 --- a/styles/base.scarlet +++ b/styles/base.scarlet @@ -30,5 +30,8 @@ strong em font-style italic +img + backface-visibility hidden + .spacer flex 1 \ No newline at end of file diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 00000000..e8500a16 --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,10 @@ +{ + "compilerOptions": { + "target": "es6", + "module": "commonjs", + "moduleResolution": "node", + "baseUrl": "./" + }, + "compileOnSave": true, + "buildOnSave": false +} \ No newline at end of file