diff --git a/BookandMovieDB.py b/BookandMovieDB.py index 4ecbee7..0da9748 100644 --- a/BookandMovieDB.py +++ b/BookandMovieDB.py @@ -67,6 +67,29 @@ def add_media(): conn.close() return redirect(url_for('index')) +@app.route('/delete/',methods=['POST']) +def delete_media(media_id): + conn = sqlite3.connect(DB_NAME) + cursor = conn.cursor() + + cursor.execute("SELECT image_path FROM media WHERE id = ?",(media_id,)) + row = cursor.fetchone() + if row and row[0] != 'default.jpg': + image_path = os.path.join(UPLOAD_FOLDER, row[0]) + if os.path.exists(image_path): + os.remove(image_path) + + cursor.execute("DELETE from media WHERE id = ?",(media_id,)) + cursor.execute("DELETE from books WHERE book_id = ?",(media_id,)) + cursor.execute("DELETE from shows WHERE show_id = ?",(media_id,)) + cursor.execute("DELETE from media_genres WHERE media_id = ?",(media_id,)) + conn.commit() + cursor.close() + conn.close() + return redirect(url_for('index')) + + + if __name__ == '__main__': init_db() app.run(debug=True) diff --git a/db/my_library.db b/db/my_library.db index e7a6c9b..8fa6417 100644 Binary files a/db/my_library.db and b/db/my_library.db differ diff --git a/static/css/style.css b/static/css/style.css index f9b2476..b39c8fa 100644 --- a/static/css/style.css +++ b/static/css/style.css @@ -42,7 +42,8 @@ width:80vw; padding:20px; } -#addLog_button{ +/*button*/ +#button{ display:flex; align-items:center; gap:8px; @@ -58,6 +59,22 @@ transition: all 0.2s; } -#navagtor{ - +/*search_bar*/ +#search_bar{ + margin-top: 20px; + width: 100%; +} + +#mediaSearch { + width:100%; + padding: 15px; + font-size:1rem; + border: 2px solid #eee; + border-radius: 10px; + outline: none; + transition: border-color 0.3s; + box-sizing: border-box; /* Ensures padding doesn't break width */ +} +#mediaSearch:focus { + border-color: var(--show-color); /* Changes color when you click it */ } diff --git a/static/js/main.js b/static/js/main.js index 6643273..7a0ab88 100644 --- a/static/js/main.js +++ b/static/js/main.js @@ -17,4 +17,29 @@ document.addEventListener("DOMContentLoaded", function() { modal.close(); }); } -}); \ No newline at end of file +}); + +document.addEventListener('DOMContentLoaded',() => { + const searchBar = document.getElementById('mediaSearch'); + + if(searchBar){ + searchBar.addEventListener('keyup', ()=>{ + const input = searchBar.value.toLowerCase(); + const cards = document.getElementsByClassName('card'); + + for (let i = 0; i < cards.length; i++) { + // We search all text inside the card (Title, Author, Genre) + const cardText = cards[i].innerText.toLowerCase(); + + if (cardText.includes(input)) { + cards[i].style.display = ""; + } + else { + cards[i].style.display = "none"; + } + } + }); + } + +}); + diff --git a/templates/card.html b/templates/card.html index b41cf7f..85554d1 100644 --- a/templates/card.html +++ b/templates/card.html @@ -11,6 +11,9 @@
Released: {{ item.release_year }} +
+ +
diff --git a/templates/main.html b/templates/main.html index 27365a9..a415fa3 100644 --- a/templates/main.html +++ b/templates/main.html @@ -48,9 +48,9 @@ Good evening
- +
-
+
+ log a book/show
@@ -80,7 +80,7 @@

📚 My Library

{# button #} - + {# this is the form #}