Was this page helpful?

Display Recent Users

     

    Introduction

    This template displays recent user logins.  The log date is not 100% accurate since browsers, cookies and other magical factors are involved.  It is still a very useful way to keep track who is online.

     

    History

    Version Date Author Description
     1.0  Oct 19, 2009  Craig Sivils  Display a list of online/recent users

    Requirements

    • This template requires MindTouch Version: 9.02.x or later (Lyons).
    • You must install the DataTable extension

    How do I install it?

    1. Create a template, call it "Template:RecentUsers" (or rename as you desire).  You must have "unsafecontent" permission for this to work.
    2. Create a "Dekiscript" block on the template page (use the "Style" menu in the editor")
    3. Copy the code from the end of this page and paste it into the Dekiscript block.  To copy, click "expand source", then mouse over the top right corner of the source code, and click the "view source" button.  This will pop up a window with the source code.  Select all, then copy to clipboard.
    4. Make sure there isn't an extra blank paragraph after the Dekiscript block! Do this every time you edit!!!  
    5. Save.

     

    A quick note about the examples on this page

    For all the examples on this page, the code is shown before the working example.  The code is shown with the syntax extension, and looks like this:

    RecentUsers();

    This means that the actual code on the page should be enclosed in a DekiScript block.  If you want to copy the code from this page, then use the same procedure as described in steps 2-4 above. 

    How do I use it?

     

    Arguments

    Name
    Type
    Default
    Description
     limit  number  100  The number of users to display

    Examples

     

    RecentUsers(100);
    
    UserLast Login
    FrancescoFlyzik2012-05-16 17:00:53Z
    FreddyCarlos2012-05-16 17:00:13Z
    BradleyYarn2012-05-16 17:00:09Z
    GordonUhlir2012-05-16 16:59:38Z
    ChaunceyWirtanen2012-05-16 16:59:31Z
    DougZaman2012-05-16 16:58:34Z
    GregoryJentsch2012-05-16 16:58:10Z
    HarlanTompkins2012-05-16 16:57:49Z
    MerrillZito2012-05-16 16:57:35Z
    BoyceRisk2012-05-16 16:57:06Z
    VirgilKapaun2012-05-16 16:55:44Z
    ElishaGoodfield2012-05-16 16:55:42Z
    RobtTutson2012-05-16 16:54:15Z
    RodneyNorris2012-05-16 16:53:00Z
    BobMartinov2012-05-16 16:52:52Z
    ShonDuguette2012-05-16 16:52:25Z
    JohnieBarbin2012-05-16 16:52:18Z
    KyleFaucette2012-05-16 16:52:11Z
    HobertBotdorf2012-05-16 16:51:22Z
    AlexisFisser2012-05-16 16:51:08Z
    MilanTokarz2012-05-16 16:50:37Z
    LouisMeline2012-05-16 16:49:56Z
    BrittBendit2012-05-16 16:49:23Z
    MosesBohonik2012-05-16 16:48:55Z
    JuniorDilallo2012-05-16 16:48:46Z
    ScottyTryner2012-05-16 16:48:34Z
    RaleighRicketts2012-05-16 16:48:11Z
    RoyalKaluzny2012-05-16 16:47:56Z
    DomenicFlorestal2012-05-16 16:47:18Z
    JameyFrohlich2012-05-16 16:46:41Z
    EmilioStoviak2012-05-16 16:45:56Z
    KentonBaskow2012-05-16 16:45:32Z
    LonnyGunby2012-05-16 16:45:27Z
    HymanGideon2012-05-16 16:44:49Z
    ArtHayman2012-05-16 16:44:15Z
    GuillermoBlatt2012-05-16 16:44:13Z
    XavierBrackin2012-05-16 16:43:43Z
    EmilioSkutt2012-05-16 16:43:12Z
    AbdulEsquerre2012-05-16 16:43:09Z
    ShelbyMaiolo2012-05-16 16:42:19Z
    WillCharves2012-05-16 16:41:04Z
    jtyler2012-05-16 16:28:44Z
    RamonTsinnie2012-05-16 16:24:49Z
    LaurenNaschke2012-05-16 16:24:38Z
    FedericoHavice2012-05-16 16:24:01Z
    AlexBosner2012-05-16 16:15:16Z
    craig.slawson2012-05-16 15:03:31Z
    alexis.bedon2012-05-16 13:14:38Z
    maicalicr2012-05-16 12:54:33Z
    Adminstrador2012-05-16 12:52:33Z
    bohappa2012-05-16 12:25:16Z
    quhaqueroll2012-05-16 10:18:43Z
    wendyg2012-05-16 09:28:18Z
    drdran2012-05-16 07:44:25Z
    FormidableInc2012-05-16 07:33:21Z
    duncanc2012-05-16 04:55:34Z
    pmcdonne2012-05-16 00:50:46Z
    groovecoder2012-05-15 19:15:50Z
    michaeldp2012-05-15 17:50:54Z
    Brig2012-05-15 14:02:38Z
    gu2ga22012-05-15 07:35:37Z
    markbell2012-05-14 21:08:47Z
    gouwzee2012-05-14 20:57:47Z
    admin2012-05-14 20:55:21Z
    Jon2012-05-14 16:05:30Z
    oso2012-05-14 10:04:33Z
    gupoxaj2012-05-14 07:52:57Z
    krishchant2012-05-14 05:42:44Z
    coreyg2012-05-14 03:46:17Z
    xiaopig2012-05-14 03:44:52Z
    jamesv2012-05-14 03:34:02Z
    ryan.durfey@level3.com2012-05-14 03:02:19Z
    Phil2012-05-14 00:57:58Z
    leoutletoutlet2012-05-13 10:35:14Z
    hsikaria2012-05-13 05:08:30Z
    cocardoso2012-05-12 20:08:57Z
    augustoz2012-05-12 09:59:02Z
    ReinerB2012-05-12 00:41:07Z
    SteveB2012-05-11 19:13:56Z
    yurig2012-05-11 19:11:36Z
    chuxd2012-05-11 15:47:19Z
    dwaweru2012-05-11 15:09:46Z
    peteben2012-05-11 12:59:07Z
    kingmario2012-05-11 07:25:28Z
    Jsohoopm122012-05-11 07:14:54Z
    chux2012-05-11 04:40:03Z
    hwangsun2012-05-11 01:24:03Z
    chuckpearson2012-05-11 01:19:11Z
    dmccoy2012-05-10 03:06:42Z
    jolmes2012-05-09 19:50:40Z
    mirhonda2012-05-09 19:12:14Z
    sirdodger2001-01-01 06:00:00Z
    tomstearns2001-01-01 06:00:00Z
    dmreiland2001-01-01 06:00:00Z
    mzeecedric2001-01-01 06:00:00Z
    sjb2001-01-01 06:00:00Z
    robertmorrison2001-01-01 06:00:00Z
    navjeet12001-01-01 06:00:00Z
    ujo_imro2001-01-01 06:00:00Z
    wbackes2001-01-01 06:00:00Z

     

    Reference(s)

     

    Credits/Special Thanks

    Thank you to sborny09 for a forum post with the API call and SteveB for cleaning up my code.

     

    Template/Extension Source Code

    datatable{ options: { aaSorting: ["2","desc"], sPaginationType: "full_numbers", iDisplayLength:10  } };
    var limit = $limit ?? $0 ?? 100;
    var users_xml = wiki.api(site.api & 'users' & { sortby: "-date.lastlogin", limit: limit });
    var user_data = [ 
        { nick: xml.text(usr, 'nick'), lastlogin: xml.text(usr, 'date.lastlogin') } 
        foreach var usr in xml.select(users_xml, '/users/user')
    ];
    let user_data = list.sort(user_data, 'lastlogin', true);
    <table cellspacing="3" cellpadding="3" border="1">
        <thead>
                <tr>
                    <th>"User"</th>
                    <th>"Last Login"</th>
                </tr>
        </thead>
        <tbody>
            foreach(var user_datum in user_data) {
                <tr>
                    <td> web.link(wiki.getuser(user_datum.nick).uri, user_datum.nick) ?? 'Nickname' </td>
                    <td> date.format(date.ChangeTimezone(user_datum.lastlogin,user.timezone),"u") ?? 'Last login' </td>
                </tr>
            }
        </tbody>
    </table>

     

    Disclaimers

    The page feature does not work until a users clicks on a column heading, changes the number of records to display drop down or types inside the search box.  This seems to be an issue with the datatables JS code.

    None.

    Was this page helpful?
    Tag page
    Viewing 2 of 2 comments: view all
    i tweaked the code to work as a bulleted list, with normal times/dates, here it is:

    <h4>"Wiki most recent logins"</h4>;
    <p>

    var limit= $limit ?? $0 ?? 20;
    var users_xml = wiki.api(uri.build(site.api, ['users']).."?sortby=-date.lastlogin&limit="..limit);
    var user_data;
    foreach (var user_index in num.series(0,#xml.list(users_xml,'/users/user/nick'))) {
    let user_data ..= [ { nick: xml.list(users_xml,'/users/user/nick')[user_index], lastlogin: xml.list(users_xml,'/users/user/date.lastlogin')[user_index] } ];
    }
    let user_data = list.sort(user_data,'lastlogin',true);
    let user_data = list.reverse(list.splice(list.reverse(user_data), limit)); // removes the first entry which is always blank -- not sure why
    <ul>
    foreach (var user_datum in user_data) <li> <a href=(site.uri .. "User:" .. user_datum.nick)>user_datum.nick</a> " (" .. date.Format(user_datum.lastlogin, "hh:mmtt M-d-yyyy") .. ")"; </li>;
    </ul>

    </p>;
    Posted 23:13, 15 Feb 2010
    Output looks like this (user names are links to that user):

    Wiki most recent logins

    * jvervill (07:10AM 2-16-2010)
    * Anonymous (07:09AM 2-16-2010)
    * LLIGHTY (07:56PM 2-4-2010)
    * gengap (08:35PM 2-3-2010)
    * BTHOMAN (07:21PM 2-1-2010)
    * wlee7 (02:12PM 1-28-2010)
    * mdsteine (03:54PM 1-7-2010)
    * acarogla1 (01:51PM 1-7-2010)
    * tests2 (01:23AM 1-6-2010)
    * tests (01:18AM 1-6-2010)
    * jpjpjp (01:14AM 1-6-2010)
    * vsank (04:00PM 1-5-2010)
    * carlos.westhelle (08:37PM 1-4-2010)
    * fhall (05:24PM 12-30-2009)
    * GCRUM (04:16PM 12-22-2009)
    * mike.viens (07:38PM 12-19-2009)
    * jvervill1 (09:12PM 12-18-2009)
    * Erik.Burgess (03:40PM 12-17-2009)
    * eburgess1 (02:50PM 12-17-2009)
    * eburgess (02:43PM 12-17-2009)
    Posted 23:14, 15 Feb 2010
    Viewing 2 of 2 comments: view all
    You must login to post a comment.

    Copyright © 2011 MindTouch, Inc. Powered by