IRC channel logs


back to list of logs

<davexunit>hmm, web browsers choke on my guile web server...
<davexunit>I have 2 script tags on the page. the browser fetches the source for the first one, but never evaluates it. the second script is not fetched and the html on the page is not rendered.
<davexunit>no errors from guile, no errors in firefox, and firefox says that the request to fetch the first js file has completed.
<davexunit>ah, found the problem. sxml is doing the wrong thing with a <script> tag
<davexunit>even when there's no content in a <script> tag, it still needs </script>, it can't be <script />
<ijp>there is an option for that, I think
<davexunit>as a workaround, I add the empty string as the contents.
<davexunit>ijp: oh? I will look.
<ijp>I misremembered, it is wishlist, not closed
<davexunit>thanks, ijp
<mark_weaver>davexunit: also, you should be able to put the doctype header in the sxml itself.
<mark_weaver>davexunit: use xml->sxml to see what it should look like.
<davexunit>mark_weaver: I'll try it. I noticed some documentation in the manual doing it this way.
<mark_weaver>where? that should probably be fixed.
<davexunit>doesn't parse.
<mark_weaver>maybe I'm misremembering
<davexunit>Throw to key `parser-error' with args `(#<input: string 4e701a0> "XML [22], unexpected EOF")'.
<mark_weaver>did you put any HTML after the doctype header?
<ijp>I do my own sxml -> xml with pre-post-order + SRV:send-reply to handle doctypes and raw strings
<davexunit>mark_weaver: no. I'll try it and see what happens.
<davexunit>it worked, but the doctype isn't in the output
<davexunit>(xml->sxml "<!DOCTYPE html><foo></foo>") returns (*TOP* (foo))
<mark_weaver>okay, nevermind then :)
<mark_weaver>however, instead of using 'string-append' to put it in front, you could use 'display' inside the 'with-output-to-string'.
<davexunit>yeah, that's a good point. I should do that for other things, too.
<davexunit>I'm needlessly reading static files in as strings and then writing them to the port
<davexunit>instead of just writing to the port.
<ijp>the pre-post-order is actually really nice to use, just most people don't
<davexunit>I will have to learn how to use it.
<davexunit>despite being a professional web developer, this is my first foray into guile's web offerings.
<ijp>davexunit: basically, you give it an alist of functions, and it rewrites your sxml accordingly
<mark_weaver>ijp: nice
<ijp>with an option specifying whether or not to rewrite the node's children
<mark_weaver>ah, this is what I was thinking of: (sxml->xml '(*TOP* (*PI* xml "version=\\"1.0\\" encoding=\\"UTF-8\\"") (html ""))) => <?xml version="1.0" encoding="UTF-8"?><html></html>
<mark_weaver>but that's not the same as the doctype decl.
*mark_weaver goes afk again
<davexunit>see ya
<davexunit>thanks for the tips
<hellekin>davexunit: nice to see you here. Are you willing to generate the GNU website from Guile? That would be awesome :)
<davexunit>hellekin: haha, yes it would.
<davexunit>a task that no one would really want to help with, probably. ;)
<hellekin>well actually I've been postponing learning Guille for at least 2 years, that's really a pity. But with such a community and gorgeous achievements such as Guix, and the numerous libraries that have been raining down on us in the past few months, I think there could be some interest in pushing for that project among the webmasters.
<hellekin>Guile sorry
<davexunit>I wonder how guile would fit in with the structure.
<davexunit>there are existing static site generators that could be used
<ijp>a really simple interpreter as a pre-post-order :)
<ijp>Exercise: do the lambda calculus
<hellekin>davexunit: are you flying to Munich?
<davexunit>no, I can't make it.
<davexunit>I'd love to go to a GHM sometime
<davexunit>but it's just not in the cards this time.
<hellekin>me too. Not this time I fear :(
<hellekin>Please Guilers, get a hold on the GNUnet guys and suck in their Social API. Tg will be there, and Mami is a sponge who loves Emacs and LISP, so you can easily convince him to get into Guile ,o)
<cky>hellekin: ..."libraries that have been raining down on us"? Wow. Maybe I should get to porting Rackona to Guile after all. ;-)
<hellekin>cky: what do you need, FFI? Guile has it :)
<hellekin>srsly there were a good number of releases in the last three or four months no?
<nalaginrut>morning guilers~
<nalaginrut>ArneBab: yeah
***siel_ is now known as siel
***endou___ is now known as endou__
***vicenteH` is now known as vicenteH
<davexunit>morning guiles
<davexunit>I am trying to write a function that can serve a static file via guile's web server.
<davexunit>my first implementation read the file as a string, and then wrote that string to the http client port.
<davexunit>is there a way that I can instead read from the input file port and write to the http client port directly?
<janneke>davexunit: i was wondering about that last week
<janneke>let me have a look
<janneke>i was quite surprised that i could not find a generic function for that
<janneke>what i came up with was
<janneke>(define (pipe producer consumer)
<janneke> (with-input-from-string (with-output-to-string producer) consumer))
<davexunit>I can just read it all in as a string for now.
<janneke>i'm afraid that's what my 'pipe' does
<janneke>but we *must* be missing something?
<davexunit>I hope so
<janneke>please let me know/post it to guile-user if you find the real way to do my `pipe'
<davexunit>sure thing
<janneke>davexunit: are you the david that's on guile-gtk-general?
<davexunit>different david
<davexunit>his nick is daviid here
*janneke is waiting for a reply on set of patches to guile-gtk-general, from about one month ago
*janneke 's internet connection resembles early 90's modem times
<davexunit>hmm, how do I write the contents of a bytevector to a port?
<davexunit>can't quite get it.
<davexunit>ah, put-bytevector
<janneke>davexunit: what i truly wonder about with guile as opposed to python
<janneke>is that i figure we all have our own separate libraries to do simple stuff
<janneke>(define (gulp-text-file name)
<janneke> (let* ((file (open-file name "r"))
<janneke> (close file)
<janneke> text))
<janneke>(define (gulp-file file-name)
<janneke> (call-with-input-file file-name get-bytevector-all))
<janneke>(define (dump-file name string)
<janneke> (let* ((file (open-output-file name)))
<janneke> (display string file)
<janneke> (close file)))
<janneke>it just so happens that i didn't need to *write* binary files, only read
<janneke>am i doing things wrong, or how can we somehow avoid re-inventing those basics all ourselves
<davexunit>for gulp-text-file, you can do (with-input-from-string filename read-string)
<janneke>it's sometimes a real put-down that simple things don't seem to be available
<janneke>davexunit: huh? file-name as input-string?
<davexunit>sorry, typo
<janneke>good :-)
<davexunit>(with-input-from-file filename read-string)
*janneke looks up read-string and is amazed he didn't find that earlier
<janneke>thanks, this is great
<janneke>now wonder about my dump-file, is there also a write-string and with output to file?
<janneke>probably something like (define (dump-file file-name string) (with-output-to-file file-name (lambda () (sisplay string))))
<mark_weaver>davexunit: there's 'sendfile', which uses the underlying system call when available.
<davexunit>mark_weaver: awesome, thanks.
<davexunit>I changed to reading static files in as bytevectors. reading in as a string caused an encoding phase to be run that corrupted binary files like images.
<mark_weaver>just keep in mind that 'sendfile' does a binary copy, so not appropriate if you're working with text and the encodings might be different on the two ports.
<mark_weaver>but if the file is UTF-8 and you can assume you're writing to the socket in UTF-8, then it's fine.
<mark_weaver>right, in this case you probably want binary mode anyway :)
<davexunit>yes indeed.
<mario-goulart>guile-gnome developers that may be reading this channel: the instructions in the "git?" section at look outdate. scripts/configure-packages and scripts/pull-packages don't seem to exist.
<janneke>mario-goulart: yes that could be
<janneke>guile-gnome used to be many different git archives but have been merged
<mario-goulart>Where can I find the source repository for guile gstreamer bindings, BTW?
<janneke>mario-goulart: have you tried adding gstreamer to guile-gnome-platform in PACKAGES and run configure?
<janneke>oops, that script is gone too :-(
<janneke>configure, then
<mark_weaver>but I think our gstreamer bindings are far out of date, and not currently usable.
<mark_weaver>the last version I see announced is 0.9.91 from 2007
<mario-goulart>Ah, ok. So probably don't cover gstreamer 1.0.
<mark_weaver>definitely not.
<mario-goulart>Alright. Thanks.
<paroneayea>ijp: btw, maybe relevant to you if you do write the guile->js thing
<paroneayea>python -> javascript, lua, dart
<paroneayea>maybe helpful if you want to look for inspiration from people doing similar stuff
<dsmith-work>Howdy Guilers
<ArneBab>on implementing virtual machines not in C or on the JVM (could be interesting):
<ArneBab>wingo: ^ this could be interesting for your work on native compilation.
<paroneayea>pypy is awesome
<ArneBab>yepp - but actually I write this here because it might contain nice inspiration for the stuff wingo is doing with Guile. Which could lead to stuff like this being the norm:
<ArneBab>wisp 0.6.1:
<davexunit>ArneBab: grats on the release
<ArneBab>it’s just something small - actually stuff I had done weeks ago, but which I had not released.
<ArneBab>unicode + make --quiet ☺
<davexunit>hmm, can't get guile's web server to accept connections from other computers.
<davexunit>I see that the default #:addr is INADDR_LOOPBACK, so I tried changing it to INADDR_BROADCAST but had no luck.
<davexunit>oh, duh. INADDR_ANY
<ijp>you're welcome
<davexunit>sometimes I just have to talk to myself
<davexunit>and the solution becomes apparent
<dsmith-work>davexunit: yes