Revert to version 5841ed7
This commit is contained in:
parent
6bc479b5c0
commit
2165fe99f0
Binary file not shown.
Binary file not shown.
@ -1,30 +1,11 @@
|
||||
{% load static %}
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>{{ page_title|default:"Unit Converter" }}</title>
|
||||
<meta name="description" content="A modern, fast, and free engineering unit converter.">
|
||||
|
||||
<!-- Google Fonts -->
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@400;600;700&family=Roboto:wght@400;500&display=swap" rel="stylesheet">
|
||||
|
||||
<!-- Bootstrap CSS -->
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||
|
||||
<!-- Custom CSS -->
|
||||
<link rel="stylesheet" href="{% static 'css/custom.css' %}">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<main class="container-fluid">
|
||||
{% block content %}{% endblock %}
|
||||
</main>
|
||||
|
||||
<!-- Bootstrap JS -->
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
<title>{% block title %}Knowledge Base{% endblock %}</title>
|
||||
{% block head %}{% endblock %}
|
||||
</head>
|
||||
<body>
|
||||
{% block content %}{% endblock %}
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@ -1,65 +1,154 @@
|
||||
{% extends "base.html" %}
|
||||
{% block content %}
|
||||
<div class="converter-wrapper">
|
||||
<div class="text-center mb-4">
|
||||
<h1>Unit Converter</h1>
|
||||
<p class="text-muted">A modern, fast, and free engineering unit converter.</p>
|
||||
</div>
|
||||
|
||||
<form method="post" action="{% url 'index' %}">
|
||||
{% csrf_token %}
|
||||
<div class="row g-3 align-items-end">
|
||||
<!-- Input Value -->
|
||||
<div class="col-md-12">
|
||||
<label for="value_in" class="form-label">Value</label>
|
||||
<input type="text" class="form-control" id="value_in" name="value_in" placeholder="Enter a value" value="{{ value_in|default:'' }}" required>
|
||||
</div>
|
||||
{% block title %}{{ project_name }}{% endblock %}
|
||||
|
||||
<!-- From Unit -->
|
||||
<div class="col-md-6">
|
||||
<label for="unit_in" class="form-label">From</label>
|
||||
<select class="form-select" id="unit_in" name="unit_in">
|
||||
{% for category, unit_list in units.items %}
|
||||
<optgroup label="{{ category }}">
|
||||
{% for unit in unit_list %}
|
||||
<option value="{{ unit }}" {% if unit == unit_in %}selected{% endif %}>{{ unit|title }}</option>
|
||||
{% endfor %}
|
||||
</optgroup>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</div>
|
||||
{% block head %}
|
||||
{% if project_description %}
|
||||
<meta name="description" content="{{ project_description }}">
|
||||
<meta property="og:description" content="{{ project_description }}">
|
||||
<meta property="twitter:description" content="{{ project_description }}">
|
||||
{% endif %}
|
||||
{% if project_image_url %}
|
||||
<meta property="og:image" content="{{ project_image_url }}">
|
||||
<meta property="twitter:image" content="{{ project_image_url }}">
|
||||
{% endif %}
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;700&display=swap" rel="stylesheet">
|
||||
<style>
|
||||
:root {
|
||||
--bg-color-start: #6a11cb;
|
||||
--bg-color-end: #2575fc;
|
||||
--text-color: #ffffff;
|
||||
--card-bg-color: rgba(255, 255, 255, 0.01);
|
||||
--card-border-color: rgba(255, 255, 255, 0.1);
|
||||
}
|
||||
|
||||
<!-- To Unit -->
|
||||
<div class="col-md-6">
|
||||
<label for="unit_out" class="form-label">To</label>
|
||||
<select class="form-select" id="unit_out" name="unit_out">
|
||||
{% for category, unit_list in units.items %}
|
||||
<optgroup label="{{ category }}">
|
||||
{% for unit in unit_list %}
|
||||
<option value="{{ unit }}" {% if unit == unit_out %}selected{% endif %}>{{ unit|title }}</option>
|
||||
{% endfor %}
|
||||
</optgroup>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
* {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
<div class="d-grid mt-4">
|
||||
<button type="submit" class="btn btn-convert">Convert</button>
|
||||
</div>
|
||||
</form>
|
||||
body {
|
||||
margin: 0;
|
||||
font-family: 'Inter', sans-serif;
|
||||
background: linear-gradient(45deg, var(--bg-color-start), var(--bg-color-end));
|
||||
color: var(--text-color);
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
min-height: 100vh;
|
||||
text-align: center;
|
||||
overflow: hidden;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
{% if result is not None %}
|
||||
<div class="result-box">
|
||||
{{ result }}
|
||||
</div>
|
||||
{% endif %}
|
||||
body::before {
|
||||
content: '';
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
background-image: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='100' height='100' viewBox='0 0 100 100'><path d='M-10 10L110 10M10 -10L10 110' stroke-width='1' stroke='rgba(255,255,255,0.05)'/></svg>");
|
||||
animation: bg-pan 20s linear infinite;
|
||||
z-index: -1;
|
||||
}
|
||||
|
||||
{% if error %}
|
||||
<div class="error-box text-center">
|
||||
{{ error }}
|
||||
</div>
|
||||
{% endif %}
|
||||
@keyframes bg-pan {
|
||||
0% {
|
||||
background-position: 0% 0%;
|
||||
}
|
||||
|
||||
</div>
|
||||
100% {
|
||||
background-position: 100% 100%;
|
||||
}
|
||||
}
|
||||
|
||||
main {
|
||||
padding: 2rem;
|
||||
}
|
||||
|
||||
.card {
|
||||
background: var(--card-bg-color);
|
||||
border: 1px solid var(--card-border-color);
|
||||
border-radius: 16px;
|
||||
padding: 2.5rem 2rem;
|
||||
backdrop-filter: blur(20px);
|
||||
-webkit-backdrop-filter: blur(20px);
|
||||
box-shadow: 0 12px 36px rgba(0, 0, 0, 0.25);
|
||||
}
|
||||
|
||||
h1 {
|
||||
font-size: clamp(2.2rem, 3vw + 1.2rem, 3.2rem);
|
||||
font-weight: 700;
|
||||
margin: 0 0 1.2rem;
|
||||
letter-spacing: -0.02em;
|
||||
}
|
||||
|
||||
p {
|
||||
margin: 0.5rem 0;
|
||||
font-size: 1.1rem;
|
||||
opacity: 0.92;
|
||||
}
|
||||
|
||||
.loader {
|
||||
margin: 1.5rem auto;
|
||||
width: 56px;
|
||||
height: 56px;
|
||||
border: 4px solid rgba(255, 255, 255, 0.25);
|
||||
border-top-color: #fff;
|
||||
border-radius: 50%;
|
||||
animation: spin 1s linear infinite;
|
||||
}
|
||||
|
||||
@keyframes spin {
|
||||
to {
|
||||
transform: rotate(360deg);
|
||||
}
|
||||
}
|
||||
|
||||
.runtime code {
|
||||
background: rgba(0, 0, 0, 0.25);
|
||||
padding: 0.15rem 0.45rem;
|
||||
border-radius: 4px;
|
||||
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
|
||||
}
|
||||
|
||||
.sr-only {
|
||||
position: absolute;
|
||||
width: 1px;
|
||||
height: 1px;
|
||||
padding: 0;
|
||||
margin: -1px;
|
||||
overflow: hidden;
|
||||
clip: rect(0, 0, 0, 0);
|
||||
border: 0;
|
||||
}
|
||||
|
||||
footer {
|
||||
position: absolute;
|
||||
bottom: 1rem;
|
||||
width: 100%;
|
||||
text-align: center;
|
||||
font-size: 0.85rem;
|
||||
opacity: 0.75;
|
||||
}
|
||||
</style>
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<main>
|
||||
<div class="card">
|
||||
<h1>Analyzing your requirements and generating your app…</h1>
|
||||
<div class="loader" role="status" aria-live="polite" aria-label="Applying initial changes">
|
||||
<span class="sr-only">Loading…</span>
|
||||
</div>
|
||||
<p class="hint">AppWizzy AI is collecting your requirements and applying the first changes.</p>
|
||||
<p class="hint">This page will refresh automatically as the plan is implemented.</p>
|
||||
<p class="runtime">
|
||||
Runtime: Django <code>{{ django_version }}</code> · Python <code>{{ python_version }}</code>
|
||||
— UTC <code>{{ current_time|date:"Y-m-d H:i:s" }}</code>
|
||||
</p>
|
||||
</div>
|
||||
</main>
|
||||
<footer>
|
||||
Page updated: {{ current_time|date:"Y-m-d H:i:s" }} (UTC)
|
||||
</footer>
|
||||
{% endblock %}
|
||||
@ -1,6 +1,7 @@
|
||||
from django.urls import path
|
||||
from .views import IndexView
|
||||
|
||||
from .views import home
|
||||
|
||||
urlpatterns = [
|
||||
path('', IndexView.as_view(), name='index'),
|
||||
]
|
||||
path("", home, name="home"),
|
||||
]
|
||||
|
||||
@ -1,75 +1,25 @@
|
||||
import os
|
||||
import platform
|
||||
|
||||
from django import get_version as django_version
|
||||
from django.shortcuts import render
|
||||
from django.views import View
|
||||
from django.utils import timezone
|
||||
|
||||
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 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
|
||||
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()
|
||||
|
||||
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)
|
||||
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)
|
||||
|
||||
@ -1,98 +0,0 @@
|
||||
/*
|
||||
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;
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user