Permalink
Browse files

moved gist support to new branch

  • Loading branch information...
1 parent b443403 commit a0365b813af564af4957a9d5f826e941d5b9aa8c @lavelle committed Apr 30, 2012
Showing with 0 additions and 90 deletions.
  1. +0 −36 src/auth.html
  2. +0 −54 src/lib/gist.py
View
@@ -1,36 +0,0 @@
-<!DOCTYPE html>
-
-<html lang="en">
-
-<head>
- <meta charset="utf-8" />
- <title>ClipCloud authorisation</title>
-</head>
-
-<body>
-
-<div class="container">
- <div id="code"></div>
-</div>
-
-<script>
- var GET = {};
-
- function decode(s){
- return decodeURIComponent(s.split('+').join(' '));
- }
-
- //Search the url for GET variables using a regex and store them in an object
- document.location.search.replace(
- /\??(?:([^=]+)=([^&]*)&?)/g,
- function(){
- GET[decode(arguments[1])] = decode(arguments[2]);
- }
- );
-
- document.getElementById('code').innerHTML = GET.code;
-</script>
-
-</body>
-
-</html>
View
@@ -1,54 +0,0 @@
-import webbrowser
-from pyjson import *
-import os
-from settings import *
-import requests
-
-
-class Gist:
- api_root = 'https://api.github.com/gists'
-
- oauth_root = 'https://github.com/login/oauth/%s'
- oauth_url = oauth_root % 'authorize?client_id=%s'
- oauth_token_url = oauth_root % 'access_token'
-
- def __init__(self):
- api_details = PyJson('dropbox/api.json').doc['github']
-
- self.client_id = api_details['id']
- self.client_secret = api_details['secret']
-
- if os.path.exists(GITHUB_TOKEN_PATH):
- self.access_token = PyJson(GITHUB_TOKEN_PATH).doc['token']
- else:
- print 'Please authorise the app and then paste in the code you see on-screen'
- webbrowser.open(self.oauth_url % self.client_id, new=2)
- code = raw_input()
-
- data = json.dumps({
- client_id: self.client_id,
- client_secret: self.client_secret,
- code: code
- })
-
- r = requests.get(self.oauth_token_url, data=data).text
-
- self.access_token = r[r.find('=') + 1: r.find('&')]
-
- doc = PyJson(GITHUB_TOKEN_PATH)
- doc.add('token', self.access_token)
- doc.save()
-
- def upload(self, filename, text):
- data = save_json({
- "public": False,
- "files": {
- filename: {
- "content": text
- }
- }
- })
-
- url = self.api_root
- r = requests.post(url, data=data)
- print r.text

0 comments on commit a0365b8

Please sign in to comment.