예제 #1
0
파일: v2.py 프로젝트: oneshoturdone/bukget
def plugin_details(server, slug, version=None):
    '''Plugin Details 
    Returns the document for a specific plugin.  Optionally can return only a
    specific version as part of the data as well.
    '''
    fields = bleach.clean(request.query.fields or '').split(',')
    fields = v2to3(fields)
    data = c.plugin_details(server, slug, version, fields)
    return c.jsonify(v3to2([data])[0])
예제 #2
0
파일: v3.py 프로젝트: oneshoturdone/bukget
def plugin_details(server, slug, version=None):
    '''Plugin Details 
    Returns the document for a specific plugin.  Optionally can return only a
    specific version as part of the data as well.
    '''
    fields = bleach.clean(request.query.fields or '').split(',')
    size = c.sint(bleach.clean(request.query.size or None))
    data = c.plugin_details(server, slug, version, fields)
    if size is not None:
        data['versions'] = data['versions'][:size]
    return c.jsonify(data)
예제 #3
0
파일: v3.py 프로젝트: oneshoturdone/bukget
def plugin_download(server, slug, version):
    '''Plugin Download Redirector
    Will attempt to redirect to the plugin download for the version specified.
    If no version exists, then it will throw a 404 error.
    '''
    plugin = c.plugin_details(server, slug, version, {})
    if version.lower() == 'latest':
        link = [plugin['versions'][0]['download'],]
    else:
        versions = plugin['versions']
        link = [v['download'] for v in versions if v['version'] == version]
    if len(link) > 0:
        redirect(link[0])
    else:
        raise bottle.HTTPError(404, '{"error": "could not find version"}')
예제 #4
0
파일: v1.py 프로젝트: oneshoturdone/bukget
def plugin_details(slug, version=None):
    '''Plugin Details 
    Returns the document for a specific plugin.  Optionally can return only a
    specific version as part of the data as well.
    '''
    data = c.plugin_details('bukkit', slug, version, [])

    # Moving data to the old format
    data['name'] = data['slug']
    data['bukkitdev_link'] = data['dbo_page']
    data['desc'] = data['description']

    # Deleting all of the data that didnt exist in the old format.
    del(data['slug'])
    del(data['dbo_page'])
    del(data['description'])
    del(data['logo'])
    del(data['logo_full'])
    del(data['server'])
    del(data['website'])
    if '_use_dbo' in data: del(data['_use_dbo'])

    # Now we will perform the same actions for each version.
    versions = []
    for version in data['versions']:
        version['dl_link'] = version['download']
        version['name'] = version['version']
        del(version['commands'])
        del(version['permissions'])
        del(version['changelog'])
        del(version['md5'])
        del(version['slug'])
        del(version['download'])
        if 'dbo_version' in version: del(version['dbo_version'])
        versions.append(version)
    data['versions'] = versions
    return c.jsonify(data)