That spiffy selection thing.

Saturday, 09 May, Year 7 d.Tr. | Author: Mircea Popescu

As you might have noticed, Trilema has been known to publish lengthy articles on occasion.

No, seriously.

Their length notwithstading, they are just as rivetingly interesting as all the other endlessly long and endless articles published on Trilema. What's worse, the parts which (on account of sheer length drowning any possibility of paying attention or even remembering what the fuck you're reading through endless run on sentences that keep referencing themselves circularily as well as drawing unexpected parallels outside of scope and in metonimic manners that get real tiresome real quick) appear to the momentary reading less interesting have a perverse way of becoming extremely relevant later on, and increasingly more so as time goes by, specifically for this reason : that the reader has missed something through being exhausted by the onslaught, rather than discounted something for being uninteresting.

Which means that specific parts will have to be highlighted later on, to be re-digested like those kernels of corn that you sometimes have to pick out of the toilet and eat all over again (chewing them specifically and deliberately this time). No, seriously.

The obvious way html allows for this need to be catered is via a static named anchor, like for instance at work in the Conference list, VIP section. The drawback to this approach is that I don't, at the time of writing, have much of a way to guess what'll end up kernels, and anchoring every single word or sentence is tedious as shit. I had despaired of ever being able to solve this problem, when suddenly...

danielpbarron: log.bitcoin-assets.com/?date=09-05-2015#1126380 << gmaxwell's email on the power ranger mailing list -> archive.is/zsz7l#selection-443.2600-443.2759
mircea_popescu: danielpbarron sheeeit... that selection thing is the tits. how the hell does it work ?
mircea_popescu: omfg im in love

I am. This shit's beautiful!

So I proceeded to hack at the page source of archive.today, which very generously offers the script quite plainly and outright. In order to deploy it on your Wordpress installation, you need to do the following :

I. Download selection-magic.txti and upload it somewhere to your server (as selection-magic.php). Read it, too - it's not really all that long, and reading code before you run it is really the only way to live.

II. Edit wp-content/themes/[your-theme-name]/footer.php to add right before the </body> tag.ii

    include "[correct path]/selection-magic.php";

III. Edit single.php, page.php and/or any other bit of your theme which deals with actually displaying the content you want to enable this function on, and wrap the content in question in a

    <span id="shash-<?php the_ID(); ?>"> [content goes here] </span>

That's it, you're done. Cool beans, huh!

———
  1. You could alternatively also download selection-magic.js, save it as such, include it in footer.php as

      <script src="[correct path]/selection-magic.js"></script>

    and then edit single.php, page.php etc as

      <span id="shash"> [content goes here] </span>

    You lose the ability to create server-side ids with this approach, which might be very inconvenient in some cases, but you might find the process simpler. []

  2. There because if we're going to manipulate the DOM, better make sure the DOM is actually loaded first. []
Category: Meta psihoza
Comments feed : RSS 2.0. Leave your own comment below, or send a trackback.

3 Responses

  1. [...] modification to wp-content/themes/default/single.php and wp-content/themes/default/page.php to wrap post and page content in a unique ID that the selection-magic javascript can [...]

  2. [...] that apparently is sometimes on different browsers; so there is the original thing described at http://trilema.com/2015/that-spiffy-selection-thing/ AND the latest find of the idiotic behaviour + a solution for it [...]

  3. [...] that since introducing that selection thing back on May 9th, 2015, a number of reader man-hours were saved by having it there ; and a number of my own man-hours were [...]

Add your cents! »
    If this is your first comment, it will wait to be approved. This usually takes a few hours. Subsequent comments are not delayed.