Compare commits

..

62 Commits

Author SHA1 Message Date
rubenwardy
7943598528 Improve package edit page layout 2018-12-29 19:06:17 +00:00
rubenwardy
4bc8b58af7 Remove limit on dependency size 2018-12-29 19:00:13 +00:00
rubenwardy
ec0e89c21d Fix bug in package_create.js 2018-12-29 18:41:09 +00:00
rubenwardy
2975f94d9e Add short description tips 2018-12-29 15:57:16 +00:00
rubenwardy
a9a045eefd Fix wizard deleting values from topic create 2018-12-28 14:32:11 +00:00
rubenwardy
d09ede00fb Add sort toggle bar to topics list 2018-12-27 15:32:15 +00:00
rubenwardy
515248eb8b Add open link to forum topic ID field 2018-12-27 00:03:16 +00:00
rubenwardy
66ee706a6c Fix profile picture bugs 2018-12-25 23:02:49 +00:00
rubenwardy
d44178cb0c Fix relative links again 2018-12-25 20:26:36 +00:00
rubenwardy
c926a812d3 Fix relative links 2018-12-25 20:25:17 +00:00
rubenwardy
0b83d2f2b5 Add task to bulk import avatars from forum 2018-12-25 19:49:17 +00:00
rubenwardy
21960f2404 Add support for using forum profile pictures 2018-12-25 19:28:32 +00:00
rubenwardy
f94885a58f Fix gravatar link being a button 2018-12-25 18:36:02 +00:00
rubenwardy
f7d4b4bf6d Show placeholder message in unadded topics profile section when empty 2018-12-25 18:34:38 +00:00
rubenwardy
d04e060854 Improve profile pic styling on user profile page 2018-12-25 18:25:25 +00:00
rubenwardy
7801be3d39 Fix create button show logic in topic list 2018-12-25 18:15:11 +00:00
rubenwardy
b10660030a Fix params in topic list being lost on page change 2018-12-25 18:12:25 +00:00
rubenwardy
f5744f5188 Fix non-editors seeing create buttons for topics 2018-12-25 17:58:44 +00:00
rubenwardy
272be09ba1 Add links to topic lists in user dropdown 2018-12-25 17:56:51 +00:00
rubenwardy
09150a4dbb Allow users to discard their own topics 2018-12-25 17:51:29 +00:00
rubenwardy
c726f56b3e Fix bugs in topic todo 2018-12-25 16:43:41 +00:00
rubenwardy
daded6d193 Add sort by option to topic list 2018-12-25 16:40:19 +00:00
rubenwardy
b0a5980833 Add unlimited results toggle in topics list 2018-12-25 15:20:58 +00:00
rubenwardy
1eaed55bc6 Add ability to unapprove package from GUI 2018-12-25 15:13:30 +00:00
rubenwardy
c2265313d8 Truncate long links in topic list 2018-12-24 00:37:52 +00:00
rubenwardy
49d5a123e5 Add progress bar to topics page 2018-12-24 00:27:55 +00:00
rubenwardy
c79c970171 Fix .wiptopic affecting buttons 2018-12-24 00:13:45 +00:00
rubenwardy
fa0506f58a Add create date to topic list 2018-12-24 00:11:15 +00:00
rubenwardy
50889ccca5 Add topic searching and topic discarding 2018-12-23 23:54:20 +00:00
rubenwardy
b8ca5d24c5 Add pagination and search to topics 2018-12-23 18:04:56 +00:00
rubenwardy
63969529ad Add random feature 2018-12-23 17:34:44 +00:00
rubenwardy
08434300d8 Rename "I'm feeling lucky" to "First" 2018-12-23 17:11:52 +00:00
rubenwardy
86566bcd39 Improve markdown editor style, switch to EasyMDE, add to comment reply fields 2018-12-23 17:02:02 +00:00
rubenwardy
a7fcce4448 Improve package grid style 2018-12-23 16:28:15 +00:00
rubenwardy
366ed9913e Update to Flask 1.0 2018-12-22 23:03:38 +00:00
rubenwardy
79f4e16286 Improve style of forms 2018-12-22 22:29:30 +00:00
rubenwardy
137a6928bc Replace Popular with Top Mods 2018-12-22 21:41:30 +00:00
rubenwardy
de9135f44f Decrease package tile rounding 2018-12-22 21:26:00 +00:00
rubenwardy
31f57e1f12 Add multi-level thumbnails 2018-12-22 21:20:25 +00:00
rubenwardy
89cae279cd Add top games to home page 2018-12-22 21:13:56 +00:00
rubenwardy
fd901726b0 Add sort and order query params to package list 2018-12-22 21:09:29 +00:00
rubenwardy
5f40d68441 Improve home page 2018-12-22 21:03:01 +00:00
rubenwardy
8eedbf64a4 Improve package grid 2018-12-22 20:49:19 +00:00
rubenwardy
c551201f79 Improve thread styling 2018-12-22 20:25:22 +00:00
rubenwardy
a21a5c24d8 Add pagination styling 2018-12-22 13:33:27 +00:00
rubenwardy
0a969e597b Fix flask_user template 2018-12-22 13:22:08 +00:00
rubenwardy
a1700b5f7e Fix small issues 2018-12-22 13:17:10 +00:00
rubenwardy
d61f77a805 Improve claim page 2018-12-22 13:14:08 +00:00
rubenwardy
f6384e2e15 Merge minetest/bootstrap into master 2018-12-22 12:39:35 +00:00
rubenwardy
09a201759b Improve card and user profile formatting 2018-12-22 12:38:03 +00:00
rubenwardy
5dcff01436 Improve button colours and position in package view 2018-12-22 12:20:26 +00:00
rubenwardy
f355721cdb Fix button style in policy alert 2018-12-22 12:10:34 +00:00
rubenwardy
a25f77ce3c Allow pasting of forum URLs in input box 2018-12-22 12:08:21 +00:00
rubenwardy
692628653c Improve package creation form 2018-12-22 12:00:20 +00:00
rubenwardy
35f798c862 Improve button layouts 2018-12-21 20:59:12 +00:00
rubenwardy
3a0e0377f9 Improve button placement 2018-12-21 17:00:16 +00:00
rubenwardy
c6a26786ec Improve package page style again 2018-12-21 16:55:22 +00:00
rubenwardy
e5cb7a3721 Improve jumbotron 2018-12-21 16:36:54 +00:00
rubenwardy
03a155c17b Improve package page style further 2018-12-21 16:06:52 +00:00
rubenwardy
266d579e9d Move cards to sidebar 2018-12-21 16:00:18 +00:00
rubenwardy
c97eefc7b2 Format package page 2018-12-21 15:58:43 +00:00
rubenwardy
9da6b45cc3 Add bootstrap, change base template 2018-12-21 14:45:54 +00:00
67 changed files with 11346 additions and 1480 deletions

2
.gitignore vendored
View File

@@ -1,7 +1,7 @@
config.cfg
config.prod.cfg
*.sqlite
main.css
custom.css
tmp
log.txt
*.rdb

View File

@@ -17,9 +17,10 @@
from flask import *
from flask_user import *
from flask_gravatar import Gravatar
import flask_menu as menu
from flask_mail import Mail
from flask.ext import markdown
from flaskext.markdown import Markdown
from flask_github import GitHub
from flask_wtf.csrf import CsrfProtect
from flask_flatpages import FlatPages
@@ -31,11 +32,19 @@ app.config["FLATPAGES_EXTENSION"] = ".md"
app.config.from_pyfile(os.environ["FLASK_CONFIG"])
menu.Menu(app=app)
markdown.Markdown(app, extensions=["fenced_code"], safe_mode=True, output_format="html5")
Markdown(app, extensions=["fenced_code"], safe_mode=True, output_format="html5")
github = GitHub(app)
csrf = CsrfProtect(app)
mail = Mail(app)
pages = FlatPages(app)
gravatar = Gravatar(app,
size=58,
rating='g',
default='mp',
force_default=False,
force_lower=False,
use_ssl=True,
base_url=None)
if not app.debug:
from .maillogger import register_mail_error_handler

View File

@@ -1,7 +1,7 @@
title: WTFPL is a terrible license
no_h1: true
<div id="warning" class="box box_grey alert alert-warning">
<div id="warning" class="alert alert-warning">
<span class="icon_message"></span>
Please reconsider the choice of WTFPL as a license.

View File

@@ -1,6 +1,6 @@
title: Package Inclusion Policy and Guidance
<div class="box box_grey alert alert-warning">
<div class="alert alert-warning">
<b>Note:</b> This is a draft
</div>

View File

@@ -19,7 +19,7 @@ from flask import Flask, url_for
from flask_sqlalchemy import SQLAlchemy
from flask_migrate import Migrate
from urllib.parse import urlparse
from app import app
from app import app, gravatar
from datetime import datetime
from sqlalchemy.orm import validates
from flask_user import login_required, UserManager, UserMixin, SQLAlchemyAdapter
@@ -78,6 +78,8 @@ class Permission(enum.Enum):
EDIT_EDITREQUEST = "EDIT_EDITREQUEST"
SEE_THREAD = "SEE_THREAD"
CREATE_THREAD = "CREATE_THREAD"
UNAPPROVE_PACKAGE = "UNAPPROVE_PACKAGE"
TOPIC_DISCARD = "TOPIC_DISCARD"
# Only return true if the permission is valid for *all* contexts
# See Package.checkPerm for package-specific contexts
@@ -95,26 +97,27 @@ class Permission(enum.Enum):
raise Exception("Non-global permission checked globally. Use Package.checkPerm or User.checkPerm instead.")
class User(db.Model, UserMixin):
id = db.Column(db.Integer, primary_key=True)
id = db.Column(db.Integer, primary_key=True)
# User authentication information
username = db.Column(db.String(50, collation="NOCASE"), nullable=False, unique=True, index=True)
password = db.Column(db.String(255), nullable=True)
username = db.Column(db.String(50, collation="NOCASE"), nullable=False, unique=True, index=True)
password = db.Column(db.String(255), nullable=True)
reset_password_token = db.Column(db.String(100), nullable=False, server_default="")
rank = db.Column(db.Enum(UserRank))
rank = db.Column(db.Enum(UserRank))
# Account linking
github_username = db.Column(db.String(50, collation="NOCASE"), nullable=True, unique=True)
forums_username = db.Column(db.String(50, collation="NOCASE"), nullable=True, unique=True)
# User email information
email = db.Column(db.String(255), nullable=True, unique=True)
confirmed_at = db.Column(db.DateTime())
email = db.Column(db.String(255), nullable=True, unique=True)
confirmed_at = db.Column(db.DateTime())
# User information
active = db.Column("is_active", db.Boolean, nullable=False, server_default="0")
display_name = db.Column(db.String(100), nullable=False, server_default="")
profile_pic = db.Column(db.String(255), nullable=True, server_default=None)
active = db.Column("is_active", db.Boolean, nullable=False, server_default="0")
display_name = db.Column(db.String(100), nullable=False, server_default="")
# Content
notifications = db.relationship("Notification", primaryjoin="User.id==Notification.user_id")
@@ -144,6 +147,12 @@ class User(db.Model, UserMixin):
def isClaimed(self):
return self.rank.atLeast(UserRank.NEW_MEMBER)
def getProfilePicURL(self):
if self.profile_pic:
return self.profile_pic
else:
return gravatar(self.email or "")
def checkPerm(self, user, perm):
if not user.is_authenticated:
return False
@@ -388,7 +397,7 @@ class Package(db.Model):
setattr(self, e.name, getattr(package, e.name))
def getAsDictionaryShort(self, base_url):
tnurl = self.getThumbnailURL()
tnurl = self.getThumbnailURL(1)
return {
"name": self.name,
"title": self.title,
@@ -401,7 +410,7 @@ class Package(db.Model):
}
def getAsDictionary(self, base_url):
tnurl = self.getThumbnailURL()
tnurl = self.getThumbnailURL(1)
return {
"author": self.author.display_name,
"name": self.name,
@@ -429,9 +438,9 @@ class Package(db.Model):
"score": round(self.score * 10) / 10
}
def getThumbnailURL(self):
def getThumbnailURL(self, level=2):
screenshot = self.screenshots.filter_by(approved=True).first()
return screenshot.getThumbnailURL() if screenshot is not None else None
return screenshot.getThumbnailURL(level) if screenshot is not None else None
def getMainScreenshotURL(self):
screenshot = self.screenshots.filter_by(approved=True).first()
@@ -449,8 +458,8 @@ class Package(db.Model):
return url_for("approve_package_page",
author=self.author.username, name=self.name)
def getDeleteURL(self):
return url_for("delete_package_page",
def getRemoveURL(self):
return url_for("remove_package_page",
author=self.author.username, name=self.name)
def getNewScreenshotURL(self):
@@ -505,7 +514,8 @@ class Package(db.Model):
return user.rank.atLeast(UserRank.TRUSTED_MEMBER if isOwner else UserRank.EDITOR)
# Moderators can delete packages
elif perm == Permission.DELETE_PACKAGE or perm == Permission.CHANGE_RELEASE_URL:
elif perm == Permission.DELETE_PACKAGE or perm == Permission.UNAPPROVE_PACKAGE \
or perm == Permission.CHANGE_RELEASE_URL:
return user.rank.atLeast(UserRank.MODERATOR)
else:
@@ -644,8 +654,10 @@ class PackageScreenshot(db.Model):
name=self.package.name,
id=self.id)
def getThumbnailURL(self):
return self.url.replace("/uploads/", "/thumbnails/350x233/")
def getThumbnailURL(self, level=2):
return self.url.replace("/uploads/", ("/thumbnails/{:d}/").format(level))
class EditRequest(db.Model):
id = db.Column(db.Integer, primary_key=True)
@@ -802,6 +814,7 @@ class ForumTopic(db.Model):
author = db.relationship("User")
wip = db.Column(db.Boolean, server_default="0")
discarded = db.Column(db.Boolean, server_default="0")
type = db.Column(db.Enum(PackageType), nullable=False)
title = db.Column(db.String(200), nullable=False)
@@ -834,9 +847,25 @@ class ForumTopic(db.Model):
"posts": self.posts,
"views": self.views,
"is_wip": self.wip,
"discarded": self.discarded,
"created_at": self.created_at.isoformat(),
}
def checkPerm(self, user, perm):
if not user.is_authenticated:
return False
if type(perm) == str:
perm = Permission[perm]
elif type(perm) != Permission:
raise Exception("Unknown permission given to ForumTopic.checkPerm()")
if perm == Permission.TOPIC_DISCARD:
return self.author == user or user.rank.atLeast(UserRank.EDITOR)
else:
raise Exception("Permission {} is not related to topics".format(perm.name))
# Setup Flask-User
db_adapter = SQLAlchemyAdapter(db, User) # Register the User model

9681
app/public/static/bootstrap.css vendored Normal file

File diff suppressed because it is too large Load Diff

7
app/public/static/bootstrap.min.js vendored Normal file

File diff suppressed because one or more lines are too long

7
app/public/static/easymde.min.css vendored Normal file

File diff suppressed because one or more lines are too long

7
app/public/static/easymde.min.js vendored Normal file

File diff suppressed because one or more lines are too long

View File

@@ -20,41 +20,38 @@ $(function() {
$(".pkg_wiz_2").show()
$(".pkg_repo").hide()
function setSpecial(id, value) {
if (value != "") {
function setField(id, value) {
if (value && value != "") {
var ele = $(id);
ele.val(value);
ele.trigger("change")
ele.trigger("change");
}
}
performTask("/tasks/getmeta/new/?url=" + encodeURI(repoURL)).then(function(result) {
$("#name").val(result.name)
setSpecial("#provides_str", result.provides)
$("#title").val(result.title)
$("#repo").val(result.repo || repoURL)
$("#issueTracker").val(result.issueTracker)
$("#desc").val(result.description)
$("#shortDesc").val(result.short_description)
setSpecial("#harddep_str", result.depends)
setSpecial("#softdep_str", result.optional_depends)
$("#shortDesc").val(result.short_description)
if (result.forumId) {
$("#forums").val(result.forumId)
}
setField("#name", result.name);
setField("#provides_str", result.provides);
setField("#title", result.title);
setField("#repo", result.repo || repoURL);
setField("#issueTracker", result.issueTracker);
setField("#desc", result.description);
setField("#shortDesc", result.short_description);
setField("#harddep_str", result.depends);
setField("#softdep_str", result.optional_depends);
setField("#shortDesc", result.short_description);
setField("#forums", result.forumId);
if (result.type && result.type.length > 2) {
$("#type").val(result.type)
$("#type").val(result.type);
}
finish()
finish();
}).catch(function(e) {
alert(e)
$(".pkg_wiz_1").show()
$(".pkg_wiz_2").hide()
$(".pkg_repo").show()
alert(e);
$(".pkg_wiz_1").show();
$(".pkg_wiz_2").hide();
$(".pkg_repo").show();
// finish()
})
});
} else {
finish()
}

View File

@@ -8,4 +8,57 @@ $(function() {
})
$(".not_mod, .not_game, .not_txp").show()
$(".not_" + $("#type").val().toLowerCase()).hide()
$("#forums").on('paste', function(e) {
try {
var pasteData = e.originalEvent.clipboardData.getData('text')
var url = new URL(pasteData);
if (url.hostname == "forum.minetest.net") {
$(this).val(url.searchParams.get("t"));
e.preventDefault();
}
} catch (e) {
console.log("Not a URL");
}
});
let hint = null;
function showHint(ele, text) {
if (hint) {
hint.remove();
}
hint = ele.parent()
.append(`<div class="alert alert-warning my-3">${text}</div>`)
.find(".alert");
}
let hint_mtmods = `Tip:
Don't include <i>Minetest</i>, <i>mod</i>, or <i>modpack</i> anywhere in the short description.
It is unnecessary and wastes characters.`;
let hint_thegame = `Tip:
It's obvious that this adds something to Minetest,
there's no need to use phrases such as \"adds X to the game\".`
$("#shortDesc").on("change paste keyup", function() {
var val = $(this).val().toLowerCase();
if (val.indexOf("minetest") >= 0 || val.indexOf("mod") >= 0 ||
val.indexOf("modpack") >= 0 || val.indexOf("mod pack") >= 0) {
showHint($(this), hint_mtmods);
} else if (val.indexOf("the game") >= 0) {
showHint($(this), hint_thegame);
} else if (hint) {
hint.remove();
hint = null;
}
})
var btn = $("#forums").parent().find("label").append("<a class='ml-3 btn btn-sm btn-primary'>Open</a>");
btn.click(function() {
var id = $("#forums").val();
if (/^\d+$/.test(id)) {
window.open("https://forum.minetest.net/viewtopic.php?t=" + id, "_blank");
}
});
})

5
app/public/static/popper.min.js vendored Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -5,13 +5,25 @@
* https://petprojects.googlecode.com/svn/trunk/GPL-LICENSE.txt
*/
(function($) {
function hide_error(input) {
var err = input.parent().parent().find(".invalid-remaining");
err.hide();
}
function show_error(input, msg) {
var err = input.parent().parent().find(".invalid-remaining");
console.log(err.length);
err.text(msg);
err.show();
}
$.fn.selectSelector = function(source, name, select) {
return this.each(function() {
var selector = $(this),
input = $('input[type=text]', this);
selector.click(function() { input.focus(); })
.delegate('.tag a', 'click', function() {
.delegate('.badge a', 'click', function() {
var id = $(this).parent().data("id");
for (var i = 0; i < source.length; i++) {
if (source[i].id == id) {
@@ -23,13 +35,14 @@
});
function addTag(item) {
var tag = $('<span class="tag"/>')
var tag = $('<span class="badge badge-pill badge-primary"/>')
.text(item.toString() + ' ')
.data("id", item.id)
.append('<a>x</a>')
.insertBefore(input);
input.attr("placeholder", null);
select.find("option[value=" + item.id + "]").attr("selected", "selected")
hide_error(input);
}
function recreate() {
@@ -42,6 +55,13 @@
}
recreate();
input.focusout(function(e) {
var value = input.val().trim()
if (value != "") {
show_error(input, "Please select an existing tag, it;s not possible to add custom ones.");
}
})
input.keydown(function(e) {
if (e.keyCode === $.ui.keyCode.TAB && $(this).data('ui-autocomplete').menu.active)
e.preventDefault();
@@ -92,7 +112,7 @@
}
selector.click(function() { input.focus(); })
.delegate('.tag a', 'click', function() {
.delegate('.badge a', 'click', function() {
var id = $(this).parent().data("id");
for (var i = 0; i < selected.length; i++) {
if (selected[i] == id) {
@@ -113,13 +133,14 @@
}
function addTag(id, value) {
var tag = $('<span class="tag"/>')
var tag = $('<span class="badge badge-pill badge-primary"/>')
.text(value)
.data("id", id)
.append(' <a>x</a>')
.insertBefore(input);
input.attr("placeholder", null);
hide_error(input);
}
function recreate() {
@@ -147,6 +168,18 @@
result.change(readFromResult);
input.focusout(function() {
var item = input.val();
if (item.length == 0) {
input.data("ui-autocomplete").search("");
} else if (item.match(/^([a-z0-9_]+)$/)) {
selectItem(item);
recreate();
input.val("");
}
return true;
});
input.keydown(function(e) {
if (e.keyCode === $.ui.keyCode.TAB && $(this).data('ui-autocomplete').menu.active)
e.preventDefault();
@@ -159,7 +192,7 @@
recreate();
input.val("");
} else {
alert("Only lowercase alphanumeric and number names allowed.");
show_error(input, "Only lowercase alphanumeric and number names allowed.");
}
e.preventDefault();
return true;

View File

@@ -0,0 +1,29 @@
$(".topic-discard").click(function() {
var ele = $(this);
var tid = ele.attr("data-tid");
var discard = !ele.parent().parent().hasClass("discardtopic");
fetch(new Request("/api/topic_discard/?tid=" + tid +
"&discard=" + (discard ? "true" : "false"), {
method: "post",
credentials: "same-origin",
headers: {
"Accept": "application/json",
"X-CSRFToken": csrf_token,
},
})).then(function(response) {
response.text().then(function(txt) {
console.log(JSON.parse(txt));
if (JSON.parse(txt).discarded) {
ele.parent().parent().addClass("discardtopic");
ele.removeClass("btn-danger");
ele.addClass("btn-success");
ele.text("Show");
} else {
ele.parent().parent().removeClass("discardtopic");
ele.removeClass("btn-success");
ele.addClass("btn-danger");
ele.text("Discard");
}
}).catch(console.log)
}).catch(console.log)
});

View File

@@ -1,49 +1,29 @@
.comments, .comments li {
list-style: none;
padding: 0;
margin: 0;
border: 1px solid #444;
.img-thumbnail-1 {
padding: 0px;
// width: 100%;
background: white;
}
.comments {
border-radius: 5px;
margin: 15px 0;
background: #333;
list-style: none;
padding: 0;
.info_strip, .msg {
display: block;
margin: 0;
}
.card {
position:relative;
.info_strip {
padding: 0.2em 1em;
border-bottom: 1px solid #444;
}
.msg {
padding: 1em;
background: #222;
}
.author {
font-weight: bold;
float: left;
display: inline-block;
}
.info_strip span {
float: right;
display: inline-block;
color: #bbb;
.card-header:before {
position: absolute;
top: 11px;
right: 100%;
width: 0;
height: 0;
display: block;
content:" ";
border-color: transparent;
border-style: solid solid outset;
pointer-events:none;
border-right-color: #444;
border-width: 14px;
}
}
}
.comment_form {
margin: 1em 0;
}
.comment_form textarea {
min-width: 60%;
max-width: 100%;
margin: 0 0 1em 0;
}

View File

@@ -1,112 +1,3 @@
h1 {
margin: 0;
}
h2, h3 {
margin: 5px 0;
}
a {
color: #0be;
font-weight: bold;
text-decoration: none;
}
a:hover {
color: #0df;
text-decoration: underline;
}
/* Containers */
.box {
border-radius: 5px;
margin: 15px 0;
padding: 0;
}
.box > h2, .box > h3 {
margin: 0;
padding: 0.5em 0.5em 0.5em 15px;
border-bottom: 1px solid #444;
}
.box .box-body {
padding: 1em !important;
}
// .box form {
// padding: 1em;
// }
.box_grey {
background: #333;
border: 1px solid #444;
}
.ul_boxes {
display: block;
margin: 0;
padding: 0;
list-style: none;
}
.ul_boxes > li {
padding: 0;
list-style: none;
}
.box_link {
display: block;
color: #ddd;
text-decoration: none;
}
.box_link:hover{
background: #3a3a3a;
}
/*
buttonset
*/
.buttonset, .buttonset li {
display: block;
margin: 0;
padding: 0;
list-style: none;
}
.buttonset {
margin: 15px 0;
}
.button, .buttonset li a, input[type=submit] {
cursor: pointer;
}
.button, .buttonset li a, input[type=submit], input[type=text],
input[type=password], textarea, select, .bulletselector {
text-align: center;
display: inline-block;
padding: 0.4em 1em;
background: rgba(255,255,255,0.07);
border: 1px solid rgba(255,255,255,0.1);
color: #ddd;
border-radius: 5px;
text-decoration: none;
font-size: 100%;
}
select > * {
color: #222;
}
input[type=text], input[type=password], textarea, select, .bulletselector {
text-align: left;
}
.ui-autocomplete, ui-front {
position:absolute;
cursor:default;
@@ -133,74 +24,11 @@ input[type=text], input[type=password], textarea, select, .bulletselector {
}
}
select {
min-width: 200px;
.bulletselector {
height: auto !important;
display: inline-block !important;
}
select:not([multiple]) {
background: linear-gradient(#444, #333);
}
.form-group {
padding: 8px 0;
}
.form-group label {
display: block;
vertical-align: top;
padding: 0 8px 8px 0;
}
.form-group input, .form-group textarea, .form-group .bulletselector {
display: block;
min-width: 100%;
max-width: 100%;
}
.box .form-group input, .box .form-group textarea, .form-group .bulletselector {
min-width: 95%;
max-width: 95%;
}
.form-group textarea {
min-height: 200px;
}
.button:hover, .buttonset li a:hover, input[type=submit]:hover {
background: rgba(255,255,255,0.13);
border: 1px solid rgba(255,255,255,0.17);
text-decoration: none;
color: #ddd;
}
.btn_green {
background: #363 !important;
border: 1px solid #473;
}
.btn_green:hover {
background: #474 !important;
}
.linedbuttonset a {
border: 1px solid #eee;
border-radius: 3px;
padding: 4px 10px;
margin: 0;
display: block;
}
.linedbuttonset {
display: block;
margin: 0;
}
.linedbuttonset li {
display: inline-block;
margin: 10px 10px 0 0;
}
.bulletselector input {
border: none;
border-radius: 0;
@@ -215,166 +43,14 @@ select:not([multiple]) {
white-space: nowrap;
background: transparent;
}
.bulletselector .tag {
background: #375D81;
border-radius: 3px;
-moz-border-radius: 3px;
color: #FFF;
.bulletselector .badge {
float: left;
height: 15px;
padding: 0.1em 0.4em 0.5em;
padding: 0.4em 0.8em;
margin-right: 0.3em;
margin-bottom: 0.3em;
vertical-align: baseline;
}
.bulletselector .tag a {
color: #FFF;
cursor: pointer;
}
.bulletselector .tag a:hover {
color: #0099CC;
text-decoration: none;
}
/* Alerts */
.alert .alert_right, .alert > form {
display: inline-block;
margin: 0;
position: absolute;
top: 0;
right: 0;
bottom: 0;
}
.alert {
padding: 10px;
position: relative;
.alert_right:not(.button) {
padding: 0;
}
.alert_right form {
height: 100%;
}
form {
display: inline-block;
margin: 0;
padding: 0;
}
input {
height: 100%;
}
input, .button {
margin: 0;
background: 0;
border: 0;
border-left: 1px solid rgba(255,255,255,0.12);
border-radius: 0;
vertical-align: middle;
}
input:hover, .button:hover {
border: 0;
border-left: 1px solid rgba(255,255,255,0.2);
}
}
#alerts {
list-style: none;
position: fixed;
bottom: 15px;
left: 0;
right: 0;
z-index: 1000;
}
#alerts .alert {
margin: 5px 0;
vertical-align: middle;
}
#alerts .close {
float: right;
color: white;
}
#alerts .close:hover {
color: #fff;
}
.alert-error, .button-danger {
background: #933 !important;
border: 1px solid #c44 !important;
}
.alert-warning {
background: #963;
border: 1px solid #c96;
}
.alert-primary {
background: #339;
border: 1px solid #66a;
}
.alert-success {
background: #161;
border: 1px solid #393;
}
table.fancyTable {
font-family: "Arial Black", Gadget, sans-serif;
border: 2px solid #000000;
background-color: #4A4A4A;
width: 100%;
text-align: center;
border-collapse: collapse;
}
table.fancyTable td, table.fancyTable th {
border: 1px solid #4A4A4A;
padding: 3px 2px;
}
table.fancyTable tbody td {
font-size: 13px;
color: #E6E6E6;
}
table.fancyTable tr:nth-child(even) {
background: #888888;
}
table.fancyTable thead {
background: #000000;
border-bottom: 3px solid #000000;
}
table.fancyTable thead th {
font-size: 15px;
font-weight: bold;
color: #E6E6E6;
text-align: center;
border-left: 2px solid #4A4A4A;
}
table.fancyTable thead th:first-child {
border-left: none;
}
table.fancyTable tfoot {
font-size: 12px;
font-weight: bold;
color: #E6E6E6;
background: #000000;
background: -moz-linear-gradient(top, #404040 0%, #191919 66%, #000000 100%);
background: -webkit-linear-gradient(top, #404040 0%, #191919 66%, #000000 100%);
background: linear-gradient(to bottom, #404040 0%, #191919 66%, #000000 100%);
border-top: 1px solid #4A4A4A;
}
table.fancyTable tfoot td {
font-size: 12px;
.invalid-remaining {
display: none;
}
.t-mll tr td:not(:first-child) {
@@ -405,69 +81,44 @@ table.fancyTable tfoot td {
color: #2c2;
}
/*
Aside
*/
.asideright {
float: right;
margin: 0 0 0 15px;
max-width: 300px;
}
.outsidecontainer {
position: absolute;
right: 102%;
top: 0;
width: intrinsic; /* Safari/WebKit uses a non-standard name */
width: -moz-max-content; /* Firefox/Gecko */
width: -webkit-max-content; /* Chrome */
}
@media (max-width: 1490px) {
.outsidecontainer {
display: none;
}
}
.flatlist, .flatlist li {
list-style: none;
padding: 0;
margin: 0;
}
.flatlist li {
display: block;
}
.flatlist a {
display: block;
padding: 0.5em 20px;
color: #ddd;
font-weight: normal;
}
.flatlist a:hover {
background: #444;
text-decoration: none;
}
.table-topalign td {
vertical-align: top;
}
.wiptopic a {
.wiptopic a:not(.btn) {
color: #7ac;
}
.editor-toolbar {
background-color: #333 !important;
.discardtopic {
text-decoration: line-through;
a:not(.btn) {
color: #7ac;
}
filter: brightness(0.5);
}
.CodeMirror {
background-color: #222 !important;
.editor-toolbar, .editor-toolbar.fullscreen {
margin-bottom: 0 !important;
background-color: #444 !important;
border: none !important;
border-radius: calc(0.25rem - 1px) calc(0.25rem - 1px) 0 0 !important;
border-bottom: 1px solid rgba(0, 0, 0, 0.125) !important;
}
.editor-preview-side {
background-color: #222 !important;
.editor-toolbar button {
color: white;
}
.editor-toolbar button.active, .editor-toolbar button:hover {
background: #375a7f !important;
color: white !important;
}
.editor-toolbar.fullscreen::before, .editor-toolbar.fullscreen::after {
display: none !important;
}
// .CodeMirror {
// background-color: #222 !important;
// }
.editor-preview-side, .editor-preview {
background-color: #222 !important;
color: white !important;
}

57
app/scss/custom.scss Normal file
View File

@@ -0,0 +1,57 @@
@import "components.scss";
@import "packages.scss";
@import "packagegrid.scss";
@import "comments.scss";
.dropdown-menu {
margin-top: 0;
}
.dropdown:hover .dropdown-menu {
display: block;
}
.nav-link > img {
max-height: 1em;
}
#alerts {
display: block;
list-style: none;
position: fixed;
bottom: 0;
left:0;
right:0;
margin: 0;
padding:0;
z-index: 1000;
}
#alerts li {
list-style: none;
}
.jumbotron {
background-size: cover;
background-repeat: no-repeat;
background-position: center;
}
.alert .btn {
text-decoration: none;
}
.card .table {
margin-bottom: 0;
}
.btn-download {
color: #fff;
background-color: #00b05c;
border-color: #00b05c;
}
.btn-download:focus, .btn-download.focus {
-webkit-box-shadow: 0 0 0 0.2rem rgba(231, 76, 60, 0.5);
box-shadow: 0 0 0 0.2rem rgba(231, 76, 60, 0.5);
}

View File

@@ -1,6 +0,0 @@
@import "page.scss";
@import "components.scss";
@import "nav.scss";
@import "packages.scss";
@import "packagegrid.scss";
@import "comments.scss";

View File

@@ -1,90 +0,0 @@
nav {
margin: 0 auto 0 auto;
list-style: none;
background: #333;
}
nav .navbar-left {
float: left;
}
nav .navbar-left li {
float: left;
}
nav .navbar-right {
float: right;
}
nav ul {
margin: 0 auto 0 auto;
padding: 0;
list-style: none;
}
nav li {
margin: 0;
padding: 0;
list-style: none;
display: inline-block;
}
nav li a {
color: #ddd;
margin: 0;
padding: 1em 1em;
display: block;
border-left: 1px solid #444;
}
nav li a:not([href]) {
cursor: default;
}
nav ul li:last-child a {
border-right: 1px solid #444;
}
nav a:hover {
color: #eee;
background: #444;
text-decoration: none;
}
nav img {
height: 1em;
}
li.dropdown {
position: relative;
display: inline-block;
}
.dropdown-menu {
display: none;
position: absolute;
margin: 0;
padding: 0;
min-width:160px;
background: #333;
z-index: 1;
right: 0;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.4);
}
.dropdown:hover ul {
display: block;
}
.dropdown li {
display: block;
}
.dropdown li a {
border: none;
border-top: 1px solid #444;
}
.dropdown li:last-child a {
border-bottom: 1px solid #444;
}

View File

@@ -1,27 +1,20 @@
.packagegrid {
display: flex;
flex-wrap: wrap;
flex-direction: row;
flex-grow: 1;
flex-shrink: 1;
.packagetile {
list-style: none;
padding: 0;
margin: 0 -7px;
margin: 0 7px 7px 0;
min-width: 250px;
}
.packagegrid li {
flex: 1;
display: block;
min-width: 300px;
min-height: 200px;
max-width: 332px;
li.d-flex {
list-style: none;
padding: 0;
margin: 7px;
margin: 0;
}
.packagegrid a {
.packagetile a {
display: block;
padding-bottom: 66.66%;
border-radius: 7px;
border-radius: 3px;
position: relative;
overflow: hidden;
background-size: cover;
@@ -29,10 +22,6 @@
background-position: center;
}
.packagegrid a:hover {
// box-shadow: 0px 0px 16px 6px rgba(0,0,0,0.4);
}
.packagegridscrub {
position: absolute;
top: 50%;
@@ -53,6 +42,14 @@
.packagegridinfo h3 {
color: white;
font-size: 120%;
font-weight: bold;
}
.packagegridinfo small {
color: #ddd;
font-size: 75%;
font-weight: bold;
}
.packagegridinfo p {
@@ -61,15 +58,15 @@
font-weight: normal;
}
.packagegrid a:hover .packagegridinfo {
.packagetile a:hover .packagegridinfo {
top: 0;
}
.packagegrid a:hover p {
.packagetile a:hover p {
display: block;
}
.packagegrid a:hover .packagegridscrub {
.packagetile a:hover .packagegridscrub {
top: 0;
background: rgba(0,0,0,0.8);
}

View File

@@ -37,34 +37,6 @@
left: 15px;
}
.sidebar_container {
display: block;
position: relative;
padding: 0;
margin: 0;
}
.sidebar_container .right, .sidebar_container .left{
position: absolute;
display: block;
top: 10px;
margin-top: 0;
}
.sidebar_container .right {
right: 0;
width: 280px;
}
.sidebar_container .left {
right: 295px;
left: 0;
}
.sidebar_container .right > *:first-child, .sidebar_container .left > *:first-child {
margin-top: 0;
}
.package-short-large {
font-size: 120%;
}

View File

@@ -1,56 +0,0 @@
html, body {
font-family: "Arial", sans-serif;
background: #222;
color: #ddd;
padding: 0;
margin: 0;
}
.container, main, #alerts, footer {
width: 90%;
max-width: 1024px;
margin: auto;
padding: 0;
display: block;
}
main {
padding: 7px 0;
position: relative;
box-sizing: border-box;
}
.clearboth {
clear: both;
}
header h1, header p, header form {
padding: 0 5px;
margin-left: 0;
}
header {
padding: 30px;
background: #258;
}
header p {
max-width: 400px;
}
header input {
margin: 3px;
}
footer {
color: #999;
padding: 30px 0;
}
footer a {
color: #aaa;
}
footer a:hover {
color: #bbb;
}

View File

@@ -16,7 +16,7 @@
import flask
from flask.ext.sqlalchemy import SQLAlchemy
from flask_sqlalchemy import SQLAlchemy
from celery import Celery
from celery.schedules import crontab
from app import app

View File

@@ -22,6 +22,7 @@ from app.tasks import celery
@celery.task()
def sendVerifyEmail(newEmail, token):
print("Sending verify email!")
msg = Message("Verify email address", recipients=[newEmail])
msg.body = "This is a verification email!"
msg.html = render_template("emails/verify.html", token=token)

View File

@@ -16,7 +16,7 @@
import flask, json, re
from flask.ext.sqlalchemy import SQLAlchemy
from flask_sqlalchemy import SQLAlchemy
from app import app
from app.models import *
from app.tasks import celery
@@ -25,7 +25,8 @@ import urllib.request
from urllib.parse import urlparse, quote_plus
@celery.task()
def checkForumAccount(username, token=None):
def checkForumAccount(username, forceNoSave=False):
print("Checking " + username)
try:
profile = getProfile("https://forum.minetest.net", username)
except OSError:
@@ -47,10 +48,34 @@ def checkForumAccount(username, token=None):
user.github_username = github_username
needsSaving = True
pic = profile.avatar
if pic and "http" in pic:
pic = None
needsSaving = needsSaving or pic != user.profile_pic
if pic:
user.profile_pic = "https://forum.minetest.net/" + pic
else:
user.profile_pic = None
# Save
if needsSaving:
if needsSaving and not forceNoSave:
db.session.commit()
return needsSaving
@celery.task()
def checkAllForumAccounts(forceNoSave=False):
needsSaving = False
query = User.query.filter(User.forums_username.isnot(None))
for user in query.all():
needsSaving = checkForumAccount(user.username) or needsSaving
if needsSaving and not forceNoSave:
db.session.commit()
return needsSaving
regex_tag = re.compile(r"\[([a-z0-9_]+)\]")
BANNED_NAMES = ["mod", "game", "old", "outdated", "wip", "api", "beta", "alpha", "git"]

View File

@@ -17,7 +17,7 @@
import flask, json, os, git, tempfile, shutil
from git import GitCommandError
from flask.ext.sqlalchemy import SQLAlchemy
from flask_sqlalchemy import SQLAlchemy
from urllib.error import HTTPError
import urllib.request
from urllib.parse import urlparse, quote_plus, urlsplit

View File

@@ -15,8 +15,9 @@ def urlEncodeNonAscii(b):
class Profile:
def __init__(self, username):
self.username = username
self.signature = ""
self.username = username
self.signature = ""
self.avatar = None
self.properties = {}
def set(self, key, value):
@@ -33,6 +34,11 @@ def __extract_properties(profile, soup):
if el is None:
return None
res1 = el.find_all("dl")
imgs = res1[0].find_all("img")
if len(imgs) == 1:
profile.avatar = imgs[0]["src"]
res = el.find_all("dl", class_ = "left-box details")
if len(res) != 1:
return None

View File

@@ -12,15 +12,16 @@
<li><a href="{{ url_for('switch_user_page') }}">Sign in as another user</a></li>
</ul>
<div class="box box_grey">
<h2>Do action</h2>
<div class="card my-4">
<h2 class="card-header">Do action</h2>
<form method="post" action="" class="box-body">
<form method="post" action="" class="card-body">
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}" />
<select name="action">
<option value="importmodlist" selected>Import forum topics</option>
<option value="recalcscores">Recalculate package scores</option>
<!-- <option value="importscreenshots">Import screenshots from VCS</option> -->
<option value="checkusers">Check forum users</option>
<option value="importscreenshots">Import screenshots from VCS</option>
<!-- <option value="importdepends">Import dependencies from downloads</option> -->
<!-- <option value="modprovides">Set provides to mod name</option> -->
<!-- <option value="vcsrelease">Create VCS releases</option> -->
@@ -29,10 +30,10 @@
</form>
</div>
<div class="box box_grey">
<h2>Restore Package</h2>
<div class="card my-4">
<h2 class="card-header">Restore Package</h2>
<form method="post" action="" class="box-body">
<form method="post" action="" class="card-body">
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}" />
<input type="hidden" name="action" value="restore" />
<select name="package">

View File

@@ -6,75 +6,96 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>{% block title %}title{% endblock %} - {{ config.USER_APP_NAME }}</title>
<link rel="stylesheet" type="text/css" href="/static/main.css">
<link rel="stylesheet" type="text/css" href="/static/bootstrap.css">
<link rel="stylesheet" type="text/css" href="/static/custom.css?v=6">
{% block headextra %}{% endblock %}
</head>
<body>
<nav>
<nav class="navbar navbar-expand-lg navbar-dark bg-primary">
<div class="container">
<ul class="nav navbar-nav navbar-left">
<li><a href="/">{{ config.USER_APP_NAME }}</a></li>
{% for item in current_menu.children recursive %}
{% if item.visible %}
<li{% if item.children %} class="dropdown"{% endif %}>
<a href="{{ item.url }}"
{% if item.children %}
class="dropdown-toggle"
data-toggle="dropdown"
role="button"
aria-expanded="false"
{% endif %}>
{{ item.text }}
{% if item.children %}
<span class="caret"></span>
{% endif %}
</a>
{% if item.children %}
<ul class="dropdown-menu" role="menu">
{{ loop(item.children) }}
</ul>
{% endif %}
</li>
{% endif %}
{% endfor %}
</ul>
<ul class="nav navbar-nav navbar-right">
{% if current_user.is_authenticated %}
<li><a href="{{ url_for('notifications_page') }}">
<img src="/static/notification{% if current_user.notifications %}_alert{% endif %}.svg" />
</a></li>
<li><a href="{{ url_for('create_edit_package_page') }}">+</a></li>
<li class="dropdown">
<a class="dropdown-toggle"
data-toggle="dropdown"
role="button"
aria-expanded="false">{{ current_user.display_name }}
<span class="caret"></span></a>
<a class="navbar-brand" href="/">{{ config.USER_APP_NAME }}</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarColor01" aria-controls="navbarColor01" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<ul class="dropdown-menu" role="menu">
<li>
<a href="{{ url_for('user_profile_page', username=current_user.username) }}">Profile</a>
<div class="collapse navbar-collapse" id="navbarColor01">
<ul class="navbar-nav mr-auto">
{% for item in current_menu.children recursive %}
{% if item.visible %}
<li class="nav-item {% if item.children %} dropdown{% endif %}">
<a class="nav-link" href="{{ item.url }}"
{% if item.children %}
class="dropdown-toggle"
data-toggle="dropdown"
role="button"
aria-expanded="false"
{% endif %}>
{{ item.text }}
{% if item.children %}
<span class="caret"></span>
{% endif %}
</a>
{% if item.children %}
<ul class="dropdown-menu" role="menu">
{{ loop(item.children) }}
</ul>
{% endif %}
</li>
{% if current_user.canAccessTodoList() %}
<li><a href="{{ url_for('todo_page') }}">Work Queue</a></li>
<li><a href="{{ url_for('user_list_page') }}">User list</a></li>
{% endif %}
{% if current_user.rank == current_user.rank.ADMIN %}
<li><a href="{{ url_for('admin_page') }}">Admin</a></li>
{% endif %}
{% if current_user.rank == current_user.rank.MODERATOR %}
<li><a href="{{ url_for('tag_list_page') }}">Tag Editor</a></li>
<li><a href="{{ url_for('license_list_page') }}">License Editor</a></li>
{% endif %}
<li><a href="{{ url_for('user.logout') }}">Sign out</a></li>
</ul>
</li>
{% else %}
<li><a href="{{ url_for('user.login') }}">Sign in</a></li>
{% endif %}
</ul>
<div class="clearboth"></div>
{% endif %}
{% endfor %}
</ul>
<form class="form-inline my-2 my-lg-0" method="GET" action="/packages/">
{% if type %}<input type="hidden" name="type" value="{{ type }}" />{% endif %}
<input class="form-control mr-sm-2" name="q" type="text" placeholder="Search {{ title | lower or 'all packages' }}" value="{{ query or ''}}">
<input class="btn btn-secondary my-2 my-sm-0 mr-sm-2" type="submit" value="Search" />
<!-- <input class="btn btn-secondary my-2 my-sm-0"
data-toggle="tooltip" data-placement="bottom"
title="Go to the first found result for this query."
type="submit" name="lucky" value="First" /> -->
</form>
<ul class="navbar-nav ml-auto">
{% if current_user.is_authenticated %}
<li class="nav-item"><a class="nav-link" href="{{ url_for('notifications_page') }}">
<img src="/static/notification{% if current_user.notifications %}_alert{% endif %}.svg" />
</a></li>
<li class="nav-item"><a class="nav-link" href="{{ url_for('create_edit_package_page') }}">+</a></li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle"
data-toggle="dropdown"
role="button"
aria-expanded="false">{{ current_user.display_name }}
<span class="caret"></span></a>
<ul class="dropdown-menu" role="menu">
<li class="nav-item">
<a class="nav-link" href="{{ url_for('user_profile_page', username=current_user.username) }}">Profile</a>
</li>
<li class="nav-item">
<a class="nav-link" href="{{ url_for('user_profile_page', username=current_user.username) }}#unadded-topics">Your unadded topics</a>
</li>
{% if current_user.canAccessTodoList() %}
<li class="nav-item"><a class="nav-link" href="{{ url_for('todo_page') }}">Work Queue</a></li>
<li class="nav-item"><a class="nav-link" href="{{ url_for('user_list_page') }}">User list</a></li>
{% endif %}
<li class="nav-item">
<a class="nav-link" href="{{ url_for('todo_topics_page') }}">All unadded topics</a>
</li>
{% if current_user.rank == current_user.rank.ADMIN %}
<li class="nav-item"><a class="nav-link" href="{{ url_for('admin_page') }}">Admin</a></li>
{% endif %}
{% if current_user.rank == current_user.rank.MODERATOR %}
<li class="nav-item"><a class="nav-link" href="{{ url_for('tag_list_page') }}">Tag Editor</a></li>
<li class="nav-item"><a class="nav-link" href="{{ url_for('license_list_page') }}">License Editor</a></li>
{% endif %}
<li class="nav-item"><a class="nav-link" href="{{ url_for('user.logout') }}">Sign out</a></li>
</ul>
</li>
{% else %}
<li><a class="nav-link" href="{{ url_for('user.login') }}">Sign in</a></li>
{% endif %}
</ul>
</div>
</div>
</nav>
@@ -83,7 +104,7 @@
{% if messages %}
<ul id="alerts">
{% for category, message in messages %}
<li class="box box_grey alert alert-{{category}}">
<li class="alert alert-{{category}} container">
<span class="icon_message"></span>
{{ message|safe }}
@@ -97,16 +118,29 @@
{% endblock %}
{% block container %}
<main>
<main class="container mt-4">
{% block content %}
{% endblock %}
</main>
{% endblock %}
<footer>
<footer class="container footer-copyright my-5 page-footer font-small text-center">
ContentDB &copy; 2018 to <a href="https://rubenwardy.com/">rubenwardy</a> |
<a href="https://github.com/minetest/contentdb">GitHub</a> |
<a href="{{ url_for('flatpage', path='help') }}">Help</a> |
<a href="{{ url_for('flatpage', path='help/reporting') }}">Report / DMCA</a>
</footer>
<script src="/static/jquery.min.js"></script>
<script src="/static/popper.min.js"></script>
<script src="/static/bootstrap.min.js"></script>
<script src="/static/easymde.min.js"></script>
<link rel="stylesheet" type="text/css" href="/static/easymde.min.css">
<script>
$("textarea.markdown").each(function() {
new EasyMDE({ element: this, hideIcons: ["image"] });
})
</script>
{% block scriptextra %}{% endblock %}
</body>
</html>

View File

@@ -5,76 +5,76 @@ Sign in
{% endblock %}
{% block content %}
<div class="sidebar_container">
<div class="left box box_grey">
{% from "flask_user/_macros.html" import render_field, render_checkbox_field, render_submit_field %}
<h2>{%trans%}Sign in{%endtrans%}</h2>
<div class="row">
<div class="col-sm-8">
<div class="card">
{% from "flask_user/_macros.html" import render_field, render_checkbox_field, render_submit_field %}
<h2 class="card-header">{%trans%}Sign in{%endtrans%}</h2>
<form action="" method="POST" class="form box-body" role="form">
<h3>Sign in with username/password</h3>
{{ form.hidden_tag() }}
<form action="" method="POST" class="form card-body" role="form">
{{ form.hidden_tag() }}
{# Username or Email field #}
{% set field = form.username if user_manager.enable_username else form.email %}
<div class="form-group {% if field.errors %}has-error{% endif %}">
{# Label on left, "New here? Register." on right #}
<div class="row">
<div class="col-xs-6">
<label for="{{ field.id }}" class="control-label">{{ field.label.text }}</label>
</div>
{# Username or Email field #}
{% set field = form.username if user_manager.enable_username else form.email %}
<div class="form-group {% if field.errors %}has-error{% endif %}">
{# Label on left, "New here? Register." on right #}
<label for="{{ field.id }}" class="control-label">{{ field.label.text }}</label>
{{ field(class_='form-control', tabindex=110) }}
{% if field.errors %}
{% for e in field.errors %}
<p class="help-block">{{ e }}</p>
{% endfor %}
{% endif %}
</div>
{{ field(class_='form-control', tabindex=110) }}
{% if field.errors %}
{% for e in field.errors %}
<p class="help-block">{{ e }}</p>
{% endfor %}
{% endif %}
</div>
{# Password field #}
{% set field = form.password %}
<div class="form-group {% if field.errors %}has-error{% endif %}">
<div class="row">
{# Password field #}
{% set field = form.password %}
<div class="form-group {% if field.errors %}has-error{% endif %}">
<label for="{{ field.id }}" class="control-label">{{ field.label.text }}
{% if user_manager.enable_forgot_password %}
<a href="{{ url_for('user.forgot_password') }}" tabindex='195'>
[{%trans%}Forgot My Password{%endtrans%}]</a>
{% endif %}
</label>
{{ field(class_='form-control', tabindex=120) }}
{% if field.errors %}
{% for e in field.errors %}
<p class="help-block">{{ e }}</p>
{% endfor %}
{% endif %}
</div>
{{ field(class_='form-control', tabindex=120) }}
{% if field.errors %}
{% for e in field.errors %}
<p class="help-block">{{ e }}</p>
{% endfor %}
{# Remember me #}
{% if user_manager.enable_remember_me %}
{{ render_checkbox_field(login_form.remember_me, tabindex=130) }}
{% endif %}
{# Submit button #}
<p>
{{ render_submit_field(form.submit, tabindex=180) }}
</p>
</form>
</div>
<div class="card mt-4">
{% from "flask_user/_macros.html" import render_field, render_checkbox_field, render_submit_field %}
<h2 class="card-header">{%trans%}Sign in with Github{%endtrans%}</h2>
<div class="card-body">
<a class="btn btn-primary" href="{{ url_for('github_signin_page') }}">GitHub</a>
</div>
{# Remember me #}
{% if user_manager.enable_remember_me %}
{{ render_checkbox_field(login_form.remember_me, tabindex=130) }}
{% endif %}
{# Submit button #}
<p>
{{ render_submit_field(form.submit, tabindex=180) }}
</p>
<h3>Sign in with Github</h3>
<p><a class="button" href="{{ url_for('github_signin_page') }}">GitHub</a></p>
</form>
</div>
</div>
<div class="right">
<aside class="box box_grey">
<h2>New here?</h2>
<div class="box-body">
<aside class="col-sm-4">
<div class="card">
{% from "flask_user/_macros.html" import render_field, render_checkbox_field, render_submit_field %}
<h2 class="card-header">{%trans%}New here?{%endtrans%}</h2>
<div class="card-body">
<p>Create an account using your forum account or email.</p>
<a href="{{ url_for('user_claim_page') }}" class="button">{%trans%}Claim your account{%endtrans%}</a>
<a href="{{ url_for('user_claim_page') }}" class="btn btn-primary">{%trans%}Claim your account{%endtrans%}</a>
</div>
</aside>
</div>
</div>
</aside>
</div>
{% endblock %}

View File

@@ -1,10 +1,10 @@
{% extends "base.html" %}
{% block container %}
<main>
<div class="box box_grey">
<!-- <h2>{{ self.title() }}</h2> -->
<div class="box-body">
<main class="container mt-4">
<div class="card">
<!-- <h2 class="card-header">{{ self.title() }}</h2> -->
<div class="card-body">
{% block content %}
{% endblock %}
</div>

View File

@@ -4,35 +4,50 @@
Welcome
{% endblock %}
{% block container %}
<header>
{% block content %}
<!-- <header class="jumbotron">
<div class="container">
<h1>Content DB</h1>
<h1 class="display-3">{{ config.USER_APP_NAME }}</h1>
<p>
<p class="lead">
Minetest's official content repository.
Browse {{ count }} packages,
the majority of which are available under a free
and open source license.
</p>
<form method="get" action="/packages/">
<input type="text" name="q" value="{{ query or ''}}" />
<input type="submit" value="Search" />
</form>
</div>
</header>
<main>
<main class="container"> -->
{% from "macros/packagegridtile.html" import render_pkggrid %}
<h2>Popular</h2>
{{ render_pkggrid(popular) }}
<a href="{{ url_for('packages_page') }}" class="button">Show More</a>
<h2 style="margin-top:2em;">Newly Added</h2>
<a href="{{ url_for('packages_page', sort='created_at', order='desc') }}" class="btn btn-secondary float-right">
See more
</a>
<h2 class="my-3">Recently Added</h2>
{{ render_pkggrid(new) }}
</main>
<a href="{{ url_for('packages_page', type='mod', sort='score', order='desc') }}" class="btn btn-secondary float-right">
See more
</a>
<h2 class="my-3">Top Mods</h2>
{{ render_pkggrid(pop_mod) }}
<a href="{{ url_for('packages_page', type='game', sort='score', order='desc') }}" class="btn btn-secondary float-right">
See more
</a>
<h2 class="my-3">Top Games</h2>
{{ render_pkggrid(pop_gam) }}
<a href="{{ url_for('packages_page', type='txp', sort='score', order='desc') }}" class="btn btn-secondary float-right">
See more
</a>
<h2 class="my-3">Top Texture Packs</h2>
{{ render_pkggrid(pop_txp) }}
<!-- </main> -->
{% endblock %}

View File

@@ -1,10 +1,10 @@
{% macro render_field(field, label=None, label_visible=true, right_url=None, right_label=None) -%}
{% macro render_field(field, label=None, label_visible=true, right_url=None, right_label=None, fieldclass=None) -%}
<div class="form-group {% if field.errors %}has-error{% endif %} {{ kwargs.pop('class_', '') }}">
{% if field.type != 'HiddenField' and label_visible %}
{% if not label %}{% set label=field.label.text %}{% endif %}
<label for="{{ field.id }}" class="control-label">{{ label|safe }}</label>
{% if not label and label != "" %}{% set label=field.label.text %}{% endif %}
{% if label %}<label for="{{ field.id }}">{{ label|safe }}</label>{% endif %}
{% endif %}
{{ field(class_='form-control', **kwargs) }}
{{ field(class_=fieldclass or 'form-control', **kwargs) }}
{% if field.errors %}
{% for e in field.errors %}
<p class="help-block">{{ e }}</p>
@@ -13,9 +13,8 @@
</div>
{%- endmacro %}
{% macro form_includes() -%}
{% macro form_scripts() -%}
<link href="/static/jquery-ui.min.css" rel="stylesheet" type="text/css">
<script src="/static/jquery.min.js"></script>
<script src="/static/jquery-ui.min.js"></script>
<script src="/static/tagselector.js"></script>
{% endmacro %}
@@ -58,16 +57,17 @@
<div class="form-group {% if field.errors %}has-error{% endif %} {{ kwargs.pop('class_', '') }}">
{% if field.type != 'HiddenField' and label_visible %}
{% if not label %}{% set label=field.label.text %}{% endif %}
<label for="{{ field.id }}" class="control-label">{{ label|safe }}</label>
<label for="{{ field.id }}">{{ label|safe }}</label>
{% endif %}
<div class="multichoice_selector bulletselector">
<div class="multichoice_selector bulletselector form-control">
<input type="text" placeholder="Start typing to see suggestions">
<div class="clearboth"></div>
</div>
<div class="invalid-remaining invalid-feedback"></div>
{{ field(class_='form-control', **kwargs) }}
{% if field.errors %}
{% for e in field.errors %}
<p class="help-block">{{ e }}</p>
<div class="invalid-feedback">{{ e }}</div>
{% endfor %}
{% endif %}
</div>
@@ -77,13 +77,14 @@
<div class="form-group {% if field.errors %}has-error{% endif %} {{ kwargs.pop('class_', '') }}">
{% if field.type != 'HiddenField' and label_visible %}
{% if not label %}{% set label=field.label.text %}{% endif %}
<label for="{{ field.id }}" class="control-label">{{ label|safe }}</label>
<label for="{{ field.id }}">{{ label|safe }}</label>
{% endif %}
<div class="metapackage_selector bulletselector">
<div class="metapackage_selector bulletselector form-control">
<input type="text" placeholder="Comma-seperated values">
<div class="clearboth"></div>
</div>
{{ field(class_='form-control', **kwargs) }}
<div class="invalid-remaining invalid-feedback"></div>
{% if field.errors %}
{% for e in field.errors %}
<p class="help-block">{{ e }}</p>
@@ -96,13 +97,14 @@
<div class="form-group {% if field.errors %}has-error{% endif %} {{ kwargs.pop('class_', '') }}">
{% if field.type != 'HiddenField' and label_visible %}
{% if not label %}{% set label=field.label.text %}{% endif %}
<label for="{{ field.id }}" class="control-label">{{ label|safe }}</label>
<label for="{{ field.id }}">{{ label|safe }}</label>
{% endif %}
<div class="deps_selector bulletselector">
<div class="deps_selector bulletselector form-control">
<input type="text" placeholder="Comma-seperated values">
<div class="clearboth"></div>
</div>
{{ field(class_='form-control', **kwargs) }}
<div class="invalid-remaining invalid-feedback"></div>
{% if field.errors %}
{% for e in field.errors %}
<p class="help-block">{{ e }}</p>
@@ -122,9 +124,9 @@
{% macro render_radio_field(field) -%}
{% for value, label, checked in field.iter_choices() %}
<div class="radio">
<label>
<input type="radio" name="{{ field.id }}" id="{{ field.id }}" value="{{ value }}"{% if checked %} checked{% endif %}>
<div class="form-check my-1">
<label class="form-check-label">
<input class="form-check-input" type="radio" name="{{ field.id }}" id="{{ field.id }}" value="{{ value }}"{% if checked %} checked{% endif %}>
{{ label }}
</label>
</div>
@@ -134,7 +136,7 @@
{% macro render_submit_field(field, label=None, tabindex=None) -%}
{% if not label %}{% set label=field.label.text %}{% endif %}
{#<button type="submit" class="form-control btn btn-default btn-primary">{{label}}</button>#}
<input type="submit" value="{{label}}"
<input type="submit" value="{{label}}" class="btn btn-primary"
{% if tabindex %}tabindex="{{ tabindex }}"{% endif %}
>
{%- endmacro %}

View File

@@ -1,13 +1,13 @@
{% macro render_pkgtile(package, show_author) -%}
<li><a href="{{ package.getDetailsURL() }}"
<li class="packagetile flex-fill"><a href="{{ package.getDetailsURL() }}"
style="background-image: url({{ package.getThumbnailURL() or '/static/placeholder.png' }});">
<div class="packagegridscrub"></div>
<div class="packagegridinfo">
<h3>
{{ package.title }}
{% if show_author %}
by {{ package.author.display_name }}
{% if show_author %}<br />
<small>{{ package.author.display_name }}</small>
{% endif %}
</h3>
@@ -34,11 +34,14 @@
{% endmacro %}
{% macro render_pkggrid(packages, show_author=True) -%}
<ul class="packagegrid">
<ul class="d-flex p-0 flex-row flex-wrap justify-content-start align-content-start ">
{% for p in packages %}
{{ render_pkgtile(p, show_author) }}
{% else %}
<li><i>No packages available</i></ul>
{% endfor %}
{% for i in range(4) %}
<li class="packagetile flex-fill"></li>
{% endfor %}
</ul>
{% endmacro %}

View File

@@ -1,36 +1,76 @@
{% macro render_thread(thread, current_user) -%}
<ul class="comments">
{% for r in thread.replies %}
<li>
<div class="info_strip">
<ul class="comments mt-4 mb-0">
{% for r in thread.replies %}
<li class="row my-2 mx-0">
<div class="col-md-1 p-1">
<a href="{{ url_for('user_profile_page', username=r.author.username) }}">
<img class="img-responsive user-photo img-thumbnail img-thumbnail-1" src="{{ r.author.getProfilePicURL() }}">
</a>
</div>
<div class="col">
<div class="card">
<div class="card-header">
<a class="author {{ r.author.rank.name }}"
href="{{ url_for('user_profile_page', username=r.author.username) }}">
{{ r.author.display_name }}</a>
<span>{{ r.created_at | datetime }}</span>
<div class="clearboth"></div>
{{ r.author.display_name }}
</a>
<a name="reply-{{ r.id }}" class="text-muted float-right"
href="{{ url_for('thread_page', id=thread.id) }}#reply-{{ r.id }}">
{{ r.created_at | datetime }}
</a>
</div>
<div class="msg">
<div class="card-body">
{{ r.comment | markdown }}
</div>
</li>
{% endfor %}
</ul>
</div>
</div>
</li>
{% endfor %}
</ul>
{% if current_user.is_authenticated %}
<form method="post" action="{{ url_for('thread_page', id=thread.id)}}" class="comment_form">
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}" />
<textarea required maxlength=500 name="comment" placeholder="Markdown supported"></textarea><br />
<input type="submit" value="Comment" />
</form>
{% endif %}
{% if current_user.is_authenticated %}
<div class="row mt-0 mb-4 comments mx-0">
<div class="col-md-1 p-1">
<img class="img-responsive user-photo img-thumbnail img-thumbnail-1" src="{{ current_user.getProfilePicURL() }}">
</div>
<div class="col">
<div class="card">
<div class="card-header {{ current_user.rank.name }}">
{{ current_user.display_name }}
<a name="reply"></a>
</div>
<form method="post" action="{{ url_for('thread_page', id=thread.id)}}" class="card-body">
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}" />
<textarea class="form-control markdown" required maxlength=500 name="comment"></textarea><br />
<input class="btn btn-primary" type="submit" value="Comment" />
</form>
</div>
</div>
</div>
{% endif %}
{% endmacro %}
{% macro render_threadlist(threads) -%}
<ul>
{% macro render_threadlist(threads, list_group=False) -%}
{% if not list_group %}<ul>{% endif %}
{% for t in threads %}
<li>{% if t.private %}&#x1f512; {% endif %}<a href="{{ url_for('thread_page', id=t.id) }}">{{ t.title }}</a> by {{ t.author.display_name }}</li>
<li {% if list_group %}class="list-group-item"{% endif %}>
{% if list_group %}
<a href="{{ url_for('thread_page', id=t.id) }}">
{% if t.private %}&#x1f512; {% endif %}
{{ t.title }}
by {{ t.author.display_name }}
</a>
{% else %}
{% if t.private %}&#x1f512; {% endif %}
<a href="{{ url_for('thread_page', id=t.id) }}">{{ t.title }}</a>
by {{ t.author.display_name }}
{% endif %}
</li>
{% else %}
<li><i>No threads found</i></li>
<li {% if list_group %}class="list-group-item"{% endif %}><i>No threads found</i></li>
{% endfor %}
</ul>
{% if not list_group %}</ul>{% endif %}
{% endmacro %}

View File

@@ -1,17 +1,15 @@
{% macro render_topics_table(topics, show_author=True) -%}
<table>
{% macro render_topics_table(topics, show_author=True, show_discard=False, current_user=current_user) -%}
<table class="table">
<tr>
<th>Id</th>
<th></th>
<th>Title</th>
{% if show_author %}<th>Author</th>{% endif %}
<th>Name</th>
<th>Link</th>
<th>Date</th>
<th>Actions</th>
</tr>
{% for topic in topics %}
<tr{% if topic.wip %} class="wiptopic"{% endif %}>
<td>{{ topic.topic_id }}</td>
<tr class="{% if topic.wip %}wiptopic{% endif %}{% if topic.discarded %}discardtopic{% endif %}">
<td>
[{{ topic.type.value }}]
</td>
@@ -23,9 +21,26 @@
<td><a href="{{ url_for('user_profile_page', username=topic.author.username) }}">{{ topic.author.display_name}}</a></td>
{% endif %}
<td>{{ topic.name or ""}}</td>
<td>{% if topic.link %}<a href="{{ topic.link }}">{{ topic.link | domain }}</a>{% endif %}</td>
<td>
<a href="{{ url_for('create_edit_package_page', author=topic.author.username, repo=topic.getRepoURL(), forums=topic.topic_id, title=topic.title, bname=topic.name) }}">Create</a>
<td>{{ topic.created_at | date }}</td>
<td class="btn-group">
{% if current_user == topic.author or topic.author.checkPerm(current_user, "CHANGE_AUTHOR") %}
<a class="btn btn-primary"
href="{{ url_for('create_edit_package_page', author=topic.author.username, repo=topic.getRepoURL(), forums=topic.topic_id, title=topic.title, bname=topic.name) }}">
Create
</a>
{% endif %}
{% if show_discard and current_user.is_authenticated and topic.checkPerm(current_user, "TOPIC_DISCARD") %}
<a class="btn btn-{% if topic.discarded %}success{% else %}danger{% endif %} topic-discard" data-tid={{ topic.topic_id }}>
{% if topic.discarded %}
Show
{% else %}
Discard
{% endif %}
</a>
{% endif %}
{% if topic.link %}
<a class="btn btn-info" href="{{ topic.link }}">{{ topic.link | domain | truncate(18) }}</a>
{% endif %}
</td>
</tr>
{% endfor %}

View File

@@ -7,86 +7,92 @@
{% endif %}
{% endblock %}
{% from "macros/forms.html" import render_field, render_submit_field, form_scripts, render_multiselect_field, render_mpackage_field, render_deps_field, package_lists %}
{% block scriptextra %}
{{ form_scripts() }}
{% if enable_wizard %}
<script src="/static/url.min.js"></script>
<script src="/static/polltask.js"></script>
<script src="/static/package_create.js?v=3"></script>
{% endif %}
<script src="/static/package_edit.js?v=3"></script>
{% endblock %}
{% block content %}
<h1>Create Package</h1>
<div class="box box_grey alert alert-info">
Have you read the Package Inclusion Policy and Guidance yet?
<div class="alert alert-info">
<a class="float-right btn btn-sm btn-default" href="{{ url_for('flatpage', path='policy_and_guidance') }}">View</a>
<a class="alert_right button" href="{{ url_for('flatpage', path='policy_and_guidance') }}">View</a>
Have you read the Package Inclusion Policy and Guidance yet?
</div>
<noscript>
<div class="alert alert-warning">
Javascript is needed to improve the user interface, and is needed for features
such as finding metadata from git, and autocompletion.<br />
Whilst disabled Javascript may work, it is not officially supported.
</div>
</noscript>
{% from "macros/forms.html" import render_field, render_submit_field, form_includes, render_multiselect_field, render_mpackage_field, render_deps_field, package_lists %}
{{ form_includes() }}
{{ package_lists() }}
<form method="POST" action="" class="tableform">
{{ form.hidden_tag() }}
<h2 class="pkg_meta">Package</h2>
<fieldset>
<legend>Package</legend>
{{ render_field(form.type, class_="pkg_meta") }}
{{ render_field(form.name, class_="pkg_meta") }}
{{ render_field(form.title, class_="pkg_meta") }}
{{ render_field(form.shortDesc, class_="pkg_meta") }}
{{ render_field(form.desc, class_="pkg_meta") }}
{{ render_multiselect_field(form.tags, class_="pkg_meta") }}
<div class="pkg_meta">
{{ render_field(form.license, class_="not_txp") }}
</div>
{{ render_field(form.media_license, class_="pkg_meta") }}
<div class="row">
{{ render_field(form.type, class_="pkg_meta col-sm-2") }}
{{ render_field(form.title, class_="pkg_meta col-sm-7") }}
{{ render_field(form.name, class_="pkg_meta col-sm-3") }}
</div>
{{ render_field(form.shortDesc, class_="pkg_meta") }}
{{ render_multiselect_field(form.tags, class_="pkg_meta") }}
<div class="pkg_meta row">
{{ render_field(form.license, class_="not_txp col-sm-6") }}
{{ render_field(form.media_license, class_="col-sm-6") }}
</div>
{{ render_field(form.desc, class_="pkg_meta", fieldclass="form-control markdown") }}
</fieldset>
<div class="pkg_meta">
<h2 class="not_txp">Dependency Info</h2>
<fieldset class="pkg_meta">
<legend class="not_txp">Dependencies</legend>
{{ render_mpackage_field(form.provides_str, class_="not_txp", placeholder="Comma separated list") }}
{{ render_deps_field(form.harddep_str, class_="not_txp not_game", placeholder="Comma separated list") }}
{{ render_deps_field(form.softdep_str, class_="not_txp not_game", placeholder="Comma separated list") }}
</div>
</fieldset>
<h2 class="pkg_meta">Repository and Links</h2>
<fieldset>
<legend class="pkg_meta">Repository and Links</legend>
<div class="pkg_wiz_1">
<p>Enter the repo URL for the package.
If the repo uses git then the metadata will be automatically imported.</p>
<div class="pkg_wiz_1">
<p>Enter the repo URL for the package.
If the repo uses git then the metadata will be automatically imported.</p>
<p>Leave blank if you don't have a repo. Click skip if the import fails.</p>
</div>
<p>Leave blank if you don't have a repo. Click skip if the import fails.</p>
</div>
{{ render_field(form.repo, class_="pkg_repo") }}
{{ render_field(form.repo, class_="pkg_repo") }}
<div class="pkg_wiz_1">
<a id="pkg_wiz_1_next" class="button button-primary">Next (Autoimport)</a>
<a id="pkg_wiz_1_skip" class="button button-default">Skip Autoimport</a>
</div>
<div class="pkg_wiz_2">
Importing... (This may take a while)
</div>
<div class="pkg_wiz_1">
<a id="pkg_wiz_1_next" class="btn btn-primary">Next (Autoimport)</a>
<a id="pkg_wiz_1_skip" class="btn btn-default">Skip Autoimport</a>
</div>
<div class="pkg_wiz_2">
Importing... (This may take a while)
</div>
{{ render_field(form.website, class_="pkg_meta") }}
{{ render_field(form.issueTracker, class_="pkg_meta") }}
{{ render_field(form.forums, class_="pkg_meta", placeholder="Tip: paste in a forum topic URL") }}
</fieldset>
{{ render_field(form.website, class_="pkg_meta") }}
{{ render_field(form.issueTracker, class_="pkg_meta") }}
{{ render_field(form.forums, class_="pkg_meta") }}
<div class="pkg_meta">{{ render_submit_field(form.submit) }}</div>
</form>
<script src="/static/simplemde.min.js"></script>
<link rel="stylesheet" type="text/css" href="/static/simplemde.min.css">
<script>
var simplemde = new SimpleMDE({ element: $("#desc")[0] });
</script>
{% if enable_wizard %}
<script src="/static/url.min.js"></script>
<script src="/static/polltask.js"></script>
<script src="/static/package_create.js"></script>
<noscript>
<div class="box box_grey alert alert-warning">
<span class="icon_message"></span>
Javascript is needed to automatically import metadata from VCS.
</div>
</noscript>
{% endif %}
<script src="/static/package_edit.js"></script>
{% endblock %}

View File

@@ -24,7 +24,7 @@
This edit request was merged.
</div>
{% elif request.status == 2 %}
<div class="box box_grey alert alert-error">
<div class="box box_grey alert alert-danger">
This edit request was rejected.
</div>
{% elif package.checkPerm(current_user, "APPROVE_CHANGES") %}

View File

@@ -5,38 +5,24 @@
{% endblock %}
{% block content %}
<form method="get" action="" class="plsearchform">
{% if type %}<input type="hidden" name="type" value="{{ type }}" />{% endif %}
<input type="text" name="q" value="{{ query or ''}}" />
<input type="submit" value="Search" />
<input type="submit" name="lucky" value="I'm feeling lucky" />
<p>
Found {{ packages_count }} packages.
</p>
</form>
<!--<aside class="box box_grey outsidecontainer">
<h3>Tags</h3>
<ul class="flatlist">
{% for t in tags %}
<li><a href="{{ url_for('packages_page', q=(query or '')+' tag:'+t.name, type=type) }}">
{{ t.title }}
</a></li>
{% else %}
<li><i>No tags available</i></ul>
{% endfor %}
</ul>
</aside> -->
{% from "macros/packagegridtile.html" import render_pkggrid %}
{{ render_pkggrid(packages) }}
<ul class="buttonset linedbuttonset">
{% if prev_url %}<li><a href="{{ prev_url }}">Previous</a></li>{% endif %}
<li>{{ page }} / {{ page_max }}</li>
{% if next_url %}<li><a href="{{ next_url }}">Next</a></li> {% endif %}
<ul class="pagination mt-4">
<li class="page-item {% if not prev_url %}disabled{% endif %}">
<a class="page-link" {% if prev_url %}href="{{ prev_url }}"{% endif %}>&laquo;</a>
</li>
{% for n in range(1, page_max+1) %}
<li class="page-item {% if n == page %}active{% endif %}">
<a class="page-link"
href="{{ url_for('packages_page', type=type, q=query, page=n) }}">
{{ n }}
</a>
</li>
{% endfor %}
<li class="page-item {% if not next_url %}disabled{% endif %}">
<a class="page-link" {% if next_url %}href="{{ next_url }}"{% endif %}>&raquo;</a>
</li>
</ul>
{% if topics %}

View File

@@ -5,7 +5,7 @@
{% endblock %}
{% block content %}
{% from "macros/forms.html" import render_field, render_submit_field %}
{% from "macros/forms.html" import render_field, render_submit_field, render_checkbox_field %}
<form method="POST" action="">
{{ form.hidden_tag() }}
@@ -34,7 +34,7 @@
<br />
{% else %}
{% if package.checkPerm(current_user, "APPROVE_RELEASE") %}
{{ render_field(form.approved) }}
{{ render_checkbox_field(form.approved, class_="my-3") }}
{% else %}
Approved: {{ release.approved }}
{% endif %}

View File

@@ -5,16 +5,19 @@
{% endblock %}
{% block content %}
{% from "macros/forms.html" import render_field, render_submit_field %}
{% from "macros/forms.html" import render_field, render_submit_field, render_radio_field %}
<form method="POST" action="" enctype="multipart/form-data">
{{ form.hidden_tag() }}
{{ render_field(form.title, placeholder="Human readable. Eg: 1.0.0 or 2018-05-28") }}
{{ render_field(form.uploadOpt) }}
<p class="mb-0">Method</p>
{{ render_radio_field(form.uploadOpt) }}
{% if package.repo %}
{{ render_field(form.vcsLabel) }}
{{ render_field(form.vcsLabel, class_="mt-3") }}
{% endif %}
{{ render_field(form.fileUpload) }}
{{ render_field(form.fileUpload, fieldclass="form-control-file") }}
{{ render_submit_field(form.submit) }}
</form>
{% endblock %}

View File

@@ -6,13 +6,14 @@
{% block content %}
<form method="POST" action="" class="box box_grey ">
<h3>Delete Package</h3>
<h3>Remove Package</h3>
<div class="box-body">
<p>This action can be undone by the admin, but he'll be very annoyed!</p>
<p>Deleting a package can be undone by the admin, but he'll be very annoyed!</p>
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}" />
<input type="submit" value="Delete" class="button-danger" />
<input type="submit" name="delete" value="Delete" class="btn btn-danger" />
<input type="submit" name="unapprove" value="Unapprove" class="btn btn-warning" />
</div>
</form>
{% endblock %}

View File

@@ -9,15 +9,15 @@
<img src="{{ screenshot.getThumbnailURL() }}" alt="{{ screenshot.title }}" />
</a>
{% from "macros/forms.html" import render_field, render_submit_field %}
{% from "macros/forms.html" import render_field, render_submit_field, render_checkbox_field %}
<form method="POST" action="" enctype="multipart/form-data">
{{ form.hidden_tag() }}
{{ render_field(form.title) }}
{{ render_field(form.delete) }}
{{ render_checkbox_field(form.delete) }}
{% if package.checkPerm(current_user, "APPROVE_SCREENSHOT") %}
{{ render_field(form.approved) }}
{{ render_checkbox_field(form.approved) }}
{% else %}
<p>Approved: {{ screenshot.approved }}</p>
{% endif %}

View File

@@ -10,7 +10,7 @@
{{ form.hidden_tag() }}
{{ render_field(form.title) }}
{{ render_field(form.fileUpload) }}
{{ render_field(form.fileUpload, fieldclass="form-control-file") }}
{{ render_submit_field(form.submit) }}
</form>
{% endblock %}

View File

@@ -1,64 +1,297 @@
{% set query=package.name %}
{% extends "base.html" %}
{% block title %}
{{ package.title }}
{% endblock %}
{% block content %}
{% if not package.approved %}
<div class="box box_grey alert alert-warning">
<span class="icon_message"></span>
{% if package.releases.count() == 0 %}
{% if package.checkPerm(current_user, "MAKE_RELEASE") %}
You need to create a release before this package can be approved.
<p>
A release is a single downloadable version of your {{ package.type.value | lower }}.
You need to create releases even if you use a rolling release development cycle,
as Minetest needs them to check for updates.
</p>
<a class="button" href="{{ package.getCreateReleaseURL() }}">Create Release</a>
{% else %}
A release is required before this package can be approved.
{% endif %}
{% block container %}
<header class="jumbotron pb-3"
style="background: linear-gradient(rgba(0, 0, 0, 0.3), rgba(0, 0, 0, 0.3)), url('{{ package.getMainScreenshotURL() }}');
background-size: cover;
background-repeat: no-repeat;
background-position: center;">
<div class="container">
<h1 class="display-3">
{{ package.title }}
<small>by {{ package.author.display_name }}</small>
</h1>
{% elif (package.type == package.type.GAME or package.type == package.type.TXP) and package.screenshots.count() == 0 %}
You need to add at least one screenshot.
<p class="lead">
{{ package.shortDesc }}
</p>
{% elif topic_error_lvl == "error" %}
Please fix the below topic issue(s).
{% elif "Other" in package.license.name or "Other" in package.media_license.name %}
Please wait for the license to be added to CDB.
{% else %}
{% if package.screenshots.count() == 0 %}
<b>You should add at least one screenshot, but this isn't required.</b><br />
{% endif %}
{% if not package.getDownloadRelease() %}
Please wait for the release to be approved.
{% elif package.checkPerm(current_user, "APPROVE_NEW") %}
You can now approve this package if you're ready.
<form method="post" action="{{ package.getApproveURL() }}">
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}" />
<input type="submit" value="Approve" />
</form>
{% else %}
Please wait for the package to be approved.
{% endif %}
{% endif %}
<div style="clear: both;"></div>
<div class="row" style="margin-top: 2rem;">
<div class="col">
</div>
<div class="btn-group-horizontal col-md-auto">
{% if package.repo %}<a class="btn btn-secondary" href="{{ package.repo }}">View Source</a>{% endif %}
{% if package.forums %}<a class="btn btn-secondary" href="https://forum.minetest.net/viewtopic.php?t={{ package.forums }}">Forums</a>{% endif %}
{% if package.issueTracker %}<a class="btn btn-secondary" href="{{ package.issueTracker }}">Issue Tracker</a>{% endif %}
{% if package.website %}<a class="btn btn-secondary" href="{{ package.website }}">Website</a>{% endif %}
</div>
</div>
</div>
</header>
{% if topic_error %}
<div class="box box_grey alert alert-{{ topic_error_lvl }}">
<main class="container mt-4">
{% if not package.approved %}
<div class="alert alert-warning">
<span class="icon_message"></span>
{{ topic_error | safe }}
{% if package.releases.count() == 0 %}
<h4 class="alert-heading">Release Required</h4>
{% if package.checkPerm(current_user, "MAKE_RELEASE") %}
<p>You need to create a release before this package can be approved.</p>
<p>
A release is a single downloadable version of your {{ package.type.value | lower }}.
You need to create releases even if you use a rolling release development cycle,
as Minetest needs them to check for updates.
</p>
<a class="btn" href="{{ package.getCreateReleaseURL() }}">Create Release</a>
{% else %}
A release is required before this package can be approved.
{% endif %}
{% elif (package.type == package.type.GAME or package.type == package.type.TXP) and package.screenshots.count() == 0 %}
You need to add at least one screenshot.
{% elif topic_error_lvl == "danger" %}
Please fix the below topic issue(s).
{% elif "Other" in package.license.name or "Other" in package.media_license.name %}
Please wait for the license to be added to CDB.
{% else %}
{% if package.screenshots.count() == 0 %}
<b>You should add at least one screenshot, but this isn't required.</b><br />
{% endif %}
{% if not package.getDownloadRelease() %}
Please wait for the release to be approved.
{% elif package.checkPerm(current_user, "APPROVE_NEW") %}
<form class="float-right" method="post" action="{{ package.getApproveURL() }}">
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}" />
<input class="btn btn-sm btn-warning" type="submit" value="Approve" />
</form>
You can now approve this package if you're ready.
{% else %}
Please wait for the package to be approved.
{% endif %}
{% endif %}
<div style="clear: both;"></div>
</div>
{% if topic_error %}
<div class="alert alert-{{ topic_error_lvl }}">
<span class="icon_message"></span>
{{ topic_error | safe }}
<div style="clear: both;"></div>
</div>
{% endif %}
{% if similar_topics %}
<div class="alert alert-warning">
Please make sure that this package has the right to
the name '{{ package.name }}'.
See the
<a href="/policy_and_guidance/">Inclusion Policy</a>
for more info.
</div>
{% endif %}
{% if not review_thread and (package.author == current_user or package.checkPerm(current_user, "APPROVE_NEW")) %}
<div class="alert alert-info">
<a class="float-right btn btn-sm btn-info" href="{{ url_for('new_thread_page', pid=package.id, title='Package approval comments') }}">Open Thread</a>
Privately ask a question or give feedback
<div style="clear:both;"></div>
</div>
{% endif %}
{% endif %}
{% if package.author == current_user or package.checkPerm(current_user, "APPROVE_NEW") %}
<aside class="float-right ml-4" style="width: 18rem;">
{% if package.getDownloadRelease() %}
<a class="btn btn-download btn-lg btn-block"
href="{{ package.getDownloadURL() }}" class="btn_green">
Download
</a>
{% else %}
No download available.
{% endif %}
<div class="card my-4">
<div class="card-header">
Details
<div class="btn-group float-right">
{% if package.checkPerm(current_user, "EDIT_PACKAGE") %}
<a class="btn btn-default btn-sm mx-1" href="{{ package.getEditURL() }}">Edit</a>
{% endif %}
{# {% if current_user.is_authenticated %}
<a class="btn btn-default btn-sm mx-1" href="{{ package.getCreateEditRequestURL() }}">Suggest Changes</a>
{% endif %} #}
{% if package.checkPerm(current_user, "DELETE_PACKAGE") or package.checkPerm(current_user, "UNAPPROVE_PACKAGE") %}
<a class="btn btn-danger btn-sm mx-1" href="{{ package.getRemoveURL() }}">Remove</a>
{% endif %}
</div>
</div>
{% if not package.license.is_foss and not package.media_license.is_foss and package.type != package.type.TXP %}
{% set package_warning="Non-free code and media." %}
{% elif not package.license.is_foss and package.type != package.type.TXP %}
{% set package_warning="Non-free code." %}
{% elif not package.media_license.is_foss %}
{% set package_warning="Non-free media." %}
{% endif %}
{% if package_warning %}
<div class="card-body">
<div class="alert alert-danger">
<b>Warning:</b> {{ package_warning }}
</div>
</div>
{% endif %}
<table class="table">
<tr>
<td>Name</td>
<td>{{ package.name }}</td>
</tr>
{% if package.provides %}
<tr>
<td>Provides</td>
<td>{% for meta in package.provides %}
<a class="badge badge-primary"
href="{{ url_for('meta_package_page', name=meta.name) }}">{{ meta.name }}</a>
{% endfor %}</td>
</tr>
{% endif %}
<tr>
<td>Author</td>
<td class="{{ package.author.rank }}">
<a href="{{ url_for('user_profile_page', username=package.author.username) }}">
{{ package.author.display_name }}
</a>
</td>
</tr>
<tr>
<td>Type</td>
<td>{{ package.type.value }}</td>
</tr>
<tr>
<td>License</td>
<td>
{% if package.license == package.media_license %}
{{ package.license.name }}
{% elif package.type == package.type.TXP %}
{{ package.media_license.name }}
{% else %}
{{ package.license.name }} for code,<br />
{{ package.media_license.name }} for media.
{% endif %}
</td>
</tr>
<tr>
<td>Added</td>
<td>{{ package.created_at | datetime }}</td>
</tr>
<tr>
<td>Tags</td>
<td>
{% for t in package.tags %}
<span class="badge badge-primary">{{ t.title }}</span>
{% else %}
<i>No tags.</i>
{% endfor %}
</td>
</table>
</div>
{% if package.type == package.type.MOD %}
<div class="card my-4">
<div class="card-header">Dependencies</div>
<div class="card-body">
{% for dep in package.dependencies %}
{% if dep.optional %}
{% set color="secondary" %}
{% else %}
{% set color="primary" %}
{% endif %}
{%- if dep.package %}
<a class="badge badge-{{ color }}"
href="{{ dep.package.getDetailsURL() }}">
{{ dep.package.title }} by {{ dep.package.author.display_name }}
{% elif dep.meta_package %}
<a class="badge badge-{{ color }}"
href="{{ url_for('meta_package_page', name=dep.meta_package.name) }}">
{{ dep.meta_package.name }}
{% else %}
{{ "Excepted package or meta_package in dep!" | throw }}
{% endif %}</a>
{% else %}
<i>No dependencies</i>
{% endfor %}
</div>
</div>
{% endif %}
<div class="card my-4">
<div class="card-header">
Releases
{% if package.checkPerm(current_user, "MAKE_RELEASE") %}
<a class="float-right"
href="{{ package.getCreateReleaseURL() }}">+</a>
{% endif %}
</div>
<ul class="list-group list-group-flush">
{% for rel in releases %}
{% if rel.approved or package.checkPerm(current_user, "MAKE_RELEASE") or package.checkPerm(current_user, "APPROVE_RELEASE") %}
<li class="list-group-item">
{% if package.checkPerm(current_user, "MAKE_RELEASE") or package.checkPerm(current_user, "APPROVE_RELEASE") %}
<a class="btn btn-sm btn-primary float-right" href="{{ rel.getEditURL() }}">Edit
{% if not rel.task_id and not rel.approved and package.checkPerm(current_user, "APPROVE_RELEASE") %}
/ Approve
{% endif %}
</a>
{% endif %}
{% if not rel.approved %}<i>{% endif %}
<a href="{{ rel.getDownloadURL() }}">{{ rel.title }}</a>{% if rel.commit_hash %}
[{{ rel.commit_hash | truncate(5, end='') }}]{% endif %}<br>
<small>created {{ rel.releaseDate | datetime }}.</small>
{% if rel.task_id %}
<a href="{{ url_for('check_task', id=rel.task_id, r=package.getDetailsURL()) }}">Importing...</a>
{% elif not rel.approved %}
Waiting for approval.
{% endif %}
{% if not rel.approved %}</i>{% endif %}
</li>
{% endif %}
{% else %}
<li class="list-group-item">No releases available.</li>
{% endfor %}
</ul>
</div>
<div class="card my-4"">
<div class="card-header">
{% if package.approved and package.checkPerm(current_user, "CREATE_THREAD") %}
<a class="float-right"
href="{{ url_for('new_thread_page', pid=package.id) }}">+</a>
{% endif %}
Threads
</div>
<ul class="list-group list-group-flush">
{% from "macros/threads.html" import render_threadlist %}
{{ render_threadlist(threads, list_group=True) }}
</ul>
</div>
</aside>
{% if not package.approved and (package.author == current_user or package.checkPerm(current_user, "APPROVE_NEW")) %}
{% if review_thread %}
<h2>{% if review_thread.private %}&#x1f512;{% endif %} {{ review_thread.title }}</h2>
{% if review_thread.private %}
@@ -70,266 +303,66 @@
{% from "macros/threads.html" import render_thread %}
{{ render_thread(review_thread, current_user) }}
{% else %}
<div class="box box_grey alert alert-info">
Privately ask a question or give feedback
<a class="alert_right button" href="{{ url_for('new_thread_page', pid=package.id, title='Package approval comments') }}">Open Thread</a>
</div>
{% endif %}
{% endif %}
{% endif %}
<h1>{{ package.title }} by {{ package.author.display_name }}</h1>
<ul class="screenshot_list">
{% for ss in package.screenshots %}
{% if ss.approved or package.checkPerm(current_user, "ADD_SCREENSHOTS") %}
<li>
<a href="{% if package.checkPerm(current_user, 'ADD_SCREENSHOTS') %}{{ ss.getEditURL() }}{% else %}{{ ss.url }}{% endif %}">
<img src="{{ ss.getThumbnailURL() }}" alt="{{ ss.title }}" />
</a>
</li>
<ul class="screenshot_list mb-4">
{% if package.checkPerm(current_user, "EDIT_PACKAGE") %}
<a class="btn btn-primary float-right" href="{{ package.getNewScreenshotURL() }}">Add screenshot</a>
{% endif %}
{% endfor %}
</ul>
<aside class="asideright box box_grey">
<h3>Details</h3>
<div class="box-body">
{% if not package.license.is_foss and not package.media_license.is_foss and package.type != package.type.TXP %}
<div class="box box_grey alert alert-error" style="margin-top: 0;">
<b>Warning:</b> Non-free code and media.
</div>
{% elif not package.license.is_foss and package.type != package.type.TXP %}
<div class="box box_grey alert alert-error" style="margin-top: 0;">
<b>Warning:</b> Non-free code.
</div>
{% elif not package.media_license.is_foss %}
<div class="box box_grey alert alert-error" style="margin-top: 0;">
<b>Warning:</b> Non-free media.
</div>
{% endif %}
<table>
<tr>
<td>Name</td>
<td>{{ package.name }}</td>
</tr>
{% if package.provides %}
<tr>
<td>Provides</td>
<td>{% for meta in package.provides %}
<a href="{{ url_for('meta_package_page', name=meta.name) }}">{{ meta.name }}</a>
{%- if not loop.last %}
,
{% endif %}
{% endfor %}</td>
</tr>
{% endif %}
<tr>
<td>Author</td>
<td class="{{ package.author.rank }}">
<a href="{{ url_for('user_profile_page', username=package.author.username) }}">
{{ package.author.display_name }}
{% for ss in package.screenshots %}
{% if ss.approved or package.checkPerm(current_user, "ADD_SCREENSHOTS") %}
<li>
<a href="{% if package.checkPerm(current_user, 'ADD_SCREENSHOTS') %}{{ ss.getEditURL() }}{% else %}{{ ss.url }}{% endif %}">
<img src="{{ ss.getThumbnailURL() }}" alt="{{ ss.title }}" />
</a>
</td>
</tr>
<tr>
<td>Type</td>
<td>{{ package.type.value }}</td>
</tr>
<tr>
<td>License</td>
<td>
{% if package.license == package.media_license %}
{{ package.license.name }}
{% elif package.type == package.type.TXP %}
{{ package.media_license.name }}
{% else %}
{{ package.license.name }} for code,<br />
{{ package.media_license.name }} for media.
{% endif %}
</td>
</tr>
<tr>
<td>Added</td>
<td>{{ package.created_at | datetime }}</td>
</tr>
</table>
<ul class="buttonset linedbuttonset">
{% if package.getDownloadRelease() %}<li><a href="{{ package.getDownloadURL() }}" class="btn_green">Download</a></li>{% endif %}
{% if package.repo %}<li><a href="{{ package.repo }}">View Source</a></li>{% endif %}
{% if package.forums %}<li><a href="https://forum.minetest.net/viewtopic.php?t={{ package.forums }}">Forums</a></li>{% endif %}
{% if package.issueTracker %}<li><a href="{{ package.issueTracker }}">Issue Tracker</a></li>{% endif %}
{% if package.website %}<li><a href="{{ package.website }}">Website</a></li>{% endif %}
{% if package.checkPerm(current_user, "EDIT_PACKAGE") %}
<li><a href="{{ package.getEditURL() }}">Edit</a></li>
<li><a href="{{ package.getNewScreenshotURL() }}">Add screenshot</a></li>
</li>
{% endif %}
{# {% if current_user.is_authenticated %}
<li><a href="{{ package.getCreateEditRequestURL() }}">Suggest Changes</a></li>
{% endif %} #}
{% if package.checkPerm(current_user, "MAKE_RELEASE") %}
<li><a href="{{ package.getCreateReleaseURL() }}">Create Release</a></li>
{% endif %}
{% if package.approved and package.checkPerm(current_user, "CREATE_THREAD") %}
<li><a href="{{ url_for('new_thread_page', pid=package.id) }}">Open Thread</a></li>
{% endif %}
{% if package.checkPerm(current_user, "DELETE_PACKAGE") %}
<li><a href="{{ package.getDeleteURL() }}">Delete</a></li>
{% endif %}
</ul>
</div>
</aside>
{% endfor %}
</ul>
<p class="package-short-large">{{ package.shortDesc }}</p>
{{ package.desc | markdown }}
{{ package.desc | markdown }}
<div style="clear: both;"></div>
<h3>Releases</h3>
{#
{% if current_user.is_authenticated or requests %}
<h3>Edit Requests</h3>
<ul>
{% for rel in releases %}
{% if rel.approved or package.checkPerm(current_user, "MAKE_RELEASE") or package.checkPerm(current_user, "APPROVE_RELEASE") %}
<li>
{% if not rel.approved %}<i>{% endif %}
<a href="{{ rel.getDownloadURL() }}">{{ rel.title }}</a>{% if rel.commit_hash %}
[{{ rel.commit_hash | truncate(5, end='') }}]{% endif %},
created {{ rel.releaseDate | datetime }}.
{% if rel.task_id %}
<a href="{{ url_for('check_task', id=rel.task_id, r=package.getDetailsURL()) }}">Importing...</a>
{% elif not rel.approved %}
Waiting for approval.
{% endif %}
{% if package.checkPerm(current_user, "MAKE_RELEASE") or package.checkPerm(current_user, "APPROVE_RELEASE") %}
<a href="{{ rel.getEditURL() }}">Edit
{% if not rel.task_id and not rel.approved and package.checkPerm(current_user, "APPROVE_RELEASE") %}
/ Approve
{% endif %}
</a>
{% endif %}
{% if not rel.approved %}</i>{% endif %}
</li>
{% endif %}
{% else %}
<li>No releases available.</li>
{% endfor %}
</ul>
<h3>Tags</h3>
<ul>
{% for t in package.tags %}
<li>{{ t.title }}</li>
{% else %}
<li>No tags.</li>
{% endfor %}
</ul>
<!-- <table class="table-topalign">
<tr>
<td> -->
<h3>Dependencies</h3>
<ul>
{% for dep in package.dependencies %}
{% for r in requests %}
<li>
{%- if dep.package %}
<a href="{{ dep.package.getDetailsURL() }}">{{ dep.package.title }}</a> by {{ dep.package.author.display_name }}
{% elif dep.meta_package %}
<a href="{{ url_for('meta_package_page', name=dep.meta_package.name) }}">{{ dep.meta_package.name }}</a>
{% else %}
{{ "Excepted package or meta_package in dep!" | throw }}
{% endif %}
{% if dep.optional %}
[optional]
{% endif %}
<a href="{{ r.getURL() }}">{{ r.title }}</a>
by
<a href="{{ url_for('user_profile_page', username=r.author.username) }}">{{ r.author.display_name }}</a>
</li>
{% else %}
<li><i>No dependencies</i></li>
<li>No edit requests have been made.</li>
{% endfor %}
</ul>
<!-- </td>
<td>
<h3>Required by</h3>
<ul>
{% for p in package.dependents %}
<li><a href="{{ p.getDetailsURL() }}">{{ p.title }}</a> by {{ p.author.display_name }}</li>
{% else %}
{% if not package.softdependents %}
<li>No dependents.</li>
{% endif %}
{% endfor %}
{% for p in package.softdependents %}
<li><a href="{{ p.getDetailsURL() }}">{{ p.title }}</a> by {{ p.author.display_name }} [optional]</li>
{% endfor %}
</ul>
</td>
</tr>
</table> -->
{% endif %}
#}
{#
{% if current_user.is_authenticated or requests %}
<h3>Edit Requests</h3>
{% if alternatives %}
<h3>Related</h3>
{% from "macros/packagegridtile.html" import render_pkggrid %}
{{ render_pkggrid(alternatives) }}
{% endif %}
{% if similar_topics %}
<h3>Similar Forum Topics</h3>
<ul>
{% for r in requests %}
{% for t in similar_topics %}
<li>
<a href="{{ r.getURL() }}">{{ r.title }}</a>
by
<a href="{{ url_for('user_profile_page', username=r.author.username) }}">{{ r.author.display_name }}</a>
[{{ t.type.value }}]
<a href="https://forum.minetest.net/viewtopic.php?t={{ t.topic_id }}">
{{ t.title }} by {{ t.author.display_name }}
</a>
{% if t.wip %}[WIP]{% endif %}
</li>
{% else %}
<li>No edit requests have been made.</li>
{% endfor %}
</ul>
{% endif %}
#}
{% if alternatives %}
<h3>Alternatives</h3>
<ul>
{% for p in alternatives %}
<li><a href="{{ p.getDetailsURL() }}">{{ p.title }} by {{ p.author.display_name }}</a></li>
{% endfor %}
</ul>
{% endif %}
{% if similar_topics %}
<h3>Similar Forum Topics</h3>
{% if not package.approved and package.type == package.type.MOD %}
<div class="box box_grey alert alert-warning">
Please make sure that this package has the right to
the name '{{ package.name }}'.
See the
<a href="/policy_and_guidance/">Inclusion Policy</a>
for more info.
</div>
{% endif %}
<ul>
{% for t in similar_topics %}
<li>
[{{ t.type.value }}]
<a href="https://forum.minetest.net/viewtopic.php?t={{ t.topic_id }}">
{{ t.title }} by {{ t.author.display_name }}
</a>
{% if t.wip %}[WIP]{% endif %}
</li>
{% endfor %}
</ul>
{% endif %}
{% if threads %}
<h3>Threads</h3>
{% if package.approved and package.checkPerm(current_user, "CREATE_THREAD") %}
<p><a href="{{ url_for('new_thread_page', pid=package.id) }}">Open Thread</a></p>
{% endif %}
{% from "macros/threads.html" import render_threadlist %}
{{ render_threadlist(threads) }}
{% endif %}
</main>
{% endblock %}

View File

@@ -5,15 +5,37 @@
{% endblock %}
{% block content %}
{% from "macros/forms.html" import render_field, render_submit_field %}
<form method="POST" action="" enctype="multipart/form-data">
{{ form.hidden_tag() }}
{{ render_field(form.title) }}
{{ render_field(form.comment) }}
{{ render_field(form.private) }}
{{ render_submit_field(form.submit) }}
{% from "macros/forms.html" import render_field, render_submit_field, render_checkbox_field %}
<form method="POST" action="" enctype="multipart/form-data">
{{ form.hidden_tag() }}
{{ render_field(form.title) }}
<div class="row mt-0 mb-4 comments mx-0">
<div class="col-md-1 p-1">
<img class="img-responsive user-photo img-thumbnail img-thumbnail-1" src="{{ current_user.getProfilePicURL() }}">
</div>
<div class="col">
<div class="card">
<div class="card-header {{ current_user.rank.name }}">
{{ current_user.display_name }}
<a name="reply"></a>
</div>
<div class="card-body">
{{ render_field(form.comment, label="", class_="m-0", fieldclass="form-control markdown") }}
</div>
</div>
</div>
</div>
{{ render_checkbox_field(form.private, class_="my-3") }}
<p>
Only the you, the package author, and users of Editor rank
and above can read private threads.
</p>
{{ render_submit_field(form.submit) }}
</form>
<p>Only the you, the package author, and users of Editor rank and above can read private threads.</p>
</form>
{% endblock %}

View File

@@ -5,25 +5,26 @@ Threads
{% endblock %}
{% block content %}
{% if current_user.is_authenticated %}
{% if current_user in thread.watchers %}
<form method="post" action="{{ thread.getUnsubscribeURL() }}" class="float-right">
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}" />
<input type="submit" class="btn btn-primary" value="Unsubscribe" />
</form>
{% else %}
<form method="post" action="{{ thread.getSubscribeURL() }}" class="float-right">
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}" />
<input type="submit" class="btn btn-primary" value="Subscribe" />
</form>
{% endif %}
{% endif %}
<h1>{% if thread.private %}&#x1f512; {% endif %}{{ thread.title }}</h1>
{% if thread.package or current_user.is_authenticated %}
{% if thread.package %}
<p>Package: <a href="{{ thread.package.getDetailsURL() }}">{{ thread.package.title }}</a></p>
{% endif %}
{% if current_user.is_authenticated %}
{% if current_user in thread.watchers %}
<form method="post" action="{{ thread.getUnsubscribeURL() }}">
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}" />
<input type="submit" value="Unsubscribe" />
</form>
{% else %}
<form method="post" action="{{ thread.getSubscribeURL() }}">
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}" />
<input type="submit" value="Subscribe" />
</form>
{% endif %}
{% endif %}
{% endif %}
{% if thread.private %}

View File

@@ -5,13 +5,94 @@ Topics to be Added
{% endblock %}
{% block content %}
<div class="float-right">
<div class="btn-group">
<a class="btn btn-primary {% if sort_by=='date' %}active{% endif %}"
href="{{ url_for('todo_topics_page', q=query, show_discarded=show_discarded, n=n, sort='date') }}">
Sort by date
</a>
<a class="btn btn-primary {% if sort_by=='name' %}active{% endif %}"
href="{{ url_for('todo_topics_page', q=query, show_discarded=show_discarded, n=n, sort='name') }}">
Sort by name
</a>
<a class="btn btn-primary {% if sort_by=='views' %}active{% endif %}"
href="{{ url_for('todo_topics_page', q=query, show_discarded=show_discarded, n=n, sort='views') }}">
Sort by views
</a>
</div>
<div class="btn-group">
{% if current_user.rank.atLeast(current_user.rank.EDITOR) %}
{% if n >= 10000 %}
<a class="btn btn-primary"
href="{{ url_for('todo_topics_page', q=query, show_discarded=show_discarded, n=100, sort=sort_by) }}">
Paginated list
</a>
{% else %}
<a class="btn btn-primary"
href="{{ url_for('todo_topics_page', q=query, show_discarded=show_discarded, n=10000, sort=sort_by) }}">
Unlimited list
</a>
{% endif %}
{% endif %}
<a class="btn btn-primary" href="{{ url_for('todo_topics_page', q=query, show_discarded=not show_discarded, n=n, sort=sort_by) }}">
{% if not show_discarded %}
Show
{% else %}
Hide
{% endif %}
discarded topics
</a>
</div>
</div>
<h1>Topics to be Added</h1>
<p>
{{ total - (topics | count) }} / {{ total }} packages have been added.
{{ topics | count }} remaining.
{{ total - topic_count }} / {{ total }} topics have been added as packages to CDB.
{{ topic_count }} remaining.
</p>
<div class="progress">
{% set perc = 100 * (total - topic_count) / total %}
<div class="progress-bar bg-success" role="progressbar"
style="width: {{ perc }}%" aria-valuenow="{{ perc }}" aria-valuemin="0" aria-valuemax="100"></div>
</div>
<form method="GET" action="{{ url_for('todo_topics_page') }}" class="my-4">
<input type="hidden" name="show_discarded" value={{ show_discarded and "True" or "False" }} />
<input type="hidden" name="n" value={{ n }} />
<input type="hidden" name="sort" value={{ sort_by or "date" }} />
<input name="q" type="text" placeholder="Search topics" value="{{ query or ''}}">
<input class="btn btn-secondary my-2 my-sm-0 mr-sm-2" type="submit" value="Search" />
</form>
{% from "macros/topics.html" import render_topics_table %}
{{ render_topics_table(topics) }}
{{ render_topics_table(topics, show_discard=True, current_user=current_user) }}
<ul class="pagination mt-4">
<li class="page-item {% if not prev_url %}disabled{% endif %}">
<a class="page-link" {% if prev_url %}href="{{ prev_url }}"{% endif %}>&laquo;</a>
</li>
{% for i in range(1, page_max+1) %}
<li class="page-item {% if i == page %}active{% endif %}">
<a class="page-link"
href="{{ url_for('todo_topics_page', page=i, query=query, show_discarded=show_discarded, n=n, sort=sort_by) }}">
{{ i }}
</a>
</li>
{% endfor %}
<li class="page-item {% if not next_url %}disabled{% endif %}">
<a class="page-link" {% if next_url %}href="{{ next_url }}"{% endif %}>&raquo;</a>
</li>
</ul>
{% endblock %}
{% block scriptextra %}
<script>
var csrf_token = "{{ csrf_token() }}";
</script>
<script src="/static/topic_discard.js"></script>
{% endblock %}

View File

@@ -5,10 +5,10 @@ Creating an Account
{% endblock %}
{% block content %}
<div class="box box_grey">
<h2>{{ self.title() }}</h2>
<div class="card">
<h2 class="card-header">{{ self.title() }}</h2>
<div class="box-body">
<div class="card-body">
<p>
If you have a forum account, you'll need to prove that you own it
to get an account on ContentDB.
@@ -19,7 +19,7 @@ Creating an Account
Please log out to continue.
</p>
<p>
<a href="{{ url_for('user.logout', next=url_for('user_claim_page')) }}" class="button">Logout</a>
<a href="{{ url_for('user.logout', next=url_for('user_claim_page')) }}" class="btn">Logout</a>
</p>
{% else %}
<p>
@@ -28,7 +28,7 @@ Creating an Account
out of the Minetest community.
</p>
<a href="https://forum.minetest.net/ucp.php?mode=register">
<a class="btn btn-primary" href="https://forum.minetest.net/ucp.php?mode=register">
Create a Forum Account
</a>
{% endif %}
@@ -36,18 +36,23 @@ Creating an Account
</div>
{% if not current_user.is_authenticated %}
<div class="box box_grey">
<h2>Option 1 - Use GitHub field in forum profile</h2>
<div class="row mt-4">
<div class="col-sm-4">
<div class="card">
<div class="card-header">
<span class="badge badge-pill badge-dark mr-2">Option 1</span>
Use GitHub field in forum profile
</div>
<form method="post" class="box-body" action="{{ url_for('user_claim_page') }}">
<input type="hidden" name="claim_type" value="github">
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}" />
<form method="post" class="card-body" action="{{ url_for('user_claim_page') }}">
<input class="form-control" type="hidden" name="claim_type" value="github">
<input class="form-control" type="hidden" name="csrf_token" value="{{ csrf_token() }}" />
<p>
Enter your forum username here:
</p>
<input type="text" name="username" value="{{ username }}" required placeholder="Forum username">
<input class="form-control my-4" type="text" name="username" value="{{ username }}" required placeholder="Forum username">
<p>
You'll need to have the GitHub field in your forum profile
@@ -56,14 +61,19 @@ Creating an Account
do that here</a>.
</p>
<input type="submit" value="Next: log in with GitHub">
<input class="btn btn-primary" type="submit" value="Next: log in with GitHub">
</form>
</div>
</div>
<div class="box box_grey">
<h2>Option 2 - Paste verification token into signature</h2>
<div class="col-sm-4">
<div class="card">
<div class="card-header">
<span class="badge badge-pill badge-dark mr-2">Option 2</span>
Verification token
</div>
<form method="post" class="box-body" action="{{ url_for('user_claim_page') }}">
<form method="post" class="card-body" action="{{ url_for('user_claim_page') }}">
<input type="hidden" name="claim_type" value="forum">
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}" />
@@ -71,7 +81,7 @@ Creating an Account
Enter your forum username here:
</p>
<input type="text" name="username" value="{{ username }}" required placeholder="Forum username">
<input class="form-control my-3" type="text" name="username" value="{{ username }}" required placeholder="Forum username">
<p>
Go to
@@ -79,11 +89,12 @@ Creating an Account
User Control Panel > Profile > Edit signature
</a>
</p>
<p>
Paste this into your signature:
</p>
<input type="text" value="{{ key }}" readonly size=32>
<input class="form-control my-3" type="text" value="{{ key }}" readonly size=32>
<p>
Click next so we can check it.
@@ -92,15 +103,20 @@ Creating an Account
Don't worry, you can remove it after this is done.
</p>
<input type="submit" value="Next">
<input class="btn btn-primary" type="submit" value="Next">
</form>
</div>
</div>
<div class="box box_grey">
<h2>Option 3 - Email/password sign up</h2>
<div class="col-sm-4">
<div class="card">
<div class="card-header">
<span class="badge badge-pill badge-dark mr-2">Option 3</span>
Email/password sign up
</div>
<div class="box-body">
<p>
<div class="card-body">
<p class="alert alert-danger">
<b>Only do this if you don't have a forum account!</b>
</p>
<p>
@@ -108,8 +124,10 @@ Creating an Account
options.
</p>
<a class="button" href="{{ url_for('user.register') }}">Register</a>
<a class="btn btn-primary" href="{{ url_for('user.register') }}">Register</a>
</div>
</div>
</div>
</div>
{% endif %}
{% endblock %}

View File

@@ -7,7 +7,7 @@
{% block content %}
{% if optional %}
<div class="box box_grey alert alert-primary">
<div class="alert alert-primary">
It is recommended that you set a password for your account.
<a class="alert_right button" href="{{ url_for('home_page') }}">Skip</a>

View File

@@ -7,72 +7,112 @@
{% block content %}
{% if not current_user.is_authenticated and user.rank == user.rank.NOT_JOINED and user.forums_username %}
<div class="box box_grey alert alert-info">
Is this you? Claim your account now!
<div class="alert alert-info alert alert-info">
<a class="float-right btn btn-default btn-sm"
href="{{ url_for('user_claim_page', username=user.forums_username) }}">Claim</a>
<a class="alert_right button" href="{{ url_for('user_claim_page', username=user.forums_username) }}">Claim</a>
Is this you? Claim your account now!
</div>
{% endif %}
<div class="box box_grey">
<h2>{{ user.display_name }}</h2>
<table class="box-body">
<tr>
<td>Rank:</td>
<td>
{{ user.rank.getTitle() }}
</td>
</tr>
<tr>
<td>Accounts:</td>
<td>
{% if user.forums_username %}
<a href="https://forum.minetest.net/memberlist.php?mode=viewprofile&un={{ user.forums_username }}">
Minetest Forum
</a>
{% elif user == current_user %}
No forum account
{% endif %}
{% if (user.forums_username and user.github_username) or user == current_user %}
|
{% endif %}
{% if user.github_username %}
<a href="https://github.com/{{ user.github_username }}">GitHub</a>
{% elif user == current_user %}
<a href="{{ url_for('github_signin_page') }}">Link Github</a>
{% endif %}
{% if user == current_user %}
&#x1f30e;
{% endif %}
</td>
</tr>
{% if user == current_user %}
<tr>
<td>Password:</td>
<td>
{% if user.password %}
Set | <a href="{{ url_for('user.change_password') }}">Change</a>
{% else %}
Not set | <a href="{{ url_for('set_password_page') }}">Set</a>
<div class="row mb-3">
<div class="col-sm-6">
<div class="card">
<h2 class="card-header">{{ user.display_name }}</h2>
<div class="card-body row">
<div class="col-md-2">
{% if user.forums_username %}
<a href="https://forum.minetest.net/ucp.php?i=profile&mode=avatar">
{% elif user.email %}
<a href="https://en.gravatar.com/">
{% endif %}
</td>
</tr>
{% endif %}
</table>
</div>
<img class="img-responsive user-photo img-thumbnail img-thumbnail-1" src="{{ user.getProfilePicURL() }}">
{% if user.forums_username or user.email %}
</a>
{% endif %}
</div>
<div class="col">
<table class="table">
<tr>
<td>Rank:</td>
<td>
{{ user.rank.getTitle() }}
</td>
</tr>
<tr>
<td>Accounts:</td>
<td>
{% if user.forums_username %}
<a href="https://forum.minetest.net/memberlist.php?mode=viewprofile&un={{ user.forums_username }}">
Minetest Forum
</a>
{% elif user == current_user %}
No forum account
{% endif %}
{% if (user.forums_username and user.github_username) or user == current_user %}
|
{% endif %}
{% if user.github_username %}
<a href="https://github.com/{{ user.github_username }}">GitHub</a>
{% elif user == current_user %}
<a href="{{ url_for('github_signin_page') }}">Link Github</a>
{% endif %}
{% if user == current_user %}
&#x1f30e;
{% endif %}
</td>
</tr>
{% if user == current_user %}
<tr>
<td>Profile Picture:</td>
<td>
{% if user.forums_username %}
<form method="post" action="{{ url_for('user_check', username=user.username) }}" class="" style="display:inline-block;">
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}" />
<input type="submit" class="btn btn-primary" value="Sync with Forums" />
</form>
{% endif %}
{% if user.email %}
<a class="btn btn-primary" href="https://en.gravatar.com/">
Gravatar
</a>
{% else %}
<a class="btn btn-primary disabled"
data-toggle="tooltip" data-placement="bottom"
title="Please add an email address to use Gravatar"
style="pointer-events: all;">
Gravatar
</a>
{% endif %}
</td>
</tr>
<tr>
<td>Password:</td>
<td>
{% if user.password %}
Set | <a href="{{ url_for('user.change_password') }}">Change</a>
{% else %}
Not set | <a href="{{ url_for('set_password_page') }}">Set</a>
{% endif %}
</td>
</tr>
{% endif %}
</table>
</div>
</div>
</div>
</div>
{% if form %}
{% from "macros/forms.html" import render_field, render_submit_field %}
<div class="box box_grey">
<h2>Edit Details</h2>
<form action="" method="POST" class="form box-body" role="form">
<div class="row">
<div class="col-sm-6 col-md-5 col-lg-4">
<div class="col-sm-6">
<div class="card">
<div class="card-header">Edit Details</div>
<div class="card-body">
<form action="" method="POST" class="form box-body" role="form">
{{ form.hidden_tag() }}
{% if user.checkPerm(current_user, "CHANGE_DNAME") %}
@@ -89,28 +129,41 @@
{% endif %}
{{ render_submit_field(form.submit, tabindex=280) }}
</div>
</form>
</div>
</form>
</div>
</div>
{% endif %}
</div>
{% from "macros/packagegridtile.html" import render_pkggrid %}
{{ render_pkggrid(packages, show_author=False) }}
{% if topics_to_add %}
<div class="box box_grey">
<h2>Unadded Packages</h2>
{% if current_user == user or (current_user.is_authenticated and current_user.rank.atLeast(current_user.rank.EDITOR)) %}
<div class="card mt-3">
<a name="unadded-topics"></a>
<h2 class="card-header">Unadded topics</h2>
<div class="box-body">
<p>
{% if topics_to_add %}
<p class="card-body">
List of your forum topics which do not have a matching package.
Topics with a strikethrough have been marked as discarded.
</p>
{% from "macros/topics.html" import render_topics_table %}
{{ render_topics_table(topics_to_add, show_author=False) }}
</div>
{{ render_topics_table(topics_to_add, show_author=False, show_discard=True, current_user=current_user) }}
{% else %}
<p class="card-body">Congrats! You don't have any topics which aren't on CDB.</p>
{% endif %}
</div>
{% endif %}
{% endblock %}
{% block scriptextra %}
<script>
var csrf_token = "{{ csrf_token() }}";
</script>
<script src="/static/topic_discard.js"></script>
{% endblock %}

View File

@@ -68,7 +68,10 @@ def make_flask_user_password(plaintext_str):
import bcrypt
plaintext = plaintext_str.encode("UTF-8")
password = bcrypt.hashpw(plaintext, bcrypt.gensalt())
return password.decode("UTF-8")
if isinstance(password, str):
return password
else:
return password.decode("UTF-8")
def _do_login_user(user, remember_me=False):
def _call_or_get(v):

View File

@@ -18,11 +18,8 @@
from app import app, pages
from flask import *
from flask_user import *
from flask_login import login_user, logout_user
from app.models import *
import flask_menu as menu
from flask.ext import markdown
from sqlalchemy import func
from werkzeug.contrib.cache import SimpleCache
from urllib.parse import urlparse
cache = SimpleCache()
@@ -35,6 +32,10 @@ def throw(err):
def domain(url):
return urlparse(url).netloc
@app.template_filter()
def date(value):
return value.strftime("%Y-%m-%d")
@app.template_filter()
def datetime(value):
return value.strftime("%Y-%m-%d %H:%M") + " UTC"
@@ -48,9 +49,12 @@ def send_upload(path):
def home_page():
query = Package.query.filter_by(approved=True, soft_deleted=False)
count = query.count()
new = query.order_by(db.desc(Package.created_at)).limit(15).all()
popular = query.order_by(db.desc(Package.score)).limit(6).all()
return render_template("index.html", new=new, popular=popular, count=count)
new = query.order_by(db.desc(Package.created_at)).limit(8).all()
pop_mod = query.filter_by(type=PackageType.MOD).order_by(db.desc(Package.score)).limit(8).all()
pop_gam = query.filter_by(type=PackageType.GAME).order_by(db.desc(Package.score)).limit(4).all()
pop_txp = query.filter_by(type=PackageType.TXP).order_by(db.desc(Package.score)).limit(4).all()
return render_template("index.html", count=count, \
new=new, pop_mod=pop_mod, pop_txp=pop_txp, pop_gam=pop_gam)
from . import users, githublogin, packages, meta, threads, api
from . import tasks, admin, notifications, tagseditor, licenseseditor

View File

@@ -17,12 +17,12 @@
from flask import *
from flask_user import *
from flask.ext import menu
import flask_menu as menu
from app import app
from app.models import *
from celery import uuid
from app.tasks.importtasks import importRepoScreenshot, importAllDependencies, makeVCSRelease
from app.tasks.forumtasks import importTopicList
from app.tasks.forumtasks import importTopicList, checkAllForumAccounts
from flask_wtf import FlaskForm
from wtforms import *
from app.utils import loginUser, rank_required, triggerNotif
@@ -36,6 +36,9 @@ def admin_page():
if action == "importmodlist":
task = importTopicList.delay()
return redirect(url_for("check_task", id=task.id, r=url_for("todo_topics_page")))
elif action == "checkusers":
task = checkAllForumAccounts.delay()
return redirect(url_for("check_task", id=task.id, r=url_for("admin_page")))
elif action == "importscreenshots":
packages = Package.query \
.filter_by(soft_deleted=False) \

View File

@@ -19,7 +19,7 @@ from flask import *
from flask_user import *
from app import app
from app.models import *
from app.utils import is_package_page
from app.utils import is_package_page, rank_required
from .packages import QueryBuilder
@app.route("/api/packages/")
@@ -43,3 +43,21 @@ def api_topics_page():
.order_by(db.asc(ForumTopic.wip), db.asc(ForumTopic.name), db.asc(ForumTopic.title))
pkgs = [t.getAsDictionary() for t in query.all()]
return jsonify(pkgs)
@app.route("/api/topic_discard/", methods=["POST"])
@login_required
def topic_set_discard():
tid = request.args.get("tid")
discard = request.args.get("discard")
if tid is None or discard is None:
abort(400)
topic = ForumTopic.query.get(tid)
if not topic.checkPerm(current_user, Permission.TOPIC_DISCARD):
abort(403)
topic.discarded = discard == "true"
db.session.commit()
return jsonify(topic.getAsDictionary())

View File

@@ -17,7 +17,7 @@
from flask import *
from flask_user import *
from flask.ext import menu
import flask_menu as menu
from app import app
from app.models import *
from app.tasks.importtasks import importRepoScreenshot, makeVCSRelease
@@ -30,6 +30,7 @@ from wtforms import *
from wtforms.validators import *
from wtforms.ext.sqlalchemy.fields import QuerySelectField, QuerySelectMultipleField
from sqlalchemy import or_, any_
from sqlalchemy.sql.expression import func
class QueryBuilder:
@@ -50,9 +51,12 @@ class QueryBuilder:
self.title = title
self.types = types
self.search = request.args.get("q")
self.lucky = "lucky" in request.args
self.random = "random" in request.args
self.lucky = self.random or "lucky" in request.args
self.hide_nonfree = isNo(request.args.get("nonfree"))
self.limit = 1 if self.lucky else None
self.order_by = request.args.get("sort") or "score"
self.order_dir = request.args.get("order") or "desc"
def buildPackageQuery(self):
query = Package.query.filter_by(soft_deleted=False, approved=True)
@@ -63,7 +67,25 @@ class QueryBuilder:
if self.search is not None and self.search.strip() != "":
query = query.filter(Package.title.ilike('%' + self.search + '%'))
query = query.order_by(db.desc(Package.score))
if self.random:
query = query.order_by(func.random())
else:
to_order = None
if self.order_by == "score":
to_order = Package.score
elif self.order_by == "created_at":
to_order = Package.created_at
else:
abort(400)
if self.order_dir == "asc":
to_order = db.asc(to_order)
elif self.order_dir == "desc":
to_order = db.desc(to_order)
else:
abort(400)
query = query.order_by(to_order)
if self.hide_nonfree:
query = query.filter(Package.license.has(License.is_foss == True))
@@ -95,6 +117,7 @@ class QueryBuilder:
@menu.register_menu(app, ".mods", "Mods", order=11, endpoint_arguments_constructor=lambda: { 'type': 'mod' })
@menu.register_menu(app, ".games", "Games", order=12, endpoint_arguments_constructor=lambda: { 'type': 'game' })
@menu.register_menu(app, ".txp", "Texture Packs", order=13, endpoint_arguments_constructor=lambda: { 'type': 'txp' })
@menu.register_menu(app, ".random", "Random", order=14, endpoint_arguments_constructor=lambda: { 'random': '1' })
@app.route("/packages/")
def packages_page():
if shouldReturnJson():
@@ -110,11 +133,11 @@ def packages_page():
return redirect(package.getDetailsURL())
topic = qb.buildTopicQuery().first()
if topic:
if qb.search and topic:
return redirect("https://forum.minetest.net/viewtopic.php?t=" + str(topic.topic_id))
page = int(request.args.get("page") or 1)
num = min(42, int(request.args.get("n") or 100))
num = min(40, int(request.args.get("n") or 100))
query = query.paginate(page, num, True)
search = request.args.get("q")
@@ -151,10 +174,11 @@ def package_page(package):
alternatives = None
if package.type == PackageType.MOD:
alternatives = Package.query \
.filter_by(name=package.name, type=PackageType.MOD, soft_deleted=False) \
.filter(Package.id != package.id) \
.order_by(db.asc(Package.title)) \
.all()
.filter_by(name=package.name, type=PackageType.MOD, soft_deleted=False) \
.filter(Package.id != package.id) \
.order_by(db.desc(Package.score)) \
.all()
show_similar_topics = current_user == package.author or \
package.checkPerm(current_user, Permission.APPROVE_NEW)
@@ -180,13 +204,13 @@ def package_page(package):
errors = []
if Package.query.filter_by(forums=package.forums, soft_deleted=False).count() > 1:
errors.append("<b>Error: Another package already uses this forum topic!</b>")
topic_error_lvl = "error"
topic_error_lvl = "danger"
topic = ForumTopic.query.get(package.forums)
if topic is not None:
if topic.author != package.author:
errors.append("<b>Error: Forum topic author doesn't match package author.</b>")
topic_error_lvl = "error"
topic_error_lvl = "danger"
if topic.wip:
errors.append("Warning: Forum topic is in WIP section, make sure package meets playability standards.")
@@ -236,8 +260,8 @@ class PackageForm(FlaskForm):
media_license = QuerySelectField("Media License", [InputRequired()], query_factory=lambda: License.query.order_by(db.asc(License.name)), get_pk=lambda a: a.id, get_label=lambda a: a.name)
provides_str = StringField("Provides (mods included in package)", [Optional(), Length(0,1000)])
tags = QuerySelectMultipleField('Tags', query_factory=lambda: Tag.query.order_by(db.asc(Tag.name)), get_pk=lambda a: a.id, get_label=lambda a: a.title)
harddep_str = StringField("Hard Dependencies", [Optional(), Length(0,1000)])
softdep_str = StringField("Soft Dependencies", [Optional(), Length(0,1000)])
harddep_str = StringField("Hard Dependencies", [Optional()])
softdep_str = StringField("Soft Dependencies", [Optional()])
repo = StringField("VCS Repository URL", [Optional(), URL()])
website = StringField("Website URL", [Optional(), URL()])
issueTracker = StringField("Issue Tracker URL", [Optional(), URL()])
@@ -378,25 +402,44 @@ def approve_package_page(package):
return redirect(package.getDetailsURL())
@app.route("/packages/<author>/<name>/delete/", methods=["GET", "POST"])
@app.route("/packages/<author>/<name>/remove/", methods=["GET", "POST"])
@login_required
@is_package_page
def delete_package_page(package):
def remove_package_page(package):
if request.method == "GET":
return render_template("packages/delete.html", package=package)
return render_template("packages/remove.html", package=package)
if not package.checkPerm(current_user, Permission.DELETE_PACKAGE):
flash("You don't have permission to do that.", "error")
if "delete" in request.form:
if not package.checkPerm(current_user, Permission.DELETE_PACKAGE):
flash("You don't have permission to do that.", "error")
return redirect(package.getDetailsURL())
package.soft_deleted = True
package.soft_deleted = True
url = url_for("user_profile_page", username=package.author.username)
triggerNotif(package.author, current_user,
"{} deleted".format(package.title), url)
db.session.commit()
url = url_for("user_profile_page", username=package.author.username)
triggerNotif(package.author, current_user,
"{} deleted".format(package.title), url)
db.session.commit()
flash("Deleted package", "success")
flash("Deleted package", "success")
return redirect(url)
elif "unapprove" in request.form:
if not package.checkPerm(current_user, Permission.UNAPPROVE_PACKAGE):
flash("You don't have permission to do that.", "error")
return redirect(package.getDetailsURL())
package.approved = False
triggerNotif(package.author, current_user,
"{} deleted".format(package.title), package.getDetailsURL())
db.session.commit()
flash("Unapproved package", "success")
return redirect(package.getDetailsURL())
else:
abort(400)
return redirect(url)
from . import todo, screenshots, releases

View File

@@ -17,7 +17,6 @@
from flask import *
from flask_user import *
from flask.ext import menu
from app import app
from app.models import *

View File

@@ -17,7 +17,6 @@
from flask import *
from flask_user import *
from flask.ext import menu
from app import app
from app.models import *
from app.tasks.importtasks import makeVCSRelease

View File

@@ -17,7 +17,7 @@
from flask import *
from flask_user import *
from flask.ext import menu
import flask_menu as menu
from app import app
from app.models import *
@@ -43,6 +43,7 @@ def todo_page():
topics_to_add = ForumTopic.query \
.filter(~ db.exists().where(Package.forums==ForumTopic.topic_id)) \
.filter_by(discarded=False) \
.count()
return render_template("todo/list.html", title="Reports and Work Queue",
@@ -54,11 +55,45 @@ def todo_page():
@app.route("/todo/topics/")
@login_required
def todo_topics_page():
total = ForumTopic.query.count()
query = ForumTopic.query
topics = ForumTopic.query \
.filter(~ db.exists().where(Package.forums==ForumTopic.topic_id)) \
.order_by(db.asc(ForumTopic.wip), db.asc(ForumTopic.name), db.asc(ForumTopic.title)) \
.all()
show_discarded = request.args.get("show_discarded") == "True"
if not show_discarded:
query = query.filter_by(discarded=False)
return render_template("todo/topics.html", topics=topics, total=total)
total = query.count()
query = query.filter(~ db.exists().where(Package.forums==ForumTopic.topic_id)) \
sort_by = request.args.get("sort")
if sort_by == "name":
query = query.order_by(db.asc(ForumTopic.wip), db.asc(ForumTopic.name), db.asc(ForumTopic.title))
elif sort_by == "views":
query = query.order_by(db.desc(ForumTopic.views))
elif sort_by is None or sort_by == "date":
query = query.order_by(db.asc(ForumTopic.created_at))
sort_by = "date"
topic_count = query.count()
search = request.args.get("q")
if search is not None and search.strip() != "":
query = query.filter(ForumTopic.title.ilike('%' + search + '%'))
page = int(request.args.get("page") or 1)
num = int(request.args.get("n") or 100)
if num > 100 and not current_user.rank.atLeast(UserRank.EDITOR):
num = 100
query = query.paginate(page, num, True)
next_url = url_for("todo_topics_page", page=query.next_num, query=search, \
show_discarded=show_discarded, n=num, sort=sort_by) \
if query.has_next else None
prev_url = url_for("todo_topics_page", page=query.prev_num, query=search, \
show_discarded=show_discarded, n=num, sort=sort_by) \
if query.has_prev else None
return render_template("todo/topics.html", topics=query.items, total=total, \
topic_count=topic_count, query=search, show_discarded=show_discarded, \
next_url=next_url, prev_url=prev_url, page=page, page_max=query.pages, \
n=num, sort_by=sort_by)

View File

@@ -17,7 +17,7 @@
from flask import *
from flask_user import *
from flask.ext import menu
import flask_menu as menu
from app import app, csrf
from app.models import *
from app.tasks import celery, TaskError

View File

@@ -21,7 +21,7 @@ from app import app
import os
from PIL import Image
ALLOWED_RESOLUTIONS=[(350,233)]
ALLOWED_RESOLUTIONS=[(100,67), (270,180), (350,233)]
def mkdir(path):
if not os.path.isdir(path):
@@ -56,15 +56,17 @@ def resize_and_crop(img_path, modified_path, size):
img.save(modified_path)
@app.route("/thumbnails/<img>")
@app.route("/thumbnails/<int:w>x<int:h>/<img>")
def make_thumbnail(img, w=350, h=233):
if not (w, h) in ALLOWED_RESOLUTIONS:
@app.route("/thumbnails/<int:level>/<img>")
def make_thumbnail(img, level):
if level > len(ALLOWED_RESOLUTIONS) or level <= 0:
abort(403)
mkdir("app/public/thumbnails/{}x{}/".format(w, h))
w, h = ALLOWED_RESOLUTIONS[level - 1]
cache_filepath = "public/thumbnails/{}x{}/{}".format(w, h, img)
mkdir("app/public/thumbnails/{:d}/".format(level))
cache_filepath = "public/thumbnails/{:d}/{}".format(level, img)
source_filepath = "public/uploads/" + img
resize_and_crop("app/" + source_filepath, "app/" + cache_filepath, (w, h))

View File

@@ -18,14 +18,12 @@
from flask import *
from flask_user import *
from flask_login import login_user, logout_user
from flask.ext import menu
from app import app
from app.models import *
from flask_wtf import FlaskForm
from flask_user.forms import RegisterForm
from wtforms import *
from wtforms.validators import *
from app.utils import rank_required, randomString, loginUser
from app.utils import randomString, loginUser
from app.tasks.forumtasks import checkForumAccount
from app.tasks.emails import sendVerifyEmail
from app.tasks.phpbbparser import getProfile
@@ -108,6 +106,26 @@ def user_profile_page(username):
return render_template("users/user_profile_page.html",
user=user, form=form, packages=packages, topics_to_add=topics_to_add)
@app.route("/users/<username>/check/", methods=["POST"])
@login_required
def user_check(username):
user = User.query.filter_by(username=username).first()
if user is None:
abort(404)
if current_user != user and not current_user.rank.atLeast(UserRank.MODERATOR):
abort(403)
if user.forums_username is None:
abort(404)
task = checkForumAccount.delay(user.forums_username)
next_url = url_for("user_profile_page", username=username)
return redirect(url_for("check_task", id=task.id, r=next_url))
class SetPasswordForm(FlaskForm):
email = StringField("Email", [Optional(), Email()])
password = PasswordField("New password", [InputRequired(), Length(2, 20)])

View File

@@ -0,0 +1,23 @@
"""empty message
Revision ID: a791b9b74a4c
Revises: 44e138485931
Create Date: 2018-12-23 23:52:02.010281
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = 'a791b9b74a4c'
down_revision = '44e138485931'
branch_labels = None
depends_on = None
def upgrade():
op.add_column('forum_topic', sa.Column('discarded', sa.Boolean(), server_default='0', nullable=True))
def downgrade():
op.drop_column('forum_topic', 'discarded')

View File

@@ -0,0 +1,28 @@
"""empty message
Revision ID: dce69ad1e4eb
Revises: a791b9b74a4c
Create Date: 2018-12-25 18:57:44.575501
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = 'dce69ad1e4eb'
down_revision = 'a791b9b74a4c'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.add_column("user", sa.Column('profile_pic', sa.String(length=255), nullable=True))
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_column("user", "profile_pic")
# ### end Alembic commands ###

View File

@@ -1,16 +1,18 @@
Flask>=0.12.2,<1.0
Flask-SQLAlchemy>=2.3
Flask-Login>=0.4.1
Flask-User==0.6.19
Flask-Menu>=0.7.0
Flask-Markdown>=0.3
GitHub-Flask>=3.2.0
pyScss==1.3.4
celery==4.1.1
redis==2.10.6
beautifulsoup4==4.6.0
lxml==4.2.1
Flask-FlatPages==0.6
Flask-Migrate==2.1.1
pillow==5.1.0
GitPython==2.1.10
Flask~=1.0
Flask-FlatPages~=0.7
Flask-Gravatar~=0.5
Flask-Login~=0.4.1
Flask-Markdown~=0.3
Flask-Menu~=0.7
Flask-Migrate~=2.3
Flask-SQLAlchemy~=2.3
Flask-User~=0.6
GitHub-Flask~=3.2
beautifulsoup4~=4.6
celery~=4.2
GitPython~=2.1
lxml~=4.2
pillow~=5.3
pyScss~=1.3
redis~=3.0