diff options
-rw-r--r-- | app/models.py | 11 | ||||
-rw-r--r-- | app/public/static/package_create.js | 31 | ||||
-rw-r--r-- | app/templates/macros/topictable.html | 26 | ||||
-rw-r--r-- | app/templates/todo/topics.html | 21 | ||||
-rw-r--r-- | app/templates/users/user_profile_page.html | 20 | ||||
-rw-r--r-- | app/views/packages/__init__.py | 15 |
6 files changed, 64 insertions, 60 deletions
diff --git a/app/models.py b/app/models.py index a50c4d0..7f0d8f3 100644 --- a/app/models.py +++ b/app/models.py @@ -659,6 +659,10 @@ class EditRequestChange(db.Model): 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): topic_id = db.Column(db.Integer, primary_key=True, autoincrement=False) @@ -676,6 +680,13 @@ class KrockForumTopic(db.Model): elif self.ttype == 6: 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 db_adapter = SQLAlchemyAdapter(db, User) # Register the User model diff --git a/app/public/static/package_create.js b/app/public/static/package_create.js index 36d1853..86c5140 100644 --- a/app/public/static/package_create.js +++ b/app/public/static/package_create.js @@ -9,20 +9,11 @@ $(function() { $(".pkg_meta").show() } - function repoIsSupported(url) { - // try { - // return URI(url).hostname() == "github.com" - // } catch(e) { - // return false - // } - return true - } - $(".pkg_meta").hide() $(".pkg_wiz_1").show() $("#pkg_wiz_1_next").click(function() { const repoURL = $("#repo").val(); - if (repoIsSupported(repoURL)) { + if (repoURL.trim() != "") { $(".pkg_wiz_1").hide() $(".pkg_wiz_2").show() $(".pkg_repo").hide() @@ -36,22 +27,22 @@ $(function() { } performTask("/tasks/getmeta/new/?url=" + encodeURI(repoURL)).then(function(result) { - $("#name").val(result.name || "") - setSpecial("#provides_str", result.provides || "") - $("#title").val(result.title || "") + $("#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 || "") + $("#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) } if (result.type && result.type.length > 2) { - $("#type").val(result.type); + $("#type").val(result.type) } finish() diff --git a/app/templates/macros/topictable.html b/app/templates/macros/topictable.html new file mode 100644 index 0000000..43324fa --- /dev/null +++ b/app/templates/macros/topictable.html @@ -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 %} diff --git a/app/templates/todo/topics.html b/app/templates/todo/topics.html index 77f32c0..f53c4eb 100644 --- a/app/templates/todo/topics.html +++ b/app/templates/todo/topics.html @@ -12,23 +12,6 @@ Topics to be Added {{ topics | count }} remaining. </p> - <table> - <tr> - <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> + {% from "macros/topictable.html" import render_topictable %} + {{ render_topictable(topics) }} {% endblock %} diff --git a/app/templates/users/user_profile_page.html b/app/templates/users/user_profile_page.html index 5c5113b..636a610 100644 --- a/app/templates/users/user_profile_page.html +++ b/app/templates/users/user_profile_page.html @@ -108,22 +108,10 @@ Powered by Krock's Mod Search. </p> - <table> - <tr> - <th>Id</th> - <th>Title</th> - <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> + + + {% from "macros/topictable.html" import render_topictable %} + {{ render_topictable(topics_to_add, show_author=False) }} </div> </div> {% endif %} diff --git a/app/views/packages/__init__.py b/app/views/packages/__init__.py index a486445..a27c468 100644 --- a/app/views/packages/__init__.py +++ b/app/views/packages/__init__.py @@ -180,11 +180,16 @@ def create_edit_package_page(author=None, name=None): form = PackageForm(formdata=request.form, obj=package) # Initial form class from post data and default data - if request.method == "GET" and package is not None: - 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 == "GET": + if package is None: + form.repo.data = request.args.get("repo") + form.title.data = request.args.get("title") + 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(): wasNew = False |