Skip to content

Instantly share code, notes, and snippets.

@jamiewilson
Last active August 29, 2015 14:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jamiewilson/6694201b837d19092f15 to your computer and use it in GitHub Desktop.
Save jamiewilson/6694201b837d19092f15 to your computer and use it in GitHub Desktop.
Creating a Member Directory for Telescope

I'm trying to create a Member Directory. This is a public list of all invited users with links back to their complete profiles.

First, I published a list of invited users:

// server/member_publication.js

Meteor.publish("members", function () {
  return Meteor.users.find({isInvited: true});
});

Next I created a new route and subscribed to the members publication:

// members.js

Router.route('/members', {
  name: 'members',
  loadingTemplate: 'loadingWeld',
  template: getTemplate('membersPage'),
  waitOn: function() {
    return Meteor.subscribe('members'); 
  },
  fastRender: true
});

Third, I created a the members_page.html and member_item.html templates:

<!-- members_page.html -->

<template name="membersPage">
  {{#each members}}
    {{> memberItem}}
  {{/each}}
</template>
<!-- member_item.html -->

<template name="memberItem">
  <a class="member-wrap" href="{{profileUrl this}}" target="_blank">
      <div class="member">
        {{> avatar user=this size="large" shape="circle"}}
        <div class="username">{{profile.name}}</div>
        <div class="profile-skills">Specialties: {{profile.skills}}</div>
        <div class="profile-location">Location: {{profile.location}}</div>
      </div>
      <div class="about">
        <div class="username">{{profile.name}}</div>
        <p class="profile-blurb truncate">{{profile.bio}}</p>
        <p class="view-more">View Profile</p>
      </div>
    </a>
</template>

Lastly, I created a couple of template helpers:

// members_page.js

Template[getTemplate('membersPage')].helpers({
  members: function () {
    return Meteor.users.find();
  }
});

Template.memberItem.rendered = function (){
  $("p.truncate").dotdotdot({
    watch: "window"
  });
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment