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

Feature: Insert links to other notes #36

Merged
merged 12 commits into from
Aug 1, 2014
Merged

Feature: Insert links to other notes #36

merged 12 commits into from
Aug 1, 2014

Conversation

rahul-ramadas
Copy link

Continued from #34.

The command allows browsing the note store to find a note, a link to
which is inserted into the current view. The command is available
only when editing a note.
Commands to allow browsing to, searching for, or picking from recent,
the note to which a link should be inserted.
In case a window command would like to operate on the active view,
save a reference to it early on so that unexpected things don't happen
if the active view changes.
The is_enabled method of the insert link command was checking to see
if the evernote GUID setting was present in the view. However, since
new notes don't yet have GUIDs, this prevents the command from being
available in a new note view. Hence, change to check the syntax
instead to see if it is an Evernote note.
I realized that there is already a setting, $evernote, that is set on
views created by Evernote. It wasn't getting set for new notes,
however. This change sets the setting for new notes as well, then
fixes the is_enabled for the insert links command to use that instead.
A text command that opens the note pointed to by the link currently
under the cursor.
I felt like the 'Open linked note' command would be more discoverable
if it was visible but disabled when on an Evernote note, and enabled
when the cursor is on a link
A command that lists all the linked notes in the current note,
allowing you to open them from a quick panel.
@rahul-ramadas
Copy link
Author

I just noticed something: when the Evernote official clients insert a note link, the link color is green, whereas links inserted by Sublime-Evernote are always blue (same color as regular links inserted by Evernote official clients). I guess Evernote client is setting the link color directly. Doesn't look like there is much we can do, aside from doing some post-processing on the markdown formatting output.

@bordaigorl
Copy link
Owner

Ah! can you inspect the HTML inside the note? Maybe they are hardcoding the color of the link in the style.
In principle it should not be too difficult to do the same by modifying markdown2 but we then need to keep an eye on how html2text reacts to that.
All in all it's not a big deal but if we can make it work, all the better!

@rahul-ramadas
Copy link
Author

The <a> tag has a style attribute with color: rgb(105, 170, 53); hardcoded.

@bordaigorl
Copy link
Owner

Ok, html2text does not seem disturbed by this so after merging I can add support for custom styles for <a> tags and evernote:// links.
It's just a couple of changes in markdown2.

@rahul-ramadas
Copy link
Author

@bordaigorl Can you please take a look at this change: https://github.com/rahul-ramadas/sublime-evernote/pull/2

I realized that with all this functionality for working with links, I have all the pieces to add another feature that I have sometimes needed: the ability to open the note in the Evernote client. This commit adds that as well.

I have a request though: if you have a Mac can you try out the feature on OSX and see if it works? I have tested it on Windows. Linux does not have an official client, but I am calling xdg-open just in case a 3rd-party client is able to handle it (I haven't tested it).

@bordaigorl
Copy link
Owner

@rahul-ramadas that's a good idea, I only included the Open in Webapp one because that's what I use (I'm on Linux).
I do not have a Mac to test it but we can maybe just put a note in the docs saying it's untested for Mac and then if it is buggy we'll get an issue from somebody?

As for Linux an xdg-open evernote://BLA should do the job as long as the system has been properly configured to open these urls with the right handler; so maybe some error catching with a meaningful error dialog would be nice.
It think the user needs the following to make it work

gconftool-2 -s -t string /desktop/gnome/url-handlers/evernote/command 'YOUR-CLIENT "%s"'
gconftool-2 -s -t bool /desktop/gnome/url-handlers/evernote/enabled true

Thanks for the love you are giving to the plugin!
I am currently very busy but I promise you I will merge this PR soon.

Implemented a command to open the current note in the Evernote client,
if it is installed. Perfectly complements the existing 'Open in Web
App' command.
@rahul-ramadas
Copy link
Author

I've merged the new feature in. I couldn't figure out a good way to know if the open actually worked. On Windows, if the client is not installed, you get a prompt for selecting an application that can handle the URL.

bordaigorl pushed a commit that referenced this pull request Aug 1, 2014
Feature: Insert links to other notes
@bordaigorl bordaigorl merged commit 2a7855b into bordaigorl:links-to-notes Aug 1, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants