applidium / Vim

Port of the Vim text editor to the iOS
https://applidium.com/en
535 stars 99 forks source link

Dropbox support #4

Open sibartlett opened 12 years ago

sibartlett commented 12 years ago

In addition to iCloud support.

Ecco commented 12 years ago

That would definitely make sense.

sibartlett commented 12 years ago

Dropbox support would enable us to sync with a directory on a desktop computer.

Which I think is not possible using iCloud unless you also release a dedicated app through the Mac App Store? Plus iCloud is tied to Apple devices, whereas Dropbox is cross-platform.

Ecco commented 12 years ago

Indeed. Both are proprietary though, so I would rather add something open like WebDAV. But the code needed to get DropBox working might be very small, so this is definitely a good idea. And you're right, it's cross-platform. If you want to contribute a patch I'd be happy to merge it :-)

mtwebb commented 12 years ago

Dropbox has verbose docs on adding support to an app:

https://www.dropbox.com/developers/start/setup#ios

rcarmo commented 12 years ago

There was also, I think, an OSS Dropbox "helper" framework from the author of one of the other iOS text editors (Nebulous?).

Mind you, WebDAV is pretty much useless unless you're OK with either running it and maintaining it yourself or are lucky enough to have someone else do it for you. I tried for years (since I wanted to replace iDisk with something similar) and gave up on it. Haven't seen anyone really use it in years, either.

trammel commented 12 years ago

This would be great.

njivy commented 11 years ago

This could be broader than Dropbox. Vim could register as a handler for various file types in iOS. Then other apps could link to Vim as appropriate.

http://developer.apple.com/library/ios/documentation/FileManagement/Conceptual/DocumentInteraction_TopicsForIOS/Introduction/Introduction.html#//apple_ref/doc/uid/TP40010403

joebologna commented 11 years ago

This handler works great with iA Writer for .txt files, I even use it with Box and FTPOnTheGoPro. Vim wouldn't really know who the clients are, it gets around the sandbox problem. This method allows for getting files into Vim's sandbox. Getting files out to Dropbox would require Vim to support an iOS dialog, which I don't see following the strict Vim text mode port on the App Store. It would also require letting the Dropbox API launch the browser of Dropbox app to let Vim access the users Dropbox. If these dialogs are OK life is easier. If not, then a text mode solution is possible as well. I've protoyped a command line method using using Java, I could try it in iOS. It seems similar to the new sync API Dropbox recently provided for iOS. I haven't tried it yet. The docs are here:

Dropbox has a new API: https://www.dropbox.com/developers/sync/docs/ios

In theory this API would allow hooking Dropbox into the netrw module in Vim. Prompts for username, password would be similar. A "finish link" method similar to store the OAuth validated keys from the server is required.

I need to move to the sync API in my app anyway and I've been supporting Dropbox the hard way for a year now in my app. With a little help I think I can get it into Vim. The big questions I have are which approach you'd prefer for getting files out of Vim due to the dialogs interfering with the strict text mode port.

rcarmo commented 11 years ago

Well, IIRC the dialogs are a one-time thing (i.e., "Do you want to let vim access your dropbox?") and then you can just call it a day for subsequent API calls.

I, for one, would vastly prefer a one-time dialog to bind the app to Dropbox than have to mess around with typing usernames and passwords into it. Seriously, that's a major nuisance.

On 05/04/2013, at 09:33, joebologna notifications@github.com wrote:

This handler works great with iA Writer for .txt files, I even use it with Box and FTPOnTheGoPro. Vim wouldn't really know who the clients are, it gets around the sandbox problem. This method allows for getting files into Vim's sandbox. Getting files out to Dropbox would require Vim to support an iOS dialog, which I don't see following the strict Vim text mode port on the App Store. It would also require letting the Dropbox API launch the browser of Dropbox app to let Vim access the users Dropbox. If these dialogs are OK life is easier. If not, then a text mode solution is possible as well. I've protoyped a command line method using using Java, I could try it in iOS. It seems similar to the new sync API Dropbox recently provided for iOS. I haven't tried it yet. The docs are here:

Dropbox has a new API: https://www.dropbox.com/developers/sync/docs/ios

In theory this API would allow hooking Dropbox into the netrw module in Vim. Prompts for username, password would be similar. A "finish link" method similar to store the OAuth validated keys from the server is required.

I need to move to the sync API in my app anyway and I've been supporting Dropbox the hard way for a year now in my app. With a little help I think I can get it into Vim. The big questions I have are which approach you'd prefer for getting files out of Vim due to the dialogs interfering with the strict text mode port.

— Reply to this email directly or view it on GitHub.

joebologna commented 11 years ago

Yes it's a one time thing. The pop up is all handled by the API and consistent with how other iOS apps work. I agree, this is the best way to go. It also avoids problems getting through the App Store review process... I've already lived through the rejections regarding Dropbox integration.

The tokens returned need to be stored. Also a mechanism to unlink is required. Dropbox offers two methods of access, application or full access. It makes sense to use full access with Vim. A poor implementation exists in the Buffer iOS app ($3.99, ick) nowhere close to this real port of Vim.

In reality, after supporting Dropbox alone for a long time, providing iCloud as the primary data store with Dropbox as an import/export method works well. I've been considering using the method iA Writer uses, it is by far the most seamless method and it handles editing files on an iPhone, iPad and Mac properly which is how I use it everyday.

With iCloud and Dropbox the file being edited can be changed in the same way Vim on Unix detects the file was modified by another process. When this happens Vim warns with a "file changed on disk" message and refuses to overwrite unless "!" is used. It's important to handle this correctly, otherwise Dropbox will actually create a file with (1) appended then tell you the new name, Vim will get confused for sure since this is not how Unix handles the same situation.

The new sync API should register for file updates from the network while the app is running and therefore keeps much of these things under control.

iOS apps that use multiple views need to handle the view will appear event and the application will enter foreground events to keep the GUI in sync with the data. Since Vim only has one view, only the foreground event needs to be handled.

Adding this functionality to Vim is essential in my opinion. I'd love to do it. It's much, much better than just providing the netrw method to the local filesystem as is currently being used.

I've been studying the iCloud method of handling files, UIDocument makes this much easier than in the past as well. Dropbox and iCloud via UIDocument are similar methods therefore a common approach could be used make it possible to introduce iCloud and Dropbox as feature together relatively easily. Dropbox is important for the Vim crowd since we are all likely programmers vs. iCloud is nice for the Darwin crowd using iPad's for programming on the go - I'm on both camps.

Let me know if you need help with this. I see this thread has been inactive for 5 months, getting this done would be really nice - I've been looking for a decent port of Vim since 2007 - sigh, I should have tried a Vim port back then - but that's another story :)

FreddyKruger commented 11 years ago

Is iTunes file transfer really still the only solution to get files from and to iPad vim?

Please provide a solution!! Vim enables me to really fast take notes in meetings etc. But without being able to sync my notes it is more or less useless as it costs me too much time to manually sync and extract notes of different topics in to different files as on iPad only one file(editable/create) works.

Please.....

joebologna commented 11 years ago

I looked at it for a while and prototyped something but never got it working properly therefore it can't be released. I ran of time to make it work and I don't see space opening up in the near future, sorry. If someone else has the time, it's rather simple in iOS, register the app as being able to open .txt/.html, etc. files, then you can import files from Dropbox or other apps that provide an export button. The inverse works in a similar manner. The file shows up in the Inbox directory on an import. All the issues with moving and opening the file from this directory needs to be solved. Also, Vim on iOS does not have a reasonable user interface to the filesystem, the ":e ." facility opens up "dired" which is pretty limited and not working as well as it could.