2

I'm trying to build a prototype/ proof of concept that builds a website from markdown files hosted on Google Drive. I've had a look at the Google Drive API, but cant seem to find a way to read a file in a format that is digestible by a markdown renderer.

Does anyone know if it's possible to inject the contents of a markdown file ( hosted in Google Drive) into the body of a webpage where it can be rendered as HTML?

Thanks.

TheJamesOne
  • 43
  • 1
  • 4
  • Have you used [StackEdit](https://stackedit.io/)? It has a good integration with Google Drive. Once you import/export a Markdown document from/to Google Drive, you can open it later directly from Google Drive since StackEdit is integrated as a third party editor/viewer application. You can also find StackEdit as a Chrome application on the [Chrome Web Store](https://chrome.google.com/webstore/detail/stackedit/iiooodelglhkcpgbajoejffhijaclcdg). – Dayton Wang Jun 03 '15 at 17:29

1 Answers1

0

I had to do the same thing for a public-facing changelog on a SaaS application. We wanted to write the changelog in Markdown, shared in our Google drive. That way, even the marketing people could update it easily, and we didn't need to redeploy the entire SaaS app just because we made that small tweak.

Our website was built using Ruby on Rails, and the markdown handled by a gem called Redcarpet (https://github.com/vmg/redcarpet). It's based on the Sundown library, which has a Node.js port called: RoboSkirt (https://github.com/benmills/robotskirt). I'd say to start there for a javascript based markdown parser to HTML.

From there, I just needed our app to fetch the markdown file. This post helped me figure out what the public facing URL's for Google drive files need to be: https://unix.stackexchange.com/questions/136371/how-to-download-a-folder-from-google-drive-using-terminal/148674#148674

It reads:

$ wget --no-check-certificate 'https://docs.google.com/uc?export=download&id=FILEID' \ -O FILENAME

Where FILEID must be replaced by the actual file ID. FILENAME is the path/filename where download will be stored.

In Rails, and javascript (I imagine), you don't need to actually 'wget' the file. I was able to directly open a remote file using the 'open-uri': Open an IO stream from a local file or url. Again, I know that's Ruby and not javascript, but it's a working example that may help get the gears going in your head. :)

Our public-facing URL for the markdown file ended up being:

https://docs.google.com/uc?export=download&id=0B2Pxr9r95zueSVBfb295Y0tpV0k

And here is our app pulling that file in live when you load the page: https://eventpie.net/changes

I hope that all helps you!

Community
  • 1
  • 1
BoomShadow
  • 912
  • 1
  • 18
  • 31