Skip to content

Instantly share code, notes, and snippets.

View KalobTaulien's full-sized avatar

Kalob Taulien KalobTaulien

View GitHub Profile
@KalobTaulien
KalobTaulien / blog.py
Created July 21, 2018 23:36
Wagtail 2: Creating a Blog with Blog Listing Page and Detail Pages
# -*- coding: utf-8 -*-
"""Blog app models."""
from django.db import models
from django.utils import timezone
from wagtail.admin.edit_handlers import FieldPanel
from wagtail.core.fields import RichTextField, StreamField
from wagtail.core.models import Page
from wagtail.images.models import Image
from wagtail.search import index
@KalobTaulien
KalobTaulien / INSTALL
Last active November 21, 2024 09:26
Force lowercase paths using NGINX. Does not affect query params.
# On Ubuntu run `sudo apt-get install nginx-extras` for perl scripts to run
# `sudo service nginx restart` (verify it restarted properly)
# Add nginx.conf perl function; add yoursite.conf location
<?php
$name = (isset($_POST['name']) ? $_POST['name'] : '');
$email = (isset($_POST['email']) ? $_POST['email'] : '');
$password = (isset($_POST['password']) ? $_POST['password'] : '');
$notification = ''
if( ! empty ( $name ) && !empty ( $email ) && ! empty( $password) ) {
$notification = "<div class='alert alert-success' role='alert'>
<h4 class='alert-heading'>Well done!</h4>
@KalobTaulien
KalobTaulien / blog_post_page.html
Created January 19, 2019 21:02
Setting Up A RichText Content Area
{# templates/blog/blog_post_page.html #}
{% extends 'base.html' %}
{% load wagtailcore_tags %}
{% block content %}
{{ self.richtext|richtext }}
{% endblock content %}
@KalobTaulien
KalobTaulien / blocks.py
Created January 20, 2019 23:02
RichText StreamFields
# demo/blocks.py; or sterams/blocks.py
"""Stream Blocks."""
from wagtail.core import blocks
class CustomRichTextBlock(blocks.StructBlock):
"""Rich text content."""
richtext_content = blocks.RichTextBlock(required=True)
bg_color = blocks.ChoiceBlock(required=True, choices=[
# flex/models.py
"""Flexible page."""
from django.db import models
from wagtail.admin.edit_handlers import FieldPanel, StreamFieldPanel
from wagtail.core.fields import StreamField
from wagtail.core.models import Page
from streams import blocks
@KalobTaulien
KalobTaulien / home models.py
Created February 6, 2019 19:26
This is the code from the learnwagtail.com lesson where we add an Orderable to the Home Page to create a Bootstrap 4 Carousel.
# home/models.py
from django.db import models
from modelcluster.fields import ParentalKey
from wagtail.admin.edit_handlers import (
FieldPanel,
MultiFieldPanel,
InlinePanel,
StreamFieldPanel,
#site_settings/models.py
from django.db import models
from wagtail.admin.edit_handlers import FieldPanel, MultiFieldPanel
from wagtail.contrib.settings.models import BaseSetting, register_setting
@register_setting
class SocialMediaSettings(BaseSetting):
"""Social media settings for our custom website."""
@KalobTaulien
KalobTaulien / base.py
Last active February 8, 2019 23:34
Adding a new Subscribers model to the Wagtail ModelAdmin. Tutorial at: https://learnwagtail.com/tutorials/how-register-django-model-wagtails-modeladmin/
# ...
INSTALLED_APPS = [
# ...
'subscribers',
'wagtail.contrib.modeladmin',
# ...
]
# ...
@KalobTaulien
KalobTaulien / staff author_page.html
Created February 28, 2019 22:02
Getting BlogPostPages by their assigned authors
{% extends 'base.html' %}
{% block content %}
{% for post in posts %}
{{ post.title }}
{% endfor %}
{% endblock %}