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

IRC log for #mojo, 2013-11-21

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

All times shown according to UTC.

Time Nick Message
00:03 punter joined #mojo
00:25 russum joined #mojo
00:32 Adurah_ joined #mojo
00:33 D4RK-PH0ENiX joined #mojo
00:50 btyler joined #mojo
00:50 maxhq1 joined #mojo
01:02 cfedde joined #mojo
01:04 laouji joined #mojo
01:43 d4rkie joined #mojo
01:48 exonity joined #mojo
01:56 laouji joined #mojo
02:19 laouji joined #mojo
02:35 duncanthrax joined #mojo
02:38 laouji joined #mojo
03:14 laouji_ joined #mojo
04:06 asarch joined #mojo
04:09 preflex_ joined #mojo
04:47 laouji joined #mojo
05:20 laouji joined #mojo
05:26 dotandimet joined #mojo
05:57 dotandimet joined #mojo
06:45 KindTwo joined #mojo
06:54 dod joined #mojo
06:54 dod joined #mojo
07:05 dod joined #mojo
07:23 hummeleBop joined #mojo
07:36 laouji joined #mojo
07:36 hummeleBop joined #mojo
08:10 Tiger joined #mojo
08:12 nicolaas joined #mojo
08:12 dod joined #mojo
08:19 bowtie_ joined #mojo
08:19 trone joined #mojo
08:56 basiliscos joined #mojo
09:05 rem_lex| joined #mojo
09:13 themage joined #mojo
09:29 Dandre hello,
09:30 iSlug joined #mojo
09:31 Dandre For a text field, using tag helper plugin I can write this:
09:31 Dandre text_field 'TextName'=>$model->get('TextName');
09:31 Dandre where $model is my model object
09:32 Dandre is there anything similar for select_field?
09:34 Dandre apparently, values for select_field are got from controller's parameter
09:38 tianon joined #mojo
09:40 batman Dandre: du you want to set the default value for the select_field ?
09:40 batman as in pre-select an item - other than the first?
09:41 batman % param select_name => 'default value' unless param 'select_name';
09:41 batman %= select_field select_name => ['some value', 'default value']
09:47 Dandre ok I'll try
09:48 batman remember the unless, so you don't mess up data from the user :)
10:00 maxhq joined #mojo
10:16 KindTwo joined #mojo
10:17 migo joined #mojo
10:21 cfedde joined #mojo
10:23 fhelmber_ joined #mojo
10:26 cfedde joined #mojo
10:29 heince joined #mojo
10:30 heince does using full app enable 5.10 features ?
10:31 cfedde joined #mojo
10:39 cfedde joined #mojo
10:44 cfedde joined #mojo
10:50 cfedde joined #mojo
10:59 abra_ joined #mojo
11:00 nicomen joined #mojo
11:10 batman heince: use Mojo::Base ...; should enable 5.10 features
11:10 batman should = will
11:11 batman https://metacpan.org/source/SRI/Mojolicious-4.58/lib/Mojo/Base.pm#L38
11:11 nicomen is there some easy way to expand respond_to() to for instance incorporate jsonp ( à la https://metacpan.org/pod/Mojolicious::Plugin::JSONP )
11:12 asarch joined #mojo
11:14 batman nicomen: yes. $c->respond_to(jsonp => sub { ... }); :)
11:14 batman at least last time i checked, it use "format" which is the file extension from the request.
11:15 nicomen batman: yes, cool, the next step would be to register the format jsonp and set up something common for the whole app
11:15 nicomen this is slightly closer to what I was thinking: http://runcible.ajbcontracts.co.uk/mojolicious-jsonp/
11:15 batman you don't need to register anything. it just works.
11:15 batman you just need to ask for domain.com/resource.jsonp
11:18 nicomen batman: yes
11:18 dvinciguerra joined #mojo
11:18 nicomen but what I want is to avoid having to write a sub in every controller
11:19 batman i don't get it. but i also don't care as long as you know what you need to do :)
11:20 nicomen so you know if you say $c->respond_to({ json => { json => $ref } }); then something somewhere converts my $ref into a json string
11:21 nicomen I would like a conversion to a jsonp string to happen somewhere central too, so I don't have to duplicate the sub { "$callback( " . to_json($ref) . ");" } in every controller
11:50 womble joined #mojo
12:03 womble Hi, does anyone here have a solution for data in a DB being rendered in front end, with frontend updated in realtime when backend rows are subjected to CRUD? Something akin to what derby.js does.
12:05 womble There was a nice discussion around this in the channel in July and I wondered if there had been any progress/developments. http://irclog.perlgeek.de/mojo/2013-07-04 search for comment starting "Howdy" by phillipadsmith
12:06 moritz womble: you can even link to specific lines of the IRC logs (click on the timestamp link of that line)
12:06 womble Thanks http://irclog.perlgeek.de/mojo/2013-07-04#i_7289146
12:07 batman womble: what is the backend db?
12:08 womble I've been playing with SQLite but the schema is so trivial I could use anything
12:08 batman if it's mysql (or something similiar) then i think you need a hook which insert rows in a log table which you could "tail"
12:08 batman or you could add a updated field which always gets the CURRENT_TIMESTAMP, do magical sorting and tail the new rows after a given timestamp
12:09 batman it will probably be super slow on big tables though.
12:09 batman i got a log table @work that i follow in my web interface. i do what i just described.
12:10 batman but i'm using longpolling instead of websockets because of ie.
12:10 batman not sure if the longpolling works in ie yet either, since i haven't gotten to that stage of testing yet
12:10 womble I'm not bothered about compatibility, it will just be small number of users with ability to use latest browser/s
12:11 womble The high level idea is executing external commands via web interface, each one writes to a log file. Users log in to web UI, watch the logs files in real time.
12:12 womble But I can't get my head around a nice way for users to begin the tail at any time and get all data from the start up to current
12:13 womble I'm thinking something like tail the log file into an array on the server, user initial request dumps contents of array back to client, client then opens web socket and on server receiving new data into the array, send web socket to all clients + offset since the initial synch
12:13 womble but it sounds dirty
12:14 batman https://github.com/jhthorsen/mojo-ioloop-readwritefork/blob/master/example/tail.pl # please tidy this up for me :)
12:14 womble derby.js looks like it takes care of that for you... but I only know perl... and barely
12:14 womble I have no clue about Mongo, node.js etc etc
12:20 hrupp joined #mojo
12:21 womble batman: I see how your solution works, but I worry about things like user rapidly flicking between views of the logs, every time a new tail is created, one per user etc etc
12:22 batman i can't solve this for you. sounds like you need to hire a consultant.
12:22 womble :-)
12:23 womble I was thinking about using DataTables to display data, or something like streamtable.js, but nothing i've seen is clean
12:24 womble to quote from derbyjs.com: "Adding dynamic features to apps written with Rails, Django, and other server-side frameworks tends to produce a tangled mess. Server code renders various initial states while jQuery selectors and callbacks desperately attempt to make sense of the DOM and user events"
12:25 womble Just a shame about the requirements with MongoDB, node.js
12:31 punter joined #mojo
12:37 batman punter: i've written Ubic::Service::Toadfarm. it doesn't do the same thing as ::Hypnotoad
12:37 punter oh
12:37 batman punter: it's funny, because i think yours is more complicated :)
12:37 punter oh really?
12:37 punter hehe
12:38 punter I'll check yours out then.
12:38 punter Does yours replace mine? Does mine have a reason of existence?
12:39 batman don't get what start_time and end_time does :/
12:39 batman yes! yours have a good reason for existence. it was even on cpan before mine :)
12:40 batman mine -can- replace yours, but it's probably overkill for most cases.
12:41 batman also, yours is the one most people will pick, since it has the right name for the job.
12:41 batman mine is created to controll toadfarm, not hypnotoad.
12:41 punter ok kewl
12:41 batman (though it can controll hypnotoad as well)
12:41 batman but... what good does start_time and end_time do?
12:42 punter I'll have to look at the code to answer that question. Just a sec.
12:42 batman :)
12:43 punter I wrote it a long time ago.
12:44 womble batman: thanks for your help btw
12:44 punter I had problems combining Ubic & Hypnotoad, so I consulted berekuk, the creator of Ubic
12:44 batman i also don't like the default pid_file. i think it should stay in ubic's tmp dir. but that is probably just a matter of taste.
12:44 punter We thought about many alternatives, and decided to go with start_time
12:45 punter here's what the problem was (if I remember correctly):
12:45 batman but who fiddles with start_time and end_time? is it Ubic?
12:46 punter start_time is set by my 'start' routine
12:47 punter I think the problem was that "hypnotoad app.pl" returns immediately, before app.pl has started
12:47 punter or something similar, I really can't remember. Sorry
12:48 punter and stop_time is set by my "stop" action, as well
12:48 batman oh! so if start_impl() returns "starting", then status is used...or?
12:48 batman is called i mean.
12:48 batman maybe we should continue in #ubic :)
12:49 punter I don't know. Yes, we should ask berekuk about all this.
12:49 batman :)
12:50 batman punter: i get it now!
12:50 punter You do??? Will you be so kind as to explain what the hell is happening to me as well?
12:50 batman this is pretty cool. i though the return value form start_impl() was ignored
12:50 laouji joined #mojo
12:51 batman yes. the start_impl() is called and since you return "starting", the Ubic::Service::Utils::wait_for_status() function is called.
12:51 punter Yay, that's it
12:51 batman this wait_for_status() function is called on the same object, which allow start_time/stop_time to be useful for your status_impl() method
12:51 punter This waiting is a Ubic::Skeleton thing, isn't it?
12:51 batman same object = the hypnotoad service object
12:52 batman yes, it is.
12:52 batman this is pretty cool. i think it need to steal your logic :)
12:52 punter Ok, please do :-)
12:53 punter the path of the .pid file is defined by Hypnotoad's configuration, right? Not by Ubic... So Ubic has to follow whatever Hypnotoad wants to do.
12:57 batman ah! you're absolutely right.
12:57 batman ::Toadfarm sets MOJO_CONFIG and has control of that part in the config file.
12:57 batman toadfarm != hypnotoad :)
13:12 mire joined #mojo
13:19 dotan joined #mojo
13:26 marty joined #mojo
13:28 d4rkie joined #mojo
13:40 aleksey joined #mojo
13:41 aleksey left #mojo
13:52 russum joined #mojo
13:52 [1]womble joined #mojo
13:54 ver joined #mojo
14:05 punter joined #mojo
14:07 dotandimet joined #mojo
14:20 sh4 joined #mojo
14:33 batman any AssetPack users here? i would like to get some feedback on this change:
14:33 ryozi joined #mojo
14:33 batman https://github.com/jhthorsen/mojolicious-plugin-assetpack/commit/c2d7426b7d519346cfc111a228d66ac3f8f27930
14:34 sh3 joined #mojo
14:37 gryphon joined #mojo
14:37 cfedde joined #mojo
14:42 cfedde joined #mojo
14:45 btyler joined #mojo
14:47 bluescreen joined #mojo
15:34 [1]womble joined #mojo
15:39 zackiv31 joined #mojo
15:42 Tiger joined #mojo
15:45 stephanj batman: btw, is there currently a way to get the currently used filename?
15:48 stephanj (use case: requirejs and data-main, i don't want the script tag in this case)
15:49 batman stephanj: interesting.
15:49 batman send me a pull request :)
15:49 batman or at least make an github issue
15:50 batman stephanj: i have no idea how to fix that.
15:51 batman guess you always need to get a list of files: many files when in expand mode and one file in minify mode...
15:53 stephanj in this case i am using assetpack to minify one scriptfile
15:54 batman i'm not interested in one solution for one case. it need to be generic
15:57 batman guess you can do @files = $self->asset->get('moniker.js');
15:57 batman would that help?
15:58 batman ...where files are relative to you app base url
16:00 hrupp left #mojo
16:03 athenot joined #mojo
16:04 stephanj batman: i think so yea
16:12 batman stephanj: https://github.com/jhthorsen/mojolicious-plugin-assetpack/commit/baae0b2993710dd108f199873ceaea9d1037df06 ?
16:29 phillipadsmith womble: Did you find the answer to your question?
16:33 basiliscos Hello. http://bpaste.net/show/151846/ I can see only "finished 1", and the script exists. What I'm doing wrong?
16:34 womble phillipadsmith: Not really! Doing lots of reading. Currently wondering what "they" means here: http://irclog.perlgeek.de/mojo/2012-10-28#i_6107287 also see 3 lines up
16:35 womble I realised I actually asked two questions as well, as I have separate but similar requirements for streaming real data.
16:35 phillipadsmith womble: I think sri was talking about threads…
16:36 phillipadsmith Read streaming data, I solved that particular challenge, per sri's advice using Websockets
16:36 phillipadsmith s/Read/Re:/
16:36 womble Definitely sounds like the way to go yes
16:37 phillipadsmith It's also relatively easy to accomplish using some of the newer JS libraries that have data binding
16:38 womble Some background on my requirements.. I want to basically run shell scripts from a web UI. I want to be able to schedule a set of shell scripts as a "job set". I want to track submitted job sets and their progress in a DB. Each "job" (read shell script) will output to a file. I would like to stream/tail each file.
16:39 womble So I would like a table that reflects state of the DB in the DOM, plus the ability to tail/cat selected files
16:39 womble I've had a look at Knockout, Angular etc
16:40 phillipadsmith Yes, what I was after -- a list, not a table, but probably roughly equivalent -- was straightforward in Angular. When there is new data in the DB, the page "just updates"
16:40 womble It's that transition from sending pre-existing data, e.g in a DB or file, to continuous updates, that is hard
16:41 womble I've been looking at DataTables and streamtable.js, as it adds some nice features... If you had log file lines in a table you can paginate nicely
16:41 womble You can also filter (streamtable.js is fantastic for this in realtime)
16:42 womble I couldn't see an easy way to hook into DB updates
16:42 womble in order to pass back to Angular/Knockout/etc
16:43 phillipadsmith I think I used jquery.tablesorter for that kind of stuff in the past… (sorting, filtering, paginating)
16:43 womble There's the load all data onto client at once vs server side pagination as well
16:43 phillipadsmith Re: Angular, you can create a data binding (that's the core concept basically) between DOM elements and your data, and it handles the updates when the state of the data changes.
16:44 phillipadsmith http://clintberry.com/2013/angular-js-websocket-service/
16:46 mire_ joined #mojo
16:47 womble Thanks... is the gist that websocket send/receive can be out of order then?
16:47 womble Partly anyway
16:49 rem_lex joined #mojo
16:53 winslow4 joined #mojo
16:55 stephanj batman: thanks
16:55 stephanj sounds like exactly what i want
16:56 womble Thinking out loud, you have the client connect to a websocket on the server. Server can send to client on websocket. When client receives, it uses javascript dump data into a variable which is bound to a DOM element by angular/knockout/whatever
16:57 womble This sounds easy for something like tailing files where only new data is received. but more complicated for a table where rows could be updated
17:16 basiliscos I read docs about Mojo::IOLoop. Well, I forget to use $delay->begin. So, why the following example http://bpaste.net/show/151859/ does not works? If I use timer instead of $ua->post, it works.
17:17 punter joined #mojo
17:33 rem_lex|pivo joined #mojo
17:34 beyondcreed joined #mojo
18:01 jzawodn I'm having trouble putting together an async Mojo::UserAgent demo for myself.  Here's my script: http://pastebin.com/0nbP56J4
18:01 jzawodn the /q works but is not async, /a never returns and always times out
18:02 jzawodn and I'm sure it's something simple missing
18:02 jzawodn line #21 seems to never run
18:02 sri jzawodn: $ua goes out of scope ;)
18:03 jzawodn gah! you're right
18:03 jzawodn does it seem right otherwise?
18:03 sri sure, the Mojo::IOLoop->start is useless though
18:04 jzawodn oh, yeah... leftover from testing
18:07 jzawodn woot!  fixed
18:07 jzawodn thanks
18:07 winslow4 joined #mojo
18:07 basiliscos I have found the issue in my code! I have to do $end = $delay->begin; and then $end->(), when actually need to step forward.!
18:12 gryphon joined #mojo
18:15 fhelmbe__ joined #mojo
18:38 dod joined #mojo
18:47 dotandimet joined #mojo
19:11 Mike-PerlRecruiter_ joined #mojo
19:29 dotandimet joined #mojo
19:51 basiliscos joined #mojo
20:01 Foxcool joined #mojo
20:01 good_news_everyone joined #mojo
20:01 good_news_everyone [mojo] kraih pushed 1 new commit to master: http://git.io/PQLw5g
20:01 good_news_everyone mojo/master d20b9cf Sebastian Riedel: more complete FAQ answer
20:01 good_news_everyone left #mojo
20:01 sri something to link to in the future
20:32 lukep joined #mojo
20:38 trone joined #mojo
20:43 batman stephanj: i will make a new release tomorrow. i hope that is soon enough...
20:49 stephanj batman: sure
20:50 batman sweet
20:50 batman still no feedback on the other change, so i'm going to release that as well.
21:49 cfedde joined #mojo
21:55 cfedde joined #mojo
21:57 batman dzil is an absolute pain in the ass.
21:57 Lucas1 joined #mojo
22:00 cfedde joined #mojo
22:04 delias joined #mojo
22:26 trone joined #mojo
22:28 punter joined #mojo
22:29 gedge_ joined #mojo
22:36 asarch joined #mojo
22:58 jzawodn ok, Mojo::UserAgent kicks ass
23:00 tianon most definitely
23:00 tianon I've pulled in all of Mojo as a dep for some tiny scripts before, just to get Mojo::UserAgent <3
23:01 basiliscos joined #mojo
23:50 sri :)
23:56 salparadise so I love Mojo::UserAgent, sri: do you take contributions?

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