monkey business

monkey business

I cached my monkeys, so it don’t take so long to retrieve pictures every time, and added a size switch. where can you retrieve the width of the sidebar the widget instance is in ?

Anyways, when I figured the cache thing out, i reckoned hey, lets cache the serp, so then I cached the serp, now it keeps a ‘current’ file and an archive. works half.

at least my pages don’t take an aeon to load anymore.

tomorrow : more monkey business.

ape beasty …that is a cute ape

tag links

SeoQuake indicates my second blog has 52 inside links and 14 outbound, 66 links, but my blog is not ranking.

I ran a spider on the site that counts all the anchors (also double links), that reports 120 anchors.

Google possibly exclude anything with 100+ anchors.

I just counted the links manually and found about 50 links, so i wondered ‘where are the other 70?’. So i counted the tag-cloud and realized ‘damn.. the tags…’. What causes it are the tags per post (the main cause) and the number of posts listed on the frontpage. If i use 10 posts per page I easily have (10*4) 40 tag-links, and if google counts ’em all for onr link and ditches my page I loose the page linking the two blogs. The whole second blog becomes a closed ring with no way out so the entire blog is excluded from page ranking.

I turned the posts per page down to max 3 posts (settings, reading), and removed the ‘recent posts’ widget from the sidebar. Now its down to about 80 links.

If that is all true then tomorrow or by sunday both blogs should start ranking again.

A quick spidering shows the main blog is on 2.20, pages on 1.80, posts on 0.60, and the second blog on 0.60, only the rss feed still has the feed url on ‘follow’ but that’s a minor detail.

That should score quite nicely.

wordpress serp widget serpent

the permutation serp creates too much of a load and the results are 90% general so not very usefull per page.

  • replaced it with a straight top-50 serp on the msn, yahoo, google engines
  • using post_tags
  • added a link to the search engine result pages themselves
  • added a cache and a timer on 6000seconds, it requeries every 1.5 hours when a page is opened and in the meantime dishes out cached results, to minimize queries and page load times
  • added before_widget and after_widget

it needs

  • specific options per engine (language etc.)
  • a dig option up to 1000 result
  • css hooks
  • max three keywords constraint
  • page keywords list (currently only posts’ tags are used)
  • a mysql backend (I don’t want the nonsense in the wordpress db)
  • a counter for used queries (otherwise you get ‘no result’)
  • an archive report to see how the serp results develop

but it’s a start

the results are accurate but i need a once a day routine to grab the keyword of the index page and other pages (the ‘keywords’ section is often dynamic and changes every day, most sites use plugins to either grab all tags of listed posts and put them in the meta-section as page-keywords, or use headspace to override it with a fixed set.)

querying the wordpress database and for all non-post page use get_meta_tags, put url and tags in a cached list and serp the lot once a day would solve that.

something like that.

once I got that fixed i’ll ask some people to test it.

scrape the ape three : sidebar zoo

“Scrape the Ape” plugin.

i ripped the widget code framework from Marcel Proulx and changed it a bit so it runs my Ape-Scrape. I’ll break my brains on the specifics of widget-codes later.

Plugin Name: Scrape the Ape
Plugin URI:
Description: How to scrape a zoo from Flickr onto the sidebar.
Version: 0.1
Author: Lord of Apes
Author URI:

function disp_apes( $args, $widget_args = 1 ) {
	extract( $args, EXTR_SKIP );
	if ( is_numeric($widget_args) )
		$widget_args = array( 'number' => $widget_args );
	$widget_args = wp_parse_args( $widget_args, array( 'number' => -1 ) );
	extract( $widget_args, EXTR_SKIP );

	// Data should be stored as array:  array( number => data for that instance of the widget, ... )
	$options = get_option('widget_apes');
	if ( !isset($options[$number]) )

	extract($options[$number], EXTR_SKIP);

//this is the scraper bit :

	$flikker = join("",file("".$apes_tags."&format=rss"));
	$flikkerhits = preg_split('/img src="\;/', $flikker, -1, PREG_SPLIT_OFFSET_CAPTURE);
	foreach($flikkerhits as $flikkerhit){
	    if($i>1) $apes[]=substr($flikkerhit[0], 0, strpos($flikkerhit[0], 'width')-7);
	$strgrid = "";
	$strgrid .= "
"; for($a=0;$a"; $strgrid .= ""; $strgrid .= ""; $currentcol++; if($currentcol>$columns) { $currentcol=1; $strgrid .= " "; $currentrow++; if($currentrow>$rows) { break; } else { $strgrid .= " "; } } } $strgrid .= "
"; echo $strgrid; } function apes_control($widget_args) { global $wp_registered_widgets; static $updated = false; // have we already updated the data after a POST submit if ( is_numeric($widget_args) ) $widget_args = array( 'number' => $widget_args ); $widget_args = wp_parse_args( $widget_args, array( 'number' => -1 ) ); extract( $widget_args, EXTR_SKIP ); // Data should be stored as array: array( number => data for that instance of the widget, ... ) $options = get_option('widget_apes'); if ( !is_array($options) ) $options = array(); // We need to update the data if ( !$updated && !empty($_POST['sidebar']) ) { // Tells us what sidebar to put the data in $sidebar = (string) $_POST['sidebar']; $sidebars_widgets = wp_get_sidebars_widgets(); if ( isset($sidebars_widgets[$sidebar]) ) $this_sidebar =& $sidebars_widgets[$sidebar]; else $this_sidebar = array(); foreach ( $this_sidebar as $_widget_id ) { // Remove all widgets of this type from the sidebar. We'll add the new data in a second. This makes sure we don't get any duplicate data // since widget ids aren't necessarily persistent across multiple updates if ( 'disp_apes' == $wp_registered_widgets[$_widget_id]['callback'] && isset($wp_registered_widgets[$_widget_id]['params'][0]['number']) ) { $widget_number = $wp_registered_widgets[$_widget_id]['params'][0]['number']; if ( !in_array( "apes-$widget_number", $_POST['widget-id'] ) ) // the widget has been removed. "many-$widget_number" is "{id_base}-{widget_number} unset($options[$widget_number]); } } foreach ( (array) $_POST['apes'] as $widget_number => $widget_apes_instance ) { // compile data from $widget_random_image_instance $apes_tags=strip_tags(stripslashes( $widget_apes_instance['apes_tags'])); $apes_rows=strip_tags(stripslashes( $widget_apes_instance['apes_rows'])); $apes_cols=strip_tags(stripslashes( $widget_apes_instance['apes_cols'])); $options[$widget_number] = compact('apes_tags', 'apes_cols', 'apes_rows'); } update_option('widget_apes', $options); $updated = true; // So that we don't go through this more than once } // Here we echo out the form if ( -1 == $number ) { // We echo out a template for a form which can be converted to a specific form later via JS $apes_tags = 'apes'; $apes_cols = 3; $apes_rows = 2; $number = '%i%'; } else { $apes_tags = attribute_escape($options[$number]['apes_tags']); $apes_cols=$options[$number]['apes_cols']; $apes_rows=attribute_escape($options[$number]['apes_rows']); } // The form has inputs with names like widget-many[$number][something] so that all data for that instance of // the widget are stored in one $_POST variable: $_POST['widget-many'][$number] ?> < ?php } /* Function: apes_register ** ** Registers the apes widgets with the widget page ** ** args: none ** returns: nothing */ function apes_register() { if ( !$options = get_option('widget_apes') ) $options = array(); $widget_ops = array('classname' => 'widget_apes', 'description' => __('Displays Flickr Apes')); $control_ops = array('apes_cols' => 3, 'apes_rows' => 2, 'apes_tags' => 'apes', 'id_base' => 'apes'); $name = __('Scrape the Apes'); $registered = false; foreach ( array_keys($options) as $o ) { // Old widgets can have null values for some reason if ( !isset($options[$o]['apes_tags']) ) continue; // $id should look like {$id_base}-{$o} $id = "apes-$o"; // Never never never translate an id $registered = true; wp_register_sidebar_widget( $id, $name, 'disp_apes', $widget_ops, array( 'number' => $o ) ); wp_register_widget_control( $id, $name, 'apes_control', $control_ops, array( 'number' => $o ) ); } // If there are none, we register the widget's existance with a generic template if ( !$registered ) { wp_register_sidebar_widget( 'apes-1', $name, 'disp_apes', $widget_ops, array( 'number' => -1 ) ); wp_register_widget_control( 'apes-1', $name, 'apes_control', $control_ops, array( 'number' => -1 ) ); } } // This is important add_action( 'widgets_init', 'apes_register' )

do not expect to see this on ;) when i figure out how the widget code works i’ll make something proper.