diff --git a/image/script/generate_annotations.py b/image/script/generate_annotations.py index 072be85..e2ce35a 100644 --- a/image/script/generate_annotations.py +++ b/image/script/generate_annotations.py @@ -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.") diff --git a/script/annotations.js b/script/annotations.js index 24f99f6..4a6217f 100644 --- a/script/annotations.js +++ b/script/annotations.js @@ -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 = `
${post_name}
@${poster_name}
`; + trueValueAnnotation.body[0].value = `
${post_name}
@${poster_name}
`; - anno.updateSelected(trueValueAnnotation); - } catch (error) { - console.error('Error:', error); - } + anno.updateSelected(trueValueAnnotation); + } catch (error) { + console.error('Error:', error); } + });