Proper html linking : the crisis, the solution, the resolution & conclusion

Saturday, 20 July, Year 11 d.Tr. | Author: Mircea Popescu

I. The crisis.

mp_en_viaje: in other horrible news : it's confirmed, the selection thing is ~~~BROWSER SPECIFIC~~~

It is the sort of bug that's always hardest to notice, because "it works for me" ; and it doesn't work for you coincidentally, now and again -- it is engineered, and with malice aforethought to work for you, and you only. The thing is fucking designed so as to deliver the interests of Inca under the color of delivering your own interests, it separates youi even as it seems to feed you.

So here I spent untold months in aspie heaven, imagining I'm actually using bidirectional links, while everyone else saw the same thing... some of the time. Can you believe that crap ?!

II. The solution.

asciilifeform: when i was sawing the thing apart , thought 'why not make selector search for start/end chars until finds unique, then sel displayer ditto' but did not get to trying this

This is good for many reasons, that all reduce to "kicking USG tendrils out of republican process". That nobody needs javascript to see a selection anymore is a thing of beauty ; that nobody needs javascript to produce a selection anymore is the other thing of beauty. Those were the last two uses known for javascript (the archive selector has proper html fallback, so it's merely a convenience, and one I intend to throw out, at that). This means... well, it means I will be able to run the shitty gfx browsers in no-js mode! Holy hell finally! I can not begin to tell you how much it pained me to need javascript, as the only way to have properii links.

III. The resolution. MP's own PHP grenadiers regiment implemented the solution "overnight"iii, and so now we have resolution!

To apply this to your own blog, you will first need to edit your root level .htaccessiv :

- RewriteRule (.*) /index.php [L]
+ RewriteRule (.*) /index.php [QSA,L]

QSA stands for Query String Append, see the mod_rewrite manual for all sorta intricately detailed views of that strange ad-hoc scripting language.

Then the following goes into your theme's functions.php. This is not the blog-wide functions.php as found in wp-includes, but the theme's own function.php as found in /wp-content/themes/<name>/ ; don't ask me about the brilliant naming conventions involved, I had no hand.

// This does the server-side selection

add_filter('the_content', 'server_side_selection');

function server_side_selection($content){
//bookend code goes here
  $b_code = '<span style="background-color:#d3d3d3" id="select">';
  $b_code .= $_GET["b"];
  $e_code = $_GET["e"].'</span>';

//change page ; last to first to preserve indexes.
  $b_pos = strpos($content,$_GET["b"]);
  $e_pos = strpos($content,$_GET["e"], $b_pos);
  if ($e_pos>0)
    $content = substr_replace($content, $e_code, $e_pos, strlen($_GET["e"]));
  if ($b_pos>0)
    $content = substr_replace($content, $b_code, $b_pos, strlen($_GET["b"]));
  return $content;
}

There are some user-tunable knobs in there, let's go through the list :

  1. You can adjust the magic words b & e, as well as the magic word "select" so as to have your page respond to differently formatted url calls. I would advise against fucking with this, so as to achieve ecosystem standardization -- there's conceivably some residual benefit for the user being able to predict which knobs work on a blog he's never seen before.
  2. background-color:#d3d3d3 will happily take any color you wish to use and apply it as background for the selected text ; obviously further hackery is available there at no detriment, you can have whatever style in the style tag you wish.
  3. The usage of "span" could be replaced, such as for instance with div. The disadvantage of span is that, being an inline element, it will not cross paragraphs (or <li> borders for that matter). The disadvantage of div is that being a block level element, it will break lines around its starting and ending point. This latter behaviour seems to me a worse trade-off than the short range span, but ymmv.
  4. MP-WP calling convention permits you to add an if(is_single()) conditional to modulate the behaviour to only articles, and such shenanigans. I do not see the utility here, but the hooks are available. You can similarily add conditionals before the first line, to have the whole process only apply in certain conditions (eg, only allow some users to view/produce selections, though I can't imagine why you'd want this).

I am of course very much interested in hearing battlefield reports.

IV. The conclusion is that it never pays to play along. Phf tried to play along with a pantsuit coven and got his asshole torn apart for his trouble. By a tree. That shit hurts.

I thought I was special and bright and smart and etcetera ; I thought I can use the empire's tools to deliver marginal benefit. I was wrong.

Consider 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 employed to produce the compatible links -- opening pages, selecting snippets, pasting modified urls...

Today I find myself in the unenviable position of... having to replace them all. Take a look at this :

| sum(ROUND((LENGTH(post_content)-LENGTH(REPLACE (post_content, "#selection-", "")))/11)) |
+-----------------------------------------------------------------------------------------------+
| 27090 |

Twenty-seven thousand links. Even if you could do one link a second, which you can't do, it's still one day's hard work. Was it worth it ? Was it worth trading my work and time for the devil's leaves ? Was it worth it, to pile my diligence at the foot of the golden calf, only to find myself, four years down the road, personally invested in the continuance of the abomination ? "Either maintain javascript", it whispers, "or else lose these children of yours", it gnashes. Was it motherfucking worth it ?

Don't stick your dick in evil. There's insufficient erections to go around as it is, no need to waste any of them. Aite ?

PS. It might also be a good idea to edit xmlrpc.php, so as to take advantage of this newfangled tech :

-                $comment_author_url = $pagelinkedfrom;

+                $select_tail = "?b=".substr(strip_tags($excerpt,0,12))."&e=#select";
+                $comment_author_url = $pagelinkedfrom.$select_tail;

If this breaks your trackbacksv you should probably change the (remarkably kludgy) selector, to something more like

if( parse_url($pagelinkedto, PHP_URL_HOST) != "trilema.com" )

This doesn't work perfectly, because intervening mark-up can well fuck it up ; but at least it gives the user something to work with in any case. I know I for one much prefer in-depth trackbacks to title-only trackbacks.

———
  1. Check that cool as fuck shit out, by the way!

    SWAG! []

  2. mp_en_viaje: the point is this : if someone says something, and then links you, odds are he's saying something like "this guy also confirms".
    mp_en_viaje: trackbacks offer you some measure of control over this "being drafted to vouch for others' idiocy" process ; because you can go check ; and if need be say "motherfucker, that's not what i'm saying at fucking all"
    mp_en_viaje: trackbacks also offer another important function : if we believe that human intelligence principally manifests in the creation of tools ; and if we believe human expression is not orthogonal to intelligence, then we thereby also believe our expression is in part tool.
    mp_en_viaje: the one most fascinating property of tools is their being the one bridge available between reals and ideals : theyr'e real objects with an ideal component! therefore, we theoretically predict the sluttery immanent to reality permits perversion, and phenomenology confirms : tools can in fact be used for purposes other than they were intended to!
    mp_en_viaje: don't you wanna see what crazy batshit unexpected but perhaps kinda cool use some other maniac put your own tools to ?

    The importance of proper bidirectional links, as opposed to the braindamaged unidirectional links implemented in the swamp of morons can not be overstsated. []

  3. I'm in Minsk, nights come at a strange time here. []
  4. Generally this is found in domain/www or domain public_html or such. []
  5. Verified by getting
    Is there no link back to us ?

    in response to a call like

    curl -A "Mozilla/5.0" -r 0-4096 --connect-timeout 30 --max-time 10 "http://trilema.com/xmlrpc.php" --header "Content-Type: text/xml" --data "<?xmlversion="1.0"?><methodCall><methodName>pingback.ping</methodName><params><param><value><string>http://trilema.com/2019/odd-comments-and-strange-doings-in-unix/</string></value></param><param><value><string>http://trilema.com/2016/a-complete-theory-of-politics/?b=The%20alpha&e=The%20female#select</string></value></param></params></methodCall>"

    []

Category: Meta psihoza
Comments feed : RSS 2.0. Leave your own comment below, or send a trackback.

15 Responses

  1. Where is the anchor?
    These don't seem to scroll to position when loaded.

  2. This method unfortunately does not mix well with links. For exampe in http://trilema.com/2019/thelastpsychiatristcom-advancing-paternal-age-and-bipolar-disorder-adnotated/#comment-130025 the link is http://trilema.com/2019/christos-ballas-tlp-thelastpsychiatristcom-archive/?b=Advan&e=#select and on click it scrolls you to place but the title link is ruined. If you look at the source,

    li><a href="http://trilema.com/2019/thelastpsychiatristcom-advancing-paternal-age-and-bipolar-disorder-adnotated/"><span style="background-color:#d3d3d3"><a name=select></a>Advancing Paternal Age And Bipolar Disorder</a

    The anchor name tag closer closes the link anchor, because anchors can not be nested. You could maybe alter the code so it piggybacks on an open a tag if present, but that will still not permit scrolling to anything but the opening of that a tag (span will still work midway though).

  3. Anchors nesting are not the only problem part with anchors, look at http://trilema.com/2019/proper-html-linking-the-crisis-the-solution-the-resolution-conclusion/?b=one&e=off#select

    it <a href=http://trilema.com/republican-thesaurus/?b=manal<span style="background-color:#d3d3d3"><a name=select></a>one&e=y#select>separates you</a><sup><a href="#footnote_0_85471" id="identifier_0_85471"

    It found the "one" in trilema.com/republican-thesaurus/?b=manalone&e=y#select and tagged that, breaking it.

  4. Not a single one of the new-type links seems to work ? (Is the thing switched off just now for debug?)

  5. Mircea Popescu`s avatar
    5
    Mircea Popescu 
    Saturday, 20 July 2019

    @Stanislav Datskovskiy This is pretty fucking bizarre... do the page sources show the <a anchor ?

    O holy shit, it WAS restricted to my local network. So everyone was "nfi what he's on about" because looking from here. Sorry about that.

    @Anon #1 This is true, but in the end anchors are supposed to be points, not fields. It's mildly annoying a selection can never include a link, but I see no way around it currently so I guess will have to live with it.

    @Anon #2 This strikes me rather like operator error. Could just add a character to the delimiters and not have the problem at all.

  6. @Anon #1 Browsers will alternatively scroll to any element with an id matching what is specified after the # in the url. Instead of including an empty <a name="selection"></a> tag you could add a unique id to the <span>. This gets around the issue with selections within links.

  7. Mircea Popescu`s avatar
    7
    Mircea Popescu 
    Saturday, 20 July 2019

    As per the standard, span's not supposed to have a name.

  8. It can have an id though. <span id="selection"></span> will work the same way as <a name="selection">

  9. Mircea Popescu`s avatar
    9
    Mircea Popescu 
    Saturday, 20 July 2019

    This is an interesting point, Ima check it out.

  10. Mircea Popescu`s avatar
    10
    Mircea Popescu 
    Saturday, 20 July 2019

    Indeed the span id approach proposed by billymg seems to work ok (as in, worked on all the browsers I tried). I've updated the article accordingly, tyvm billy!

  11. np, glad it worked!

  12. Mircea Popescu`s avatar
    12
    Mircea Popescu 
    Sunday, 21 July 2019

    Fucking beautiful, this works now, Trilema trackbacks just gained a great win!

  13. Mircea Popescu`s avatar
    13
    Mircea Popescu 
    Sunday, 21 July 2019

    Incidentally, this new selection mechanism is bringing into my life a very keen new awareness of the importance of tags for text!

    Consider http://trilema.com/2017/is-it-still-rape-if-i-write-science-on-my-penis-first/?b=the%20entire&e=up.#select : it's not practical to select just the bolded part ; but as it happens, it's very useful to select the following part. So this means that for once (and unawaredly) I actually put the border for bolding in just the right spot.

    Did it ever occur to you before there's right and wrong places to bold/italicize ? I mean specifically, not vaguely & generally, "I know it when I see it"-ly. Verbalizably, here but not there for this reason not that reason. Hm ?

  1. [...] b/strong, blockquote, ol, ul, li, table, img, code, pre tags + footnotes. ...span field as per url selection. ...article footer, including category/tag. ...responses, boxed individually, comments first, [...]

  2. [...] have added the selection logic change from Trilema to this website. If you see any strange, please let me [...]

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.