Ejemplo n.º 1
0
def search():
    query = request.args.get('query')
    if not query:
        query = ''
    results = list()
    for m in search_mods(query, 0):
        a = {
            "name": m.name,
            "id": m.id,
            "short_description": m.short_description,
            "downloads": m.download_count,
            "followers": m.follower_count,
            "author": m.user.username
        }
        versions = list()
        for v in m.versions:
            versions.append({
                "friendly_version": v.friendly_version,
                "ksp_version": v.ksp_version,
                "id": v.id,
                "download_path": v.download_path,
                "changelog": v.changelog
            })
        a['versions'] = versions
        results.append(a)
    return results
Ejemplo n.º 2
0
def index():
    featured = Featured.query.order_by(desc(Featured.created)).limit(6)[:6]
    top = search_mods("", 1, 3)[0]
    new = Mod.query.filter(Mod.published).order_by(desc(
        Mod.created)).limit(3)[:3]
    recent = Mod.query.filter(Mod.published).order_by(desc(
        Mod.updated)).limit(3)[:3]
    user_count = User.query.count()
    mod_count = Mod.query.count()
    yours = list()
    if current_user:
        yours = sorted(current_user.following,
                       key=lambda m: m.updated,
                       reverse=True)[:3]
    return render_template("index.html",\
        featured=featured,\
        new=new,\
        top=top,\
        recent=recent,\
        user_count=user_count,\
        mod_count=mod_count,
        yours=yours,
                           site_name=_cfg('site-name'),
                           support_mail=_cfg('support-mail'),
                           source_code=_cfg('source-code'))
Ejemplo n.º 3
0
def singlegame_browse_all(gameshort):
    if not gameshort:
        gameshort = "kerbal-space-program"
    ga = Game.query.filter(Game.short == gameshort).first()
    session["game"] = ga.id
    session["gamename"] = ga.name
    session["gameshort"] = ga.short
    session["gameid"] = ga.id
    page = request.args.get("page")
    if page:
        page = int(page)
    else:
        page = 1
    mods, total_pages = search_mods(ga, "", page, 30)
    return render_template(
        "browse-list.html",
        mods=mods,
        page=page,
        total_pages=total_pages,
        ga=ga,
        url="/browse/all",
        name="All Mods",
        site_name=_cfg("site-name"),
        support_mail=_cfg("support-mail"),
    )
Ejemplo n.º 4
0
def search():
    query = request.args.get('query')
    results = search_mods(query, 0)
    wrapped = list()
    for result in results:
        m = wrap_mod(result)
        if m:
            wrapped.append(m)
    return render_template("search.html", results=wrapped, query=query)
Ejemplo n.º 5
0
def browse_top():
    page = request.args.get('page')
    if page:
        page = int(page)
    else:
        page = 1
    mods, total_pages = search_mods("", page, 30)
    return render_template("browse-list.html", mods=mods, page=page, total_pages=total_pages,\
            url="/browse/top", name="Popular Mods")
Ejemplo n.º 6
0
def browse_top():
    page = request.args.get('page')
    if page:
        page = int(page)
    else:
        page = 1
    mods, total_pages = search_mods("", page, 30)
    return render_template("browse-list.html", mods=mods, page=page, total_pages=total_pages,\
            url="/browse/top", name="Popular Mods")
Ejemplo n.º 7
0
def browse_all():
    page = request.args.get('page')
    if page:
        page = int(page)
    else:
        page = 1
    mods, total_pages = search_mods(False, "", page, 30)
    return render_template("browse-list.html", mods=mods, page=page, total_pages=total_pages,\
            url="/browse/all", name="All Mods", site_name=_cfg('site-name'), support_mail=_cfg('support-mail'))
Ejemplo n.º 8
0
def browse_all():
    page = request.args.get('page')
    if page:
        page = int(page)
    else:
        page = 1
    mods, total_pages = search_mods(False,"", page, 30)
    return render_template("browse-list.html", mods=mods, page=page, total_pages=total_pages,\
            url="/browse/all", name="All Mods", site_name=_cfg('site-name'), support_mail=_cfg('support-mail'))
Ejemplo n.º 9
0
def search():
    query = request.args.get('query')
    results = search_mods(query, 0)
    wrapped = list()
    for result in results:
        m = wrap_mod(result)
        if m:
            wrapped.append(m)
    return render_template("search.html", results=wrapped, query=query)
Ejemplo n.º 10
0
def anniversary():
    user_count = User.query.count()
    mod_count = Mod.query.count()
    download_count = 0
    top = search_mods("", 1, 6)[0]
    oldest = Mod.query.filter(Mod.published).order_by(Mod.created).limit(6)[:6]
    for m in Mod.query.all():
        download_count += m.download_count
    return render_template("anniversary.html", users=user_count, \
            mods=mod_count, downloads=download_count, top=top, oldest=oldest)
Ejemplo n.º 11
0
def anniversary():
    user_count = User.query.count()
    mod_count = Mod.query.count()
    download_count = 0
    top = search_mods("", 1, 6)[0]
    oldest = Mod.query.filter(Mod.published).order_by(Mod.created).limit(6)[:6]
    for m in Mod.query.all():
        download_count += m.download_count
    return render_template("anniversary.html", users=user_count, \
            mods=mod_count, downloads=download_count, top=top, oldest=oldest, site_name=_cfg('site-name'), support_mail=_cfg('support-mail'))
Ejemplo n.º 12
0
def browse():
    featured = Featured.query.order_by(desc(Featured.created)).limit(6)[:6]
    top = search_mods("", 1, 6)[:6][0]
    new = Mod.query.filter(Mod.published).order_by(desc(
        Mod.created)).limit(6)[:6]
    return render_template("browse.html",
                           featured=featured,
                           top=top,
                           new=new,
                           site_name=_cfg('site-name'),
                           support_mail=_cfg('support-mail'))
Ejemplo n.º 13
0
def search():
    query = request.args.get('query')
    if not query:
        query = ''
    page = request.args.get('page')
    if page:
        page = int(page)
    else:
        page = 1
    mods, total_pages = search_mods(query, page, 30)
    return render_template("browse-list.html", mods=mods, page=page, total_pages=total_pages, search=True, query=query)
Ejemplo n.º 14
0
def search():
    query = request.args.get('query')
    if not query:
        query = ''
    page = request.args.get('page')
    if page:
        page = int(page)
    else:
        page = 1
    mods, total_pages = search_mods(query, page, 30)
    return render_template("browse-list.html", mods=mods, page=page, total_pages=total_pages, search=True, query=query)
Ejemplo n.º 15
0
def search():
    query = request.args.get('query')
    if not query:
        query = ''
    page = request.args.get('page')
    if page:
        page = int(page)
    else:
        page = 1
    mods, total_pages = search_mods(query, page, 30)
    return render_template("browse-list.html", mods=mods, page=page, total_pages=total_pages, search=True, query=query, site_name=_cfg('site-name'), support_mail=_cfg('support-mail'))
Ejemplo n.º 16
0
def singlegame_browse(gameshort):
    if not gameshort:
        gameshort = "kerbal-space-program"
    ga = Game.query.filter(Game.short == gameshort).first()
    session["game"] = ga.id
    session["gamename"] = ga.name
    session["gameshort"] = ga.short
    session["gameid"] = ga.id
    featured = Featured.query.outerjoin(Mod).filter(Mod.game_id == ga.id).order_by(desc(Featured.created)).limit(6)[:6]
    top = search_mods(ga, "", 1, 6)[:6][0]
    new = Mod.query.filter(Mod.published, Mod.game_id == ga.id).order_by(desc(Mod.created)).limit(6)[:6]
    return render_template("browse.html", featured=featured, top=top, ga=ga, new=new)
Ejemplo n.º 17
0
def index():
    featured = Featured.query.order_by(desc(Featured.created)).limit(6)[:6]
    top = search_mods("", 1, 3)[0]
    new = Mod.query.filter(Mod.published).order_by(desc(Mod.created)).limit(3)[:3]
    user_count = User.query.count()
    mod_count = Mod.query.count()
    return render_template("index.html",\
        featured=featured,\
        new=new,\
        top=top,\
        user_count=user_count,\
        mod_count=mod_count)
Ejemplo n.º 18
0
def search_mod():
    query = request.args.get("query")
    page = request.args.get("page")
    query = "" if not query else query
    page = 1 if not page or not page.isdigit() else int(page)
    results = list()
    for m in search_mods(None, query, page, 30)[0]:
        a = mod_info(m)
        a["versions"] = list()
        for v in m.versions:
            a["versions"].append(version_info(m, v))
        results.append(a)
    return results
Ejemplo n.º 19
0
def index():
    featured = Featured.query.order_by(desc(Featured.created)).limit(6)[:6]
    top = search_mods("", 1, 3)[0]
    new = Mod.query.filter(Mod.published).order_by(desc(
        Mod.created)).limit(3)[:3]
    user_count = User.query.count()
    mod_count = Mod.query.count()
    return render_template("index.html",\
        featured=featured,\
        new=new,\
        top=top,\
        user_count=user_count,\
        mod_count=mod_count)
Ejemplo n.º 20
0
def search_mod():
    query = request.args.get('query')
    page = request.args.get('page')
    query = '' if not query else query
    page = 1 if not page or not page.isdigit() else int(page)
    results = list()
    for m in search_mods(query, page, 30)[0]:
        a = mod_info(m)
        a['versions'] = list()
        for v in m.versions:
            a['versions'].append(version_info(m, v))
        results.append(a)
    return results
Ejemplo n.º 21
0
def browse_top():
    page = request.args.get('page')
    if page:
        page = int(page)
    else:
        page = 1
    mods, total_pages = search_mods("", page, 30)
    results = list()
    for m in mods:
        a = mod_info(m)
        a['versions'] = list()
        for v in m.versions:
            a['versions'].append(version_info(m, v))
        results.append(a)
    return results
Ejemplo n.º 22
0
def browse_top():
    page = request.args.get('page')
    if page:
        page = int(page)
    else:
        page = 1
    mods, total_pages = search_mods("", page, 30)
    results = list()
    for m in mods:
        a = mod_info(m)
        a['versions'] = list()
        for v in m.versions:
            a['versions'].append(version_info(m, v))
        results.append(a)
    return results
Ejemplo n.º 23
0
def singlegame_browse_all(gameshort):
    if not gameshort:
        gameshort = 'kerbal-space-program'
    ga = Game.query.filter(Game.short == gameshort).first()
    session['game'] = ga.id;
    session['gamename'] = ga.name;
    session['gameshort'] = ga.short;
    session['gameid'] = ga.id;
    page = request.args.get('page')
    if page:
        page = int(page)
    else:
        page = 1
    mods, total_pages = search_mods(False,"", page, 30)
    return render_template("browse-list.html", mods=mods, page=page, total_pages=total_pages,ga = ga,\
            url="/browse/all", name="All Mods", site_name=_cfg('site-name'), support_mail=_cfg('support-mail'))
Ejemplo n.º 24
0
def singlegame_browse_all(gameshort):
    if not gameshort:
        gameshort = 'kerbal-space-program'
    ga = Game.query.filter(Game.short == gameshort).first()
    session['game'] = ga.id
    session['gamename'] = ga.name
    session['gameshort'] = ga.short
    session['gameid'] = ga.id
    page = request.args.get('page')
    if page:
        page = int(page)
    else:
        page = 1
    mods, total_pages = search_mods(False, "", page, 30)
    return render_template("browse-list.html", mods=mods, page=page, total_pages=total_pages,ga = ga,\
            url="/browse/all", name="All Mods", site_name=_cfg('site-name'), support_mail=_cfg('support-mail'))
Ejemplo n.º 25
0
def browse_top():
    page = request.args.get("page")
    if page:
        page = int(page)
    else:
        page = 1
    mods, total_pages = search_mods(None, "", page, 30)
    return render_template(
        "browse-list.html",
        mods=mods,
        page=page,
        total_pages=total_pages,
        url="/browse/top",
        name="Popular Mods",
        site_name=_cfg("site-name"),
        support_mail=_cfg("support-mail"),
    )
Ejemplo n.º 26
0
def singlegame_browse(gameshort):
    if not gameshort:
        gameshort = 'kerbal-space-program'
    ga = Game.query.filter(Game.short == gameshort).first()
    session['game'] = ga.id
    session['gamename'] = ga.name
    session['gameshort'] = ga.short
    session['gameid'] = ga.id
    featured = Featured.query.outerjoin(Mod).filter(
        Mod.game_id == ga.id).order_by(desc(Featured.created)).limit(6)[:6]
    top = search_mods(ga, "", 1, 6)[:6][0]
    new = Mod.query.filter(Mod.published, Mod.game_id == ga.id).order_by(
        desc(Mod.created)).limit(6)[:6]
    return render_template("browse.html",
                           featured=featured,
                           top=top,
                           ga=ga,
                           new=new)
Ejemplo n.º 27
0
def search():
    query = request.args.get('query')
    if not query:
        query = ''
    page = request.args.get('page')
    if page:
        page = int(page)
    else:
        page = 1
    mods, total_pages = search_mods(query, page, 30)
    return render_template("browse-list.html",
                           mods=mods,
                           page=page,
                           total_pages=total_pages,
                           search=True,
                           query=query,
                           site_name=_cfg('site-name'),
                           support_mail=_cfg('support-mail'))
Ejemplo n.º 28
0
def index():
    featured = Featured.query.order_by(desc(Featured.created)).limit(6)[:6]
    top = search_mods("", 1, 3)[0]
    new = Mod.query.filter(Mod.published).order_by(desc(Mod.created)).limit(3)[:3]
    recent = Mod.query.filter(Mod.published).order_by(desc(Mod.updated)).limit(3)[:3]
    user_count = User.query.count()
    mod_count = Mod.query.count()
    yours = list()
    if current_user:
        yours = sorted(current_user.following, key=lambda m: m.updated, reverse=True)[:3]
    return render_template("index.html",\
        featured=featured,\
        new=new,\
        top=top,\
        recent=recent,\
        user_count=user_count,\
        mod_count=mod_count,
        yours=yours)
Ejemplo n.º 29
0
def singlegame_search(gameshort):
    if not gameshort:
        gameshort = 'kerbal-space-program'
    ga = Game.query.filter(Game.short == gameshort).first()
    session['game'] = ga.id;
    session['gamename'] = ga.name;
    session['gameshort'] = ga.short;
    session['gameid'] = ga.id;
    query = request.args.get('query')
    if not query:
        query = ''
    page = request.args.get('page')
    if page:
        page = int(page)
    else:
        page = 1
    mods, total_pages = search_mods(ga,query, page, 30)
    return render_template("browse-list.html", mods=mods, page=page, total_pages=total_pages, search=True, query=query,ga=ga)
Ejemplo n.º 30
0
def search():
    query = request.args.get('query')
    category = request.args.get('category')
    nsfw = request.args.get('nsfw')
    game_a = request.args.get('game')
    if(game_a == None):
        game_a = "all"
    if(nsfw == None or nsfw == ""):
        nsfw = "no"
    if not query:
        query = ''
    page = request.args.get('page')
    if page:
        page = int(page)
    else:
        page = 1
    mods, total_pages = search_mods(query, page, 30, category, nsfw, game_a)
    
    return render_template("browse-list.html", mods=mods, page=page, total_pages=total_pages, search=True, query=query, category=category)
Ejemplo n.º 31
0
def singlegame_search(gameshort):
    if not gameshort:
        gameshort = "kerbal-space-program"
    ga = Game.query.filter(Game.short == gameshort).first()
    session["game"] = ga.id
    session["gamename"] = ga.name
    session["gameshort"] = ga.short
    session["gameid"] = ga.id
    query = request.args.get("query")
    if not query:
        query = ""
    page = request.args.get("page")
    if page:
        page = int(page)
    else:
        page = 1
    mods, total_pages = search_mods(ga, query, page, 30)
    return render_template(
        "browse-list.html", mods=mods, page=page, total_pages=total_pages, search=True, query=query, ga=ga
    )
Ejemplo n.º 32
0
def singlegame_search(gameshort):
    if not gameshort:
        gameshort = 'kerbal-space-program'
    ga = Game.query.filter(Game.short == gameshort).first()
    session['game'] = ga.id
    session['gamename'] = ga.name
    session['gameshort'] = ga.short
    session['gameid'] = ga.id
    query = request.args.get('query')
    if not query:
        query = ''
    page = request.args.get('page')
    if page:
        page = int(page)
    else:
        page = 1
    mods, total_pages = search_mods(ga, query, page, 30)
    return render_template("browse-list.html",
                           mods=mods,
                           page=page,
                           total_pages=total_pages,
                           search=True,
                           query=query,
                           ga=ga)
Ejemplo n.º 33
0
def browse():
    featured = Featured.query.order_by(desc(Featured.created)).limit(6)[:6]
    top = search_mods("", 1, 6)[:6][0]
    new = Mod.query.filter(Mod.published).order_by(desc(Mod.created)).limit(6)[:6]
    return render_template("browse.html", featured=featured, top=top, new=new, site_name=_cfg('site-name'), support_mail=_cfg('support-mail'))
Ejemplo n.º 34
0
def browse():
    featured = Featured.query.order_by(desc(Featured.created)).limit(7)[:7]
    top = search_mods("", 0)[:7]
    new = Mod.query.filter(Mod.published).order_by(desc(Mod.created)).limit(7)[:7]
    return render_template("browse.html", featured=featured, top=top, new=new)
Ejemplo n.º 35
0
def browse():
    featured = Featured.query.order_by(desc(Featured.created)).limit(6)[:6]
    top = search_mods("", 1, 6)[:6][0]
    new = Mod.query.filter(Mod.published).order_by(desc(
        Mod.created)).limit(6)[:6]
    return render_template("browse.html", featured=featured, top=top, new=new)