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

Small enhancement to import Google Bookmarks - with some code draft #316

Open
krylm opened this issue Sep 24, 2021 · 2 comments
Open

Small enhancement to import Google Bookmarks - with some code draft #316

krylm opened this issue Sep 24, 2021 · 2 comments
Labels
Enhancement Any requests for improvements or new features

Comments

@krylm
Copy link

krylm commented Sep 24, 2021

Thank you for LInkAce. I was looking for replacement for Google Bookmarks manager and LinkAce is right option for me.

I have almost 10k links stored in Google Bookmarks and every link has 4 or more tags. This results in 9 MB file GoogleBookmarks.html to import. Current setup imports all links, but only with one tag. Every other tags are ignored because of duplicit in other section with different name.

I've created short preprocessing function to aggregate tags to according links before storing to database. And everything is correctly imported to database.

I don't have skill enough (and don't know Laravel fw at all) to create pull request to modify behaviour or make some other option to import GoogleBookmarks in aggregated way.

But I can share code snippet, which worked for me, to implement it in codebase if you want.
https://github.com/Kovah/LinkAce/blob/main/app/Actions/ImportHtmlBookmarks.php#L42

function preprocess_bookmarks($data) {
    $output = [];
    foreach ($data as $k => $v) {
        $found = False;
        foreach ($output as $idx => $item) {
            if ( $item['uri'] == $v['uri'] ) {
                $found = $idx;
                break;
            }
        }

       if ($found !== False) {
            $output[$found]['tags'][] = $v['tags'];
        } else {
            $add_item = $v;
            $add_item['tags'] = array($v['tags']);
            $add_item['title'] = addslashes( html_entity_decode($v['title'], ENT_QUOTES | ENT_XML1, '                                                      UTF-8') );
            $add_item['note'] = addslashes( html_entity_decode($v['note'], ENT_QUOTES | ENT_XML1, 'UT                                                      F-8') );
            $output[] = $add_item;
        }
    }

    return $output;
}


// preprocessing

$links = preprocess_bookmarks($links);

And modify exploding tags variable to don't explode it at all.
https://github.com/Kovah/LinkAce/blob/main/app/Actions/ImportHtmlBookmarks.php#L72

// $tags = explode(' ', $link['tags']);
$tags = $link['tags'];

With this small modification I was able to import complete file from Google Bookmarks and migrade to LinkAce.

@krylm krylm added the Enhancement Any requests for improvements or new features label Sep 24, 2021
@Kovah
Copy link
Owner

Kovah commented Sep 27, 2021

Hi! Thanks for the valuable feedback. I got other reports of imports from Chrome being broken. I will take a look when I have the time.

@Kovah
Copy link
Owner

Kovah commented Dec 12, 2021

Also requested by @Fivefold

Additional info:

This seems to be related to the used shaarli bookmark parser (see sebsauvage/Shaarli#22).

@Kovah Kovah moved this to Ideas & Requests in LinkAce Roadmap Aug 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement Any requests for improvements or new features
Projects
Status: Ideas & Requests
Development

No branches or pull requests

2 participants