hummingbird-me/hummingbird

View on GitHub
frontend/app/templates/story/comment.hbs

Summary

Maintainability
Test Coverage
<div {{bind-attr class=":update-panel model.isNew"}}>
  <div class="row">
    <div class="user-info-bar">
      <div class="user-image">
        {{#link-to 'user' model.poster}}
          {{unbound avatar model.poster "thumb_small"}}
        {{/link-to}}
      </div>
      <div class="comment-content">
        <h4 class="story-title">
          {{#link-to 'user' model.poster}}{{unbound model.poster.username}}{{/link-to}}
          {{#unless selfPost}}
            <i class="fa fa-share reply-icon"></i>
            {{#link-to 'user' model.user}}{{unbound model.user.username}}{{/link-to}}
          {{else}}
            {{#if model.user.isPro}}
              {{#link-to 'pro'}}<span class="mini-badge">pro</span>{{/link-to}}
            {{/if}}
            {{#if model.group}}
              {{! don't show this if we are actually on the group page }}
              {{#unless isOnGroupPage}}
                posted to
                {{#link-to 'group' model.group}}{{unbound model.group.name}}{{/link-to}}
              {{/unless}}
            {{/if}}
          {{/unless}}
        </h4>
        <p class="secondary">
          {{time-ago time=model.createdAt}}
          ·
          {{#link-to 'story.permalink' model class="permalink"}}
            permalink
          {{/link-to}}
          {{#if model.canToggleNSFW}}
            ·
            <a class="remove-post" {{action "toggleNSFW"}}>
              {{#if model.adult}}remove{{else}}set{{/if}} nsfw
            </a>
          {{/if}}
          {{#if model.canDeleteStory}}
            ·
            <a class="remove-post" {{action "deleteStory"}}>remove</a>
          {{/if}}
        </p>
      </div>
    </div>
  </div>
  <div class="row">
    <div class="post-content clearfix">
      {{#if collapsed}}
        <a {{action "showCollapsedPost"}}>Show NSFW Content</a>
      {{else}}
        <p {{bind-attr class=":comment-text isExpanded:full-post" }}>
          {{#if model.isNew}}
            {{unbound model.comment}}
          {{else}}
            {{{unbound model.comment}}}
          {{/if}}
        </p>
      {{/if}}
    </div>
  </div>
  {{#if overflowing}}
    <div class="row view-more">
      <a {{action "toggleFullPost"}}>{{showMoreText}}</a>
    </div>
  {{/if}}
</div>

<div class="story-actions">
  {{#if model.adult}}
    <span class="nsfw-indicator" data-tooltip="This post has been marked as nsfw!">
      <i class="fa fa-warning"></i>
    </span>
  {{/if}}
  <a {{bind-attr class=":like model.isLiked:active"}} {{action "toggleLike"}}>
    <i class="fa fa-heart-o"></i> {{model.totalVotes}}
  </a>
  <ul class="active-users">
    {{#each model.recentLikers as |liker|}}
      <li {{bind-attr data-tooltip=liker.username}}>
        {{#link-to 'user' liker.id}}
          {{unbound avatar liker "thumb_small"}}
        {{/link-to}}
      </li>
    {{/each}}
    {{#if showExtraLikers}}
      <li>
        <a {{action "openModal" "story-likes" this}}>
          <span class="more-users">{{extraLikers}}</span>
        </a>
      </li>
    {{/if}}
  </ul>
</div>

<div class="comment-replies">
  {{#if collapsed}}
    <div class="view-more">Comments Hidden</div>
  {{else}}
    {{#if moreThanTwoSubstories}}
      <div class="view-more">
        {{#if loadingAll}}
          <i class="fa fa-spin fa-spinner"></i>
        {{else}}
          <a {{action "toggleShowAll"}}>
            {{#if showAll}}
              Show Less
            {{else}}
              Show {{pluralize model.omittedSubstoryCount "more reply" "more replies"}}
            {{/if}}
          </a>
        {{/if}}
      </div>
    {{/if}}
    {{#each reversedDisplaySubstories as |substory|}}
      <div {{bind-attr class=":reply substory.isNew"}}>
        <div class="user-avatar">
          {{#link-to 'user' substory.user}}
            {{unbound avatar substory.user 'thumb_small'}}
          {{/link-to}}
        </div>
        <div class="content">
          <p>
            <span class="username">
              {{#link-to 'user' substory.user}}
                {{unbound substory.user.username}}
              {{/link-to}}
            </span>
            <span class="comment">
              {{#if substory.isNew}}
                {{unbound substory.reply}}
              {{else}}
                {{{unbound substory.reply}}}
              {{/if}}
            </span>
          </p>
          <div class="secondary">
            {{time-ago time=substory.createdAt}}
            {{#if substory.canDeleteSubstory}}
              ·
              <a class="remove-post" {{action "deleteSubstory" substory}}>remove</a>
            {{/if}}
          </div>
        </div>
      </div>
    {{/each}}
    {{#if currentUser.isSignedIn}}
      {{#if model.group}}
        {{#if model.group.currentMember}}
          {{#unless model.group.currentMember.pending}}
            <div class="reply-form">
              {{expanding-textarea value=reply rows="1" placeholder="Leave a comment..." enterAction="submitReply"}}
            </div>
          {{/unless}}
        {{/if}}
      {{else}}
        <div class="reply-form">
          {{expanding-textarea value=reply rows="1" placeholder="Leave a comment..." enterAction="submitReply"}}
        </div>
      {{/if}}
    {{/if}}
  {{/if}}
</div>