<head>
  <title>image_share</title>
</head>

<body>
  {{> image_add_form }}

  <nav class="navbar navbar-default navbar-fixed-top">
    <div class="container">
      {{> loginButtons }}
    </div>
  </nav>

  <div class="container">
    <h1>Welcome to image share {{ username }} !</h1>

    {{> images}}
  </div>
</body>

<template name="image_add_form">

  <div class="modal fade" id="image_add_form">
    <div class="modal-dialog">
      <div class="modal-content">
        <div class="modal-header">
          <div class="modal-title"></div>
        </div>
        <div class="modal-body">
          <form class="js-add-image">
            <input type="text" name="img_src" />
            <br /><input type="text" name="img_alt" />
            <button class="btn btn-success">save</button>
          </form>
        </div>
        <div class="modal-footer">
          <button class="btn btn-warning" data-dismiss="modal">cancel</button>
        </div>
      </div>
    </div>

  </div>

</template>

<template name="images">
  {{#if currentUser }}
    <button class="btn btn-success js-show-image-form">add image</button>
  {{/if}}
  <div class="row">
    {{#each images}}
      <div class="col-xs-12 col-md-3" id="{{_id}}">
        <div class="thumbnail">

          <img class="thumbnail-img js-image" src="{{img_src}}" alt="{{img_alt}}" />

          <div class="caption">
            <h3>Rating: {{ rating }}</h3>
            <p>{{ img_alt }}</p>
            <p>{{> starsRating mutable=true class="js-rate-image" id=image_id }}</p>
            <button class="js-del-image btn btn-warning">delete</button>
          </div>
        </div>
      </div> <!-- / col -->
    {{/each}}
  </div> <!-- / row -->
</template>
