-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
added "Suggest new title" feature #2000
added "Suggest new title" feature #2000
Conversation
@jywarren I have a raw idea about this. Just like inline power tags there could be another syntax which could create the specified template for title suggestion (e.g {New title}). |
Generated by 🚫 Danger |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a pretty interesting approach -- happy to help refine it and get it ready! Thanks!
config/routes.rb
Outdated
@@ -6,6 +6,7 @@ | |||
post 'comment/create/token/:id.:format', to: 'comment#create_by_token' | |||
|
|||
get 'searches/test' => 'searches#test' | |||
post '/request_title_change/:id/:title' => 'notes#request_title_change' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we could simplify this and also not put the title itself in the path, as it may contain punctuation? It could be using ?title=____
instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, we could do the same with id!! Also we'd need to have a check in the request_title_update method, since the route could easily be manipulated to change the id or title so an authorisation check is a must at the back-end.
app/views/notes/_comment.html.erb
Outdated
@@ -64,7 +64,7 @@ | |||
</script> | |||
|
|||
<div id="c<%= comment.cid %>show"> | |||
<p><%= raw sanitize(auto_link(RDiscount.new(comment.body).to_html)) %></p> | |||
<p><%= raw sanitize (RDiscount.new(title_suggestion(comment.body, comment.drupal_user.name, comment.nid, comment.id)).to_html), attributes: %w(class style href data-method) %></p> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isi getting quite long; any way to simplify via formatting?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe pass the comment object to title_suggestion method would be better rather than breaking it up into body, name, etc. 'Attributes' require href and data-method for the time being perhaps. I'll try something to shorten this!!,
016d34f
to
06b292b
Compare
PR #2000 -- cool! :-) |
app/views/notes/_comment.html.erb
Outdated
@@ -64,7 +64,7 @@ | |||
</script> | |||
|
|||
<div id="c<%= comment.cid %>show"> | |||
<p><%= raw sanitize(auto_link(RDiscount.new(comment.body).to_html)) %></p> | |||
<p><%= raw sanitize (RDiscount.new(title_suggestion(comment)).to_html), attributes: %w(class style href data-method src) %></p> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This starts to get quite long. See how we've batched these in this code?
What do you think about making this more readable with an additional helper somehow, rather than a long in-line code block?
Looking good though!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some helper method like:- comment_body
It could look like this:-
def comment body(comment)
RDiscount.new(title_suggestion(comment)).to_html), attributes: %w(class style href data-method src
end
Then we could use it in line 67 as:-
<p><%= raw sanitize(auto_link(RDiscount.new(comment_body(comment)).to_html)) %></p>
Will this be good?
@@ -0,0 +1,6 @@ | |||
<blockquote> | |||
<a href="/profile/<%= user %>"><%= user %></a> is suggesting an alternative title, "<%= title %>". |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we switch to 2-space indents here? sorry to be particular :-)
Also, can you share a screenshot of what this looks like?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh I missed that!! I'll do!!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I'll share the screenshots!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a complex feature and I love your implementation. Made a few requests, and perhaps a single line comment like this above some of your method definitions could help make it clear how this new function works/
# explanation
def method_name
...
end
config/routes.rb
Outdated
@@ -6,6 +6,7 @@ | |||
post 'comment/create/token/:id.:format', to: 'comment#create_by_token' | |||
|
|||
get 'searches/test' => 'searches#test' | |||
post '/reset-title' => 'notes#request_title_change' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this actually change the title, or does it request a title change? I think it actually changes the title. Maybe we could do like /node/update/title
or something more descriptive? Same for the method name request_title_change
-- could that be update_title
to be more accurate, or do i misunderstand?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This actually changes the title. Yes, that's a cool idea!! I'll change the route name and method name to the above.
5193310
to
1e15361
Compare
|
aha - cool. Do you think perhaps it should be something like this, though, so we can expand out for other types of inline comment features in the future?
|
This syntax looks cool indeed!! I'll do the changes |
Or:
which do you think makes more sense? |
1e15361
to
8876e12
Compare
@jywarren I have made the changes!! May I write tests if the design seems to be finalised? |
Let's see -- one thing is, perhaps we can use an Also, just to think through this, what if you press this twice? It'll just continually replace the title, right? No possibility of weird behavior I can think of... just want to be thorough. OK, let's go for tests then! |
Yes, it would just replace the title continuously, I have tried that too and no weird behaviours were seen. I'd like to try and replace the block quote with something mentioned above. |
Duh! That was closed by mistake! I'll write the tests! |
@jywarren written the tests and also replaced the blockquotes with |
Wow, very cool! I think we are ready to go; do you think we should try this out once merged, then think about a user interface as a follow-up? We could for example add a button like the "promote to answer" button on comments -- which could use a JavaScript The button could appear as it does in this change by @Gauravano -- https://github.com/publiclab/plots2/pull/2001/files What do you think, shall we merge this in, test it out, then think about UI as a follow-up? |
This could make a really good first timer issue. Let's test this out on
production and see if it works or not.
Then, should I create a first-timer-issue for the follow-up part? This
would be quite a task but would be very interesting for new comers!!
…On Thu, Jan 18, 2018 at 4:47 AM, Jeffrey Warren ***@***.***> wrote:
Wow, very cool! I think we are ready to go; do you think we should try
this out once merged, then think about a user interface as a follow-up? We
could for example add a button like the "promote to answer" button on
comments -- which could use a JavaScript prompt() to ask for the proposed
title.
The button could appear as it does in this change by @Gauravano
<https://github.com/gauravano> -- https://github.com/publiclab/
plots2/pull/2001/files
What do you think, shall we merge this in, test it out, then think about
UI as a follow-up?
—
You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHub
<#2000 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AVkX0cH5VclQr-TWFsaR-UNB_O69Hvvfks5tLn-EgaJpZM4RdW21>
.
|
@jywarren I was just thinking of another way of doing this! We would have a button in the comments section (which would say something like 'propose title'). When clicked, it would append the template for title suggestion like |
Oh, that sounds really nice -- and could still be a first-timers-issue --
super!
…On Thu, Jan 18, 2018 at 12:56 AM, Vidit ***@***.***> wrote:
@jywarren <https://github.com/jywarren> I was just thinking of another
way of doing this! We would have a button in the comments section (which
would say something like 'propose title'). When clicked, it would append
the template for title suggestion like [propose:title]Propose your title
here[/propose] in the comment editor.
This could be useful if a user wants to propose more than one title in a
single comment. Then there would be no need of the prompt.
Your thoughts?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#2000 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AABfJ4TVjY_-f_wfIH9eTCBNjI-XiK88ks5tLt0XgaJpZM4RdW21>
.
|
Cool!! Do you think we should merge this? I will create a fto issue for the left over part as explained above!! |
@jywarren please see if there are any more required changes to it. |
Hi, I guess i'd like to know if there's a way to test the conversion of the Sorry to be delaying on this a bit, it's a great feature :-) 👍 |
That's interesting!! I'll do add the tests!! |
@jywarren the tests are written!! Please have a look! |
Wow, this is so cool! 🎉 Merging this! I hope we can publish tomorrow, we'll see! |
Hi, @ViditChitkara -- just noting one follow-up issue -- i see an error:
Looks like maybe we need to escape that? |
Oh I had this warning too, slipped out of my mind. Will give a quick fix to update this!! |
@ViditChitkara @jywarren working on this in #2125 |
Oops sorry didn't see that!! So are you covering the regex warning in fixing the robocup offences? |
@ViditChitkara yes i am covering all the rubocop offences there |
great, thanks folks! |
* added "Suggest new title" feature closes publiclab#919 * formatted routes * few changes for simplification * authorisation check to request_title_change method * changes for test faliures * minor changes and enhancements * minor changes * changed inline syntax for title suggestion * written tests * added more tests
closes #919
Make sure these boxes are checked before your pull request is ready to be reviewed and merged. Thanks!
rake test:all
Please be sure you've reviewed our contribution guidelines at https://publiclab.org/wiki/contributing-to-public-lab-software
We have a loose schedule of reviewing and pulling in changes every Tuesday and Friday, and publishing changes on Fridays. Please alert developers on plots-dev@googlegroups.com when your request is ready or if you need assistance.
Thanks!