diff --git a/README.md b/README.md index f9da9ec9..8dd173c6 100644 --- a/README.md +++ b/README.md @@ -101,24 +101,6 @@ make build-simple To build releases, I use [GoReleaser](https://goreleaser.com/). If you have that installed, you can run `make build` or `make build-snapshot`. -## FAQ - -### Isn't this like ...? -Probably. I didn't do a whole lot of research before making this. - -### Can I use this in my app? -Yes. As long as you don't abuse it, it'll be available and free of charge. - -### What are the uptime guarantees? -Best effort. - -### Why is the web UI so ugly? -I don't particularly like JS or dealing with CSS. I'll make it pretty after it's functional. - -### Will you know what topics exist, can you spy on me? -If you don't trust me or your messages are sensitive, run your ntfy on your own server. That said, the logs do not -contain any topic names or other details about you. - ## TODO - add HTTPS diff --git a/examples/example_desktop_notifications.sh b/examples/example_desktop_notifications.sh new file mode 100644 index 00000000..5329c107 --- /dev/null +++ b/examples/example_desktop_notifications.sh @@ -0,0 +1,7 @@ +#!/bin/bash +# This is an example shell script showing how to consume a ntfy.sh topic using +# a simple script. The notify-send command sends any arriving message as a desktop notification. + +while read msg; do + notify-send "$msg" +done < <(stdbuf -i0 -o0 curl -s ntfy.sh/mytopic/raw) diff --git a/server/index.html b/server/index.html index d5073f00..a0ecb51e 100644 --- a/server/index.html +++ b/server/index.html @@ -25,14 +25,14 @@ - +

ntfy.sh - simple HTTP-based pub-sub

- ntfy (pronounce: notify) is a simple HTTP-based pub-sub notification service and tool. + ntfy (pronounce: notify) is a simple HTTP-based pub-sub notification service. It allows you to send desktop notifications via scripts from any computer, entirely without signup or cost. It's also open source if you want to run your own.

@@ -55,20 +55,38 @@

- +

-

Subscribed topics:

+

Topics:

- +

Subscribe via your app, or via the CLI

+

+ Here are some examples using curl: +

- curl -s ntfy.sh/mytopic/raw # one message per line (\n are replaced with a space)
- curl -s ntfy.sh/mytopic/json # one JSON message per line
- curl -s ntfy.sh/mytopic/sse # server-sent events (SSE) stream + # one message per line (\n are replaced with a space)
+ curl -s ntfy.sh/mytopic/raw

+ + # one JSON message per line
+ curl -s ntfy.sh/mytopic/json

+ + # server-sent events (SSE) stream, use with EventSource
+ curl -s ntfy.sh/mytopic/sse +
+

+ Using EventSource, you can consume + notifications like this (see full example): +

+ + const eventSource = new EventSource(`https://ntfy.sh/mytopic/sse`);
+ eventSource.onmessage = (e) => {
+   // Do something with e.data
+ };

Publishing messages

@@ -78,10 +96,44 @@ curl -d "long process is done" ntfy.sh/mytopic +

+ Here's an example in JS with fetch() (see full example): +

+ + fetch(`https://ntfy.sh/mytopic`, {
+   method: 'POST', // PUT works too
+   body: `Hello from the other side.`
+ }) +

Messages published to a non-existing topic or a topic without subscribers will not be delivered later. There is (currently) no buffering of any kind. If you're not listening, the message won't be delivered.

+ +

FAQ

+

+ Isn't this like ...?
+ Who knows. I didn't do a lot of research before making this. It was fun making it. +

+ +

+ Can I use this in my app? Will it stay free?
+ Yes. As long as you don't abuse it, it'll be available and free of charge. I do not plan on monetizing + the service. +

+ +

+ What are the uptime guarantees?
+ Best effort. +

+ +

+ Will you know what topics exist, can you spy on me?
+ If you don't trust me or your messages are sensitive, run your own server. It's open source. + That said, the logs do not contain any topic names or other details about you. Check the code if you don't believe me. +

+ +
Made with ❤️ by Philipp C. Heckel
diff --git a/server/static/css/app.css b/server/static/css/app.css index 1c623901..ba6c8c21 100644 --- a/server/static/css/app.css +++ b/server/static/css/app.css @@ -20,6 +20,7 @@ h1 { font-size: 2.5em; } + h2 { margin-top: 20px; margin-bottom: 5px; @@ -33,8 +34,10 @@ h3 { } p { - margin-top: 0; + margin-top: 10px; + margin-bottom: 20px; font-size: 1.1em; + line-height: 140%; } tt { @@ -49,6 +52,8 @@ code { font-family: monospace; padding: 20px; border-radius: 3px; + margin-top: 10px; + margin-bottom: 10px; } /* Lato font (OFL), https://fonts.google.com/specimen/Lato#about, @@ -74,3 +79,7 @@ code { color: darkred; font-style: italic; } + +#ironicCenterTagDontFreakOut { + color: #666; +} diff --git a/server/static/img/ntfy.png b/server/static/img/ntfy.png deleted file mode 100644 index 93982c6f..00000000 Binary files a/server/static/img/ntfy.png and /dev/null differ diff --git a/server/static/js/app.js b/server/static/js/app.js index 3670b485..33baa990 100644 --- a/server/static/js/app.js +++ b/server/static/js/app.js @@ -59,8 +59,11 @@ const subscribeInternal = (topic, delaySec) => { }; eventSource.onmessage = (e) => { const event = JSON.parse(e.data); - new Notification(event.message); notifySound.play(); + new Notification(topic, { + body: event.message, + icon: '/static/img/favicon.png' + }); }; topics[topic] = eventSource; localStorage.setItem('topics', JSON.stringify(Object.keys(topics))); @@ -80,7 +83,7 @@ const unsubscribe = (topic) => { const test = (topic) => { fetch(`/${topic}`, { method: 'PUT', - body: `This is a test notification for topic ${topic}!` + body: `This is a test notification` }) }; diff --git a/server/static/sound/mixkit-long-pop-2358.wav b/server/static/sound/mixkit-long-pop-2358.wav deleted file mode 100644 index 4bed79ac..00000000 Binary files a/server/static/sound/mixkit-long-pop-2358.wav and /dev/null differ diff --git a/server/static/sound/mixkit-message-pop-alert-2354.mp3 b/server/static/sound/mixkit-message-pop-alert-2354.mp3 new file mode 100644 index 00000000..a1ad34ac Binary files /dev/null and b/server/static/sound/mixkit-message-pop-alert-2354.mp3 differ