Chris911 / Ask-Stack-Atom

Ask Stack Overflow for Atom
https://atom.io/packages/ask-stack
MIT License
124 stars 22 forks source link

Include source link when importing examples #33

Closed dhm116 closed 8 years ago

dhm116 commented 8 years ago

Based on the animated gif showing the plugin usage, it did not appear that a link to the original SO post was included when importing code. That should probably be added, right?

Chris911 commented 8 years ago

You mean in the copied code? Good idea. Only problem is that the comment syntax is different based on the current language which makes this a bit more complicated.

dhm116 commented 8 years ago

I haven't had time to dig into whether this would work or not, but would something like https://atom.io/docs/api/v1.4.1/Selection#instance-toggleLineComments work?

Chris911 commented 8 years ago

Perhaps. Thanks for the suggestion.

hazrpg commented 8 years ago

I came across this thread because I was thinking about implementing something like this - if I get chance I will give it a go. Thanks @dhm116 for the API reference.

ChristopherKing42 commented 8 years ago

It should be noted that you are technically required to provide a link to StackOverflow code, unless using it under fair use.

See http://blog.stackoverflow.com/2009/06/attribution-required/

Chris911 commented 8 years ago

Yep for the time being. This will change in a few weeks though: http://meta.stackexchange.com/questions/272956/a-new-code-license-the-mit-this-time-with-attribution-required

ChristopherKing42 commented 8 years ago

@Chris911 Well, they changed their mind I'm pretty sure (given the vote). We have no idea what the license is going to be.

hazrpg commented 8 years ago

@ChristopherKing42 this was part of the reason for my previous patch that was @Chris911 applied to the release - since the questions and answers listed didn't either show the original author or wasn't linked back to their profile (which is point 3 and 4 of the above link).

@Chris911 already had a link back to the question (point 2). And point 1 is obvious from the package and the tab's name.

I appreciate that those changes I did in the last update are for the interface, and not for the imported code examples, but since the package is essentially publishing the data it should also conform there too.

Most good programmers will attribute the authors anyway, and the package does provide them with enough information for them to do so. That said, I'm sure that if @Chris911 doesn't do it for the code imports, then I probably will when I get the time to. Since it would be nice for it to do it automatically.

To make this issue report more constructive, I think we should discuss the style we would like it to appear in the code.

hazrpg commented 8 years ago

@dhm116 thanks for the link, I ended up passing in a {select: true} as an option for insertText(text, [options]), and then using toggleLineCommentsInSelection() followed by toggleLineCommentsInSelection().

EDIT: I also coupled this by using the transact method which allows you to wrap several amendments as part of one undo transaction - so that you don't have to undo multiple edits to the document.

E.g.

editor = atom.workspace.getActivePaneItem();
editor.transact =>
  editor.insertText('hello', {select: true});
  editor.toggleLineCommentsInSelection();
  editor.insertNewlineBelow();

  editor.insertText('world', {select: true});
  editor.toggleLineCommentsInSelection();
  editor.insertNewlineBelow();

This will insert "hello" and comment it out, add a new line, insert "world", comment that out, and insert a new line, then you can undo the two commented out lines with one simple undo.

hazrpg commented 8 years ago

I believe this can now be closed, right?

dhm116 commented 8 years ago

I think so. Fixed via https://github.com/Chris911/Ask-Stack-Atom/issues/35

Chris911 commented 8 years ago

I'm also updating the animated gif in the README to reflect the new changes.

hazrpg commented 8 years ago

Nice! Hopefully it might attract more people seeing the new additions. Just a small one, but it might be worth adding a link to the package in the repo description. https://atom.io/packages/ask-stack

Chris911 commented 8 years ago

There's already a link in the README under "package homepage" but I can add it in description on top as well.

hazrpg commented 8 years ago

True, I only added it to the description in my fork because I'm lazy. However, it is also the first place I look when seeing someone's repo, so I can only imagine that's where most people would look first too.

hazrpg commented 8 years ago

@Chris911 just noticed that the gif/image hadn't been updated. Thought I would mention it incase you created it but forgot to upload it.

Chris911 commented 8 years ago

Yeah I created it but the image size was too big (15+ mb). I might give it another go this week. Ideally I'd like to host the image not in the repo as it will increase the size for nothing.

hazrpg commented 8 years ago

This might be an alternative solution for doing just that: https://git-lfs.github.com/ or alternatively, create a new repo for resource files such as images and link to it that way? There's also things like imgur, etc...