forked from OWASP-BLT/BLT
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
543 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,4 +21,4 @@ LANGCHAIN_ENDPOINT="https://api.smith.langchain.com" | |
DATABASE_URL=postgres://user:password@localhost:5432/dbname | ||
|
||
#Sentry DSN | ||
SENTRY_DSN=https://[email protected]/0 | ||
SENTRY_DSN=https://[email protected]/0 |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
from django.contrib import admin | ||
|
||
from .models import Post | ||
|
||
|
||
@admin.register(Post) | ||
class PostAdmin(admin.ModelAdmin): | ||
list_display = ("title", "author", "created_at", "image") | ||
prepopulated_fields = {"slug": ("title",)} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
from django.apps import AppConfig | ||
|
||
|
||
class BlogConfig(AppConfig): | ||
default_auto_field = "django.db.models.BigAutoField" | ||
name = "blog" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# Generated by Django 5.0.8 on 2024-10-30 15:57 | ||
|
||
import django.db.models.deletion | ||
from django.conf import settings | ||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
initial = True | ||
|
||
dependencies = [ | ||
migrations.swappable_dependency(settings.AUTH_USER_MODEL), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name="Post", | ||
fields=[ | ||
( | ||
"id", | ||
models.BigAutoField( | ||
auto_created=True, | ||
primary_key=True, | ||
serialize=False, | ||
verbose_name="ID", | ||
), | ||
), | ||
("title", models.CharField(max_length=200)), | ||
("slug", models.SlugField(unique=True)), | ||
("content", models.TextField()), | ||
("created_at", models.DateTimeField(auto_now_add=True)), | ||
("updated_at", models.DateTimeField(auto_now=True)), | ||
( | ||
"author", | ||
models.ForeignKey( | ||
on_delete=django.db.models.deletion.CASCADE, | ||
to=settings.AUTH_USER_MODEL, | ||
), | ||
), | ||
], | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Generated by Django 5.0.8 on 2024-10-30 18:52 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
("blog", "0001_initial"), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name="post", | ||
name="slug", | ||
field=models.SlugField(blank=True, unique=True), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# Generated by Django 5.0.8 on 2024-10-31 08:48 | ||
|
||
import django.utils.timezone | ||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
("blog", "0002_alter_post_slug"), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name="post", | ||
name="image", | ||
field=models.ImageField(default=django.utils.timezone.now, upload_to=""), | ||
preserve_default=False, | ||
), | ||
] |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
from django.contrib.auth.models import User | ||
from django.db import models | ||
from django.urls import reverse | ||
|
||
|
||
class Post(models.Model): | ||
title = models.CharField(max_length=200) | ||
slug = models.SlugField(unique=True, blank=True) | ||
author = models.ForeignKey(User, on_delete=models.CASCADE) | ||
content = models.TextField() | ||
created_at = models.DateTimeField(auto_now_add=True) | ||
updated_at = models.DateTimeField(auto_now=True) | ||
image = models.ImageField() | ||
|
||
def __str__(self): | ||
return self.title | ||
|
||
def get_absolute_url(self): | ||
return reverse("post_detail", kwargs={"slug": self.slug}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
{% extends "base.html" %} | ||
|
||
{% block content %} | ||
<style> | ||
body { | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
height: 100vh; | ||
margin: 0; | ||
background-color: #f4f4f4; | ||
} | ||
|
||
.confirm-buttons { | ||
display: flex; | ||
gap: 10px; | ||
justify-content: center; | ||
margin-top: 20px; | ||
} | ||
|
||
.delete-button { | ||
padding: 10px 20px; | ||
border: none; | ||
border-radius: 5px; | ||
color: #fff; | ||
font-weight: bold; | ||
background-color: #dc3545; | ||
text-decoration: none; | ||
cursor: pointer; | ||
} | ||
|
||
.delete-button:hover { | ||
background-color: #c82333; | ||
} | ||
|
||
.cancel-button { | ||
padding: 10px 20px; | ||
border: none; | ||
border-radius: 5px; | ||
color: #fff; | ||
font-weight: bold; | ||
background-color: #007bff; | ||
text-decoration: none; | ||
cursor: pointer; | ||
} | ||
|
||
.cancel-button:hover { | ||
background-color: #0056b3; | ||
} | ||
|
||
.post_content { | ||
text-align: center; | ||
margin: 0; | ||
} | ||
</style> | ||
|
||
{% include "includes/sidenav.html" %} | ||
<h1>Confirm Delete</h1> | ||
<p class="post_content">Are you sure you want to delete the post "{{ post.title }}"?</p> | ||
<form method="post" class="confirm-buttons"> | ||
{% csrf_token %} | ||
<button type="submit" class="delete-button">Delete</button> | ||
<a href="{% url 'post_detail' slug=post.slug %}" class="cancel-button">Cancel</a> | ||
</form> | ||
{% endblock content %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
{% extends "base.html" %} | ||
|
||
{% block content %} | ||
<style> | ||
body { | ||
font-family: Arial, sans-serif; | ||
background-color: #f4f4f4; | ||
margin: 0; | ||
padding: 20px; | ||
} | ||
|
||
.post-article { | ||
background-color: #ffffff; | ||
border-radius: 8px; | ||
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1); | ||
padding: 20px; | ||
max-width: 800px; | ||
margin: 0 auto; | ||
} | ||
|
||
.post-title { | ||
font-size: 2.5em; | ||
color: #333; | ||
margin-bottom: 10px; | ||
text-align: center; | ||
} | ||
|
||
.post-meta { | ||
font-size: 1em; | ||
color: #666; | ||
text-align: center; | ||
margin-bottom: 20px; | ||
} | ||
|
||
.post-content { | ||
line-height: 1.6; | ||
color: #444; | ||
} | ||
|
||
.b-update { | ||
display: inline-block; | ||
padding: 10px 20px; | ||
margin: 5px; | ||
border: none; | ||
border-radius: 5px; | ||
color: #fff; | ||
background-color: #007bff; | ||
text-decoration: none; | ||
font-weight: bold; | ||
text-align: center; | ||
} | ||
|
||
.b-update:hover { | ||
background-color: #0056b3; | ||
} | ||
|
||
.b-delete { | ||
display: inline-block; | ||
padding: 10px 20px; | ||
margin: 5px; | ||
border: none; | ||
border-radius: 5px; | ||
color: #fff; | ||
background-color: #dc3545; | ||
text-decoration: none; | ||
font-weight: bold; | ||
text-align: center; | ||
} | ||
|
||
.b-delete:hover { | ||
background-color: #c82333; | ||
} | ||
|
||
.btn-div { | ||
text-align: center; | ||
margin-top: 20px; | ||
} | ||
|
||
.post-image img { | ||
width: 100%; | ||
height: auto; | ||
border-radius: 8px; | ||
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); | ||
margin-bottom: 20px; | ||
} | ||
</style> | ||
|
||
{% include "includes/sidenav.html" %} | ||
<article class="post-article"> | ||
<h1 class="post-title">{{ post.title }}</h1> | ||
<p class="post-meta">By {{ post.author }} on {{ post.created_at }}</p> | ||
<div class="post-content"> | ||
{{ post.content|safe }} | ||
</div> | ||
{% if post.image %} | ||
<div class="post-image"> | ||
<img height="200" width="100%" src="{{ post.image.url }}" alt="{{ post.title }}"> | ||
</div> | ||
{% endif %} | ||
|
||
{% if request.user == post.author %} | ||
<div class="btn-div"> | ||
<a href="{% url 'post_update' slug=post.slug %}" class="b-update">Update Post</a> | ||
<a href="{% url 'post_delete' slug=post.slug %}" class="b-delete">Delete Post</a> | ||
</div> | ||
{% endif %} | ||
</article> | ||
{% endblock content %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
{% extends "base.html" %} | ||
|
||
{% block content %} | ||
<style> | ||
body { | ||
font-family: Arial, sans-serif; | ||
background-color: #f4f4f4; | ||
margin: 0; | ||
padding: 20px; | ||
} | ||
|
||
#form-title { | ||
text-align: center; | ||
color: #333; | ||
margin-bottom: 20px; | ||
font-size: 2em; /* Adjusted font size for better visibility */ | ||
} | ||
|
||
.form-container { | ||
background-color: #ffffff; | ||
border-radius: 8px; | ||
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1); | ||
padding: 20px; | ||
max-width: 600px; | ||
margin: 0 auto; | ||
} | ||
|
||
.form-container button { | ||
background-color: #007bff; | ||
color: black; | ||
border: none; | ||
border-radius: 5px; | ||
padding: 10px 15px; | ||
cursor: pointer; | ||
font-size: 16px; | ||
transition: background-color 0.3s ease; | ||
} | ||
|
||
.form-container button:hover { | ||
background-color: #0056b3; | ||
} | ||
|
||
.form-field { | ||
margin-bottom: 15px; | ||
} | ||
</style> | ||
|
||
{% include "includes/sidenav.html" %} | ||
<h1 id="form-title">{% if form.instance.pk %}Edit{% else %}New{% endif %} Post</h1> | ||
|
||
<div class="form-container"> | ||
<form method="post" enctype="multipart/form-data" novalidate> | ||
{% csrf_token %} | ||
<div class="form-field"> | ||
{{ form.title.label }}<br> | ||
{{ form.title }}<br> | ||
{% for error in form.title.errors %} | ||
<div>{{ error }}</div> | ||
{% endfor %} | ||
</div> | ||
|
||
<div class="form-field"> | ||
{{ form.content.label }}<br> | ||
{{ form.content }}<br> | ||
{% for error in form.content.errors %} | ||
<div>{{ error }}</div> | ||
{% endfor %} | ||
</div> | ||
|
||
<div class="form-field"> | ||
{{ form.image.label }}<br> | ||
{{ form.image }}<br> | ||
{% for error in form.image.errors %} | ||
<div>{{ error }}</div> | ||
{% endfor %} | ||
</div> | ||
|
||
<button type="submit">Save</button> | ||
</form> | ||
</div> | ||
|
||
<link rel="stylesheet" href="https://unpkg.com/easymde/dist/easymde.min.css"> | ||
<script src="https://unpkg.com/easymde/dist/easymde.min.js"></script> | ||
<script> | ||
var easyMDE = new EasyMDE({ element: document.getElementById('id_content') }); | ||
</script> | ||
{% endblock content %} |
Oops, something went wrong.