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.">
|
||||
<h1>Sketchers United 4th Anniversary Collaboration</h1>
|
||||
<p id = "current">Currently we are featuring 150 images.</p>
|
||||
|
||||
<p>❤️🧡💛💚💙💜
|
||||
<h2>❓ What is this?</h2>
|
||||
|
@ -103,8 +104,6 @@
|
|||
</div>
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
<!--- SCRIPTS -->
|
||||
<script src="script/modal.js"></script>
|
||||
<script src="script/live.js"></script>
|
||||
|
|
|
@ -20,7 +20,6 @@ function sendMessageToServer(message) {
|
|||
anno.on('clickAnnotation', async function(annotation) {
|
||||
let annotationValue = annotation.body[0].tag;
|
||||
|
||||
try {
|
||||
let newAnnotation = annotation;
|
||||
newAnnotation.body[0].value = "🔁 Downloading label...";
|
||||
anno.updateSelected(newAnnotation);
|
||||
|
@ -29,18 +28,30 @@ anno.on('clickAnnotation', async function(annotation) {
|
|||
|
||||
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
|
||||
|
||||
let site = "https://sketchersunited.org";
|
||||
try {
|
||||
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>`;
|
||||
|
||||
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++;
|
||||
}
|
||||
});
|
||||
document.getElementById("current").innerText = `Currently we are featuring ${image_count} images.`;
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('Error:', error);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
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) => {
|
||||
if(event.data.toString().length < 5) {
|
||||
|
|
|
@ -43,7 +43,22 @@ class WebSocketHandler(tornado.websocket.WebSocketHandler):
|
|||
self.write_message(response.body)
|
||||
|
||||
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):
|
||||
tornado.ioloop.IOLoop.current().add_callback(self.handle_message, message)
|
||||
|
|
Loading…
Reference in New Issue