Add: mastodon instance env var

This commit is contained in:
Óscar M. Lage 2024-12-05 14:13:54 +01:00
parent 6a878a411d
commit 6a7c97538f
3 changed files with 7 additions and 3 deletions

View File

@ -3,3 +3,4 @@ BASE_URL=https://wrap.sh
SERVER_PORT=8080 SERVER_PORT=8080
UPLOAD_DIR=uploads UPLOAD_DIR=uploads
TOP_N_COMMANDS=10 TOP_N_COMMANDS=10
MASTODON_INSTANCE_FOR_SHARING=mastodon.social

View File

@ -121,6 +121,9 @@ func handleResults(w http.ResponseWriter, r *http.Request) {
} }
stats["baseURL"] = baseURL stats["baseURL"] = baseURL
mastodon := os.Getenv("MASTODON_INSTANCE_FOR_SHARING")
stats["mastodon"] = mastodon
tmpl, err := loadTemplates("result.html") tmpl, err := loadTemplates("result.html")
if err != nil { if err != nil {
http.Error(w, "Error loading template", http.StatusInternalServerError) http.Error(w, "Error loading template", http.StatusInternalServerError)

View File

@ -54,17 +54,17 @@
<div class="mt-8 flex justify-center space-x-4"> <div class="mt-8 flex justify-center space-x-4">
<a <a
href="https://twitter.com/intent/tweet?text=Check%20out%20my%20command%20stats!&url={{.baseURL}}/{{.uniqueID}}" href="https://twitter.com/intent/tweet?text=Wrappd.sh:%20check%20out%20my%20command%20stats!&url={{.baseURL}}/{{.uniqueID}}"
target="_blank" target="_blank"
class="bg-blue-600 hover:bg-blue-700 text-white py-2 px-4 rounded-lg transition duration-200">Share on Twitter</a> class="bg-blue-600 hover:bg-blue-700 text-white py-2 px-4 rounded-lg transition duration-200">Share on Twitter</a>
<a <a
href="https://mastodon.social/share?text=Check%20out%20my%20command%20stats!%20{{.baseURL}}/{{.uniqueID}}" href="https://{{.mastodon}}/share?text=Wrappd.sh:%20check%20out%20my%20command%20stats!%20{{.baseURL}}/{{.uniqueID}}"
target="_blank" target="_blank"
class="bg-blue-600 hover:bg-blue-700 text-white py-2 px-4 rounded-lg transition duration-200">Share on Mastodon</a> class="bg-blue-600 hover:bg-blue-700 text-white py-2 px-4 rounded-lg transition duration-200">Share on Mastodon</a>
<a <a
href="https://bsky.app/share?text=Check%20out%20my%20command%20stats!%20{{.baseURL}}/{{.uniqueID}}" href="https://bsky.app/share?text=Wrappd.sh:%20check%20out%20my%20command%20stats!%20{{.baseURL}}/{{.uniqueID}}"
target="_blank" target="_blank"
class="bg-blue-600 hover:bg-blue-700 text-white py-2 px-4 rounded-lg transition duration-200">Share on Bluesky</a> class="bg-blue-600 hover:bg-blue-700 text-white py-2 px-4 rounded-lg transition duration-200">Share on Bluesky</a>
<a <a