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

28-7
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 http://www.district30.net and changed it a bit so it runs my Ape-Scrape. I’ll break my brains on the specifics of widget-codes later.

  1. /*
  2. Plugin Name: Scrape the Ape
  3. Plugin URI: http://juust.org/
  4. Description: How to scrape a zoo from Flickr onto the sidebar.
  5. Version: 0.1
  6. Author: Lord of Apes
  7. Author URI: http://juust.org/
  8. */
  9.  
  10. function disp_apes( $args, $widget_args = 1 ) {
  11.  extract( $args, EXTR_SKIP );
  12.  if ( is_numeric($widget_args) )
  13.   $widget_args = array( 'number' => $widget_args );
  14.  $widget_args = wp_parse_args( $widget_args, array( 'number' => -1 ) );
  15.  extract( $widget_args, EXTR_SKIP );
  16.  
  17.  // Data should be stored as array:  array( number => data for that instance of the widget, … )
  18.  $options = get_option('widget_apes');
  19.  if ( !isset($options[$number]) )
  20.   return;
  21.  
  22.  extract($options[$number], EXTR_SKIP);
  23.  
  24. //this is the scraper bit :
  25.  
  26.  $flikker = join("",file("http://api.flickr.com/services/feeds/photos_public.gne?tags=".$apes_tags."&format=rss"));
  27.  $flikkerhits = preg_split('/img src="\;/', $flikker, -1, PREG_SPLIT_OFFSET_CAPTURE);
  28.  foreach($flikkerhits as $flikkerhit){
  29.      $i++;
  30.      if($i>1) $apes[]=substr($flikkerhit[0], 0, strpos($flikkerhit[0], 'width')-7);
  31.  }
  32.  $strgrid = "";
  33.  $currentcol=1;
  34.  $currentrow=1;
  35.  $columns=$apes_cols;
  36.  $rows=$apes_rows;
  37.  $strgrid .= "
  38. <div class="\&quot;ApesZoo\&quot;">
  39. <table border="0">
  40. <tbody>
  41. <tr>";
  42.  for($a=0;$a";
  43.     $strgrid .= "<img src="\" alt="" width="45" height="45" />";
  44.      $strgrid .= "";
  45.      $currentcol++;
  46.      if($currentcol&gt;$columns) {
  47.   $currentcol=1;
  48.                 $strgrid .=  "</tr>
  49. ";
  50.   $currentrow++;
  51.   if($currentrow&gt;$rows) {
  52.      break;
  53.   } else {
  54.      $strgrid .=  "
  55. <tr>";
  56.   }
  57.      }
  58.         }
  59.  $strgrid .= "</tr>
  60. </tbody></table>
  61. </div>
  62. ";
  63.  echo $strgrid;
  64.  
  65. }
  66.  
  67. function apes_control($widget_args) {
  68.  global $wp_registered_widgets;
  69.  static $updated = false; // have we already updated the data after a POST submit
  70.  
  71.  if ( is_numeric($widget_args) )
  72.   $widget_args = array( 'number' =&gt; $widget_args );
  73.  $widget_args = wp_parse_args( $widget_args, array( 'number' =&gt; -1 ) );
  74.  extract( $widget_args, EXTR_SKIP );
  75.  
  76.  // Data should be stored as array:  array( number =&gt; data for that instance of the widget, … )
  77.  $options = get_option('widget_apes');
  78.  if ( !is_array($options) )
  79.   $options = array();
  80.  
  81.  // We need to update the data
  82.  if ( !$updated &amp;&amp; !empty($_POST['sidebar']) ) {
  83.   // Tells us what sidebar to put the data in
  84.   $sidebar = (string) $_POST['sidebar'];
  85.  
  86.   $sidebars_widgets = wp_get_sidebars_widgets();
  87.   if ( isset($sidebars_widgets[$sidebar]) )
  88.    $this_sidebar =&amp; $sidebars_widgets[$sidebar];
  89.   else
  90.    $this_sidebar = array();
  91.  
  92.   foreach ( $this_sidebar as $_widget_id ) {
  93.    // 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
  94.    // since widget ids aren't necessarily persistent across multiple updates
  95.    if ( 'disp_apes' == $wp_registered_widgets[$_widget_id]['callback'] &amp;&amp; isset($wp_registered_widgets[$_widget_id]['params'][0]['number']) ) {
  96.     $widget_number = $wp_registered_widgets[$_widget_id]['params'][0]['number'];
  97.     if ( !in_array( "apes-$widget_number", $_POST['widget-id'] ) ) // the widget has been removed. "many-$widget_number" is "{id_base}-{widget_number}
  98.      unset($options[$widget_number]);
  99.    }
  100.   }
  101.  
  102.   foreach ( (array) $_POST['apes'] as $widget_number =&gt; $widget_apes_instance ) {
  103.    // compile data from $widget_random_image_instance
  104.    $apes_tags=strip_tags(stripslashes( $widget_apes_instance['apes_tags']));
  105.    $apes_rows=strip_tags(stripslashes( $widget_apes_instance['apes_rows']));
  106.    $apes_cols=strip_tags(stripslashes( $widget_apes_instance['apes_cols']));
  107.    $options[$widget_number] = compact('apes_tags', 'apes_cols', 'apes_rows');
  108.   }
  109.  
  110.   update_option('widget_apes', $options);
  111.  
  112.   $updated = true; // So that we don't go through this more than once
  113.  }
  114.  
  115.  // Here we echo out the form
  116.  if ( -1 == $number ) { // We echo out a template for a form which can be converted to a specific form later via JS
  117.   $apes_tags = 'apes';
  118.   $apes_cols = 3;
  119.   $apes_rows = 2;
  120.   $number = '%i%';
  121.  }
  122.  else {
  123.   $apes_tags = attribute_escape($options[$number]['apes_tags']);
  124.   $apes_cols=$options[$number]['apes_cols'];
  125.   $apes_rows=attribute_escape($options[$number]['apes_rows']);
  126.  }
  127.  
  128.  // The form has inputs with names like widget-many[$number][something] so that all data for that instance of
  129.  // the widget are stored in one $_POST variable: $_POST['widget-many'][$number]
  130. ?&gt;
  131.  
  132. <label for="apes-apes_tags-&lt;?php echo $number; ?&gt;">Tags:
  133. <input id="apes-apes_tags-&lt;?php echo $number; ?/&gt;" style="width: 200px;" name="apes[&lt; ?php echo $number; ?&gt;][apes_tags]" type="text" value="&lt; ?php echo $apes_tags; ?&gt;" /></label>
  134.  
  135.  
  136. <label for="apes-apes_cols-&lt;?php echo $number; ?&gt;">Colums:
  137. <input id="apes-apes_cols-&lt;?php echo $number; ?/&gt;" style="width: 200px;" name="apes[&lt; ?php echo $number; ?&gt;][apes_cols]" type="text" value="&lt; ?php echo $apes_cols; ?&gt;" /></label>
  138.  
  139.  
  140. <label for="apes-apes_rows-&lt;?php echo $number; ?&gt;">rows:
  141. <input id="apes-apes_rows-&lt;?php echo $number; ?/&gt;" style="width: 200px;" name="apes[&lt; ?php echo $number; ?&gt;][apes_rows]" type="text" value="&lt; ?php echo $apes_rows; ?&gt;" /></label>
  142.  
  143. &lt; ?php
  144. }
  145.  
  146. /* Function: apes_register
  147. **
  148. ** Registers the apes widgets with the widget page
  149. **
  150. ** args: none
  151. ** returns: nothing
  152. */
  153.  
  154. function apes_register() {
  155.  if ( !$options = get_option('widget_apes') )
  156.   $options = array();
  157.  
  158.  $widget_ops = array('classname' =&gt; 'widget_apes', 'description' =&gt; __('Displays Flickr Apes'));
  159.  $control_ops = array('apes_cols' =&gt; 3, 'apes_rows' =&gt; 2, 'apes_tags' =&gt; 'apes', 'id_base' =&gt; 'apes');
  160.  $name = __('Scrape the Apes');
  161.  
  162.  $registered = false;
  163.  foreach ( array_keys($options) as $o ) {
  164.   // Old widgets can have null values for some reason
  165.   if ( !isset($options[$o]['apes_tags']) )
  166.    continue;
  167.   // $id should look like {$id_base}-{$o}
  168.   $id = "apes-$o"; // Never never never translate an id
  169.   $registered = true;
  170.   wp_register_sidebar_widget( $id, $name, 'disp_apes', $widget_ops, array( 'number' =&gt; $o ) );
  171.   wp_register_widget_control( $id, $name, 'apes_control', $control_ops, array( 'number' =&gt; $o ) );
  172.  }
  173.  
  174.  // If there are none, we register the widget's existance with a generic template
  175. if ( !$registered ) {
  176. wp_register_sidebar_widget( 'apes-1', $name, 'disp_apes', $widget_ops, array( 'number' =&gt; -1 ) );
  177. wp_register_widget_control( 'apes-1', $name, 'apes_control', $control_ops, array( 'number' =&gt; -1 ) );
  178. }
  179. }
  180.  
  181. // This is important
  182. add_action( 'widgets_init', 'apes_register' )

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