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

IRC log for #mojo, 2017-09-03

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

All times shown according to UTC.

Time Nick Message
00:04 pink_mist robx: I haveto ask ... do you mean the shebang? because that's probably intentionally meant to sort of fade away since it's not really relevant to the tutorial
00:09 robx pink_mist, no, I mean the entire contents of the code-boxes
00:09 genio it's not hard to read here. *shrugs*
00:10 robx the page background is white, but the code-box background is white with gray vertical stripes, and the code itself is various colors, but all of them quite light
00:10 robx genio, how old are your eyes?
00:10 genio not here. the box's background is completely light grey.
00:11 robx use "xmag" on it
00:13 robx genio, I would use perldoc, but that has problems with escape sequences in the various terminals I've tried
00:13 robx here an example: "ESC[1mTUTORIALESC[0m"
00:15 genio ah, if I zoom in really far I can kind of see the pinstriping
00:15 robx indeed
00:16 robx you can read about low-contrast web pages on Vincent Flanders' webpagesthatsuck site
00:17 genio http://i.imgur.com/6HlK4ab.png
00:17 genio what I see ^^
00:17 genio super zoom-in
00:18 robx hmm, the text looks a millions times crisper than what I see
00:18 robx maybe my firefox is rendering the text badly?
00:18 genio http://i.imgur.com/FeOajgy.jpg
00:19 genio normal zoom
00:22 genio robx: Does metacpan look better to you?
00:22 genio https://metacpan.org/pod/distribution/Mojolicious/lib/Mojolicious/Guides/Tutorial.pod
00:24 robx this is a code example to compare to yours: https://imgur.com/x3wHsAa
00:25 pink_mist are you on windows?
00:25 robx god no :)
00:25 robx Fedora 25
00:25 robx genio, the metacpan page looks way better
00:27 Grinnz robx: firefox has been known to render weirdly with different system themes
00:29 robx gargoyle-chrome does it a lot better
00:29 robx I also sorted out the problem with perldoc
00:30 robx PAGER was set to "less". I changed it to "less -R"
00:30 Grinnz perldoc is also known to currently have issues with pagers.
00:31 robx when I complained I was unable to make out the asterisk in the "Wildcard placeholders" example
00:32 robx I think the complaint is still valid though. The code examples, even with chrome, are low-contrast
00:32 robx but I thank you both for the help
00:34 Grinnz it looks like the background of those code blocks is an image https://github.com/kraih/mojo/blob/master/lib/Mojolicious/resources/templates/mojo/perldoc.html.ep#L49
00:57 sri robx: it's your browser setup that's borked
00:58 sri on my suse and mac os desktops it looks great
00:59 sri omg that screenshot...
00:59 sri wtf did you do to your desktop environment?
01:00 sri it's like you have a filter to make everything look washed out
01:37 robx indeed, I went to great lengths to ruin my desktop environment
02:23 noganex_ joined #mojo
02:56 mib_26o072 joined #mojo
03:10 mib_26o072 I'm new to Mojolicious and to object oriented programming. I'm trying to get the following to work, but it return an error message as described in the attached file. Why can I not call $self->testme() the way I have attempted to do it? Should I somehow be using use Mojo::Base in the third package? I'm definitely missing something. THANK YOU!
03:11 mib_26o072 http://mibpaste.com/YK4SrT
03:11 mib_26o072 (Sorry, there it is, pasted above.)
03:17 pink_mist shift->s_start() only works by coincidence ... that one should be written s_start(shift())
03:17 preaction first, the controller method gets a controller as the first argument. if you want a Mod::Service object, you ned to instantiate one
03:17 pink_mist and yeah, what preaction said
03:18 preaction but your Mod::Service class has no constructor, so it is not an object class
03:18 pink_mist you shouldn't mix functional interface with OO interface like you're trying to do
03:18 pink_mist Mod::Service is actually not OO at all
03:22 mib_26o072 First, thank you. So, basically, are you saying that I should create a new constructor in Mod::Service, and then call Mod::Service->new() in TestApp::Controller::Service?
03:24 pink_mist well, what object do you want to run the testme() subroutine on?
03:25 mib_26o072 well, the main deal here (what I really want to do) is to be able to pass self around so I can use it in my program.
03:25 pink_mist you can pass it as a parameter to any subroutine you want, like I mentioned before
03:26 pink_mist s_start(shift())
03:26 pink_mist testme($self)
03:26 pink_mist it's not OO though
03:27 mib_26o072 The program is much bigger than I've specified (as I've only presented an example), and I need self at various times and I don't want to keep passing it around as an argument into a subroutine. It seems to me that OO should handle this much better on a package level.
03:28 mib_26o072 So do I need to create a constructor for each package, and somehow inherit self, or can I pass self around as a global in my program?
03:29 pink_mist what OO in perl does is literally just pass in the variable as the first parameter. the only difference is where it tries to find the sub you're calling
03:29 pink_mist but you want to call subs in various places, and you can't do that unless you inherit from them
03:29 pink_mist so you'd need to put something like: push @ISA, 'Mod::Service';
03:30 pink_mist in your controller class
03:30 pink_mist then method lookup would start working like you seem to want
03:31 pink_mist also, you should stop using Exporter if you're doing OO
03:31 pink_mist normally those things aren't mixed, and it's often frowned upon if you try
03:35 mib_26o072 Well, right now, I have (non OO) perl packages in which I'm using Exporter, and so if I want to use strip_non_alpha in Connect::FormOut, I write use Connect::FormOut qw(strip_non_alpha);; So if I want to convert that to OO, I should create a new constructor in each package, and stop using Exporter?
03:36 pink_mist no, that's only if you want to make a different object for each package
03:36 pink_mist if you want to pass your controller around using OO, you simply put the packages into your controller's inheritance tree
03:36 pink_mist which is what @ISA is for
03:38 mib_26o072 So push @ISA, 'Mod::Service';, where does that go?
03:38 pink_mist below the "use Mod::Service;" line in your controller
03:38 pink_mist (and stop importing s_start in that use line too)
03:39 mib_26o072 So I stop importing it, and then in Mod::Service, I stop exporting it, correct?
03:40 pink_mist yes
03:40 preaction what self though? the context? don't use the context like that
03:40 pink_mist though actually
03:40 pink_mist let me check Mojo::Base a bit
03:40 preaction if you want a sub in your controller, just put it in your controller
03:41 preaction if you want another object, a Mod::Service object, then make one
03:41 preaction don't make your controller into a Mod::Service object as well as a Mojolicious::Controller. that's asking for trouble
03:41 pink_mist never mind my "though actually"
03:42 pink_mist preaction: yes, he's asking for trouble
03:42 preaction i mean, you told him to do it...
03:42 pink_mist I told him to do something totally different, but he wanted to do it, so I told him how
03:45 preaction mib_26o072: this fixes your can't find method problem: https://gist.github.com/preaction/951888f6ebc61c2e000770297ef22d2c if you need things from the $c object, pass them into the Mod::Service->new() method. like, say, the app's name maybe
03:45 mib_26o072 OK on a few points. I won't call $self->anything() where anything is not already defined as a Mojo method.
03:48 preaction here's an updated version that adds an attribute "app_name", gets that information from the controller object, and prints it out in the testme() method: https://gist.githubusercontent.com/preaction/951888f6ebc61c2e000770297ef22d2c/raw/675f34c1921e80b4a5aa172a73ea2b678c34c7d2/gistfile1.txt
03:52 Lee joined #mojo
03:54 mib_26o072 Wow, it looks pretty nice and might just be exactly what I need. But two questions. First, I don't see any push @ISA, 'Mod::Service'; there. Second, is this code "asking for trouble" or is it "safe"?
03:57 pink_mist mib_26o072: there's no push @ISA there because it does something completely different: you create new objects
03:58 pink_mist the push @ISA was for reusing your controller object to dispatch to the methods you wanted
03:59 preaction which is bad
03:59 preaction i don't know what asking for trouble is, nor safe
04:04 dboehmer joined #mojo
04:08 mib_26o072 Hum, ran your code and Can't locate object method "new" via package "Mod::Service"; should I defined "new" or does use Mojo::Base; do that for me?
04:09 preaction sorry, it should be use Mojo::Base -base
04:10 preaction see the docs as to what that does: http://mojolicious.org/perldoc/Mojo/Base
04:15 meredith robx: I did a test raising the minimum contrast in highlighted code to 4.5:1, removing the stripes, while using a similar dpi.  I think it would be helpful, but I don't think it would've saved you here:
04:15 meredith https://i.imgur.com/9P3F23L.png
04:16 meredith Looking at your example, it fell back to Courier on the preference list of some nicer (proprietary) fonts.  Courier is very thin, and I see anti-aliasing, but I don't see subpixel rendering, which makes this very washed out.
04:17 meredith There may be a global option for subpixel rendering you can enable, or maybe that fallback Courier on your system doesn't work with subpixel so it stood out as particularly awful.
04:21 meredith I'm going to submit a PR to better the contrast, and maybe we can suggest a better monospace font list too.  (I'm not sure of one off the top of my head)
04:21 meredith Sorry you got some unhelpful remarks here.
04:27 mib_26o072 Thank you, preaction and pink_mist. It's enough to get me started. Still very confusing though. Getting there.
04:45 mib_26o072 I do have another question, because after implementation this code (it works and does not crash, thankfully), it seems to me that $self is missing information, is that possible?
04:48 mib_26o072 For example, $self->stash('trailer') is no longer accessible;
04:48 preaction one $self is not another $self
04:48 mib_26o072 From $r->any('/svc/*trailer')->to('Service#access_svc');
04:49 preaction every "my $self" is a different $self
04:49 preaction if you have a value in $c->stash( 'trailer' ), then give it to the Mod::Service object using an argument, like i showed you
04:51 mib_26o072 I assume you mean like app_name
04:51 mib_26o072 So that basically I am redefining $c->stash( 'trailer' )
04:52 mib_26o072 I cannot pass around $c in my entire program (making it into a global, for example). Is that bad programming practice?
05:11 mib_26o072 Hi guys, thank you so much for your help. I must go to bed now. Have a good day.
05:40 Vandal joined #mojo
05:49 bianca joined #mojo
05:56 bianca joined #mojo
06:42 mohawk joined #mojo
06:46 mohawk sorry if this is an FAQ. it seems, as linked on this stackoverflow answer, like websockets never get reused. is that due to something i can't see in the protocol? https://stackoverflow.com/questions/45497182/mojolicious-re-using-a-previously-established-connection
06:52 mohawk (also a search on the GH issues for "websocket" didn't show anything i thought looked like discussion of this, nor did a read of `git log -p` shed any light)
07:13 bianca joined #mojo
07:19 ashimema joined #mojo
08:14 trone joined #mojo
10:09 sh14 joined #mojo
10:56 karjala_ joined #mojo
11:11 petru joined #mojo
11:23 aborazmeh joined #mojo
11:26 sh14 joined #mojo
11:27 klapperl_ joined #mojo
11:28 Lee[home] joined #mojo
11:42 n16gel joined #mojo
11:43 sri meredith: i was just mirroring their tone... but i see your point and will abstain from the discussion from now on
11:50 sri not including a screenshot in the pull request will prolly make most people abstain from voting too though
11:56 itaipu joined #mojo
12:13 stryx` joined #mojo
12:22 bianca joined #mojo
12:49 castaway joined #mojo
12:54 castaway joined #mojo
13:52 [vlad] joined #mojo
14:55 robx meredith, thanks for your trouble. Your changes are definitely an improvement and I would implement them anyhow
14:58 robx ah, reading further, it seems you intend to :0
15:00 sh14 joined #mojo
15:05 mohawk sri, jberger - any thoughts on the above websocket point?
15:15 bianca joined #mojo
15:45 sri mohawk: no
15:51 sri mohawk: you seem to be looking in the wrong direction though, adding things on top of the websocket protocol should be higher level, not lower
16:04 good_news_everyon joined #mojo
16:04 good_news_everyon [mojo] kraih pushed 1 new commit to master: https://git.io/v50hf
16:04 good_news_everyon mojo/master 108caf9 Sebastian Riedel: bump version
16:04 good_news_everyon left #mojo
16:04 good_news_everyon joined #mojo
16:04 good_news_everyon [mojo] kraih tagged v7.44 at 0dc8387: https://git.io/v50hJ
16:04 good_news_everyon left #mojo
16:09 stryx` joined #mojo
16:15 sri kinda odd how often people start working on a Mojo::Pg patch and then just give up
16:16 sri like ->expand support for more column types, or ashimema's pubsub keep-alive
16:25 mohawk sri, fair enough - thanks
16:25 mohawk if you could share a few more words on what that would look like, that would be extremely helpful :-)
16:28 sri mohawk: some frameworks like phoenix have their own higher level protocol on top of websockets to multiplex multiple channels https://hexdocs.pm/phoenix/channels.html
16:28 sri sounds like that's what you want
16:28 sri mojolicious should have something like that, but doesn't yet
16:41 mohawk sri, thanks!
16:42 sri it's not hard to build on top of mojolicious, but for now you have to do that yourself
16:42 sri ultimately i'd hope for us to have it in core, without the message bus part
16:43 sri but channel management and routing
16:48 Alex342 joined #mojo
16:51 ChmEarl joined #mojo
16:55 Alex342 Hei guys. What can you about / Mojolicious::Plugin::Notifications?
16:56 Alex342 say about**
17:11 dboehmer joined #mojo
17:12 zivester joined #mojo
17:19 ashimema sri, I'm still slowly working on that pubsub keepalive.. I solicited some advice from ribasushi on how to write a test for it.. then promptly went on holiday for a week.. with any luck I'll get back to it this week.. if work permits ;)
17:20 CHYC WRT ->expand support, you can now subclass Mojo::Pg::Database, so I have done that in my own code for custom expanders.
17:20 * ashimema wonder what ->expand was?
17:23 CHYC ashimema: https://github.com/kraih/mojo-pg/pull/18
17:24 petru joined #mojo
17:30 hesco joined #mojo
17:33 hesco The sample code in perldoc Mojolicious::Plugin::CGI seems to assume that an application is ancapsulated in a single script.  But the legacy application I want to port to mojolicious has about 20 distinct cgi scripts which each need to be served at their own path.  Should this work?  plugin CGI => [ "/cgi-bin/script" => "/path/to/cgi/script.pl", "/cgi-bin/script2" => "/path/to/cgi/script2.pl", etc. ];
17:33 bianca joined #mojo
18:02 bianca joined #mojo
18:03 Alex342 Guys can you give me some advice? I have a table with notifications. But i dont really know how to display them. I want smth facebook like.
18:39 bianca joined #mojo
18:53 dmanto joined #mojo
20:01 bianca joined #mojo
20:46 nic joined #mojo
21:58 batman hesco: you can load the plugin as many times as you want
22:00 batman You might also be interested in https://metacpan.org/pod/Mojolicious::Plugin::CGI#Helper
22:00 hesco thanks batman, so an additional plugin CGI => [ "/cgi-bin/this_script" => "/path/to/cgi/this_script.pl" ]; plugin CGI => [ "/cgi-bin/that_script" => "/path/to/cgi/that_script.pl" ];  ## Like that?
22:01 hesco rather than an arrayref of url_path_fs_path pairs?
22:03 batman yeah
22:04 hesco thanks,  If it really is that simple, I hope to test that successfully before the end of this weekend.
22:05 batman that's what i've done, so it better work for you as well, hehe
22:05 hesco that is quite encouraging, actually.
22:05 hesco thanks again batman!
22:08 batman you're welcome
22:08 batman btw: i'm the author of that plugin
22:20 obi_wan joined #mojo
22:26 hesco ah, thank you sir, for your work, then.
22:26 hesco be back in a few.
22:38 hesco and back

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