Skip to content

Instantly share code, notes, and snippets.

@legenderrys
legenderrys / MiniCart JS cart widget + item counter & cart toggle button
Last active August 29, 2015 13:57
MiniCart JS Cart Widget and Item Counter
<html>
<head>
<meta charset="UTF-8">
<title>MiniCart JS</title>
</head>
<body>
<div id="cart">
<button class="showCart">Show Cart</button>
<div class="itemCount"></div>
<!-- paypal minicart will be added here after dom load -->
@legenderrys
legenderrys / djax + body class update
Last active August 29, 2015 13:56
updating body class with current page name for djax plugin
<script type="text/javascript">
var transition = function($newEl) {
// the pageTitle var assumes your title tag is formatted as " Site Name|Page Name "
// i perfer to use this method, otherwise landing page body class will show empty
var pageTitle = document.title.split('|')[1].toLowerCase().replace(/ /g,"-");
function updateBodyClass(){
$('body').removeClass().addClass(pageTitle);
}
var $oldEl = this; // reference to the DOM element that is about to be replaced
$newEl.hide(); // hide the new content before it comes in
@legenderrys
legenderrys / Pelican Jinja Date Extension
Last active November 8, 2016 16:49
Pelican Jinja Date extension and conditional for comparing current datetime to object date.
This will format python datetime as a string to be used within jinja conditionals for comparing current date to article date using pelican app.
1. Create a file named jinjaext.py
2. paste the following snippet
def convertdate(datetime, format='%a-%d-%m-%Y'):
return datetime.date().strftime(format)
3. Add the following line to your config file
@legenderrys
legenderrys / Barrel Mixitup Url Filter
Created September 24, 2013 22:31
Using Barrel's MixitUp jquery filter to automatically filter based on url hash
$('#grid').mixitup({
onMixLoad: function(){
var hash = window.location.hash;
var noHash=hash.replace("#","");
if(hash){
$('#grid').mixitup('filter', noHash);
}
}
});
@legenderrys
legenderrys / Jinja splits
Created September 20, 2013 19:29
Split Key Value Pairs multiple times using jinja template
{% if article.productvariations %}
{% for category_groups in article.productvariations.split('|') %}
{% for category in category_groups.split('=') %}
{% if loop.first %}
<h1>{{ category }}</h1>
{% else %}
<ul>
{% for list in category.split(',') %}
{% set itemvalues = list.split(':') %}
<li>{{ itemvalues[0] }} costs {{itemvalues [1]}}
@legenderrys
legenderrys / Jinja Key Value Pair Breakdown
Last active December 23, 2015 13:19
Jinja2 Key Value Spliter for Pelican meta data
# What I am attempting to do is split each key value pair groups down into smaller key value pairs spliting each at specified characters i.e:("=" "," ":" "|" )..etc. the characters used are arbitrary
# Example: Markdown metadata looks like this.
Title: Demo Product
date: 9-19-2013
productvariations: Sizes=Small:13.00,Med:33.00,Large:42.00|Colors=Red,Green,Blue
# We need to output the following as:
@legenderrys
legenderrys / Makefile
Last active December 23, 2015 13:09
Pelican Make file for multiple site generations using one command
PROJECTSITE=$(DROPBOX_DIR)/WEBSITE/PROJECT_site
PROJECTSTORE=$(DROPBOX_DIR)/WEBSITE/PROJECT_store
PROJECTSITE_OUTPUT=$(BASEDIR)/output/PROJECTsite
PROJECTSTORE_OUTPUT=$(BASEDIR)/output/PROJECTstore
SITECONFFILE=$(BASEDIR)/projectconf.py
STORECONFFILE=$(BASEDIR)/projectstoreconf.py
generate_site:
$(PELICAN) $(PROJECTSITE) -o $(PROJECTSITE_OUTPUT) -s $(SITECONFFILE)
generate_store:
$(PELICAN) $(PROJECTSTORE) -o $(PROJECTSTORE_OUTPUT) -s $(STORECONFFILE)