sgsinclair / Voyant

GNU General Public License v3.0
208 stars 53 forks source link

DToC: rendering of CSS referenced in the document is broken #448

Open ilovan opened 5 years ago

ilovan commented 5 years ago

E.g. https://voyant-tools.org/dtoc/?corpus=4978d6afadcd771d4518a4d2d0490554&docId=21aa2b6d36dc723ec7314a449aaed7a4&curatorId=1518363009029.9955 or https://voyant-tools.org/dtoc/?corpus=3010d36556c3683e1dd04fdb27084c43&docId=04318ae2976bd748f135b63447d16d52&curatorId=1558461900682.4175

These were corpora created from multiple files, each with a separate css reference.

I believe @ajmacdonald mentioned this is an issue that needs to be fixed on the Voyant side of things (as opposed to in the DToC code)

ilovan commented 5 years ago

Another example, this time of a single file corpus: https://voyant-tools.org/dtoc/?corpus=ec67cb9b4de7979000477284b2945d81&docId=34f6deee0f280982e03cd9b67e371beb&curatorId=1558467195537.2904

ilovan commented 5 years ago

@sgsinclair , based on our conversation yesterday, I created two new corpora: https://voyant-tools.org/dtoc/?corpus=01a9da00259d2c1957b3393c29c20341&docId=ea6e8d1770c93f286674ff6f7b8c49da, where I added the css processing instructions inside the first document xPath https://voyant-tools.org/dtoc/?corpus=ed1fb8cd091c50c6953b7cc84cdf43fb&docId=f245ec43493e0752781391b0c4ed7ed2, where I added the css processing instructions inside both document xPaths

As you can see, the styling doesn't work for either of them. lmk if there are any other experiments you would like me to run to help with debugging this issue

ajmacdonald commented 5 years ago

I've altered the XSLT so that any identified XML processing instructions will be added to the top of the document, which seems to work for displaying custom CSS. https://github.com/sgsinclair/Voyant/commit/ab0fe7a92025a174219a954ec46054eacd1140c7

ajmacdonald commented 5 years ago

@sgsinclair this is a temporary solution that requires the xml-stylesheet to be inside the document content, but we still need to look into associating CSS with documents on the backend cc @SusanBrown

ilovan commented 5 years ago

Thanks Andrew,

This looks like a great improvement, albeit a stopgap solution until you find a more permanent one . @sgsinclair https://github.com/sgsinclair, would it be possible to have an intermediate step in the ingestion process where Voyant takes the css declaration from the top of the document (where it usually resides for most, "normal", xml documents) and plops it inside every content xPath?

If that is not possible, the workaround will need to be specified in the documentation and, despite that, I am afraid that the entire procedure would place quite a heavy burden on the less technologically inclined users.

Thanks

Mihaela Ilovan

Project Manager Canadian Writing Research Collaboratory University of Alberta 4-20 Humanities Centre Edmonton, AB Canada T6G 2E5

780-966-4507 ilovan@ualberta.ca

On Thu, May 30, 2019 at 9:05 AM Andrew notifications@github.com wrote:

@sgsinclair https://github.com/sgsinclair this is a temporary solution that requires the xml-stylesheet to be inside the document content, but we still need to look into associating CSS with documents on the backend cc @SusanBrown https://github.com/SusanBrown

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/sgsinclair/Voyant/issues/448?email_source=notifications&email_token=ABSLLBU7BG5XR6J74VADKILPX7UNFA5CNFSM4HONRQE2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODWSSRDA#issuecomment-497363084, or mute the thread https://github.com/notifications/unsubscribe-auth/ABSLLBU4X3MQSWIWBQBPFZLPX7UNFANCNFSM4HONRQEQ .

sgsinclair commented 5 years ago

I'm working on this now, I'll keep you informed!

sgsinclair commented 5 years ago

I've deployed a version that should work when you select DToC as the input format: the stylesheet definition gets applied for each of the child documents. Please test!

ilovan commented 5 years ago

Seems to be working in the stand-alone DToC: https://voyant-tools.org/dtoc/?corpus=98af2bfcc890aafeda3f683018116cea&docId=b70640739d63a0894821f1fbfa1285fd&curatorId=1560455194195.4258

However, the curator feature where the user would map figures, links and notes doesn't seems to be working anymore. (@sgsinclair , let me know if you want me to put this in a separate ticket)

Also the css does not work in the CWRC-integrated DToC. Isn't DToC the default input format? Do we need to specify it in the JSON we're sending to Voyant? See https://cwrc.ca/islandora/object/cwrc%3A3ac52750-d05c-4672-b7a9-0e438c169968

ajmacdonald commented 5 years ago

@ilovan for the link and image mappings, you have to add the attribute to the xpath or it won't know what to use, e.g. ref[@target] and graphic[@url] https://voyant-tools.org/dtoc/?corpus=98af2bfcc890aafeda3f683018116cea&docId=761d64d2800bbd6df73cebcd4cf009b1&curatorId=1560469549498.8381

sgsinclair commented 5 years ago

I have a vague memory that we may have used XML as the input format from CWRC since many documents won't be DToC. Also, you need to make sure that you're providing a new document for processing (otherwise the cached version will be used, which is the intended behaviour).

ajmacdonald commented 5 years ago

I've just committed a fix for why default CSS is not being shown, re: https://cwrc.ca/islandora/object/cwrc%3A3ac52750-d05c-4672-b7a9-0e438c169968

ilovan commented 5 years ago

Thanks @ajmacdonald . @sgsinclair , could you possibly push this fix that Andrew referenced to the server if you haven't done so already? As far as we can tell, the default css is still not being shown. Thanks :)

ilovan commented 5 years ago

Hi both. @ajmacdonald , thanks for the fix. @sgsinclair , thanks for deployment.

I I have two very different results for two corpora composed of multiple files that have the same css declaration:

https://voyant-tools.org/dtoc/?corpus=7e2154c128307e03c685cdee5eb09681&docId=1014c129c48fe9a0a80f484c9d238952&curatorId=1561742259839.6266 styles things like bullet lists and reference lists (but does not style headings)

https://cwrc.ca/islandora/object/cwrc%3Acd5f65d3-0ea7-4f7c-a679-93bf502f74c0 seems to display only the placeholder style that @ajmacdonald put in place (I think it's just block display for paragraphs and headings and padding around the text area, with no additional styling), even though the documents that are sent have https://cwrc.ca/templates/css/tei.css declared (see https://cwrc.ca/islandora/object/islandora%3A4d5b7324-6393-4d58-9a77-ebd640a84a5b, download the CWRC datastream from the "Datastreams" block at the bottom of the page)

The configuration used for both corpora listed here is:

Content: //*[(local-name()='div' and('chapter'=@*[local-name()='type']))] Title: //*[local-name()='titleStmt']//*[local-name()='title'] Author: //*[local-name()='titleStmt']//*[local-name()='author']//*[local-name()='persName'] Document: /

Any idea why these inconsistencies are happening? Is it something in the configuration that I am using? Is there anything missing from the data that CWRC sends to Voyant in order for the declared style (https://cwrc.ca/templates/css/tei.css in this case) to be applied? Any reason why the div/head elements are not styled, even when the rest of the document seems to be styled based on the declared stylesheet?

ajmacdonald commented 5 years ago

@ilovan the link https://cwrc.ca/islandora/object/cwrc%3Acd5f65d3-0ea7-4f7c-a679-93bf502f74c0 doesn't seem to work so I can't do a comparison.

The div/head elements aren't being styled because the CSS rules require a parent body element ( body > div > head ) which doesn't exist in the XML that Voyant is producing, due to the XPath selectors targeting the children (divs) of the body element.

SusanBrown commented 5 years ago

Can you try comparison with this one @ajmacdonald ?https://cwrc.ca/islandora/object/cwrc%3Abf58d0a8-41fe-4e13-abc8-30f4ff3cb46d

nikathone commented 5 years ago

@ajmacdonald here is the commit https://github.com/cwrc/cwrc_dtoc_edition/commit/33d1f70d02fb15be3641f5e4f181c7dd9cb7dbc8 containing the changes from yesterday.