From 8bc257aec678c4b30f761b0c9557e7fe029e89b8 Mon Sep 17 00:00:00 2001 From: nocci Date: Mon, 21 Apr 2025 11:06:38 +0000 Subject: [PATCH] new setup.sh --- README.md | 71 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ setup.sh | 60 ++++++++++++++++++++++++++++++++++++---------- 2 files changed, 119 insertions(+), 12 deletions(-) create mode 100644 README.md mode change 100755 => 100644 setup.sh diff --git a/README.md b/README.md new file mode 100644 index 0000000..ca9c8e3 --- /dev/null +++ b/README.md @@ -0,0 +1,71 @@ +# 🗝️ Game Key Management System 🔑 + +![Project Logo - ideally a nerdy picture of keys or a gamepad] + +**Welcome!** 👋 + +This project helps you keep track of your collected game keys. Does this sound familiar? You have a key here, a key there, from Humble Bundle, Fanatical, or just given to you, but you can't remember if you redeemed it, gifted it, or if it's still lurking somewhere? Don't panic, this is the solution! + +## ✨ Features ✨ + +* **Key Management:** Enter your game keys, along with the corresponding game, platform (Steam, GOG, etc.) and where you got the key. +* **Status Tracking:** Mark keys as "Redeemed", "Gifted" or "Available". So you always know where you stand. +* **Clear Database:** All your keys in one place, easily searchable and sortable. +* **(Planned Features):** + * Import/Export of Keys (CSV, JSON) + * Integration with Steam API (to automatically check if a key has already been redeemed) + * Dark Mode! (Because who doesn't love Dark Mode?) + +## 🚀 Get Started! 🚀 + +1. **Clone the Repository:** + + ```bash + git clone [Repository URL] + cd [Project Directory] + ``` + +2. **Installation (if required - e.g. for a web application):** + + * Describe the necessary installation steps here. Example: + + ```bash + npm install # Or yarn install, whatever you prefer! + ``` + +3. **Configuration:** + + * Explain here which configuration steps are necessary (e.g. setting up a database connection). + * Example: Create a `.env` file and enter your database access data. + +4. **Start the Application:** + + ```bash + npm start # Or however the application is started + ``` + +5. **Use the Application!** Open your browser and go to `http://localhost:[Port]` (or wherever your application is running). + +## 🛠️ Technology Stack 🛠️ + +* **Frontend:** [Enter the frontend technology here - e.g. React, Vue.js, Angular] +* **Backend:** [Enter the backend technology here - e.g. Node.js, Python/Flask, Java/Spring] +* **Database:** [Enter the database here - e.g. PostgreSQL, MySQL, SQLite] + +## 🙌 Contribute! 🙌 + +This project is open source and thrives on your help! If you find bugs, have suggestions, or want to contribute code yourself, you are welcome! + +* **Bug Reports:** Please report bugs as Issues. +* **Feature Requests:** Suggest new features! +* **Pull Requests:** Submit your code changes! + +Before contributing code, please read the [CONTRIBUTING.md](CONTRIBUTING.md) file. + +## 📜 License 📜 + +This project is licensed under the [MIT License](LICENSE). + +## 💖 Acknowledgements 💖 + +A big thank you to everyone who supports and contributes to this project! diff --git a/setup.sh b/setup.sh old mode 100755 new mode 100644 index 27345e9..fc3d3c9 --- a/setup.sh +++ b/setup.sh @@ -41,6 +41,7 @@ app.config['BABEL_DEFAULT_LOCALE'] = 'de' app.config['BABEL_SUPPORTED_LOCALES'] = ['de', 'en'] app.config['BABEL_TRANSLATION_DIRECTORIES'] = 'translations' + db = SQLAlchemy(app) login_manager = LoginManager(app) login_manager.login_view = 'login' @@ -76,6 +77,7 @@ class Game(db.Model): created_at = db.Column(db.DateTime, default=datetime.utcnow) redeem_date = db.Column(db.DateTime) user_id = db.Column(db.Integer, db.ForeignKey('user.id'), nullable=False) + steam_appid = db.Column(db.String(20)) @login_manager.user_loader def load_user(user_id): @@ -139,18 +141,31 @@ def logout(): logout_user() return redirect(url_for('login')) +import re + +def extract_steam_appid(url): + match = re.search(r'store\.steampowered\.com/app/(\d+)', url or '') + if match: + return match.group(1) + return '' + @app.route('/add', methods=['GET', 'POST']) @login_required def add_game(): if request.method == 'POST': try: + url = request.form.get('url', '') + steam_appid = request.form.get('steam_appid', '').strip() + if not steam_appid: + steam_appid = extract_steam_appid(url) new_game = Game( name=request.form['name'], steam_key=request.form['steam_key'], status=request.form['status'], recipient=request.form.get('recipient', ''), notes=request.form.get('notes', ''), - url=request.form.get('url', ''), + url=url, + steam_appid=steam_appid, # <- jetzt wird sie gesetzt! redeem_date=datetime.strptime(request.form['redeem_date'], '%Y-%m-%d') if request.form['redeem_date'] else None, user_id=current_user.id ) @@ -163,31 +178,45 @@ def add_game(): flash(_('Error: ') + str(e), 'danger') return render_template('add_game.html') + @app.route('/edit/', methods=['GET', 'POST']) @login_required def edit_game(game_id): - game = Game.query.get_or_404(game_id) - if game.owner != current_user: + game = db.session.get(Game, game_id) # SQLAlchemy 2.x-kompatibel + if not game or game.owner != current_user: return _("Not allowed!"), 403 + if request.method == 'POST': try: + # Steam AppID aus Formular oder URL extrahieren + url = request.form.get('url', '') + steam_appid = request.form.get('steam_appid', '').strip() + if not steam_appid: + steam_appid = extract_steam_appid(url) + + # Aktualisiere alle Felder game.name = request.form['name'] game.steam_key = request.form['steam_key'] game.status = request.form['status'] game.recipient = request.form.get('recipient', '') game.notes = request.form.get('notes', '') - game.url = request.form.get('url', '') + game.url = url + game.steam_appid = steam_appid # <- FEHLTE HIER game.redeem_date = datetime.strptime(request.form['redeem_date'], '%Y-%m-%d') if request.form['redeem_date'] else None + db.session.commit() flash(_('Changes saved!'), 'success') return redirect(url_for('index')) + except Exception as e: db.session.rollback() flash(_('Error: ') + str(e), 'danger') + return render_template('edit_game.html', game=game, redeem_date=game.redeem_date.strftime('%Y-%m-%d') if game.redeem_date else '') + @app.route('/delete/', methods=['POST']) @login_required def delete_game(game_id): @@ -395,6 +424,7 @@ cat < templates/index.html + @@ -407,6 +437,12 @@ cat < templates/index.html {% for game in games %} + @@ -452,6 +483,7 @@ cat < templates/index.html HTML_END + cat < templates/add_game.html {% extends "base.html" %} {% block content %} @@ -517,6 +549,10 @@ cat < templates/edit_game.html +
+ + +
{{ _('Cover') }} {{ _('Name') }} {{ _('Key') }} {{ _('Status') }}
+ {% if game.steam_appid %} + Steam Header + {% endif %} + {{ game.name }} {{ game.steam_key }} @@ -430,14 +466,9 @@ cat < templates/index.html {% endif %} - ✏️ -
- + ✏️ + +