<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Mundo Ruby &#187; www</title>
	<atom:link href="http://www.mundoruby.com.ar/tag/www/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.mundoruby.com.ar</link>
	<description>Ruby Artists, Hackers y otras yerbas ...</description>
	<lastBuildDate>Wed, 12 Aug 2009 23:02:13 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Sitemaps vía crawling</title>
		<link>http://www.mundoruby.com.ar/2009/07/15/sitemaps-via-crawling/</link>
		<comments>http://www.mundoruby.com.ar/2009/07/15/sitemaps-via-crawling/#comments</comments>
		<pubDate>Thu, 16 Jul 2009 01:49:05 +0000</pubDate>
		<dc:creator>FreedomCoder</dc:creator>
				<category><![CDATA[Open Source]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[www]]></category>

		<guid isPermaLink="false">http://www.mundoruby.com.ar/?p=147</guid>
		<description><![CDATA[
Hoy me pidieron agregar un Sitemap para uno de los trabajos que hicimos para el gobierno y me encontré con que los plugins que uso para esta tarea no me cerraban de forma cómoda. El problema es que este sitio tiene, además del contenido dinámico, muchas páginas estáticas que no puedo referenciar desde un modelo, [...]]]></description>
			<content:encoded><![CDATA[<p>
<p>Hoy me pidieron agregar un <a href="http://www.sitemaps.org/es/">Sitemap</a> para uno de los trabajos que hicimos para el gobierno y me encontré con que los plugins que uso para esta tarea no me cerraban de forma cómoda. El problema es que este sitio tiene, además del contenido dinámico, muchas páginas estáticas que no puedo referenciar desde un modelo, por lo que debía forzarlas y era bastante molesto.</p>
<p>Buscando encontré <a href="http://www.webficient.com/2008/09/06/google-sitemap-ruby-on-rails">una solución</a> práctica para este caso (donde hay pocas páginas, menos de 1k) que usa un crawler para recorrer todo el sitio y obtener las URLs a agregar al sitemap. El script que presentan me sirvió, aunque tuve que hacerle algunos cambios menores.</p>
<p>El primer problema que tenía era que me agregaba páginas que no deben ir en un sitemap (ni ser indexadas) como las de login, recuperar clave, form de registración, etc. Por lo que tuve que modificar ligeramente el código para no seguir los enlaces que estuvieran marcados con <code>rel="nofollow"</code> y para eso modifiqué en el método <code>extract_and_call_urls</code> la última línea como sigue :</p>
<div class="wp_syntax">
<div class="code">
<pre class="ruby" style="font-family:monospace;">links.<span style="color:#9900CC;">each</span><span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#006600; font-weight:bold;">|</span>link<span style="color:#006600; font-weight:bold;">|</span>
   extract_and_call_urls<span style="color:#006600; font-weight:bold;">&#40;</span>link.<span style="color:#9900CC;">href</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#9966CC; font-weight:bold;">unless</span>
      !can_follow?<span style="color:#006600; font-weight:bold;">&#40;</span>link<span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">||</span> ignore_url?<span style="color:#006600; font-weight:bold;">&#40;</span>link.<span style="color:#9900CC;">href</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">||</span>
      <span style="color:#0066ff; font-weight:bold;">@visited_pages</span>.<span style="color:#9966CC; font-weight:bold;">include</span>?<span style="color:#006600; font-weight:bold;">&#40;</span>link.<span style="color:#9900CC;">href</span><span style="color:#006600; font-weight:bold;">&#41;</span>
<span style="color:#006600; font-weight:bold;">&#125;</span></pre>
</div>
</div>
<p>Y definiendo el nuevo método :</p>
<div class="wp_syntax">
<div class="code">
<pre class="ruby" style="font-family:monospace;"> <span style="color:#9966CC; font-weight:bold;">def</span> can_follow?<span style="color:#006600; font-weight:bold;">&#40;</span>link<span style="color:#006600; font-weight:bold;">&#41;</span>
   <span style="color:#0000FF; font-weight:bold;">return</span> <span style="color:#0000FF; font-weight:bold;">false</span> <span style="color:#9966CC; font-weight:bold;">if</span> link.<span style="color:#0000FF; font-weight:bold;">nil</span>? <span style="color:#006600; font-weight:bold;">||</span>
   <span style="color:#006600; font-weight:bold;">&#40;</span>link.<span style="color:#9900CC;">attributes</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">&quot;rel&quot;</span><span style="color:#006600; font-weight:bold;">&#93;</span> <span style="color:#006600; font-weight:bold;">&amp;&amp;</span> link.<span style="color:#9900CC;">attributes</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">&quot;rel&quot;</span><span style="color:#006600; font-weight:bold;">&#93;</span>.<span style="color:#9966CC; font-weight:bold;">include</span>?<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;nofollow&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
&nbsp;
   <span style="color:#0000FF; font-weight:bold;">true</span>
 <span style="color:#9966CC; font-weight:bold;">end</span></pre>
</div>
</div>
<p>Entonces, cuando el crawler encuentra un enlace que el <em>developer</em> marcó que no debe seguirse en una indexación (esto es principalmente para los crawlers de los search engines) se ignora y no se agrega al sitemap.</p>
<p>El otro cambio menor fue que tenía algunas URLs con el path completo y por default siempre me agregaba al inicio el domain name, por lo que me quedaban URLs inválidas, por lo que hice la siguiente modificación :</p>
<div class="wp_syntax">
<div class="code">
<pre class="ruby" style="font-family:monospace;"><span style="color:#008000; font-style:italic;"># Antes</span>
xml.<span style="color:#9900CC;">loc</span><span style="color:#006600; font-weight:bold;">&#40;</span>@starting_url <span style="color:#006600; font-weight:bold;">+</span> url<span style="color:#006600; font-weight:bold;">&#41;</span>
&nbsp;
<span style="color:#008000; font-style:italic;"># Después</span>
xml.<span style="color:#9900CC;">loc</span><span style="color:#006600; font-weight:bold;">&#40;</span>url.<span style="color:#9966CC; font-weight:bold;">include</span>?<span style="color:#006600; font-weight:bold;">&#40;</span>@starting_url<span style="color:#006600; font-weight:bold;">&#41;</span> ? url : <span style="color:#006600; font-weight:bold;">&#40;</span>@starting_url <span style="color:#006600; font-weight:bold;">+</span> url<span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span></pre>
</div>
</div>
<p>Una vez probado el script hice una tarea rake para poder correrla fácil desde un cronjob :</p>
<div class="wp_syntax">
<div class="code">
<pre class="ruby" style="font-family:monospace;"><span style="color:#008000; font-style:italic;"># lib/tasks/sitemap.rake</span>
<span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'lib/crawler'</span>
&nbsp;
desc <span style="color:#996600;">&quot;Generate the sitemap file&quot;</span>
task <span style="color:#ff3333; font-weight:bold;">:sitemap</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#ff3333; font-weight:bold;">:environment</span> <span style="color:#9966CC; font-weight:bold;">do</span>
  start_url = ENV<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">&quot;URL&quot;</span><span style="color:#006600; font-weight:bold;">&#93;</span> <span style="color:#006600; font-weight:bold;">||</span> <span style="color:#996600;">&quot;http://localhost:3000&quot;</span>
  Crawler.<span style="color:#9900CC;">new</span><span style="color:#006600; font-weight:bold;">&#40;</span>start_url, <span style="color:#006600; font-weight:bold;">&#40;</span>ENV<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">&quot;CREDS&quot;</span><span style="color:#006600; font-weight:bold;">&#93;</span> <span style="color:#9966CC; font-weight:bold;">if</span> ENV<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">&quot;CREDS&quot;</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span>, ENV<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">&quot;QUIET&quot;</span><span style="color:#006600; font-weight:bold;">&#93;</span> <span style="color:#006600; font-weight:bold;">||</span> <span style="color:#0000FF; font-weight:bold;">false</span>, ENV<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">&quot;SITEMAP&quot;</span><span style="color:#006600; font-weight:bold;">&#93;</span> <span style="color:#006600; font-weight:bold;">||</span> <span style="color:#0000FF; font-weight:bold;">false</span>, ENV<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">&quot;DEBUG&quot;</span><span style="color:#006600; font-weight:bold;">&#93;</span> <span style="color:#006600; font-weight:bold;">||</span> <span style="color:#0000FF; font-weight:bold;">false</span><span style="color:#006600; font-weight:bold;">&#41;</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre>
</div>
</div>
<p>Y listo, lo último fue hacer un deploy y configurar un cron.dayli para que cree el sitemap actualizado :</p>
<div class="wp_syntax">
<div class="code">
<pre class="bash" style="font-family:monospace;">rake sitemap <span style="color: #007800;">URL</span>=http:<span style="color: #000000; font-weight: bold;">//</span>www.haciendoelcolon.buenosaires.gob.ar <span style="color: #007800;">SITEMAP</span>=<span style="color: #c20cb9; font-weight: bold;">true</span></pre>
</div>
</div>
<p>Así una vez por día se actualiza el sitemap y se hace un ping a google para que sepa que debe pasar a reindexar el contenido.</p>
<p>Esto tiene varias desventajas (pero aún así para este sitio sirve a su propópito) :</p>
<ul>
<li>No se puede priorizar cada tipo de contenido fácilmente</li>
<li>La fecha de última modificación es inexacta</li>
<li>Carga el webserver para generar el sitemap</li>
</ul>
<p>Código completo : <a href='http://www.gazer.com.ar/wp-content/uploads/2009/07/crawler.rb'>crawler.rb</a></p>
</p>
<p>(Via <a href="http://www.gazer.com.ar">El Futirifoken</a>.) Original Link: <a href="http://www.gazer.com.ar/2009/07/15/sitemaps-via-crawling/#comments">Sitemaps vía crawling</a> </p>
<p><script type="text/javascript"><!--
google_ad_client = "pub-7949681675937032";
google_ad_slot = "0874687580";
google_ad_width = 468;
google_ad_height = 60;
//--></script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mundoruby.com.ar/2009/07/15/sitemaps-via-crawling/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Random User Agents</title>
		<link>http://www.mundoruby.com.ar/2009/07/13/random-user-agents/</link>
		<comments>http://www.mundoruby.com.ar/2009/07/13/random-user-agents/#comments</comments>
		<pubDate>Mon, 13 Jul 2009 17:45:18 +0000</pubDate>
		<dc:creator>FreedomCoder</dc:creator>
				<category><![CDATA[Open Source]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[www]]></category>

		<guid isPermaLink="false">http://www.mundoruby.com.ar/?p=135</guid>
		<description><![CDATA[
While programming Esearchy I had to create a simple class to retrieve random user agents. You may say but why you would want something like this, and the answer is simple:
 &#8220;Try to trick the search engines, so they would not block me&#8221;.  
Yeah, I know this might not even works, but it&#8217;s still [...]]]></description>
			<content:encoded><![CDATA[<p>
<p>While programming Esearchy I had to create a simple class to retrieve random user agents. You may say but why you would want something like this, and the answer is simple:<br />
 &#8220;Try to trick the search engines, so they would not block me&#8221;.  </p>
<p>Yeah, I know this might not even works, but it&#8217;s still cool. =D</p>
<p>Well here it goes</p>
<p><script src="http://gist.github.com/144932.js"></script>
<p>
Use it at your own discretion and listen to your ghost &#8230;</p>
</p>
<p>(Via <a href="http://www.freedomcoder.com.ar">自由編碼人</a>.) Original Link: <a href="http://www.freedomcoder.com.ar/node/154#comments">Random User Agents</a></p>
<p><script type="text/javascript"><!--
google_ad_client = "pub-7949681675937032";
google_ad_slot = "0874687580";
google_ad_width = 468;
google_ad_height = 60;
//--></script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mundoruby.com.ar/2009/07/13/random-user-agents/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

