download annotation even if post was deleted
This commit is contained in:
parent
35838d8081
commit
5796f6b50e
|
@ -52,6 +52,7 @@
|
||||||
|
|
||||||
<img src = "image/banner.png" id = "banner" alt="A banner for the Sketchers United 4th anniversary collab.">
|
<img src = "image/banner.png" id = "banner" alt="A banner for the Sketchers United 4th anniversary collab.">
|
||||||
<h1>Sketchers United 4th Anniversary Collaboration</h1>
|
<h1>Sketchers United 4th Anniversary Collaboration</h1>
|
||||||
|
<p id = "current">Currently we are featuring 150 images.</p>
|
||||||
|
|
||||||
<p>❤️🧡💛💚💙💜
|
<p>❤️🧡💛💚💙💜
|
||||||
<h2>❓ What is this?</h2>
|
<h2>❓ What is this?</h2>
|
||||||
|
@ -103,8 +104,6 @@
|
||||||
</div>
|
</div>
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<!--- SCRIPTS -->
|
<!--- SCRIPTS -->
|
||||||
<script src="script/modal.js"></script>
|
<script src="script/modal.js"></script>
|
||||||
<script src="script/live.js"></script>
|
<script src="script/live.js"></script>
|
||||||
|
|
|
@ -20,27 +20,38 @@ function sendMessageToServer(message) {
|
||||||
anno.on('clickAnnotation', async function(annotation) {
|
anno.on('clickAnnotation', async function(annotation) {
|
||||||
let annotationValue = annotation.body[0].tag;
|
let annotationValue = annotation.body[0].tag;
|
||||||
|
|
||||||
|
let newAnnotation = annotation;
|
||||||
|
newAnnotation.body[0].value = "🔁 Downloading label...";
|
||||||
|
anno.updateSelected(newAnnotation);
|
||||||
|
|
||||||
|
let response = await sendMessageToServer(annotationValue);
|
||||||
|
|
||||||
|
let trueValueAnnotation = newAnnotation;
|
||||||
|
|
||||||
|
let site = "https://sketchersunited.org";
|
||||||
try {
|
try {
|
||||||
let newAnnotation = annotation;
|
let post_id = response.post.id;
|
||||||
newAnnotation.body[0].value = "🔁 Downloading label...";
|
let post_name = response.post.title;
|
||||||
anno.updateSelected(newAnnotation);
|
let poster_id = response.post.profile.id;
|
||||||
|
let poster_name = response.post.profile.username;
|
||||||
let response = await sendMessageToServer(annotationValue);
|
let poster_avatar = response.post.profile.profile_image_url_thumb;
|
||||||
|
|
||||||
let trueValueAnnotation = newAnnotation;
|
|
||||||
|
|
||||||
let site = "https://sketchersunited.org"
|
|
||||||
let post_id = response.post.id
|
|
||||||
let post_name = response.post.title
|
|
||||||
let poster_id = response.post.profile.id
|
|
||||||
let poster_name = response.post.profile.username
|
|
||||||
let poster_avatar = response.post.profile.profile_image_url_thumb
|
|
||||||
|
|
||||||
trueValueAnnotation.body[0].value = `<div class = "profile-container"><div class="profileimg"><img src = "${poster_avatar}"></div><div class="profile"><a href = "${site}/posts/${post_id}" class="rainbow">${post_name}</a><br><a href = "${site}/users/${poster_id}">@${poster_name}</a></div></div>`;
|
trueValueAnnotation.body[0].value = `<div class = "profile-container"><div class="profileimg"><img src = "${poster_avatar}"></div><div class="profile"><a href = "${site}/posts/${post_id}" class="rainbow">${post_name}</a><br><a href = "${site}/users/${poster_id}">@${poster_name}</a></div></div>`;
|
||||||
|
|
||||||
anno.updateSelected(trueValueAnnotation);
|
anno.updateSelected(trueValueAnnotation);
|
||||||
} catch (error) {
|
}
|
||||||
console.error('Error:', error);
|
catch (error) {
|
||||||
|
try {
|
||||||
|
let poster_id = response.data.id;
|
||||||
|
let poster_name = response.data.username;
|
||||||
|
let poster_avatar = response.data.profile_image_url.replace("small", "thumb");
|
||||||
|
trueValueAnnotation.body[0].value = `<div class = "profile-container"><div class="profileimg"><img src = "${poster_avatar}"></div><div class="profile"><a href = "${site}/users/${poster_id}" class = "rainbow">@${poster_name}</a></div></div>`;
|
||||||
|
anno.updateSelected(trueValueAnnotation);
|
||||||
|
}
|
||||||
|
catch (error) {
|
||||||
|
console.log(`Post ${annotationValue} was dead: `, error);
|
||||||
|
newAnnotation.body[0].value = "❌ An error occurred downloading the label.";
|
||||||
|
anno.updateSelected(newAnnotation);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -38,6 +38,7 @@ fetch('image/image.txt')
|
||||||
image_count++;
|
image_count++;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
document.getElementById("current").innerText = `Currently we are featuring ${image_count} images.`;
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
console.error('Error:', error);
|
console.error('Error:', error);
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
const clientCountElement = document.getElementById('clientCount');
|
const clientCountElement = document.getElementById('clientCount');
|
||||||
const socket = new WebSocket('wss://sketchersunitedcollab.com/funsocket');
|
const socket = new WebSocket('ws://localhost:8080/funsocket');
|
||||||
|
|
||||||
socket.addEventListener('message', (event) => {
|
socket.addEventListener('message', (event) => {
|
||||||
if(event.data.toString().length < 5) {
|
if(event.data.toString().length < 5) {
|
||||||
|
|
|
@ -43,7 +43,22 @@ class WebSocketHandler(tornado.websocket.WebSocketHandler):
|
||||||
self.write_message(response.body)
|
self.write_message(response.body)
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"Error handling message: {e}")
|
if str(e) == "HTTP 404: Not Found":
|
||||||
|
try:
|
||||||
|
user_url = f"https://sketchersunited.org/users/{user}"
|
||||||
|
|
||||||
|
headers = {
|
||||||
|
"Accept": "application/json",
|
||||||
|
}
|
||||||
|
request = HTTPRequest(user_url, method="GET", headers=headers)
|
||||||
|
|
||||||
|
http_client = AsyncHTTPClient()
|
||||||
|
response = await http_client.fetch(request)
|
||||||
|
self.write_message(response.body)
|
||||||
|
except Exception as f:
|
||||||
|
print(f"Error getting user page: {f}")
|
||||||
|
else:
|
||||||
|
print(f"Error getting post page: {e}")
|
||||||
|
|
||||||
def on_message(self, message):
|
def on_message(self, message):
|
||||||
tornado.ioloop.IOLoop.current().add_callback(self.handle_message, message)
|
tornado.ioloop.IOLoop.current().add_callback(self.handle_message, message)
|
||||||
|
|
Loading…
Reference in New Issue