-
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
Add a new /preview route to open editor preview in new tab #8560
Comments
More details here: publiclab/PublicLab.Editor#490 (comment) |
For this, i'm thinking we could make a notes controller method for plots2/app/views/notes/show.html.erb Line 23 in 3664a28
plots2/app/views/notes/show.html.erb Line 64 in 3664a28
...but there are lots of references to we might also need to pass in the |
Okay @jywarren that makes sense 👍 |
Hi @sagarpreet-chadha I'd like to try this out...please assign it to me. |
Hey @RuthNjeri , sure go ahead! I was just going to start on this myself :) |
This will be pretty interesting feature, we will also make sure that we write proper tests for this 😄 |
@sagarpreet-chadha thanks! I'll definitely reach out throughout! |
Hi, @sagarpreet-chadha I'm working on understanding the task, I have a couple of questions.. The preview tab is meant for this editor page, right? And from this form, I'll pass the params to the preview route when the params have values? That is the title, image, location, markdown, and tags. I don't understand how this relates to the notes controller. |
Hey @RuthNjeri , Now corresponding to this route we will implement a controller function in For this The only change we will need to do inside So I will break the tasks as well:
I hope this helps 😄 |
@sagarpreet-chadha thanks, that helps a lot, I'm curious why the preview action should be defined in the NotesController...how does that relate to the EditorController? Also, what's a node in this case? |
The
On the other hand |
Thanks, I'll use this info and start out with the first task and create a PR for it... |
Hi @sagarpreet-chadha 👋🏾 I'm working on creating a manual node.. I am thinking of defining one in the node model file, similar to the new_note but without saving any details, since it creates the revision and author. But I am not sure why revision is needed, because the body in the show view is defined as So far what I think should happen for the manual definition is this...
Let me know if this makes sense so far.. |
Yes @RuthNjeri , you are going in the right direction 👍 Can you check this PR: #8604, I have added a lot of TODO's (9-10 todo's 🙈 ) and you will get idea of how I am thinking of mocking the |
Thanks @Sagarpreet I'll look at the PR and add my contributions to it.. in my case, I had just defined the preview action with some minor changes on the show template, you've done a much better job breaking down what is required. I'll first try and understand the PR then begin asking/adding onto it.. |
Hi all! this is awesome. Just to answer @RuthNjeri's Q about revisions, the body of all posts (nodes) is stored in a Revision record, so we have to mock that too. Unfortunately for us in this case, i believe the saving of both revision and node is interconnected, and in our case, we don't want to save either. Lines 686 to 690 in 737f6fa
See how normally, we check if a node is valid, then we begin creating its first revision, and we save the node... but we try to ensure that if the revision fails, it's in a "transaction" which then rolls back the node saving too -- this is a database feature for ensuring either both succeed or both fail. That way we're never left with a situation where a node exists with no revision! In our case, i think we have to duplicate some of this code instead of relying on the transaction code, because w never want to save. One of the tests might be a check to ensure the total count of nodes and revisions doesn't change! Just to be sure we aren't saving any records. That test could look like this: plots2/test/functional/notes_controller_test.rb Lines 777 to 779 in 737f6fa
Anyways, great work! @Sagarpreet I think we can make the preview system and tests first, and then later add the buttons, but yes, it would go on the |
Thanks for the clarification @jywarren, it's beginning to make much more sense now.. |
The text was updated successfully, but these errors were encountered: