User:mikelietz
From Habari Project
Cabal member, plugin developer, (occasionally) troublesome user, likes lurking in the IRC channel. Theme porter. Wrestler of bears.
Twitter: twitter.com/mikelietz
Website: mikelietz.org
sandbox:
Wanted Pages
- What makes Habari so secure?
- ASL2 Apache License, v2.0
- How do I know which license to use?
- Dev:Using a Token that you created when Dev:Creating A Plugin ... a more practical Core:ACL_Class
- Dev:Naming Tokens ... would come in handy on Dev:Adding an Admin Page
- Dev:Core Tokens ... same.
- Dev:Creating a Dropbutton ... or just Dropbutton.
- Dev:Adding a Search Filter ... how to add, say, search=category:whatever
- Dev:Working With URLs - rewrite rule stuff. Dev:Adding Rewrite Rules should redirect there.
- Dev:Creating a Custom Content Type, including how to add it to the feed, and even better, how to modify what goes in the feed.
- Dev:Adding to the Header as seen in the typekit and geotags plugins.
- Guidelines like Dev:Adding Content to Themes for blocks and whatnot.
Using the author imageurl
Outside of the loop (this is from a header.php):
<?php if( $request->display_entries_by_author && isset( $posts ) ) { ?> <img src="<?php echo $posts[0]->author->info->imageurl; ?>" alt="Posts by <?php echo $posts[0]->author->displayname; ?>"> <?php } else { ?> <img src="header.png" alt="regular header image"> <?php } ?>
I suppose I should point out that display_entries_by_author up there is from a custom version of 0.5.2, not a core feature (yet).
Textarea rows and cols on the publish page
(for /dev/plugin)
Textareas don't always need to be massive. This works for both tabcontrol_textarea and admincontrol_textarea templates.
$instructions = $myform->append('textarea','plugin_version_instructions', 'null:null', Instructions'); $instructions->value = $plugin_versions->info->instructions; $instructions->rows = '3'; $instructions->cols = '75'; $instructions->class[] = 'resizable'; $instructions->template = 'tabcontrol_textarea';
$Request display content
These are the possible display methods(? attributes?) for a $request object (plus any added through rewrite rules):
- display_home
- display_entries
- display_entries_by_date
- display_entries_by_tag
- display_entry
- display_page
- display_search
- display_404
In the example below I only want to display the search form when I am not displaying the search results page(s).
<?php if( !($request->display_search ) ) { ?> <li id="search"> <?php include 'searchform.php'; ?> </li> <?php } ?>
Friendlier ordinal comments links
"Friendlier" only in English, that is.
<? // pointless and dirty hack. $ordinals = array("no","one","two"); ?> <div class="feedback"> <a href="<?php echo $post->permalink; ?>" title="Comments on this post"><? echo ($post->comments->approved->count >= count($ordinals) ? $post->comments->approved->count : $ordinals[$post->comments->approved->count ] ); echo _n( ' comment', ' comments', $post->comments->approved->count ); ?></a>
Counting words in a post
Not counting the title, though:
<? echo count( explode( " ", strip_tags( $post->content_out ) ) ); ?> words.
This is the basis of my word count plugins.
XHTML to HTML
Wow. Amazingly easy way to fix all of the horizontal rules:
UPDATE habari__posts SET content=REPLACE(content,'hr /','hr');
Pulling out the most recent entry outside of Habari
$conn = mysql_connect($host,$user,$password) or die ('Connection failed'); mysql_select_db( $db ); $query = "SELECT * FROM habari__posts where id = (SELECT max(id) FROM habari__posts WHERE content_type = '1' and status = '2')"; $result = mysql_query($query); while($row = mysql_fetch_array($result, MYSQL_ASSOC)) { $date = date("j F Y",strtotime($row['pubdate'])); $title = $row['title']; $content = wpautop($row['content']); } mysql_close( $conn );
Merging to the makaanga
# svn co https://svn.habariproject.org/habari/makaanga/0.x/htdocs makaanga
Merge r3958-59 (note first rev is one less):
# svn merge -r 3957:3959 https://svn.habariproject.org/habari/trunk/htdocs/
Merge r3962-64 (note first rev is one less):
# svn merge -r 3961:3964 https://svn.habariproject.org/habari/trunk/htdocs/
Releasing a minor point release
See Release Checklist.
Make sure system/classes/version.php has been updated with the new version.
Tag it:
svn copy https://svn.habariproject.org/habari/makaanga/0.x https://svn.habariproject.org/habari/tags/0.6.4
Create a zip for /dist - svn export only the https://svn.habariproject.org/habari/makaanga/0.x/htdocs folder, not everything.
Update the downloads page, both the post *and* the template. @TODO make updating the template obsolete by adding an option that can be edited.
Update the wiki - release notes and front page.
Update Wikipedia. Habari @ Wikipedia
Update the beacon.
Free webhosts that don't support Habari
x10Hosting - Installs fine, but Flickr silo does not work. Inactivity policy somewhat aggressive.
110mb.com - PHP5.1.6 and, as of 10/2009, no plans to upgrade to 5.2.anything.
UnlimitedMB - missing many extensions.
Host.sk - missing PDO.
T35 - forced ads on all pages, including admin. Unacceptable, and breaks admin.
iLive - Streams disabled and no Curl.
Installer testing (on hold for now)
I think I'll make a spreadsheet for this.
| case | db type | / writable | /user writable | results |
|---|---|---|---|---|
| sqlite | no | no | yes | big red box |
random musings, not ticket worthy until thought through
- Would there be any merit to having a $comment->permalink? Instead of hardcoding {$comment-post->url}#comment-{$comment->id} in both the admin and the theme (as well as anywhere else) wouldn't it be more flexible to have a permalink function (as well as a configurable option) to do it?
Changing 'tag' in the URL to 'blah'
Quick and dirty way to customize the stock rewriterule URLs.
public function filter_rewrite_rules( $rules ) { foreach ( $rules as $rule ) { if ( $rule->name == 'display_entries_by_tag' ) { $rule->parse_regex = '#^blah/(?P<tag>[^/]*)(?:/page/(?P<page>\d+))?/?$#i'; $rule->build_str = 'blah/{$tag}(/page/{$page})'; $rule->update(); } } return $rules; }
Monthly Archives link list
(thanks Rick)
public function theme_monthly_archives_links_list( $theme, $full_names = TRUE, $show_counts = TRUE, $type = 'entry', $status = 'published' ) { $results = Posts::get( array( 'content_type' => $type, 'status' => $status, 'month_cts' => 1 ) ); $archives[] = '<ul class="archives">'; foreach ( $results as $result ) { // what format do we want to show the month in? if( $full_names ) { $display_month = HabariDateTime::date_create()->set_date( $result->year, $result->month, 1)->get( 'F' ); } else { $display_month = HabariDateTime::date_create()->set_date( $result->year, $result->month, 1)->get( 'M' ); } // do we want to show the count of posts? if ( $show_counts ) { $count = ' (' . $result->ct . ')'; } else { $count = ''; } $result->month= str_pad( $result->month, 2, 0, STR_PAD_LEFT ); $archives[] = '<li>'; $archives[] = '<a href="' . URL::get( 'display_entries_by_date', array( 'year' => $result->year, 'month' => $result->month ) ) . '" title="View entries in ' . $display_month . '/' . $result->year . '">' . $display_month . ' ' . $result->year . ' ' . $count . '</a>'; $archives[] = '</li>'; } $archives[] = '</ul>'; return implode( "\n", $archives ); }
