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

IRC log for #mojo, 2017-01-30

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

All times shown according to UTC.

Time Nick Message
00:05 tchaves joined #mojo
00:33 sugar joined #mojo
00:46 aborazmeh joined #mojo
01:36 litwol Hmm
01:36 litwol http://mojolicious.org/perldoc/Mojolicious/Plugin/TagHelpers#form_for
01:37 litwol All examples show form being built to submit to a specific route. this implies that the controller/view which implements the form knows where form will be placed.
01:37 litwol Is there an example that shows form placement on arbitrary page, and it submits to same page, and the form controller then getting executed (for submission handling) ?
01:42 litwol Although
01:43 litwol I suppose i could always submit form to dedicated form-routes, then redirect back to original page on which form was submitted upon completion. maybe? not sure what's possible here.
02:02 bpmedley litwol : Using the 'current' route might be desirable in that scenario: http://mojolicious.org/perldoc/Mojolicious/Guides/Routing#Named-routes
02:03 litwol looking
02:03 litwol t
02:03 litwol y
02:16 sugar joined #mojo
02:21 kiwiroy joined #mojo
02:39 litwol Does perl or mojolicious have a function/method that is equivalent to http://php.net/manual/en/function.get-defined-vars.php ?
02:39 litwol i use this function to great effect when working with new templates and don't know which all of the variables available within that scope.
02:41 preaction no, but for your purpose, you can use $c->stash to see everything in the stash. you can even, in the template, (probably) do something like: %= dumper stash
02:41 litwol well there's also $c you mentioned.
02:41 preaction but you probably want to <pre> that, so <pre><%= dumper stash %></pre>
02:41 litwol where can i read which params are passed into templaes?
02:41 preaction $c is the controller and has lots of other things on it
02:41 litwol oh
02:41 preaction the stash is all the params passed into the template
02:42 litwol now that i think about it. i can alays 'Dumper @_' inside a sub, can't i ?
02:42 preaction yes, that too
02:46 * litwol self facepalm
02:46 litwol ty
02:46 litwol does @_ inside template also hold all params passed into it?
02:46 preaction maybe, technically, but just use the stash!
02:46 litwol but i'm interesteind in more than just /variables for template/
02:46 purl Hmm.  No matches for that, litwol.
02:46 litwol i'm really curious for *all* data in scope
02:46 litwol for learning purposes.
02:46 preaction inside the template, that is the stash. don't use anything but the stash or the helpers you have available to you. doing anything else is an implementation detail and may open you up to terrible consequences in the future
02:46 litwol for example, if i didn't know that "$c" existed inside template for me to pass "$c" into 'dumper'. how would i find out that $c exists, and anything else?
02:47 ilbot2 joined #mojo
02:47 Topic for #mojo is now 🍩 nom nom | http://mojolicious.org | http://irclog.mojolicious.org | http://code-of-conduct.mojolicious.org
02:47 preaction like, if you want to see how the ep template is turned into a Perl sub and then executed, you can just read the code
02:47 preaction i wasn't aware it did. i've never used it
02:47 preaction the Stash-data example is showing you setting the stash in the controller, not in the template
02:48 preaction if i'm aware of anything, though, it's because i read it in the guides
02:49 tardisx joined #mojo
02:52 litwol i'm really curious how to build a plugin that provides a form without a route. i'm pursuing this because in my previous experience platform (drupal) forms were decoupled from route displayed on. system would route form to correct controller (module) based on its form_id during submission. form_id is based on actual function implementing the form.
02:52 litwol so there is routing happening, just not URL based.
02:54 preaction sounds like you want to include a template and then delegate to a controller method to process the form in the template? what's wrong with having a route for the form though?
02:54 litwol well. my assumption is the plugin which implements form, and knows how to handle it, doesn't care which page said form would be placed on. leaving such choise to consumer of the plugin.
02:55 litwol just feels more flexible that way.
02:55 preaction i could see perhaps maybe using that for login forms, except that login forms work fine when making them post to a single specific route and redirect the user back to whence they came
02:56 preaction to me, that mostly sounds more complicated. if the form is being processed exactly the same way, why does it live at multiple places?
02:57 litwol that's just the kind of past experience 'baggage' i carry around. trying to find if same methodology carries over to mojo, or if not then what do i need to learn.. etc.
02:58 litwol i think i've seen example somewhere where a plugin (or equivalent) would register multiple routes for itself, but then consumer of the plugin would be able to configure root route for that plugin, nesting all sub-routes under it.
02:58 litwol that certainly is very flexible and less chances of multiple plugins collising on route namespaces.
03:01 preaction sure. plugins can do anything, since they're usually added at startup and have access to the Mojolicious object (the $app object)
03:02 preaction but i'd advise against flexibility unless you know you need it now, otherwise you'll just make things harder
03:04 litwol i'm trying to cross reference what i can do with mojo from what i can do with Drupal for example. Drupal is also very opinionated on how to do things, and there's extensive documentation on how to work with forms.
03:05 litwol the way it's designed there is forms declare own validate/submit callbacks, and then system would call the right callback at the right stage of execution.
03:05 litwol forms by default submit onto the same page they are displayed on
03:05 preaction all frameworks are generally opinionated. that's what makes them different from libraries: your code is written _inside_ a framework, but your code is _outside_ a library
03:05 preaction also, drupal is a content management system, which mojolicious does not desire to be
03:05 preaction RapidApp might have more opinions on forms and data and such
03:06 litwol ah, derpal is often used as a framework. cms just a part of it.
03:09 preaction i would say that it is more of a cms, which informs its approach to things like forms: that form you're talking about is _content_, which is why it can be put anywhere and its processing found later
03:10 litwol i haven't  done anything outside drupal in nearly 10 years :-\. i'm really hoping to unlearn some of its approaches and succeed with something new. specifically what other ways could one handle forms and form workflows successfully.
03:11 litwol also, having difficult time finding mojo examples displaying and handling multiple forms on 1 page (login, comment, signup, etc)
03:11 litwol although
03:11 litwol based on your tips i undersatnd it is not a problem now
03:11 litwol since each form would submit to different route
03:16 preaction that'd be the easiest way to do it, yes
03:17 litwol and what's the non easy way? :)
03:18 preaction add a form_id to each form and process them either in every controller route (worst) or using some kind of before_dispatch hook (still pretty bad though) (http://mojolicious.org/perldoc/Mojolicious/Guides/Routing#Hooks)
03:23 litwol i c
03:23 litwol ty
03:41 noganex joined #mojo
03:52 disputin joined #mojo
04:30 PryMar56 joined #mojo
04:34 cgi_programmer_look joined #mojo
04:42 PryMar56 joined #mojo
04:57 litwol http://dpaste.com/1V9YEZM
04:58 litwol http://dpaste.com/1DXV0X3 < plugin registers own namespace and paths to be able to route to own controllers and render own templates.
04:59 litwol pretty sure i'm making it more complcated than it could be.. still trying to learn. just happy this form works now.
04:59 litwol What i'm really after is creating really stand-alone plugin. plugin which has own unique namespace. be able to load that plugin inside my main app namespace and it would auto-register all required routes and what not.
05:01 litwol consider use case like.. well simple use case like a 'blog' plugin. such plugin could have render functionality, but also lots of restricted "admin" functionality for cms-like behavior (form to edit blog, admin access control, etc).
05:01 litwol while blog use case is super silly, what i'm really after is the /ability/ to package such plugin for distribution and reusability.
05:04 dboehmer_ joined #mojo
05:18 jberger reading back
05:18 jberger litwol: $c being in the template automatically is mentioned explicitly here: http://mojolicious.org/perldoc/Mojolicious/Guides/Rendering#Embedded-Perl
05:19 jberger towards the bottom of that section
05:19 jberger "At the beginning of the template, stash values that don't have invalid characters in their name get automatically initialized as normal variables, and the controller object as both $self and $c."
05:21 jberger as to functional plugins, you might look at some of mine
05:21 jberger it depends on what you want it to do
05:21 jberger but I have several very complex plugins on CPAN
05:21 jberger https://metacpan.org/author/JBERGER?sort=[[0,0]]
05:23 jberger I also have a (admittedly somewhat eccentric) CMS called Galileo
05:23 jberger if you want to look at that for some things
05:23 jberger it relies heavily on websockets rather than forms
05:23 jberger but most of the other stuff is there
05:24 jberger M::P::ReplyTable and M::P::RevealJS both have templates included in a plugin'
05:24 jberger M::P::Multiplex registers routes in a plugin
05:25 inokenty-w joined #mojo
05:30 preaction litwol: sounds like you want a standalone app, or a controller. controllers have actions, but no routes. you use the router to give an action a url
05:35 litwol jberger: ++ exactly what i wanted to read as a referrence (i think).. Galileo seems like a great learning ground for tastily complex things :-D
05:35 litwol dont mind not using forms at all, i just dont know anything else right now. seems like a good opportunity to learn websockets.
05:36 litwol on that note. good night for now :)
05:36 litwol ty for all the help, again.
05:36 * litwol afk
06:52 CW joined #mojo
07:19 Vandal joined #mojo
07:21 dod joined #mojo
07:26 dod joined #mojo
07:34 dod joined #mojo
07:46 sdeseille joined #mojo
07:55 sdeseille Hello
07:55 purl salut, sdeseille.
07:57 kiwiroy joined #mojo
08:15 AndrewIsh joined #mojo
08:16 howitdo joined #mojo
08:21 trone joined #mojo
08:33 dod joined #mojo
08:39 rshadow joined #mojo
08:56 CW joined #mojo
09:02 pink_mist purl is so polite .. how unusual
09:14 sugar joined #mojo
09:21 kiwiroy joined #mojo
09:21 Petru joined #mojo
09:35 * sri pokes purl
09:35 purl Lower!
09:52 Petru joined #mojo
10:28 dod joined #mojo
10:40 sugar joined #mojo
11:03 sugar joined #mojo
11:05 tchaves joined #mojo
11:10 mishanti1 joined #mojo
11:10 tchaves joined #mojo
11:21 stryx` joined #mojo
11:57 kiwiroy joined #mojo
12:07 litwol with regards to being modular via plugins, is there any prrformance difference when bundling all plugins under 1 namespace (package Mojolicious::Plugin, or MyApp::Plugin), versus plugins trgistering own namespaces such as Plugin1::*, Plugin2::,... ?
12:08 pink_mist does not matter for performance at all
12:18 cpan_mojo Mojo-RabbitMQ-Client-0.0.8 by SEBAPOD https://metacpan.org/release/SEBAPOD/Mojo-RabbitMQ-Client-0.0.8
12:23 Petru joined #mojo
12:24 bc547_ joined #mojo
13:10 sugar joined #mojo
13:12 cpan_mojo Mojolicious-Plugin-OpenAPI-1.09 by ASHIMEMA https://metacpan.org/release/ASHIMEMA/Mojolicious-Plugin-OpenAPI-1.09
13:18 litwol pink_mist: ty. to confirm. if i wish to organize my plugins into "self contained *root* namespaces" and reuse them in my projects, it is perfectly fine for plugin to register own namespace within mojo's runtime... is /that/ the correct way to maintain and interact with plugins?
13:21 kiwiroy joined #mojo
13:25 tyldis litwol: "Plugin1::*, Plugin2::,... " soind like a bad idea. Collect them under Local:: at least. Neither aproach is wise if you ever intent to release these in the wild
13:26 litwol tyldis: that's precisely my interest (not actually to release yet, but what if i need to)
13:26 tyldis litwol: Or under MyCompany:: or if you have a PAUSE user you can prefix them with your username
13:26 litwol looking for advise how to organie them.
13:27 litwol for example i'm clearly planning to use them within context of mojolicious. I cannot imagine any of them will work outside mojo, because i'd use mojo apis inside it.
13:27 litwol but, i 100% dont want to organize them under MyApp::*
13:27 litwol because i want to reuse them across MyApp1::*, MyApp2::...
13:28 litwol so does it mean i declare them under Mojolicious::Plugins::*?
13:28 tyldis https://github.com/kraih/mojo/wiki/Plugins-on-cpan
13:28 pink_mist if you intend to release them, DEFINITELY put them under Mojolicious::Plugin:: namespace
13:29 pink_mist if you intend to release them, that's THE ONLY place people will look for them. so nobody will find them unless you put them there.
13:29 litwol okey that answers that.
13:29 tyldis litwol: tldr: Mojolicious::Plugin::
13:29 litwol ty
13:29 litwol i presume Mojolicious::* namespace is active by default?
13:29 tyldis Mojolicious::Plugin:: is default for plugins
13:30 tyldis Otherwise you need to use the full name or register the desired namespace
13:30 litwol yeah, i dont see it being explicitly declared in source http://cpansearch.perl.org/src/BYTEROCK/Mojolicious-Plugin-Authorization-1.04/lib/Mojolicious/Plugin/Authorization.pm
13:30 litwol great stuff
13:31 litwol ty :). this helps a lot. yesterday i learned/succeeded in creating simple plugin to render simple form with text field, validate it, and echo text back
13:31 litwol just need to organize it better now
13:31 pink_mist litwol: and it's Mojolicious::Plugin::, not Mojolicious::Plugins:: ... just so you're aware
13:31 litwol yep. ty
13:32 litwol Next thing i'm curious about is another organizational piece.
13:32 litwol when i build a page out of plugins. each plugin has piece of content it outputs, some outputs a block, some output a form.
13:33 litwol yesterday i achieved outputting form from a plugin by including it in layout template via %= include 'my_plugin_form_TEMPLATE'
13:33 litwol key here is that i used template include another template.
13:34 litwol i bring this up because i'm not used to template being responsible for decising which content/plugin is included/executed
13:34 Petru joined #mojo
13:35 litwol i'm used to a module(drupal terminology)/plugin/controller responding to an event "build my page" on some route, and then said plugin injects content into the rendering pipeline.
13:35 litwol again, i'm not sure if such approach makes sense in mojo echosystem.
13:36 litwol just trying to examine my experiences/biases from previous frameworks.
13:36 gryphon joined #mojo
13:38 litwol soi'm trying to figure out whether to organize my plugins which produce some content output in a manner that /interaction/ or /activation/ of such plugin is done via template %= include, or some other way where plugin responds to pre/post render events to inject own content.
13:42 sri anyone know why Mojo::Server::Daemon doesn't have a graceful shutdown on SIGQUIT?
13:43 sri as far as i can see it should just be a local $SIG{QUIT} = sub { $loop->stop_gracefully }; in sub run {...}
13:44 * sri just ad the problem that he wanted to shut down a test server gracefully
13:52 rshadow joined #mojo
13:53 marty joined #mojo
13:58 Petru joined #mojo
13:59 sugar joined #mojo
14:09 kiwiroy joined #mojo
14:19 orev joined #mojo
14:22 jberger litwol if you are having helpers that return HTML for templates you should be sure they return Mojo::ByteStream objects
14:22 litwol jberger: do you have a link to example handy ? preferrably not just documentation page, but a working plugin from the wild?
14:23 Pyritic joined #mojo
14:23 litwol when i was experimenting yesterday.. i didn't know any better and i used 'return $controller->render(...)' and it was invoked somehow from inside template.
14:24 litwol i would end up with output of '1' instead of actual content :-\
14:28 jberger litwol i think you are at the point that I start recommending a reread of the documentation
14:28 jberger This time lots of things will click
14:29 litwol oke :)
14:29 genio sri: I watched the first episode of The Good Place last night and that was pretty funny. Hopefully they keep it up
14:29 jberger Read through the tutorial and guides as seen on the site
14:30 pink_mist genio: it's one of those shows which seems like it would be impossible for it to work, but then ... it does
14:33 marty_ joined #mojo
14:43 sugar joined #mojo
15:01 dikim joined #mojo
15:35 kes joined #mojo
15:42 sri genio: all episodes are like that, and then there's one of the best twists ever in the season finale
15:43 genio My wife enjoyed it too (which is hard to find for silly comedy).
15:49 lluad joined #mojo
16:04 asarch joined #mojo
16:04 marty joined #mojo
16:14 orev joined #mojo
16:20 sh14 joined #mojo
16:21 kiwiroy joined #mojo
16:26 * sri is tempted to add graceful shurdown to Mojo::Server::Daemon
16:28 jberger any downside?
16:30 sri don't think so, maybe the inconsistency with Mojo::Server::Prefork?
16:30 sri which is that prefork can have a timeout on the graceful shutdown, while daemon could wait forever
16:32 sugar joined #mojo
16:36 kgoess joined #mojo
16:37 PryMar56 joined #mojo
16:55 marty joined #mojo
17:10 sugar joined #mojo
17:21 sri btw. this query condition has ben working very well for my tests https://gist.github.com/anonymous/1626dde7cdcc9f3fc08ee0b17276785d
17:23 sri get '/public/source/home:kraih/perl-Mojolicious' => (query => {expand => 1, rev => '1234567890'}) => {text => <<'EOF'};
17:23 Ryoga joined #mojo
17:23 sri to match /public/source/home:kraih/perl-Mojolicious?expand=1&rev=1234567890
17:24 sri with arbitrary order of query params
17:24 sri great to mock a REST service you're interacting with
17:26 sri my client object just has a ua attribute
17:26 sri $obs->api('http://127.0.0.1:' . $obs->ua->server->app(app)->url->port);
17:27 sri and that's all i do to connect it with the app
17:27 sri the api attribute is a configurable prefix
17:30 sri guess my $obs object could have a little helper method to assign an app
17:31 sri if i start reusing it in more projects
17:33 kiwiroy joined #mojo
17:39 sri actually, i could just make that condition an example in the guides
18:00 DavidSouza joined #mojo
18:34 sugar joined #mojo
18:37 dod joined #mojo
18:52 marty_ joined #mojo
18:52 marty_ joined #mojo
18:56 marty_ joined #mojo
18:56 marty_ joined #mojo
18:57 marty joined #mojo
18:57 Petru joined #mojo
18:59 disputin joined #mojo
19:11 disputin joined #mojo
19:49 sugar joined #mojo
19:49 good_news_everyon joined #mojo
19:49 good_news_everyon [mojo] kraih pushed 1 new commit to master: https://git.io/vDIJG
19:49 good_news_everyon mojo/master 084cc33 Sebastian Riedel: more examples for conditions
19:49 good_news_everyon left #mojo
19:50 sri $r->get('/hello' => query => {test => 1, to => 'world'})->to('foo#bar');
19:50 sri that looks kinda interesting
19:51 good_news_everyon joined #mojo
19:51 good_news_everyon [mojo] kraih pushed 1 new commit to master: https://git.io/vDIJK
19:51 good_news_everyon mojo/master fea34d7 Sebastian Riedel: just recommend the over method
19:51 good_news_everyon left #mojo
19:51 sri but i guess we better recommend the more readable option
19:52 genio s/world/😾/g  # hello kitty all the things
19:53 sri lol
19:53 sri that totally works btw.
19:54 genio \o/
20:08 Ryoga joined #mojo
20:22 litwol by the way, if not a secret. whta is your day jobs, given that 'mojolicious' is an open source project and it's so actively being committed to...
20:22 litwol full time mojo support, or ?
20:28 jberger I work at ServerCentral https://www.servercentral.com/
20:28 jberger we are building lots of internal tools with mojo
20:29 litwol oh cool.
20:41 * sri works at https://www.suse.com
20:43 sri actually kinda funny how in the last 2 weeks i broke something in mojolicious over the weekend and then had to fix it during the week for work :)
20:45 spicyjack *cough*
20:45 spicyjack that's called "job security"
20:46 marcus o/
20:46 jberger sri: now you know how the rest of us feel :-P
20:46 sri i'm terrible at job security i guess... wherever i go i leave behind lots of tests and docs
20:46 jberger hahaha
20:46 marcus I'm also pretty happy to be working in a Mojolicious shop again.
20:47 sri marcus: contribute more upstream then!
20:47 marcus sri: I just did
20:47 * sri chains marcus to the channel
20:47 marcus whee
20:48 marcus purl: do you still love me?
20:48 purl i don't know, marcus
20:48 marcus :-/
20:48 genio she's been pretty mean lately. watch out
20:49 mishanti1 marcus: Where do you currently work?
20:49 marcus mishanti1: reisegiganten
20:50 marcus (solfaktor.no/restplass.no and such)
20:50 mishanti1 Ah. :)
20:50 marcus together with nicomen and batman.
20:50 mishanti1 The band keeping together?
20:50 mishanti1 s/keeping/sticking/
20:51 sugar joined #mojo
20:51 marcus more like we got the band back together again :)
20:52 marcus https://www.youtube.com/watch?v=dzOHq5WbQ8k
20:52 mishanti1 Glad to hear it.
20:54 sri genio: the good place got renewed for a second season \o/
20:55 genio awsome! A funny show to watch for a few seasons is always a plus
20:55 kiwiroy joined #mojo
20:56 stryx` joined #mojo
20:59 jberger oooh if we're getting the band back together, can I play guitar .... I was getting tired of the tambourine
21:00 genio <insert_cowbell_joke_here>
21:00 jberger I almost went with the cowbell :P
21:01 mib_lfigny joined #mojo
21:03 mib_lfigny hey everyone
21:03 purl everyone is, like, asleep
21:04 mib_lfigny how does one get started with Mojolicious if the things I found on the website are hard to understand for me?
21:05 mib_lfigny I mean is there something a bit more explicit? Things seem very fast-paced
21:05 sugar joined #mojo
21:06 Grinnz http://mojolicious.org/perldoc is where you should start
21:06 mib_lfigny yes, and this is what I've tried
21:06 Grinnz specifically for learning mojolicious, the guides
21:06 mib_lfigny was wondering if there's something else
21:06 mib_lfigny feel stupid :D
21:07 sri the screencasts
21:07 purl the screencasts are cool or the devil telling you to take a bite of the apple
21:07 mib_lfigny (have no experience with web programming)
21:07 mishanti1 mib_lfigny: My enthusiasm for this project was in part sparked by the (now outdated but) _excellent_ videos tempire made.
21:07 sri just be aware that they are a little old and have some small mistakes
21:07 sri https://github.com/kraih/mojo/wiki#screencasts
21:08 mishanti1 mib_lfigny: Then it was just a matter of reading the documentation and getting into the "mindset" of the documentation.
21:08 mib_lfigny thanks, I'll give them a try
21:08 mishanti1 mib_lfigny: If you come from a background where you expect documentation to be simply a class-reference then it is a bit of a switch, but I think the Mojolicious-style documentation is better than the traditional type of documentation.
21:10 mib_lfigny cool, have a great $whatevertimeitsinyourtimezone!
21:11 mib_lfigny left #mojo
21:11 marty_ joined #mojo
21:12 kiwiroy joined #mojo
21:39 kiwiroy joined #mojo
21:42 sugar joined #mojo
21:53 good_news_everyon joined #mojo
21:53 good_news_everyon [mojo] kraih pushed 1 new commit to master: https://git.io/vDI82
21:53 good_news_everyon mojo/master c02ae1f Sebastian Riedel: use the result method in more examples
21:53 good_news_everyon left #mojo
22:04 kiwiroy joined #mojo
22:16 PryMar56 joined #mojo
23:04 michael joined #mojo
23:10 sugar joined #mojo
23:20 Petru joined #mojo
23:21 marcus I quite like the 'A Series of Unfortunate Events' netflix show.
23:28 jberger I find the Mojo documentation is quite like the Vue documentation btw
23:28 jberger a section of guides, a section of reference
23:28 jberger all terse and to the point
23:32 stryx` joined #mojo

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