COM-FSM
Template:MindTouch > Views > Activity Dashboard

Activity Dashboard

Page last modified 14:15, 31 Oct 2010 by Admin
    Table of contents
    No headers
    <link href="/skins/common/templates/activitydashboard.css" rel="stylesheet" type="text/css" />
    
    try {
        // set page-level user details
        var ActivityUser = page.namespaceuser;
        var userDetails = wiki.api(ActivityUser.api);
    } catch {
        <span class="error-dekiscript">wiki.localize('MindTouch.Templates.UserProfile.error.initialization');</span>
        web.showerror(__error);
        return;
    };
    
    <div id="deki-activity-dashboard">
    <div id="col-left">
    
    /*
     * User Profile Information Box 
     */
    <div id="deki-profile" class="deki-dashboard-group">
    try {
        <div class="dashboard-title">
            <div class="profile-name">
                #ActivityUser.fullname > 0 ? ActivityUser.fullname : ActivityUser.name;
    
                var status = xml.text(userDetails, 'status');
                status == 'active' ? '' : ' (' .. wiki.localize('MindTouch.Templates.UserProfile.status.disabled') .. ')';
            </div>
        </div>
    
        <div class="profile-image">
            ActivityUser.Gravatar
        </div>
        <dl class="profile-details">
            var loginDate = date.parse(xml.text(userDetails, 'date.lastlogin'));
            <dt>wiki.localize('MindTouch.Templates.UserProfile.label.lastlogin') .. ': ';</dt>
            <dd class="dashboard-lastlogin">Template('MindTouch/Controls/DateTime', {date:loginDate, format:'datetime'});</dd>
            <dt>
                wiki.localize('MindTouch.Templates.UserProfile.label.joined') .. ': '
            </dt>
            <dd class="profile-joined">
                var joinDate = date.parse(xml.text(userDetails, 'date.created'));
                Template('MindTouch/Controls/DateTime', {date:joinDate, format:'date'})
            </dd>
            <dt>
                wiki.localize('MindTouch.Templates.UserProfile.label.timezone') .. ': ';
            </dt>
            <dd class="profile-timezone">
                ActivityUser.timezone;
            </dd>
            if (#ActivityUser.language > 0 && ActivityUser.language != site.language) {
            <dt>
                wiki.localize('MindTouch.Templates.UserProfile.label.language') .. ': '
            </dt>
            <dd class="profile-language">
                ActivityUser.language;
            </dd>
            }
            var groups = userDetails['groups/group'];
            if (#groups > 0) {
            <dt>
                wiki.localize('MindTouch.Templates.UserProfile.label.groups') .. ': '
            </dt>
            <dd class="profile-groups">
                string.join(list.sort([ xml.text(g["groupname"]) foreach var g in groups ]), ", ");
            </dd>
            }
        </dl>
        <div class="clear" />
    } catch {    
        <span class="error-dekiscript">wiki.localize('MindTouch.Templates.UserProfile.error.profile');</span>
        web.showerror(__error);
    };
    </div> // end deki-profile
    
    /*
     * Recent Comments Dashboard Box
     */
    <div id="deki-recent-comments" class="deki-dashboard-group">
    try {
    	<div class="dashboard-title">wiki.localize('MindTouch.Templates.UserProfile.label.comments', ['@' .. ActivityUser.name]);</div>
    
    	var dependencies = Template("MindTouch/Controls/DependencyErrors", {
    	    components:[
    	        {name: "activitystream", sid: "sid://mindtouch.com/std/2009/04/activitystream"}
    	    ]
    	});
    
    	if (!#dependencies["//div"]) {
    	
    	    var activities = activitystream.timeline(ActivityUser.name, 10);
    	
    	    if (#activities > 0) {
    	        foreach (var a in activities) {
    	        <div class="activity-comment">
    	            <div class="activity-avatar">
    	                <img src=(a.user.gravatar) height="30px" />
    	            </div>
    	            
    	            <div class="activity-meta">
    	            <div class="activity-from">
    	                <span class="activity-name">a.user.name</span>
    	                <span class="activity-page">
    	                    ' ' .. wiki.localize('MindTouch.Templates.UserProfile.comment.on') .. ' ';
    	                    a.page.uri ? web.link(a.page.uri, a.page.title) : wiki.localize('MindTouch.Templates.UserProfile.empty.page');
    	                </span>
    	
    	                <div class="activity-date">Template('MindTouch/Controls/DateTime', {date:a.time, format:'datetime'})</div>
    	            </div>
    	            <div class="activity-text"> a.content </div>
    	            </div> // end meta
    	        </div> // end comment
    	       } // end foreach
    	    } // end if
    	    else {
    	        <div class="dashboard-message">
    	            wiki.localize('MindTouch.Templates.UserProfile.empty.comments');
    	        </div>
    	    }
    	}
    	else {
    	    if (#dependencies["//a[contains(@rel, 'component-missing')]"]) {
    	        dependencies;
    	    } else {
    	        <div class="dashboard-commercial-text">
    	            <div class="dashboard-commercial-message">
    	                var link = web.link('http://mindtouch.com/redir/activity-stream/', wiki.localize('MindTouch.Templates.UserProfile.error.commercial.link'));
    	                wiki.localize('MindTouch.Templates.UserProfile.error.commercial', [link]);
    	            </div>
    	        </div>
    	    }
    	}
    } catch {
        <span class="error-dekiscript">wiki.localize('MindTouch.Templates.UserProfile.error.comments');</span>
        web.showerror(__error);
    };
    
    </div> // end recent-comments
    </div> // end col-left
    
    <div id="col-right">
    
    /*
     * Recent User Activities
     */
    <div id="deki-recent-changes" class="deki-dashboard-group">
    try {
        <div class="dashboard-title">wiki.localize('MindTouch.Templates.UserProfile.label.changes')</div>
       
        var feedUri = ActivityUser.api & 'feed' & {limit: 10, format: 'raw'};
        var changes = wiki.api(feedUri)['change'];
    
        if (#changes > 0) {
            <ul>
            foreach (var c in changes) {
    
                var pageId =  xml.num(c, 'rc_cur_id');
                var page = wiki.getPage(pageId);
                var changeDate = date.parse(xml.text(c, 'rc_timestamp'), 'yyyyMMddHHmmss');
                var pageExists = xml.num(c, 'rc_page_exists');
                var pageTitle = xml.text(c, 'rc_title');
    
                 <li>
                    pageExists ? web.link(page.uri, page.title) : pageTitle;
                    <div class="recentchanges-date">Template('MindTouch/Controls/DateTime', {date:changeDate, format:'date'})</div> 
                    <div class="recentchanges-details">
                        <span class="dashboard-change">xml.text(c, 'rc_comment');</span>
                    </div>
                </li>
            }
            </ul>
    
            <div class="deki-dashboard-group-footer">
                web.link('/Special:Contributions?target=' .. ActivityUser.name,
                   wiki.localize('MindTouch.Templates.UserProfile.label.allchanges', [ActivityUser.name]));
            </div>
        }
        else {
            <div class="dashboard-message">
                wiki.localize('MindTouch.Templates.UserProfile.empty.changes');
            </div>
        }
    } catch {
        <span class="error-dekiscript">wiki.localize('MindTouch.Templates.UserProfile.error.changes');</span>
        web.showerror(__error);
    };
    
    </div> // end deki-recent-changes
    </div> // end col-right
    </div> // end deki-activity-dashboard
    
    Powered by MindTouch Core