From 6bc479b5c08fb42c076e39eb715277a8514dbfe0 Mon Sep 17 00:00:00 2001 From: Flatlogic Bot Date: Sun, 16 Nov 2025 18:04:45 +0000 Subject: [PATCH] Auto commit: 2025-11-16T18:04:45.434Z --- core/__pycache__/urls.cpython-311.pyc | Bin 347 -> 401 bytes core/__pycache__/views.cpython-311.pyc | Bin 1364 -> 2693 bytes core/templates/base.html | 35 +++- core/templates/core/index.html | 213 +++++++------------------ core/urls.py | 7 +- core/views.py | 92 ++++++++--- static/css/custom.css | 98 ++++++++++++ 7 files changed, 261 insertions(+), 184 deletions(-) create mode 100644 static/css/custom.css diff --git a/core/__pycache__/urls.cpython-311.pyc b/core/__pycache__/urls.cpython-311.pyc index 1f807fae1897c89361c99c5e868a26d00799b73f..623856529455f54b4d685036cac6bbdbf744b7c4 100644 GIT binary patch delta 282 zcmcc3G?AHiIWI340}!kgl*+7~$ScVhHc?%B2rk_uq|T- ziU2VLq%%gbrmzPyXmY#+31~9jVkt;0$#}^K;c$B9rKDDbWu}(jVz|Yc3F3g1WUg4Fy$g6OLS7AZ<1s45_Ec#bi^gl2&@iR4W KgJ2OK&}abdU`KZV delta 177 zcmbQpe4B}PIWI340}vcY|CNz7kynz@W}>>XL@IL%>l(IY%nS^xffxeP8KYPx)<}!9 zWaQ_j-eM?X1qy32-eSp1%uV&vWSzKGe&Su97(SpVBM=vR0f`UHjEsyo7-TM>q6ZA( q7f{g$HU?JC2A2+@j*uB_7g*#kvdCXyk^jKV#Lv{g4T42HK;r-r@GMLK diff --git a/core/__pycache__/views.cpython-311.pyc b/core/__pycache__/views.cpython-311.pyc index 6867ddf286a519cf1754ac97038f9f1e4605fbf2..b1607bdeeb5584d6b3d5204ff6623f31fcbc5f66 100644 GIT binary patch literal 2693 zcmb7FUu+vi8lScIpPfJU+G!d)lrBjc$GOI#;owMGK}hMpqm-iN5Y0VUCOdJK+Ph|U zw@IyyR3skqm!DJp99{@> zBt*^;E&LJDcpAPNCgeW+TWNvUgexQ~?qKsC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`z`Y<)5;BG^zo;?`Q?6crISo|lj(kPxtsi=lf2$d zUhiF8=v}zfU%GryZ>QE?g*r>Q?ozJ5xODJS`|4MJebZUI)m^+bn2pWI0|cyf_w9L< zIJbYby>RVisS{uA##h^s)e}e(07x&wM(2TX`E06G0Q9V<>X{|ul?i3g0?%(HPYlgf z1`zb;;Me{qqL;+gPk@~&H*I26ExbmrfGYk1-V - + - {% block title %}Knowledge Base{% endblock %} - {% block head %}{% endblock %} - - - {% block content %}{% endblock %} - - + + {{ page_title|default:"Unit Converter" }} + + + + + + + + + + + + + + + +
+ {% block content %}{% endblock %} +
+ + + + + \ No newline at end of file diff --git a/core/templates/core/index.html b/core/templates/core/index.html index 0a3f404..e8849db 100644 --- a/core/templates/core/index.html +++ b/core/templates/core/index.html @@ -1,154 +1,65 @@ {% extends "base.html" %} - -{% block title %}{{ project_name }}{% endblock %} - -{% block head %} -{% if project_description %} - - - -{% endif %} -{% if project_image_url %} - - -{% endif %} - - - - -{% endblock %} - {% block content %} -
-
-

Analyzing your requirements and generating your app…

-
- Loading… +
+
+

Unit Converter

+

A modern, fast, and free engineering unit converter.

-

AppWizzy AI is collecting your requirements and applying the first changes.

-

This page will refresh automatically as the plan is implemented.

-

- Runtime: Django {{ django_version }} · Python {{ python_version }} - — UTC {{ current_time|date:"Y-m-d H:i:s" }} -

-
-
-
- Page updated: {{ current_time|date:"Y-m-d H:i:s" }} (UTC) -
-{% endblock %} \ No newline at end of file + +
+ {% csrf_token %} +
+ +
+ + +
+ + +
+ + +
+ + +
+ + +
+
+ +
+ +
+
+ + {% if result is not None %} +
+ {{ result }} +
+ {% endif %} + + {% if error %} +
+ {{ error }} +
+ {% endif %} + + +{% endblock %} diff --git a/core/urls.py b/core/urls.py index 6299e3d..5f9bb72 100644 --- a/core/urls.py +++ b/core/urls.py @@ -1,7 +1,6 @@ from django.urls import path - -from .views import home +from .views import IndexView urlpatterns = [ - path("", home, name="home"), -] + path('', IndexView.as_view(), name='index'), +] \ No newline at end of file diff --git a/core/views.py b/core/views.py index c9aed12..ccbf5d8 100644 --- a/core/views.py +++ b/core/views.py @@ -1,25 +1,75 @@ -import os -import platform - -from django import get_version as django_version from django.shortcuts import render -from django.utils import timezone +from django.views import View +class IndexView(View): + def get(self, request, *args, **kwargs): + # For now, units are hardcoded. This will be moved to the database later. + units = { + 'Length': ['meters', 'feet', 'inches'], + 'Mass': ['kilograms', 'pounds', 'ounces'], + 'Temperature': ['Celsius', 'Fahrenheit', 'Kelvin'] + } + context = { + 'units': units, + 'page_title': 'Engineering Unit Converter', + } + return render(request, 'core/index.html', context) -def home(request): - """Render the landing screen with loader and environment details.""" - host_name = request.get_host().lower() - agent_brand = "AppWizzy" if host_name == "appwizzy.com" else "Flatlogic" - now = timezone.now() + def post(self, request, *args, **kwargs): + # Hardcoded units and conversion factors for the first iteration + units = { + 'Length': ['meters', 'feet', 'inches'], + 'Mass': ['kilograms', 'pounds', 'ounces'], + 'Temperature': ['Celsius', 'Fahrenheit', 'Kelvin'] + } + + value_in = request.POST.get('value_in') + unit_in = request.POST.get('unit_in') + unit_out = request.POST.get('unit_out') + + result = None + error = None - context = { - "project_name": "New Style", - "agent_brand": agent_brand, - "django_version": django_version(), - "python_version": platform.python_version(), - "current_time": now, - "host_name": host_name, - "project_description": os.getenv("PROJECT_DESCRIPTION", ""), - "project_image_url": os.getenv("PROJECT_IMAGE_URL", ""), - } - return render(request, "core/index.html", context) + try: + value_in_float = float(value_in) + + # Basic, non-comprehensive conversion logic + # This should be replaced with a more robust library or model-driven approach + + # Length + if unit_in == 'meters' and unit_out == 'feet': + result = value_in_float * 3.28084 + elif unit_in == 'feet' and unit_out == 'meters': + result = value_in_float / 3.28084 + + # Mass + elif unit_in == 'kilograms' and unit_out == 'pounds': + result = value_in_float * 2.20462 + elif unit_in == 'pounds' and unit_out == 'kilograms': + result = value_in_float / 2.20462 + + # Temperature + elif unit_in == 'Celsius' and unit_out == 'Fahrenheit': + result = (value_in_float * 9/5) + 32 + elif unit_in == 'Fahrenheit' and unit_out == 'Celsius': + result = (value_in_float - 32) * 5/9 + + elif unit_in == unit_out: + result = value_in_float + else: + # Placeholder for conversions not yet implemented + error = f"Conversion from {unit_in} to {unit_out} is not yet supported." + + except (ValueError, TypeError): + error = "Invalid input value. Please enter a number." + + context = { + 'units': units, + 'result': round(result, 4) if result is not None else None, + 'error': error, + 'value_in': value_in, + 'unit_in': unit_in, + 'unit_out': unit_out, + 'page_title': 'Engineering Unit Converter', + } + return render(request, 'core/index.html', context) \ No newline at end of file diff --git a/static/css/custom.css b/static/css/custom.css new file mode 100644 index 0000000..e10eda2 --- /dev/null +++ b/static/css/custom.css @@ -0,0 +1,98 @@ +/* +Engineering Unit Converter - Custom Stylesheet +*/ + +:root { + --background-color: #1a1a2e; + --primary-text-color: #ffffff; + --secondary-text-color: #dcdcdc; + --accent-color-1: #e94560; + --accent-color-2: #0f3460; + --card-background: #16213e; + --border-color: #0f3460; +} + +body { + background-color: var(--background-color); + color: var(--secondary-text-color); + font-family: 'Roboto', sans-serif; + display: flex; + justify-content: center; + align-items: center; + min-height: 100vh; + padding: 2rem; +} + +h1, h2, h3, h4, h5, h6 { + font-family: 'Poppins', sans-serif; + color: var(--primary-text-color); + font-weight: 600; +} + +.converter-wrapper { + max-width: 600px; + width: 100%; + background-color: var(--card-background); + padding: 2.5rem; + border-radius: 15px; + border: 1px solid var(--border-color); + box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2); +} + +.form-control, .form-select { + background-color: var(--accent-color-2); + color: var(--primary-text-color); + border: 1px solid var(--border-color); + padding: 0.75rem 1rem; + font-size: 1rem; +} + +.form-control::placeholder { + color: #a0a0c0; +} + +.form-control:focus, .form-select:focus { + background-color: var(--accent-color-2); + color: var(--primary-text-color); + border-color: var(--accent-color-1); + box-shadow: 0 0 0 0.25rem rgba(233, 69, 96, 0.25); +} + +.form-label { + font-family: 'Poppins', sans-serif; + font-weight: 500; + color: var(--primary-text-color); +} + +.btn-convert { + background-color: var(--accent-color-1); + color: var(--primary-text-color); + border: none; + padding: 0.75rem 1.5rem; + font-weight: 600; + font-family: 'Poppins', sans-serif; + transition: background-color 0.3s ease; +} + +.btn-convert:hover { + background-color: #d43d51; + color: var(--primary-text-color); +} + +.result-box { + background-color: var(--accent-color-2); + color: var(--primary-text-color); + padding: 1.5rem; + border-radius: 10px; + margin-top: 1.5rem; + text-align: center; + font-size: 1.5rem; + font-weight: 700; + font-family: 'Poppins', sans-serif; +} + +.error-box { + color: var(--accent-color-1); + font-weight: 500; + margin-top: 1rem; +}