WordPress.org

Ready to get started?Download WordPress

Forums

Zotpress
BibTex bibliography (15 posts)

  1. davidswelt
    Member
    Posted 10 months ago #

    Hi,
    I'm putting together a dynamic bibliography that shows BibTeX records as follows:

    [zotpress collection="MGID93AS" style="bibtex" sortby="date" order="desc" download="no"]

    Unfortunately, only some of the records are actually formatted as BibTeX - the rest appears in what may be standard citation style. You can see the generated page here:

    https://cc.ist.psu.edu/wp/publications/bibtex-records-dyn/

    (The link will be up until the site goes live.)

    Is there a bug, or is there anything I can do to fix this on my end?

    Thanks,
    David

    http://wordpress.org/plugins/zotpress/

  2. davidswelt
    Member
    Posted 10 months ago #

    I think what's happening here is that I have multiple bibliographies on different pages. When updating the database (sync with Zotero), I notice that other pages (showing APA format) get corrupted as well.

    Is it possible that WordPress or Zotpress updates the two pages in parallel, and some portions of Zotpress can't handle the concurrency?

  3. Katie
    Member
    Plugin Author

    Posted 10 months ago #

    Zotpress should auto-update the styles of citations displayed on the front-end after a moment. I think the request URL might be too long because there's so many citations on that one page. Does it happen when there's under 50 citations?

  4. davidswelt
    Member
    Posted 10 months ago #

    You're right, this does make a difference. With limit=50, it works fine.
    Can you add some code that retrieves the bibliography in batches?

    (I'm surprised you have to give individual record IDs to make the retrieval, rather than the collection.)

    I seem to remember that the Zotero API limits BibTex retrievals to 100 at a time anyway.

  5. Katie
    Member
    Plugin Author

    Posted 10 months ago #

    The reason has to do with the length of the URL string in the browser rather than the Zotero limits. I can't assume that citations are always displayed by collection, which is why it goes by individual item. That said, I thought I'd set it up so that Zotpress loops through multiple requests if necessary, but perhaps that's in an unreleased version. I'll make a note of it and add it in if it's not there.

  6. davidswelt
    Member
    Posted 10 months ago #

    In the browser?
    The URL displayed is my short WordPress URL.

    I can't see an iframe or anything else - it seems to me that what goes on on the server is fully opaque to the browser. (I even assumed that the content itself is static!)

    Either way, even with the shorter collections do I see the bug now.

    I have a page that contains numerous separate collections with style=apa, and another one with style=bibtex (at most 33 items in a single included collection).
    However, many of the items do not appear in the right style. It is a mix of BibTeX and APA, and there is no consistency. You reload the page, and they appear in a different style.

    The pages in question is here and here.

    My impression is that I can reproduce the problem if I retrieve the BibTeX pages and regular bibliography in quick succession. Is there some caching (or concurrency) problem?

    I'm rather convinced this is a server-side issue. I can retrieve the BibTeX page in Chrome and then produce the problem by retrieving the plaintext page with Curl. I still see a mix of BibTeX and plain references on the Curl side.

  7. davidswelt
    Member
    Posted 10 months ago #

    One more thing. I'm looking at the database.

    In response to browser requests it appears that the table wp_zotpress_zoteroItems changes content. The same row (HUVVSUQ6 in this case) is either style=apa or style=bibtex, and the "citation" field changes accordingly.

    Is there supposed to be a write db access every time it is loaded? Are all the bibliography entries re-generated with every client access? I'm not sure if this is intentional, which is why I mention it here.

    This is designed to scale well with number of page requests, right?

  8. Katie
    Member
    Plugin Author

    Posted 10 months ago #

    I'm going off of memory (and this has changed a few times) but another user had a similar issue (if I understand it correctly) with a large number of items displayed on a single page not having the style updated. This is done with AJAX. I noticed that the URL fed to AJAX could not be over a certain length (rather than number of items such as Zotero requires). I thought for certain I'd added a looping mechanism to make multiple AJAX calls to work around this.

    Since you're getting the bug with the smaller collections, I'm beginning to think something different is going on.

    All of the styles on the first page are APA and appear to be set as APA in the shortcode (although this is hard to know for certain without seeing the shortcodes).

    I see the error occurring on the second page, where the style is set to bibtext but this is not reflected at about halfway down the screen.

    Feel free to post your exact shortcodes here or perhaps send them to me so I can debug on my end: http://katieseaborn.com/contact

    There is no caching anymore -- AJAX should be taking care of instances where multiple styles with the same items (a bit unusual) are used across site, but something is going wrong in your case. Yes, the item's style is updated in the database each time it's changed, whether it's on the front-end or otherwise.

  9. davidswelt
    Member
    Posted 10 months ago #

    So, AJAX may explain why I often see the wrong version (e.g., BibTeX) displayed first, and then, after a second or two in the browser, the text changes to the correct version (e.g., plain APA - although not for all entries).

    The shortcode for the first collection is

    <h3>ACT-R</h3>
    [zotpress collection="MWXM72N2" style="apa" sortby="date" order="desc" download="yes"]

    On the BibTeX page, it's the same except for style="bibtex":

    <h3>ACT-R</h3>
    [zotpress collection="MWXM72N2" style="bibtex" sortby="date" order="desc" download="yes"]

    If I look at one of the items, e.g., 6CBJZA4M, I only see one entry. I wonder if you correctly distinguish between difference occurrences of the same item.

  10. davidswelt
    Member
    Posted 10 months ago #

    FWIW, the SELECT statements that go to the DB look like this:

    SELECT item_key, citation, json, linkMode FROM wp_zotpress_zoteroItems WHERE api_user_id='160464'
    AND parent = '6CBJZA4M' AND linkMode IN ( 'imported_file', 'linked_url' ) ORDER BY linkMode ASC LIMIT 1

    So, you're not selecting by style in the first place.
    And then your update goes by item_key

    UPDATE wp_zotpress_zoteroItems SET style = 'bibtex', citation = '...bibtex...\n' WHERE item_key = '6CBJZA4M' AND api_user_id = '160464'

    ... and does not distinguish between different uses of the item.

    So, if the design behind this is correct, i don't understand the logic.

    Methinks... if you cache the "citation" of an item, you need to do it separately for each style. (And you should think about caching the whole collection citation text as well - see my new post in this forum.)

  11. Katie
    Member
    Plugin Author

    Posted 10 months ago #

    Yes, there's always going to be a short delay with AJAX if the style needs updating.

    I'm not sure what you mean by looking at only one item.

    That first SELECT statement is unfamiliar to me -- I'm going to check the code but it doesn't seem right / I don't remember writing it and I'm not sure what it's trying to do.

    There's no selecting by style. Is that what you're trying to do? It's one item dynamically updated where the shortcode requests.

    I think I see where the issue might be. Are you displaying the same item on the same page BUT with different styles each time? If so, can you explain why?

    There used to be caching, but this was removed some time ago. If I recall it was because of performance reasons with the method of request back then, but it may be a good thing to bring it back now.

  12. davidswelt
    Member
    Posted 10 months ago #

    Perhaps you want to look at the site.

    I think I explained in the post just above that I display the items in APA style once, and then, on a separate page, as BibTeX.

    That seems to me like a normal thing to do.

  13. davidswelt
    Member
    Posted 10 months ago #

    And no, it's not on the same page, but it could be.

    Even if it is on separate pages, I don't understand how your plugin distinguishes between different concurrent or nearly concurrent page views. One visitor might view the BibTeX version, while another views the APA version.

  14. Katie
    Member
    Plugin Author

    Posted 10 months ago #

    Perhaps I was unclear -- AJAX makes a request each time the document is loaded and the given citation is not the required style -- there is no caching, so it's expected that after a small delay each view will be updated (if you're flipping back and forth between pages and reloading). What's curious in your case is that some style change requests are not going through. Again, as in your case, if you're going to have different styles for the same citation it might be best to re-introduce caching.

  15. davidswelt
    Member
    Posted 10 months ago #

    I see. That explains the strange effects.

    I have turned off JavaScript for the time being. I get a mix of styles on my page now.

Reply

You must log in to post.

About this Plugin

About this Topic

Tags