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

"Switch to legacy editor" should preserve content of page #1563

Closed
jywarren opened this issue Aug 3, 2017 · 11 comments

Comments

Projects
None yet
3 participants
@jywarren
Copy link
Contributor

commented Aug 3, 2017

This can be achieved with some JavaScript. The notice is here:

https://github.com/publiclab/plots2/blob/master/app/controllers/editor_controller.rb#L40

But we should probably move it into the HTML template here:

https://github.com/publiclab/plots2/blob/master/app/views/editor/rich.html.erb

Once we do that, we can use editor.richTextModule.value(); from the PublicLab.Editor project to fetch the markdown of the post and add it to the URL of the legacy editor with ?body=______ syntax. Same for the title and tags (although we won't be able to grab the lead image as easily)

@jywarren jywarren added the enhancement label Aug 3, 2017

@Pk13055

This comment has been minimized.

Copy link
Collaborator

commented Aug 5, 2017

Can I pick this up?

@jywarren

This comment has been minimized.

Copy link
Contributor Author

commented Aug 5, 2017

@jywarren

This comment has been minimized.

Copy link
Contributor Author

commented Aug 8, 2017

Did you need some help getting started with this? Thanks!

@Pk13055

This comment has been minimized.

Copy link
Collaborator

commented Aug 9, 2017

@jywarren Sorry, I got caught up with something else, I'll get started on this, and get back to you if I need some help! Thanks

@Pk13055

This comment has been minimized.

Copy link
Collaborator

commented Aug 9, 2017

...Once we do that..

What is it exactly? From what I understood, I have to use JS to get the body markdown and add it here. However, I do not see said line on the html, so where am I supposed to append it?

@jywarren

This comment has been minimized.

Copy link
Contributor Author

commented Aug 10, 2017

Hi, so, I believe we have to set up an onClick listener, since we'll have to get the latest body text. So something like:

$('.legacy-button').click(function onLegacyClick() {
  window.location = "/post?legacy=true&body=" + editor.richTextModule.value();
});

But, sometimes people arrive at the /post page with URL get parameters already set. So we may need to think about getting those too:

https://publiclab.org/post?tags=community,web-development,software,plots2,outreach

We can get those using editor.tagsModule.value() -- so let's append those to the end as well. The final URL in this case would be:

https://publiclab.org/post?legacy=true&tags=community,web-development,software,plots2,outreach&body=____

For title, editor.titleModule.value(). So I think we can assemble all three and add them to the URL. Make sense?

@jywarren

This comment has been minimized.

Copy link
Contributor Author

commented Aug 10, 2017

Also, just mentioning @Fastie who originally requested this feature so he knows when it's complete. Hi, Chris!

@Diksha2008

This comment has been minimized.

Copy link
Contributor

commented Oct 6, 2017

@jywarren If this issue is still available, can I work on it?

@jywarren

This comment has been minimized.

Copy link
Contributor Author

commented Oct 6, 2017

@jywarren

This comment has been minimized.

Copy link
Contributor Author

commented Oct 9, 2017

I believe this has been solved, although I'm not sure it'll work for very complex existing body text. If we have trouble with that, we may want to look into submitting a synchronous POST request with the body text instead of trying to include it in the URL GET parameters.

@jywarren

This comment has been minimized.

Copy link
Contributor Author

commented Oct 9, 2017

And thanks, @Dishka2008! We'll get this published in the next few days!

@icarito if you're comfortable publishing to production please go ahead!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.