Commit c1e0ad74 authored by Anurag Kumar's avatar Anurag Kumar

final commit

parents
from django.contrib import admin
from blog.models import Post, BlogComment
admin.site.register((Post, BlogComment))
from django.apps import AppConfig
class BlogConfig(AppConfig):
name = 'blog'
# Generated by Django 3.1.3 on 2021-12-01 11:28
from django.db import migrations, models
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='Post',
fields=[
('sno', models.AutoField(primary_key=True, serialize=False)),
('title', models.CharField(max_length=255)),
('author', models.CharField(max_length=14)),
('slug', models.CharField(max_length=130)),
('timeStamp', models.DateTimeField(blank=True)),
('content', models.TextField()),
],
),
]
# Generated by Django 3.1.3 on 2021-12-01 11:44
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
import django.utils.timezone
class Migration(migrations.Migration):
dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
('blog', '0001_initial'),
]
operations = [
migrations.CreateModel(
name='BlogComment',
fields=[
('sno', models.AutoField(primary_key=True, serialize=False)),
('comment', models.TextField()),
('timestamp', models.DateTimeField(default=django.utils.timezone.now)),
('parent', models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to='blog.blogcomment')),
('post', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='blog.post')),
('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
],
),
]
from django.db import models
from django.contrib.auth.models import User
from django.utils.timezone import now
class Post(models.Model):
sno=models.AutoField(primary_key=True)
title=models.CharField(max_length=255)
author=models.CharField(max_length=14)
slug=models.CharField(max_length=130)
timeStamp=models.DateTimeField(blank=True)
content=models.TextField()
def __str__(self):
return self.title + " by " + self.author
class BlogComment(models.Model):
sno= models.AutoField(primary_key=True)
comment=models.TextField()
user=models.ForeignKey(User, on_delete=models.CASCADE)
post=models.ForeignKey(Post, on_delete=models.CASCADE)
parent=models.ForeignKey('self',on_delete=models.CASCADE, null=True )
timestamp= models.DateTimeField(default=now)
def __str__(self):
return self.comment[0:13] + "..." + "by" + " " + self.user.username
from django import template
register=template.Library()
@register.filter(name='get_val')
def get_val(dict, key):
return dict.get(key)
\ No newline at end of file
from django.test import TestCase
# Create your tests here.
from django.contrib import admin
from django.urls import path, include
from . import views
urlpatterns = [
path('postComment', views.postComment, name="postComment"),
path('', views.blogHome, name="bloghome"),
path('<str:slug>', views.blogPost, name="blogPost"),
]
from django.shortcuts import render, HttpResponse, redirect
from blog.models import Post, BlogComment
from django.contrib import messages
from django.contrib.auth.models import User
from blog.templatetags import extras
# Create your views here.
def blogHome(request):
allPosts= Post.objects.all()
context={'allPosts': allPosts}
return render(request, "blog/blogHome.html", context)
def blogPost(request, slug):
post=Post.objects.filter(slug=slug).first()
comments= BlogComment.objects.filter(post=post, parent=None)
replies= BlogComment.objects.filter(post=post).exclude(parent=None)
replyDict={}
for reply in replies:
if reply.parent.sno not in replyDict.keys():
replyDict[reply.parent.sno]=[reply]
else:
replyDict[reply.parent.sno].append(reply)
context={'post':post, 'comments': comments, 'user': request.user, 'replyDict': replyDict}
return render(request, "blog/blogPost.html", context)
def postComment(request):
if request.method == "POST":
comment=request.POST.get('comment')
user=request.user
postSno =request.POST.get('postSno')
post= Post.objects.get(sno=postSno)
parentSno= request.POST.get('parentSno')
if parentSno=="":
comment=BlogComment(comment= comment, user=user, post=post)
comment.save()
messages.success(request, "Your comment has been posted successfully")
else:
parent= BlogComment.objects.get(sno=parentSno)
comment=BlogComment(comment= comment, user=user, post=post , parent=parent)
comment.save()
messages.success(request, "Your reply has been posted successfully")
return redirect(f"/blog/{post.slug}")
File added
from django.contrib import admin
from .models import Contact
# Register your models here.
admin.site.register(Contact)
from django.apps import AppConfig
class HomeConfig(AppConfig):
name = 'home'
# Generated by Django 3.1.3 on 2021-12-01 11:14
from django.db import migrations, models
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='Contact',
fields=[
('sno', models.AutoField(primary_key=True, serialize=False)),
('name', models.CharField(max_length=255)),
('phone', models.CharField(max_length=13)),
('email', models.CharField(max_length=100)),
('content', models.TextField()),
('timeStamp', models.DateTimeField(auto_now_add=True)),
],
),
]
from django.db import models
# Create your models here.
class Contact(models.Model):
sno= models.AutoField(primary_key=True)
name= models.CharField(max_length=255)
phone= models.CharField(max_length=13)
email= models.CharField(max_length=100)
content= models.TextField()
timeStamp=models.DateTimeField(auto_now_add=True, blank=True)
def __str__(self):
return "Message from " + self.name + ' - ' + self.email
\ No newline at end of file
from django.test import TestCase
# Create your tests here.
from django.contrib import admin
from django.urls import path, include
from home import views
urlpatterns = [
path('', views.home, name="home"),
path('contact', views.contact, name="contact"),
path('about', views.about, name="about"),
path('search', views.search, name="search"),
path('search', views.search, name="search"),
path('signup', views.handleSignUp, name="handleSignUp"),
path('login', views.handeLogin, name="handleLogin"),
path('logout', views.handelLogout, name="handleLogout"),
]
from django.shortcuts import render, HttpResponse, redirect
from home.models import Contact
from django.contrib import messages
from django.contrib.auth.models import User
from django.contrib.auth import authenticate, login, logout
from blog.models import Post
def home(request):
return render(request, "home/home.html")
def contact(request):
if request.method=="POST":
name=request.POST['name']
email=request.POST['email']
phone=request.POST['phone']
content =request.POST['content']
if len(name)<2 or len(email)<3 or len(phone)<10 or len(content)<4:
messages.error(request, "Please fill the form correctly")
else:
contact=Contact(name=name, email=email, phone=phone, content=content)
contact.save()
messages.success(request, "Your message has been successfully sent")
return render(request, "home/contact.html")
def search(request):
query=request.GET['query']
if len(query)>78:
allPosts=Post.objects.none()
else:
allPostsTitle= Post.objects.filter(title__icontains=query)
allPostsAuthor= Post.objects.filter(author__icontains=query)
allPostsContent =Post.objects.filter(content__icontains=query)
allPosts= allPostsTitle.union(allPostsContent, allPostsAuthor)
if allPosts.count()==0:
messages.warning(request, "No search results found. Please refine your query.")
params={'allPosts': allPosts, 'query': query}
return render(request, 'home/search.html', params)
def handleSignUp(request):
if request.method=="POST":
# Get the post parameters
username=request.POST['username']
email=request.POST['email']
fname=request.POST['fname']
lname=request.POST['lname']
pass1=request.POST['pass1']
pass2=request.POST['pass2']
# check for errorneous input
if len(username)<10:
messages.error(request, " Your user name must be under 10 characters")
return redirect('home')
if not username.isalnum():
messages.error(request, " User name should only contain letters and numbers")
return redirect('home')
if (pass1!= pass2):
messages.error(request, " Passwords do not match")
return redirect('home')
# Create the user
myuser = User.objects.create_user(username, email, pass1)
myuser.first_name= fname
myuser.last_name= lname
myuser.save()
messages.success(request, " Your iCoder has been successfully created")
return redirect('home')
else:
return HttpResponse("404 - Not found")
def handeLogin(request):
if request.method=="POST":
# Get the post parameters
loginusername=request.POST['loginusername']
loginpassword=request.POST['loginpassword']
user=authenticate(username= loginusername, password= loginpassword)
if user is not None:
login(request, user)
messages.success(request, "Successfully Logged In")
return redirect("home")
else:
messages.error(request, "Invalid credentials! Please try again")
return redirect("home")
return HttpResponse("404- Not found")
return HttpResponse("login")
def handelLogout(request):
logout(request)
messages.success(request, "Successfully logged out")
return redirect('home')
def about(request):
return render(request, "home/about.html")
"""
ASGI config for iCoder project.
It exposes the ASGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/3.1/howto/deployment/asgi/
"""
import os
from django.core.asgi import get_asgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'iCoder.settings')
application = get_asgi_application()
"""
Django settings for iCoder project.
Generated by 'django-admin startproject' using Django 3.1.1.
For more information on this file, see
https://docs.djangoproject.com/en/3.1/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/3.1/ref/settings/
"""
import os
from django.contrib.messages import constants as messages
from pathlib import Path
# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/3.1/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'l=rlgjubv9^b)1*zwxb@hwsdu&k_r=(xaz$g!d1vd#+@md+mn^'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
ALLOWED_HOSTS = []
# Application definition
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'home.apps.HomeConfig',
'blog.apps.BlogConfig',
'django.contrib.humanize',
]
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
ROOT_URLCONF = 'iCoder.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': ['templates'],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
WSGI_APPLICATION = 'iCoder.wsgi.application'
# Database
# https://docs.djangoproject.com/en/3.1/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': BASE_DIR / 'db.sqlite3',
}
}
# Password validation
# https://docs.djangoproject.com/en/3.1/ref/settings/#auth-password-validators
AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
},
]
# Internationalization
# https://docs.djangoproject.com/en/3.1/topics/i18n/
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_L10N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/3.1/howto/static-files/
STATIC_URL = '/static/'
STATICFILES_DIRS = [
os.path.join(BASE_DIR, "static"),
]
MESSAGE_TAGS = {
messages.ERROR:'danger'
}
"""iCoder URL Configuration
The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/3.1/topics/http/urls/
Examples:
Function views
1. Add an import: from my_app import views
2. Add a URL to urlpatterns: path('', views.home, name='home')
Class-based views
1. Add an import: from other_app.views import Home
2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
Including another URLconf
1. Import the include() function: from django.urls import include, path
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import path, include
admin.site.site_header="iCoder Admin"
admin.site.site_title="iCoder Admin Panel"
admin.site.index_title="Welcome to iCoder Admin Panel"
urlpatterns = [
path('admin/', admin.site.urls),
path('', include('home.urls')),
path('blog/', include('blog.urls')),
]
"""
WSGI config for iCoder project.
It exposes the WSGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/3.1/howto/deployment/wsgi/
"""
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'iCoder.settings')
application = get_wsgi_application()
#!/usr/bin/env python
"""Django's command-line utility for administrative tasks."""
import os
import sys
def main():
"""Run administrative tasks."""
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'iCoder.settings')
try:
from django.core.management import execute_from_command_line
except ImportError as exc:
raise ImportError(
"Couldn't import Django. Are you sure it's installed and "
"available on your PYTHONPATH environment variable? Did you "
"forget to activate a virtual environment?"
) from exc
execute_from_command_line(sys.argv)
if __name__ == '__main__':
main()
<!doctype html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" integrity="sha384-JcKb8q3iqJ61gNV9KGb8thSsNjpSL0n8PARn9HuZOnIxN0hoP+VmmDGMN5t9UJ0Z" crossorigin="anonymous">
<title>{% block title %} {% endblock title %}</title>
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
<a class="navbar-brand" href="/">iCoder</a>
<button class="navbar-toggler" type="button" data-toggle ="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav mr-auto">
<li class="nav-item {% block homeactive %} {% endblock homeactive %}">
<a class="nav-link" href="/">Home <span class="sr-only">(current)</span></a>
</li>
<li class="nav-item {% block aboutactive %} {% endblock aboutactive %}" >
<a class="nav-link" href="/about">About</a>
</li>
<li class="nav-item {% block contactactive %} {% endblock contactactive %} ">
<a class="nav-link" href="/contact">Contact</a>
</li>
<li class="nav-item {% block blogactive %} {% endblock blogactive %} ">
<a class="nav-link" href="/blog">Blog</a>
</li>
</ul>
<div class="ml-auto form-inline ">
<form method="get" action="/search"class="my-2 my-lg-0 mx-3">
<input class="form-control mr-sm-2" type="search" placeholder="Search" aria-label="Search" name="query" id="query">
<button class="btn btn-primary my-2 my-sm-0 " type="submit">Search</button>
<a href="/admin" role="button" target="_blank" class="btn btn-outline-success m-2 my-sm-0"> Admin Panel </a>
</form>
{% if user.is_authenticated %}
<ul class="navbar-nav mr-2">
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href='#' id="navbarDropdown" role="button" data-toggle="dropdown"> Welcome {{request.user}}</a>
<div class="dropdown-menu" aria-labelledby="navbarDropdown">
<a class="dropdown-item" href="/logout">Logout</a>
</div>
</li>
</ul>
</div>
{% else %}
<!-- Button to trigger Login modal -->
<button type="button" class="btn btn-primary mr-2" data-toggle="modal" data-target="#loginModal">
Login
</button>
<button type="button" class="btn btn-primary mr-2" data-toggle="modal" data-target="#signupModal">
SignUp
</button>
{% endif %}
</div>
</nav>
{% for message in messages %}
<div class="alert alert-{{ message.tags }} alert-dismissible fade show" role="alert">
<strong>Message : </strong> {{ message }}
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
{% endfor %}
<!-- SignUp Modal -->
<div class="modal fade" id="signupModal" tabindex="-1" aria-labelledby="signupModal" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="signupModalTitle">SignUp Here</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
<form action= "/signup" method='post'>
<div class="form-group">
<label for="username">Username</label>
<input type="text" class="form-control" id="username" name="username" placeholder="Choose a unique username" required>
</div>
<div class="form-group">
<label for="fname">First Name</label>
<input type="text" class="form-control" id="fname" name="fname" placeholder="Enter Your First Name" required>
</div>
<div class="form-group">
<label for="lname">Last Name</label>
<input type="text" class="form-control" id="lname" name="lname" placeholder="Enter Your Last Name" required>
</div>
<div class="form-group">
<label for="email">Email address</label>
<input type="email" class="form-control" id="email" name="email" placeholder="name@example.com" required>
</div>
<div class="form-group">
<label for="pass1">Choose a password</label>
<input type="password" class="form-control" id="pass1" name="pass1" placeholder="Choose Your Password" required>
</div>
<div class="form-group">
<label for="pass2">Confirm Password</label>
<input type="password" class="form-control" id="pass2" name="pass2" placeholder="Enter your password again" required>
</div>
{% csrf_token %}
<button type="submit" class="btn btn-primary">Submit</button>
</form>
</div>
<div class="modal-footer">
</div>
</div>
</div>
</div>
{% block body %} {% endblock body %}
{% block js %}
{% endblock js %}
<!-- Login Modal -->
<div class="modal fade" id="loginModal" tabindex="-1" aria-labelledby="loginModal" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="loginModalTitle">Login Here</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
<form action="/login" method="POST"> {% csrf_token %}
<div class="form-group">
<label for="username">Username</label>
<input type="text" class="form-control" id="loginusername" name="loginusername" placeholder="Enter your username "required>
</div>
<div class="form-group">
<label for="pass">Enter your password </label>
<input type="password" class="form-control" id="loginpassword" name="loginpassword" placeholder="Enter your password "required>
</div>
<button type="submit" class="btn btn-primary">Submit</button>
</form>
</div>
<div class="modal-footer">
</div>
<!-- Optional JavaScript -->
<!-- jQuery first, then Popper.js, then Bootstrap JS -->
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.1/dist/umd/popper.min.js" integrity="sha384-9/reFTGAW83EW2RDu2S0VKaIzap3H66lZH81PoYlFhbGU+6BZp6G7niu735Sk7lN" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js" integrity="sha384-B4gt1jrGC7Jh4AgTPSdUtOBvfO8shuf57BaghqFfPlYxofvL8/KUEfYiJOMMV+rV" crossorigin="anonymous"></script>
</body>
</html>
\ No newline at end of file
{% extends 'base.html' %}
{% block title %} BlogHome {% endblock title %}
{% block js %}
<script>
let previews=document.getElementsByClassName('preview');
Array.from(previews).forEach((element))=>{
element.innerHTML=element.innerText;
})
{% endblock js %}
{% block blogactive %} active {% endblock blogactive %}
{% block body %}
<div class="container my-3">
<h2>Coding Articles by iCoder</h2>
{% for post in allPosts %}
<div class="row no-gutters border rounded overflow-hidden flex-md-row mb-4 shadow-sm h-md-250 my-4 position-relative">
<div class="col p-4 d-flex flex-column position-static">
<strong class="d-inline-block mb-2 text-primary">Article by {{post.author}}</strong>
<h3 class="mb-0"><a class="text-dark" href="/blog/{{post.slug}}"{{post.title}} </a> </h3>
<div class="mb-1 text-muted">{{post.datetime}}</div>
<p class="card-text mb-auto">{{post.content|safe| truncatechars:500}}</p>
<div class="my-2">
<a href="/blog/{{post.slug}}" role="button" class="btn btn-primary">Continue reading</a>
</div>
</div>
<div class="col-auto d-none d-lg-block">
<svg class="bd-placeholder-img" width="200" height="250" xmlns="http://www.w3.org/2000/svg" preserveAspectRatio="xMidYMid slice" focusable="false" role="img" aria-label="Placeholder: Thumbnail">
<title>Placeholder</title>
<rect width="100%" height="100%" fill="#55595c"></rect><text x="50%" y="50%" fill="#eceeef" dy=".3em">Thumbnail</text>
</svg>
</div>
</div>
{% endfor %}
</div>
{% endblock %}
\ No newline at end of file
{% extends 'base.html' %}
{% block title %} Blogpost{% endblock title %}
{% block body %}
{% load humanize %}
{% load extras %}
<div class="container my-3">
<h2 class="blog-post-title">{{post.title}}</h2>
<p class="blog-post-meta">{{post.timeStamp}} by <a href="/about">{{post.author}}</a></p>
<p>{{post.content|safe}}</p>
<hr>
</div>
<div class="container">
<h2> Comments ({{comments.count}}) </h2>
<div class="my-2">
{% if user.is_authenticated %}
<form action="/blog/postComment" method="post">
{% csrf_token %}
<div class="form-group">
<label for="exampleInputEmail1">Post Comment </label>
<input type="text" class="form-control" name="comment" placeholder="Enter comment here">
</div>
<input type="hidden" name="postSno" value="{{post.sno}}">
<input type="hidden" name="parentSno" value="">
<button type="submit" class="btn btn-primary">Submit</button>
</form>
{% else %}
Please login to post a comment
{% endif %}
</div>
{% for comment in comments %}
<div class="row my-3">
<div class="col-md-1 ">
<img class="rounded mx-auto d-block w-100 border border-dark p-2" src="/static/img/user.png" alt="user">
</div>
<div class="col-md-11 ">
<b> {{comment.user.username}} </b> <span class="badge badge-secondary ">{{comment.timestamp| naturaltime}}</span>
<div>{{comment.comment}}</div>
<div class="reply mx-0">
{% if user.is_authenticated %}
<button class="btn btn-sm btn-primary" type="button" data-toggle="collapse" data-target="#replyBox{{comment.sno}}" aria-expanded="false" aria-controls="replyBox{{comment.sno}}">
Reply
</button>
<div class="collapse" id="replyBox{{comment.sno}}">
<div class="card card-body my-2">
<form action="/blog/postComment" method="post">
{% csrf_token %}
<div class="form-group">
<label for="comment">Post a reply </label>
<input type="text" class="form-control" name="comment" placeholder="Enter comment here">
<input type="hidden" name="parentSno" value="{{comment.sno}}">
</div>
<input type="hidden" name="postSno" value="{{post.sno}}">
<button type="submit" class="btn btn-primary">Submit</button>
</form>
</div>
</div>
{% else %}
<button class="btn btn-sm btn-primary" type="button" data-toggle="collapse" data-target="#replyBox{{comment.sno}}" aria-expanded="false" aria-controls="replyBox{{comment.sno}}">
Login to reply
</button>
{% endif %}
<div class="replies my-2 ">
{% for reply in replyDict|get_val:comment.sno %}
<div class="row my-2">
<div class="col-md-1 ">
<img class="rounded mx-auto d-block w-75 my-2 border border-dark p-2" src="/static/img/user.png" alt="user">
</div>
<div class="col-md-11">
<div class="col-md-11 ">
<b> {{reply.user.username}} </b> <span class="badge badge-secondary ">{{reply.timestamp| naturaltime}}</span>
<div>{{reply.comment}}</div>
</div>
<br>
</div>
</div>
{% endfor %}
</div>
</div>
</div>
</div>
{% endfor %}
</div>
{% endblock %}
\ No newline at end of file
{% extends 'base.html' %}
{% block title %} About{% endblock title %}
{% block body %}
{% endblock %}
\ No newline at end of file
{% extends 'base.html' %}
{% block title %} Contact{% endblock title %}
{% block body %}
<div class="container my-3">
<h3>Contact iCoder Admin</h3>
<form action="/contact" method="post">
{% csrf_token %}
<div class="form-group">
<label for="name">Name</label>
<input type="text" class="form-control" id="name" name="name"aria-describedby="name">
</div>
<div class="form-group">
<label for="email">Email address</label>
<input type="email" class="form-control" id="email" name="email" aria-describedby="emailHelp">
<small id="emailHelp" class="form-text text-muted">We'll never share your email with anyone else.</small>
</div>
<div class="form-group">
<label for="phone">Phone Number</label>
<input type="tel" class="form-control" id="phone" name="phone">
</div>
<div class="form-group">
<label for="content">Describe your issue :</label>
<textarea class="form-control" name="content" id="content" cols="30" rows="5"></textarea>
</div>
<button type="submit" class="btn btn-primary">Submit</button>
</form>
</div>
{% endblock %}
\ No newline at end of file
{% extends 'base.html' %}
{% block title %} Home{% endblock title %}
{% block body %}
<div class="container">
<div class="jumbotron my-3">
<h1 class="display-4">Welcome to iCoder!</h1>
<p class="lead">This is a simple hero unit, a simple jumbotron-style component for calling extra attention to
featured content or information.</p>
<hr class="my-4">
<p>It uses utility classes for typography and spacing to space content out within the larger container.</p>
<a class="btn btn-primary btn-lg" href="/blog" role="button">Go to Blog</a>
</div>
</div>
<div class="container">
<h2>Popular Blogposts</h2>
<div
class="row no-gutters border rounded overflow-hidden flex-md-row mb-4 shadow-sm h-md-250 my-4 position-relative">
<div class="col p-4 d-flex flex-column position-static">
<strong class="d-inline-block mb-2 text-primary">World</strong>
<h3 class="mb-0">Featured post</h3>
<div class="mb-1 text-muted">Nov 12</div>
<p class="card-text mb-auto">This is a wider card with supporting text below as a natural lead-in to
additional content.</p>
<a href="#" class="stretched-link">Continue reading</a>
</div>
<div class="col-auto d-none d-lg-block">
<svg class="bd-placeholder-img" width="200" height="250" xmlns="http://www.w3.org/2000/svg"
preserveAspectRatio="xMidYMid slice" focusable="false" role="img" aria-label="Placeholder: Thumbnail">
<title>Placeholder</title>
<rect width="100%" height="100%" fill="#55595c"></rect><text x="50%" y="50%" fill="#eceeef"
dy=".3em">Thumbnail</text>
</svg>
</div>
</div>
</div>
{% endblock %}
\ No newline at end of file
{% extends 'base.html' %}
{% block title %} Search Results {% endblock title %}
{% block blogactive %} active {% endblock blogactive %}
{% block body %}
<div class="container my-3">
<h2>Search results : </h2>
{% if allPosts|length < 1 %}
<p>No search results</p>
Your search query : <b>{{query}}</b> did not match any documents. <br>
Suggestions:
<ul>
<li>Make sure that all words are spelled correctly.</li>
<li>Try more general keywords.</li>
<li> Try fewer keywords.</li>
<li> Try different keywords.</li>
</li>
</ul>
{% endif %}
{% for post in allPosts %}
<div class="row no-gutters border rounded overflow-hidden flex-md-row mb-4 shadow-sm h-md-250 my-4 position-relative">
<div class="col p-4 d-flex flex-column position-static">
<strong class="d-inline-block mb-2 text-primary">Article by {{post.author}}</strong>
<h3 class="mb-0">{{post.title}}</h3>
<div class="mb-1 text-muted">{{post.datetime}}</div>
<p class="card-text mb-auto">{{post.content| truncatechars:500}}</p>
<div class="my-2">
<a href="/blog/{{post.slug}}" role="button" class="btn btn-primary">Continue reading</a>
</div>
</div>
<div class="col-auto d-none d-lg-block">
<svg class="bd-placeholder-img" width="200" height="250" xmlns="http://www.w3.org/2000/svg" preserveAspectRatio="xMidYMid slice" focusable="false" role="img" aria-label="Placeholder: Thumbnail">
<title>Placeholder</title>
<rect width="100%" height="100%" fill="#55595c"></rect><text x="50%" y="50%" fill="#eceeef" dy=".3em">Thumbnail</text>
</svg>
</div>
</div>
{% endfor %}
</div>
{% endblock %}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment