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

Import from other places #66

Open
fiatjaf opened this issue May 8, 2018 · 2 comments
Open

Import from other places #66

fiatjaf opened this issue May 8, 2018 · 2 comments
Labels

Comments

@fiatjaf
Copy link

fiatjaf commented May 8, 2018

Is there an easy way to import bookmarks from other places?

Or maybe there's a way to inject the data directly on remoteStorage, but what is the format the data is expected to have?

@raucao
Copy link
Owner

raucao commented May 8, 2018

I had something in some branch years ago (iirc it was importing from Delicious), but there's nothing supported in the app right now.

You could easily write an import script for node.js and/or browsers, using rs.js and the bookmarks module. Something like this should be enough (not tested):

import RemoteStorage from 'remotestoragejs';
import RemoteStorage from 'remotestorage-module-bookmarks';

const remoteStorage = new RemoteStorage({modules: [Bookmarks.default]});
remoteStorage.access.claim('bookmarks', 'rw');
remoteStorage.connect('[email protected]', 'this-could-be-an-oauth-token');

const bookmarks = [];
// Fill up bookmarks with stuff to import;

function importBookmarks () {
  bookmarks.forEach(bookmark => {
    remoteStorage.bookmarks.archive.store({
      title: bookmark.title,
      url: bookmark.url,
      description: bookmark.desc,
      tags: bookmark.tags // array of strings
    })
    .then(() => console.log(`Imported ${bookmark.url}`).
    .catch(err => console.error(`Failed to import ${bookmark.url}:`, err));
  });
});

The store() function will validate the format using the data module JSON Schema, and it would tell you exactly what's wrong or missing. Also, this function would be idempotent (meaning you can run it multiple times with the same result and no additional bookmarks stored), because the bookmarks' ID (and thus document/file name) will automatically be the MD5 hash of the URL.

@raucao raucao added the feature label Feb 1, 2019
@raucao
Copy link
Owner

raucao commented Feb 1, 2019

I definitely want some kind of feature to import bookmarks from popular silos. However, I'm wondering if it belongs in Webmarks itself, or if it should be part of some larger data liberation app/agent.

I guess even if the app wouldn't connect to proprietary APIs, it could at least allow to import from exported-data files from those services.

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

No branches or pull requests

2 participants