Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with and suggestion for "Copy select item links" #63

Closed
jlegewie opened this issue Feb 11, 2017 · 10 comments
Closed

Problem with and suggestion for "Copy select item links" #63

jlegewie opened this issue Feb 11, 2017 · 10 comments

Comments

@jlegewie
Copy link

Hey,

I am having a problem with the "Copy select item links" function. Zotero 5.0 always selects the same (and wrong) item. Might be a zotero problem and not zutilo but I also think that the link format changed in Zotero 5.

And a suggestion: formatted links in html or markdown. So Zutilo would copy something like this:

[Bertrand, Marianne and Sendhil Mullainathan. 2004. “Are Emily and Greg More Employable than Lakisha and Jamal? A Field Experiment on Labor Market Discrimination.” The American Economic Review 94(4):991–1013.](zotero://select/items/1_W5UGGXXV)

<a href="zotero://select/items/1_W5UGGXXV">Bertrand, Marianne and Sendhil Mullainathan. 2004. “Are Emily and Greg More Employable than Lakisha and Jamal? A Field Experiment on Labor Market Discrimination.” The American Economic Review 94(4):991–1013</a>
@wshanks
Copy link
Owner

wshanks commented Feb 12, 2017

Hmm, okay, I will have to experiment with the select links.

The suggestion seems reasonable. Should this be an option set in preferences -- copy as plain link, markdown link, or html link? For the other text, the function could use whatever format QuickCopy is set to.

@jlegewie
Copy link
Author

The suggestion could either be a separate (optional) item menu "Copy formatted select item links" (with an option for html or markdown) or a preference... Both work, I think.

@wshanks
Copy link
Owner

wshanks commented Feb 14, 2017

How are you testing the select item links? I tried with Zutilo 2.0.2 and Zotero 5.0-beta.135+12735fa. I used Zutilo to copy the link and then created a link in a note and clicked on it. I tried that a couple different items. It always selected the right item for me.

@wshanks
Copy link
Owner

wshanks commented Feb 14, 2017

Also, I thought about the suggestion a little more. I think an export translator could be written to output a markdown or html link in the format you describe. Then you could just set that format to be the QuickCopy format (or one of the alternative QuickCopy formats in Zutilo's preferences).

@jlegewie
Copy link
Author

Thanks for looking into it. I realized that I have the same problems with zotero links that are not coming from Zutilo. Sometimes it works, sometimes it doesn't but that is entirely unrelated to Zutilo. Sorry for the trouble.

By the way, here is Dan's info on the revised link format: https://groups.google.com/d/msg/zotero-dev/efFuMEqLarY/bZ167jIyGQAJ

But I am not sure whether anything has changed since then.

@wshanks
Copy link
Owner

wshanks commented Feb 14, 2017

Thanks for pointing that out. So for Zotero 5.0 or greater, I can change the format to zotero://select/library/items?itemKey=4IRKVFFX. The older format also included the libraryID -- I guess that isn't needed? Are items selected inconsistently with this new format as well?

@jlegewie
Copy link
Author

I would check with Dan about any changes to the format. In his post, he mentioned that the protocol handler still needs work in 5.

There is a different format for group libraries but I am not sure how it works. I thought it's this zotero://select/groups/317405/items?itemKey=VK9JBHWK but that doesn't work.

@wshanks
Copy link
Owner

wshanks commented Feb 17, 2017

Hmm, in very limited testing, the zotero://select/groups/317405/items?itemKey=VK9JBHWK format worked for me for groups. I tried some other formats just to experiment and found that some unsupported formats resulted in the same item getting selected each time. Maybe that is similar to what you were seeing (maybe something was not formatted properly in your links?).

@dstillman maybe you can comment here. Zutilo has functions for copying either an item's select link or its Zotero URI (currents versions are here). I assume the URI function doesn't need to change because it just uses Zotero.URI.getItemURI, but it seems like the select link format is old. What would be the best way to update it (least likely to break in the future)? Here is what I think would work for the newer format, but I am wondering if there is an equivalent to Zotero.URI.getItemURI that would be more robust to future changes.

var libraryType = Zotero.Libraries.get(item.libraryID).libraryType;

switch (libraryType) {
	case 'group':
		var path = Zotero.URI.getLibraryPath(item.libraryID)
		break;
	case 'user':
		var path = 'library'
		break;
	default:
		// Feeds?
		alert('Unsupported type')
}

var link = 'zotero://' + path + '/items?itemKey=' + item.key

@dstillman
Copy link
Contributor

I tried some other formats just to experiment and found that some unsupported formats resulted in the same item getting selected each time.

Old formats should still work, so if they're not, let me know what you're seeing and we can fix.

Your proposed code should work. (In theory it should also work with /items/<itemKey>, though I'm not sure if it does currently.) There's no equivalent function, but we could have one (e.g., Zotero.URI.getClientURI(obj)) that took an object or an array of objects and generated an appropriate URI.

(Related: We should also support users/<userID> in order to mirror the web API more closely. /library allows it to work even if the local user account changes, though, so if the function supported that it should probably be optional.)

@wshanks
Copy link
Owner

wshanks commented Sep 24, 2017

I'm closing this because I think the conclusion was that the format Zutilo uses still works. Perhaps Zutilo should be updated to use the newer format but it seems like there are still some future changes planned to the protocol handler (like zotero/zotero#1176) so I'll leave it alone for now.

There was also the suggestion about adding the option to change the link format to markdown or html, but I think that can be done with an export translator and Zutilo's quickcopy shortcut, so I won't add a separate function for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants