Skip to content

Commit

Permalink
Merge pull request #72 from Thorfusion/dev
Browse files Browse the repository at this point in the history
Update to 1.3.1
  • Loading branch information
maggi373 authored Jun 23, 2024
2 parents 1861a30 + c38129a commit a754912
Show file tree
Hide file tree
Showing 8 changed files with 141 additions and 8 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ solder.py is even compatible with original solder's database, visit the install
+ Clone builds from other modpacks
+ R2 bucket integration with mod uploading, host your files on the cloud!
+ MCIL optional mod tag
+ Generate changelog

# Features to be added in the future

Expand Down Expand Up @@ -61,13 +62,13 @@ mysql

Create a new user

```mysql
```sql
CREATE USER 'solderpy'@'localhost' IDENTIFIED BY 'passwordsecret';
```

Create a database and give the user access to it

```mysql
```sql
CREATE DATABASE solderpy;
GRANT ALL ON solder.* TO 'solderpy'@'localhost';
FLUSH PRIVILEGES;
Expand Down
2 changes: 1 addition & 1 deletion api.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

@api.route("/api/")
def api_info():
return jsonify({"api": "solder.py", "version": "v1.3.0", "stream": "DEV"})
return jsonify({"api": "solder.py", "version": "v1.3.1", "stream": "DEV"})


@api.route("/api/verify")
Expand Down
20 changes: 19 additions & 1 deletion app.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = "1.3.0"
__version__ = "1.3.1"

import os
from dotenv import load_dotenv
Expand Down Expand Up @@ -281,6 +281,10 @@ def modpack(id):
if "marked_submit" in request.form:
Build.update_checkbox_marked(request.form["marked_modid"], request.form["marked_check"])
return redirect(id)
if "changelog_submit" in request.form:
oldversion = request.form["changelog_oldver"]
newversion = request.form["changelog_newver"]
return redirect(url_for("changelog", oldver=oldversion, newver=newversion))
if "deletemod_submit" in request.form:
if "modpack_delete_id" not in request.form:
return redirect(id)
Expand All @@ -289,6 +293,20 @@ def modpack(id):

return render_template("modpack.html", modpack=builds, modpackname=modpack)

@app.route("/changelog/<oldver>-<newver>", methods=["GET", "POST"])
def changelog(oldver, newver):
if "token" not in session or not Session.verify_session(session["token"], request.remote_addr):
# New or invalid session, send to login
return redirect(url_for("login"))

try:
changelog = Build_modversion.get_changelog(oldver, newver)
except connector.ProgrammingError as e:
Database.create_tables()
builds = []

return render_template("changelog.html", changelog=changelog)


@app.route("/mainsettings")
def mainsettings():
Expand Down
11 changes: 9 additions & 2 deletions models/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from .modversion import Modversion

class Build:
def __init__(self, id, modpack_id, version, created_at, updated_at, minecraft, forge, is_published, private, min_java, min_memory, marked):
def __init__(self, id, modpack_id, version, created_at, updated_at, minecraft, forge, is_published, private, min_java, min_memory, marked, count=None):
self.id = id
self.modpack_id = modpack_id
self.version = version
Expand All @@ -17,6 +17,7 @@ def __init__(self, id, modpack_id, version, created_at, updated_at, minecraft, f
self.min_java = min_java
self.min_memory = min_memory
self.marked = marked
self.count = count

@classmethod
def new(cls, modpack_id, version, minecraft, is_published, private, min_java, min_memory, clone_id):
Expand Down Expand Up @@ -99,7 +100,13 @@ def get_by_id(cls, id):
def get_by_modpack(modpack):
conn = Database.get_connection()
cursor = conn.cursor(dictionary=True)
cursor.execute("SELECT * FROM builds WHERE modpack_id = %s", (modpack.id,))
cursor.execute(
"""SELECT builds.*, modcount.count
FROM builds
LEFT JOIN (SELECT build_id, COUNT(*) AS count FROM build_modversion GROUP BY build_id) modcount ON builds.id = modcount.build_id
WHERE modpack_id = %s
"""
, (modpack.id,))
builds = cursor.fetchall()
if builds:
return [Build(**build) for build in builds]
Expand Down
58 changes: 58 additions & 0 deletions models/build_modversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,64 @@ def get_modpack_build(id):
"""
, (id,))
rows = cur.fetchall()
if rows:
return rows
return []

@staticmethod
def get_changelog(previd, id):
conn = Database.get_connection()
cur = conn.cursor(dictionary=True)
cur.execute(
"""SELECT coalesce(build.name1, build.name2) name, build.oldversion,
case
when build.name1 is null then 'added'
when build.name2 is null then 'removed'
when build.name1 is not null AND build.name2 IS NOT NULL THEN 'changed to'
end status, build.newversion
FROM
(
SELECT *
FROM
(
SELECT modversions.version AS oldversion, mods.name AS name1, modversions.id AS modverid
FROM build_modversion
INNER JOIN modversions ON build_modversion.modversion_id = modversions.id
INNER JOIN mods ON modversions.mod_id = mods.id
WHERE build_id = %s
) AS build1
LEFT OUTER JOIN
(
SELECT modversions.version AS newversion, mods.name AS name2, modversions.id AS modverid2
FROM build_modversion
INNER JOIN modversions ON build_modversion.modversion_id = modversions.id
INNER JOIN mods ON modversions.mod_id = mods.id
WHERE build_id = %s
) AS build2 ON build1.name1 = build2.name2 WHERE NOT build1.modverid <=> build2.modverid2
UNION
SELECT *
FROM
(
SELECT modversions.version AS oldversion, mods.name AS name1, modversions.id AS modverid
FROM build_modversion
INNER JOIN modversions ON build_modversion.modversion_id = modversions.id
INNER JOIN mods ON modversions.mod_id = mods.id
WHERE build_id = %s
) AS build1
RIGHT OUTER JOIN
(
SELECT modversions.version AS newversion, mods.name as name2, modversions.id AS modverid2
FROM build_modversion
INNER JOIN modversions ON build_modversion.modversion_id = modversions.id
INNER JOIN mods ON modversions.mod_id = mods.id
WHERE build_id = %s
) AS build2 ON build1.name1 = build2.name2 WHERE NOT build1.modverid <=> build2.modverid2
) AS build ORDER BY status, name
"""
, (previd, id, previd, id,))
rows = cur.fetchall()
if rows:
return rows
return []
35 changes: 35 additions & 0 deletions templates/changelog.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{%extends "layout.html"%} {% set active_page = "modpacklibrary" %} {%block head%}
<title>solder.py</title>
<link rel="stylesheet" href="{{ url_for('static',filename='css/table.css') }}" /> {%endblock%}{%block main%}

<div class="">
<table class="table table-striped table-hover maxheighttable">
<thead class="table-light sticky-md-top">
<tr>
<th scope="col">Mod</th>
<th scope="col">Oldversion</th>
<th scope="col">Status</th>
<th scope="col">Newversion</th>
</tr>
</thead>
<tbody class="">
{%for mod in changelog%}
<tr>
<td>{{mod.name}}</td>
<td>{% if mod.oldversion != None %}{{mod.oldversion}}{% endif %}</td>
<td>{{mod.status}}</td>
<td>{% if mod.newversion != None %}{{mod.newversion}}{% endif %}</td>
</tr>
{%endfor%}
</tbody>
</table>
</div>
{% endblock %}
{%block aside%}

<div class="">

</div>

<script src="{{ url_for('static',filename='js/solderpy.js') }}"></script>
{% endblock %}
2 changes: 1 addition & 1 deletion templates/layout.html
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
</ul>
</nav>
<div class="flex-column flex-shrink-0 p-3 text-white navcontainer2">
<p class="">Version 1.3.0</p>
<p class="">Version 1.3.1</p>
</div>

</div>
Expand Down
16 changes: 15 additions & 1 deletion templates/modpack.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<td class="tablewidthid">{{mod.id}}</td>
<td>{{mod.version}}</td>
<td>{{mod.minecraft}}</td>
<td>{{mod.author}}</td>
<td>{{mod.count}}</td>
<td><input class="form-check-input" type="radio" name="flexRadioDefault" value="" id="rec_{{mod.id}}" onclick="submitecheckedpress('recommended_modid', '{{mod.version}}', 'recommended_check', 'rec_{{mod.id}}', 'recommended_submit')" {%
if modpackname.recommended == mod.version %}checked{% endif %} ></td>
<td><input class="form-check-input" type="radio" name="flexRadioDefault1" value=""
Expand Down Expand Up @@ -146,6 +146,20 @@
<input type="text" class="form-control invisible" name="modpack_delete_id" id="modpack_delete_id" readonly>
<input class="btn btn-danger invisible" type="submit" name="deletemod_submit" id="deletemod_submit" value="Delete">
</form>
<form method="post" action="">
<h4>Changelog</h4>
<div class="mb-3">
<label class="form-check-label" for="changelog_oldver">Old Version Build ID</label>
<input type="number" class="form-control" name="changelog_oldver" id="changelog_oldver" required>
</div>
<div class="mb-3">
<label class="form-check-label" for="changelog_newver">New Version Build ID</label>
<input type="number" class="form-control" name="changelog_newver" id="changelog_newver" required>
</div>
<div class="mb-3">
<input class="btn btn-dark" type="submit" name="changelog_submit" id="changelog_submit" value="Generate Changelog">
</div>
</form>
</div>

<script src="{{ url_for('static',filename='js/solderpy.js') }}"></script>
Expand Down

0 comments on commit a754912

Please sign in to comment.