1
0
Fork 0

annotation update

This commit is contained in:
red 2023-10-02 15:35:19 +01:00
parent 96e378fd77
commit 1db9bd33cb
2 changed files with 22 additions and 22 deletions

View File

@ -13,7 +13,8 @@ def process_line(line):
"type": "TextualBody",
"value": folder_name,
"format": "text/html",
"language": "en"
"language": "en",
"tag": folder_name
}],
"target": {
"selector": {
@ -28,12 +29,12 @@ def process_line(line):
return annotation
annotations = []
with open('../image.txt', 'r') as file:
with open('image.txt', 'r') as file:
lines = file.readlines()
for line in lines:
annotations.append(process_line(line))
with open('../../annotations/annotations.w3c.json', 'w') as output_file:
with open('../annotations/annotations.w3c.json', 'w') as output_file:
json.dump(annotations, output_file, indent=2)
print("Annotations JSON file created.")

View File

@ -18,30 +18,29 @@ function sendMessageToServer(message) {
}
anno.on('clickAnnotation', async function(annotation) {
let annotationText = annotation.body[0].value;
let annotationValue = annotation.body[0].tag;
if (!annotationText.includes("sketchersunited.org/")) {
try {
let newAnnotation = annotation;
newAnnotation.body[0].value = "🔁 Downloading label...";
anno.updateSelected(newAnnotation);
try {
let newAnnotation = annotation;
newAnnotation.body[0].value = "🔁 Downloading label...";
anno.updateSelected(newAnnotation);
let response = await sendMessageToServer(annotationText);
let response = await sendMessageToServer(annotationValue);
let trueValueAnnotation = newAnnotation;
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"
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);
} catch (error) {
console.error('Error:', error);
}
anno.updateSelected(trueValueAnnotation);
} catch (error) {
console.error('Error:', error);
}
});