arxiv2notion icon indicating copy to clipboard operation
arxiv2notion copied to clipboard

Advice for adding date

Open vitchyr opened this issue 4 years ago • 1 comments

Thank you for this plugin! I would like to modify this to automatically download the date that the paper was published. I have experience programming, but I don't have much experience with JavaScript or using the Notion API. Do you have suggestions for how to get started (e.g., files/lines I need to modify) to make this modification? I'd be happy to make a PR for this if I finish this.

vitchyr avatar Nov 12 '21 17:11 vitchyr

@vitchyr

Hi, I would like to share some information to extend this extension. (I hope this information would also help other users)

How to debug your extension

  • change this line to the following https://github.com/denkiwakame/arxiv2notion/blob/main/src/js/popup.js#L19
    • this will query arxiv information not from the current tab data but from the hard-coded URL.
- this.getCurrentTabUrl();
+ this.getPaperInfo(TEST_URL);
  • $ npm install & npm run build build the extension locally
  • navigate to chrome://extension
    • turn on developer mode
    • select load unpacked and open arxiv2notion/dist
    • you can see the extension ID like aedplelmaaaldilfkeobdapccljxxxxx in the loaded extension description
    • open chrome-extension://aedplelmaaaldilfkeobdapccljxxxxx/popup.html
  • open chrome developer tools in your browser (Ctrl + Shift + i w/Linux)
    • you can see debugging outputs (\eg console.log()) in the devtools.
  • once you load unpacked , the extension is automatically synced whenever you run npm run build and reload chrome-extension://${your-extension-id}/popup.html
  • you will be able to know more about how everything is working.

image

Change Notion database scheme

  • If you attempt to add a new column like published date , you need to add it in your notion.so manually https://github.com/denkiwakame/arxiv2notion#getting-started or via Notion API https://developers.notion.com/reference/update-a-database

Get arXiv published date

  • To retrieve arXiv paper information, this extension utilizes arXiv public API.
  • You can see properties available in the current API https://arxiv.org/help/api/basics
  • For example, if you need published , you can add some code to obtain the target property.
    • https://github.com/denkiwakame/arxiv2notion/blob/main/src/js/popup.js#L112-L124
    • const published = entry.querySelector("published").textContent;
  • The retrieved contents will be posted by this line https://github.com/denkiwakame/arxiv2notion/blob/main/src/js/popup.js#L49
    • Thus you need to add properties to https://github.com/denkiwakame/arxiv2notion/blob/main/src/js/popup.js#L127

Post to notion.so

  • Add property to https://github.com/denkiwakame/arxiv2notion/blob/main/src/js/notion.js#L62-L118
  • You may need to follow the Notion API date format. https://developers.notion.com/reference/page#date-property-values
  • I haven't tested though, maybe like this ?
        Published: {
          id: "published",
          type: "date",
          date: { start: "2020-12-08T12:00:00Z", end: null },
        },

Oh, wait, when I finished up writing this, I realized that customizing this extension is somewhat troublesome. :skull_and_crossbones: I designed the default database scheme simplest so that it would meet the demand for diversified potential users. I will be considering to update this extension so that the user can select properties on-demand without coding. If you don't mind, could you please give me some feedback on the desired properties (database scheme) or UIs to save on notion.so ?

denkiwakame avatar Nov 13 '21 05:11 denkiwakame

Merged: https://github.com/denkiwakame/arxiv2notion/pull/6

denkiwakame avatar Jan 08 '24 04:01 denkiwakame