plots2 icon indicating copy to clipboard operation
plots2 copied to clipboard

"Switch to legacy editor" should preserve content of page

Open jywarren opened this issue 9 years ago • 11 comments

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 avatar Aug 03 '17 11:08 jywarren

Can I pick this up?

Pk13055 avatar Aug 05 '17 00:08 Pk13055

Yes please!!! That would be great. I'm happy to add any info necessary!

On Aug 4, 2017 8:09 PM, "Pratik Kamble" [email protected] wrote:

Can I pick this up?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/publiclab/plots2/issues/1563#issuecomment-320377974, or mute the thread https://github.com/notifications/unsubscribe-auth/AABfJ5xmlcguQL3iCdVil2D27j1qW8tVks5sU7KagaJpZM4OsTfL .

jywarren avatar Aug 05 '17 00:08 jywarren

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

jywarren avatar Aug 08 '17 14:08 jywarren

@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 avatar Aug 09 '17 04:08 Pk13055

...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?

Pk13055 avatar Aug 09 '17 05:08 Pk13055

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 avatar Aug 10 '17 13:08 jywarren

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

jywarren avatar Aug 10 '17 13:08 jywarren

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

Diksha2008 avatar Oct 06 '17 08:10 Diksha2008

Yes please! Thank you!

On Oct 6, 2017 2:58 AM, "Diksha Manchanda" [email protected] wrote:

@jywarren https://github.com/jywarren If this issue is still available, can I work on it?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/publiclab/plots2/issues/1563#issuecomment-334698779, or mute the thread https://github.com/notifications/unsubscribe-auth/AABfJwjNRkT6P1FXq3twcOZch269qCDLks5speufgaJpZM4OsTfL .

jywarren avatar Oct 06 '17 13:10 jywarren

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 avatar Oct 09 '17 19:10 jywarren

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

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

jywarren avatar Oct 09 '17 19:10 jywarren