diff --git a/server.js b/server.js index 6b393f4..0ae1109 100644 --- a/server.js +++ b/server.js @@ -160,6 +160,27 @@ app.use ( async (req, res, next) => { } } + + // handle one-time-links for images + if ( req.originalUrl.startsWith("/otl/" ) ){ + try{ + let token = decryptCookie(req.originalUrl.substr(5)); + + // expire tokens in 5 minutes + if ( new Date().getTime() - token.t > 300000 ){ // 5 minutes + res.status(404).send(NOT_FOUND); + return; + } + + let imagePath = getImagePath(token.u, token.p, 'o'); + res.sendFile(imagePath.file); + return; + } catch (e){ + res.status(404).send(NOT_FOUND); + return; + } + } + // skip auth for pub resources // handle login and register paths if ( req.originalUrl.startsWith("/pub/") ){ @@ -529,6 +550,20 @@ app.post("/api/pins/:pinId", (req,res) => { }); +// get a one-time-link for an image +app.post("/api/pins/:pinId/otl", (req,res) => { + + let data = { + u: req.user.id, + p: req.params.pinId, + t: new Date().getTime() + }; + + let token = encryptCookie(data); + + res.status(200).send({t: token}); +}); + // delete pin app.delete("/api/pins/:pinId", async (req, res) => { try { @@ -630,10 +665,6 @@ app.post("/up/", async (req, res) => { return; }); -app.get("/otl/:l", (req, res) => { - -}); - // start listening diff --git a/static/app.js b/static/app.js index ec2e2b3..4a57cab 100644 --- a/static/app.js +++ b/static/app.js @@ -86,7 +86,7 @@ app.addSetter('load.user', async (data) => { data.user = await res.json(); window.uid = data.user.id; - window.socketConnect(); + dispatchSocketConnect(); store.do("loader.hide"); }); @@ -105,6 +105,10 @@ app.addSetter("hash.update", (data) => { } }); +function dispatchSocketConnect(){ + window.dispatchEvent(new CustomEvent("socket-connect")); +} + let store = new Reef.Store({ data: { hash: { @@ -278,5 +282,5 @@ appComponent.render(); window.addEventListener("focus", () => { store.do("load.boards"); store.do("load.board"); - window.dispatchEvent(new CustomEvent("socket-connect")); + dispatchSocketConnect(); }); \ No newline at end of file diff --git a/static/client.css b/static/client.css index 4fdb2ae..13a0ac9 100644 --- a/static/client.css +++ b/static/client.css @@ -429,4 +429,17 @@ body.socketConnected #socketConnected { .lg-touch-hide-items .lg-toolbar { opacity: 0; transform: translate3d(0,-10px,0); +} + +.is-touch .navbar-burger:hover { + background-color: transparent; +} + +.is-touch .navbar.is-light .navbar-brand > a.navbar-item:focus, +.is-touch .navbar.is-light .navbar-brand > a.navbar-item:hover, +.is-touch .navbar.is-light .navbar-brand > a.navbar-item.is-active, +.is-touch .navbar.is-light .navbar-brand .navbar-link:focus, +.is-touch .navbar.is-light .navbar-brand .navbar-link:hover, +.is-touch .navbar.is-light .navbar-brand .navbar-link.is-active { + background-color: transparent; } \ No newline at end of file diff --git a/static/components/brickwall.js b/static/components/brickwall.js index 3c291f8..6d941db 100644 --- a/static/components/brickwall.js +++ b/static/components/brickwall.js @@ -57,6 +57,21 @@ function openOriginal(el){ } +async function iosShare(){ + let data = store.data; + + let index = getLightGalleryIndex(); + let pin = data.board.pins[index]; + + let result = await fetch("/api/pins/" + pin.id + "/otl", {method: 'POST'}); + let obj = await result.json(); + let t = obj.t; + + let url = "https://sktp.quikstorm.net/otl/" + t; + + window.location = "shortcuts://run-shortcut?name=Open%20In&input=" + encodeURIComponent(url); +} + let lightgalleryElement = document.getElementById("lightgallery"); let lightgalleryOpen = false; diff --git a/static/components/navbar.js b/static/components/navbar.js index 63b8536..7821560 100644 --- a/static/components/navbar.js +++ b/static/components/navbar.js @@ -14,6 +14,7 @@ app.addSetter("navbar.logout", () => { window.location = "./logout"; }); + app.addComponent('navbar', (store) => { return new Reef("#navbar", { store: store, template: (data) => { @@ -76,7 +77,7 @@ app.addComponent('navbar', (store) => { return new Reef("#navbar", { ${boardName}
-
+
diff --git a/static/lightgallery/js/lightgallery-custom.js b/static/lightgallery/js/lightgallery-custom.js index 57e4e54..6e7ea9d 100644 --- a/static/lightgallery/js/lightgallery-custom.js +++ b/static/lightgallery/js/lightgallery-custom.js @@ -594,7 +594,7 @@ // tinypin -- add controls - this.outer.querySelector('.lg-toolbar').insertAdjacentHTML('beforeend', ''); + this.outer.querySelector('.lg-toolbar').insertAdjacentHTML('beforeend', ''); if (this.s.download) { this.outer.querySelector('.lg-toolbar').insertAdjacentHTML('beforeend', ''); @@ -1040,8 +1040,8 @@ let openOriginalEl = document.getElementById("lg-openOriginal"); openOriginalEl.setAttribute("href", _this.s.dynamicEl[index].originalUrl); - let iosShareEl = document.getElementById("lg-iosShare"); - iosShareEl.setAttribute("href", "shortcuts://run-shortcut?name=Open%20In&input=" + encodeURIComponent("https://sktp.quikstorm.net/" + _this.s.dynamicEl[index].originalUrl)); + //let iosShareEl = document.getElementById("lg-iosShare"); + //iosShareEl.setAttribute("href", "shortcuts://run-shortcut?name=Open%20In&input=" + encodeURIComponent("https://sktp.quikstorm.net/" + _this.s.dynamicEl[index].originalUrl)); // end tinypin