mirror of
https://github.com/slynn1324/tinypin.git
synced 2026-01-23 02:25:08 +00:00
fix touch icon hover styles, one time links for ios sharing
This commit is contained in:
parent
b23208c0bf
commit
d73f429976
6 changed files with 74 additions and 10 deletions
39
server.js
39
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
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
});
|
||||
|
|
@ -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;
|
||||
}
|
||||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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}
|
||||
<span id="loader-mobile" class="navbar-item" style="position: relative; margin-left: auto;">
|
||||
<div id="loader" class="button is-text ${data.loading ? 'is-loading' : ''}"></div>
|
||||
<div id="socketConnected" class="button is-text"></div>
|
||||
<div id="socketConnected" class="button is-text" data-onclick-x="dispatchSocketConnect"></div>
|
||||
</span>
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -594,7 +594,7 @@
|
|||
|
||||
|
||||
// tinypin -- add controls
|
||||
this.outer.querySelector('.lg-toolbar').insertAdjacentHTML('beforeend', '<a id="lg-deletePin" class="lg-icon" data-onclick="brickwall.deletePin"></a><a id="lg-siteUrl" class="lg-icon" target="_blank"></a><a id="lg-edit" class="lg-icon" data-onclick="brickwall.editPin"></a><a id="lg-iosShare" class="lg-icon"></a><a id="lg-openOriginal" class="lg-icon" download></a>');
|
||||
this.outer.querySelector('.lg-toolbar').insertAdjacentHTML('beforeend', '<a id="lg-deletePin" class="lg-icon" data-onclick="brickwall.deletePin"></a><a id="lg-siteUrl" class="lg-icon" target="_blank"></a><a id="lg-edit" class="lg-icon" data-onclick="brickwall.editPin"></a><a id="lg-iosShare" data-onclick-x="iosShare" class="lg-icon"></a><a id="lg-openOriginal" class="lg-icon" download></a>');
|
||||
|
||||
if (this.s.download) {
|
||||
this.outer.querySelector('.lg-toolbar').insertAdjacentHTML('beforeend', '<a id="lg-download" aria-label="Download" target="_blank" download class="lg-download lg-icon"></a>');
|
||||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue