Skip to content

Instantly share code, notes, and snippets.

View ringmaster's full-sized avatar

Owen Winkler ringmaster

View GitHub Profile
@ringmaster
ringmaster / gist:3199354
Created July 29, 2012 14:54
Exclude posts with info debate != 0 from the home display
public function filter_posts_get_update_preset($preset_parameters, $presetname, $paramarray) {
switch($presetname) {
case 'home':
$notallinfo = isset($preset_parameters['not:all:info']) ? Utils::single_array($preset_parameters['not:all:info']) : array();
$notallinfo['debate'] = 0;
$preset_parameters['not:all:info'] = $notallinfo;
break;
}
return $preset_parameters;
}
@ringmaster
ringmaster / gist:3165682
Created July 23, 2012 19:31
Habari shorttags
public static function filter_post_content_out_7( $content, $post )
{
$regex = '%\[(\w+?)(?:\s+(.+?))?/\]|\[(\w+?)(?:\s+(.+?))?(?<!/)](?:(.*?)\[/(\w+?)])%si';
if(preg_match($regex, $content, $matches)) {
$matches = array_pad($matches, 6, '');
$code = $matches[1] . $matches[3];
$attrs = $matches[2] . $matches[4];
$code_contents = $matches[5];
preg_match_all('#(\w+)\s*=\s*(?:(["\'])?(.*?)\2|(\S+))#i', $attrs, $attr_match, PREG_SET_ORDER);
@ringmaster
ringmaster / casbah.css
Created June 22, 2012 17:49
Casbah CSS
/*Created by http://freehtml5templates.com
reset*/
* {
margin: 0;
padding: 0;
}
@font-face {
font-family: AdamskySFRegular;
src: url('adma-webfont.eot');
src: url('adma-webfont.eot?#iefix') format('embedded-opentype'), url('adma-webfont.woff') format('woff'), url('adma-webfont.ttf') format('truetype'), url('adma-webfont.svg#AdamskySFRegular') format('svg');
@ringmaster
ringmaster / gist:2838993
Created May 30, 2012 21:10
Get a post, find posts with any of the same tags that match
<?php
$post = Posts::get(array('slug' => 'habari', 'fetch_fn' => 'get_row'));
$related = Posts::get( array( 'vocabulary' => array( 'any:tags' => $post->tags) ) );
Utils::debug($post->title, $related);
?>
/**
* Helper function: Displays the home page
* @param array $user_filters Additional arguments used to get the page content
*/
public function act_display_home( $user_filters = array() )
{
$paramarray['fallback'] = array(
'home',
'multiple',
);
array (
0 => 'SELECT
{posts}.id AS id,
{posts}.slug AS slug,
{posts}.title AS title,
{posts}.guid AS guid,
{posts}.content AS content,
{posts}.cached_content AS cached_content,
{posts}.user_id AS user_id,
{posts}.status AS status,
array (
0 => 'SELECT
{posts}.id AS id,
{posts}.slug AS slug,
{posts}.title AS title,
{posts}.guid AS guid,
{posts}.content AS content,
{posts}.cached_content AS cached_content,
{posts}.user_id AS user_id,
{posts}.status AS status,
array (
0 => 'SELECT
{posts}.id AS id,
{posts}.slug AS slug,
{posts}.title AS title,
{posts}.guid AS guid,
{posts}.content AS content,
{posts}.cached_content AS cached_content,
{posts}.user_id AS user_id,
{posts}.status AS status,
@ringmaster
ringmaster / config.php
Created April 25, 2012 19:58
Habari Test Configuration
<?php
if(Utils::env_test()) {
Config::set( 'db_connection', array(
'connection_string'=>'sqlite:habari_unittest.db',
'username'=>'',
'password'=>'',
'prefix'=>''
));
Config::set('blog_data', array(
'admin_username' => 'admin',
Query::__set_state(array(
'where' =>
QueryWhere::__set_state(array(
'operator' => 'AND',
'expressions' =>
array (
1 =>
QueryWhere::__set_state(array(
'operator' => 'AND',
'expressions' =>