SalisburyThis page is a bit of documentation for how I do stuff on the multifarious websites that I’ve perpetrated over the years. These are very much notes for myself but if anybody else should happen upon this page I hope you find it useful :)

On This Day - how it works

These are a couple of vim things I use regularly.

My local history website has a list of stuff that happened on this day' in Salisbury’s history

I maintain the list by adding a page for each event into a Wordpress page structure that looks like this:

  • on-this-day
    • month
    • event page, title of which is prefixed by the date

I fill in the event pages' ‘Order’ field (under ‘Page Attributes’) with the day of the month. The months' ‘Order’ field has the ‘number of the month’ (i.e. 1 is January, 2 is February etc). This keeps everything in order.

Then the top level page has this:

    <ul class="sitemap-pages">
    
    

I think I’m going to change this to have a separate wp_list_pages for each month. This will allow me to have a table of contents, although it will slow it down, I guess.

On This Day - reformatting from dynamic list of Wordpress child pages to static list for the weekly post

Anyhoo, I use the top level list to create a weekly post, summarizing that weeks events in Salisbury history.

There are a couple of vim things that help me do that.

When I grab the page source from the top level list, each page looks like this:

<li class="page_item page-item-7354"><a href="/on-this-day/april/28th-april-1948-terry-pratchetts-birthday">28th April 1948 - Terry Pratchett's birthday</a>

which looks like this on the page:

  • 28th April 1948 - Terry Pratchett's birthday

    I could just cut and paste that, but I think it looks a little bit nicer, in the context of a post to do the following, in gvim.

    This removes the ‘class=“page_item page-item-7354”’ bit. I’m not sure what it’s for but I’m pretty sure it’s not useful in this context

    :%s/ class="page_item page-item-[0-9][0-9]*"//

    Then I’m moving the date out of the anchor text to the start of the line. I could probably do this in one hit, but for the time being I’m mapping a key and then executing it manually once for each line

    :map b />[0-9]ld4w0lllp

    Then typing ‘b’ renders the html like this:

    <li>6th April 1967 - <a href="/on-this-day/april/6th-april-1967-pink-floyd-play-salisbury-city-hall">Pink Floyd play Salisbury City Hall</a>

    …which looks like this:

  • 6th April 1967 - Pink Floyd play Salisbury City Hall

    I prefer this for the posts.

    On This Day - reformatting for the Parish Mag

    A slight variation on the above - this is for re-formatting the On This Day stuff for the Parish mag

    map q /[0-9][0-9][0-9][0-9] dw$A (pi).
    

    then

    / May
    cw: 
    

    WH Smith Deep Linking

    Go to the Deep Link page:

    https://www.affiliatewindow.com/affiliates/customise_link.php?mid=3017

    Paste in the URL from the product page:

    This generates a Deep Link:

    <a href="http://www.awin1.com/cread.php?awinmid=3017&awinaffid=171527&clickref=Notes%20From%20a%20Small%20Island&p=http%3A%2F%2Fwww.whsmith.co.uk%2Fproducts%2Fnotes-from-a-small-island%2Fproduct%2F9780552996006" target="_top">WHSmith</a>

    For a simple text link that’s all you need.

    Pic: The book cover is an ‘affliate link’, which means that if you click on it it will take you to the

    and

    If you buy anything on Smith’s website I get a commission. The image is copyrighted, but because it’s essentially a way of advertizing the product, so I think that this is ‘fair use’

    Insert the image as normal. This gives you some html like this:

    ```Bill Bryson - Notes from a Small Island ```

    Replace the anchor text section (i.e. ‘WHSmith') with the image spec from what was inserted from the Wordpress gallery

    <a href="http://www.awin1.com/cread.php?awinmid=3017&awinaffid=171527&clickref=Notes%20From%20a%20Small%20Island&p=http%3A%2F%2Fwww.whsmith.co.uk%2Fproducts%2Fnotes-from-a-small-island%2Fproduct%2F9780552996006" target="_top"><img src="/images/Bill-Bryson-Notes-from-a-Small-Island-192x300.jpg" alt="Bill Bryson - Notes from a Small Island" width="192" height="300" class="alignright size-medium wp-image-9114" /></a>