mirror of
https://github.com/minetest/contentdb.git
synced 2025-03-25 03:12:40 +01:00
Split Featured tag into Featured and Spotlight
This commit is contained in:
app
@ -77,9 +77,9 @@ def packages():
|
|||||||
pkgs = [package for package in pkgs if package.get("release")]
|
pkgs = [package for package in pkgs if package.get("release")]
|
||||||
|
|
||||||
# Promote featured packages
|
# Promote featured packages
|
||||||
if "sort" not in request.args and "order" not in request.args:
|
if "sort" not in request.args and "order" not in request.args and "q" not in request.args:
|
||||||
featured_lut = set()
|
featured_lut = set()
|
||||||
featured = qb.convertToDictionary(query.filter(Package.tags.any(name="featured")).all())
|
featured = qb.convertToDictionary(query.filter(Package.tags.any(name="featured")).all())[:3]
|
||||||
for pkg in featured:
|
for pkg in featured:
|
||||||
featured_lut.add(f"{pkg['author']}/{pkg['name']}")
|
featured_lut.add(f"{pkg['author']}/{pkg['name']}")
|
||||||
pkg["short_description"] = "Featured. " + pkg["short_description"]
|
pkg["short_description"] = "Featured. " + pkg["short_description"]
|
||||||
@ -529,7 +529,7 @@ def homepage():
|
|||||||
query = Package.query.filter_by(state=PackageState.APPROVED)
|
query = Package.query.filter_by(state=PackageState.APPROVED)
|
||||||
count = query.count()
|
count = query.count()
|
||||||
|
|
||||||
featured = query.filter(Package.tags.any(name="featured")).order_by(
|
spotlight = query.filter(Package.tags.any(name="spotlight")).order_by(
|
||||||
func.random()).limit(6).all()
|
func.random()).limit(6).all()
|
||||||
new = query.order_by(db.desc(Package.approved_at)).limit(4).all()
|
new = query.order_by(db.desc(Package.approved_at)).limit(4).all()
|
||||||
pop_mod = query.filter_by(type=PackageType.MOD).order_by(db.desc(Package.score)).limit(8).all()
|
pop_mod = query.filter_by(type=PackageType.MOD).order_by(db.desc(Package.score)).limit(8).all()
|
||||||
@ -553,7 +553,7 @@ def homepage():
|
|||||||
return jsonify({
|
return jsonify({
|
||||||
"count": count,
|
"count": count,
|
||||||
"downloads": downloads,
|
"downloads": downloads,
|
||||||
"featured": mapPackages(featured),
|
"spotlight": mapPackages(spotlight),
|
||||||
"new": mapPackages(new),
|
"new": mapPackages(new),
|
||||||
"updated": mapPackages(updated),
|
"updated": mapPackages(updated),
|
||||||
"pop_mod": mapPackages(pop_mod),
|
"pop_mod": mapPackages(pop_mod),
|
||||||
@ -572,9 +572,6 @@ def welcome_v1():
|
|||||||
.order_by(func.random()) \
|
.order_by(func.random()) \
|
||||||
.limit(5).all()
|
.limit(5).all()
|
||||||
|
|
||||||
mtg = Package.query.filter(Package.author.has(username="Minetest"), Package.name == "minetest_game").one()
|
|
||||||
featured.insert(2, mtg)
|
|
||||||
|
|
||||||
def map_packages(packages: List[Package]):
|
def map_packages(packages: List[Package]):
|
||||||
return [pkg.getAsDictionaryShort(current_app.config["BASE_URL"]) for pkg in packages]
|
return [pkg.getAsDictionaryShort(current_app.config["BASE_URL"]) for pkg in packages]
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ def home():
|
|||||||
query = Package.query.filter_by(state=PackageState.APPROVED)
|
query = Package.query.filter_by(state=PackageState.APPROVED)
|
||||||
count = query.count()
|
count = query.count()
|
||||||
|
|
||||||
featured = query.filter(Package.tags.any(name="featured")).order_by(func.random()).limit(6).all()
|
spotlight_pkgs = query.filter(Package.tags.any(name="spotlight")).order_by(func.random()).limit(6).all()
|
||||||
|
|
||||||
new = package_load(query.order_by(db.desc(Package.approved_at))).limit(4).all()
|
new = package_load(query.order_by(db.desc(Package.approved_at))).limit(4).all()
|
||||||
pop_mod = package_load(query.filter_by(type=PackageType.MOD).order_by(db.desc(Package.score))).limit(8).all()
|
pop_mod = package_load(query.filter_by(type=PackageType.MOD).order_by(db.desc(Package.score))).limit(8).all()
|
||||||
@ -57,5 +57,5 @@ def home():
|
|||||||
.select_from(Tag).outerjoin(Tags).join(Package).filter(Package.state == PackageState.APPROVED)\
|
.select_from(Tag).outerjoin(Tags).join(Package).filter(Package.state == PackageState.APPROVED)\
|
||||||
.group_by(Tag.id).order_by(db.asc(Tag.title)).all()
|
.group_by(Tag.id).order_by(db.asc(Tag.title)).all()
|
||||||
|
|
||||||
return render_template("index.html", count=count, downloads=downloads, tags=tags, featured=featured,
|
return render_template("index.html", count=count, downloads=downloads, tags=tags, spotlight_pkgs=spotlight_pkgs,
|
||||||
new=new, updated=updated, pop_mod=pop_mod, pop_txp=pop_txp, pop_gam=pop_gam, high_reviewed=high_reviewed, reviews=reviews)
|
new=new, updated=updated, pop_mod=pop_mod, pop_txp=pop_txp, pop_gam=pop_gam, high_reviewed=high_reviewed, reviews=reviews)
|
||||||
|
@ -27,7 +27,8 @@ def populate(session):
|
|||||||
for tag in ["Inventory", "Mapgen", "Building",
|
for tag in ["Inventory", "Mapgen", "Building",
|
||||||
"Mobs and NPCs", "Tools", "Player effects",
|
"Mobs and NPCs", "Tools", "Player effects",
|
||||||
"Environment", "Transport", "Maintenance", "Plants and farming",
|
"Environment", "Transport", "Maintenance", "Plants and farming",
|
||||||
"PvP", "PvE", "Survival", "Creative", "Puzzle", "Multiplayer", "Singleplayer", "Featured"]:
|
"PvP", "PvE", "Survival", "Creative", "Puzzle", "Multiplayer", "Singleplayer",
|
||||||
|
"Featured", "Spotlight"]:
|
||||||
row = Tag(tag)
|
row = Tag(tag)
|
||||||
tags[row.name] = row
|
tags[row.name] = row
|
||||||
session.add(row)
|
session.add(row)
|
||||||
|
@ -27,12 +27,12 @@
|
|||||||
{% from "macros/packagegridtile.html" import render_pkggrid %}
|
{% from "macros/packagegridtile.html" import render_pkggrid %}
|
||||||
<div id="featuredCarousel" class="carousel slide my-0" data-ride="carousel" data-interval="7500">
|
<div id="featuredCarousel" class="carousel slide my-0" data-ride="carousel" data-interval="7500">
|
||||||
<ol class="carousel-indicators">
|
<ol class="carousel-indicators">
|
||||||
{% for package in featured %}
|
{% for package in spotlight_pkgs %}
|
||||||
<li data-target="#featuredCarousel" data-slide-to="{{ loop.index - 1 }}" {% if loop.index == 1 %}class="active"{% endif %}></li>
|
<li data-target="#featuredCarousel" data-slide-to="{{ loop.index - 1 }}" {% if loop.index == 1 %}class="active"{% endif %}></li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ol>
|
</ol>
|
||||||
<div class="carousel-inner">
|
<div class="carousel-inner">
|
||||||
{% for package in featured %}
|
{% for package in spotlight_pkgs %}
|
||||||
{% set cover_image = package.getCoverImageURL() %}
|
{% set cover_image = package.getCoverImageURL() %}
|
||||||
{% set tags = package.tags | sort(attribute="views", reverse=True) %}
|
{% set tags = package.tags | sort(attribute="views", reverse=True) %}
|
||||||
<div class="carousel-item {% if loop.index == 1 %}active{% endif %}">
|
<div class="carousel-item {% if loop.index == 1 %}active{% endif %}">
|
||||||
@ -64,7 +64,7 @@
|
|||||||
</span>
|
</span>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% for t in tags[:3] %}
|
{% for t in tags[:3] %}
|
||||||
{% if t.name != "featured" %}
|
{% if t.name != "featured" and t.name != "Spotlight" %}
|
||||||
<span class="badge badge-primary" title="{{ t.description or '' }}">
|
<span class="badge badge-primary" title="{{ t.description or '' }}">
|
||||||
{{ t.title }}
|
{{ t.title }}
|
||||||
</span>
|
</span>
|
||||||
@ -96,12 +96,12 @@
|
|||||||
<span class="sr-only">{{ _("Next") }}</span>
|
<span class="sr-only">{{ _("Next") }}</span>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
<div class="text-right mb-5 text-muted" style="opacity: 0.4;">
|
<!-- <div class="text-right mb-5 text-muted" style="opacity: 0.4;">
|
||||||
<a href="/help/featured/" class="btn">
|
<a href="/help/featured/" class="btn">
|
||||||
<i class="fas fa-question-circle mr-1"></i>
|
<i class="fas fa-question-circle mr-1"></i>
|
||||||
{{ _("Featured") }}
|
{{ _("Featured") }}
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div> -->
|
||||||
|
|
||||||
<a href="{{ url_for('packages.list_all', sort='approved_at', order='desc') }}" class="btn btn-secondary float-right">
|
<a href="{{ url_for('packages.list_all', sort='approved_at', order='desc') }}" class="btn btn-secondary float-right">
|
||||||
{{ _("See more") }}
|
{{ _("See more") }}
|
||||||
|
Reference in New Issue
Block a user