       to_repo_url: (path) ->
         path = path.toString()
         if path.indexOf('http') != 0
-          site = settings.get 'sites', github.default()
+          site = github.get_site()
           path = path.substr 1 if path[0] == '/'
           [user, repo, segments...] = path.split '/'
           url = github.to_api_url site, "/repos/#{user}/#{repo}/contents/#{segments.join '/'}"

            url = github.to_api_url site, "/repos/#{user}/#{repo}/contents/#{segments.join '/'}", {ref}

      save_gist: (gist, options={}) ->
        github_host = options.github ? github.default()
        gh = settings.get 'sites', github_host
        http.post github.to_api_url(gh, '/gists'), gist

      to_api_url: (site, path, params={}) ->
        result = URI("#{site.api_base_url}#{path}").setQuery(params)

        else
          host = hostname

        github.get_site host

      default: -> settings.get 'default'
      get_site: (name) -> settings.get 'sites', name ? settings.get 'default'

      get_repo_contents: (url) ->
        http.get(url)
