Created a new version of the project (mariage_5) running locally, and did the first conversion of the db format (which differs slightly from the previous plan, to include the modern versions of the texts):
----mariage
----anthology
----images
----texts_original
----editorial
----articles
----intros
----back_matter
----references
----biblio
----translations
----texts_modern
I've also modified all of the documents so that all their validation links point to a single copy of the main schema in the root mariage
folder (one, of course, points at the drama-enhanced version). At the end of this entire process, I'm planning to run oddbyexample and get a really trimmed-down schema.
Next, I normalized all the elements which point to external components (references and biblio items) so that they all have the same format, and don't rely on an @type attribute. Then I confirmed that everything that worked before now also works.
Now, before I go any further, I need to decide once and for all how I'm going to handle the display of this linked content in the site. My instinct goes like this:
- All items (biblio, ref or whatever) which are directly linked from a document are retrieved with that document, and made available for rendering as back matter for that document. Whether they're actually rendered or not will depend on the document type; biblio items in editorial articles should be rendered at the bottom of the page, but there's no point in rendering visibly all the references for e.g. Varin, so they can stay hidden in the output.
- All document links calling out to such items are rendered to call exactly the same function,
showReference()
.
- The
showReference()
function works like this:
- Check if there's an item with the right id already in the document.
- If there is, then:
- Remove any existing content from the popup box.
- Clone the content of the item into the popup box (removing its
@xml:id
, to avoid duplicate ids).
- Show the popup box.
- If the item doesn't exist in the document, then it needs to be retrieved by AJAX:
- Store the id of the target item.
- Empty any existing content from the box. This may delete the item which was clicked-on to initiate the retrieval, so we'll need to be sure there isn't a problem there. We might have to use a timeout to trigger the second part of the process.
- Retrieve the item by AJAX and append it to the end of the back div (so there should always be a back
<div>
, in case we need to do that).
- Clone the item into the popup as above, and show the popup.
This allows us to handle situations in which a reference points to another reference, and also avoids retrieving the same content by AJAX more than once.
I already have the same popup code working for both footnotes and references, but I haven't yet finished the code which will retrieve a reference by AJAX.