main #8
6 changed files with 84 additions and 28 deletions
|
@ -1,5 +1,11 @@
|
||||||
const ntfyInput = document.getElementById("ntfy-input");
|
const ntfyMessage = document.getElementById("ntfy-message");
|
||||||
const ntfyButton = document.getElementById("ntfy-send");
|
const ntfyTitle = document.getElementById("ntfy-title");
|
||||||
|
const ntfyTags = document.getElementById("ntfy-tags");
|
||||||
|
const ntfyAttach = document.getElementById("ntfy-attach");
|
||||||
|
const ntfyClickAction = document.getElementById("ntfy-click");
|
||||||
|
const ntfyButton = document.getElementById("ntfy-button");
|
||||||
|
|
||||||
|
const msgPFX = "message: "
|
||||||
|
|
||||||
// Random placeholder
|
// Random placeholder
|
||||||
|
|
||||||
|
@ -7,56 +13,64 @@ function getPlaceholder() {
|
||||||
placeholderSelector = Math.floor(Math.random() * 8) + 1;
|
placeholderSelector = Math.floor(Math.random() * 8) + 1;
|
||||||
switch (placeholderSelector) {
|
switch (placeholderSelector) {
|
||||||
case 1:
|
case 1:
|
||||||
ntfyInput.placeholder = "hi nelle! (。>﹏<。)";
|
ntfyMessage.placeholder = `${msgPFX}hi nelle! (。>﹏<。)`;
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
ntfyInput.placeholder = "(╹◡╹)凸";
|
ntfyMessage.placeholder = `${msgPFX}(╹◡╹)凸`;
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
ntfyInput.placeholder = "Confession of sin: I dont like SciAdv";
|
ntfyMessage.placeholder = `${msgPFX}Confession of sin: I dont like SciAdv`;
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
ntfyInput.placeholder = "Knock Knock...";
|
ntfyMessage.placeholder = `${msgPFX}Knock Knock...`;
|
||||||
break;
|
break;
|
||||||
case 5:
|
case 5:
|
||||||
ntfyInput.placeholder = "El. Psy. Kongroo.";
|
ntfyMessage.placeholder = `${msgPFX}El. Psy. Kongroo.`;
|
||||||
break;
|
break;
|
||||||
case 6:
|
case 6:
|
||||||
ntfyInput.placeholder = "the organization is after you.";
|
ntfyMessage.placeholder = `${msgPFX}the organization is after you.`;
|
||||||
break;
|
break;
|
||||||
case 7:
|
case 7:
|
||||||
ntfyInput.placeholder =
|
ntfyMessage.placeholder =
|
||||||
"you wouldnt happen to know where an IBN5100 is, would you?";
|
`${msgPFX}you wouldnt happen to know where an IBN5100 is, would you?`;
|
||||||
break;
|
break;
|
||||||
case 8:
|
case 8:
|
||||||
ntfyInput.placeholder =
|
ntfyMessage.placeholder =
|
||||||
"if you had to choose, between: bacon, unlimited bacon, but no games. or. games. unlimited games, but no games. which would you pick?";
|
`${msgPFX}if you had to choose, between: bacon, unlimited bacon, but no games. or. games. unlimited games, but no games. which would you pick?`;
|
||||||
break;
|
break;
|
||||||
case 9:
|
case 9:
|
||||||
ntfyInput.placeholder = "time travel?";
|
ntfyMessage.placeholder = `${msgPFX}time travel?`;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
ntfyInput.placeholder = "type some words and hit send";
|
ntfyMessage.placeholder = `${msgPFX}type some words and hit send`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// send function
|
// send function
|
||||||
function send(message) {
|
function send(message, title, tags, attachment, click) {
|
||||||
const r = new XMLHttpRequest();
|
const r = new XMLHttpRequest();
|
||||||
r.open("POST", "https://ntfy.ouroboros.group/beep", true);
|
r.open("POST", "https://ntfy.ouroboros.group/beep", true);
|
||||||
r.setRequestHeader("Content-Type", "text/plain");
|
r.setRequestHeader("Content-Type", "text/plain");
|
||||||
|
r.setRequestHeader("Title", title);
|
||||||
|
r.setRequestHeader("Tags", tags);
|
||||||
|
r.setRequestHeader("Attach", attachment);
|
||||||
|
r.setRequestHeader("Click", click);
|
||||||
r.send(message);
|
r.send(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
// send notification
|
// send notification
|
||||||
function sendNotification() {
|
function sendNotification() {
|
||||||
send(ntfyInput.value);
|
send(ntfyTitle.value, ntfyMessage.value, ntfyTags.value, ntfyAttach.value, ntfyClickAction.value);
|
||||||
ntfyInput.value = "";
|
ntfyTitle.value = "";
|
||||||
|
ntfyTags.value = "";
|
||||||
|
ntfyAttach.value = "";
|
||||||
|
ntfyClickAction.value = "";
|
||||||
|
ntfyMessage.value = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
// on send button click
|
// on send button click
|
||||||
async function ntfyClick() {
|
async function ntfyClick() {
|
||||||
if (!ntfyInput.value.replace(/\s/g, "").length) {
|
if (!ntfyMessage.value.replace(/\s/g, "").length) {
|
||||||
ntfyButton.innerHTML = "<span>ಠ﹏ಠ</span>";
|
ntfyButton.innerHTML = "<span>ಠ﹏ಠ</span>";
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
ntfyButton.innerHTML = "<span>Send</span>";
|
ntfyButton.innerHTML = "<span>Send</span>";
|
||||||
|
|
|
@ -20,15 +20,21 @@
|
||||||
</small>
|
</small>
|
||||||
<br>
|
<br>
|
||||||
<br>
|
<br>
|
||||||
<div class="ntfyForm">
|
|
||||||
<textarea id="ntfy-input" placeholder="type some words and hit send" rows=2></textarea>
|
<textarea id="ntfy-title" placeholder="title" rows=1 style="resize: none;"></textarea>
|
||||||
|
<textarea id="ntfy-message" placeholder="message" rows=2></textarea>
|
||||||
|
<textarea id="ntfy-tags" placeholder="tags" rows=1 style="resize: none;"></textarea>
|
||||||
|
<textarea id="ntfy-attach" placeholder="attachment link" rows=1 style="resize: none;"></textarea>
|
||||||
|
<textarea id="ntfy-click" placeholder="click link" rows=1 style="resize: none;"></textarea>
|
||||||
|
<br>
|
||||||
<button
|
<button
|
||||||
class="custom-btn btn-1"
|
class="custom-btn btn-1"
|
||||||
|
style="width: 42%;"
|
||||||
onclick="ntfyClick()"
|
onclick="ntfyClick()"
|
||||||
id="ntfy-send">
|
id="ntfy-button">
|
||||||
<span>Send</span>
|
<span>Send</span>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
<br>
|
||||||
<small>if it doesnt seem to be working, or you have javascript disabled, <br>you can POST to <span class="glitch">https://ntfy.ouroboros.group/beep</span>.</small>
|
<small>if it doesnt seem to be working, or you have javascript disabled, <br>you can POST to <span class="glitch">https://ntfy.ouroboros.group/beep</span>.</small>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
|
@ -35,6 +35,11 @@ dependencies {
|
||||||
implementation("io.ktor:ktor-server-netty-jvm")
|
implementation("io.ktor:ktor-server-netty-jvm")
|
||||||
implementation("ch.qos.logback:logback-classic:$logback_version")
|
implementation("ch.qos.logback:logback-classic:$logback_version")
|
||||||
implementation("io.ktor:ktor-server-config-yaml")
|
implementation("io.ktor:ktor-server-config-yaml")
|
||||||
|
implementation("org.jetbrains.kotlin:kotlin-stdlib:2.0.0")
|
||||||
|
implementation("io.ktor:ktor-client-core:$ktor_version")
|
||||||
|
implementation("io.ktor:ktor-client-cio:$ktor_version")
|
||||||
|
implementation("io.ktor:ktor-client-auth:$ktor_version")
|
||||||
|
implementation("io.ktor:ktor-client-content-negotiation:$ktor_version")
|
||||||
}
|
}
|
||||||
|
|
||||||
kotlin {
|
kotlin {
|
||||||
|
|
|
@ -1,11 +1,19 @@
|
||||||
package observer.nelle
|
package observer.nelle
|
||||||
|
|
||||||
|
import io.ktor.client.*
|
||||||
|
import io.ktor.client.engine.cio.*
|
||||||
|
import io.ktor.client.plugins.auth.*
|
||||||
|
import io.ktor.client.plugins.auth.providers.*
|
||||||
import io.ktor.server.application.*
|
import io.ktor.server.application.*
|
||||||
|
import kotlinx.coroutines.runBlocking
|
||||||
|
import observer.nelle.api.sendMessage
|
||||||
import observer.nelle.plugins.configureRouting
|
import observer.nelle.plugins.configureRouting
|
||||||
import observer.nelle.plugins.configureSecurity
|
import observer.nelle.plugins.configureSecurity
|
||||||
import observer.nelle.plugins.configureTemplating
|
import observer.nelle.plugins.configureTemplating
|
||||||
|
|
||||||
fun main(args: Array<String>) {
|
fun main(args: Array<String>) {
|
||||||
|
|
||||||
|
|
||||||
io.ktor.server.netty.EngineMain.main(args)
|
io.ktor.server.netty.EngineMain.main(args)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
23
ktor/src/main/kotlin/api/ntfy.kt
Normal file
23
ktor/src/main/kotlin/api/ntfy.kt
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
package observer.nelle.api
|
||||||
|
|
||||||
|
import io.ktor.client.*
|
||||||
|
import io.ktor.client.call.*
|
||||||
|
import io.ktor.client.request.*
|
||||||
|
import io.ktor.client.request.forms.*
|
||||||
|
import io.ktor.client.statement.*
|
||||||
|
import io.ktor.http.*
|
||||||
|
|
||||||
|
suspend fun sendMessage(client: HttpClient, title: String, tags: String, attachment: String, click: String, messageText: String) {
|
||||||
|
// Fetch posts from the Home timeline, amount of posts configurable
|
||||||
|
val sendMessage: HttpResponse = client.post("https://ntfy.ouroboros.group/beep") {
|
||||||
|
headers {
|
||||||
|
append(HttpHeaders.ContentType, "text/html")
|
||||||
|
append("Title", title)
|
||||||
|
append("Tags", tags)
|
||||||
|
append("Attach", attachment)
|
||||||
|
append("Click", click)
|
||||||
|
}
|
||||||
|
setBody(messageText)
|
||||||
|
}
|
||||||
|
println(sendMessage.status)
|
||||||
|
}
|
|
@ -21,6 +21,6 @@ fun Application.configureRouting() {/*
|
||||||
|
|
||||||
routing {
|
routing {
|
||||||
// Set a static resource path 'resources/content/' to be served
|
// Set a static resource path 'resources/content/' to be served
|
||||||
staticFiles("/", File("static"))
|
staticResources("/", "static")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue