Open jywarren opened 6 years ago
@jywarren am unable to get where we need to add the checkboxes.
Hi @amitsin6h ... I think we need to change this files :
1.) https://github.com/publiclab/plots2/blob/master/app/models/revision.rb
2.) https://github.com/publiclab/plots2/blob/master/config/initializers/constants.rb
For Regex expression , we can test here : http://rubular.com/ .
Thanks !
Awesome, @sagarpreet-chadha -- great; @amitsin6h we'd love your help with this! I think we could start with just converting checkboxes in Markdown into HTML checkboxes. Then we can think about how to make them "checkable". One at a time, like a checklist! :-)
This has been marked as a good candidate for becoming a first-timers-only issue like these, meaning that it's simple, self-contained, and with some extra formatting, could be a great entry point for a new contributor. If you're familiar enough with this code, please consider reformatting or reposting it as a first-timers-only issue, and then ping @publiclab/reviewers to get it labelled. Or, if this is not your first time, try to solve it yourself!
Here's a Regex expression which will find * [ ]
or - [x]
: http://rubular.com/r/wmVibUgpIt
/[-|\*] \[( |x)\]/
You could use it like this:
string.gsub(/[-|\*] \[( |x)\]/) do |match|
checked = " checked='true'" if match == "x"
"* <input type='checkbox' disabled='disabled' #{checked}/>"
end
Hi, all! @amitsin6h any interest in this one, or is it up for grabs? Thank you!!!
I want to try this.. first timer here
Great !!!!! Ask @publiclab/reviewers team here in case of any doubt .
Thanks so much 😃 🎈 !
@publiclab/soc if anyone's looking for a break or wants to make a full-fledged first-timers-only
issue out of this one, it'd be a fun one!
I'd like to help out if it's still open, first-timer and first time with open source. @sagarpreet-chadha @jywarren
That would be great :smile: !!!
@sagarpreet-chadha Thanks, I'll get started :)
@publiclab/reviewers looking for help on this issue Based on the comments on the page, I'm assuming that I need to:
I think I'm confused on how you actually render the checkboxes. So far I have:
constants.rb, added this line to search for checkbox
CHECKBOX = '/[-|\*] \[( |x)\]/'
revision.rb, added this line to the #render_body and #render_body_raw methods to search for checkboxes within body
def render_body
...
body = body.gsub(Callouts.const_get(:CHECKBOX), Callouts.const_get(:CHECKBOX))
end
def render_body_raw
body = body.gsub(Callouts.const_get(:CHECKBOX), Callouts.const_get(:CHECKBOX))
end
I think those edits might be okay, if I'm understanding this task, but I'm confused on where we actually add the checkboxes? @sagarpreet-chadha gave some great hints in comments on how to use the regex, but unfortunately, I'm still a bit lost..
string.gsub(/[-|\*] \[( |x)\]/) do |match|
checked = " checked='true'" if match == "x"
"* <input type='checkbox' disabled='disabled' #{checked}/>"
end
How you translate that into the methods we need, e.g. the below method I wrote doesn't make sense to me because I'm not appending the checkboxes anywhere yet...
def checkbox
body.scan(Callouts.const_get(:CHECKBOX)).each do |match|
checked = " checked='true'" if match == "x"
# do we append to parent?
"* <input type='checkbox' disabled='disabled' #{checked}/>"
end
end
Also, I'm unsure of where exactly we're putting these checkboxes, and how I can test this locally? Any help/tips appreciated, thanks :)
Hi @cheneyshreve !
Great work so far 😄 ! I would recommend you to open a pull request with your changes .
This looks perfect !
CHECKBOX = '/[-|\*] \[( |x)\]/'
I guess we would need to take care of cases like [[]
or maybe ][[]
, etc . but we can do that later as a follow-up .
Okay so in this function :
body = body.gsub(Callouts.const_get(:CHECKBOX), Callouts.const_get(:CHECKBOX))
the first argument is the REGEX which searches the body for [ ]
and the second argument should be the one that replaces [ ]
with Checkbox tag <input type="checkbox">
--- this should also be a callout in constants.rb .
I hope this helps !! Thanks :)
This closed similar issue will make this more clear #1825 with PR #1826 😄 .
@cheneyshreve ...another way would be to make two pair of callouts .
One callout for parsing * [ ]
and after parsing replacing this via callout <input type="checkbox">
Another callout for parsing * [x]
which would be replaced by <input type="checkbox" checked>
What do you think ?
@sagarpreet-chadha thank you! I will take a look at the other issues you posted and follow-up.
@sagarpreet-chadha I have made some edits and submitted a PR. I know there are still issues, but hopefully I'm on the right track. Thank you for your kindness and support during this process!
This was completed by @cheneyshreve in #2452 - thanks!!!
I'm thinking about how we could get checkboxes to be editable as in GitHub. Could we break out some steps for that here?
It could use this code, for wikis:
But we'd have to think about how this works for research notes too. The above code seems based on this node.rb replace
method:
What do you think? This seems like a potentially large project, but we could think about how to break it up into smaller pieces... maybe working on research notes first?
We are preparing to participate in Google Code-in, and have reserved this issue for participants in GCI - but we'd love to have your help with another one! Please check out https://code.publiclab.org to see more.
Nodes on publiclab.org could use a means of making and checking off lists - just like her in github:
* [ ]
or* [x]
<ul>...
* [ ]
to* [x]
Lists are made in github flavor markdown like this:
Try making checklists in the comments here to see!