mirror of
https://github.com/minetest/contentdb.git
synced 2024-12-22 22:12:24 +01:00
Split Featured tag into Featured and Spotlight
This commit is contained in:
parent
78b5986027
commit
0a77a0110d
@ -77,9 +77,9 @@ def packages():
|
||||
pkgs = [package for package in pkgs if package.get("release")]
|
||||
|
||||
# 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 = 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:
|
||||
featured_lut.add(f"{pkg['author']}/{pkg['name']}")
|
||||
pkg["short_description"] = "Featured. " + pkg["short_description"]
|
||||
@ -529,7 +529,7 @@ def homepage():
|
||||
query = Package.query.filter_by(state=PackageState.APPROVED)
|
||||
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()
|
||||
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()
|
||||
@ -553,7 +553,7 @@ def homepage():
|
||||
return jsonify({
|
||||
"count": count,
|
||||
"downloads": downloads,
|
||||
"featured": mapPackages(featured),
|
||||
"spotlight": mapPackages(spotlight),
|
||||
"new": mapPackages(new),
|
||||
"updated": mapPackages(updated),
|
||||
"pop_mod": mapPackages(pop_mod),
|
||||
@ -572,9 +572,6 @@ def welcome_v1():
|
||||
.order_by(func.random()) \
|
||||
.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]):
|
||||
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)
|
||||
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()
|
||||
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)\
|
||||
.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)
|
||||
|
@ -27,7 +27,8 @@ def populate(session):
|
||||
for tag in ["Inventory", "Mapgen", "Building",
|
||||
"Mobs and NPCs", "Tools", "Player effects",
|
||||
"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)
|
||||
tags[row.name] = row
|
||||
session.add(row)
|
||||
|
@ -27,12 +27,12 @@
|
||||
{% from "macros/packagegridtile.html" import render_pkggrid %}
|
||||
<div id="featuredCarousel" class="carousel slide my-0" data-ride="carousel" data-interval="7500">
|
||||
<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>
|
||||
{% endfor %}
|
||||
</ol>
|
||||
<div class="carousel-inner">
|
||||
{% for package in featured %}
|
||||
{% for package in spotlight_pkgs %}
|
||||
{% set cover_image = package.getCoverImageURL() %}
|
||||
{% set tags = package.tags | sort(attribute="views", reverse=True) %}
|
||||
<div class="carousel-item {% if loop.index == 1 %}active{% endif %}">
|
||||
@ -64,7 +64,7 @@
|
||||
</span>
|
||||
{% endfor %}
|
||||
{% 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 '' }}">
|
||||
{{ t.title }}
|
||||
</span>
|
||||
@ -96,12 +96,12 @@
|
||||
<span class="sr-only">{{ _("Next") }}</span>
|
||||
</a>
|
||||
</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">
|
||||
<i class="fas fa-question-circle mr-1"></i>
|
||||
{{ _("Featured") }}
|
||||
</a>
|
||||
</div>
|
||||
</div> -->
|
||||
|
||||
<a href="{{ url_for('packages.list_all', sort='approved_at', order='desc') }}" class="btn btn-secondary float-right">
|
||||
{{ _("See more") }}
|
||||
|
Loading…
Reference in New Issue
Block a user