Added basic blog model with templates styling

master
androiddrew 6 years ago
parent fd505fa144
commit 57f96e1b31

@ -0,0 +1 @@
media/

@ -0,0 +1,3 @@
from django.contrib import admin
# Register your models here.

@ -0,0 +1,5 @@
from django.apps import AppConfig
class BlogConfig(AppConfig):
name = 'blog'

@ -0,0 +1,28 @@
# Generated by Django 2.1.2 on 2018-11-11 02:20
from django.db import migrations, models
import django.db.models.deletion
import wagtail.core.fields
class Migration(migrations.Migration):
initial = True
dependencies = [
('wagtailcore', '0040_page_draft_title'),
]
operations = [
migrations.CreateModel(
name='BlogIndexPage',
fields=[
('page_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='wagtailcore.Page')),
('intro', wagtail.core.fields.RichTextField(blank=True)),
],
options={
'abstract': False,
},
bases=('wagtailcore.page',),
),
]

@ -0,0 +1,29 @@
# Generated by Django 2.1.2 on 2018-11-11 02:58
from django.db import migrations, models
import django.db.models.deletion
import wagtail.core.fields
class Migration(migrations.Migration):
dependencies = [
('wagtailcore', '0040_page_draft_title'),
('blog', '0001_initial'),
]
operations = [
migrations.CreateModel(
name='BlogPage',
fields=[
('page_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='wagtailcore.Page')),
('date', models.DateField(verbose_name='Post date')),
('intro', models.CharField(max_length=250)),
('body', wagtail.core.fields.RichTextField(blank=True)),
],
options={
'abstract': False,
},
bases=('wagtailcore.page',),
),
]

@ -0,0 +1,30 @@
from django.db import models
from wagtail.core.models import Page
from wagtail.core.fields import RichTextField
from wagtail.admin.edit_handlers import FieldPanel
from wagtail.search import index
class BlogIndexPage(Page):
intro = RichTextField(blank=True)
content_panels = Page.content_panels + [
FieldPanel('intro', classname="full")
]
class BlogPage(Page):
date = models.DateField("Post date")
intro = models.CharField(max_length=250)
body = RichTextField(blank=True)
search_fields = Page.search_fields + [
index.SearchField("intro"),
index.SearchField("body")
]
content_panels = Page.content_panels + [
FieldPanel('date'),
FieldPanel('intro'),
FieldPanel('body', classname="full"),
]

@ -0,0 +1,34 @@
{% extends "base.html" %}
{% load wagtailcore_tags %}
{% block body_class %}helvetica{% endblock %}
{% block content %}
<section class="mw7 center">
<h1 class="ph3 ph0-l">{{ page.title }}</h1>
{% for post in page.get_children %}
<article class="pv4 bt bb b--black-10 ph3 ph0-l">
<a class="db pv4 ph3 ph0-l no-underline black dim" href="{% pageurl post %}" >
<div class="flex flex-column flex-row-ns">
<div class="w-100 w-60-ns pr3-ns order-2 order-1-ns">
<h1 class="f3 mt0 lh-title">{{ post.title }}</h1>
<p class="f5 f4-l lh-copy">{{ post.specific.intro }}</p>
</div>
<div class="pl3-ns order-1 order-2-ns mb4 mb0-ns w-100 w-40-ns">
<img src="http://mrmrs.github.io/photos/cpu.jpg" class="db"
alt="Photo of a dimly lit room with a computer interface terminal.">
</div>
</div>
<p class="f6 lh-copy gray mv0">By <span class="ttu">{{ post.owner }}</span></p>
<time class="f6 db gray">{{ post.specific.date|date }}</time>
</a>
</article>
{% endfor %}
</section>
{% endblock %}

@ -0,0 +1,14 @@
{% extends "base.html" %}
{% load wagtailcore_tags %}
{% block body_class %}helvetica{% endblock %}
{% block content %}
<h1>{{ page.title }}</h1>
<p class="meta">{{ page.date }}</p>
<div class="intro">{{ page.intro }}</div>
{{ page.body|richtext }}
<p><a href="{{ page.get_parent.url }}">Return to blog</a></p>
{% endblock %}

@ -0,0 +1,3 @@
from django.test import TestCase
# Create your tests here.

@ -0,0 +1,3 @@
from django.shortcuts import render
# Create your views here.

@ -25,6 +25,7 @@ BASE_DIR = os.path.dirname(PROJECT_DIR)
INSTALLED_APPS = [
"home",
"blog",
"search",
"wagtail.contrib.forms",
"wagtail.contrib.redirects",

@ -14,7 +14,7 @@ EMAIL_BACKEND = "django.core.mail.backends.console.EmailBackend"
DATABASES = {
"default": {
"ENGINE": "django.db.backends.postgresql",
"NAME": "datasketch",
"NAME": "datasketch_dev",
"USER": "datasketch",
"PASSWORD": os.environ.get("DB_PASSWD") if os.environ.get("DB_PASSWD") else "",
"HOST": os.environ.get("DB_HOST") if os.environ.get("DB_HOST") else "127.0.0.1",

Loading…
Cancel
Save