Limited Landing Page Display

In order to increase awareness and sales (“conversions” of site traffic to customers) of the book “Devil Music” by Carly Orosz, the promotional landing page is now displayed to new visitors instead of the homepage.

Previously, the Buy The Book promotional landing page was only accessible by scanning the QR-code on the back of the book, by clicking on one of our internet advertisements (e.g. on Facebook, or The House of Hair), or by someone sharing it.

This limited display of the landing page is accomplished by redirecting the user from the homepage to the landing page if a “past visitor” cookie has not been set.

if ($_COOKIE['pastvisitor'] == '') {
setcookie('pastvisitor', 'true', time() + (1 * 365 * 24 * 60 * 60)); // expires in 1 year
// Redirect the user to the landing page only once per year.
header( 'Location: '.'http://www.devil-music.com/buy-the-book/', true, 307 );
die();
}

Using Sublime Text Editor With PHP

Do you have a brand new installation of the Sublime Text editor which you plan on using for PHP (or any other language which identifies special strings, like variable names, with a symbol, like the dollar sign ‘$’)? Don’t forget to change the Preferences > Settings — Default > “word_separators” to remove that dollar sign (or other symbol). Now your copy-paste won’t keep losing your ‘$’.

Posting Code To A Blogger Blog

Added support to this blog for syntax-highlighted code blocks in this blog using SyntaxHighlighter by Alex Gorbatchev.

I wanted to add properly formatted and syntax-highlighted code blocks to this blog, so I looked into what others were doing and what was considered best practice at this time. The best single article I read covering this topic was “How to Post Code To Your Blog and other Religious Arguments” by Scott Hanselman. Visually, my favorite code blocks were those formatted as though they were in Sublime Text (example #1, example #2). However, I could not figure out how to accomplish that without making the underlying material a mess; I suspect there is a tool for Jekyll or similar, which I’m not currently using and cannot easily take advantage of. As such, my choice is instead to use SyntaxHighlighter by Alex Gorbatchev. The SyntaxHighlighter source code is on GitHub and it keeps the underlying code intact inside a single <pre> tag. Also, Alex very kindly offers free public hosting of SyntaxHighlighter, which makes using it on Blogger much simpler (include <script src=””> tag calls instead of copy-pasting the source either into JavaScript widgets or the template itself).

The SyntaxHighlighter installation is as simple as one could hope, though you do need to edit the HTML of your Blogger template directly (Blogger > Template > Edit HTML). Just include the necessary files just before the </head> tag:

<!-- support for SyntaxHighlighter by alexgorbatchev.com -->
<link href='http://alexgorbatchev.com/pub/sh/current/styles/shCore.css' rel='stylesheet' type='text/css'/>
<link href='http://alexgorbatchev.com/pub/sh/current/styles/shThemeDefault.css' rel='stylesheet' type='text/css'/>
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shCore.js' type='text/javascript'/>
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushCss.js' type='text/javascript'/>
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushJScript.js' type='text/javascript'/>
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushPhp.js' type='text/javascript'/>
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushSql.js' type='text/javascript'/>
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushXml.js' type='text/javascript'/>

And then add a couple lines of JavaScript at the end of the template, just before the </body> tag:

<script language='javascript'>
// support for SyntaxHighlighter by alexgorbatchev.com
SyntaxHighlighter.config.bloggerMode = true;
SyntaxHighlighter.all();
</script>

I also was not able to get the AutoLoader to work, so instead I’m explicitly including all of the code brushes I intend on using (out of the many default available brushes).

Using it is similarly straightforward. There is a demo. Used trivially, it is just content in a <pre> tag with a class=”brush: language”, but there are additional options if you care. The one caveat is that all right angle brackets must be HTML escaped (you must replace all “<” with “&lt;” in order to avoid it being interpreted improperly by browsers and other readers) (read the installation page).

Navigation Bar Gadget

Added a navigation bar to this blog, currently hosted on Blogger, as an HTML/JavaScript gadget (widget).

I looked around at how other people were adding navigation to their Blogger blogs and decided that I liked the HTML/CSS/JavaScript gadget method. For this specific navigation bar, I followed:

Although I found that I also had to add some additional CSS to the theme customization in order to undo some of my current theme’s defaults.

.widget li {
margin: 0px;
}