forked from CoreyMSchafer/code_snippets
-
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
1 parent
16bd511
commit 11d4c9f
Showing
48 changed files
with
1,224 additions
and
0 deletions.
There are no files selected for viewing
119 changes: 119 additions & 0 deletions
119
Django_Blog/13-Deployment-Heroku/django_project/.gitignore
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,119 @@ | ||
# Mac | ||
.DS_Store | ||
|
||
# Byte-compiled / optimized / DLL files | ||
__pycache__/ | ||
*.py[cod] | ||
*$py.class | ||
|
||
# C extensions | ||
*.so | ||
|
||
# Distribution / packaging | ||
.Python | ||
build/ | ||
develop-eggs/ | ||
dist/ | ||
downloads/ | ||
eggs/ | ||
.eggs/ | ||
lib/ | ||
lib64/ | ||
parts/ | ||
sdist/ | ||
var/ | ||
wheels/ | ||
pip-wheel-metadata/ | ||
share/python-wheels/ | ||
*.egg-info/ | ||
.installed.cfg | ||
*.egg | ||
MANIFEST | ||
|
||
# PyInstaller | ||
# Usually these files are written by a python script from a template | ||
# before PyInstaller builds the exe, so as to inject date/other infos into it. | ||
*.manifest | ||
*.spec | ||
|
||
# Installer logs | ||
pip-log.txt | ||
pip-delete-this-directory.txt | ||
|
||
# Unit test / coverage reports | ||
htmlcov/ | ||
.tox/ | ||
.nox/ | ||
.coverage | ||
.coverage.* | ||
.cache | ||
nosetests.xml | ||
coverage.xml | ||
*.cover | ||
.hypothesis/ | ||
.pytest_cache/ | ||
|
||
# Translations | ||
*.mo | ||
*.pot | ||
|
||
# Django stuff: | ||
*.log | ||
local_settings.py | ||
db.sqlite3 | ||
|
||
# Flask stuff: | ||
instance/ | ||
.webassets-cache | ||
|
||
# Scrapy stuff: | ||
.scrapy | ||
|
||
# Sphinx documentation | ||
docs/_build/ | ||
|
||
# PyBuilder | ||
target/ | ||
|
||
# Jupyter Notebook | ||
.ipynb_checkpoints | ||
|
||
# IPython | ||
profile_default/ | ||
ipython_config.py | ||
|
||
# pyenv | ||
.python-version | ||
|
||
# celery beat schedule file | ||
celerybeat-schedule | ||
|
||
# SageMath parsed files | ||
*.sage.py | ||
|
||
# Environments | ||
.env | ||
.venv | ||
env/ | ||
venv/ | ||
ENV/ | ||
env.bak/ | ||
venv.bak/ | ||
|
||
# Spyder project settings | ||
.spyderproject | ||
.spyproject | ||
|
||
# Rope project settings | ||
.ropeproject | ||
|
||
# mkdocs documentation | ||
/site | ||
|
||
# mypy | ||
.mypy_cache/ | ||
.dmypy.json | ||
dmypy.json | ||
|
||
# Pyre type checker | ||
.pyre/ |
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 @@ | ||
web: gunicorn django_project.wsgi |
Empty file.
4 changes: 4 additions & 0 deletions
4
Django_Blog/13-Deployment-Heroku/django_project/blog/admin.py
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,4 @@ | ||
from django.contrib import admin | ||
from .models import Post | ||
|
||
admin.site.register(Post) |
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,5 @@ | ||
from django.apps import AppConfig | ||
|
||
|
||
class BlogConfig(AppConfig): | ||
name = 'blog' |
28 changes: 28 additions & 0 deletions
28
Django_Blog/13-Deployment-Heroku/django_project/blog/migrations/0001_initial.py
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,28 @@ | ||
# Generated by Django 2.1 on 2018-08-28 02:32 | ||
|
||
from django.conf import settings | ||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
import django.utils.timezone | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
initial = True | ||
|
||
dependencies = [ | ||
migrations.swappable_dependency(settings.AUTH_USER_MODEL), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name='Post', | ||
fields=[ | ||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('title', models.CharField(max_length=100)), | ||
('content', models.TextField()), | ||
('date_posted', models.DateTimeField(default=django.utils.timezone.now)), | ||
('author', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)), | ||
], | ||
), | ||
] |
Empty file.
17 changes: 17 additions & 0 deletions
17
Django_Blog/13-Deployment-Heroku/django_project/blog/models.py
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 @@ | ||
from django.db import models | ||
from django.utils import timezone | ||
from django.contrib.auth.models import User | ||
from django.urls import reverse | ||
|
||
|
||
class Post(models.Model): | ||
title = models.CharField(max_length=100) | ||
content = models.TextField() | ||
date_posted = models.DateTimeField(default=timezone.now) | ||
author = models.ForeignKey(User, on_delete=models.CASCADE) | ||
|
||
def __str__(self): | ||
return self.title | ||
|
||
def get_absolute_url(self): | ||
return reverse('post-detail', kwargs={'pk': self.pk}) |
84 changes: 84 additions & 0 deletions
84
Django_Blog/13-Deployment-Heroku/django_project/blog/static/blog/main.css
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,84 @@ | ||
body { | ||
background: #fafafa; | ||
color: #333333; | ||
margin-top: 5rem; | ||
} | ||
|
||
h1, h2, h3, h4, h5, h6 { | ||
color: #444444; | ||
} | ||
|
||
ul { | ||
margin: 0; | ||
} | ||
|
||
.bg-steel { | ||
background-color: #5f788a; | ||
} | ||
|
||
.site-header .navbar-nav .nav-link { | ||
color: #cbd5db; | ||
} | ||
|
||
.site-header .navbar-nav .nav-link:hover { | ||
color: #ffffff; | ||
} | ||
|
||
.site-header .navbar-nav .nav-link.active { | ||
font-weight: 500; | ||
} | ||
|
||
.content-section { | ||
background: #ffffff; | ||
padding: 10px 20px; | ||
border: 1px solid #dddddd; | ||
border-radius: 3px; | ||
margin-bottom: 20px; | ||
} | ||
|
||
.article-title { | ||
color: #444444; | ||
} | ||
|
||
a.article-title:hover { | ||
color: #428bca; | ||
text-decoration: none; | ||
} | ||
|
||
.article-content { | ||
white-space: pre-line; | ||
} | ||
|
||
.article-img { | ||
height: 65px; | ||
width: 65px; | ||
margin-right: 16px; | ||
} | ||
|
||
.article-metadata { | ||
padding-bottom: 1px; | ||
margin-bottom: 4px; | ||
border-bottom: 1px solid #e3e3e3 | ||
} | ||
|
||
.article-metadata a:hover { | ||
color: #333; | ||
text-decoration: none; | ||
} | ||
|
||
.article-svg { | ||
width: 25px; | ||
height: 25px; | ||
vertical-align: middle; | ||
} | ||
|
||
.account-img { | ||
height: 125px; | ||
width: 125px; | ||
margin-right: 20px; | ||
margin-bottom: 16px; | ||
} | ||
|
||
.account-heading { | ||
font-size: 2.5rem; | ||
} |
4 changes: 4 additions & 0 deletions
4
Django_Blog/13-Deployment-Heroku/django_project/blog/templates/blog/about.html
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,4 @@ | ||
{% extends "blog/base.html" %} | ||
{% block content %} | ||
<h1>About Page</h1> | ||
{% endblock content %} |
83 changes: 83 additions & 0 deletions
83
Django_Blog/13-Deployment-Heroku/django_project/blog/templates/blog/base.html
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,83 @@ | ||
{% load static %} | ||
<!DOCTYPE html> | ||
<html> | ||
<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://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous"> | ||
|
||
<link rel="stylesheet" type="text/css" href="{% static 'blog/main.css' %}"> | ||
|
||
{% if title %} | ||
<title>Django Blog - {{ title }}</title> | ||
{% else %} | ||
<title>Django Blog</title> | ||
{% endif %} | ||
</head> | ||
<body> | ||
<header class="site-header"> | ||
<nav class="navbar navbar-expand-md navbar-dark bg-steel fixed-top"> | ||
<div class="container"> | ||
<a class="navbar-brand mr-4" href="{% url 'blog-home' %}">Django Blog</a> | ||
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarToggle" aria-controls="navbarToggle" aria-expanded="false" aria-label="Toggle navigation"> | ||
<span class="navbar-toggler-icon"></span> | ||
</button> | ||
<div class="collapse navbar-collapse" id="navbarToggle"> | ||
<div class="navbar-nav mr-auto"> | ||
<a class="nav-item nav-link" href="{% url 'blog-home' %}">Home</a> | ||
<a class="nav-item nav-link" href="{% url 'blog-about' %}">About</a> | ||
</div> | ||
<!-- Navbar Right Side --> | ||
<div class="navbar-nav"> | ||
{% if user.is_authenticated %} | ||
<a class="nav-item nav-link" href="{% url 'post-create' %}">New Post</a> | ||
<a class="nav-item nav-link" href="{% url 'profile' %}">Profile</a> | ||
<a class="nav-item nav-link" href="{% url 'logout' %}">Logout</a> | ||
{% else %} | ||
<a class="nav-item nav-link" href="{% url 'login' %}">Login</a> | ||
<a class="nav-item nav-link" href="{% url 'register' %}">Register</a> | ||
{% endif %} | ||
</div> | ||
</div> | ||
</div> | ||
</nav> | ||
</header> | ||
<main role="main" class="container"> | ||
<div class="row"> | ||
<div class="col-md-8"> | ||
{% if messages %} | ||
{% for message in messages %} | ||
<div class="alert alert-{{ message.tags }}"> | ||
{{ message }} | ||
</div> | ||
{% endfor %} | ||
{% endif %} | ||
{% block content %}{% endblock %} | ||
</div> | ||
<div class="col-md-4"> | ||
<div class="content-section"> | ||
<h3>Our Sidebar</h3> | ||
<p class='text-muted'>You can put any information here you'd like. | ||
<ul class="list-group"> | ||
<li class="list-group-item list-group-item-light">Latest Posts</li> | ||
<li class="list-group-item list-group-item-light">Announcements</li> | ||
<li class="list-group-item list-group-item-light">Calendars</li> | ||
<li class="list-group-item list-group-item-light">etc</li> | ||
</ul> | ||
</p> | ||
</div> | ||
</div> | ||
</div> | ||
</main> | ||
|
||
<!-- Optional JavaScript --> | ||
<!-- jQuery first, then Popper.js, then Bootstrap JS --> | ||
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script> | ||
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script> | ||
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script> | ||
</body> | ||
</html> |
37 changes: 37 additions & 0 deletions
37
Django_Blog/13-Deployment-Heroku/django_project/blog/templates/blog/home.html
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,37 @@ | ||
{% extends "blog/base.html" %} | ||
{% block content %} | ||
{% for post in posts %} | ||
<article class="media content-section"> | ||
<img class="rounded-circle article-img" src="{{ post.author.profile.image.url }}"> | ||
<div class="media-body"> | ||
<div class="article-metadata"> | ||
<a class="mr-2" href="{% url 'user-posts' post.author.username %}">{{ post.author }}</a> | ||
<small class="text-muted">{{ post.date_posted|date:"F d, Y" }}</small> | ||
</div> | ||
<h2><a class="article-title" href="{% url 'post-detail' post.id %}">{{ post.title }}</a></h2> | ||
<p class="article-content">{{ post.content }}</p> | ||
</div> | ||
</article> | ||
{% endfor %} | ||
{% if is_paginated %} | ||
|
||
{% if page_obj.has_previous %} | ||
<a class="btn btn-outline-info mb-4" href="?page=1">First</a> | ||
<a class="btn btn-outline-info mb-4" href="?page={{ page_obj.previous_page_number }}">Previous</a> | ||
{% endif %} | ||
|
||
{% for num in page_obj.paginator.page_range %} | ||
{% if page_obj.number == num %} | ||
<a class="btn btn-info mb-4" href="?page={{ num }}">{{ num }}</a> | ||
{% elif num > page_obj.number|add:'-3' and num < page_obj.number|add:'3' %} | ||
<a class="btn btn-outline-info mb-4" href="?page={{ num }}">{{ num }}</a> | ||
{% endif %} | ||
{% endfor %} | ||
|
||
{% if page_obj.has_next %} | ||
<a class="btn btn-outline-info mb-4" href="?page={{ page_obj.next_page_number }}">Next</a> | ||
<a class="btn btn-outline-info mb-4" href="?page={{ page_obj.paginator.num_pages }}">Last</a> | ||
{% endif %} | ||
|
||
{% endif %} | ||
{% endblock content %} |
Oops, something went wrong.