The web in a box - a next generation web framework for the Perl programming language

IRC log for #mojo, 2017-10-22

| Channels | #mojo index | Today | | Search | Google Search | Plain-Text | summary

All times shown according to UTC.

Time Nick Message
00:55 sri this seems to actually work :o https://gist.github.com/anonymous/5b2af60a51943afb4944ed7f7d9c8b3c
00:55 genio tbh, Future is almost the same feel you get with Promises in JS
00:55 sri i think that covers promises/a+
00:55 sri 16 lines though
00:57 genio sri++  I like that
00:57 mohawk reject, resolve, then - what's not to like? :-)
00:57 mohawk sri++ # sterling work
00:59 sri i don't think anyone has ever combined a flow control library like step.js/async.js and promises
01:00 sri this could end up being amazing or stupid
01:01 mohawk can't it be both?
01:01 sri amazingly stupid?
01:01 mohawk or stupidly amazing
01:01 sri i suppose that's an option
01:04 aborazmeh joined #mojo
01:07 sri oh, one part is not promises/a+
01:07 sri the spec actually requires no invocant
01:07 mohawk ?
01:08 sri explicitly says the callbacks have to be called as functions without a "this"
01:08 sri little awkward
01:08 mohawk well
01:09 mohawk when you're being promise-y (then etc) then don't pass an invocant
01:09 mohawk but you might eg to "local $_ = $self" just before
01:09 mohawk s/ to//
01:10 genio That's, I guess, not that odd. But, I've gotten used to it in Mojo delays and would feel odd to me now
01:10 mohawk if you use it as a delay, then you have an invocant. if you use it as a thenable, you don't (except via sneaky $_)
01:12 sri i guess no invocant would be better for compatibility with other promise implementations
01:12 mohawk that's what i as a user would very very much like
01:52 jberger Sorry I am trying to read the scrollback but I'm really not available to vote on anything tonight. Don't deprecate anything without me
01:53 jberger Definitely don't pass delays around. I'm totally opposed to that
01:55 mohawk another important thing for me would be able to pass promises in and have them used as though delays - if that were a vaguely sensible thing to do, then it would suggest using delays by their "thenable" interface in case they were actually promises
02:24 noganex joined #mojo
03:50 jberger Ok now as I read to current. I hadn't gotten to where you were making delays composable
03:50 jberger I have to think about it, try it, but I'm not opposed to that. My opposition was agreeing earlier
03:52 jberger As to deprecating the Mojo::IOLoop->delay method, I'm opposed to that. I don't think it solves any problems and it would create tons of breakage
03:53 jberger You know I'm fine with breakage as long as we are solving some problem
04:04 dboehmer_ joined #mojo
06:13 Vandal joined #mojo
06:32 aborazmeh joined #mojo
07:21 hrupp joined #mojo
07:22 dod joined #mojo
07:29 dod joined #mojo
07:55 bjakubski joined #mojo
09:17 karjala_ joined #mojo
09:19 rshadow joined #mojo
09:22 batman adding delay() to Mojo::Util feels wrong to me. I’m also opposed to deprecating Mojo::IOLoop->delay
09:23 batman I’m fine with adding the extra promises methods
09:24 batman I’m not sure what the exported function will help with, except less typing... vim has line completion, so I don’t mind the extra keystrokes :)
09:26 batman s/keystrokes/characters/
09:51 sh14 joined #mojo
10:53 kes joined #mojo
11:21 sri hmm, my full implementation of promises does cost a little more lines
11:22 dotan_convos joined #mojo
11:22 sri https://gist.github.com/anonymous/7fb9eb394fc406da2ae26f6acd079583
11:22 sri ->race is very much optional though
11:22 sri and there is no ->all yet
11:24 sri and there's old delay behavior that will stay, like Mojo::IOLoop::Delay->new->reject('whatever') throwing an exception because there's no subscriber to the error event
11:24 sri i've also looked at the js promise spec, and there will be a few incompatibilities
11:25 sri https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise
11:25 sri they have Promise.resolve(...) as a class method to create new promises
11:26 sri and promise.catch(...) as a method that also creates a new promise
11:26 sri both would make things kinda awkward for a Perl-ish implementation imo
11:46 sri hmm, i'm starting to get annoyed
11:48 sri handling of then callback return values and exceptions is still missing
11:48 sri my motivation is kinda gone though, so i might give up now
11:52 good_news_everyon joined #mojo
11:52 good_news_everyon [mojo] kraih created promises (+1 new commit): https://git.io/vdNQ9
11:52 good_news_everyon mojo/promises 8e14c2d Sebastian Riedel: proof of concept for Promises/A+ in Mojolicious (Mojo::IOLoop::Delay::all is missing and there is no handling of return values from ->then callbacks or exceptions in ->then callbacks)
11:52 good_news_everyon left #mojo
11:52 sri yea, i'm out
11:52 sri if anyone else feels like promises should be in mojolicious, please finish the patch
11:54 petru joined #mojo
11:54 sri although, it seems only mohawk is currently interested in the proposal
12:06 sri well, opened an issue https://github.com/kraih/mojo/issues/1139
12:18 good_news_everyon joined #mojo
12:18 good_news_everyon [mojo] kraih pushed 1 new commit to promises: https://git.io/vdN7N
12:18 good_news_everyon mojo/promises 1554997 Sebastian Riedel: consistent tests
12:18 good_news_everyon left #mojo
13:18 ChmEarl joined #mojo
13:44 trone joined #mojo
14:07 aborazmeh joined #mojo
14:18 rshadow joined #mojo
14:50 mohawk sri, i'll be looking at that once i've done a bit of blogging about the graphql schema-file-reading capability, and then crowbarred promise-ish stuff into gql
14:50 mohawk thanks!
14:51 sri the ->then method needs a rewrite for return value and exception handling
14:52 mohawk roger
14:52 mohawk i'll commentate that on the issue unless you want to?
14:52 sri i've already mentioned it
14:52 mohawk superb
14:54 sri handling ->then callbacks that return promises give me a little bit of a headache
14:55 sri suppose that also requires a ->wrap method, with a ->can('then') check to see if the value is already a thenable
15:01 mohawk i'd hope to avoid a wrap
16:38 trone joined #mojo
16:42 rshadow joined #mojo
16:55 robx hi Folks. I'm still struggling to understand Mojolicious. My current project is to use it to replace a several private virtual host hierarchies currently served by Apache 1.3
16:56 robx Mostly the hierarchies consist of a lot of static content. A good example is directories containing images with a ".htaccess" which directs the apache httpd to produce an index page of the contents
16:57 robx how might this be done with Mojolicious?
16:57 pink_mist mojo is for serving apps, not really a good choice for what you're doing. I'd just upgrade to apache 2, or nginx instead
16:58 robx pink_mist, I guess this means I'd have to write an app (or helper) to produce such an index based on the route?
16:58 pink_mist you're missing the point
16:59 pink_mist but no, there are plugins for that
16:59 pink_mist https://metacpan.org/pod/Mojolicious::Plugin::Directory::Stylish for instance
16:59 robx I understand that mojo is probably not the simplest solution to my problem, but I'm also keen to learn it
17:00 robx and I really like its security record
17:04 Grinnz robx: not to say it isn't a good idea, it will certainly work, but apache and nginx are much more battle tested for serving static files
17:05 robx Grinnz, I understand. Not all of the content is static, however. There is also some CGI, which I would like to replace
17:06 Grinnz ah, in that case go for it
17:06 Grinnz just as long as you're aware how webapps differ from CGI apps
17:06 robx Grinnz, uh, sort-of. I guess I'll learn :)
17:07 Grinnz you can have mojo serve CGI scripts using https://metacpan.org/pod/Mojolicious::Plugin::CGI but i would consider that a hacky stopgap; if you really want mojo to serve pages they should be rewritten in its paradigm
17:08 robx Grinnz, exactly the way I see it
17:08 robx if I have understood correctly, in the absence of an explicit route, mojo will look for a match under the /public/ hierarchy. I guess I can use explicit routes into the /public/ hierarchy to override this static handler?
17:09 Grinnz no, routing and static are separate, you would configure the static handler
17:09 Grinnz or create a route which serves static files from somewhere other than public
17:10 Grinnz https://metacpan.org/pod/Mojolicious::Guides::Rendering#Serving-static-files
17:10 robx how is route precedence handled?
17:10 Grinnz first one that matches wins
17:10 robx ok
17:10 Grinnz in the order they were defined
17:10 robx right
17:10 robx sounds simple enough :)
17:11 Grinnz /public/ is not a route, but the directory internally which is used to serve static files by default
17:11 robx ack
17:11 Grinnz you configure the static handler via https://metacpan.org/pod/Mojolicious#static
17:12 robx I will have a look at that. thanks
17:13 pink_mist robx: I would still suggest using apache 2 or nginx to server everything except the specific stuff you need to make an app from, and only delegate that via a reverse proxy to hypnotoad and the mojo app
17:14 pink_mist *serve
17:14 pink_mist it's really the best way to do it
17:16 robx pink_mist, is there an example of such a config that you could point me to?
17:16 pink_mist http://mojolicious.org/perldoc/Mojolicious/Guides/Cookbook#Nginx
17:16 pink_mist http://mojolicious.org/perldoc/Mojolicious/Guides/Cookbook#Apache-mod_proxy
17:16 robx ok, thanks
17:17 Grinnz i still have our mojo app serve some of the static stuff, because it's less annoying to configure than apache (which we're currently stuck with), but yeah apache is still better at it
17:18 robx I would use nginx if anything. I find apache just too daunting
17:18 Grinnz also lets some of the static stuff be dependent on user sandbox config, which is helpful
17:19 robx I don't understand that last comment
17:19 robx which does, and what do you mean by "user sandbox config"?
17:19 Grinnz it's a multi user dev environment, and some devs need static files to be served differently due to JS or assets stuff they're working on, so i can just have mojo do that based on their config
17:22 Grinnz on the other hand, it's also nice when static assets don't have to touch the mojo app at all
17:23 Grinnz so, tradeoffs
17:24 robx mmm, ok
17:56 rshadow joined #mojo
19:34 petru joined #mojo
20:09 sri looks like there is some interest in promises
20:09 sri lets see if someone can fix the ->then method
20:10 mohawk i'd look now but i'm elbow-deep in YAML.pm
20:10 mohawk it promises to do "LoadCode" (for single-line mode) - it lied
20:12 mohawk (the reference to "promise" there was accidental, i promise)
20:12 pink_mist heh
20:14 mohawk you may not believe this but so was that one
20:14 mohawk i will quit while i can still claim to be ahead
20:21 sri promises...
20:21 purl promises is http://i.imgur.com/7aTdI.jpg
20:21 pink_mist lol
20:21 pink_mist botsnack
20:21 purl :)
20:36 jberger hehe, I hit another funny one
20:36 jberger I consistently have been using $delay->wait in the library code
20:37 jberger because this whole thing makes no sense blocking
20:37 jberger and yet, Test::Mojo is blocking and so as I write Test::Mojo::Role::Chrome, I discovered how odd that makes things
20:38 jberger so I wrote it with the Mojo::IOLoop->start/stop dance as with the websocket tests
20:39 jberger but then I found that I needed to next_tick the stop, seen here: https://github.com/jberger/Mojo-Chrome/blob/master/lib/Test/Mojo/Role/Chrome.pm
20:39 jberger then I realized, those next_tick'd stops were needed because they were stopping the start, which happened AFTER the delays did their thing :-P
20:39 jberger whoops
20:47 jberger anyway, fixed that
20:47 jberger mohawk: so this is what the tester can look like: https://github.com/jberger/Mojo-Chrome/blob/master/t/tester.t
20:52 sri jberger: why is the url handling not built into the method?
20:53 jberger into which method?
20:53 jberger oh
20:53 sri just check if the url is relative, and if it is make it absolute with the one from the server
20:53 jberger yeah, I should do that
20:53 jberger I wasn't to that point yet
20:53 sri should be one or two copypasta lines from Mojo::UserAgent
20:53 jberger I was doing the _is method
20:53 jberger yeah, its not a problem
20:54 jberger literally hadn't thought about that bit yet, but I would have eventually
20:54 sri noticed it because it was the only odd looking part of the test :p
20:54 jberger should I make an _is at all? the reason is that evaluate can return any jsonable structure
20:54 jberger I guess I could do it like the json tests with an optional pointer
20:55 sri i would
20:55 sri yea, neat little json structure tests
21:02 mohawk looking
21:03 mohawk jberger, nice
21:05 petru_ joined #mojo
22:21 karjala_ A new version of Promises module just happened
22:27 CandyAngel Does anyone know what codepage might make ' octal 222?
22:57 mohawk jberger, turns out you were 100% right about the encoding stuff in the graphiql template. i figured a test case and all is good once i replaced <%= with <%==. i was SURE <script> elements got html-decoded before JS saw them
23:00 mohawk without your prior help that would have been a quagmire instead of a 4-minute job ;-)
23:36 jberger mohawk glad to help. That's one of the things we see often enough here to warn early on it
23:38 mohawk i bet!
23:38 mohawk anyway, i fixed the yaml thing so am just finishing up the gql-perl tute stuff
23:38 mohawk next: promises!
23:38 purl it has been said that promises is http://i.imgur.com/7aTdI.jpg
23:39 jberger CandyAngel i don't follow your question
23:40 CandyAngel It'a okies, it's just suffering, stay back :P
23:40 jberger Hahahaha
23:40 purl LOLCON 4 reached.
23:40 CandyAngel I have like.. 160 text files.. and they all have different character encoding :|
23:41 CandyAngel So I'm trying to figure out what they are
23:46 mohawk heuristics are the best form of character decoding
23:49 nicomen CandyAngel: is it really ' or perhaps ’ or similar?
23:49 CandyAngel I was looking for "anything similar" and it did turn out to be some curly quote thing
23:50 nicomen perhaps some Windows 1252 involved too?
23:51 CandyAngel Mhm, I've seen some that are windows-1252 and some Mac Roman
23:51 nicomen aight, lucky you ;)

| Channels | #mojo index | Today | | Search | Google Search | Plain-Text | summary