-
Notifications
You must be signed in to change notification settings - Fork 429
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
Comments
How would I export to html ? |
@majkinetor What do you mean by "export to HTML"? Be more specific please. |
Tab to html page ? |
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 |
What about images ? |
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 += '" />'
} |
Totally epic. Thanks. NOTE: |
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. |
Cancel that. Copying the entire folder over does work. Thanks. |
Implementation is in What is not imported:
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. |
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.
The text was updated successfully, but these errors were encountered: