Exemplo n.º 1
0
    def get(self, app_id = None):
        user_info = models.User.get_by_id(long(self.user_id))
        app = models.App.get_by_id(long(app_id))

        # get our gist's filenames
        files = github.get_gist_filenames(app.gist_id)
        app_manifest = github.get_gist_manifest(app.gist_id)

        if app.owner == user_info.key:
            # update existing app with current manifest
            app.name = app_manifest['name']
            app.command = app_manifest['command']
            app.description = app_manifest['description']
            app.thumb_url = app_manifest['thumb_url']
            app.public = app_manifest['public']
            app.github_author = app_manifest['github_author']
            
            # write out our new app data
            app.put()

            # loop through files in gist and clear cache
            for afile in files:
                github.flush_raw_gist_content(app.gist_id, afile)
        
            response = 'Article was flushed from cache.'
        else:
            response = 'Something went wrong flushing from cache!'
        
        params = {'app_response': response}
        return self.render_template('app/app_response.html', **params)
Exemplo n.º 2
0
    def get(self, app_id=None):
        user_info = models.User.get_by_id(long(self.user_id))
        app = models.App.get_by_id(long(app_id))

        # get our gist's filenames
        files = github.get_gist_filenames(app.gist_id)
        app_manifest = github.get_gist_manifest(app.gist_id)

        if app.owner == user_info.key:
            # update existing app with current manifest
            app.name = app_manifest['name']
            app.command = app_manifest['command']
            app.description = app_manifest['description']
            app.thumb_url = app_manifest['thumb_url']
            app.public = app_manifest['public']
            app.github_author = app_manifest['github_author']

            # write out our new app data
            app.put()

            # loop through files in gist and clear cache
            for afile in files:
                github.flush_raw_gist_content(app.gist_id, afile)

            response = 'Article was flushed from cache.'
        else:
            response = 'Something went wrong flushing from cache!'

        params = {'app_response': response}
        return self.render_template('app/app_response.html', **params)
Exemplo n.º 3
0
    def get(self):
        # pull the github token out of the social user db and grab gists from github
        if self.request.get('job_token') != config.job_token:
            logging.info("Hacker attack on jobs!")
            return
        else:
            user_info = models.User.get_by_id(long(self.request.get('user')))
            social_user = models.SocialUser.get_by_user_and_provider(
                user_info.key, 'github')
            apps = github.get_user_gists(social_user.uid,
                                         social_user.access_token)

            # update with the apps we get back from github
            for app in apps:
                app2 = models.App.get_by_user_and_gist_id(
                    user_info.key, app['gist_id'])

                if app2:
                    # update existing app with new data
                    app2.name = app['name']
                    app2.command = app['command']
                    app2.description = app['description']
                    app2.thumb_url = app['thumb_url']
                    app2.gist_id = app['gist_id']
                    app2.public = app['public']
                else:
                    # we have a new app on our hands - insert
                    app2 = models.App(
                        name=app['name'],
                        command=app['command'],
                        description=app['description'],
                        thumb_url=app['thumb_url'],
                        gist_id=app['gist_id'],
                        owner=user_info.key,
                        author=user_info.key,
                        github_author=app['github_author'],
                        public=app['public'],
                    )

                # update
                app2.put()

                # flush memcache copies just in case we had them
                # get our gist's filenames
                files = github.get_gist_filenames(app['gist_id'])

                for afile in files:
                    github.flush_raw_gist_content(app2.gist_id, afile)

            # use the channel to tell the browser we are done
            channel_token = self.request.get('channel_token')
            channel.send_message(channel_token, 'reload')
            return
Exemplo n.º 4
0
    def get(self, article_id=None):
        user_info = models.User.get_by_id(long(self.user_id))
        article = models.Article.get_by_id(long(article_id))

        if article.owner == user_info.key:
            github.flush_raw_gist_content(article.gist_id, config.gist_article_markdown_name)
            response = 'Article was flushed from cache.'
        else:
            response = 'Something went wrong flushing from cache!'
        
        params = {'blog_response': response}
        return self.render_template('blog/blog_response.html', **params)
Exemplo n.º 5
0
    def get(self, article_id=None):
        user_info = models.User.get_by_id(long(self.user_id))
        article = models.Article.get_by_id(long(article_id))

        if article.owner == user_info.key:
            github.flush_raw_gist_content(article.gist_id,
                                          config.gist_article_markdown_name)
            response = 'Article was flushed from cache.'
        else:
            response = 'Something went wrong flushing from cache!'

        params = {'blog_response': response}
        return self.render_template('blog/blog_response.html', **params)
Exemplo n.º 6
0
    def get(self):
        # pull the github token out of the social user db and grab gists from github
        if self.request.get('job_token') != config.job_token:
            logging.info("Hacker attack on jobs!")
            return
        else: 
            user_info = models.User.get_by_id(long(self.request.get('user')))
            social_user = models.SocialUser.get_by_user_and_provider(user_info.key, 'github')
            apps = github.get_user_gists(social_user.uid, social_user.access_token)

            # update with the apps we get back from github
            for app in apps:
                app2 = models.App.get_by_user_and_gist_id(user_info.key, app['gist_id'])

                if app2:
                    # update existing app with new data
                    app2.name = app['name']
                    app2.command = app['command']
                    app2.description = app['description']
                    app2.thumb_url = app['thumb_url']
                    app2.gist_id = app['gist_id']
                    app2.public = app['public']
                else:
                    # we have a new app on our hands - insert
                    app2 = models.App(
                        name = app['name'],
                        command = app['command'],
                        description = app['description'],
                        thumb_url = app['thumb_url'],
                        gist_id = app['gist_id'],
                        owner = user_info.key,
                        author = user_info.key,
                        github_author = app['github_author'],
                        public = app['public'],
                    )
                
                # update
                app2.put()

                # flush memcache copies just in case we had them
                # get our gist's filenames
                files = github.get_gist_filenames(app['gist_id'])
                
                for afile in files:
                    github.flush_raw_gist_content(app2.gist_id, afile)
               
            # use the channel to tell the browser we are done
            channel_token = self.request.get('channel_token')
            channel.send_message(channel_token, 'reload')
            return
Exemplo n.º 7
0
    def get(self):
        # pull the github token out of the social user db and grab gists from github
        if self.request.get('job_token') != config.job_token:
            logging.info("Hacker attack on jobs!")
            return
        else:
            user_info = models.User.get_by_id(long(self.request.get('user')))
            social_user = models.SocialUser.get_by_user_and_provider(
                user_info.key, 'github')
            gists = github.get_article_gists(social_user.uid,
                                             social_user.access_token)

            # update with the gists
            for gist in gists:
                article = models.Article.get_by_user_and_gist_id(
                    user_info.key, gist['gist_id'])

                if article:
                    # update existing article with new data
                    article.title = gist['title']
                    article.summary = gist['summary']
                    article.gist_id = gist['gist_id']
                    article.article_type = gist['article_type']
                    article.updated = datetime.datetime.fromtimestamp(
                        gist['published'])
                else:
                    # we have a new article on our hands - insert
                    # prep the slug
                    slug = utils.slugify(gist['title'])
                    article = models.Article(
                        title=gist['title'],
                        summary=gist['summary'],
                        created=datetime.datetime.fromtimestamp(
                            gist['published']),
                        gist_id=gist['gist_id'],
                        owner=user_info.key,
                        slug=slug,
                        article_type=gist['article_type'],
                    )

                # update
                article.put()

                # flush memcache copy just in case we had it
                github.flush_raw_gist_content(article.gist_id)

            # use the channel to tell the browser we are done
            channel_token = self.request.get('channel_token')
            channel.send_message(channel_token, 'reload')
            return
Exemplo n.º 8
0
    def get(self):
        # pull the github token out of the social user db and grab gists from github
        if self.request.get('job_token') != config.job_token:
            logging.info("Hacker attack on jobs!")
            return
        else: 
            user_info = models.User.get_by_id(long(self.request.get('user')))
            social_user = models.SocialUser.get_by_user_and_provider(user_info.key, 'github')
            gists = github.get_article_gists(social_user.uid, social_user.access_token)

            # update with the gists
            for gist in gists:
                article = models.Article.get_by_user_and_gist_id(user_info.key, gist['gist_id'])

                if article:
                    # update existing article with new data
                    article.title = gist['title']
                    article.summary = gist['summary']
                    article.gist_id = gist['gist_id']
                    article.article_type = gist['article_type']
                    article.updated = datetime.datetime.fromtimestamp(gist['published'])
                else:
                    # we have a new article on our hands - insert
                    # prep the slug
                    slug = utils.slugify(gist['title'])
                    article = models.Article(
                        title = gist['title'],
                        summary = gist['summary'],
                        created = datetime.datetime.fromtimestamp(gist['published']),
                        gist_id = gist['gist_id'],
                        owner = user_info.key,
                        slug = slug,
                        article_type = gist['article_type'],
                    )
                
                # update
                article.put()

                # flush memcache copy just in case we had it
                github.flush_raw_gist_content(article.gist_id)
                                
            # use the channel to tell the browser we are done
            channel_token = self.request.get('channel_token')
            channel.send_message(channel_token, 'reload')
            return
Exemplo n.º 9
0
    def get(self, article_id=None, username=None):
        user_info = models.User.get_by_id(long(self.user_id))
        article = models.Article.get_by_id(long(article_id))

        if article.owner == user_info.key and github.flush_raw_gist_content(article.gist_id):
            message = 'Article was flushed from cache.'
        else:
            message = 'Something went wrong flushing from cache!'
        
        return message