mirror of
https://github.com/minetest/contentdb.git
synced 2025-03-22 10:12:28 +01:00
Add create links to topic table
This commit is contained in:
@ -659,6 +659,10 @@ class EditRequestChange(db.Model):
|
|||||||
setattr(package, self.key.name, self.newValue)
|
setattr(package, self.key.name, self.newValue)
|
||||||
|
|
||||||
|
|
||||||
|
REPO_BLACKLIST = [".zip", "mediafire.com", "dropbox.com", "weebly.com", \
|
||||||
|
"minetest.net", "dropboxusercontent.com", "4shared.com", \
|
||||||
|
"digitalaudioconcepts.com", "hg.intevation.org", "www.wtfpl.net", \
|
||||||
|
"imageshack.com", "imgur.com"]
|
||||||
|
|
||||||
class KrockForumTopic(db.Model):
|
class KrockForumTopic(db.Model):
|
||||||
topic_id = db.Column(db.Integer, primary_key=True, autoincrement=False)
|
topic_id = db.Column(db.Integer, primary_key=True, autoincrement=False)
|
||||||
@ -676,6 +680,13 @@ class KrockForumTopic(db.Model):
|
|||||||
elif self.ttype == 6:
|
elif self.ttype == 6:
|
||||||
return PackageType.GAME
|
return PackageType.GAME
|
||||||
|
|
||||||
|
def getRepoURL(self):
|
||||||
|
for item in REPO_BLACKLIST:
|
||||||
|
if item in self.link:
|
||||||
|
return None
|
||||||
|
|
||||||
|
return self.link.replace("repo.or.cz/w/", "repo.or.cz/")
|
||||||
|
|
||||||
|
|
||||||
# Setup Flask-User
|
# Setup Flask-User
|
||||||
db_adapter = SQLAlchemyAdapter(db, User) # Register the User model
|
db_adapter = SQLAlchemyAdapter(db, User) # Register the User model
|
||||||
|
@ -9,20 +9,11 @@ $(function() {
|
|||||||
$(".pkg_meta").show()
|
$(".pkg_meta").show()
|
||||||
}
|
}
|
||||||
|
|
||||||
function repoIsSupported(url) {
|
|
||||||
// try {
|
|
||||||
// return URI(url).hostname() == "github.com"
|
|
||||||
// } catch(e) {
|
|
||||||
// return false
|
|
||||||
// }
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
$(".pkg_meta").hide()
|
$(".pkg_meta").hide()
|
||||||
$(".pkg_wiz_1").show()
|
$(".pkg_wiz_1").show()
|
||||||
$("#pkg_wiz_1_next").click(function() {
|
$("#pkg_wiz_1_next").click(function() {
|
||||||
const repoURL = $("#repo").val();
|
const repoURL = $("#repo").val();
|
||||||
if (repoIsSupported(repoURL)) {
|
if (repoURL.trim() != "") {
|
||||||
$(".pkg_wiz_1").hide()
|
$(".pkg_wiz_1").hide()
|
||||||
$(".pkg_wiz_2").show()
|
$(".pkg_wiz_2").show()
|
||||||
$(".pkg_repo").hide()
|
$(".pkg_repo").hide()
|
||||||
@ -36,22 +27,22 @@ $(function() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
performTask("/tasks/getmeta/new/?url=" + encodeURI(repoURL)).then(function(result) {
|
performTask("/tasks/getmeta/new/?url=" + encodeURI(repoURL)).then(function(result) {
|
||||||
$("#name").val(result.name || "")
|
$("#name").val(result.name)
|
||||||
setSpecial("#provides_str", result.provides || "")
|
setSpecial("#provides_str", result.provides)
|
||||||
$("#title").val(result.title || "")
|
$("#title").val(result.title)
|
||||||
$("#repo").val(result.repo || repoURL)
|
$("#repo").val(result.repo || repoURL)
|
||||||
$("#issueTracker").val(result.issueTracker || "")
|
$("#issueTracker").val(result.issueTracker)
|
||||||
$("#desc").val(result.description || "")
|
$("#desc").val(result.description)
|
||||||
$("#shortDesc").val(result.short_description || "")
|
$("#shortDesc").val(result.short_description)
|
||||||
setSpecial("#harddep_str", result.depends || "")
|
setSpecial("#harddep_str", result.depends)
|
||||||
setSpecial("#softdep_str", result.optional_depends || "")
|
setSpecial("#softdep_str", result.optional_depends)
|
||||||
$("#shortDesc").val(result.short_description || "")
|
$("#shortDesc").val(result.short_description)
|
||||||
if (result.forumId) {
|
if (result.forumId) {
|
||||||
$("#forums").val(result.forumId)
|
$("#forums").val(result.forumId)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (result.type && result.type.length > 2) {
|
if (result.type && result.type.length > 2) {
|
||||||
$("#type").val(result.type);
|
$("#type").val(result.type)
|
||||||
}
|
}
|
||||||
|
|
||||||
finish()
|
finish()
|
||||||
|
26
app/templates/macros/topictable.html
Normal file
26
app/templates/macros/topictable.html
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
{% macro render_topictable(topics, show_author=True) -%}
|
||||||
|
<table>
|
||||||
|
<tr>
|
||||||
|
<th>Id</th>
|
||||||
|
<th>Title</th>
|
||||||
|
{% if show_author %}<th>Author</th>{% endif %}
|
||||||
|
<th>Name</th>
|
||||||
|
<th>Link</th>
|
||||||
|
<th>Actions</th>
|
||||||
|
</tr>
|
||||||
|
{% for topic in topics %}
|
||||||
|
<tr>
|
||||||
|
<td>{{ topic.topic_id }}</td>
|
||||||
|
<td>[{{ topic.getType().value }}] <a href="https://forum.minetest.net/viewtopic.php?t={{ topic.topic_id}}">{{ topic.title }}</a></td>
|
||||||
|
{% if show_author %}
|
||||||
|
<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><a href="{{ topic.link }}">{{ topic.link | domain }}</a></td>
|
||||||
|
<td>
|
||||||
|
<a href="{{ url_for('create_edit_package_page', author=topic.author.username, repo=topic.getRepoURL(), forums=topic.topic_id, title=topic.title) }}">Create</a>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
</table>
|
||||||
|
{% endmacro %}
|
@ -12,23 +12,6 @@ Topics to be Added
|
|||||||
{{ topics | count }} remaining.
|
{{ topics | count }} remaining.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<table>
|
{% from "macros/topictable.html" import render_topictable %}
|
||||||
<tr>
|
{{ render_topictable(topics) }}
|
||||||
<th>Id</th>
|
|
||||||
<th>Title</th>
|
|
||||||
<th>Author</th>
|
|
||||||
<th>Name</th>
|
|
||||||
<th>Link</th>
|
|
||||||
</tr>
|
|
||||||
{% for topic in topics %}
|
|
||||||
<tr>
|
|
||||||
<td>{{ topic.topic_id }}</td>
|
|
||||||
<td>[{{ topic.getType().value }}] <a href="https://forum.minetest.net/viewtopic.php?t={{ topic.topic_id}}">{{ topic.title }}</a></td>
|
|
||||||
<td><a href="{{ url_for('user_profile_page', username=topic.author.username) }}">{{ topic.author.display_name}}</a></td>
|
|
||||||
<td>{{ topic.name or ""}}</td>
|
|
||||||
<td><a href="{{ topic.link }}">{{ topic.link | domain }}</a></td>
|
|
||||||
|
|
||||||
</tr>
|
|
||||||
{% endfor %}
|
|
||||||
</table>
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
@ -108,22 +108,10 @@
|
|||||||
Powered by Krock's Mod Search.
|
Powered by Krock's Mod Search.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<table>
|
|
||||||
<tr>
|
|
||||||
<th>Id</th>
|
{% from "macros/topictable.html" import render_topictable %}
|
||||||
<th>Title</th>
|
{{ render_topictable(topics_to_add, show_author=False) }}
|
||||||
<th>Name</th>
|
|
||||||
<th>Link</th>
|
|
||||||
</tr>
|
|
||||||
{% for topic in topics_to_add %}
|
|
||||||
<tr>
|
|
||||||
<td>{{ topic.topic_id }}</td>
|
|
||||||
<td>[{{ topic.getType().value }}] <a href="https://forum.minetest.net/viewtopic.php?t={{ topic.topic_id}}">{{ topic.title }}</a></td>
|
|
||||||
<td>{{ topic.name or ""}}</td>
|
|
||||||
<td><a href="{{ topic.link }}">{{ topic.link | domain }}</a></td>
|
|
||||||
</tr>
|
|
||||||
{% endfor %}
|
|
||||||
</table>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
@ -180,11 +180,16 @@ def create_edit_package_page(author=None, name=None):
|
|||||||
form = PackageForm(formdata=request.form, obj=package)
|
form = PackageForm(formdata=request.form, obj=package)
|
||||||
|
|
||||||
# Initial form class from post data and default data
|
# Initial form class from post data and default data
|
||||||
if request.method == "GET" and package is not None:
|
if request.method == "GET":
|
||||||
deps = package.dependencies
|
if package is None:
|
||||||
form.harddep_str.data = ",".join([str(x) for x in deps if not x.optional])
|
form.repo.data = request.args.get("repo")
|
||||||
form.softdep_str.data = ",".join([str(x) for x in deps if x.optional])
|
form.title.data = request.args.get("title")
|
||||||
form.provides_str.data = MetaPackage.ListToSpec(package.provides)
|
form.forums.data = request.args.get("forums")
|
||||||
|
else:
|
||||||
|
deps = package.dependencies
|
||||||
|
form.harddep_str.data = ",".join([str(x) for x in deps if not x.optional])
|
||||||
|
form.softdep_str.data = ",".join([str(x) for x in deps if x.optional])
|
||||||
|
form.provides_str.data = MetaPackage.ListToSpec(package.provides)
|
||||||
|
|
||||||
if request.method == "POST" and form.validate():
|
if request.method == "POST" and form.validate():
|
||||||
wasNew = False
|
wasNew = False
|
||||||
|
Reference in New Issue
Block a user