diff --git a/app/__init__.py b/app/__init__.py index 9805d2d..33aa404 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -32,12 +32,13 @@ def create_app(): csrf.init_app(app) # register blueprint - from app.routes import user_routes, recipe_routes, auth_routes, category_routes, main_routes, api + from app.routes import user_routes, recipe_routes, auth_routes, category_routes, main_routes,search_routes, api app.register_blueprint(user_routes.bp) app.register_blueprint(recipe_routes.bp) app.register_blueprint(auth_routes.auth_bp) - app.register_blueprint(category_routes.cat_bp, url_prefix='/api') app.register_blueprint(main_routes.main) + app.register_blueprint(search_routes.search_bp) + app.register_blueprint(category_routes.cat_bp, url_prefix='/api') app.register_blueprint(api.api, url_prefix='/api/v1') diff --git a/app/config.py b/app/config.py index 5797451..586b7ef 100644 --- a/app/config.py +++ b/app/config.py @@ -10,7 +10,7 @@ class Config: SECRET_KEY = os.getenv('SECRET_KEY') or 'with_this_you-will-never-guess' SQLALCHEMY_DATABASE_URI = os.getenv( - 'DATABASE_URL') or 'postgresql://spiceshare:fudf2024@localhost/spiceshare_db' + 'DATABASE_URL') or 'postgresql://spiceshare:o@localhost/spiceshare_db' SQLALCHEMY_TRACK_MODIFICATIONS = False SESSION_COOKIE_HTTPONLY = True SESSION_COOKIE_SECURE = True diff --git a/app/models/recipe.py b/app/models/recipe.py index c80894a..6b1c098 100644 --- a/app/models/recipe.py +++ b/app/models/recipe.py @@ -32,3 +32,8 @@ class Recipe(db.Model): def __repr__(self): return f'' + + def increment_view_count(self): + """Increment the view count without updating the updated_at timestamp.""" + self.view_count += 1 + # No commit or onupdate manipulation here diff --git a/app/routes/auth_routes.py b/app/routes/auth_routes.py index 7064f49..4e5a67b 100644 --- a/app/routes/auth_routes.py +++ b/app/routes/auth_routes.py @@ -9,6 +9,16 @@ auth_bp = Blueprint('auth', __name__) +def is_safe_url(target): + """Check if the target URL is safe for redirection.""" + from urllib.parse import urlparse, urljoin + # Allow relative URLs + if target.startswith('/'): + return True + safe = urlparse(target).scheme in ['http', 'https'] and \ + urljoin(request.host_url, target) == target + return safe + @auth_bp.route('/login', methods=['GET', 'POST'], strict_slashes=False) def login(): """Login authentication handler""" @@ -19,12 +29,13 @@ def login(): if request.method == 'POST': email = request.form["email"] password = request.form["password"] + next_page = request.form.get("next") user = User.query.filter_by(email=email).first() if user and check_password_hash(user.password_hash, password): login_user(user) - next_page = request.args.get('next') - if next_page: + + if next_page and is_safe_url(next_page): return redirect(next_page) else: flash('logged in', 'success') diff --git a/app/routes/recipe_routes.py b/app/routes/recipe_routes.py index 3ec4be7..9d664ff 100644 --- a/app/routes/recipe_routes.py +++ b/app/routes/recipe_routes.py @@ -50,8 +50,10 @@ def add_recipe(): except Exception as e: # Rollback db session in case of an error db.session.rollback() - flash( - f"An error occurred while creating the recipe: {str(e)}", "error") + flash(f"An error occurred while creating the recipe: {str(e)}", "error") + # If recipe creation fails, delete the uploaded image if it was uploaded + if image_url: + delete_image_from_s3(image_url) # delete the image if it was uploaded return redirect(url_for('recipe_routes.add_recipe')) @@ -87,9 +89,11 @@ def view_recipe(recipe_id): comment.user = db.session.query(User).filter_by(id=comment.user_id).first() # Get the user who made the comment if recipe: - recipe.view_count += 1 - db.session.commit() + recipe.increment_view_count() # Increment view count without committing recipe.user = db.session.query(User).filter_by(id=recipe.user_id).first() + + # Commit all changes here + db.session.commit() # Commit after all changes are made return render_template('recipes/readPages/recipe_detail.html', recipe=recipe, ingredients=ingredients, instructions=instructions, comments=comments, title=f'{recipe.title} - SpiceShare Inc.') else: flash("Recipe not found.", "error") @@ -140,6 +144,9 @@ def edit_recipe(recipe_id): # Rollback db session in case of an error db.session.rollback() flash(f"An error occurred while updating the recipe: {str(e)}", "error") + # delete the image if it was uploaded + if image_url: + delete_image_from_s3(image_url) return redirect(url_for('recipe_routes.edit_recipe', recipe_id=recipe_id)) categories = CategoryService.get_all_categories() diff --git a/app/routes/search_routes.py b/app/routes/search_routes.py new file mode 100644 index 0000000..cb3d0a2 --- /dev/null +++ b/app/routes/search_routes.py @@ -0,0 +1,25 @@ +from flask import Blueprint, request, render_template +from app.services.search_service import search_recipes + +search_bp = Blueprint('search', __name__) + + +@search_bp.route('/search', methods=['GET'], strict_slashes=False) +def search(): + query = request.args.get('q', '').strip() + page = int(request.args.get('page', 1)) + per_page = int(request.args.get('per_page', 10)) + + if not query: + return render_template('search_results.html', query=query, recipes=[]) + + results = search_recipes(query, page, per_page) + + return render_template( + 'search_results.html', + query=query, + recipes=results['items'], + total_pages=results['total_pages'], + current_page=results['current_page'], + per_page=results['per_page'], + ) diff --git a/app/routes/user_routes.py b/app/routes/user_routes.py index 9625ea8..5a324d6 100644 --- a/app/routes/user_routes.py +++ b/app/routes/user_routes.py @@ -2,6 +2,7 @@ from flask import Blueprint, jsonify, request, flash, redirect, url_for, render_template from app import db from app.services.user_services import get_all_users, delete_user, get_user_by_id, update_user_details, create_user, get_user_by_email, get_user_by_username, is_valid_username +from app.services.recipe_service import get_recipes_by_user from app.models.recipe import Recipe from flask_login import login_required, current_user from werkzeug.security import check_password_hash @@ -119,10 +120,16 @@ def delete_user_profile(user_id): @login_required def user_profile(user_id): user = get_user_by_id(user_id) + page = int(request.args.get('page', 1)) + per_page = int(request.args.get('per_page', 9)) if user != current_user: flash("You are not authorized to view page", 'danger') return redirect(url_for('index')) - recipes = Recipe.query.filter_by(user_id=user.id).all() - return render_template('user_auth/user_profile.html',recipes=recipes, user=user) + paginated_user_recipes = get_recipes_by_user(user.id, page, per_page) + return render_template('user_auth/user_profile.html', recipes=paginated_user_recipes['items'], user=user, total_items=paginated_user_recipes['total_items'], + total_pages=paginated_user_recipes['total_pages'], + current_page=paginated_user_recipes['current_page'], + per_page=per_page + ) diff --git a/app/services/recipe_service.py b/app/services/recipe_service.py index 5f16d8c..e25d023 100644 --- a/app/services/recipe_service.py +++ b/app/services/recipe_service.py @@ -150,6 +150,7 @@ def update_recipe(recipe, data, ingredients, instructions, image_url): def get_recipe_by_id(recipe_id): + """Fetch a recipe by its ID without updating the updated_at timestamp.""" return Recipe.query.get_or_404(recipe_id) @@ -186,6 +187,7 @@ def get_random_recipes_with_images(limit=3): return recipes_with_image -def get_recipes_by_user(user_id): - """Fetch recipes created by a specific user.""" - return Recipe.query.filter_by(user_id=user_id) +def get_recipes_by_user(user_id, page=1, per_page=9): + """Fetch recipes created by a specific user with pagination.""" + recipes = Recipe.query.filter_by(user_id=user_id).all() + return paginate(recipes, page, per_page) diff --git a/app/services/search_service.py b/app/services/search_service.py new file mode 100644 index 0000000..e68eb6e --- /dev/null +++ b/app/services/search_service.py @@ -0,0 +1,32 @@ +from app import db +from app.models.recipe import Recipe +from app.models.category import Category +from app.models.ingredient import Ingredient +from app.models.instruction import Instruction +from app.models.user import User +from app.services.pagination_service import paginate +from sqlalchemy import or_ + + +def search_recipes(query, page=1, per_page=10): + """ + Search for recipes based on a query string. + The query can match recipe names, ingredients, author or categories. + """ + query = f"%{query.lower()}%" + + + recipes = Recipe.query.join(Ingredient).join(Category).join(User).filter( + or_( + Recipe.title.ilike(query), + Recipe.description.ilike(query), + Ingredient.name.ilike(query), + Category.name.ilike(query), + User.first_name.ilike(query), + User.last_name.ilike(query), + User.username.ilike(query) + ) + ).distinct() + + + return paginate(recipes.all(), page, per_page) diff --git a/app/static/css/output.css b/app/static/css/output.css deleted file mode 100644 index 8968436..0000000 --- a/app/static/css/output.css +++ /dev/null @@ -1,4 +0,0 @@ -@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap"); - - -/*! tailwindcss v3.4.10 | MIT License | https://tailwindcss.com*/*,:after,:before{box-sizing:border-box;border:0 solid #e5e7eb}:after,:before{--tw-content:""}:host,html{line-height:1.5;-webkit-text-size-adjust:100%;-moz-tab-size:4;-o-tab-size:4;tab-size:4;font-family:Inter,ui-sans-serif,system-ui,sans-serif;font-feature-settings:normal;font-variation-settings:normal;-webkit-tap-highlight-color:transparent}body{margin:0;line-height:inherit}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,pre,samp{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-feature-settings:normal;font-variation-settings:normal;font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}button,input,optgroup,select,textarea{font-family:inherit;font-feature-settings:inherit;font-variation-settings:inherit;font-size:100%;font-weight:inherit;line-height:inherit;letter-spacing:inherit;color:inherit;margin:0;padding:0}button,select{text-transform:none}button,input:where([type=button]),input:where([type=reset]),input:where([type=submit]){-webkit-appearance:button;background-color:transparent;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:baseline}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dd,dl,figure,h1,h2,h3,h4,h5,h6,hr,p,pre{margin:0}fieldset{margin:0}fieldset,legend{padding:0}menu,ol,ul{list-style:none;margin:0;padding:0}dialog{padding:0}textarea{resize:vertical}input::-moz-placeholder,textarea::-moz-placeholder{opacity:1;color:#9ca3af}input::placeholder,textarea::placeholder{opacity:1;color:#9ca3af}[role=button],button{cursor:pointer}:disabled{cursor:default}audio,canvas,embed,iframe,img,object,svg,video{display:block;vertical-align:middle}img,video{max-width:100%;height:auto}[hidden]{display:none}*,:after,:before{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgba(59,130,246,.5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }::backdrop{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgba(59,130,246,.5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }.container{width:100%}@media (min-width:640px){.container{max-width:640px}}@media (min-width:768px){.container{max-width:768px}}@media (min-width:1024px){.container{max-width:1024px}}@media (min-width:1280px){.container{max-width:1280px}}@media (min-width:1536px){.container{max-width:1536px}}.visible{visibility:visible}.static{position:static}.fixed{position:fixed}.absolute{position:absolute}.relative{position:relative}.inset-0{inset:0}.bottom-0{bottom:0}.bottom-4{bottom:1rem}.left-0{left:0}.left-1\/2{left:50%}.right-0{right:0}.right-2{right:.5rem}.right-3{right:.75rem}.top-2{top:.5rem}.top-3{top:.75rem}.top-4{top:1rem}.z-10{z-index:10}.mx-16{margin-left:4rem;margin-right:4rem}.mx-4{margin-left:1rem;margin-right:1rem}.mx-auto{margin-left:auto;margin-right:auto}.mb-16{margin-bottom:4rem}.mb-2{margin-bottom:.5rem}.mb-4{margin-bottom:1rem}.mb-6{margin-bottom:1.5rem}.mb-8{margin-bottom:2rem}.ml-2{margin-left:.5rem}.ml-4{margin-left:1rem}.mr-2{margin-right:.5rem}.mr-4{margin-right:1rem}.mr-6{margin-right:1.5rem}.mt-1{margin-top:.25rem}.mt-10{margin-top:2.5rem}.mt-12{margin-top:3rem}.mt-2{margin-top:.5rem}.mt-4{margin-top:1rem}.mt-6{margin-top:1.5rem}.mt-8{margin-top:2rem}.block{display:block}.inline-block{display:inline-block}.inline{display:inline}.flex{display:flex}.inline-flex{display:inline-flex}.grid{display:grid}.hidden{display:none}.h-10{height:2.5rem}.h-4{height:1rem}.h-40{height:10rem}.h-48{height:12rem}.h-64{height:16rem}.h-8{height:2rem}.h-\[500px\]{height:500px}.h-full{height:100%}.h-screen{height:100vh}.min-h-screen{min-height:100vh}.w-1\/2{width:50%}.w-10{width:2.5rem}.w-16{width:4rem}.w-4{width:1rem}.w-64{width:16rem}.w-96{width:24rem}.w-full{width:100%}.max-w-3xl{max-width:48rem}.max-w-4xl{max-width:56rem}.max-w-6xl{max-width:72rem}.max-w-md{max-width:28rem}.flex-1{flex:1 1 0%}.shrink-0{flex-shrink:0}.-translate-x-1\/2{--tw-translate-x:-50%}.-translate-x-1\/2,.transform{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.resize{resize:both}.list-inside{list-style-position:inside}.list-decimal{list-style-type:decimal}.list-disc{list-style-type:disc}.grid-cols-1{grid-template-columns:repeat(1,minmax(0,1fr))}.grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.flex-col{flex-direction:column}.items-start{align-items:flex-start}.items-center{align-items:center}.justify-end{justify-content:flex-end}.justify-center{justify-content:center}.justify-between{justify-content:space-between}.gap-4{gap:1rem}.gap-6{gap:1.5rem}.gap-8{gap:2rem}.space-x-2>:not([hidden])~:not([hidden]){--tw-space-x-reverse:0;margin-right:calc(.5rem*var(--tw-space-x-reverse));margin-left:calc(.5rem*(1 - var(--tw-space-x-reverse)))}.space-x-4>:not([hidden])~:not([hidden]){--tw-space-x-reverse:0;margin-right:calc(1rem*var(--tw-space-x-reverse));margin-left:calc(1rem*(1 - var(--tw-space-x-reverse)))}.space-x-6>:not([hidden])~:not([hidden]){--tw-space-x-reverse:0;margin-right:calc(1.5rem*var(--tw-space-x-reverse));margin-left:calc(1.5rem*(1 - var(--tw-space-x-reverse)))}.space-y-2>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(.5rem*(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.5rem*var(--tw-space-y-reverse))}.space-y-4>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(1rem*(1 - var(--tw-space-y-reverse)));margin-bottom:calc(1rem*var(--tw-space-y-reverse))}.overflow-hidden{overflow:hidden}.overflow-x-auto{overflow-x:auto}.rounded{border-radius:.25rem}.rounded-full{border-radius:9999px}.rounded-lg{border-radius:.5rem}.rounded-md{border-radius:.375rem}.rounded-tl-lg{border-top-left-radius:.5rem}.border{border-width:1px}.border-b{border-bottom-width:1px}.border-b-2{border-bottom-width:2px}.border-gray-200{--tw-border-opacity:1;border-color:rgb(229 231 235/var(--tw-border-opacity))}.border-gray-300{--tw-border-opacity:1;border-color:rgb(209 213 219/var(--tw-border-opacity))}.bg-background{--tw-bg-opacity:1;background-color:rgb(247 255 247/var(--tw-bg-opacity))}.bg-black{--tw-bg-opacity:1;background-color:rgb(0 0 0/var(--tw-bg-opacity))}.bg-blue-100{--tw-bg-opacity:1;background-color:rgb(219 234 254/var(--tw-bg-opacity))}.bg-blue-500{--tw-bg-opacity:1;background-color:rgb(59 130 246/var(--tw-bg-opacity))}.bg-blue-600{--tw-bg-opacity:1;background-color:rgb(37 99 235/var(--tw-bg-opacity))}.bg-error{--tw-bg-opacity:1;background-color:rgb(255 107 107/var(--tw-bg-opacity))}.bg-gray-100{--tw-bg-opacity:1;background-color:rgb(243 244 246/var(--tw-bg-opacity))}.bg-gray-200{--tw-bg-opacity:1;background-color:rgb(229 231 235/var(--tw-bg-opacity))}.bg-gray-400{--tw-bg-opacity:1;background-color:rgb(156 163 175/var(--tw-bg-opacity))}.bg-gray-50{--tw-bg-opacity:1;background-color:rgb(249 250 251/var(--tw-bg-opacity))}.bg-gray-600{--tw-bg-opacity:1;background-color:rgb(75 85 99/var(--tw-bg-opacity))}.bg-gray-800{--tw-bg-opacity:1;background-color:rgb(31 41 55/var(--tw-bg-opacity))}.bg-green-600{--tw-bg-opacity:1;background-color:rgb(22 163 74/var(--tw-bg-opacity))}.bg-indigo-600{--tw-bg-opacity:1;background-color:rgb(79 70 229/var(--tw-bg-opacity))}.bg-info{--tw-bg-opacity:1;background-color:rgb(33 150 243/var(--tw-bg-opacity))}.bg-primary{--tw-bg-opacity:1;background-color:rgb(255 107 107/var(--tw-bg-opacity))}.bg-red-600{--tw-bg-opacity:1;background-color:rgb(220 38 38/var(--tw-bg-opacity))}.bg-secondary{--tw-bg-opacity:1;background-color:rgb(78 205 196/var(--tw-bg-opacity))}.bg-success{--tw-bg-opacity:1;background-color:rgb(76 175 80/var(--tw-bg-opacity))}.bg-warning{--tw-bg-opacity:1;background-color:rgb(255 152 0/var(--tw-bg-opacity))}.bg-white{--tw-bg-opacity:1;background-color:rgb(255 255 255/var(--tw-bg-opacity))}.bg-yellow-100{--tw-bg-opacity:1;background-color:rgb(254 249 195/var(--tw-bg-opacity))}.bg-opacity-50{--tw-bg-opacity:0.5}.bg-cover{background-size:cover}.bg-center{background-position:50%}.object-cover{-o-object-fit:cover;object-fit:cover}.p-2{padding:.5rem}.p-3{padding:.75rem}.p-4{padding:1rem}.p-6{padding:1.5rem}.p-8{padding:2rem}.px-2{padding-left:.5rem;padding-right:.5rem}.px-3{padding-left:.75rem;padding-right:.75rem}.px-4{padding-left:1rem;padding-right:1rem}.px-6{padding-left:1.5rem;padding-right:1.5rem}.px-8{padding-left:2rem;padding-right:2rem}.py-1{padding-top:.25rem;padding-bottom:.25rem}.py-10{padding-top:2.5rem;padding-bottom:2.5rem}.py-16{padding-top:4rem;padding-bottom:4rem}.py-2{padding-top:.5rem;padding-bottom:.5rem}.py-3{padding-top:.75rem;padding-bottom:.75rem}.py-4{padding-top:1rem;padding-bottom:1rem}.py-6{padding-top:1.5rem;padding-bottom:1.5rem}.py-8{padding-top:2rem;padding-bottom:2rem}.text-center{text-align:center}.font-sans{font-family:Inter,ui-sans-serif,system-ui,sans-serif}.text-2xl{font-size:1.5rem;line-height:2rem}.text-3xl{font-size:1.875rem;line-height:2.25rem}.text-4xl{font-size:2.25rem;line-height:2.5rem}.text-5xl{font-size:3rem;line-height:1}.text-lg{font-size:1.125rem;line-height:1.75rem}.text-sm{font-size:.875rem;line-height:1.25rem}.text-xl{font-size:1.25rem;line-height:1.75rem}.text-xs{font-size:.75rem;line-height:1rem}.font-bold{font-weight:700}.font-light{font-weight:300}.font-medium{font-weight:500}.font-semibold{font-weight:600}.text-blue-300{--tw-text-opacity:1;color:rgb(147 197 253/var(--tw-text-opacity))}.text-blue-600{--tw-text-opacity:1;color:rgb(37 99 235/var(--tw-text-opacity))}.text-blue-800{--tw-text-opacity:1;color:rgb(30 64 175/var(--tw-text-opacity))}.text-gray-400{--tw-text-opacity:1;color:rgb(156 163 175/var(--tw-text-opacity))}.text-gray-500{--tw-text-opacity:1;color:rgb(107 114 128/var(--tw-text-opacity))}.text-gray-600{--tw-text-opacity:1;color:rgb(75 85 99/var(--tw-text-opacity))}.text-gray-700{--tw-text-opacity:1;color:rgb(55 65 81/var(--tw-text-opacity))}.text-gray-800{--tw-text-opacity:1;color:rgb(31 41 55/var(--tw-text-opacity))}.text-gray-900{--tw-text-opacity:1;color:rgb(17 24 39/var(--tw-text-opacity))}.text-indigo-600{--tw-text-opacity:1;color:rgb(79 70 229/var(--tw-text-opacity))}.text-red-400{--tw-text-opacity:1;color:rgb(248 113 113/var(--tw-text-opacity))}.text-red-500{--tw-text-opacity:1;color:rgb(239 68 68/var(--tw-text-opacity))}.text-red-600{--tw-text-opacity:1;color:rgb(220 38 38/var(--tw-text-opacity))}.text-text{--tw-text-opacity:1;color:rgb(26 83 92/var(--tw-text-opacity))}.text-white{--tw-text-opacity:1;color:rgb(255 255 255/var(--tw-text-opacity))}.underline{text-decoration-line:underline}.opacity-50{opacity:.5}.shadow{--tw-shadow:0 1px 3px 0 rgba(0,0,0,.1),0 1px 2px -1px rgba(0,0,0,.1);--tw-shadow-colored:0 1px 3px 0 var(--tw-shadow-color),0 1px 2px -1px var(--tw-shadow-color)}.shadow,.shadow-lg{box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.shadow-lg{--tw-shadow:0 10px 15px -3px rgba(0,0,0,.1),0 4px 6px -4px rgba(0,0,0,.1);--tw-shadow-colored:0 10px 15px -3px var(--tw-shadow-color),0 4px 6px -4px var(--tw-shadow-color)}.shadow-md{--tw-shadow:0 4px 6px -1px rgba(0,0,0,.1),0 2px 4px -2px rgba(0,0,0,.1);--tw-shadow-colored:0 4px 6px -1px var(--tw-shadow-color),0 2px 4px -2px var(--tw-shadow-color)}.shadow-md,.shadow-sm{box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.shadow-sm{--tw-shadow:0 1px 2px 0 rgba(0,0,0,.05);--tw-shadow-colored:0 1px 2px 0 var(--tw-shadow-color)}.blur{--tw-blur:blur(8px)}.blur,.filter{filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.transition{transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,-webkit-backdrop-filter;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,backdrop-filter;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,backdrop-filter,-webkit-backdrop-filter;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-transform{transition-property:transform;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.duration-300{transition-duration:.3s}.duration-500{transition-duration:.5s}.hover\:scale-105:hover{--tw-scale-x:1.05;--tw-scale-y:1.05;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.hover\:bg-blue-700:hover{--tw-bg-opacity:1;background-color:rgb(29 78 216/var(--tw-bg-opacity))}.hover\:bg-gray-100:hover{--tw-bg-opacity:1;background-color:rgb(243 244 246/var(--tw-bg-opacity))}.hover\:bg-gray-200:hover{--tw-bg-opacity:1;background-color:rgb(229 231 235/var(--tw-bg-opacity))}.hover\:bg-gray-700:hover{--tw-bg-opacity:1;background-color:rgb(55 65 81/var(--tw-bg-opacity))}.hover\:bg-green-700:hover{--tw-bg-opacity:1;background-color:rgb(21 128 61/var(--tw-bg-opacity))}.hover\:bg-indigo-700:hover{--tw-bg-opacity:1;background-color:rgb(67 56 202/var(--tw-bg-opacity))}.hover\:text-accent:hover{--tw-text-opacity:1;color:rgb(255 230 109/var(--tw-text-opacity))}.hover\:text-blue-800:hover{--tw-text-opacity:1;color:rgb(30 64 175/var(--tw-text-opacity))}.hover\:text-red-700:hover{--tw-text-opacity:1;color:rgb(185 28 28/var(--tw-text-opacity))}.hover\:text-red-800:hover{--tw-text-opacity:1;color:rgb(153 27 27/var(--tw-text-opacity))}.hover\:underline:hover{text-decoration-line:underline}.focus\:border-blue-300:focus{--tw-border-opacity:1;border-color:rgb(147 197 253/var(--tw-border-opacity))}.focus\:border-blue-500:focus{--tw-border-opacity:1;border-color:rgb(59 130 246/var(--tw-border-opacity))}.focus\:outline-none:focus{outline:2px solid transparent;outline-offset:2px}.focus\:ring:focus{--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(3px + var(--tw-ring-offset-width)) var(--tw-ring-color)}.focus\:ring-2:focus,.focus\:ring:focus{box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow,0 0 #0000)}.focus\:ring-2:focus{--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color)}.focus\:ring-blue-500:focus{--tw-ring-opacity:1;--tw-ring-color:rgb(59 130 246/var(--tw-ring-opacity))}.focus\:ring-indigo-500:focus{--tw-ring-opacity:1;--tw-ring-color:rgb(99 102 241/var(--tw-ring-opacity))}@media (min-width:640px){.sm\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.sm\:grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}}@media (min-width:768px){.md\:block{display:block}.md\:w-1\/2{width:50%}.md\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.md\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}}@media (min-width:1024px){.lg\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.lg\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}} \ No newline at end of file diff --git a/app/templates/recipes/readPages/allRecipes.html b/app/templates/recipes/readPages/allRecipes.html index af63943..3022faa 100644 --- a/app/templates/recipes/readPages/allRecipes.html +++ b/app/templates/recipes/readPages/allRecipes.html @@ -5,11 +5,14 @@

Recipes

-
- +
+
+ + +
-
+
{% for recipe in recipes %}
@@ -77,4 +80,8 @@

Savory Porridge

-{% endblock %} \ No newline at end of file +{% endblock %} + +{% block scripts %} + +{% endblock scripts %} \ No newline at end of file diff --git a/app/templates/recipes/readPages/read_layout.html b/app/templates/recipes/readPages/read_layout.html index c42f40d..a58d789 100644 --- a/app/templates/recipes/readPages/read_layout.html +++ b/app/templates/recipes/readPages/read_layout.html @@ -26,13 +26,16 @@ - +
SpiceShare
+
-
+
{% with messages = get_flashed_messages(with_categories=true) %} {% if messages %}
diff --git a/app/templates/recipes/readPages/recipe_detail.html b/app/templates/recipes/readPages/recipe_detail.html index 5d6f12f..8dff45b 100644 --- a/app/templates/recipes/readPages/recipe_detail.html +++ b/app/templates/recipes/readPages/recipe_detail.html @@ -1,10 +1,10 @@ {% extends "recipes/readPages/read_layout.html" %} {% block content %} - + -
+
{% if recipe %}
diff --git a/app/templates/search_results.html b/app/templates/search_results.html new file mode 100644 index 0000000..d733146 --- /dev/null +++ b/app/templates/search_results.html @@ -0,0 +1,43 @@ +{% extends "recipes/readPages/read_layout.html" %} +{% block content %} +
+

Search Results

+ + {% if query %} +

Results for "{{ query }}":

+ {% else %} +

No search query provided.

+ {% endif %} + + {% if recipes %} +
    + {% for recipe in recipes %} +
  • + {{ recipe.title }} +

    {{ recipe.description[:150] }}...

    +

    By {{ recipe.author.username }} | Category: {{ recipe.category.name }}

    +
  • + {% endfor %} +
+ + +
+
+ {% if current_page > 1 %} + Previous + {% endif %} + Page {{ current_page }} of {{ total_pages }} + {% if current_page < total_pages %} + Next + {% endif %} +
+
+ + {% else %} +

No recipes found matching your search criteria.

+ {% endif %} +
+{% endblock %} \ No newline at end of file diff --git a/app/templates/user_auth/login.html b/app/templates/user_auth/login.html index f4ea7f8..93da0cb 100644 --- a/app/templates/user_auth/login.html +++ b/app/templates/user_auth/login.html @@ -54,6 +54,7 @@

Sign In

+
- + - -
-

Your Recipes

- {% if recipes%} -
- {% for recipe in recipes %} + +
+

Your Recipes

+ {% if recipes%} +
+ {% for recipe in recipes %}
{% if recipe.image_url %} {{ recipe.title }}{{ recipe.title }}
{% endfor %}
+ + +
+
+ {% if current_page > 1 %} + Previous + {% endif %} + Page {{ current_page }} of {{ total_pages }} + {% if current_page < total_pages %} Next + {% endif %} +
+
+ {% else %}

You haven't posted any recipes yet.

{% endif %}