more ntfy options!
This commit is contained in:
parent
fa7d3bd2b7
commit
8c04183bfe
6 changed files with 84 additions and 28 deletions
|
@ -1,5 +1,11 @@
|
|||
const ntfyInput = document.getElementById("ntfy-input");
|
||||
const ntfyButton = document.getElementById("ntfy-send");
|
||||
const ntfyMessage = document.getElementById("ntfy-message");
|
||||
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
|
||||
|
||||
|
@ -7,56 +13,64 @@ function getPlaceholder() {
|
|||
placeholderSelector = Math.floor(Math.random() * 8) + 1;
|
||||
switch (placeholderSelector) {
|
||||
case 1:
|
||||
ntfyInput.placeholder = "hi nelle! (。>﹏<。)";
|
||||
ntfyMessage.placeholder = `${msgPFX}hi nelle! (。>﹏<。)`;
|
||||
break;
|
||||
case 2:
|
||||
ntfyInput.placeholder = "(╹◡╹)凸";
|
||||
ntfyMessage.placeholder = `${msgPFX}(╹◡╹)凸`;
|
||||
break;
|
||||
case 3:
|
||||
ntfyInput.placeholder = "Confession of sin: I dont like SciAdv";
|
||||
ntfyMessage.placeholder = `${msgPFX}Confession of sin: I dont like SciAdv`;
|
||||
break;
|
||||
case 4:
|
||||
ntfyInput.placeholder = "Knock Knock...";
|
||||
ntfyMessage.placeholder = `${msgPFX}Knock Knock...`;
|
||||
break;
|
||||
case 5:
|
||||
ntfyInput.placeholder = "El. Psy. Kongroo.";
|
||||
ntfyMessage.placeholder = `${msgPFX}El. Psy. Kongroo.`;
|
||||
break;
|
||||
case 6:
|
||||
ntfyInput.placeholder = "the organization is after you.";
|
||||
ntfyMessage.placeholder = `${msgPFX}the organization is after you.`;
|
||||
break;
|
||||
case 7:
|
||||
ntfyInput.placeholder =
|
||||
"you wouldnt happen to know where an IBN5100 is, would you?";
|
||||
ntfyMessage.placeholder =
|
||||
`${msgPFX}you wouldnt happen to know where an IBN5100 is, would you?`;
|
||||
break;
|
||||
case 8:
|
||||
ntfyInput.placeholder =
|
||||
"if you had to choose, between: bacon, unlimited bacon, but no games. or. games. unlimited games, but no games. which would you pick?";
|
||||
ntfyMessage.placeholder =
|
||||
`${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;
|
||||
case 9:
|
||||
ntfyInput.placeholder = "time travel?";
|
||||
ntfyMessage.placeholder = `${msgPFX}time travel?`;
|
||||
break;
|
||||
default:
|
||||
ntfyInput.placeholder = "type some words and hit send";
|
||||
ntfyMessage.placeholder = `${msgPFX}type some words and hit send`;
|
||||
}
|
||||
}
|
||||
|
||||
// send function
|
||||
function send(message) {
|
||||
function send(message, title, tags, attachment, click) {
|
||||
const r = new XMLHttpRequest();
|
||||
r.open("POST", "https://ntfy.ouroboros.group/beep", true);
|
||||
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);
|
||||
}
|
||||
|
||||
// send notification
|
||||
function sendNotification() {
|
||||
send(ntfyInput.value);
|
||||
ntfyInput.value = "";
|
||||
send(ntfyTitle.value, ntfyMessage.value, ntfyTags.value, ntfyAttach.value, ntfyClickAction.value);
|
||||
ntfyTitle.value = "";
|
||||
ntfyTags.value = "";
|
||||
ntfyAttach.value = "";
|
||||
ntfyClickAction.value = "";
|
||||
ntfyMessage.value = "";
|
||||
}
|
||||
|
||||
// on send button click
|
||||
async function ntfyClick() {
|
||||
if (!ntfyInput.value.replace(/\s/g, "").length) {
|
||||
if (!ntfyMessage.value.replace(/\s/g, "").length) {
|
||||
ntfyButton.innerHTML = "<span>ಠ﹏ಠ</span>";
|
||||
setTimeout(() => {
|
||||
ntfyButton.innerHTML = "<span>Send</span>";
|
||||
|
|
|
@ -20,15 +20,21 @@
|
|||
</small>
|
||||
<br>
|
||||
<br>
|
||||
<div class="ntfyForm">
|
||||
<textarea id="ntfy-input" placeholder="type some words and hit send" rows=2></textarea>
|
||||
<button
|
||||
class="custom-btn btn-1"
|
||||
onclick="ntfyClick()"
|
||||
id="ntfy-send">
|
||||
<span>Send</span>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<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
|
||||
class="custom-btn btn-1"
|
||||
style="width: 42%;"
|
||||
onclick="ntfyClick()"
|
||||
id="ntfy-button">
|
||||
<span>Send</span>
|
||||
</button>
|
||||
<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>
|
||||
</div>
|
||||
</section>
|
|
@ -35,6 +35,11 @@ dependencies {
|
|||
implementation("io.ktor:ktor-server-netty-jvm")
|
||||
implementation("ch.qos.logback:logback-classic:$logback_version")
|
||||
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 {
|
||||
|
|
|
@ -1,11 +1,19 @@
|
|||
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 kotlinx.coroutines.runBlocking
|
||||
import observer.nelle.api.sendMessage
|
||||
import observer.nelle.plugins.configureRouting
|
||||
import observer.nelle.plugins.configureSecurity
|
||||
import observer.nelle.plugins.configureTemplating
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
|
||||
|
||||
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 {
|
||||
// Set a static resource path 'resources/content/' to be served
|
||||
staticFiles("/", File("static"))
|
||||
staticResources("/", "static")
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue