Skip to content

Commit

Permalink
Merge pull request #81 from Thorfusion/dev
Browse files Browse the repository at this point in the history
Update to 1.4.1
  • Loading branch information
maggi373 authored Aug 15, 2024
2 parents 0aef104 + 167b756 commit 482e324
Show file tree
Hide file tree
Showing 8 changed files with 54 additions and 31 deletions.
13 changes: 6 additions & 7 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 18 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ solder.py is even compatible with original solder's database, visit the install

## Unfinished Features in dev



# Installation/Updating

solder.py is compatible with the original database and only adds columns to tables for the extra features we have, you can even dual run with both solder.py and original solder.
Expand Down Expand Up @@ -130,13 +128,13 @@ docker run --name solderpy --restart always -d -p 80:5000 thorfusion/solderpy

#### Repo variables

This is the public facing URL for your repository. If your repository location is already a URL, you can use the same value here. Include a trailing slash!
This is the public facing URL for your repository. This is prefix url that technic launcher uses to download the mods. Include a trailing slash!

```bash
-e SOLDER_MIRROR_URL=https://solder.example.com/mods/
```

This is the location of your mod reposistory. This can be a URL (remote repo), or an absolute file location (local repo, much faster). When a remote repo is used, Solder will have to download the entire file to calculate the MD5 hash.
This is the url solder.py uses to calculate md5 and filesize when rehashing or adding a mod manually. This is currently only url, so use localhost or local ip address if on the same network, else use same url as mirror url.

```bash
-e SOLDER_REPO_LOCATION=https://solder.example.com/mods/
Expand Down Expand Up @@ -190,6 +188,22 @@ If new user is enabled, you can enable this migration tool for technic solder da
-e TECHNIC_MIGRATION=True
```

#### API only mode

solder.py will only run the api part of solder, allows it to run on read only permissions on a database, no login. good fit for public facing api only mode and another solder.py instance for local access only or similar for login and management

```bash
-e API_ONLY=True
```

#### Management only mode

solder.py will run everything except api part of solder, quite rare usecase.

```bash
-e MANAGEMENT_ONLY=True
```

NOTE: The docker image does not and will not support https, therefore it is required to run an reverse proxy

## Dev Enviroment
Expand Down
14 changes: 8 additions & 6 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,19 @@
from asetup import asetup
from asite import asite
from flask import Flask, render_template
from models.globals import debug, host, port
from models.globals import debug, host, port, api_only, management_only

__version__ = solderpy_version

app: Flask = Flask(__name__)
app.register_blueprint(api)
app.register_blueprint(alogin)
app.register_blueprint(asetup)
app.register_blueprint(asite)
if not management_only:
app.register_blueprint(api)
if not api_only:
app.register_blueprint(alogin)
app.register_blueprint(asetup)
app.register_blueprint(asite)

app.secret_key = secrets.token_hex()
app.secret_key = secrets.token_hex()

@app.errorhandler(404)
def page_not_found(e):
Expand Down
8 changes: 4 additions & 4 deletions asite.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,18 +120,18 @@ def newmodversion(id):

if request.form["rehash_md5"] != "":
version = Modversion.get_by_id(request.form["rehash_id"])
version.update_hash(request.form["rehash_md5"], mirror_url + request.form["rehash_url"])
version.update_hash(request.form["rehash_md5"], repo_url + request.form["rehash_url"])
else:
version = Modversion.get_by_id(request.form["rehash_id"])
t = threading.Thread(target=version.rehash, args=(mirror_url + request.form["rehash_url"],))
t = threading.Thread(target=version.rehash, args=(repo_url + request.form["rehash_url"],))
t.start()
if "newmodvermanual_submit" in request.form:
filesie2 = Modversion.get_file_size(mirror_url + request.form["newmodvermanual_url"])
filesie2 = Modversion.get_file_size(repo_url + request.form["newmodvermanual_url"])
if request.form["newmodvermanual_md5"] != "":
Modversion.new(id, request.form["newmodvermanual_version"], request.form["newmodvermanual_mcversion"], request.form["newmodvermanual_md5"], filesie2, "0")
else:
# Todo Add filesize rehash and md5 hash, if fails do not add
Modversion.new(id, request.form["newmodvermanual_version"], request.form["newmodvermanual_mcversion"], "0", filesie2, "0", mirror_url + request.form["newmodvermanual_url"])
Modversion.new(id, request.form["newmodvermanual_version"], request.form["newmodvermanual_mcversion"], "0", filesie2, "0", repo_url + request.form["newmodvermanual_url"])
return redirect(id)


Expand Down
7 changes: 6 additions & 1 deletion models/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,12 @@ def get_marked_build():
def get_modversions_minimal(self):
conn = Database.get_connection()
cursor = conn.cursor(dictionary=True)
cursor.execute("SELECT modversions.id, modversions.mod_id, modversions.version, modversions.mcversion, modversions.md5, modversions.created_at, modversions.updated_at, modversions.filesize, mods.name AS modname, build_modversion.optional FROM modversions INNER JOIN build_modversion ON modversions.id = build_modversion.modversion_id JOIN mods ON modversions.mod_id = mods.id WHERE build_modversion.build_id = %s", (self.id,))
cursor.execute(
"""SELECT modversions.id, modversions.mod_id, modversions.version, modversions.mcversion, modversions.md5, modversions.created_at, modversions.updated_at, modversions.filesize, mods.name AS modname, build_modversion.optional
FROM modversions
INNER JOIN build_modversion ON modversions.id = build_modversion.modversion_id JOIN mods ON modversions.mod_id = mods.id
WHERE build_modversion.build_id = %s AND build_modversion.optional = 0 AND mods.side IN ('CLIENT','BOTH')
""", (self.id,))
modversions = cursor.fetchall()
if modversions:
versions = []
Expand Down
12 changes: 6 additions & 6 deletions models/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,11 @@ def create_tables() -> bool:
id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(255) NOT NULL UNIQUE,
pretty_name VARCHAR(255) DEFAULT(''),
description VARCHAR(255),
description VARCHAR(255) DEFAULT(''),
author VARCHAR(255),
link VARCHAR(255),
side enum('CLIENT', 'SERVER', 'BOTH'),
modtype enum('MOD', 'LAUNCHER', 'RES', 'CONFIG', 'MCIL', 'NONE') DEFAULT 'NONE',
side enum('CLIENT', 'SERVER', 'BOTH') DEFAULT 'BOTH',
modtype enum('MOD', 'LAUNCHER', 'RES', 'CONFIG', 'MCIL', 'NONE') DEFAULT 'MOD',
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
note TEXT
Expand Down Expand Up @@ -271,9 +271,9 @@ def migratetechnic_tables() -> bool:
)
cur.execute(
"""ALTER TABLE mods
ADD COLUMN side enum('CLIENT', 'SERVER', 'BOTH') AFTER link,
ADD COLUMN modtype enum('MOD', 'LAUNCHER', 'RES', 'CONFIG', 'MCIL', 'NONE') DEFAULT 'NONE',
ADD COLUMN note VARCHAR(255)
ADD COLUMN side enum('CLIENT', 'SERVER', 'BOTH') DEFAULT 'BOTH',
ADD COLUMN modtype enum('MOD', 'LAUNCHER', 'RES', 'CONFIG', 'MCIL', 'NONE') DEFAULT 'MOD',
ADD COLUMN note VARCHAR(255) DEFAULT('')
"""
)
cur.execute(
Expand Down
5 changes: 4 additions & 1 deletion models/globals.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from dotenv import load_dotenv

## Solderpy version
solderpy_version = "1.4.0"
solderpy_version = "1.4.1"

load_dotenv(".env")

Expand All @@ -17,6 +17,9 @@
new_user = os.getenv("NEW_USER")
migratetechnic = os.getenv("TECHNIC_MIGRATION")

api_only = os.getenv("API_ONLY")
management_only = os.getenv("MANAGEMENT_ONLY")

debug = os.getenv("APP_DEBUG").lower() in ["true", "t", "1", "yes", "y"]

mirror_url = os.getenv("SOLDER_MIRROR_URL")
Expand Down
4 changes: 2 additions & 2 deletions templates/newmod.html
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
<div class="mb-3 grid2">
<label>Select Type</label>
<div class="form-check">
<input class="form-check-input" type="radio" name="type" id="type_MOD" value="MOD" required>
<input class="form-check-input" type="radio" name="type" id="type_MOD" value="MOD" required checked>
<label class="form-check-label" for="type_MOD">
MOD
</label>
Expand Down Expand Up @@ -79,7 +79,7 @@
</label>
</div>
<div class="form-check">
<input class="form-check-input" type="radio" name="type" id="type_NONE" value="NONE" required checked>
<input class="form-check-input" type="radio" name="type" id="type_NONE" value="NONE" required>
<label class="form-check-label" for="type_NONE">
NONE
</label>
Expand Down

0 comments on commit 482e324

Please sign in to comment.