Skip to content

Instantly share code, notes, and snippets.

View carlwiedemann's full-sized avatar

Carl Wiedemann carlwiedemann

View GitHub Profile
@carlwiedemann
carlwiedemann / gist:3947045
Created October 24, 2012 16:14
Git deploy
# Usage: (From [current branch])
#
# $> gitdeploy [to branch]
#
# This will checkout [to branch], merge --no-ff [current branch] with auto
# message, push [to branch] to remote, & re-checkout current.
function gitdeploy() {
# Get branch we are on
CURRENT=`git branch | grep ^\* | awk '{print $2}'`
git checkout $1 && git merge --no-ff $CURRENT -m "Merging $CURRENT" && git push && git checkout $CURRENT
@carlwiedemann
carlwiedemann / find_func.sh
Created October 25, 2012 17:55 — forked from msonnabaum/find_func.sh
Find the given function from anywhere in the Drupal codebase, open in TextMate with cursor on same line
function findfunc {
grep -rn "function $1(" `drush dd`| grep -vP "tags|patch$"| awk -F':' '{print $1,$2}' |
while read FILE LINE
do
mate -l ${LINE} ${FILE}
done
}
@carlwiedemann
carlwiedemann / gist:4035400
Created November 7, 2012 23:40
Drush login, Drush logout
# Drush login function dli
# ------------------------
#
# Open the given site in the browser, login as root, and go to destination
# argument. Requires the -l option, or drush site-set @alias, or $options['l']
# in sites/default/bashrc.php
#
# Usage
# -----
#
@carlwiedemann
carlwiedemann / gist:4036948
Created November 8, 2012 05:12
Markup utility functions sandbox...looking for a proof-of-concept
<?php
/**
* Refactored l() and theme-less version of theme_link().
*
* @see markup_html_tag().
*/
function markup_l($title, $path, $options = array()) {
// Merge in defaults.
$options += array(
@carlwiedemann
carlwiedemann / gist:4061841
Created November 12, 2012 20:57
The Future of Renderables, in Theory
<?php
/**
* DISCLAIMER: This is a purely theoretical example.
*
* Let's render a paged list of nodes, using a component. Components
* are common layout recipes, and we wish to provide a Theme
* Component Library that developers can use. These are similar in
* concept to the traditional theme functions, but should be more
* flexible and reusable by core and contrib. We're hoping that
// <ol id="x">
// <li id="id-first">first</li>
// <li>second</li>
// <li>third</li>
// </ol>
return array(
'#theme' => 'ol',
'items' => array(
array(
@carlwiedemann
carlwiedemann / component.php
Created November 12, 2012 22:39 — forked from LionsAd/component.php
Theme Component Library - Draft
<?php
/** Disclaimer: in-progress **/
/**
* The component function. c().
* Usage:
* c($component_name, $data, [$attributes], [$options]);
*/
@carlwiedemann
carlwiedemann / gist:4089436
Created November 16, 2012 17:57
Link to sandbox
<h3>UPDATE: Looking to help with Twig tasks?</h3>
Please see the <a href="http://drupal.org/sandbox/pixelmord/1750250">Twig sandbox</a> for all information about the roadmap, current tasks, related issues, and more.

Summary

I had a look at calls to _preprocess_html and _process_html and what they do in core. I've listed what we need to provide and a summary of existing implementations.

It seems that everything existing in core can be potentially solved by:

  • Providing the ability to add/modify attributes to the <body> tag and the <html> tag. Most of the time, it's class attributes, but RDFa will have other needs.
  • Better asset management (CSS/JS). Preprocessors sometimes call drupal_add_js, etc. We're already talking about this in core.
  • Providing an API for theme hook/template suggestions outside of preprocessors. (There's an issue for this)
  • Providing the ability to add/modify and tags, and the tag, all within. This is on sdboyer's radar.
@carlwiedemann
carlwiedemann / gist:5385704
Created April 15, 2013 04:31
Diffing the output from a patched drupal site (d8.localhost) to a non-patched drupal site (d8clean.localhost) using HTTPie (https://github.com/jkbr/httpie) and Kaleidescope's ksdiff (http://www.kaleidoscopeapp.com/)
export DRUPALCOOKIECLEAN='SESSa0e1d886dc4b4b88b3a69b139b38d0fd=NOKT1qpWWjYFp0CP3SLf8ejIA-MFrkNIg9vmPP-YEdE'
export DRUPALCOOKIE='SESSe9f6dd3bde2847011220467f468a895f=vQcLvAdPPC4mfmhl_kbwlf4vAhwCWm75AjsC3QGL4UU'
function ddiff() {
URL=$1
# Get clean output
http d8clean.localhost/$URL Cookie:$DRUPALCOOKIECLEAN > /tmp/d8clean-tmp.html
# Get patched output
http d8.localhost/$URL Cookie:$DRUPALCOOKIE > /tmp/d8.html
# Make domains similar