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

More general Import/Export #42

Closed
hluk opened this issue May 5, 2013 · 10 comments
Closed

More general Import/Export #42

hluk opened this issue May 5, 2013 · 10 comments
Assignees
Labels
feature New feature request

Comments

@hluk
Copy link
Owner

hluk commented May 5, 2013

Replace "Import/Export Tab" in File menu with more general "Import ...", "Export ...".

Export command will open simple dialog containing list with all tabs -- with only the current one selected by default -- and check boxes with whatever else to export.

Exported/imported could be none or multiple tabs, options, theme and commands. Accepting dialog should be disabled if nothing is selected to be exported/imported.

Import should provide the import dialog only if imported file contains anything else than single tab. This dialog should allow user to choose elements to import from imported file.

If commands are imported, existing commands should not be overwritten (the same goes for tabs).

Edit: Import dialog should be open even if imported file contains only single tab -- for user to review changes.

@majkinetor
Copy link

How would I export to html ?

@hluk
Copy link
Owner Author

hluk commented Feb 9, 2016

@majkinetor What do you mean by "export to HTML"? Be more specific please.

@majkinetor
Copy link

Tab to html page ?

@hluk
Copy link
Owner Author

hluk commented Feb 9, 2016

This task is about making backups or moving tabs and items to different installation.

Creating HTML page from tab would be possible using a custom command (importing the page back to the app could be possible but a bit more complicated).

You can do something like following (saves selected HTML and plain text items).

[Command]
Name=Save As HTML...
Command="
    copyq:
    currentpath(Dir().homePath())
    var defaultFileName = 'untitled.html'

    var fileName = dialog(
      '.title', 'Save Items As HTML...',
      '.width', 250,
      'File', File(defaultFileName)
    ) || abort()

    if (!fileName)
      abort()

    var f = File(fileName)
    if (!f.open()) {
      popup('Failed to open \"' + f.fileName() + '\"', f.errorString())
      abort()
    }

    var html = \"<html><body>\"

    var selected = selectedItems()
    for (var i in selected) {
      var item = getitem(selected[i])
      html += \"<p>\"
      if ('text/html' in item) {
        html += str(item['text/html'])
      } else if ('text/plain' in item) {
        html += escapeHtml(str(item['text/plain']))
      }
      html += \"</p>\"
    }

    html += \"</body></html>\"

    f.write(html)
    popup(\"Items Saved\", 'Items saved as \"' + f.fileName() + '\".')"
InMenu=true
Icon=\xf0c7
Shortcut=ctrl+s

@majkinetor
Copy link

What about images ?

@hluk
Copy link
Owner Author

hluk commented Feb 9, 2016

Sure, images can be saved separately and referenced in HTML or serialized with base64 encoding, e.g.:

if ('text/png' in item) {
  html += '<img src="data:image/png;base64,'
  html += str(toBase64(item['image/png']))
  html += '" />'
}

@majkinetor
Copy link

Totally epic. Thanks.

NOTE: text/png should be image/png.

@paul1149
Copy link

paul1149 commented Jun 3, 2016

I just upgraded my main machine to Linux Lite 3.0, which required a fresh install. I thought I would simply copy the old database files at /.config/copyq over to the new install but it's not happening. Is there something I'm missing about bringing in the old data? Thanks.

@paul1149
Copy link

paul1149 commented Jun 3, 2016

Cancel that. Copying the entire folder over does work. Thanks.

@hluk hluk mentioned this issue Feb 18, 2017
@hluk hluk self-assigned this Feb 18, 2017
hluk added a commit that referenced this issue Feb 18, 2017
hluk added a commit that referenced this issue Feb 19, 2017
hluk added a commit that referenced this issue Feb 19, 2017
hluk added a commit that referenced this issue Feb 19, 2017
hluk added a commit that referenced this issue Feb 19, 2017
@hluk
Copy link
Owner Author

hluk commented Feb 19, 2017

Implementation is in import-export branch.

What is not imported:

  • position and size for windows/dialogs
  • filter history
  • command history (from Action dialog)
  • underlying files for Synchronize plugins
  • encrypted tabs are imported decrypted (!)
  • public and secret keys from Encryption plugin (needs to be generated again)

For backup it's still better to back up the whole configuration folder manually since everything is not exported and import doesn't replace existing tabs and commands.

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

No branches or pull requests

3 participants