{{define "title"}}{{end}}

{{define "body"}}

<div class="blurb">
  You're signed in as
  {{template "user" .User}}
  (<form class="inline" method="POST" action="{{routeUrl "sign-out"}}"><input type="submit" class="inline" value="sign out"></form>).
  {{if eq .SettingsSummary.EmailAddress "disabled"}}
    You've disabled emails, but you can still view your digest for your
    GitHub activity in {{.SettingsSummary.RepositoryCount}} repositories below
  {{else}}
    You'll be getting a {{.SettingsSummary.Frequency}} digest of your past
    GitHub activity in {{.SettingsSummary.RepositoryCount}} repositories sent to
    <code>{{.SettingsSummary.EmailAddress}}</code>
  {{end}}
  (<a href="{{routeUrl "settings"}}">change settings</a>).
</div>

{{if ne .SettingsSummary.EmailAddress "disabled"}}
<div class="blurb">
  If you just can't wait, you can get your digest now:
</div>
{{end}}

<div id="primary-actions">
  <form class="inline" method="GET" action="{{routeUrl "view-digest"}}">
    <input type="submit" class="action-button" value="View Digest">
  </form>
  {{if ne .SettingsSummary.EmailAddress "disabled"}}
    or
    <form class="inline" method="POST" action="{{routeUrl "send-digest"}}">
      <input type="submit" class="action-button" value="Email Digest">
    </form>
  {{end}}
</div>

{{if .DetectTimezone }}

<script src="//cdnjs.cloudflare.com/ajax/libs/jstimezonedetect/1.0.4/jstz.min.js"></script>
<script>
  var timezoneName = jstz.determine().name();
  var preferredTimezoneNames = {
    "America/Santa_Isabel": "America/Los_Angeles"
  };
  if (timezoneName in preferredTimezoneNames) {
    timezoneName = preferredTimezoneNames[timezoneName]
  }
  var formData = new FormData();
  formData.append("timezone_name", timezoneName);
  var xhr = new XMLHttpRequest();
  xhr.open("POST", "{{routeUrl "set-initial-timezone"}}", true);
  xhr.send(formData);
</script>

{{end}}

{{end}}
