<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
     xmlns:content="http://purl.org/rss/1.0/modules/content/"
     xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
     xmlns:atom="http://www.w3.org/2005/Atom"
     xmlns:dc="http://purl.org/dc/elements/1.1/"
     xmlns:wfw="http://wellformedweb.org/CommentAPI/"
     >
  <channel>
    <title>MorganGoose.com</title>
    <link>http://morgangoose.com/blog</link>
    <description>notes about various technical subjects</description>
    <pubDate>Thu, 08 Dec 2016 01:14:37 GMT</pubDate>
    <generator>Blogofile</generator>
    <sy:updatePeriod>hourly</sy:updatePeriod>
    <sy:updateFrequency>1</sy:updateFrequency>
    <item>
      <title>Github project list</title>
      <link>http://morgangoose.com/blog/2010/09/29/github-project-list</link>
      <pubDate>Wed, 29 Sep 2010 22:24:00 PDT</pubDate>
      <category><![CDATA[Website]]></category>
      <category><![CDATA[Version Control]]></category>
      <guid isPermaLink="true">http://morgangoose.com/blog/2010/09/29/github-project-list</guid>
      <description>Github project list</description>
      <content:encoded><![CDATA[<div class="document">
<div class="section" id="adding-in-more-stuff">
<h1>Adding in more stuff</h1>
<p>It's mostly what I am working on atm for the blog. After using <a class="reference external" href="http://blogofile.com">blogofile</a> for a
few days now I've really gotten accustomed to writing up new things for it. It
is only python after all. So that helps. My newest idea was to have a listing of
my github projects in the sidebar.</p>
</div>
<div class="section" id="seems-simple-enough">
<h1>Seems simple enough</h1>
<p>Found a <a class="reference external" href="http://github.com/ask/python-github2">good api in python</a> for this.
There was one that used javascript that would have also done the job, but I
decided this could be slow and updated when the site was built, instead of
needing to be updated real time.</p>
<p>After installing the <a class="reference external" href="http://github.com/ask/python-github2">github2</a> module, I got right to it and started making a
controller for the widget. And I ended up with something like this:</p>
<div class="section" id="github-py">
<h2>github.py</h2>
<div class="highlight"><pre><span class="kn">import</span> <span class="nn">logging</span>

<span class="kn">from</span> <span class="nn">blogofile.cache</span> <span class="kn">import</span> <span class="n">bf</span>
<span class="n">github</span> <span class="o">=</span> <span class="n">bf</span><span class="o">.</span><span class="n">config</span><span class="o">.</span><span class="n">controllers</span><span class="o">.</span><span class="n">github</span>

<span class="kn">from</span> <span class="nn">github2.client</span> <span class="kn">import</span> <span class="n">Github</span>
<span class="n">github_api</span> <span class="o">=</span> <span class="n">Github</span><span class="p">()</span>

<span class="n">config</span> <span class="o">=</span> <span class="p">{</span>
    <span class="s">&quot;name&quot;</span><span class="p">:</span> <span class="s">&quot;Github&quot;</span><span class="p">,</span>
    <span class="s">&quot;description&quot;</span><span class="p">:</span> <span class="s">&quot;Makes a nice github project listing for the sidebar&quot;</span><span class="p">,</span>
    <span class="s">&quot;priority&quot;</span><span class="p">:</span> <span class="mf">90.0</span><span class="p">,</span>
    <span class="p">}</span>

<span class="k">def</span> <span class="nf">get_list</span><span class="p">(</span><span class="n">user</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">    Each item in the list has:</span>
<span class="sd">    name, url, description, forks, watchers, homepage, open_issues</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="k">return</span> <span class="p">[</span><span class="n">g</span> <span class="k">for</span> <span class="n">g</span> <span class="ow">in</span> <span class="n">github_api</span><span class="o">.</span><span class="n">repos</span><span class="o">.</span><span class="n">list</span><span class="p">(</span><span class="n">user</span><span class="p">)</span> <span class="k">if</span> <span class="ow">not</span> <span class="n">g</span><span class="o">.</span><span class="n">fork</span><span class="p">]</span>


<span class="k">def</span> <span class="nf">run</span><span class="p">():</span>
    <span class="n">github</span><span class="o">.</span><span class="n">logger</span> <span class="o">=</span> <span class="n">logging</span><span class="o">.</span><span class="n">getLogger</span><span class="p">(</span><span class="n">config</span><span class="p">[</span><span class="s">&#39;name&#39;</span><span class="p">])</span>
    <span class="n">github</span><span class="o">.</span><span class="n">repo_list</span> <span class="o">=</span> <span class="n">get_list</span><span class="p">(</span><span class="n">github</span><span class="o">.</span><span class="n">user</span><span class="p">)</span>
</pre></div>
<p>With a configuration in _config.py like this:</p>
<div class="highlight"><pre><span class="c">#### github projects ####</span>
<span class="n">controllers</span><span class="o">.</span><span class="n">github</span><span class="o">.</span><span class="n">enabled</span> <span class="o">=</span> <span class="bp">True</span>
<span class="n">github</span> <span class="o">=</span> <span class="n">controllers</span><span class="o">.</span><span class="n">github</span>
<span class="n">github</span><span class="o">.</span><span class="n">user</span> <span class="o">=</span> <span class="s">&quot;goosemo&quot;</span>
</pre></div>
<p>And a simple github.mako file that I used mako's <a class="reference external" href="http://www.makotemplates.org/docs/syntax.html#syntax_tags_include">include</a> function for:</p>
<div class="highlight"><pre><span class="nt">&lt;div</span> <span class="na">class=</span><span class="s">&quot;sidebar_item&quot;</span><span class="nt">&gt;</span>
<span class="nt">&lt;h3&gt;</span>Github Projects<span class="nt">&lt;/h3&gt;</span>
<span class="nt">&lt;ul&gt;</span>
% for project in bf.config.controllers.github.repo_list:
    <span class="nt">&lt;li&gt;&lt;a</span> <span class="na">href=</span><span class="s">&quot;${project.url}&quot;</span> <span class="na">title=</span><span class="s">&quot;${project.name}&quot;</span><span class="nt">&gt;</span>
    ${project.name}<span class="nt">&lt;/a&gt;</span><span class="ni">&amp;nbsp;</span>${project.description}<span class="nt">&lt;/li&gt;</span>
    <span class="nt">&lt;br/&gt;</span>
% endfor
<span class="nt">&lt;/ul&gt;</span>
<span class="nt">&lt;/div&gt;</span>
<span class="nt">&lt;br</span> <span class="nt">/&gt;</span>
</pre></div>
</div>
</div>
<div class="section" id="i-did-run-into-an-issue">
<h1>I did run into an issue</h1>
<p>After getting this all down the site was acting strange. The frontage had the
listing of my git repos just as it was supposed to be. But I found that on
every other page the github section was blank.</p>
<p>After tweaking and getting a bit frustrated, I read the <a class="reference external" href="http://blogofile.com">blogofile</a> code a bit
more for the controller sections, and got the idea to up the priority from 70
to 90.</p>
<p>This did the trick, and I figure it was because the permalinks and other page
creation work was being done before the github.repo_list could be populated.</p>
</div>
<div class="section" id="thoughts-so-far">
<h1>Thoughts so far</h1>
<p>Overall the process from idea to working in <a class="reference external" href="http://blogofile.com">blogofile</a> is straightforward,
since it's nothing new in form of coding. Mako and python go well together.</p>
<p>Now I just need to get down a coherent way to publish these little bits I keep
adding, and to also make them completely configurable via the _config.py and
isolated into their own units so that installation/use is a simple procedure.</p>
</div>
</div>
]]></content:encoded>
    </item>
    <item>
      <title>Github and Bitbucket hooks</title>
      <link>http://morgangoose.com/blog/2010/09/29/github-and-bitbucket-hooks</link>
      <pubDate>Wed, 29 Sep 2010 17:40:10 PDT</pubDate>
      <category><![CDATA[Version Control]]></category>
      <guid isPermaLink="true">http://morgangoose.com/blog/2010/09/29/github-and-bitbucket-hooks</guid>
      <description>Github and Bitbucket hooks</description>
      <content:encoded><![CDATA[<div class="document">
<div class="section" id="i-use-hg-but-like-github">
<h1>I use hg but like github</h1>
<p>I also dislike unevenness. Having recently read about the <a class="reference external" href="http://hg-git.github.com/">hg-git</a> plugin and
read about a <a class="reference external" href="http://hgtip.com/tips/advanced/2009-11-09-create-a-git-mirror/">setup</a> that uses the paths definitions for <a class="reference external" href="http://hgbook.red-bean.com/index.html">hg</a> to make simple
names to push to, and decided to combine them all together. I ended up with a
~/.hgrc that I had this:</p>
<div class="highlight"><pre><span class="k">[extensions]</span>
<span class="na">hgext.bookmarks</span> <span class="o">=</span>
<span class="na">hggit</span> <span class="o">=</span>
</pre></div>
<p>And then in the repo's .hg/hgrc I'd add something like this:</p>
<div class="highlight"><pre><span class="k">[paths]</span>
<span class="na">github</span> <span class="o">=</span> <span class="s">git+ssh://git@github.com:goosemo/hooks.git</span>
<span class="na">bitbucket</span> <span class="o">=</span> <span class="s">ssh://hg@bitbucket.org/morgan_goose/hooks</span>
</pre></div>
</div>
<div class="section" id="that-worked-well">
<h1>That worked well</h1>
<p>But I had to remember to push to both, and that was annoying. Then I dug into
<a class="reference external" href="http://www.selenic.com/mercurial/hgrc.5.html#hooks">hooks</a> and found that I could easily make a shell script to push to both for
me. What I ended up with was a bash script that would determine which path I
had pushes to, and then push to the other:</p>
<div class="highlight"><pre><span class="c">#!/bin/bash</span>

<span class="c"># This script takes in the args that a hg push is given and checks for the paths</span>
<span class="c"># that I&#39;ve defined in my hg repos for either a push to bitbucket or github,</span>
<span class="c"># and then does the other, so that regardless of which of these sites I push to</span>
<span class="c"># the other also get pushed to.</span>

<span class="c">#post-push to bitbucket</span>
<span class="k">if</span> <span class="o">[[</span> <span class="nv">$HG_ARGS</span> <span class="o">=</span>~ <span class="s2">&quot;push bitbucket&quot;</span> <span class="o">]]</span>
<span class="k">then</span>
<span class="k">    </span>hg push github --quiet
<span class="k">fi</span>

<span class="c">#post-push to github</span>
<span class="k">if</span> <span class="o">[[</span> <span class="nv">$HG_ARGS</span> <span class="o">=</span>~ <span class="s2">&quot;push github&quot;</span> <span class="o">]]</span>
<span class="k">then</span>
<span class="k">    </span>hg push bitbucket --quiet
<span class="k">fi</span>
</pre></div>
<p>Note that the quiet flags or similar must be employed, otherwise you'll get
caught in an infinite loop. After that I added this line into my ~/.hgrc</p>
<div class="highlight"><pre><span class="k">[hooks]</span>
<span class="na">post-push</span> <span class="o">=</span> <span class="s">$HOME/workspace/hooks/github.sh</span>
</pre></div>
</div>
<div class="section" id="success">
<h1>Success</h1>
<p>Now regardless of where I push the other will get the update:</p>
<div class="highlight"><pre>~/workspace/hooks<span class="nv">$ </span>hg push bitbucket
pushing to ssh://hg@bitbucket.org/morgan_goose/hooks
searching <span class="k">for </span>changes
no changes found


~/workspace/hooks<span class="nv">$ </span>hg push github
pushing to git+ssh://git@github.com:goosemo/hooks.git
importing Hg objects into Git
creating and sending data
github::refs/heads/master <span class="o">=</span>&gt; GIT:b4fb4c58
</pre></div>
</div>
</div>
]]></content:encoded>
    </item>
  </channel>
</rss>
