Commit fd436baf authored by Jean Michel Rouly's avatar Jean Michel Rouly

Split big annotations.json file into smaller, field-dependent ones.

parent a61ca1fb
{
"cs": [
],
"edu": [
],
"eng": [
],
"gov": [
],
"hist": [
],
"lit": [
],
"med": [
],
"psy": [
],
"sci": [
],
"sample": [
{
"id": "#title",
"title": "Title",
"string": "The title of a scholarly article is generally (but not always) an extremely brief summary of the article's contents. It will usually contain technical terms related to the research presented."
}
]
}
...@@ -9,11 +9,11 @@ echo "Cleaning build directory." ...@@ -9,11 +9,11 @@ echo "Cleaning build directory."
clean.sh clean.sh
mkdir -p tmp mkdir -p tmp
mkdir -p webroot mkdir -p webroot
mkdir -p webroot/json
echo "Copying static files into webroot." echo "Copying static files into webroot."
cp -r static webroot/ cp -r static webroot/
cp -r annotations.json webroot/
echo "Building articles." echo "Building articles."
for article in pages/articles/* for article in pages/articles/*
...@@ -27,12 +27,14 @@ do ...@@ -27,12 +27,14 @@ do
ARTICLE_FILE="pages/articles/$ID/article" ARTICLE_FILE="pages/articles/$ID/article"
OVERVIEW_FILE="pages/articles/$ID/overview" OVERVIEW_FILE="pages/articles/$ID/overview"
COPYRIGHT_FILE="pages/articles/$ID/copyright" COPYRIGHT_FILE="pages/articles/$ID/copyright"
ANNOTATIONS_FILE="pages/articles/$ID/annotations.json"
echo " Checking file presence." echo " Checking file presence."
if [ ! -f $TITLE_FILE ]; then echo "No file $TITLE_FILE found. Exiting."; exit; fi if [ ! -f $TITLE_FILE ]; then echo "No file $TITLE_FILE found. Exiting."; exit; fi
if [ ! -f $OVERVIEW_FILE ]; then echo "No file $OVERVIEW_FILE found. Exiting."; exit; fi if [ ! -f $OVERVIEW_FILE ]; then echo "No file $OVERVIEW_FILE found. Exiting."; exit; fi
if [ ! -f $ARTICLE_FILE ]; then echo "No file $ARTICLE_FILE found. Exiting."; exit; fi if [ ! -f $ARTICLE_FILE ]; then echo "No file $ARTICLE_FILE found. Exiting."; exit; fi
if [ ! -f $COPYRIGHT_FILE ]; then echo "No file $COPYRIGHT_FILE found. Exiting."; exit; fi if [ ! -f $COPYRIGHT_FILE ]; then echo "No file $COPYRIGHT_FILE found. Exiting."; exit; fi
if [ ! -f $ANNOTATIONS_FILE ]; then echo "No file $ANNOTATIONS_FILE found. Exiting."; exit; fi
echo " Reading data." echo " Reading data."
TITLE=$( cat $TITLE_FILE ) TITLE=$( cat $TITLE_FILE )
...@@ -55,6 +57,7 @@ do ...@@ -55,6 +57,7 @@ do
echo " Moving into webroot." echo " Moving into webroot."
mv "tmp/$ID.html" webroot/ mv "tmp/$ID.html" webroot/
cp $ANNOTATIONS_FILE "webroot/json/$ID.json"
ASSETS="pages/articles/$ID/assets" ASSETS="pages/articles/$ID/assets"
if [ -e $ASSETS ] if [ -e $ASSETS ]
......
...@@ -52,5 +52,5 @@ ...@@ -52,5 +52,5 @@
</div> </div>
<script> <script>
getAnnotations( "{{ ID }}" ); getAnnotations( "json/{{ ID }}.json" );
</script> </script>
...@@ -11,14 +11,14 @@ function getAnnotations( field ) { ...@@ -11,14 +11,14 @@ function getAnnotations( field ) {
*/ */
$.getJSON( $.getJSON(
"annotations.json", field,
function( data ) { function( data ) {
// Read in the dictionary of annotations from a central JSON // Read in the dictionary of annotations from a central JSON
// dictionary. // dictionary.
console.log( "Successfully read in JSON annotations." ); console.log( "Successfully read in JSON annotations." );
// Grab only the annotations for this specific field. // Grab only the annotations for this specific field.
var annotations = data[field]; var annotations = data['annotations'];
// Verify that the field name was valid and annotations were found. // Verify that the field name was valid and annotations were found.
if( ! annotations ) { if( ! annotations ) {
...@@ -27,7 +27,7 @@ function getAnnotations( field ) { ...@@ -27,7 +27,7 @@ function getAnnotations( field ) {
return; return;
} }
console.log( "Found '" + field + "' in JSON dictionary." ); console.log( "Found valid annotations in JSON dictionary." );
// Loop over each annotation found and set its trigger's alt text as // Loop over each annotation found and set its trigger's alt text as
// well as define the popover for it. // well as define the popover for it.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment