diff --git a/pkg/templates/templates.go b/pkg/templates/templates.go index 5816436..2bbd676 100644 --- a/pkg/templates/templates.go +++ b/pkg/templates/templates.go @@ -133,6 +133,7 @@ var baseTemplates = []string{ config.TemplatePath + "/base.html", config.TemplatePath + "/partials/user_avatar.html", config.TemplatePath + "/partials/like_modal.html", + config.TemplatePath + "/partials/right_click.html", } // templates returns a template chain with the base templates preceding yours. diff --git a/web/static/js/right-click.js b/web/static/js/right-click.js index 1e8e2ea..7d57c66 100644 --- a/web/static/js/right-click.js +++ b/web/static/js/right-click.js @@ -1,5 +1,29 @@ // Right-click button handler, to dissuade downloading. document.addEventListener('DOMContentLoaded', () => { + // Whitelist of paths to NOT engage the script on (because it's annoying) + let path = window.location.pathname; + if (path === "/") return; + let pathWhitelist = [ + "/messages", + "/forum/post", + "/f/", + "/settings", + "/photo/certification", + "/notes/me", + "/notes/u/", + "/admin", + "/about", + "/faq", + "/tos", + "/privacy", + "/contact", + ]; + for (let prefix of pathWhitelist) { + if (path.indexOf(prefix) === 0) { + return; + } + } + const $modal = document.querySelector("#rightclick-modal"), $button = $modal.querySelector("button"), cls = 'is-active'; diff --git a/web/templates/base.html b/web/templates/base.html index c202ac5..9e65a54 100644 --- a/web/templates/base.html +++ b/web/templates/base.html @@ -369,41 +369,7 @@ {{template "like-modal"}} - - + {{template "right-click-modal"}} {{end}} diff --git a/web/templates/partials/right_click.html b/web/templates/partials/right_click.html new file mode 100644 index 0000000..bc2b02f --- /dev/null +++ b/web/templates/partials/right_click.html @@ -0,0 +1,39 @@ + + +{{define "right-click-modal"}} + + +{{end}}