#dev 2017-09-03

2017-09-03 UTC
#
bear
this is confusing the hell out of me
eli_oat, snarfed1, snarfed and KartikPrabhu joined the channel
#
bear
the result is a 302 but with what looks like a relative url of /page/2dcbSEKTnlZahlLF3yIY
#
bear
ok, I must not be seeing something... the target url of https://webmention.rocks/test/23/page has a 302 response and the Location header is "page/2dcbSEKTnlZahlLF3yIY"
#
Loqi
[Webmention Rocks!] Discovery Test #23
#
bear
that's tell me that the new target url should be https://webmention.rocks/page/2dcbSEKTnlZahlLF3yIY but that is returning a 404
#
aaronpk
Ah that's the problem
#
aaronpk
the redirect does not begin with /
#
aaronpk
so resolving that URL should give /test/23/page/2dcb...
#
bear
where do you get /test/23 at from all of this
#
aaronpk
The target URL that redirects
#
bear
which is "https://webmention.rocks/test/23/page"
#
Loqi
[Webmention Rocks!] Discovery Test #23
#
aaronpk
Visit that in a browser and watch it redirect
#
bear
I try to avoid browsers you should know that :/
#
aaronpk
Loqi figured it out
#
aaronpk
Correct
#
jjuran
Last I checked, it’s illegal for a Location not to be an entire URL.
#
aaronpk
jjuran: maybe in the spec, but in practice it happens all the time and browsers deal with it just fine too
#
aaronpk
So arguably the http spec should be updated based on the actual deployed code
#
aaronpk
Well there you have it
#
bear
i'm just having trouble seeing how I craft a url from "page/####" in the Location header when the netloc is webmention.rocks/
#
aaronpk
It's the same as relative URL resolution of embedded images and CSS files in HTML pages
#
aaronpk
it's relative to the rightmost folder
#
bear
the url parsing tool in python returns ParseResult(scheme='https', netloc='webmention.rocks', path='/test/23/page', params='', query='', fragment='')
#
aaronpk
Is there a function for relative URL resolving?
#
KartikPrabhu
from urlparse lib
#
bear
sheesh - this test hates me and my command-line self
#
bear
i'm getting this now:
#
bear
404 Not Found
#
Loqi
[Webmention Rocks!] Discovery Test #23
#
Loqi
[Mike Taylor] Checking Indieweb Code
#
bear
thanks KartikPrabhu for the pointer to urljoin - I never realized it does relative, I've always just crafted urls manually
#
aaronpk
I see "410 Gone" on that last URL
#
bear
hrmm, what can I be doing wrong now ...
#
bear
am I getting two different dynamic pages because of how I process things?
#
bear
yea, I think i'm getting two different redirects :/
tantek joined the channel
#
aaronpk
oh i think each time you hit the "page" one it makes a new redirect
#
bear
yea, my library does a endpoint lookup as needed - it doesn't cache them
#
aaronpk
i don't think you need to cache it to only fetch it once
#
bear
sorry - bad use of "cache"
#
bear
I make a call to discoverEndpoint() to get what the webmention url should be as part of test prep
#
bear
and then the sendMention() code is now also doing that
#
bear
so each time I reference /23/page it's storing a new set of random strings from my IP address?
#
aaronpk
doesn't that mean you're fetching a target URL twice when you really only need to fetch it once?
#
bear
well, I have to do a request for it to make sure it's valid
#
bear
and then to discover the endpoint
#
bear
but this is all for a test on my side to test against webmention.rocks
#
bear
I might just put this new code onto my site and see how it works
#
bear
or hack a flag into my test code
#
bear
yep, that was it
#
bear
I'm not going to change how discoverEndpoint and sendWebmention work as they are working for me right now - so I just added a bit of debug code to discoverEndpoint to have it return the target url redirect
#
bear
fsck'ing hell - still failing
#
bear
the redirected target gives me a 410 response now
#
bear
takes a brain break
tantek, tantek_, gRegorLove, KartikPrabhu, jeremycherfas and [kevinmarks] joined the channel
#
[kevinmarks]
The "what fake username for my domain" problem reminds me of the himself@neilgaiman.com email address.
#
[kevinmarks]
The other precedent is @me in opensocial etc so me@domain.com
#
Zegnat
jeremycherfas if you are looking into PHP HTTP clients, may I nudge you a little towards http://httplug.io/ ? They have created a fixed interface for doing HTTP requests, and you can swap out the backend (Guzzle, or just cURL, or any other lib) without having to change your own code.
#
jeremycherfas
Youb may! I will take a look now.
#
Loqi
jeremycherfas: Zegnat left you a message 17 hours, 2 minutes ago: know me, I am always happy to talk you through something
#
Zegnat
It can still be a little hard to wrap your head around. But the basic is: create a Request object that matches with PSR7 (the PHP standard), send it off through any HTTPlug supporting library, and get a Response object (again PSR7) back.
#
Zegnat
It simply abstracts a lot so you can independently swap libraries around to find the one that’s best for you.
#
jeremycherfas
I don’t really understand that. Currently not using any libraries at all.
#
jeremycherfas
But of course I could.
#
jeremycherfas
Right now, I want to understand authentication.
#
jeremycherfas
The Known API examples all use user name and endpoint to create a “password”.
#
jeremycherfas
Or I can use gimme-a-token, I think.
#
Zegnat
rechecks gimme-a-token
#
jeremycherfas
But I don’t understand what gimme wants under client_id
#
Zegnat
client_id is a URL that identifies the software that is using the token
#
Zegnat
E.g. if Twitter was requesting a token so they could post to your site, they would put https://twitter.com as client_id
#
jeremycherfas
So if I am currently working in localhost:8888/RSS-thing/index.php — is that the client_id?
#
Zegnat
Sure. Or just https://www.jeremycherfas.net. You don’t really care, you are going to accept it anyway because you know it is you making the request
#
Loqi
Jeremy Cherfas
#
Zegnat
client_id is there so you, when granting a token to someone, can see who is requesting the token. It isn’t used for anything else in IndieAuth
#
jeremycherfas
See, that blows my mind. I can put anything in there, because when it sends me to the Known page to authroise, I am going to authroise it, whatever.
#
Zegnat
Your software needs to “remember” it though, because you need to send the same client_id on the verification or token retrieval step. But that just needs to match the first one, so you can still use whatever.
#
Zegnat
Although it MUST be a URL if I remember correctly. So not just a name or string.
#
Zegnat
( Selfauth will throw an error if it isn’t a valid URL. I don’t know about Known, but best to stick to the rules either way :) )
#
jeremycherfas
I just wonder whether that is for some reason preferable to calculating the known-username and known-signature from scratch each time the app runs.
#
jeremycherfas
Just making a gist to show what I mean.
#
Zegnat
I guess it depends on what the Known API can offer you. If you go through Micropub your little application will be able to post to everything that supports Micropub and not just Known.
#
Zegnat
That’s what I would base the decision on. If you don’t need Known specific things that are only in their API, maybe go with implementing the W3 Micropub standard to open up many future uses :)
#
jeremycherfas
Well, that’s my other question I’m not sure I understand. I’ve been thinking only about posting bookmarks to KNown. And doing that directly by POSTing to Known’s endpoint.
#
jeremycherfas
But is there a way I can post to, say, Quill and then have Quill post to Known?
#
Zegnat
Hmm, no, I don’t think Quill has any endpoint you can send to. You could write code that emulates a user logging into Quill and submitting through Quill, but that feels like overkill.
#
Zegnat
Especially because Quill is just going to do the Micropub POST then. Better to do the Micropub POST yoursel
#
jeremycherfas
Thank you. That is very helpful and stops me thinking there might be an easier way. :)
#
jeremycherfas
As for opening up fully, I’d like to get this thing working very specifically, and then see.
#
jeremycherfas
So for now I will make it Known only.
#
Zegnat
Interesting how that GitHub code you linked defines a cookiejar. I wouldn’t expect the Known API to require state that way
#
Loqi
[Marcus Povey] Using the Known API
#
jeremycherfas
That little bit of code does calculate the values I need. Now to see whether they work.
#
Zegnat
I read that blogpost, it seems pretty clear on the steps you need to take to connect with the API.
#
Zegnat
I just don’t understand why you would need a cookie if you are also sending authentication headers with your requests. Those headers should cover access. But me being confused has no effect on you getting the API to work ;)
#
jeremycherfas
Yes, and I am slowly getting there. For a while I was scared bout calculating the signature each time I run the program, but I now think that’s the easiest.
jeremycherfas, snarfed and r11 joined the channel
#
jeremycherfas
To get everything after a regex match, to the end of the string, do I have to use a lookahead? Or is there some simpler method to get everything after the match to the end of the string?
#
Zegnat
End your regex with .*$ ( . = anything, * = any amount, $ = end of string )
#
Zegnat
If by “get” you mean you need to capture it, just use (.*)
#
jeremycherfas
Aha! Thanks. Now I can use capture group 2 as my replace.
#
Zegnat
Yes, if you are removing things with regex, you can make an entire capture group your replacement, or you can replace a selection with an empty string for it to be removed
[kevinmarks] and snarfed joined the channel
#
jeremycherfas
Is preg_replace() the right function though? I’m having terrible difficulty with it.
#
jeremycherfas
Apparently does nothing.
#
jeremycherfas
But I know the Regex works, and I thought $2 would be the bit that I want.
#
Zegnat
You are going to need some start and end markers on that regex. Most people use /:
#
sknebel
also have to escape the backslashes I think
#
jeremycherfas
I thought the markers were the ^ inside the parentheses
#
Zegnat
No, those backslashes are there to escape the / within a regex that uses / as start and end markers, sknebel.
#
jeremycherfas
Well, that works, and once again I am indebted to you, zegnat
#
Zegnat
jeremycherfas ^ and $ are symbols for the start and end of the string you are matching against. But regex sometimes expects its own “this is where the expression starts” symbol
#
jeremycherfas
Zegnat++ for being amazingly willing to help
#
Loqi
zegnat has 29 karma in this channel (131 overall)
#
jeremycherfas
Man this stuff is hard.
#
Zegnat
Ie. /EXPRESSION/FLAGS . Regex will use the very first symbol (here a /) to split between the expression part and the flags part.
#
Zegnat
I sometimes like to use @ instead, because that way I don’t need to put backslashes on the normal slashes: e.g. @(^.+?/p/[^/]+/)(.*)@
#
sknebel
Zegnat: oh, ok, I thought you needed additional escaping to get the \ into the string literal
#
Zegnat
To do what you are doing now, jeremycherfas, without the need for escaping slashes or capturing groups:
#
jeremycherfas
I’m taking that over to the explainer
#
sknebel
Zegnat: thx
#
sknebel
Seen examples with it, but it isn't necessary. good to know
#
jeremycherfas
OK, so you have simplified the first match, and just left the replace blank.
#
Zegnat
jeremycherfas: regex101.com (and many others) will force / delimiters, and thus require the backslash escapes. You can, on regex101.com, click on the grey / at the start of the input to switch it to an @
tantek and [miklb] joined the channel
#
[miklb]
me reads back scroll, breaks out in hives
snarfed joined the channel
#
jeremycherfas
Acutally zegnat, I’ve just realised that the main link in those bhookmarks is to the clean link, only the little icon goes to reading.am The actual title goes to the clean link. So, maybe no need to even clean it up further.
snarfed joined the channel
#
Zegnat
Oh, interesting, jeremycherfas. I was more concerned with the parsed output: https://php.microformats.io/?url=http%3A%2F%2Fstream.jeremycherfas.net%2F2017%2F-danger-seeing-white-part-11
#
jeremycherfas
Oh, I see. So bookmark of is the reading link
#
jeremycherfas
Well, I’m happy enough at the moment. I’ll probably keep working at it.
#
Zegnat
Yes. The name property also doesn't make a lot of sense. So I'm feeling like the wrong content good to the wrong field
#
Zegnat
Launch early and iterate often, I like it ? haha
#
Loqi
rofl
#
jeremycherfas
I need to build a proper test suite, because at the moment I have to add a new bookmark to test things, because I don’t store the whole result I get from the RSS.
#
jeremycherfas
So need to build a tst suite that reads the xml from a file.
#
jeremycherfas
Interesting that the icon is different depending on where the bookmark came from (Quill vs known endpoint) and the star that quill puts in does not have a link.
#
jeremycherfas
Or maybe the star is Known and the fingers are from Reading. So much to figure out.
#
snarfed
tests++
#
Loqi
tests has 3 karma in this channel (12 overall)
#
jeremycherfas
Zegnat: I can’t think where that name property is coming from.
#
Zegnat
The u-bookmark-of and p-name are both on the element with the hand emoji, linking to the reading.am link
#
Zegnat
So it takes the hand emoji as name.
#
Zegnat
dinner time :)
[jeremycherfas] joined the channel
#
[jeremycherfas]
And micro.blog takes the reading.am link. I guess my work is not quite done yet.
#
Zegnat
jeremycherfas, where does micro.blog take their input from? The RSS feed from stream.jeremycherfas.net?
[manton] joined the channel
#
[manton]
Let me know if there's anything for me to look at with Micro.blog. I checked the feed and the behavior looks correct on first glance... It shows the title and adds a link to reading.am which is in the RSS item's <link>.
#
Zegnat
If that’s the feed he is feeding micro.blog, that makes sense :)
[kevinmarks], gRegorLove and snarfed joined the channel
#
loqi.me
edited /User:Kaja.sknebel.net (+47) "sknebel added "PM-alerts if specific user becomes available" to "See Also""
(view diff)
davidmead, snarfed, EmreSokullu, KartikPrabhu, tbbrown and gRegorLove joined the channel
#
gRegorLove
Connections to graph.facebook.com are realllly slow from my site. I'm caching the profile photos for Bridgy backfeed and it keeps timing out.
#
gRegorLove
Even when I try using wget instead of php's copy()
#
gRegorLove
There's a 302 it follows, but it takes a long time just to respond to the initial request, then follow the redirect