A Ruby implementation of Gist.io built with Sinatra.
View a gist at roughdraft.dev/gist-id. Example: roughdraft.dev/4370358
View a list of a GitHub user's Gists at username.roughdraft.dev. Example jedfoster.roughdraft.dev. Only public Gists with renderable content are listed.
If you happen to be on a user subdomain, e.g. jedfoster.roughdraft.dev, and you paste in a Gist ID that does not belong to that user, you will be redirected to the appropriate subdomain. Example: jedfoster.roughdraft.dev/4731881 will redirect to blackfalcon.roughdraft.dev, because
jedfoster does not own that Gist.
GitHub Flavored Markdown includes a number of improvements over Markdown, like fenced code blocks with syntax highlighting. Example:
```ruby require 'redcarpet' markdown = Redcarpet.new("Hello World!") puts markdown.to_html ```
Roughdraft's implementation of Haml does not support Ruby evaluation, and many Haml filters will result errors.
Plain text is rendered as Markdown.
git clone https://github.com/jedfoster/Roughdraft.git cd Roughdraft mkdir tmp touch tmp/restart.txt
APP_DOMAIN constant in roughdraft.rb, line 68, to whatever local domain you want to use. I recommend using Pow for local development, especially on this project as the username subdomain feature doesn't work with IP addresses.
The GitHub API limits the number of unauthenticated requests to 60 per hour, which is too little for production and often even for development. To get around this you will need to register your app with GitHub. Once you have your client ID and secret, rename config/github.example.yml to config/github.yml and paste in your app's credentials. Mine looks something like this:
client_id: 9ef1xxxx client_secret: 5784xxxxxxxx
You should now be able to submit up to 5000 requests per hour.
FAIR WARNING: Your client ID and secret should not be shared publicly. Do not commit github.yml to your repo, especially if you post your repo on GitHub. Read the instructions for configuring Heroku with your credentials, below.
# Restart Pow touch tmp/restart.txt # Rock and Roll
heroku create git push heroku heroku open # Rock and Roll
APP_DOMAIN constant in roughdraft.rb, line 41, to whatever custom domain your app will use.
The user subdomain feature doesn't seem to work without a custom domain name (i.e. not the Heroku generated domain.) This may be fixed in a future release. See this article on custom domain names and Heroku.
GitHub authentication on Heroku
Since the YAML file with your API credentials is not committed to your repo, it won't be sent to Heroku, so we need another way of storing that information. Enter Heroku environment variables:
heroku config:set GITHUB_ID=9ef1xxxx heroku config:set GITHUB_SECRET=5784xxxxxxxx heroku open # Rock and Roll, again.