wordpress-mobile / WordPress-iOS

WordPress for iOS - Official repository
http://ios.wordpress.org/
GNU General Public License v2.0
3.66k stars 1.11k forks source link

[Sharing] Add URL scheme support for creating a new post #11152

Closed frosty closed 5 years ago

frosty commented 5 years ago

As part of our work to improve sharing into the app, we can implement URL scheme support for creating new posts and pages.

We should follow the x-callback-url specification common on iOS. Here’s a first proposal at how this could look:

Endpoint /new (Potentially also /new-post and /new-page?)

Opens the editor, with some content pre-populated specified by the parameters below.

Parameters

Optional extras

I think we should just ship the above first and then look at usage to assess whether to extend this feature. If we did extend it, we could look at adding parameters for other post metadata such as:

Example

wordpress://x-callback-url/new?title=My%20Awesome%20Post&content=My%20post&site_name=Stay%20Frosty&format=text

nheagy commented 5 years ago

I dug up our previous implementation: https://github.com/wordpress-mobile/WordPress-iOS/blob/d89b7ec712be1f2e11fb1228089771a25f5587c5/WordPress/Classes/ViewRelated/System/WPTabBarController.m#L388

My preference would be to make the new version compatible with the old one, since it's apparently still in use (or would be 😉)

This means naming the endpoint newpost. We could, of course, support multiple names 😀

The old endpoint also supported parameters for tags, and image, although I'm not yet sure what format the image param took. If the code is easy to resurrect, then I will, otherwise I'll probably leave media out of this version with the thought that media support may work better in the share extension, or that future support for TextBundle may be a better fit.

frosty commented 5 years ago

Nice detective work :) It looks like the image handling was simply taking a URL to an image and using it to populate an <img> tag – I think that's probably not worth resurrecting.

matteorattotti commented 5 years ago

x-callback-url are great for automatization (Siri shortcuts, etc..), but not ideal for improving sharing from other apps as they'll need to implement custom code only for WordPress instead of just using the iOS share extension.

Said so, I can't imagine WordPress posts without images, so adding them to the parameters would be awesome. Using url parameters the only options is to base64 encode the images, but it should work just fine.

In our app Bear we're already using the base64 encoding to allows image inserting, if you need any info I'll be happy to provide these.