           github.to_api_url site, "/gists/#{id}"
         gist = gist.toString()
         if gist.indexOf('http') != 0
-          site = settings.get 'githubs', github.default()
+          site = settings.get 'sites', github.default()
           build_url site, gist
         else
-          site = github.get_github gist
+          site = github.get_site_from_url gist
 
           if github?
             [id, rest...] = URI(gist).filename().split '.'

    notebook = nb

  modules.create 'github', ({fn, cmd, settings}) ->
    settings.set 'githubs', 'github.com', 'api_base_url', 'https://api.github.com'
    settings.default 'default', 'github.com'

    github =
      get_github: (url) ->
        uri = URI url
        hostname = uri.hostname()
        if hostname == 'gist.github.com' or hostname == 'api.github.com'

    ensure_access = (ctx, url) ->
      unless url?
        domain = github.default()
        site = settings.get 'sites', domain
      else
        site = github.get_site_from_url url
        domain = url.hostname()
      if site? and site.requires_access_token and not site.access_token?
        result = Q.defer()
        ctx.text 'Please set a GitHub access token:'
        input = ctx.input.text_input()
        button = ctx.input.button('Save')
        user_details = button.map(input).flatMapLatest (access_token) ->
          Bacon.combineTemplate
            user: Bacon.fromPromise http.get github.to_api_url(site, '/user').setQuery {access_token}
            access_token: access_token
          .changes()
        user_details.onValue ({user, access_token}) =>
          global_settings.user_settings.set 'github', 'sites', domain, 'access_token', access_token
          ctx.text "Logged in as #{user.name}"
          result.resolve url?.setQuery {access_token}
        user_details.onError =>
