How to share comparison of two Observable notebooks

Dear Observable team:

I have a fork notebook Observable

when i click on compare fork, a diff page is created

May i know what i have to do to share the above comparison page with other people. It shows “Sorry, we couldn’t find that page” when i opened this link in another browser.

Capture3

thank you :grinning:

It appears that version 156 of your notebook is private:

Thus the compare link ends up being private as well. I don’t know if there’s a way to directly share a link to a previous version which is private, since the “Enable link sharing” menu item doesn’t appear.

One workaround which comes to mind is to use the “History” feature to revert to the old version and then re-publish your notebook. You can then “revert the revert” to go back to your previously published version, re-publish yet again, and then share the compare link.

As far as I’m aware only shared and published revisions can be accessed. These are marked in the History timeline.

There is another workaround, due to the fact that comparing works for arbitrary notebooks:

  1. Open the history and select the revision in question.
  2. Create a fork and share.
  3. Adjust your compare link to point to your fork.

That way unnecessary reverts on the original notebook can be avoided. Which method is preferable though is probably up to personal taste. :slight_smile:

1 Like

Thanks Mootari and Brian for your suggestion,

I made a few adjustment of notebook comparison, and I found the inaccessible comparison link happens under the following condition.

  1. Notebook1 is public (latest version 156).
    https://observablehq.com/@kun-ting/issue-forked-referenced-cell-within-a-function-not-reflect

  2. Create a fork Notebook2 (version 158) from version 156 of Notebook 1 and publish
    https://observablehq.com/@kun-ting/issue-forked-from-updated-referenced-cell-within-a-functio

  3. Click on “compare with fork” to compare “Notebook2 to Notebook1”
    https://observablehq.com/compare/9853f4ec6ffb0aef@156...156388149e55bc95@158

  4. This diff page shows page not found when opened in another browser, although version 156 and 158 are both public.

Currently I solved this issue by the other way around, i.e., compare “Notebook1 to Notebook2”.

  1. In the Notebook2 v158 from step2,

  2. Go to View History, select the very first version (v156) when it was forked out from Notebook1

  3. Fork this version (as if it is same as Notebook1) to Notebook3 (v158)
    https://observablehq.com/@kun-ting/issue-updated-forked-from-history-v156-referenced-cell-wit

  4. Click “compare with fork” which compares “Notebook3 (which is Notebook1) to Notebook2”

  5. This link is able to share
    https://observablehq.com/compare/156388149e55bc95@158...16578ff12875066f@160

Is this same as what your explained?

Another scenario which shows error page is when comparing within a public notebook, i.e., comparing history to its latest, in above Notebook3, when clicking “view history” and select version 156, then “compare to latest”

The above link is also not shareable although both 156 and 160 are public.

It seems currently the only working solution to share a diff page is to publish, then go to history, fork out, publish, edit, and then compare with fork.

Please correct me if i’m wrong.
Thank you

Just so we’re on the same page: by “publish” you mean creating a share link, right? That is, you’re aware that you don’t have to “publish”-publish a notebook to grant access?

@tom Would it be possible to allow retroactive sharing of past revisions?

Technically you can publish or share older versions through the API using the developer console, but this capability is not exposed in the UI (and if you published an older version it would replace the version shown to readers); the Publish and Reshare buttons always use the latest version of the notebook.

In general we don’t expose all versions in history because we think it’s better for authors to have control over what versions are visible to readers, but we don’t currently allow retroactive toggling to which individual versions are visible. The easiest way to workaround that currently is probably to fork the notebook at the versions you want to share and then share or publish those separately.

1 Like

And here’s a handy function to do just that:

function share(identifier, unlisted = true) {
  const [id, rev] = identifier.split('@', 2);
  return fetch(`https://api.observablehq.com/document/${id}/publish`, {
    method: 'POST',
    credentials: 'include',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify({
      token: document.cookie.match(/\bT=([a-f0-9]{32})/)[1],
      version: +rev, unlisted, 
    })
  });
}

Just drop the code in the console, then copy the document ID + version from the URL (ideally while in the history view), and call the function like this:

share("62f151d62ae2dbf1@10")
share("62f151d62ae2dbf1@5")
share("62f151d62ae2dbf1@8")

Each shared revision will then be accessible.

3 Likes