Skip to content

Instantly share code, notes, and snippets.

View KalobTaulien's full-sized avatar

Kalob Taulien KalobTaulien

View GitHub Profile
@KalobTaulien
KalobTaulien / WordPressThemeSetup.php
Created August 6, 2017 04:07
Adds different thumbnail sizes and setups up default jpeg quality to be 100%
<?php
function application_setup() {
// Thumbnail sizes. Change as needed.
// NOTE: These only take affect on new uploaded images.
add_image_size('icon', 50, 50, true);
add_image_size('small', 150, 150, true); // small, 150px width, 150px height, crop: true
add_image_size('medium', 250, 250, true);
add_image_size('large', 500, 500, true);
add_image_size('xlarge', 1000, 1000, true);
@KalobTaulien
KalobTaulien / Strip WordPress Comments from WXR File.txt
Created August 17, 2017 17:34
Strip WordPress Comments from WXR File.
sed -i '/<wp:comment>/,/<\/wp:comment>/d' wordpress_wxr.xml
sed -i '/<wp:comment_status>/,/<\/wp:comment_status>/d' wordpress_wxr.xml
@KalobTaulien
KalobTaulien / your_page.html
Created July 21, 2018 18:44
Wagtail 2: Adding custom context to your pages.
{% extends 'base.html' %}
{% block content %}
<h2>Hello world!</h2>
<p>{{ extra }}</p>
{% endblock content %}
@KalobTaulien
KalobTaulien / yourpage_inside_example.py
Created July 21, 2018 19:16
Wagtail 2: Removing the Promote and Settings
"""Inside the class example."""
from wagtail.core.models import Page
class YourPage(Page):
"""Your Wagtail Page Type."""
template = "templates/your_page.html"
# Your other Page fields
@KalobTaulien
KalobTaulien / story_page.html
Created July 21, 2018 19:27
Wagtail 2: Adding Tags to Your Pages
<!-- Your Django Template -->
{% for tag in tags %}
<a href="{{ tag.slug }}">{{ tag }}</a>
{% endfor %}
@KalobTaulien
KalobTaulien / custompage.py
Created July 21, 2018 23:18
Wagtail 2: Adding Streamfields to a Custom Page
"""Custom Page model(s)."""
from wagtail.wagtailadmin.edit_handlers import FieldPanel, MultiFieldPanel, StreamFieldPanel
from wagtail.wagtailcore.fields import StreamField
from wagtail.wagtailcore.models import Page
from wagtail.wagtailsearch import index
from .streamfields import * # Replace * with the streamfields you want to use
@KalobTaulien
KalobTaulien / snippet.py
Last active July 21, 2018 23:23
Wagtail 2: Creating a new Snippet
"""Register a custom Wagtail Snippet."""
from django.db import models
from wagtail.admin.edit_handlers import FieldPanel
from wagtail.snippets.models import register_snippet
class Category(models.Model):
"""Category information."""
@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
<?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 %}