Added basic blog model with templates styling
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.
|
Loading…
Reference in New Issue