mirror of
https://github.com/minetest/contentdb.git
synced 2024-12-23 06:22:24 +01:00
Add package types
This commit is contained in:
parent
ae600582a0
commit
bc88027fbe
@ -9,7 +9,7 @@ First create a Python virtual env:
|
|||||||
|
|
||||||
then use pip:
|
then use pip:
|
||||||
|
|
||||||
pip install -r requirements.txt
|
pip3 install -r requirements.txt
|
||||||
|
|
||||||
## Running
|
## Running
|
||||||
|
|
||||||
@ -20,11 +20,11 @@ the current session:
|
|||||||
|
|
||||||
Reset the database like so:
|
Reset the database like so:
|
||||||
|
|
||||||
python setup.py -d
|
python3 setup.py -d
|
||||||
|
|
||||||
Then run the server:
|
Then run the server:
|
||||||
|
|
||||||
python rundebug.py
|
python3 rundebug.py
|
||||||
|
|
||||||
Then view in your web browser:
|
Then view in your web browser:
|
||||||
|
|
||||||
|
@ -11,4 +11,5 @@ menu.Menu(app=app)
|
|||||||
markdown.Markdown(app, extensions=['fenced_code'])
|
markdown.Markdown(app, extensions=['fenced_code'])
|
||||||
github = GitHub(app)
|
github = GitHub(app)
|
||||||
|
|
||||||
import models, views
|
from . import models
|
||||||
|
from .views import *
|
||||||
|
@ -4,6 +4,7 @@ from app import app
|
|||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from sqlalchemy.orm import validates
|
from sqlalchemy.orm import validates
|
||||||
from flask_user import login_required, UserManager, UserMixin, SQLAlchemyAdapter
|
from flask_user import login_required, UserManager, UserMixin, SQLAlchemyAdapter
|
||||||
|
import enum
|
||||||
|
|
||||||
# Initialise database
|
# Initialise database
|
||||||
db = SQLAlchemy(app)
|
db = SQLAlchemy(app)
|
||||||
@ -57,6 +58,19 @@ class UserRoles(db.Model):
|
|||||||
user_id = db.Column(db.Integer(), db.ForeignKey('user.id', ondelete='CASCADE'))
|
user_id = db.Column(db.Integer(), db.ForeignKey('user.id', ondelete='CASCADE'))
|
||||||
role_id = db.Column(db.Integer(), db.ForeignKey('role.id', ondelete='CASCADE'))
|
role_id = db.Column(db.Integer(), db.ForeignKey('role.id', ondelete='CASCADE'))
|
||||||
|
|
||||||
|
class PackageType(enum.Enum):
|
||||||
|
MOD = "Mod"
|
||||||
|
GAME = "Game"
|
||||||
|
TXP = "Texture Pack"
|
||||||
|
|
||||||
|
def getTitle(self):
|
||||||
|
if self == PackageType.MOD:
|
||||||
|
return "Mod"
|
||||||
|
elif self == PackageType.GAME:
|
||||||
|
return "Game"
|
||||||
|
else:
|
||||||
|
return "TXP"
|
||||||
|
|
||||||
class Package(db.Model):
|
class Package(db.Model):
|
||||||
id = db.Column(db.Integer, primary_key=True)
|
id = db.Column(db.Integer, primary_key=True)
|
||||||
|
|
||||||
@ -65,6 +79,7 @@ class Package(db.Model):
|
|||||||
name = db.Column(db.String(100), nullable=False)
|
name = db.Column(db.String(100), nullable=False)
|
||||||
title = db.Column(db.String(100), nullable=False)
|
title = db.Column(db.String(100), nullable=False)
|
||||||
desc = db.Column(db.Text, nullable=True)
|
desc = db.Column(db.Text, nullable=True)
|
||||||
|
type = db.Column(db.Enum(PackageType))
|
||||||
|
|
||||||
# Downloads
|
# Downloads
|
||||||
repo = db.Column(db.String(200), nullable=True)
|
repo = db.Column(db.String(200), nullable=True)
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
{% block content %}
|
{% block content %}
|
||||||
<ul>
|
<ul>
|
||||||
{% for p in packages %}
|
{% for p in packages %}
|
||||||
<li><a href="{{ url_for('package_page', type='mod', author=p.author.username, name=p.name) }}">
|
<li><a href="{{ url_for('package_page', type=p.type.getTitle()|lower, author=p.author.username, name=p.name) }}">
|
||||||
{{ p.title }} by {{ p.author.display_name }}
|
{{ p.title }} by {{ p.author.display_name }}
|
||||||
</a></li>
|
</a></li>
|
||||||
{% else %}
|
{% else %}
|
||||||
|
@ -14,9 +14,9 @@ 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, mods
|
|
||||||
|
|
||||||
@app.route('/')
|
@app.route('/')
|
||||||
@menu.register_menu(app, '.', 'Home')
|
@menu.register_menu(app, '.', 'Home')
|
||||||
def home_page():
|
def home_page():
|
||||||
return render_template('index.html')
|
return render_template('index.html')
|
||||||
|
|
||||||
|
from . import users, githublogin, packages
|
||||||
|
@ -7,9 +7,21 @@ from app.models import *
|
|||||||
@app.route('/mods/')
|
@app.route('/mods/')
|
||||||
@menu.register_menu(app, '.mods', 'Mods')
|
@menu.register_menu(app, '.mods', 'Mods')
|
||||||
def mods_page():
|
def mods_page():
|
||||||
packages = Package.query.all()
|
packages = Package.query.filter_by(type=PackageType.MOD).all()
|
||||||
return render_template('packages.html', title="Mods", packages=packages)
|
return render_template('packages.html', title="Mods", packages=packages)
|
||||||
|
|
||||||
|
@app.route('/games/')
|
||||||
|
@menu.register_menu(app, '.games', 'Games')
|
||||||
|
def games_page():
|
||||||
|
packages = Package.query.filter_by(type=PackageType.GAME).all()
|
||||||
|
return render_template('packages.html', title="Games", packages=packages)
|
||||||
|
|
||||||
|
@app.route('/texturepacks/')
|
||||||
|
@menu.register_menu(app, '.txp', 'Texture Packs')
|
||||||
|
def txp_page():
|
||||||
|
packages = Package.query.filter_by(type=PackageType.TXP).all()
|
||||||
|
return render_template('packages.html', title="Texture Packs", packages=packages)
|
||||||
|
|
||||||
@app.route("/<type>s/<author>/<name>/")
|
@app.route("/<type>s/<author>/<name>/")
|
||||||
def package_page(type, author, name):
|
def package_page(type, author, name):
|
||||||
package = Package.query.filter_by(name=name).first()
|
package = Package.query.filter_by(name=name).first()
|
||||||
|
1
setup.py
1
setup.py
@ -19,6 +19,7 @@ if not os.path.isfile("db.sqlite"):
|
|||||||
mod1 = Package()
|
mod1 = Package()
|
||||||
mod1.name = "awards"
|
mod1.name = "awards"
|
||||||
mod1.title = "Awards"
|
mod1.title = "Awards"
|
||||||
|
mod1.type = PackageType.MOD
|
||||||
mod1.author = ruben
|
mod1.author = ruben
|
||||||
mod1.description = "Adds achievements and an API to register new ones."
|
mod1.description = "Adds achievements and an API to register new ones."
|
||||||
mod1.repo = "https://github.com/rubenwardy/awards"
|
mod1.repo = "https://github.com/rubenwardy/awards"
|
||||||
|
Loading…
Reference in New Issue
Block a user