Skip to content

Instantly share code, notes, and snippets.

@samnabi
samnabi / showIndex.php
Created June 7, 2015 10:39
showIndex for Kirby
<?php
/**
Translates Kirby's index() function to a nested list by building a string of markdown text then converting it to HTML. Useful for navigation menus of unknown depth.
@param must be an index() object
@return string of HTML
*/
function showIndex($pages) {
// Initialize output string
@samnabi
samnabi / cart.php
Created June 12, 2015 01:05
Kyle Bean's paypal plugin
<?php
function get_cart() {
s::start();
$cart = s::get('cart', array());
return $cart;
}
function cart_logic($cart) {
if (isset($_REQUEST['action'])) {
@samnabi
samnabi / gfycat.php
Last active August 29, 2015 14:26
Kirbytext extension for Gfycat
<?php
kirbytext::$tags['gfycat'] = array(
'html' => function($tag) {
$gfyID = $tag->attr('gfycat');
return '<video poster="//thumbs.gfycat.com/'.$gfyID.'-poster.jpg" loop autoplay mute>
<source id="webmsource" type="video/webm" src="//zippy.gfycat.com/'.$gfyID.'.webm"></source>
<source id="mp4source" type="video/mp4" src="//fat.gfycat.com/'.$gfyID.'.mp4"></source>
<img src="//giant.gfycat.com/'.$gfyID.'.gif"></img>
@samnabi
samnabi / .htaccess
Created December 11, 2015 17:39
Shopzest rewrite rules
RewriteEngine On
RewriteBase /
# http://shopzest.com => https://shopzest.com
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} ^shopzest\.com
RewriteRule ^(.*)$ https://shopzest.com/$1 [R=301,L]
# http://www.shopzest.com => https://shopzest.com
# https://www.shopzest.com => https://shopzest.com
@samnabi
samnabi / userChrome.css
Last active March 13, 2016 21:03
Compact Firefox chrome for Mac OS X 10.11 (El Capitan). Make the most of vertical space while increasing font size.
/* Vertically-centred close/minimize/fullscreen buttons */
#titlebar-buttonbox-container {
margin-top: 7px !important;
}
/* Move tabs to top edge of window */
#TabsToolbar {
margin: -16px 0 0 !important;
padding: 0 !important;
height: 30px !important;
@samnabi
samnabi / config.php
Created February 1, 2016 18:41
Kirby v2: Shrink large images on upload
<?php
// Copy this code into your config.php file
// Replace the default $maxDimension to meet your needs
// Read more about Kirby's Panel hooks at https://getkirby.com/docs/panel/developers/hooks
// Shrink large images on upload
kirby()->hook('panel.file.upload', 'shrinkImage');
kirby()->hook('panel.file.replace', 'shrinkImage');
function shrinkImage($file, $maxDimension = 1000) {
@samnabi
samnabi / panel.css
Created February 25, 2016 15:03
Better drag-and-drop file upload UI for Kirby Panel
/* Better drag-and-drop UI for panel files */
.marginalia[href="#upload"] {
padding: 1rem 1rem 1rem 4rem;
position: relative;
display: block;
border: 2px dashed lightgrey;
border-radius: 0.3em;
}
html[lang="en"] .marginalia[href="#upload"]:after {
content: '. Drag & drop here to upload.';
@samnabi
samnabi / product.php
Last active September 10, 2016 19:58
Product page with combined dropdown for all variants (Shopkit 1.0.5)
<?php
// Tested with Shopkit 1.0.5. This template may break in future releases.
// Save this file as /site/templates/product.php to override the default Product template included with Shopkit.
snippet('header') ?>
<?php snippet('breadcrumb') ?>
<?php if ($page->hasImages()) snippet('slider',['photos'=>$page->images()]) ?>
<?php if ($page->brand()->isNotempty()) { ?>