mirror of
https://github.com/minetest/contentdb.git
synced 2025-01-03 11:47:28 +01:00
Add package list and package view
This commit is contained in:
parent
84f123a0ab
commit
358fc4e5da
14
app/templates/package_details.html
Normal file
14
app/templates/package_details.html
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
{% extends "base.html" %}
|
||||||
|
|
||||||
|
{% block title %}
|
||||||
|
{{ package.title }}
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
{{ package.title }}
|
||||||
|
{{ package.author.display_name }}
|
||||||
|
{{ package.name }}
|
||||||
|
{{ package.desc }}
|
||||||
|
<a href="{{ package.repo }}">VCS Repo</a>
|
||||||
|
<a href="{{ package.issueTracker }}">Report Issue</a>
|
||||||
|
{% endblock %}
|
17
app/templates/packages.html
Normal file
17
app/templates/packages.html
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
{% extends "base.html" %}
|
||||||
|
|
||||||
|
{% block title %}
|
||||||
|
{{ title }}
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<ul>
|
||||||
|
{% for p in packages %}
|
||||||
|
<li><a href="{{ url_for('package_page', type='mod', author=p.author.username, name=p.name) }}">
|
||||||
|
{{ p.title }} by {{ p.author.display_name }}
|
||||||
|
</a></li>
|
||||||
|
{% else %}
|
||||||
|
<li><i>No packages available</i></ul>
|
||||||
|
{% endfor %}
|
||||||
|
</ul>
|
||||||
|
{% endblock %}
|
@ -20,7 +20,11 @@
|
|||||||
{% elif user == current_user %}
|
{% elif user == current_user %}
|
||||||
<a href="">Link Forums Account</a>
|
<a href="">Link Forums Account</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
|
||||||
|
{% if (user.forums_username and user.github_username) or user == current_user %}
|
||||||
|
|
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
{% if user.github_username %}
|
{% if user.github_username %}
|
||||||
<a href="https://github.com/{{ user.github_username }}">GitHub</a>
|
<a href="https://github.com/{{ user.github_username }}">GitHub</a>
|
||||||
{% elif user == current_user %}
|
{% elif user == current_user %}
|
||||||
|
@ -14,7 +14,7 @@ cache = SimpleCache()
|
|||||||
def send_static(path):
|
def send_static(path):
|
||||||
return send_from_directory('static', path)
|
return send_from_directory('static', path)
|
||||||
|
|
||||||
import users, githublogin
|
import users, githublogin, mods
|
||||||
|
|
||||||
@app.route('/')
|
@app.route('/')
|
||||||
@menu.register_menu(app, '.', 'Home')
|
@menu.register_menu(app, '.', 'Home')
|
||||||
|
19
app/views/mods.py
Normal file
19
app/views/mods.py
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
from flask import *
|
||||||
|
from flask_user import *
|
||||||
|
from flask.ext import menu
|
||||||
|
from app import app
|
||||||
|
from app.models import *
|
||||||
|
|
||||||
|
@app.route('/mods/')
|
||||||
|
@menu.register_menu(app, '.mods', 'Mods')
|
||||||
|
def mods_page():
|
||||||
|
packages = Mod.query.all()
|
||||||
|
return render_template('packages.html', title="Mods", packages=packages)
|
||||||
|
|
||||||
|
@app.route("/<type>s/<author>/<name>/")
|
||||||
|
def package_page(type, author, name):
|
||||||
|
package = Mod.query.filter_by(name=name).first()
|
||||||
|
if package is None:
|
||||||
|
abort(404)
|
||||||
|
|
||||||
|
return render_template('package_details.html', package=package)
|
17
setup.py
17
setup.py
@ -2,10 +2,10 @@ import os, datetime
|
|||||||
|
|
||||||
delete_db = False
|
delete_db = False
|
||||||
|
|
||||||
if delete_db and os.path.isfile("app/data.sqlite"):
|
if delete_db and os.path.isfile("db.sqlite"):
|
||||||
os.remove("app/data.sqlite")
|
os.remove("db.sqlite")
|
||||||
|
|
||||||
if not os.path.isfile("app/data.sqlite"):
|
if not os.path.isfile("db.sqlite"):
|
||||||
from app.models import *
|
from app.models import *
|
||||||
|
|
||||||
print("Creating database tables...")
|
print("Creating database tables...")
|
||||||
@ -15,6 +15,17 @@ if not os.path.isfile("app/data.sqlite"):
|
|||||||
ruben = User("rubenwardy")
|
ruben = User("rubenwardy")
|
||||||
ruben.github_username = "rubenwardy"
|
ruben.github_username = "rubenwardy"
|
||||||
db.session.add(ruben)
|
db.session.add(ruben)
|
||||||
|
|
||||||
|
mod1 = Mod()
|
||||||
|
mod1.name = "awards"
|
||||||
|
mod1.title = "Awards"
|
||||||
|
mod1.author = ruben
|
||||||
|
mod1.description = "Adds achievements and an API to register new ones."
|
||||||
|
mod1.repo = "https://github.com/rubenwardy/awards"
|
||||||
|
mod1.issueTracker = "https://github.com/rubenwardy/awards/issues"
|
||||||
|
mod1.forums = "https://forum.minetest.net/viewtopic.php?t=4870"
|
||||||
|
db.session.add(mod1)
|
||||||
|
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
else:
|
else:
|
||||||
print("Database already exists")
|
print("Database already exists")
|
||||||
|
Loading…
Reference in New Issue
Block a user