<?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/" xmlns:series="http://unfoldingneurons.com/" ><channel><title>kott.fm/tomek/</title> <atom:link href="http://kott.fm/tomek/feed/" rel="self" type="application/rss+xml" /><link>http://kott.fm/tomek</link> <description>odds &#38; ends</description> <lastBuildDate>Fri, 27 Apr 2012 19:35:47 +0000</lastBuildDate> <language>en</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.3.2</generator> <item><title>Publish on Gallery 3 v1.1</title><link>http://kott.fm/tomek/2012/04/07/publish-on-gallery-3-v1-1/</link> <comments>http://kott.fm/tomek/2012/04/07/publish-on-gallery-3-v1-1/#comments</comments> <pubDate>Sun, 08 Apr 2012 02:55:06 +0000</pubDate> <dc:creator>Tomek</dc:creator> <category><![CDATA[Gallery 3]]></category> <category><![CDATA[Publish on Gallery 3]]></category> <category><![CDATA[pog3]]></category> <category><![CDATA[release]]></category><guid isPermaLink="false">http://kott.fm/tomek/?p=1600</guid> <description><![CDATA[With Kevin&#8217;s posts about a firewall setting that prevented the internet check from working in the plugin, I have recoded the check to simply look for a response from the online gallery. If the response is received, the computer is &#8230; <a href="http://kott.fm/tomek/2012/04/07/publish-on-gallery-3-v1-1/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description> <content:encoded><![CDATA[<p>With Kevin&#8217;s posts about a firewall setting that prevented the internet check from working in the plugin, I have recoded the check to simply look for a response from the online gallery. If the response is received, the computer is deemed connected to the internet. Download the new install file <a href="http://kott.fm/tomek/wp-content/uploads/2012/04/PublishOnGallery3.zip">here</a>. I suggest that you uninstall the previous version first.</p>]]></content:encoded> <wfw:commentRss>http://kott.fm/tomek/2012/04/07/publish-on-gallery-3-v1-1/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>XMP Module Version 1.3</title><link>http://kott.fm/tomek/2012/01/28/xmp-module-version-1-3/</link> <comments>http://kott.fm/tomek/2012/01/28/xmp-module-version-1-3/#comments</comments> <pubDate>Sat, 28 Jan 2012 20:51:10 +0000</pubDate> <dc:creator>Tomek</dc:creator> <category><![CDATA[Gallery 3]]></category> <category><![CDATA[Windows Live]]></category> <category><![CDATA[gallery3]]></category> <category><![CDATA[release]]></category> <category><![CDATA[xmp]]></category><guid isPermaLink="false">http://kott.fm/tomek/?p=1233</guid> <description><![CDATA[I&#8217;ve released a new version of the XMP module due to a request by a user. You can now select to use the photo&#8217;s &#8220;caption&#8221; metadata to populate the title of the uploaded photo in Gallery. Download it here.]]></description> <content:encoded><![CDATA[<p>I&#8217;ve released a new version of the XMP module due to a <a title="Uploaded title" href="http://kott.fm/tomek/forums/topic/uploaded-title/">request </a>by a user. You can now select to use the photo&#8217;s &#8220;caption&#8221; metadata to populate the title of the uploaded photo in Gallery. Download it <a href="http://kott.fm/tomek/wp-content/uploads/2010/08/xmp-1.3.zip">here</a>.</p>]]></content:encoded> <wfw:commentRss>http://kott.fm/tomek/2012/01/28/xmp-module-version-1-3/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Publish on Gallery 3: Out of beta!</title><link>http://kott.fm/tomek/2012/01/03/publish-on-gallery-3-out-of-beta/</link> <comments>http://kott.fm/tomek/2012/01/03/publish-on-gallery-3-out-of-beta/#comments</comments> <pubDate>Tue, 03 Jan 2012 16:03:57 +0000</pubDate> <dc:creator>Tomek</dc:creator> <category><![CDATA[Publish on Gallery 3]]></category> <category><![CDATA[pog3]]></category> <category><![CDATA[release]]></category><guid isPermaLink="false">http://kott.fm/tomek/?p=1175</guid> <description><![CDATA[Having fixed a bug with the help of Quirin in the forums, I&#8217;m releasing Publish On Gallery 3 as a &#8220;1.0&#8243; piece of software. The bug fix was to deal with some different URL rewriting conditions that were causing a &#8230; <a href="http://kott.fm/tomek/2012/01/03/publish-on-gallery-3-out-of-beta/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description> <content:encoded><![CDATA[<p>Having fixed a bug with the help of Quirin in the forums, I&#8217;m releasing <a href="http://kott.fm/tomek/wp-content/uploads/2011/12/PublishOnGallery3.zip">Publish On Gallery 3 </a>as a &#8220;1.0&#8243; piece of software. The bug fix was to deal with some different URL rewriting conditions that were causing a connection attempt to fail. The method proposed by Quirin was much more general and should work for more rewriting rules.</p>]]></content:encoded> <wfw:commentRss>http://kott.fm/tomek/2012/01/03/publish-on-gallery-3-out-of-beta/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Automatic Category Lists in FarCry (a la WordPress)</title><link>http://kott.fm/tomek/2011/09/04/automatic-category-lists-in-farcry-a-la-wordpress/</link> <comments>http://kott.fm/tomek/2011/09/04/automatic-category-lists-in-farcry-a-la-wordpress/#comments</comments> <pubDate>Sun, 04 Sep 2011 13:56:07 +0000</pubDate> <dc:creator>Tomek</dc:creator> <category><![CDATA[Tutorials]]></category> <category><![CDATA[automatic]]></category> <category><![CDATA[categories]]></category> <category><![CDATA[ColdFusion]]></category> <category><![CDATA[FarCry]]></category> <category><![CDATA[fc6]]></category> <category><![CDATA[webskin]]></category> <category><![CDATA[wordpress]]></category><guid isPermaLink="false">https://kott.fm/tomek/?p=588</guid> <description><![CDATA[In this tutorial, I want to share how I went about using the &#60;skin:genericNav&#62; tag from FarCry, combined with a custom function, to create an archive of similarly categorized items. This culd be considered similar to WordPress&#8217;s category or tag &#8230; <a href="http://kott.fm/tomek/2011/09/04/automatic-category-lists-in-farcry-a-la-wordpress/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description> <content:encoded><![CDATA[<p>In this tutorial, I want to share how I went about using the &lt;skin:genericNav&gt; tag from <a href="http://www.farcrycore.org/">FarCry</a>, combined with a custom function, to create an archive of similarly categorized items. This culd be considered similar to WordPress&#8217;s category or tag view, in which all the posts matching the category are shown. I&#8217;ve extended this idea for FarCry by allowing any number of different types to be shown.</p><p><span id="more-588"></span></p><h2>Finished Product</h2><p><a href="http://kott.fm/tomek/wp-content/uploads/2011/09/clip_image001.png"><img class="alignright" style="display: inline;" title="clip_image001" src="http://kott.fm/tomek/wp-content/uploads/2011/09/clip_image001_thumb.png" alt="clip_image001" width="404" height="315" /></a>Let&#8217;s take a look at the finished product first. In this screenshot, I&#8217;m showing news (dmNews) and events (dmEvents) that match the category &#8220;Free&#8221;. Additionally, in order to ensure that the page is not overwhelmed, a max of three results are shown on the &#8216;landing&#8217; page. The rest of the events can be seen on a separately loaded page. Let&#8217;s get started!</p><h2>Overview</h2><p>In order to make this work, there are only a few pieces that are necessary. First, there is the &#8220;displayTypeBody&#8221; view for &#8220;dmCategory&#8221;. If you&#8217;re unfamiliar with the naming scheme for webskins in FarCry, I suggest looking <a href="https://farcry.jira.com/wiki/display/FCDEV60/UNIT+07+-+Webskins+II">here</a>.</p><p>Second, there is the &#8220;displayBody&#8221; webskin, which will dictate how each specific category shows its results. This is where the brunt of the work is found.</p><p>Finally, there is the custom function, which will map some generic fields found in the &#8220;displayBody&#8221; webskin to the specific properties of the types we want to show.</p><p>Note that this is only one way to set this up, and which I chose in order to minimize the number of webskins that had to be coded. However, the more proper &#8220;FarCry way&#8221; would be to also have webskins, let&#8217;s call them &#8220;displayTypeCategory&#8221;, which will call &#8220;displayTeaserCategory&#8221; for each the types that we want to show. This would obviate the need for the custom function that I will set up, at the cost of having many more webskins to upkeep. It&#8217;s a trade-off.</p><h2>Setting up dmCategory</h2><p>First, let&#8217;s set up the two webskin files for the category type. First comes the &#8220;type webskin.&#8221; As a quick refresher, this is the one that should display multiple categories. Here, due to a <a href="https://farcry.jira.com/browse/FC-2273">feature enhancement</a> I filed and which was adopted, we can simply use the &lt;skin:genericNav&gt; tag with a category UUID instead of a dmNavigation UUID.</p><p>The code for this skin is super simple:</p><pre><code>&lt;!--- @@displayname: Display List of Categories ---&gt;
&lt;!--- @@cacheStatus: 1 ---&gt;
&lt;!--- @@cacheByVars: url.root ---&gt;

&lt;cfimport taglib="/farcry/projects/gsg/tags/webskin" prefix="skin" /&gt;

&lt;cfparam name="url.root" default="root"&gt;

&lt;cfset sRootCategory =  application.fapi.getContentType("dmCategory").getCategoryIDbyName(url.root)&gt;

&lt;cfif isValid("uuid",sRootCategory)&gt;
    &lt;skin:genericNav navID="#sRootCategory#"
    lColumns=""
    class="cats"
    startLevel="1"
    depth="3"
    bLast="true"
    bIncludeHome="false" /&gt;
&lt;/cfif&gt;
</code></pre><p>Basically, we do:</p><ol><li>Specify name &amp; cache parameters</li><li>Import tags we need to use</li><li>Make sure the URL parameters are present</li><li>Get the UUID of the root category</li><li>Display the categories as an unordered list</li></ol><p>Next up, we set up the displayBody. Remember, this is for a particular category, so we need to decide how to go about displaying the information in a nice manner. Let me post the code in chunks, explaining as I go.</p><p>First, we specify some caching options, and load up the tags we will need later</p><pre><code>&lt;!--- @@displayname: Standard Category body display ---&gt;
&lt;!--- @@cacheStatus: 1 ---&gt;
&lt;!--- @@cacheByVars: url.results,url.catType ---&gt;
&lt;!--- @@author: Tomek Kott ---&gt;

&lt;!--- INCLUDE TAG LIBRARIES ---&gt;
&lt;cfimport taglib="/farcry/core/tags/webskin" prefix="skin" /&gt;
</code></pre><p>Next, we set up and get default values for the url parameters. Namely, we need to know how many results we should be showing, whether we should be showing just one type or all of them, and we need to get the current friendly url so we can put together links easily.</p><pre><code>&lt;cfparam name="url.results" default="3"&gt;
&lt;cfif NOT isValid('integer',url.results)&gt;
    &lt;cfset url.results = 3&gt;
&lt;/cfif&gt;

&lt;cfset lTypes = "dmHTML,dmInclude,dmNews,dmEvent,dmFile,dmImage,dmLink,dmFacts"&gt;
&lt;cfif StructKeyExists(url,'catType') AND listContainsNoCase(lTypes,url.catType)&gt;
    &lt;cfset lTypes = url.catType&gt;
&lt;/cfif&gt;

&lt;cfif structKeyExists(url,'fu')&gt;
    &lt;cfset urlHere = url.fu&gt;
&lt;cfelse&gt;
    &lt;cfset urlHere = application.fapi.getLink(objectid = stObj.objectid, typename = stObj.typename)&gt;
&lt;/cfif&gt;</code></pre><p>Then, we check if there are any child categories for the one we are looking at, and if there are, we display them here so that users can drill down if they want to.</p><pre><code>&lt;cfoutput&gt;&lt;h1&gt;Category: #stObj.categoryLabel#&lt;/h1&gt;&lt;/cfoutput&gt;

&lt;cfset oCat = application.fapi.getContentType("dmCategory")&gt;

&lt;cfset lSubCats = oCat.getCategoryBranchAsList(stObj.objectid)&gt;
&lt;cfif listLen(lSubCats) GT 1 &gt;
    &lt;cfoutput&gt;&lt;h2&gt;Filter&lt;/h2&gt;&lt;p&gt;Currently showing results for this categories
    and all sub-categories. Click on the sub-categories below to filter
    the results. &lt;/p&gt;&lt;/cfoutput&gt;
    &lt;skin:genericNav navID="#stObj.objectid#"
    lColumns=""
    class="cats"
    startLevel="1"
    depth="3"
    bLast="true"
    bIncludeHome="false" /&gt;    
&lt;/cfif&gt;
</code></pre><p>Finally, we hit the brunt of the logic. Here we get the data for each object, and place it in a structure that comes from the custom function (see the next section). Once all the objects have been found, we display them using some cfoutput, information from the custom fields. This is where, if you were following the &#8220;FarCry way&#8221;, you would probably not have the custom function, and instead of this piece of logic, you would simply have a webskin &#8220;displayTypeCategory&#8221; or something similar for each of the types nominated, and put the display logic there.</p><pre><code>&lt;cfoutput&gt;
&lt;h2&gt;Categorized Items&lt;/h2&gt;
&lt;/cfoutput&gt;

&lt;cfset stResults = application.oCustomFunctions.returnRelatedStruct()&gt;

&lt;cfloop list="#lTypes#" index="type"&gt;
    &lt;cfset stResults[type].q = oCat.getObjectByCategory(stObj.objectid,type,true)&gt;
    &lt;cfif NOT stResults[type].q.RecordCount&gt;
        &lt;cfset structdelete(stResults, type)&gt;
    &lt;/cfif&gt;
&lt;/cfloop&gt;

&lt;cfloop list="#lTypes#" index="type"&gt;
    &lt;cfif structKeyExists(stResults,type)&gt;
        &lt;cfoutput&gt;&lt;h3&gt;#stResults[type].name#&lt;/h3&gt;
        &lt;cfif url.Results LT stResults[type].q.recordCount&gt;
            &lt;p&gt;Only showing newest #url.results# results. To show
            all #stResults[type].q.recordCount# results, click
            &lt;a href="#urlHere#?results=#stResults[type].q.recordCount#&amp;catType=#type#"&gt;here&lt;/a&gt;.&lt;/p&gt;
        &lt;/cfif&gt;
        &lt;ul&gt;&lt;/cfoutput&gt;
            
        &lt;cfset qTemp = queryNew("")&gt;
        &lt;cfset qTemp = stResults[type].q &gt;
        &lt;cfquery dbtype="query" name="q" maxrows="#url.results#"&gt;
            SELECT * FROM qTemp
            WHERE status in (#listQualify(request.mode.lvalidstatus, '''')#)
            ORDER BY #stResults[type].date# DESC
        &lt;/cfquery&gt;
        &lt;cfloop query="q"&gt;
            &lt;cfset thisLink = application.fapi.getLink(objectid = q.objectid, typename = type)&gt;
            &lt;cfoutput&gt;&lt;li style="margin-top: 5px;"&gt;&lt;h4 style="padding: 0; margin: 0;" &gt;&lt;a href="#thisLink#"&gt;#q.title#&lt;/a&gt;&lt;/h4&gt;
            &lt;cfif len(stResults[type].teaser)&gt;
                &lt;cfset teaserName = stResults[type].teaser&gt;
                &lt;p&gt;#q[teaserName][q.currentrow]# &lt;a href="#thisLink#"&gt;More&lt;span&gt; about: #q.Title#&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;
            &lt;cfelse&gt;
                &lt;p&gt;&lt;a href="#thisLink#"&gt;More&lt;span&gt; about: #q.Title#&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;
            &lt;/cfif&gt;
            &lt;cfif type EQ "dmImage"&gt;
                &lt;p&gt;&lt;img src="#application.fapi.getImageWebRoot()##q.thumbnailImage#" alt="#q.alt#" title="#q.title#" /&gt;&lt;/p&gt;
                &lt;p&gt;&lt;/p&gt;
            &lt;/cfif&gt;
            &lt;/li&gt;&lt;/cfoutput&gt;
        &lt;/cfloop&gt;
        &lt;cfoutput&gt;&lt;/ul&gt;&lt;/cfoutput&gt;
        
    &lt;/cfif&gt;
&lt;/cfloop&gt;
</code></pre><h2>Custom Function</h2><p>The custom component (which I put in my packages/custom folder, and load into the application scope during the initialization process), has the following function.</p><pre><code>&lt;cfcomponent displayname="Custom Functions" output="false"&gt;
    &lt;cffunction name="returnRelatedStruct" returntype="struct" access="public"&gt;
        &lt;cfset stResults = StructNew()&gt;
        &lt;cfset stResults.dmNews = StructNew()&gt;
        &lt;cfset stResults.dmNews.teaser = "teaser"&gt;
        &lt;cfset stResults.dmNews.date = "publishDate"&gt;
        &lt;cfset stResults.dmNews.name = "News"&gt;
        &lt;cfset stResults.dmNews.cat = "catNews"&gt;
        
        &lt;cfset stResults.dmEvent = StructNew()&gt;
        &lt;cfset stResults.dmEvent.teaser = "teaser"&gt;
        &lt;cfset stResults.dmEvent.date = "startdate"&gt;
        &lt;cfset stResults.dmEvent.name = "Events"&gt;
        &lt;cfset stResults.dmEvent.cat = "catEvent"&gt;
        
        &lt;cfset stResults.dmHTML = StructNew()&gt;
        &lt;cfset stResults.dmHTML.teaser = "teaser"&gt;
        &lt;cfset stResults.dmHTML.date = "datetimelastupdated"&gt;
        &lt;cfset stResults.dmHTML.name = "HTML Pages"&gt;
        &lt;cfset stResults.dmHTML.cat = "catHTML"&gt;
    &lt;/cffunction&gt;
&lt;/cfcomponent&gt;
</code></pre><p>As you can tell, it is straightforward: simply map normal names (date on which to order by, a nice name, whether a teaser is present, and what the category property is called) onto some properties so we can call the easy names without thinking about what we&#8217;re doing.</p><h2>Download</h2><p>Download the three files that go into this solution <a href="http://kott.fm/tomek/wp-content/uploads/2011/09/categories.zip">here</a>, and put them in the projects folder (I think I got the folder structure right!).</p><p>For the next tutorial, I plan on discussing adding an automatic &#8220;Related Items&#8221; section to news and events items, based in part on the custom function outlined above. Stay tuned!</p>]]></content:encoded> <wfw:commentRss>http://kott.fm/tomek/2011/09/04/automatic-category-lists-in-farcry-a-la-wordpress/feed/</wfw:commentRss> <slash:comments>0</slash:comments> <series:name><![CDATA[FarCry Tutorials]]></series:name> </item> <item><title>Seamless computing using Windows devices</title><link>http://kott.fm/tomek/2011/08/30/seamless-computing-using-windows-devices/</link> <comments>http://kott.fm/tomek/2011/08/30/seamless-computing-using-windows-devices/#comments</comments> <pubDate>Wed, 31 Aug 2011 00:52:14 +0000</pubDate> <dc:creator>Tomek</dc:creator> <category><![CDATA[Notes]]></category> <category><![CDATA[slate]]></category> <category><![CDATA[surface]]></category> <category><![CDATA[windows phone 7]]></category><guid isPermaLink="false">http://kott.fm/tomek/?p=576</guid> <description><![CDATA[Now, some of the actions in this blog post / video are a bit hokey, but the idea of being able to seamlessly go from Windows Phone to Surface to Slate just sounds awesome. This is where Microsoft should spend &#8230; <a href="http://kott.fm/tomek/2011/08/30/seamless-computing-using-windows-devices/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description> <content:encoded><![CDATA[<p>Now, some of the actions in <a href="http://nsquaredblog.blogspot.com/2011/08/nsquared-seamless-computing.html">this blog post / video</a> are a bit hokey, but the idea of being able to seamlessly go from Windows Phone to Surface to Slate just sounds awesome. This is where Microsoft should spend some more money on.</p>]]></content:encoded> <wfw:commentRss>http://kott.fm/tomek/2011/08/30/seamless-computing-using-windows-devices/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Gmail copies Outlook</title><link>http://kott.fm/tomek/2011/08/27/gmail-copies-outlook/</link> <comments>http://kott.fm/tomek/2011/08/27/gmail-copies-outlook/#comments</comments> <pubDate>Sat, 27 Aug 2011 23:50:31 +0000</pubDate> <dc:creator>Tomek</dc:creator> <category><![CDATA[Technology]]></category> <category><![CDATA[gmail]]></category> <category><![CDATA[outlook]]></category> <category><![CDATA[previews]]></category><guid isPermaLink="false">https://kott.fm/tomek/?p=523</guid> <description><![CDATA[This made me laugh when I saw it. Yup, gmail is gaining the ability to “preview” your email: Sometimes, though, I want to see more than snippets, which is why I’m happy to announce that you can now preview messages &#8230; <a href="http://kott.fm/tomek/2011/08/27/gmail-copies-outlook/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description> <content:encoded><![CDATA[<p><a href="http://gmailblog.blogspot.com/2011/08/new-in-labs-preview-pane.html">This</a> made me laugh when I saw it. Yup, gmail is gaining the ability to “preview” your email:</p><blockquote><p>Sometimes, though, I want to see more than snippets, which is why I’m happy to announce that you can now preview messages in your inbox using a new feature in Gmail Labs called Preview Pane. It’s probably a very familiar layout to those of you who have used <a href="http://gmailblog.blogspot.com/2010/04/gmail-on-ipad.html">Gmail on a tablet device</a>.</p></blockquote><p>Sound <a href="http://www.google.com/search?q=outlook+2010+preview+pane&amp;hl=en&amp;client=firefox-a&amp;hs=Dtz&amp;rls=org.mozilla:en-US:official&amp;prmd=ivnsfd&amp;source=lnms&amp;tbm=isch&amp;ei=IutSTrGxIoTy0gHy2IzwCA&amp;sa=X&amp;oi=mode_link&amp;ct=mode&amp;cd=2&amp;ved=0CAsQ_AUoAQ&amp;biw=1215&amp;bih=698">familiar</a>? Because hey, it seems like Microsoft actually knows what they’re doing with the whole email thing. Who would’ve <a href="http://www.microsoft.com/presspass/press/2011/jul11/07-21fy11Q4earningsPR.mspx">known</a>.</p>]]></content:encoded> <wfw:commentRss>http://kott.fm/tomek/2011/08/27/gmail-copies-outlook/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>HTML Editing in Fossil: Tickets, Wiki, Comments &amp; Events</title><link>http://kott.fm/tomek/2011/08/24/html-editing-in-fossil-tickets-wiki-comments-events/</link> <comments>http://kott.fm/tomek/2011/08/24/html-editing-in-fossil-tickets-wiki-comments-events/#comments</comments> <pubDate>Thu, 25 Aug 2011 02:27:48 +0000</pubDate> <dc:creator>Tomek</dc:creator> <category><![CDATA[Tutorials]]></category> <category><![CDATA[fossil]]></category> <category><![CDATA[fossil skin]]></category> <category><![CDATA[fossil style]]></category> <category><![CDATA[fossil-scm]]></category> <category><![CDATA[fossil-scm skin]]></category> <category><![CDATA[javascript]]></category> <category><![CDATA[skin]]></category> <category><![CDATA[th1]]></category> <category><![CDATA[tinyeditor]]></category> <category><![CDATA[wysiwyg]]></category><guid isPermaLink="false">https://kott.fm/tomek/?p=557</guid> <description><![CDATA[Do you want to use an HTML editor in Fossil, would like semantically correct code that is sanitized appropriately, but don&#8217;t want to clutter up your repository with useless javascript, css, and image files? Well, here&#8217;s a guide especially for &#8230; <a href="http://kott.fm/tomek/2011/08/24/html-editing-in-fossil-tickets-wiki-comments-events/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description> <content:encoded><![CDATA[<p><a href="http://kott.fm/tomek/wp-content/uploads/2011/08/image.png"><img class="alignright" style="display: inline;" title="image" src="http://kott.fm/tomek/wp-content/uploads/2011/08/image_thumb.png" alt="image" width="240" height="168" align="right" /></a>Do you want to use an HTML editor in <a href="http://fossil-scm.org">Fossil</a>, would like semantically correct code that is sanitized appropriately, but don&#8217;t want to clutter up your repository with useless javascript, css, and image files? Well, here&#8217;s a guide especially for you!</p><p>If you&#8217;re only interested in the skin configuration for the solution (including the &#8216;google code&#8217; type styling in use on my repositories), jump <a href="#config">here</a>. If you&#8217;re interested in integrating things into your own skin, download this <a href="http://kott.fm/tomek/wp-content/uploads/2011/08/tinyeditor.zip">zip </a>file, and then follow through the tutorial!<br /> <span id="more-557"></span></p><h2>How to include png/gifs in CSS</h2><p>Your first question, and the most relevant one, is how to have a nice icon based ui without resorting to any image files. For those that are smarter than me, they would have already muttered something about &#8220;base64&#8243;. For those that are as smart as me, we all turn to searching the web.</p><p>Apparently, it&#8217;s fairly straightforward to embed an image into CSS, HTML, or JS. When I searched, I found this <a href="http://stackoverflow.com/questions/1124149/embedding-background-image-data-into-css-as-base64-good-or-bad-practice">StackOverflow</a> posting, which then led me <a href="http://www.greywyvern.com/code/php/binary2base64">here</a>, which is where I got the text data for the images I needed. Once you&#8217;ve translated a given .png or .gif file into text data, you can include it in CSS with something such as:</p><pre><code class="css">.teheader {
	height:31px;
	border-bottom:1px solid #bbb;
	 background:url(data:image/gif;base64,R0lGODlhAQAgAJEAAO3t7f///+vr6/Ly8iH5BAAAAAAALAAAAAABACAAAAIIzI6pIO3/QgEAOw%3D%3D) repeat-x;
	padding-top:1px
}</code></pre><p>The above is actually taken from the solution&#8217;s css file. Now that we&#8217;ve got a method for ignoring gifs/pngs completely, we can move onto the javascript necessary for a full fledged WYSIWYG editor.</p><h2>TinyEditor</h2><p>When I was looking for bare-bones javascript editors, I first came across <a href="http://speckedit.com/">SpeckEdit</a>. However, that seemed to not be very new, and I had a bit of trouble getting it to work right with two textareas on a page (such as the &#8220;Event&#8221; edit page in Fossil).</p><p>I then found &#8220;<a href="http://www.scriptiny.com/2010/02/javascript-wysiwyg-editor/">TinyEditor</a>&#8220;. It looks nicer than SpeckEdit, and had a few more options, so off I went to integrate it! Really all I had to figure out, once I fixed one minor bug, was how to call the editor for each text area on an appropriate page (Events, Wiki, Tickets, etc.) and ensure that the &#8220;Submit&#8221; and &#8220;Preview&#8221; buttons properly picked up the changed text.</p><div class="wp-caption alignright" style="width: 250px"><a href="http://kott.fm/tomek/wp-content/uploads/2011/08/clip_image0012.png"><img title="clip_image001" src="http://kott.fm/tomek/wp-content/uploads/2011/08/clip_image001_thumb2.png" alt="clip_image001" width="240" height="163" align="right" /></a><p class="wp-caption-text">&quot;Admin&quot; Section of the Fossil UI</p></div><p>Let&#8217;s start integrating. To begin with, open up the header setup (under &#8220;Admin&#8221;, see image), and in between some &#8220;&lt;script type=&#8221;text/javascript&#8221;&gt;&#8221; tags, go ahead and paste the contents of the &#8220;tinyeditor.js&#8221; file. In the CSS setup, copy the contents of the tinyeditor.css file at the bottom of all your CSS.</p><p>Finally, open up the footer, and paste the following section in at the bottom:</p><pre><code class="html">&lt;script type="text/javascript"&gt;
&lt;th1&gt;
if {  -1 != [ string first $current_page "tktnew tktedit wikiedit wikiappend eventedit ci_edit" ] } {
html "textAreas = document.getElementsByTagName('textarea');
if(textAreas.length) \{
    for(var i=0;i&lt;textAreas.length;i++) \{
        textAreas\[i].id='textarea' + i;

new TINY.editor.edit('textarea'+i+'editor',\{
    id:'textarea'+i, // (required) ID of the textarea
    cssclass:'te', // (optional) CSS class of the editor
    cssfile:'style.css?default',
    controlclass:'tecontrol tebackground', // (optional) CSS class of the buttons
    rowclass:'teheader', // (optional) CSS class of the button rows
    dividerclass:'tedivider', // (optional) CSS class of the button diviers
    controls:\['bold', 'italic', 'underline', 'strikethrough', '|', 'subscript', 'superscript', '|', 'orderedlist', 'unorderedlist', '|' ,'outdent' ,'indent', '|', 'leftalign', 'centeralign', 'rightalign', 'blockjustify', 'n', 'unformat',  'undo', 'redo',  'style', '|', 'hr', 'link', 'unlink', '|', 'cut', 'copy', 'paste', 'print'], // (required) options you want available, a '|' represents a divider and an 'n' represents a new row
    footer:true, // (optional) show the footer
    fonts:\['Verdana','Arial','Georgia','Trebuchet MS'],  // (optional) array of fonts to display
    styles:\[\['Style',''],\['Paragraph','&lt;p&gt;'],\['Pre','&lt;pre&gt;'],\['Header 1','&lt;h1&gt;'],\['Header 2','&lt;h2&gt;'],\['Header 3','&lt;h3&gt;'],\['Header 4','&lt;h4&gt;'],\['Header 5','&lt;h5&gt;'],\['Header 6','&lt;h6&gt;']],
    xhtml:true, // (optional) generate XHTML vs HTML
    bodyid:'tineditTimeline', // (optional) attach an ID to the editor body
    footerclass:'tefooter', // (optional) CSS class of the footer
    toggle:\{text:'source',activetext:'wysiwyg',cssclass:'toggle tebackground'\}, // (optional) toggle to markup view options
    resize:\{cssclass:'resize'\} // (optional) display options for the editor resize
\});

    button = document.getElementsByName('submit');
    if(button.length) \{
        currentOnClick = button\[0].getAttribute('onclick');
        if( currentOnClick == null ) currentOnClick = '';
        button\[0].setAttribute('onclick', currentOnClick + 'textarea' + i + 'editor.post();');
    \}
    button = document.getElementsByName('preview');
    if(button.length) \{
        currentOnClick = button\[0].getAttribute('onclick');
        if( currentOnClick == null ) currentOnClick = '';
        button\[0].setAttribute('onclick', currentOnClick + 'textarea' + i + 'editor.post();');
    \}

    \}
\}

"}&lt;/th1&gt;
&lt;/script&gt;
 </code></pre><p>Note that there are several configuration options you can choose when launching the editor, including height and width, among others. Take a look at the script <a href="http://www.scriptiny.com/2010/02/javascript-wysiwyg-editor/">home page</a> for more details.</p><p>Now, go to any user page where there is a text area (such as the Wiki Sandbox or Events), and see your hard work:</p><h2 style="text-align: left;"><a href="http://kott.fm/tomek/wp-content/uploads/2011/08/clip_image0022.png"><img class="aligncenter" title="clip_image002" src="http://kott.fm/tomek/wp-content/uploads/2011/08/clip_image002_thumb2.png" alt="clip_image002" width="640" height="393" /></a>TH1</h2><p>For those that are curious, let me explain the &#8220;TH1&#8243; script that is included above:</p><pre><code class="html"> if { -1 != [ string first $current_page "tktnew tktedit wikiedit wikiappend eventedit ci_edit" ] } { Html "…" } </code></pre><p>First, we have to make sure to launch the TH1 interpreter. This is done by calling the tag &#8220;&lt;th1&gt;&#8221;. Naturally, we need to close the tag as well. Then, there is the overarching if statement:</p><pre><code class="haskell">If { expression } { do something } </code></pre><p>The expression in this case really boils down to the following:</p><pre><code class="haskell">[ string first $current_page "tktnew tktedit wikiedit wikiappend eventedit ci_edit" ] </code></pre><p>The &#8220;[ ]&#8221; tells TH1 to treat everything inside as a single command, and return that value to the next piece to be interpreted. That is, in the &#8220;-1 != […]&#8221; expression, TH1 would first interpret […], and then check &#8220;-1 != …&#8221;. Inside the square brackets, we have:</p><pre><code class="haskell">string first $current_page "tktnew tktedit wikiedit wikiappend eventedit ci_edit" </code></pre><p>$current_page is a global variable available throughout Fossil that basically gives you the string corresponding to the first part of the url you are at. So, if you are at <a href="http://127.0.0.1:8080/eventedit">http://127.0.0.1:8080/eventedit</a>, then $current_page is &#8220;eventedit&#8221;. Then, there is the expression</p><pre><code class="haskell">string first needle haystack ?startindex? </code></pre><p>Citing straight from the TH1 manual.</p><blockquote><p>The <strong>string first</strong> subcommand searches argument <span style="font-family: Courier New;">haystack</span> for a sequence of characters that exactly match the characters in argument <span style="font-family: Courier New;">needle</span>. If found, it returns a decimal string with the index of the first character in the first such match within <span style="font-family: Courier New;">haystack</span>. If not found, it returns return -1. The optional integer argument <span style="font-family: Courier New;">startindex</span> specifies the position where the search begins; the default value is 0, i.e. the first character in haystack.</p></blockquote><p>So, if the current page is in any part of the list given, then the if statement will do something. Otherwise, nothing will happen.</p><p>Finally, the &#8220;html&#8221; part simply says, treat the string in quotes as an HTML string, and therefore do not change &#8220;&lt;&#8221; to &amp;lt; etc. The on caveat is that the TH1 special characters &#8220;,{,},[,],$ are all interpreted, so they must all be escaped using the backslash. It comes out fine the other end though, without the escape characters.</p><h2>Bug Fix in TinyEditor</h2><p>There seems to be an error in the tinyeditor.js: edit.prototype.toggle function. The first part of the if statement has this bit for replacing &#8220;em&#8221;s with a style attribute, but it should be:</p><pre><code class="html">style="font-style: italic;" </code></pre><p>not</p><pre><code class="html">style="font-weight: italic;" </code></pre><h2>Known issues</h2><p>There is only <a href="http://www.scriptiny.com/qa/2216/default-p-on-enter-rather-than-br">one deficiency</a> in the above method. By default, a &#8220;return&#8221; or &#8220;enter&#8221; will not start a new &#8220;&lt;p&gt;&#8221; tag, as should be proper in HTML. Instead, it will simply insert a &#8220;&lt;br&gt;&#8221;. While frustrating, it does not break it&#8217;s use for me, so I&#8217;ll happily use the WYSIWYG editor.</p><h2><a name="config"></a>The Fossil config file</h2><p>If you would rather just download the config file, <a href="http://kott.fm/tomek/wp-content/uploads/2011/08/tinyEditGoogleSkin.zip">here </a>you go. Simply issue a</p><pre><code class="haskell">fossil config import tinyEditGoogleSkin.config </code></pre><p>in an open repository, or</p><pre><code class="haskell">fossil config import googleSkinHighlight.config -R repositoryName </code></pre><p>for any old repository. You can also use &#8220;fossil config merge&#8221; to have fossil attempt to merge your existing config with the one you&#8217;re importing. Your mileage may vary.</p>]]></content:encoded> <wfw:commentRss>http://kott.fm/tomek/2011/08/24/html-editing-in-fossil-tickets-wiki-comments-events/feed/</wfw:commentRss> <slash:comments>2</slash:comments> <series:name><![CDATA[Fossil-SCM]]></series:name> </item> <item><title>f.bat or f.exe: sometimes just use the easy solution</title><link>http://kott.fm/tomek/2011/08/22/f-bat-or-f-exe-sometimes-just-use-the-easy-solution/</link> <comments>http://kott.fm/tomek/2011/08/22/f-bat-or-f-exe-sometimes-just-use-the-easy-solution/#comments</comments> <pubDate>Mon, 22 Aug 2011 23:45:21 +0000</pubDate> <dc:creator>Tomek</dc:creator> <category><![CDATA[Tutorials]]></category> <category><![CDATA[autorun]]></category> <category><![CDATA[batch]]></category> <category><![CDATA[cmd]]></category> <category><![CDATA[doskey]]></category> <category><![CDATA[fossil]]></category> <category><![CDATA[fossil-scm]]></category> <category><![CDATA[windows]]></category><guid isPermaLink="false">https://kott.fm/tomek/?p=522</guid> <description><![CDATA[This was supposed to be a short topic about running fossil from the command &#8220;f&#8221;. I mean short &#8211; like a paragraph introduction and then some code and bam, done. But noooo, I had to try to out do myself. &#8230; <a href="http://kott.fm/tomek/2011/08/22/f-bat-or-f-exe-sometimes-just-use-the-easy-solution/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description> <content:encoded><![CDATA[<p>This was supposed to be a short topic about running fossil from the command &#8220;f&#8221;. I mean short &#8211; like a paragraph introduction and then some code and bam, done. But noooo, I had to try to out do myself. First, why would I want to use &#8220;f&#8221; instead of &#8220;fossil&#8221;? Because I&#8217;m lazy. Pure and simple.<br /> <span id="more-522"></span></p><h2>The aborted attempt</h2><p>Using windows, the obvious thought occurred to me: &#8220;I&#8217;ll just create a shortcut!&#8221; Err. No, that doesn&#8217;t get recognized from the command line. The correct solution, of course, is to open trusty, trusty notepad, type in:</p><pre><code class="haskell">fossil %*</code></pre><p>and save it as &#8220;f.bat&#8221; in some findable directory (I put it right next to fossil.exe). The &#8220;%*&#8221; above simply says, pass all command line arguments on.</p><p>That almost works. The problem is when you run &#8220;f ui&#8221; and then when you&#8217;re done, you want to kill the UI, so you hit CTRL-C:<br /> <a href="http://kott.fm/tomek/wp-content/uploads/2011/08/clip_image0011.png"><img class="aligncenter" style="display: inline;" title="clip_image001" src="http://kott.fm/tomek/wp-content/uploads/2011/08/clip_image001_thumb1.png" alt="clip_image001" width="384" height="50" /></a><br /> Oops, you have to answer a question.</p><h2>The better fix</h2><p>The better solution is to fix the command line starter program, and create, in effect, an alias to &#8220;fossil&#8221;. On a UNIX machine, this would be easy &#8212; modify your &#8220;.bashrc&#8221; file with an alias command, and off you go. Not so simple in Windows.</p><p>Namely, under Windows, you must specify in the <a href="http://www.liutilities.com/products/registrybooster/tweaklibrary/tweaks/10641/">registry</a> that you would like a file to be run every time you start the command prompt. As a rule, I avoid mucking around the registry myself. I figured there had to be a less prying way to do so.</p><p>Then it dawned on me, shortcuts! You see, if I start cmd.exe from the start menu or a shortcut, I can specify the effective command line parameters! So, let&#8217;s get started!</p><ol><li>Open the start menu, and right click on &#8220;All programs&#8221;:<a href="http://kott.fm/tomek/wp-content/uploads/2011/08/clip_image0021.png"><img style="display: inline;" title="clip_image002" src="http://kott.fm/tomek/wp-content/uploads/2011/08/clip_image002_thumb1.png" alt="clip_image002" width="382" height="148" /></a></li><li>Click &#8220;Open&#8221; to open up the start menu as an explorer. Go to the &#8220;Accessories&#8221; folder, and right click on &#8220;Command Prompt&#8221;<br /> <a href="http://kott.fm/tomek/wp-content/uploads/2011/08/clip_image0031.png"><img style="margin: 0px; display: inline;" title="clip_image003" src="http://kott.fm/tomek/wp-content/uploads/2011/08/clip_image003_thumb1.png" alt="clip_image003" width="161" height="146" /></a><br /> and then select &#8220;properties”:<a href="http://kott.fm/tomek/wp-content/uploads/2011/08/clip_image0041.png"><br /> <img style="margin: 0px; display: inline;" title="clip_image004" src="http://kott.fm/tomek/wp-content/uploads/2011/08/clip_image004_thumb1.png" alt="clip_image004" width="386" height="533" /></a></li><li>Append &#8220;/k autorun.bat&#8221; in the &#8220;Target&#8221; box. This will automatically look for a batch file named &#8220;autorun&#8221; in your home directory and call it when you open the shortcut. Now you&#8217;ve got your &#8220;.bashrc&#8221; equivalent!</li><li>The contents of autorun.bat are simple:</li></ol><pre><code class="haskell">@doskey ls=dir $*
@doskey f=fossil $*</code></pre><p>The doskey command is a combo of &#8220;alias&#8221; and normal scripting. The &#8220;@&#8221; above simply silences the printout of any response from the command line, so you start with a nice empty command line.</p><p>There, all done!</p><h2>The really easy way</h2><p>There is an easier way, since fossil is such a small executable. Copy fossil, paste fossil, rename &#8220;f.exe&#8221;. Done.<br /> <a href="http://kott.fm/tomek/wp-content/uploads/2011/08/clip_image0051.png"><img class="alignright" style="display: inline;" title="clip_image005" src="http://kott.fm/tomek/wp-content/uploads/2011/08/clip_image005_thumb1.png" alt="clip_image005" width="96" height="44" /></a><br /> But I like the hard ways better anyway&#8230;</p>]]></content:encoded> <wfw:commentRss>http://kott.fm/tomek/2011/08/22/f-bat-or-f-exe-sometimes-just-use-the-easy-solution/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Updating my style</title><link>http://kott.fm/tomek/2011/08/17/updating-my-style/</link> <comments>http://kott.fm/tomek/2011/08/17/updating-my-style/#comments</comments> <pubDate>Thu, 18 Aug 2011 02:01:35 +0000</pubDate> <dc:creator>Tomek</dc:creator> <category><![CDATA[Solutions]]></category> <category><![CDATA[bbpress]]></category> <category><![CDATA[hybrid]]></category> <category><![CDATA[page]]></category> <category><![CDATA[sidebar]]></category> <category><![CDATA[single]]></category> <category><![CDATA[theme]]></category> <category><![CDATA[twentyeleven]]></category> <category><![CDATA[twentyten]]></category> <category><![CDATA[wordpress]]></category><guid isPermaLink="false">https://kott.fm/tomek/2011/08/17/updating-my-style/</guid> <description><![CDATA[Another summer almost gone. I got back from vacation a couple of weeks ago, and looked over this blog. I realized that when I started, I had meant to do a whole bit on integrating bbPress and Hybrid together into &#8230; <a href="http://kott.fm/tomek/2011/08/17/updating-my-style/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description> <content:encoded><![CDATA[<p>Another summer almost gone. I got back from vacation a couple of weeks ago, and looked over this blog. I realized that when I <a href="http://kott.fm/tomek/2010/07/23/wordpress-bbpress-hybrid/">started</a>, I had meant to do a whole bit on integrating <a title="bbPress.org" href="http://bbpress.org">bbPress</a> and Hybrid together into one kickass package. A year later, nothing had happened &#8212; it was time for a change.</p><p>As you can see, I&#8217;ve updated the blog to be more stylish. I did this in a simple way: updated to the default <a title="WordPress.org" href="http://wordpress.org">WordPress</a> 3.2 theme: TwentyEleven. Then, I got rid of the header images. And that was it. Well, not quite. There were a couple of issues left to fix:</p><ol><li>WordPress sidebar on single blog posts</li><li>Styling bbPress to look like the default bbPress supported TwentyTen theme.</li><li>WordPress sidebar on anything related to forums</li><li>Updating to the highlight.js syntax highlighting plugin: aka shortcode hell</li></ol><p><span id="more-504"></span></p><h2>WordPress Sidebar</h2><p><a href="http://kott.fm/tomek/wp-content/uploads/2011/08/clip_image001.png"><img style="display: inline; float: right;" title="clip_image001" src="http://kott.fm/tomek/wp-content/uploads/2011/08/clip_image001_thumb.png" alt="clip_image001" width="302" height="258" align="right" /></a>The first thing I noticed when I changed the theme over to TwentyEleven, was the lack of the sidebar on single post pages. I can understand that &#8212; no distractions for the reader. However, considering how much info is generally held on the sidebar, I also found this puzzling. Apparently, though, so did a lot of other people.</p><p>I found two generic approaches, and at the moment, I&#8217;m actually using the first one:</p><ol><li>Change the single.php template file, add some CSS.</li><li>Drop the &#8216;singular&#8217; class from &#8220;the Loop,&#8221; thus avoiding the problem in the first place. The necessary change is described very well over at <a href="http://futurewebblog.com/add-sidebar-support-posts-twenty-eleven-theme/">FutureWeb</a>, and essentially get&#8217;s rid of the &#8216;singular&#8217; styling on web pages.</li></ol><p>If you&#8217;re interested in the first option, the longer answer is to create a <a href="http://codex.wordpress.org/Child_Themes">child theme</a><sup>[<a href="#updating-my-style-n-1" class="footnoted" id="to-updating-my-style-n-1">1</a>]</sup>, copy the needed template over, and modify it so that it overrules the parent theme. The necessary modifications are described <a href="http://tricksmommy.com/2011/07/08/add-sidebar-in-single-post-pages-of-twenty-eleven-wordpress-theme/">here</a>, but amount to adding a &#8220;get the sidebar&#8221; function to the template (that seems straightforward) and then adding some css code. The same had to be done for the &#8220;page.php&#8221; template file.</p><h2>Styling bbPress</h2><p><a href="http://kott.fm/tomek/wp-content/uploads/2011/08/clip_image002.png"><img style="display: block; float: none; margin-left: auto; margin-right: auto;" title="clip_image002" src="http://kott.fm/tomek/wp-content/uploads/2011/08/clip_image002_thumb.png" alt="clip_image002" width="620" height="373" /></a></p><p>A year has gone by, and bbPress is now simply a plugin for WordPress. I&#8217;m fine with that &#8212; all I need is a forum type place for debugging and question answering for my <a href="http://kott.fm/tomek/plugins-extensions/">plugins</a>. There was only one last problem &#8212; the super ugly way that bbPress was now being styled due to a lack of compatible code in the TwentyEleven theme.</p><p>So, I set about fixing that. Basically, all I did was the following:</p><ol><li>Create a child theme (partially done already above)</li><li>Copy all the theme files over from the bbPress themes folder</li><li>Change a few settings in the functions.php file</li><li>Figure out FF vs. Internet Explorer issues&#8230;</li></ol><p>In the functions.php file, I deleted the following function:</p><pre><code class="php">if ( ! function_exists( 'bbp_twentyten_setup' ) ):
/**
 * Sets up theme support for bbPress
 *
 * If you're looking to add bbPress support into your own custom theme, you'll
 * want to make sure to use: add_theme_support( 'bbpress' );
 *
 * @since bbPress (r2652)
 */
function bbp_twentyten_setup() {

	// This theme comes bundled with bbPress template files
	add_theme_support( 'bbpress' );
}
/** Tell WordPress to run twentyten_setup() when the 'after_setup_theme' hook is run. */
add_action( 'after_setup_theme', 'bbp_twentyten_setup' );
endif;
</code></pre><p>and the &#8220;else&#8221; part of the css function:</p><pre><code class="php">else {

	// TwentyTen
	wp_enqueue_style( 'twentyten', get_template_directory_uri() . '/style.css', '', $version, 'screen' );

	// bbPress specific
	wp_enqueue_style( 'bbp-twentyten-bbpress', get_stylesheet_directory_uri() . '/css/bbpress.css', 'twentyten', $version, 'screen' );
}</code></pre><p>Finally, I added the following code:</p><pre><code class="php">add_action( 'after_setup_theme', 'my_child_theme_setup' );
	function my_child_theme_setup() {
	add_theme_support( 'bbpress' );
}</code></pre><h3>Firefox vs. Internet Explorer</h3><table width="400" border="0" cellspacing="0" cellpadding="2"><tbody><tr><td valign="top" width="200">FireFox</td><td valign="top" width="200"><a href="http://kott.fm/tomek/wp-content/uploads/2011/08/clip_image003.png"><img style="display: inline;" title="clip_image003" src="http://kott.fm/tomek/wp-content/uploads/2011/08/clip_image003_thumb.png" alt="clip_image003" width="178" height="147" /></a></td></tr><tr><td valign="top" width="200">Internet Explorer 9</td><td valign="top" width="200"><a href="http://kott.fm/tomek/wp-content/uploads/2011/08/clip_image004.png"><img style="display: inline;" title="clip_image004" src="http://kott.fm/tomek/wp-content/uploads/2011/08/clip_image004_thumb.png" alt="clip_image004" width="189" height="154" /></a></td></tr></tbody></table><p>What fixed everything is to get rid of the auto css loader from the added bbPress functions.php and simply include it inline in my style.css. There were two problems: one was that I was looking at the site in FireFox as a user, and in IE as an admin, while the other was an ordering issue<sup>[<a href="#updating-my-style-n-2" class="footnoted" id="to-updating-my-style-n-2">2</a>]</sup>. The above fixed both.</p><h2>Forums Sidebar</h2><p><a href="http://kott.fm/tomek/wp-content/uploads/2011/08/clip_image005.png"><img style="display: inline; float: right;" title="clip_image005" src="http://kott.fm/tomek/wp-content/uploads/2011/08/clip_image005_thumb.png" alt="clip_image005" width="244" height="157" align="right" /></a>Turns out by the time I started looking at how to add the sidebar to a topic, it seems that my changes from single.php and page.php did the trick! Woohoo, nothing to do!</p><h2>Highlight.js and Shortcodes</h2><p>First, I need to make an admission: I got sucked in by WordPress <a href="http://codex.wordpress.org/Shortcode_API">shortcodes</a>. Huh? Turns out, I&#8217;m not the <a href="http://justintadlock.com/archives/2011/05/02/dealing-with-shortcode-madness">only</a> one.</p><p>Let me explain. You see, a good portion of my entries deal with something related to coding. Hence, I need to add code to my posts. When I was first starting out, I found a WordPress <a href="http://wordpress.org/extend/plugins/syntaxhighlighter/">plugin</a> for highlighting, and away I went. Except that instead of relying on the HTML normal &#8220;&lt;pre&gt;&lt;code&gt;&#8221; sequence, it relied on the short code &#8220;[pre]&#8220;.</p><p>That didn&#8217;t bother me until I decided to change to the <a href="http://softwaremaniacs.org/soft/highlight/en/">highlight.js</a> library (as evidenced by it&#8217;s use in <a href="http://kott.fm/tomek/2011/06/23/highlighting-code-diffs-in-fossils-ui/">fossil</a>). I go to the WordPress plugins, search for highlight.js, and here we go: <a href="http://wordpress.org/extend/plugins/wp-highlightjs/">WP-highlight.js</a>. Oops, one problem &#8212; it requires &#8220;&lt;pre&gt;&lt;code&gt;&#8221;. So, now I was left with a shortcode that wasn&#8217;t useful. So, off I went to update all the posts by hand form &#8220;[pre]&#8221; to the proper html equivalent.</p><p>On an implementation note, I have found that specifying &#8220;haskell&#8221; for snippets from a command line (using &lt;pre&gt;&lt;code class=&#8221;haskell&#8221;&gt;), such as</p><pre><code class="haskell">fossil commit -m "commit message"</code></pre><p>makes things appear nicer than just plain or &#8220;bash&#8221; styling. Go figure.</p><h2>Final Note</h2><p>This blog post actually took about two or three times as long mostly because when I kept looking for what I had changed, I realized I wanted to do things differently, and therefore had to change the blog post around, and then I would find that I had broken something, so I would need to fix that, and then the blog post…. It should all be correct now though!</p><ol class="footnotes"><li class="footnote" id="updating-my-style-n-1"><strong><sup>[1]</sup></strong> WordPress documentation I think is very good to introduce the concept of child themes, so I won&#8217;t do it here. If you have any questions, ask away! <a class="note-return" href="#to-updating-my-style-n-1">&#x21A9;</a></li><li class="footnote" id="updating-my-style-n-2"><strong><sup>[2]</sup></strong> Mind you, IE9 wasn&#8217;t doing anything wrong… I was just assuming that things worked the same.. Stupid assumptions <a class="note-return" href="#to-updating-my-style-n-2">&#x21A9;</a></li></ol> ]]></content:encoded> <wfw:commentRss>http://kott.fm/tomek/2011/08/17/updating-my-style/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Highlighting Code &amp; Diffs in Fossil&#8217;s UI</title><link>http://kott.fm/tomek/2011/06/23/highlighting-code-diffs-in-fossils-ui/</link> <comments>http://kott.fm/tomek/2011/06/23/highlighting-code-diffs-in-fossils-ui/#comments</comments> <pubDate>Thu, 23 Jun 2011 20:05:11 +0000</pubDate> <dc:creator>Tomek</dc:creator> <category><![CDATA[Solutions]]></category> <category><![CDATA[Tutorials]]></category> <category><![CDATA[diff highlighting]]></category> <category><![CDATA[fossil]]></category> <category><![CDATA[fossil skin]]></category> <category><![CDATA[fossil style]]></category> <category><![CDATA[fossil-scm]]></category> <category><![CDATA[fossil-scm highlighting]]></category> <category><![CDATA[fossil-scm skin]]></category> <category><![CDATA[highlight.js]]></category> <category><![CDATA[skin]]></category> <category><![CDATA[syntax highlighting]]></category><guid isPermaLink="false">http://kott.fm/tomek/?p=344</guid> <description><![CDATA[In a previous post and associated email on the fossil-users list, I had promised a write-up of how to get nice diff highlighting. Considering how long ago I wrote that post, I think it is obvious I might have forgotten &#8230; <a href="http://kott.fm/tomek/2011/06/23/highlighting-code-diffs-in-fossils-ui/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description> <content:encoded><![CDATA[<p><a href="http://kott.fm/tomek/wp-content/uploads/2011/06/highlightjs.png"><img class="alignright size-thumbnail wp-image-345" title="highlight.js" src="http://kott.fm/tomek/wp-content/uploads/2011/06/highlightjs-150x150.png" alt="highlight.js" width="150" height="150" /></a>In a <a title="Setting Fossil up with Style" href="http://kott.fm/tomek/2011/05/22/setting-fossil-up-with-style/">previous post</a> and <a href="http://www.mail-archive.com/fossil-users@lists.fossil-scm.org/msg04703.html">associated email</a> on the fossil-users list, I had promised a write-up of how to get nice diff highlighting. Considering how long ago I wrote that post, I think it is obvious I might have forgotten about it. <a href="http://www.mail-archive.com/fossil-users@lists.fossil-scm.org/msg04971.html">A recent email chain</a> on the same list snapped me out of it. Thanks to <a href="http://www.mail-archive.com/fossil-users@lists.fossil-scm.org/msg04780.html">this response</a> to my original <a href="http://fossil-scm.org/">fossil</a> styling tutorial on the <a href="http://www.mail-archive.com/fossil-users@lists.fossil-scm.org/">user list</a>, you will find a simple solution that doesn&#8217;t require committing anything to your fossil repository that will highlight your source code and your diffs.</p><p><span id="more-344"></span></p><h2>Highlight.js</h2><p>The javascript library that I chose to use is &#8220;<a href="http://softwaremaniacs.org/soft/highlight/en/">highlight.js</a>&#8220;. I looked at a bunch of different options (including jQuery based ones, SHJS, etc.), but settled on highlight.js for two very simple reasons:</p><ol><li>all you need for all your highlighting (of 40+ languages) is one 24kB javascript file, and any associated css you would like. It fits the bill exactly when looking at integrating it into fossil. <sup>[<a href="#highlighting-code-diffs-in-fossils-ui-n-1" class="footnoted" id="to-highlighting-code-diffs-in-fossils-ui-n-1">1</a>]</sup></li><li>It automatically guesses the language that you are displaying and changes the styling accordingly</li></ol><p><del>The one drawback is that highlight.js expects the code to be placed in &#8220;&lt;pre&gt;&lt;code&gt;&#8221;, rather than the single &#8220;&lt;pre&gt;&#8221; that fossil uses. We will take care of this later through some more (easy) javascript.</del></p><p>Thanks to Ivan&#8217;s comment, I took another look at the js code, and something clicked this time. There is, in fact, no problem with going with just the &lt;pre&gt; tags. The javascript to put in the footer has been updated to reflect this.</p><p>So, download the highlight.js zip file (version 6!), and expand into any directory. We won&#8217;t actually be copying the files, so as long as you can open them in a text editor, we&#8217;re all set!</p><h2>Changing your Fossil Repository</h2><p>In fossil, we will be keeping things as simple as possible. For me, that means no committing some &#8220;/www&#8221; folder to the repository, and using the available &#8220;/doc/tip/www/*&#8221; url scheme that is available in fossil. Instead, we will be copy &amp; pasting directly into the header and footer parts of fossil admin.</p><ol><li>Open the fossi web interface (&#8220;fossil ui&#8221;), and click on over to &#8220;Admin&#8221; and then &#8220;Header&#8221;.</li><li>Open the &#8220;highlight.pack.js&#8221; file in any text browser (somewhere you can copy from).</li><li>At the bottom of your &lt;head&gt; tag, copy in the javascript form the packed file between some &lt;script type=&#8221;text/javascript&#8221;&gt; tags.</li><li>Click &#8220;Apply Changes&#8221; and head on over to the &#8220;Admin&#8221; and &#8220;Footer&#8221; section.</li><li>Add  the following code to the footer section right above the end of the &lt;body&gt; tag:<pre><code>&lt;script type="text/javascript"&gt;
var block=document.getElementsByTagName('pre');
for (var i = 0; i &lt; block.length; i++) {
  hljs.highlightBlock(block[i]);
}
&lt;/script&gt;</code></pre></li><li>Make sure to hit &#8220;Apply Changes&#8221;</li><li>Finally, we need to make sure that everything is styled properly. Highlight.js comes with several css files for styling the generated output. I personally like the github style, so I used that. Pick one of the files and open it in a text editor.</li><li>Go to &#8220;Admin&#8221; &gt; &#8220;CSS&#8221;. At the bottom of the text box, simply copy in the entirety of the relevant css file. Hit &#8220;Apply Changes&#8221;<strong><br /> Note</strong>: for those of you who are using the &#8220;Google Code&#8221;-esque style that I described in my <a title="Setting Fossil up with Style" href="http://kott.fm/tomek/2011/05/22/setting-fossil-up-with-style/">previous post</a>, you will need to make some changes. Namely, that css has a bunch of &#8220;.title&#8221; css descriptors. However, that same CSS class is used in the context of &#8220;pre code .title&#8221;. So, to separate the two, go through and change every instance of &#8220;.title&#8221; to &#8220;div.title&#8221; where it is not part of the &#8220;pre code .title&#8221; blocks.</li><li>Done! As a bonus, there was no need for committing anything. Here are some examples from the <a href="http://kott.fm/cgi-bin/fossil/xmp">XMP</a> repository:<br /> <strong>PHP source highlighting:</strong><br /> <a href="http://kott.fm/tomek/wp-content/uploads/2011/06/examplePHP.png"><img class="alignnone size-full wp-image-346" title="Example of Highlight.js on PHP" src="http://kott.fm/tomek/wp-content/uploads/2011/06/examplePHP.png" alt="" width="300" height="217" /></a><br /> <strong>Diff highlighting:<br /> <a href="http://kott.fm/tomek/wp-content/uploads/2011/06/exampleDiff.png"><img class="alignnone size-full wp-image-347" title="Example of diff highlighting with Highlight.js" src="http://kott.fm/tomek/wp-content/uploads/2011/06/exampleDiff.png" alt="" width="243" height="212" /></a></strong></li></ol><p>Please let me know in the comments if you find anything wrong with the above instructions!</p><h2>Fossil Repository Template</h2><p>Since I like my Fossil skin &amp; highlighting set up, I don’t want to go through the trouble of adding it to every new repository that I create. So I set up a template fossil repository. Everyone is welcome to clone it anonymously:</p><pre><code class="haskell">fossil clone http://kott.fm/cgi-bin/fossil/template template.fossil</code></pre><p>Finally, you can <a href="http://kott.fm/tomek/wp-content/uploads/2011/06/googleSkinHighlight.zip">download the skin</a> with associated highlighting code.  (Unzip it) This is a combination of the Google Code-esque skin + the highlighting. I&#8217;ve corrected for the CSS title problems. Import it into your existing repository via</p><pre><code class="haskell">fossil config import googleSkinHighlight.config</code></pre><p>in an open repository or</p><pre><code class="haskell">fossil config import googleSkinHighlight.config -R repo.fossil</code></pre><p>if you don&#8217;t have your repository &#8220;repo.fossil&#8221; open.</p><ol class="footnotes"><li class="footnote" id="highlighting-code-diffs-in-fossils-ui-n-1"><strong><sup>[1]</sup></strong> You can choose which languages to include in the packed file. If you only want one or two specific languages, then the file will be smaller! If you want all supported languages, the file weighs in at 94 kB <a class="note-return" href="#to-highlighting-code-diffs-in-fossils-ui-n-1">&#x21A9;</a></li></ol> ]]></content:encoded> <wfw:commentRss>http://kott.fm/tomek/2011/06/23/highlighting-code-diffs-in-fossils-ui/feed/</wfw:commentRss> <slash:comments>5</slash:comments> <series:name><![CDATA[Fossil-SCM]]></series:name> </item> </channel> </rss>
<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk: basic
Page Caching using disk: basic
Database Caching using disk: basic

Served from: kott.fm @ 2012-05-20 04:56:45 -->
