Skip to content

Instantly share code, notes, and snippets.

@su-narthur
su-narthur / videos.twig
Created January 8, 2019 20:55
Display videos using Twig and the SUFramework theme API
<style>
.homeVideos {
display: grid;
grid-template-columns: repeat( auto-fit, minmax( 200px, 1fr ) );
grid-gap: 1rem;
}
.responsiveIframe {
height: 0;
padding-bottom: 65%;
position: relative;
{% set getParamDateFormat = "Y-n-j" %}
{% set today = "now"|date(getParamDateFormat) %}
{% set devotionalDate = ( su.request.query.date ) ? su.request.query.date : today %}
{% set dateFragment = devotionalDate|date("-m-d") %}
{% set devotional = su.collection( "devotional" ).sort( "date", "desc" ).date("%"~dateFragment).limit(1).find()[0] %}
{% set displayDate = devotionalDate|date("l, F j, Y") %}
<div class="devotional">
    <h3>{{ (devotional.title) ? devotional.title : "Devotional for "~displayDate }}</h3>
    <div class="devotional-date">{{ displayDate }}</div>
<?php
use Mexitek\PHPColors\Color;
class SF_static_color
{
public static function contrast( $color, $dark = "black", $light = "white", $threshold = 0.43 ) {
# https://github.com/oyejorge/less.php/blob/master/lib/Less/Functions.php#L438-L475
@su-narthur
su-narthur / sunset_times.twig
Created June 6, 2018 14:24
Use SUFramework API to display sunset times
{% set dayOfWeekIndex = date()|date("N") %}
{% if dayOfWeekIndex == 5 %}
Sunset tonight: {{ su.calendar.sunsetTime|date( "H:i:s" ) }}<br>
Sunset tomorrow: {{ su.calendar.sunsetTime( '+1 day' )|date( "H:i:s" ) }}<br>
{% elseif dayOfWeekIndex == 6 %}
Sunset tonight: {{ su.calendar.sunsetTime|date( "H:i:s" ) }}<br>
Sunset next Friday: {{ su.calendar.sunsetTime( 'next friday' )|date( "H:i:s" ) }}<br>
Sunset next Sabbath: {{ su.calendar.sunsetTime( 'next saturday' )|date( "H:i:s" ) }}<br>
{% else %}
@su-narthur
su-narthur / testimonial_carousel.twig
Created April 19, 2018 14:59
Static and rotating testimonial twig
<style>
.code-example {
overflow-y: scroll;
padding: 1rem;
background-color: #eee;
word-break: break-all;
word-wrap: break-word;
white-space: pre;
color: #666666;
border-left: 3px solid #7b7b7b;
<style>
.directory-entry {
margin: 15px 30px 15px 0;
width: 300px;
max-width: 100%;
display: inline-block;
vertical-align: top;
}
</style>
{% set staffCollection = su.collection("staff") %}
{% set staffMembers = staffCollection.find() %}
<div class="staffListing">
{% for staffMember in staffMembers %}
<div class="staffMember">
{% if staffMember.photo %}
<img style="float: left; margin-right: 1.5rem;" src="{{ staffMember.photo }}" alt="{{ staffMember.name.first }} {{ staffMember.name.last }}" width=150 />
{% endif %}
{% set getParamDateFormat = "Y-n-j" %}
{% set today = "now"|date(getParamDateFormat) %}
{% set devotionalDate = ( su.request.query.date ) ? su.request.query.date : today %}
{% set dateFragment = devotionalDate|date("-m-d") %}
{% set devotional = su.collection( "devotionals" ).sort( "date", "desc" ).date("%"~dateFragment).limit(1).find()[0] %}
{% set displayDate = devotionalDate|date("l, F j, Y") %}
<div class="devotional">
<h3>{{ (devotional.title) ? devotional.title : "Devotional for "~displayDate }}</h3>
@su-narthur
su-narthur / compile-less.sh
Created December 13, 2017 15:40
Attempt at creating a bash script that would inject variables and compile out css from less files to allow for more complete static analysis of SUFramework themes
#!/usr/bin/env bash
echo "hi"
VARS=""
while read -r line
do
VARS="${VARS}--global-var=${line}=red "
done < <(cat theme/SUThemeSpruce/style/*.less | egrep -o 'config-\w+')