#dev 2019-03-15

2019-03-15 UTC
iasai and KartikPrabhu joined the channel
#
GWG
[eddie]: What are you looking to do to contexts exactly?
iasai and [grantcodes] joined the channel
#
[grantcodes]
Front end is pretty dodgy but post type testing tool is working now, can selectively publish posts and it will test if your html rendering is missing any mf2 properties
eli_oat, gRegorLove and iasai joined the channel
#
@kheeleesi
haruuuy kasakit sko pus-on, pang tuk-on lage nako ang mga microsub na mgsamok2 nko rn
(twitter.com/_/status/1106370954857373696)
iasai and [tantek] joined the channel
#
[tantek]
microsub wat
iasai, zaius and snarfed joined the channel
#
GWG
Looking at this post type tests.. one of the tests involves comments. Does someone post comments using Micropub?
[tantek] joined the channel
#
[tantek]
pretty sure aaronpk does
#
GWG
If the post created contains a comment property, what am I expected to do with it?
#
GWG
This is as part of an h-entry post
#
GWG
[tantek]: how would you add issue to post type discovery?
#
[tantek]
what is post type discovery
#
Loqi
Post Type Discovery specifies an algorithm for consuming code to determine the type of a post by its content properties and their values rather than an explicit “post type” property, thus better matched to modern post creation UIs that allow combining text, media, etc in a variety of ways without burdening users with any notion of what kind of post they are creating https://indieweb.org/post-type-discovery
#
[tantek]
I need to update that a bit but it has a github issues link
#
[tantek]
GWG what comment property? where are you seeing this
#
GWG
[grantcodes] new post type test app https://post-type-tests.herokuapp.com/
#
GWG
One of the tests is article with comments
#
GWG
I probably should ask [grantcodes].
#
GWG
I just didn't know anyone was doing that
iasai, snarfed, cweiske, barpthewire, KartikPrabhu and [jgmac1106] joined the channel
#
@jgmac1106
@dogtrax https://mastodon.social/@dogtrax/101753951038475801 beautiful #smallpoems I don't know if I wrote three poems or one poem connected by webmentions. I will go ask the owl (https://quickthoughts.jgregorymcverry.com/s/111IXt)
(twitter.com/_/status/1106493276964700160)
#
@jgmac1106
@dogtrax https://mastodon.social/@dogtrax/101753951038475801 beautiful #smallpoems I don't know if I wrote three poems or one poem connected by webmentions. I will go ask the owl (https://quickthoughts.jgregorymcverry.com/s/a56ks)
(twitter.com/_/status/1106493423098437632)
[kevinmarks] and iasai joined the channel
#
[jgmac1106]
!tell [aaronpk] would it be easy to fork https://github.com/aaronpk/IndieNews and change the syndication topic for another group?
#
Loqi
Ok, I'll tell them that when I see them next
#
Loqi
[aaronpk] IndieNews: 📰 News aggregator for IndieWeb-related posts
iasai, [Rose] and [grantcodes] joined the channel
#
[grantcodes]
GWG: I would doubt anyone actually posts content with comments already included. That's really more useful on the other site that shows how to markup comments in HTML. I'm using the same data source for both
#
GWG
[grantcodes]: I was wondering about that
#
GWG
Also wondering if anyone posted pure invite posts
#
GWG
I gave it a test and it did point out I'm not currently supporting quotation posts
#
jeremycherfas
I could use some PHP help if anyone is able.
iasai joined the channel
#
jeremycherfas
My problem is that I want to create a folder with a unique name, based on a date. But there could be more than one folder needed for the same date. I thought of adding hour, but it is possible there will be overlap there too.
#
jeremycherfas
This gist contains a version that adds a second folder if the first exists. https://gist.github.com/jeremycherfas/2df9dea2c5c900901e8389bbd8299453
#
jeremycherfas
But I would like it to be robust enough to cope with the second folder already existing.
#
jeremycherfas
There will never be more than 9 possible folders for a day, so I thought of adding a suffix to the slug. But I can't see a way to use either a do while loop or a straight while loop to check that the folder does not already exist. And I can't see how to loop back within the existing if block.
#
jeremycherfas
Any pointers gratefully received.
#
jeremycherfas
Or else, I could just extend the slug (which is yyyy-mm-dd) to include -H:i) but that seems like overkill for the slug for a url.
[pfefferle] joined the channel
#
[Rose]
I personally used yyyymmddhhi as my slugs
#
[Rose]
I think this is an excellent case for recursion
#
jeremycherfas
OK. Let me try that
#
[Rose]
I'm sending you my sample code via private message on Slack
#
[Rose]
function create_folder($path, $slug, $counter = 0)
#
[Rose]
$folderPath = $path . $slug;
#
[Rose]
if ($counter) {
#
[Rose]
$folderPath .= '-' . $counter;
#
[Rose]
if (!file_exists($folderPath)) { // Check folder with slug does not exist
#
[Rose]
mkdir($folderPath); //Creates the folder
#
[Rose]
return;
#
[Rose]
create_folder($path, $slug, $counter++);
#
[Rose]
And here too, because I messed up the formatting 😄
#
[Rose]
When you first call the function you don't need to provide a value for counter, what you probably want to do though is return folderPath so you know what the folder is called
#
[Rose]
I accidentally took that out, but I'm sure you can manage to put it back 😉
iasai joined the channel
#
jeremycherfas
Thanks [Rose] Studying that now. I see that I completely forgot that `return` exists. :)
#
[grantcodes]
GWG: That's cool that it's already useful! Again I doubt there are many micropub clients that will post `quote-of`. But never hurts to be prepared!
#
[Rose]
I should note, that code is not my best work, but it's a short example for you 😉
#
[grantcodes]
Definitely need to get more examples in there though
#
GWG
[grantcodes]: I added it to my post type discovery function, until someone wants to post one, I might not write a display template
#
GWG
If someone tried to post one, it would work, but use the generic template, which might work or not
#
GWG
Like, bookmark, etc all use the same layout right now
#
jeremycherfas
I should shamefacedly confess that in my previous effort I managed to create 129,545 folders by getting the existence check wrong.
#
Loqi
I agree
#
cweiske
you aren't a real programmer if you never crashed your computer by just setting a ; at the wrong place
#
jeremycherfas
Yes! In that case, I am a real programmer many times over.
#
[Rose]
Congratulations 😄
iasai joined the channel
#
@jgmac1106
↩️ #openbadges I couldn't agree more. I added my resume to my website https://jgregorymcverry.com/resume.html and then a page to display my webmention badges https://quickthoughts.jgregorymcverry.com/pages/badges Instead of eliminating the vita I want to think about connecting the two and… https://quickthoughts.jgregorymcverry.com/2019/03/15/dominicorr-openbadges-i-couldnt-agree-more-i
(twitter.com/_/status/1106543547841425408)
[jgmac1106] joined the channel
#
jeremycherfas
[Rose] I get an error Allowed memory size of 134217728 bytes exhausted (tried to allocate 262144 bytes when it creates the folder second time around.
#
jeremycherfas
I'm wondering whether incrementing the counter in the internal function call does something weird.
#
Zegnat
That sounds more like you got into a loop that took too long
#
Zegnat
As in, your code kept running and running and running (needing more memory at every step) and thus PHP dropped it
#
jeremycherfas
Is there anything in PHP that will pause and wait for input? As opposed to die;
#
Zegnat
Hmm. Not in a useful way
#
Zegnat
Was your code still on gist?
#
Zegnat
realises he is late to the code party
#
jeremycherfas
No, I deleted it. I can put it back.
#
jeremycherfas
I think I understand the logic. The first if should fail, because counter is 0 (false?)
#
Zegnat
Having a look now
#
jeremycherfas
The second time, counter is 1 and so true and so it proceeds to the second IF and makes the directory.
#
jeremycherfas
UNLESS when it first sets $folderPath, that should include Counter. Because every time it comes back in, it resets $folderpath without accounting for counter?
#
[jgmac1106]
so I have a WordPress theory I want to test...the mf2 plugin never really worked because of older microformats...since editing a theme is hard can I search through my WP files and delete any old mf2 properties and then use the mf2 plugin?
eli_oat joined the channel
#
jeremycherfas
No, that's not right because it creates a new folderPath in the first IF
#
Zegnat
If the counter is any number not 0 it gets added to the folder name. So when a directory already exists it ups the counter by one and runs the function again.
#
Zegnat
This seems right
#
jeremycherfas
That's what I thought.
#
sknebel
(although I'd ask why a recursive call and not a loop?)
#
sknebel
(especially since you're not passing through the result from the nested call)
#
jeremycherfas
Because I couldn't figure out a while loop, and [Rose] thought recursion would be OK.
#
jeremycherfas
In other words, I'm too dumb to build a loop, and [Rose] was being helpful.
#
Zegnat
The recursion shouldn't lead to memory issues. I think. Though maybe?
#
sknebel
technically it uses a bit more memory, but if it isn't thousands of levels not relevant
#
sknebel
anyways, then you need a "return" to pass the result of your recursive call up
#
jeremycherfas
I'd use a goto except I don't want T. Rex trampling on me.
#
Zegnat
Ah. Hmm. Why is there no return in front of create_folder on line 12
eli_oat1 and iasai joined the channel
#
jeremycherfas
I don't know. There is one inside the previous IF. Would it go outside that if?
#
sknebel
you need both, because in both places you want to return the path
#
jeremycherfas
Ah. Let me see if that works. Thanks.
#
jeremycherfas
Yeah, but now it never creates an additional folder with the counter added on.
#
jeremycherfas
Still get the fatal memory error with that Sven
#
jeremycherfas
If I could do it without recursion I would prefer to, but I just don't see how to nest the if statements.
#
sknebel
that problem might very well be something else, the return was just something I noticed about the code
#
sknebel
(and I have to excuse myself now, moving tomorrow and still soo many boxes to pack...)
#
jeremycherfas
Thanks for help so far, and good luck with the move
#
jeremycherfas
I think I will revert to making slug more unique.
[Rose] joined the channel
#
[Rose]
That's probably the easiest.
#
Zegnat
And I am back from a meeting, haha
#
Zegnat
Let me take another look
#
Zegnat
This can definitely be done without the recursion. What is it you want the function to result in?
#
Zegnat
(All these dumb meeting are cutting into my idle indieweb time)
[ken] joined the channel
#
Zegnat
Is create_folder() a grav thing or a function you call yourself? I think I may need some context.
#
[Rose]
It's his function, as far as I know Grav directly uses mkdir
#
jeremycherfas
It is a function I call myself. I'm extending slug now to include hours and minutes, and my problem now is that date_parse_from_format does not seem to give me leading zeroes.
#
Zegnat
So when you call it, what do you expect it to do, jeremycherfas?
#
Zegnat
If you give me the wordy-spec, I can have a look at explaining the codey-hows ;)
#
[Rose]
How about date('yyyy-mm-dd-hh-i', strftime($dateToParse); ?
#
jeremycherfas
I pass it the path and the slug. If there is no folder at path.slug, create one. If there is a folder at parth.slug, create a folder at path.slug.suffix
#
[Rose]
Missing brackets and incorrect functions because I'm on a Tram
#
jeremycherfas
But I do think that the better answer is to ensure that slug is unique.
#
jeremycherfas
That could be a better approach [Rose]
[kevinmarks] joined the channel
#
[kevinmarks]
oops, I used '+' insted of '.'
#
jeremycherfas
Thanks [kevinmarks] I don't understand line 3
#
[kevinmarks]
it sets up $basepath and makes $folderpath equal to it initially
#
[kevinmarks]
equivalent to $basePath = $path . $slug; $folderPath = $basePath;
#
jeremycherfas
Right. I thought that might be it, remembering about assignment from right to left.
#
jeremycherfas
Get an error with `$counter++;`
snarfed joined the channel
#
jeremycherfas
S'ok. Found it
#
jeremycherfas
Thank you very much [kevinmarks]++
#
Loqi
[kevinmarks] has 13 karma in this channel over the last year (38 in all channels)
#
jeremycherfas
That gives me a manageable slug and uniqueness. And teaches me about testing in a While loop.
#
[kevinmarks]
you can think of a while() as an if() that keeps trying
#
Zegnat
should stop offering help when he gets interupted every 5 minutes because work
#
jeremycherfas
I got confused by the difference between do while and straight while
#
[kevinmarks]
whiel is like an if - it tests first
#
[kevinmarks]
do{} while() does it once then tests to see if it is done
#
jeremycherfas
Right, And I was tying myself in knots trying to increment the counter in the wrong place.
#
[kevinmarks]
you could do it with a for loop but it would be less clear
#
[kevinmarks]
all 3 are clearer versions of if() goto combinations for common cases
#
[kevinmarks]
I think a while() is clearer
iasai and [eddie] joined the channel
#
[eddie]
Uh oh! AutoAuth shout out from Dries. Better change the name soon if we don’t want it to stick as it gets out there!
eli_oat1 joined the channel
#
[kevinmarks]
I'm wary of auth as it conflates identity and permission
#
Zegnat
Hmm. Maybe we should invite Dries to the Utrecht IWC
#
Zegnat
Yeah, temporary names are dangerous as they may end up sticking :(
[pfefferle] joined the channel
#
Zegnat
Better names are welcome, just add suggestions to /AutoAuth
iasai joined the channel
#
[eddie]
I actually like it okay, but I'm not a picky person when it comes to naming 🙂
#
[eddie]
Yeah, I definitely think so! He's been excited about multiple IndieWeb things recently
#
Zegnat
Yeay, reading for my commute! :D
iasai joined the channel
#
Zegnat
[kevinmarks]: interesting! I hadnt read that post before but we came to the same conclusion in our discussions, it should be fine to add WWW-Authenticate to 2xx responses.
#
Zegnat
So that's what we ended up doing.
[tantek] joined the channel
#
[kevinmarks]
I saw, yes. Tim Bray's post there is interesting too.
[Zegnat] joined the channel
#
[Zegnat]
I think 2 legged already has a specific meaning though. So that doesn’t feel like something we could use
iasai joined the channel
#
Zegnat
2 legged in OAuth 2.0 would be something like https://tools.ietf.org/html/rfc6749#section-4.4 - autoauth is not like that in any way
#
[eddie]
RemoteId?
#
[eddie]
lol probably already used for something
#
[kevinmarks]
I think 2 legged vs 3 legged are terrible names too
#
jeremycherfas
I need to learn a LOT more about error checking.
#
jeremycherfas
And, maybe, sorting array elements.
[jgmac1106], iasai, snarfed, KartikPrabhu, KidReese777, RenoG, Reno__ and gRegorLove joined the channel
#
gRegorLove
jgmac1106, I've gotten a bit more familiar with Weebly. Adding mf2 wouldn't be too difficult, though we're using a customized theme so I'm not in a place to set up/distribute an mf2 theme.
#
Loqi
gRegorLove: aaronpk left you a message 4 days, 16 hours ago: looks like indiebookclub has already been registered for indielogin.com!
#
gRegorLove
I mean, I could set one up, but I wouldn't be using it myself / not too interested in maintaining it.
#
gRegorLove
I'll assist if someone wants to take that on though.
iasai, ben_thatmustbeme, [tantek], [ken] and [jgmac1106] joined the channel
#
[jgmac1106]
yeah same here, good to know for back burner, if someone asks we can work with them
[eddie], snarfed, [kimberlyhirsh], iasai, [kevinmarks], [tantek], [grantcodes], [jackjamieson] and KartikPrabhu joined the channel