+ Reply to Thread
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 15

Thread: Is it possible to show images into dhtml.table using channels?

  1. #1
    Join Date
    Apr 2009
    Location
    Bulgaria, Europe
    Posts
    111

    Question Is it possible to show images into dhtml.table using channels?

    Hello!

    Is it possible to show images into dhtml.table using channels? And how to?

  2. #2
    Join Date
    Mar 2008
    Posts
    1,630

    Default

    No, it is not possible. But that doesn't mean it's impossible.

    The stock dhtml.table() function always outputs text, period. So I threw together a new template, dhtml_table_plus, that extends the functionality just a bit. You use it just like dhtml.table(), except that if a field name ends in "HTML" (case insensitive), the message text will be interpreted as HTML rather than plain text.

    See it in action.

    Not well tested, but seems to work. The template would be easy to hack to customize the appearance as desired.

    Enjoy.

  3. #3
    Join Date
    Apr 2009
    Location
    Bulgaria, Europe
    Posts
    111

    Default

    Wow! Great, thank You very much! May be it is a good idea this template to be embedded in standard DekiScript library some day! It will be very powerful.

  4. #4
    Join Date
    Apr 2009
    Location
    Bulgaria, Europe
    Posts
    111

    Default

    How could I use this template with conjunction with ImageMagick. image.* functions are returning some kind of local URI. How could I transform it to "outside accessible" URI? To make it possible to display on that new table.

  5. #5
    Join Date
    Mar 2008
    Posts
    1,630

    Default

    You'll need to be a bit more specific than that. Exactly what do you want to do?

  6. #6
    Join Date
    Apr 2009
    Location
    Bulgaria, Europe
    Posts
    111

    Default

    I have large pictures attached to different pages in Deki. I have script that gather those pictures URLs and some other info and pass them to image.fittosize(). Then I would like to pipe them through a channel to that table you made. I would like to separate gathering code from table for easy use as different templates. That is why I'm using channels.

  7. #7
    Join Date
    Mar 2008
    Posts
    1,630

    Default

    Well, I can't get image.fittosize to work at all on my Wiki, and it seems like the ImageMagick extension is not running on the MCP. So I can't test it. If it is returning one of those funky local URIs, you're probably out of luck.

    You don't strictly need image.fittosize() for wiki attachments, though. Depending on how you're identifying the images you want to use (list of URLs? Search?) you can get the dimensions from the API and set the width or height of the <img> object passed in the message sent from Pagebus.publish(). If you give me an idea how you're generating your list of images, I can help out with that.

    Now that I understand your use case, though, I'm not super enthusiastic about using channels to solve your problem. That stuff is really designed to handle dynamic page construction given client interactions, whereas your application could be done completely on the server side. I don't think it would in any way hinder your ability to keep the table generator and the image gathering separate. But ultimately that's up to you.

  8. #8
    Join Date
    Apr 2009
    Location
    Bulgaria, Europe
    Posts
    111

    Default

    The idea is to have two script commands: {{ UserList() }} that is pushing user profiles (custom profiles). And a DHTML table that is listening to the default channel that could be configured easily by our stuff to display only certain columns including ones that have people's pictures. May be it is good idea to scale on HTML, not on the server-side. This may speed-up page loading. Because now it takes from 3 to 6 seconds to load the page with about 60 users.

  9. #9
    Join Date
    Mar 2008
    Posts
    1,630

    Default

    Ah, I see what you're doing (mostly). That is pretty clean, though I can almost certainly assure that the 3-6 seconds is being driven by UserList(), not the table. But whatever.

    So basically, we just need to design out image.fittosize(). Can you give me an idea of how UserList() works right now?

  10. #10
    Join Date
    Apr 2009
    Location
    Bulgaria, Europe
    Posts
    111

    Default

    Now it does something like this:
    var usersURLs = list.apply( list.select( site.users, "!$.anonymous && $.name!='Admin'"), "$.Uri" );
    foreach( var userURL in usersURLs ) {
    let userName = uri.parts( userURL ).path[0];
    let userPage = wiki.page( userName );
    let name = xml.text( userPage, "//div[@id='name']" );
    .... // parsing different fields of the profile
    pagebus.publish( publish, fields );
    }

+ Reply to Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts