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 one&e=y#select>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.

41 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 ?

  14. The

    $select_tail = ...

    line gets cut off in my browser. Also the the parens need to be rearranged

    substr(strip_tags($excerpt,0,12)) --> substr(strip_tags($excerpt),0,12)

    In my xmlrpc I made a few changes to try to increase my chance to get b&e values that select the excerpt. I first replace all " "s with "+"s in $excerpt, and I set the e value to the last 4 characters in the $excerpt

    $naked_excerpt = str_replace(" ", "+", strip_tags($excerpt));

    $select_tail = "?b=".substr($naked_excerpt, 0,
    4)."&e=".substr($naked_excerpt, -4)."#select";

    $comment_author_url = $pagelinkedfrom.$select_tail;

  15. Mircea Popescu`s avatar
    15
    Mircea Popescu 
    Saturday, 2 November 2019

    Basically urlencode for the whitespace between words. I dunno this does anything, for instance http://trilema.com/2019/proper-html-linking-the-crisis-the-solution-the-resolution-conclusion/?b=So%20here&e=spent#select works just as well as http://trilema.com/2019/proper-html-linking-the-crisis-the-solution-the-resolution-conclusion/?b=So+here&e=spent#select as proven by

    $ curl "http://trilema.com/2019/proper-html-linking-the-crisis-the-solution-the-resolution-conclusion/?b=So here&e=spent#select" | grep "span style"
    % Total % Received % Xferd Average Speed Time Time Time Current
    Dload Upload Total Spent Left Speed
    0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0<p><span style="background-color:#d3d3d3" id="select">So here I spent untold months in aspie heaven, [...]

  16. In the browser's I've tried your generated links are not url encoding the whitespaces with + or %20, they are just omitting them. For example the pingback for diana_coman's "How my blog moved.." puts b=andt instead of b=and%20t in the url, and thus nothing is selected when I follow the link.

  17. Mircea Popescu`s avatar
    17
    Mircea Popescu 
    Saturday, 2 November 2019

    Which browser is it ?

  18. Chrome 66.0.3359.181
    Firefox 70.0.1
    Safari Version 7.0.6

  19. Fwiw: a quick check shows Firefox 52.8 handles spaces & + just fine, doesn't require %20

  20. I do not think it is a browser issue. The browsers will turn spaces into %20's

    The links on trilema being displayed for the comments made via pingback already have their spaces stripped.

    curl http://trilema.com/2019/proper-html-linking-the-crisis-the-solution-the-resolution-conclusion/#comment-132065 | grep "andt"

    ^^ the b value should be some variation of "and t" for "...and the..." instead of "andt"

  21. Mircea Popescu`s avatar
    21
    Mircea Popescu 
    Saturday, 2 November 2019

    @whaack I don't understand what you're saying here.

    Yes some browsers urlencode ; but curl does not.

    What's the "andt" stuff ?

  22. @Mircea Popescu

    Diana_Coman sent a pingback to _this_ post from her post titled How My Blog Moved North (to the USA)

    The excerpt that the pingback provided begins with

    "and the wasteful padding of single-post..."

    The code on trilema's server uses that excerpt to generate the b value for the pingback linkback. That code, for an unknown reason, is stripping the space between "and" and "the" and providing the b value

    b=andt

    the full link that it generates is:

    http://ossasepia.com/2019/10/20/how-my-blog-moved-north-to-the-usa/?b=andt&e=#select

  23. Mircea Popescu`s avatar
    23
    Mircea Popescu 
    Saturday, 2 November 2019

    Come to think about it, 4 leading character might also be too narrow.

    Also, I checked, and indeed the code does remove whitespace somehow. Nfi how or why atm, will have this looked into some.

  24. I'll roll this into a proper vpatch shortly, but for now a simple fix is to add the following line under the original fix to mlrpc.php:

    $comment_author_url = str_replace(' ', '%20', $comment_author_url);

    What was happening was that the data in '$comment_author_url' was being sent through the 'clean_url()' function in 'wp-includes/formatting.php', which stripped the spaces. This fix allows those spaces to get through unmolested.

  25. Mircea Popescu`s avatar
    25
    Mircea Popescu 
    Tuesday, 12 November 2019

    So what you actually mean is rather

    /xmlrpc.php
    - $comment_author_url = $pagelinkedfrom.$select_tail;
    + $comment_author_url = $pagelinkedfrom.rawurlencode($select_tail);

    Nice find, in any case!

  26. Mircea Popescu`s avatar
    26
    Mircea Popescu 
    Wednesday, 13 November 2019

    Keks & http://thewhet.net/2019/11/central-european-retrospective-frague/%3Fb%3DWhere's%20Frag%26e%3DWher%23select

    Let's try this once more :

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

    Two bugs in one!

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

  2. [...] and the wasteful padding of single-post pages, as well as a few further touches to .php to put in the server-side selection mechanism and tweak odd bits and pieces so it doesn't look *that* terrible. Hopefully there will be some [...]

  3. [...] there are other small things that you might wish to do, for example getting the proper selection mechanism in place4. Similarly, you can add Trilema-style random taglines to your header.php by first adding [...]

  4. [...] my broken understanding of proper html linking and then fix the consequences on my blog I have stemming from that broken [...]

  5. [...] There are two quirks I've noticed with the select displayer. [...]

  6. [...] or if they are downstream from a larger problem. The third gain was I discovered a small issue with "pingback linkbacks." The fourth gain was I perhaps uncovered a serious problem with my thinking process that caused me [...]

  7. [...] have spent the past few days pondering why I tried to create links conforming to the new the html selection method before investigating their proper format. The first reason I came up with was I had thought it best [...]

  8. [...] exists a bug in the pingback mechanism in mp-wp which strips spaces out of the selection portion of the source url. What this means is that if this article were to ping a target url,1 that target server would [...]

  9. [...] is recomended for now. [↩]At minimum the blog software should support comments, pingbacks, server side select a la MP-WP., and no SSL or javascript or captchas of anykind if. Really, you should probably just install [...]

  10. [...] 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, [...]

  11. [...] server-side selection code to base themes (if investigation to include this higher up the stack doesn't yield [...]

  12. [...] Isn't it great how the proper selection mechanism also works as in-place adnotation ? Something like "from the article titled An Examination Of [...]

  13. [...] This is the third iteration after the first two discussions. This patch also now contains the server-side select mechanism, including the updates to xmlrpc.php. The functionality is included in what is now the MP-WP [...]

  14. [...] first two discussions. This patch also now contains the server-side select mechanism, including the updates to xmlrpc.php. The functionality is included in what is now the MP-WP Content Processing plugin1 so it will work [...]

  15. [...] This would be one of the simplest, yet most helpful, yet non-obvious changes you can make to a new installation of MP's WordPress, right up there with separating pingbacks from direct comments and chapter-and-verse linking. [...]

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.