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

Options update #29

Merged
merged 3 commits into from
Aug 17, 2017
Merged

Options update #29

merged 3 commits into from
Aug 17, 2017

Conversation

swflint
Copy link
Contributor

@swflint swflint commented Jul 1, 2017

Create User-settable options and enable both new and old-style capture Links

@swflint
Copy link
Contributor Author

swflint commented Jul 1, 2017

Supercedes #27 and #25.

@sprig
Copy link
Owner

sprig commented Jul 3, 2017

Thanks for your contribution!

I am more inclined to accept this PR rather than #30.
However, please change default template tags that they are consistent with current ones. Likewise, I would like the new style links to only apply (by default) to new installations rather than updates to old ones.

In summary, if I already have the extension installed and I update to the new version, everything should continue working without my intervention.

@swflint
Copy link
Contributor Author

swflint commented Jul 3, 2017

If I may ask, why would you prefer this over #30? #30 continues this work, but adds further functionality, making the extension more useful.

I will certainly change the defaults though.

Copy link
Owner

@sprig sprig left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR! Sorry for taking so long to review it.

It looks good but there are several issues of varying severity, as you can see in the comments. Last moment I decided it would be easier to change them myself, so I'm approving the PR.

useOldStyleLinks: false
}, function(items) {
var uri = '';
if (selection != '')
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use consistent equality operator (see above)


if (selection != "") { uri += '/' + esc(selection); };
function createCaptureURL(template, title, url, selection, oldStyle) {
if (oldStyle == true)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if oldStyle is a boolean, there is no need for == true

if (selection != "") { uri += '/' + esc(selection); };
function createCaptureURL(template, title, url, selection, oldStyle) {
if (oldStyle == true)
return "org-protocol://capture:/"+template+'/'+url+'/'+title + ((selection === '') ? '' : ('/' + selection));
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use consistent equality operator (see below)

chrome.storage.sync.get({
selectedTemplate: 'p',
unselectedTemplate: 'L',
useOldStyleLinks: false
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please make the default to old style links, for the benefit of those who already have the extension installed.


console.log("Capturing the following URI with org-protocol:", uri);
function captureIt() {
var selection = window.getSelection().toString();
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please escape the selection as well, not just the title.

</tr>
<tr>
<td>
Use Old-Style Links?
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add write that new-style is the recommended option for supported org-mode versions above 9.0

if (oldStyle == true)
return "org-protocol://capture:/"+template+'/'+url+'/'+title + ((selection === '') ? '' : ('/' + selection));
else
return "org-protocol://capture?template="+template+'&url='+url+'&title='+title+((selection === '') ? '' : ('&body=' + selection));
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since you are using a regular URL syntax here, the selection should be escaped using encodeURIComponent as well.

@sprig sprig merged commit 19d4716 into sprig:master Aug 17, 2017
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