diff --git a/ai/__pycache__/__init__.cpython-311.pyc b/ai/__pycache__/__init__.cpython-311.pyc new file mode 100644 index 0000000..9beeae7 Binary files /dev/null and b/ai/__pycache__/__init__.cpython-311.pyc differ diff --git a/ai/__pycache__/local_ai_api.cpython-311.pyc b/ai/__pycache__/local_ai_api.cpython-311.pyc new file mode 100644 index 0000000..ae12bda Binary files /dev/null and b/ai/__pycache__/local_ai_api.cpython-311.pyc differ diff --git a/core/__pycache__/models.cpython-311.pyc b/core/__pycache__/models.cpython-311.pyc index e061640..51ad1fd 100644 Binary files a/core/__pycache__/models.cpython-311.pyc and b/core/__pycache__/models.cpython-311.pyc differ diff --git a/core/__pycache__/urls.cpython-311.pyc b/core/__pycache__/urls.cpython-311.pyc index 5a69659..40d6968 100644 Binary files a/core/__pycache__/urls.cpython-311.pyc and b/core/__pycache__/urls.cpython-311.pyc differ diff --git a/core/__pycache__/views.cpython-311.pyc b/core/__pycache__/views.cpython-311.pyc index 2a36fd6..c3e25ff 100644 Binary files a/core/__pycache__/views.cpython-311.pyc and b/core/__pycache__/views.cpython-311.pyc differ diff --git a/core/migrations/0001_initial.py b/core/migrations/0001_initial.py new file mode 100644 index 0000000..c975305 --- /dev/null +++ b/core/migrations/0001_initial.py @@ -0,0 +1,48 @@ +# Generated by Django 5.2.7 on 2026-02-08 03:43 + +import django.db.models.deletion +import django.utils.timezone +from django.db import migrations, models + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + ] + + operations = [ + migrations.CreateModel( + name='Project', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('title', models.CharField(max_length=255)), + ('description', models.TextField(blank=True)), + ('created_at', models.DateTimeField(default=django.utils.timezone.now)), + ('updated_at', models.DateTimeField(auto_now=True)), + ('status', models.CharField(choices=[('draft', 'Draft'), ('scripting', 'Scripting'), ('processing', 'Processing'), ('completed', 'Completed')], default='draft', max_length=20)), + ], + ), + migrations.CreateModel( + name='MediaAsset', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('file', models.FileField(upload_to='assets/%Y/%m/%d/')), + ('asset_type', models.CharField(choices=[('video', 'Video'), ('audio', 'Audio'), ('image', 'Image')], max_length=10)), + ('original_name', models.CharField(max_length=255)), + ('created_at', models.DateTimeField(default=django.utils.timezone.now)), + ('project', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='assets', to='core.project')), + ], + ), + migrations.CreateModel( + name='Script', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('prompt', models.TextField()), + ('content', models.TextField()), + ('created_at', models.DateTimeField(default=django.utils.timezone.now)), + ('project', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='scripts', to='core.project')), + ], + ), + ] diff --git a/core/migrations/__pycache__/0001_initial.cpython-311.pyc b/core/migrations/__pycache__/0001_initial.cpython-311.pyc new file mode 100644 index 0000000..f625734 Binary files /dev/null and b/core/migrations/__pycache__/0001_initial.cpython-311.pyc differ diff --git a/core/models.py b/core/models.py index 71a8362..010acab 100644 --- a/core/models.py +++ b/core/models.py @@ -1,3 +1,44 @@ from django.db import models +from django.utils import timezone -# Create your models here. +class Project(models.Model): + STATUS_CHOICES = [ + ('draft', 'Draft'), + ('scripting', 'Scripting'), + ('processing', 'Processing'), + ('completed', 'Completed'), + ] + + title = models.CharField(max_length=255) + description = models.TextField(blank=True) + created_at = models.DateTimeField(default=timezone.now) + updated_at = models.DateTimeField(auto_now=True) + status = models.CharField(max_length=20, choices=STATUS_CHOICES, default='draft') + + def __str__(self): + return self.title + +class Script(models.Model): + project = models.ForeignKey(Project, on_delete=models.CASCADE, related_name='scripts') + prompt = models.TextField() + content = models.TextField() # JSON or structured text from AI + created_at = models.DateTimeField(default=timezone.now) + + def __str__(self): + return f"Script for {self.project.title} ({self.created_at.strftime('%Y-%m-%d')})" + +class MediaAsset(models.Model): + ASSET_TYPE_CHOICES = [ + ('video', 'Video'), + ('audio', 'Audio'), + ('image', 'Image'), + ] + + project = models.ForeignKey(Project, on_delete=models.CASCADE, related_name='assets') + file = models.FileField(upload_to='assets/%Y/%m/%d/') + asset_type = models.CharField(max_length=10, choices=ASSET_TYPE_CHOICES) + original_name = models.CharField(max_length=255) + created_at = models.DateTimeField(default=timezone.now) + + def __str__(self): + return self.original_name \ No newline at end of file diff --git a/core/templates/base.html b/core/templates/base.html index 1e7e5fb..f92452d 100644 --- a/core/templates/base.html +++ b/core/templates/base.html @@ -1,25 +1,165 @@ +{% load static %} - - - {% block title %}Knowledge Base{% endblock %} - {% if project_description %} - - - - {% endif %} - {% if project_image_url %} - - - {% endif %} - {% load static %} - - {% block head %}{% endblock %} + + + {{ title|default:"AI Video Creator" }} + + + + + + + + + + + + + {% block extra_head %}{% endblock %} - - {% block content %}{% endblock %} - - + + +
+ {% block content %}{% endblock %} +
+ + + + + + {% block extra_js %}{% endblock %} + + \ No newline at end of file diff --git a/core/templates/core/index.html b/core/templates/core/index.html index faec813..b7b4725 100644 --- a/core/templates/core/index.html +++ b/core/templates/core/index.html @@ -1,145 +1,57 @@ -{% extends "base.html" %} - -{% block title %}{{ project_name }}{% endblock %} - -{% block head %} - - - - -{% endblock %} +{% extends 'base.html' %} {% block content %} -
-
-

Analyzing your requirements and generating your app…

-
- Loading… +
+
+
+

Create Magic with AI.

+

Transform your ideas into viral short-form videos in seconds. No editing skills required.

+
+
+
+

New Project

+
+ {% csrf_token %} +
+ + +
+
+ + +
+ +
+
+
-

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" }} -

-
-
- -{% endblock %} \ No newline at end of file + +
+
+

Recent Projects

+
+ + {% for project in projects %} +
+
+
+ {{ project.get_status_display }} + {{ project.created_at|date:"M d, Y" }} +
+

{{ project.title }}

+

{{ project.description|truncatewords:20 }}

+ +
+
+ {% empty %} +
+
+

No projects yet. Start by creating your first one above!

+
+
+ {% endfor %} +
+ +{% endblock %} diff --git a/core/templates/core/project_detail.html b/core/templates/core/project_detail.html new file mode 100644 index 0000000..c72cfbf --- /dev/null +++ b/core/templates/core/project_detail.html @@ -0,0 +1,167 @@ +{% extends 'base.html' %} + +{% block content %} +
+ + +
+
+
+
+

AI Script Generator

+ {{ project.get_status_display }} +
+ +
+ {% csrf_token %} +
+ + +
+
AI will brainstorm scenes, actions, and dialogue for your short video.
+
+ +
+
+
+

Generated Script

+ +
+
+
+
+
+ +
+

Media Assets

+
+
+
+
Upload Clips
+ +
+
+ {% for asset in assets %} +
+
+
+ {{ asset.original_name }} +
+
+
+ {% empty %} +
+

Your uploaded video clips and images will appear here.

+
+ {% endfor %} +
+
+
+ +
+
+

Project Details

+
+ +
{{ project.title }}
+
+
+ +
{{ project.created_at|date:"M d, Y H:i" }}
+
+
+ +
{{ project.description|default:"No description provided." }}
+
+
+ +
+ +
+

Script History

+
+ {% for script in scripts %} +
+
{{ script.created_at|date:"M d, H:i" }}
+
{{ script.prompt|truncatechars:40 }}
+ +
+ {% empty %} +

No scripts generated yet.

+ {% endfor %} +
+
+
+
+
+{% endblock %} + +{% block extra_js %} + +{% endblock %} diff --git a/core/urls.py b/core/urls.py index 6299e3d..1974411 100644 --- a/core/urls.py +++ b/core/urls.py @@ -1,7 +1,9 @@ from django.urls import path - -from .views import home +from . import views urlpatterns = [ - path("", home, name="home"), -] + path('', views.index, name='index'), + path('project/create/', views.create_project, name='create_project'), + path('project//', views.project_detail, name='project_detail'), + path('project//generate-script/', views.generate_script, name='generate_script'), +] \ No newline at end of file diff --git a/core/views.py b/core/views.py index c9aed12..281a283 100644 --- a/core/views.py +++ b/core/views.py @@ -1,25 +1,68 @@ -import os -import platform +import json +from django.shortcuts import render, redirect, get_object_or_404 +from django.http import JsonResponse +from django.views.decorators.http import require_POST +from .models import Project, Script, MediaAsset +from ai.local_ai_api import LocalAIApi -from django import get_version as django_version -from django.shortcuts import render -from django.utils import timezone +def index(request): + projects = Project.objects.all().order_by('-created_at') + return render(request, 'core/index.html', { + 'projects': projects, + 'title': 'Creator Studio Dashboard', + }) +@require_POST +def create_project(request): + title = request.POST.get('title', 'Untitled Project') + description = request.POST.get('description', '') + project = Project.objects.create(title=title, description=description) + return redirect('project_detail', project_id=project.id) -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 project_detail(request, project_id): + project = get_object_or_404(Project, id=project_id) + scripts = project.scripts.all().order_by('-created_at') + assets = project.assets.all().order_by('-created_at') + return render(request, 'core/project_detail.html', { + 'project': project, + 'scripts': scripts, + 'assets': assets, + 'title': f'Studio: {project.title}', + }) - 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) +@require_POST +def generate_script(request, project_id): + project = get_object_or_404(Project, id=project_id) + prompt = request.POST.get('prompt', '') + + if not prompt: + return JsonResponse({'success': False, 'error': 'Prompt is required'}) + + # Construct a high-quality AI prompt for video scripting + ai_input = [ + {"role": "system", "content": "You are an expert social media content creator and scriptwriter for TikTok, Reels, and YouTube Shorts. Generate a catchy script with Scene details, Action, and Dialogue/Narration."}, + {"role": "user", "content": f"Generate a short-form video script for the following idea: {prompt}"} + ] + + response = LocalAIApi.create_response({ + "input": ai_input, + }) + + if response.get("success"): + content = LocalAIApi.extract_text(response) + script = Script.objects.create( + project=project, + prompt=prompt, + content=content + ) + return JsonResponse({ + 'success': True, + 'content': content, + 'script_id': script.id, + 'created_at': script.created_at.strftime('%Y-%m-%d %H:%M') + }) + else: + return JsonResponse({ + 'success': False, + 'error': response.get('message', 'AI Generation failed') + }) \ No newline at end of file