Desktop app doesn't use online username when exporting URI

When I use "Export Item..." to export a URI, the format of the URI is (for example):

http://zotero.org/users/9677/items/HW6XKIU7

When I click on this link, however, I get a "Page Not Found" error. To get it to work I have to manually edit the link to change "users/9677" to "docja" (my online username). Is there a way to have this happen automatically when the URI is exported?

Thanks!

ja
  • These are identifiers, not URLs, so they're not necessarily intended as links -- they used to work and IIRC Zotero had to disable the redirect for technical reason, but I might be wrong there.

    What format are you exporting the item to? It'd certainly be possible to customize an export script that just did the search & replace for you.
  • Thanks for the quick reply!

    Yes, they used to work for me, too, but not now. I'm exporting it as "Item URI" to an HTML file called "Exported Items.html", which I open with Notepad++. In NPP the URI is an HTML link. When I copy and paste that into my notes in OneNote it pastes as a link. I don't want to take the time to make a script file to do the change, so I just edit the link in OneNote and it then works. But it seems like this is something that ought to be made to still work. Or is there another way to directly get a link to the online file in the desktop app? I haven't found one yet.
  • edited January 3, 2023
    Item URI would be a custom exporter anyway -- Zotero doesn't have that. The URI *looks* like a link, but it's really just an identifier (hence URI and not URL) and Zotero itself doesn't visibly expose that anywhere for just that reason

    Bu it literally just takes adding
    .replace("/users/9677", "/docja/items") to the relevant line in the export translator for Item URI to get a working link.
    .
  • IIRC Zotero had to disable the redirect for technical reasons
    Because of abuse.
    Or is there another way to directly get a link to the online file in the desktop app?
    This will be coming soon.
  • @adamsmith, I was unaware of the export translators. Manually editing the URI isn't terrible, but I did find my "Item URI.js". However, I don't know javascript, so I don't know where to put your suggested code. Here's the code in my file:

    {
    "translatorID":"064ef4ee-61b8-4bb4-ba16-5501d09aed0c",
    "translatorType":2,
    "label":"Item URI",
    "creator":"Sebastian Karcher",
    "target":"html",
    "minVersion":"2.0",
    "maxVersion":"",
    "priority":200,
    "inRepository":false,
    "lastUpdated":"2012-07-17 22:27:00"
    }

    function doExport() {
    var item;
    while(item = Zotero.nextItem()) {Zotero.write(item.uri + "\n");}
    }

    Which line is the relevant one? And won't my modification be lost when Zotero updates?

    @dstillman, I and I'm sure others will be glad to see that "coming soon" functionality.

    Thanks again to both of you.
  • edited January 4, 2023
    while(item = Zotero.nextItem()) {Zotero.write(item.uri.replace("/users/9677", "/docja/items") + "\n");}

    Zotero's built-in translators would potentially be overwritten on update, but a custom translator won't auto-update and would only disappear when you use reset translators in the Zotero preferences (and that would also apply to the current Item URI translator).

    edit: I've added /items to the replacement because I don't get that as part of the item URI, but if you are, then simply change the replacing string to just "/docja"
  • @adamsmith, many thanks. I made that change and it works.
Sign In or Register to comment.