stefanopagliari / bibnotes

359 stars 30 forks source link

get zotero url of the attachment #154

Closed awkar closed 1 year ago

awkar commented 1 year ago

I have a question to get the url of the pdf in the zotero item using the md template. To get the path to the attachment, I use the {{file}}, and I can use Adobe to read it. But I also want to read it in Zotero. Thus, I want to get zotero://open-pdf/library/items/"attachment's itemkey". On the other hand, I want to get the "select" of the attachment. I find that {{attachments}} is available, but I can't get the values in it.

{
      "key": "XLH7KWT6",
      "version": 7179,
      "itemType": "preprint",
      "title": "Actor-Attention-Critic for Multi-Agent Reinforcement Learning",
      "abstractNote": "Reinforcement learning in multi-agent scenarios is important for real-world applications but presents challenges beyond those seen in single-agent settings. We present an actor-critic algorithm that trains decentralized policies in multi-agent settings, using centrally computed critics that share an attention mechanism which selects relevant information for each agent at every timestep. This attention mechanism enables more effective and scalable learning in complex multi-agent environments, when compared to recent approaches. Our approach is applicable not only to cooperative settings with shared rewards, but also individualized reward settings, including adversarial settings, as well as settings that do not provide global states, and it makes no assumptions about the action spaces of the agents. As such, it is flexible enough to be applied to most multi-agent learning problems.",
      "date": "2019-05-27",
      "libraryCatalog": "arXiv.org",
      "url": "http://arxiv.org/abs/1810.02912",
      "accessDate": "2023-01-07T14:55:28Z",
      "rights": "\u6ce8\u610f\u529b\u673a\u5236",
      "extra": "arXiv:1810.02912 [cs, stat]",
      "DOI": "10.48550/arXiv.1810.02912",
      "creators": [
        {
          "firstName": "Shariq",
          "lastName": "Iqbal",
          "creatorType": "author"
        },
        {
          "firstName": "Fei",
          "lastName": "Sha",
          "creatorType": "author"
        }
      ],
      "tags": [
        {
          "tag": "/unread",
          "type": 1
        }
      ],
      "relations": [],
      "dateAdded": "2023-01-07T14:55:28Z",
      "dateModified": "2023-01-07T14:59:31Z",
      "uri": "http://zotero.org/users/6484617/items/XLH7KWT6",
      "itemID": 4095,
      "attachments": [
        {
          "itemType": "attachment",
          "title": "Iqbal_Sha_2019_Actor-Attention-Critic for Multi-Agent Reinforcement Learning.pdf",
          "tags": [],
          "relations": [],
          "dateAdded": "2023-01-07T14:59:30Z",
          "dateModified": "2023-01-07T14:59:31Z",
          "uri": "http://zotero.org/users/6484617/items/SKMPVHUV",
          "path": "D:\\ZoteroFile\\storage\\SKMPVHUV\\Iqbal_Sha_2019_Actor-Attention-Critic for Multi-Agent Reinforcement Learning.pdf",
          "select": "zotero://select/library/items/SKMPVHUV"   % which I want to get
        }
      ],
      "notes": [],
      "citationKey": "iqbalActorAttentionCriticMultiAgentReinforcement2019",
      "itemKey": "XLH7KWT6",
      "libraryID": 1,
      "select": "zotero://select/library/items/XLH7KWT6",
      "number": "arXiv:1810.02912",
      "publisher": "arXiv"
}

How do I get that value? Look forward to your reply. Thank you!

stefanopagliari commented 1 year ago

Hi @awkar. Adding {{select}} to the template returns that value. I'm closing this but please reopen it and tag me if it does not work on your end

awkar commented 1 year ago

Hi @stefanopagliari. I'm so sorry that I find your response today. I add {{select}} to the template and find that it returns the same value as {{localLibraryLink}}, which is the URL for the item in Zotero (zotero://select/library/items/XLH7KWT6), not the PDF file's (zotero://select/library/items/SKMPVHUV). In other word, when clicking the value returning from {{select}} or {{localLibraryLink}}, I cannot open the PDF in Zotero directly.

awkar commented 1 year ago

I have another question. I add these code in the template:

create_time: <% tp.date.now("YYYY-MM-DD") %>
update_time: <% tp.date.now("YYYY-MM-DD") %>
importance: #normal

Therefore, I can get the create time and update time directly.

create_time: 2023-01-10
update_time: 2023-01-10
importance: #normal

Then, I read the paper and change the importance, #good.

importance: #good

When I reload the same item into obsidian, I will get

create_time: <% tp.date.now("YYYY-MM-DD") %>
update_time: <% tp.date.now("YYYY-MM-DD") %>
create_time: 2023-01-10
update_time: 2023-01-10
importance: #normal
importance: #good

How can I set that only changing the update time automatically when reload, but not changing the create time and the importance label. In my imagination, I will get below in obsidian when I reload the item.

create_time: 2023-01-10
update_time: 2023-01-13
importance: #good

I think it will be very difficult and I should try to improve my template, which is not this plugin's problem. Can you give me some advice?

stefanopagliari commented 1 year ago

Hi @stefanopagliari. I'm so sorry that I find your response today. I add {{select}} to the template and find that it returns the same value as {{localLibraryLink}}, which is the URL for the item in Zotero (zotero://select/library/items/XLH7KWT6), not the PDF file's (zotero://select/library/items/SKMPVHUV). In other word, when clicking the value returning from {{select}} or {{localLibraryLink}}, I cannot open the PDF in Zotero directly.

@awkar I have added in the new version (0.9.217) a new available filed in the template called filePath. This links to the specific attachment (or multiple attachments) within zotero. This is different from {{file}} that opens the attachment in an external reader. Could you please test it and let me know if this works?

stefanopagliari commented 1 year ago

I have another question. I add these code in the template:

create_time: <% tp.date.now("YYYY-MM-DD") %>
update_time: <% tp.date.now("YYYY-MM-DD") %>
importance: #normal

Therefore, I can get the create time and update time directly.

create_time: 2023-01-10
update_time: 2023-01-10
importance: #normal

Then, I read the paper and change the importance, #good.

importance: #good

When I reload the same item into obsidian, I will get

create_time: <% tp.date.now("YYYY-MM-DD") %>
update_time: <% tp.date.now("YYYY-MM-DD") %>
create_time: 2023-01-10
update_time: 2023-01-10
importance: #normal
importance: #good

How can I set that only changing the update time automatically when reload, but not changing the create time and the importance label. In my imagination, I will get below in obsidian when I reload the item.

create_time: 2023-01-10
update_time: 2023-01-13
importance: #good

I think it will be very difficult and I should try to improve my template, which is not this plugin's problem. Can you give me some advice?

@awkar do you have the setting activated that prevents the over-write of manual changes to the notes? I imagine that the plugin interprets the changes made by templates to the date field as a manual input and it does not overwrite them. If that is the case you need to either turn down that option, or define an area that where changes to the note should be overwritten (it is possible to set text delimiters)

awkar commented 1 year ago

Hi @stefanopagliari. I'm so sorry that I find your response today. I add {{select}} to the template and find that it returns the same value as {{localLibraryLink}}, which is the URL for the item in Zotero (zotero://select/library/items/XLH7KWT6), not the PDF file's (zotero://select/library/items/SKMPVHUV). In other word, when clicking the value returning from {{select}} or {{localLibraryLink}}, I cannot open the PDF in Zotero directly.

@awkar I have added in the new version (0.9.217) a new available filed in the template called filePath. This links to the specific attachment (or multiple attachments) within zotero. This is different from {{file}} that opens the attachment in an external reader. Could you please test it and let me know if this works?

I'm very excited to find that the field {{filePath}} works. It can link to the attachments in the Zotero even there are multiple attachments. But I have one more requirement. The field {{filePath}} returns "zotero://select/library/items/xxxxx" which can match many types of file formats. And when clicking the link in Obsidian, it can open the Zotero and jump to the certain item. In my notes, most of the file are in PDF format. Therefore, would you have the plan to add one more field that returns "zotero://open-pdf/library/items/xxxxxx"? In this way, I can directly open the PDF in Zotero when I click the link in Obsidian. Anyway, the field {{filePath}} is really useful. Thank you again,

awkar commented 1 year ago

I have another question. I add these code in the template:

create_time: <% tp.date.now("YYYY-MM-DD") %>
update_time: <% tp.date.now("YYYY-MM-DD") %>
importance: #normal

Therefore, I can get the create time and update time directly.

create_time: 2023-01-10
update_time: 2023-01-10
importance: #normal

Then, I read the paper and change the importance, #good.

importance: #good

When I reload the same item into obsidian, I will get

create_time: <% tp.date.now("YYYY-MM-DD") %>
update_time: <% tp.date.now("YYYY-MM-DD") %>
create_time: 2023-01-10
update_time: 2023-01-10
importance: #normal
importance: #good

How can I set that only changing the update time automatically when reload, but not changing the create time and the importance label. In my imagination, I will get below in obsidian when I reload the item.

create_time: 2023-01-10
update_time: 2023-01-13
importance: #good

I think it will be very difficult and I should try to improve my template, which is not this plugin's problem. Can you give me some advice?

@awkar do you have the setting activated that prevents the over-write of manual changes to the notes? I imagine that the plugin interprets the changes made by templates to the date field as a manual input and it does not overwrite them. If that is the case you need to either turn down that option, or define an area that where changes to the note should be overwritten (it is possible to set text delimiters)

Thank you for your reply. I am so sorry to find that there are so many functions I don't know in the plugin. You mentioned "define an area that where changes to the note should be overwritten (it is possible to set text delimiters)". I think it is what I want. But I don't know how to operate. Thus, I will take some time to learn how to use this plugin. If I have some troubles to achieve my needs, I would like to seek your help. Thank you very much.

stefanopagliari commented 1 year ago

Hi @stefanopagliari. I'm so sorry that I find your response today. I add {{select}} to the template and find that it returns the same value as {{localLibraryLink}}, which is the URL for the item in Zotero (zotero://select/library/items/XLH7KWT6), not the PDF file's (zotero://select/library/items/SKMPVHUV). In other word, when clicking the value returning from {{select}} or {{localLibraryLink}}, I cannot open the PDF in Zotero directly.

@awkar I have added in the new version (0.9.217) a new available filed in the template called filePath. This links to the specific attachment (or multiple attachments) within zotero. This is different from {{file}} that opens the attachment in an external reader. Could you please test it and let me know if this works?

I'm very excited to find that the field {{filePath}} works. It can link to the attachments in the Zotero even there are multiple attachments. But I have one more requirement. The field {{filePath}} returns "zotero://select/library/items/xxxxx" which can match many types of file formats. And when clicking the link in Obsidian, it can open the Zotero and jump to the certain item. In my notes, most of the file are in PDF format. Therefore, would you have the plan to add one more field that returns "zotero://open-pdf/library/items/xxxxxx"? In this way, I can directly open the PDF in Zotero when I click the link in Obsidian. Anyway, the field {{filePath}} is really useful. Thank you again,

@awkar In 0.9.219 I have added the placeholder {{zoteroReaderLink}} that directly opens the file in the Zotero PDF reader