## The contents of this file are subject to the Common Public Attribution
## License Version 1.0. (the "License"); you may not use this file except in
## compliance with the License. You may obtain a copy of the License at
## http://code.reddit.com/LICENSE. The License is based on the Mozilla Public
## License Version 1.1, but Sections 14 and 15 have been added to cover use of
## software over a computer network and provide for limited attribution for the
## Original Developer. In addition, Exhibit A has been modified to be
## consistent with Exhibit B.
##
## Software distributed under the License is distributed on an "AS IS" basis,
## WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
## the specific language governing rights and limitations under the License.
##
## The Original Code is reddit.
##
## The Original Developer is the Initial Developer.  The Initial Developer of
## the Original Code is reddit Inc.
##
## All portions of the code written by reddit are Copyright (c) 2006-2015
## reddit Inc. All Rights Reserved.
###############################################################################

<%!
   from r2.lib.strings import strings, Score
   from r2.lib.pages import WrappedUser, UserText
   from r2.lib.template_helpers import _ws
 %>

<%namespace file="utils.html" import="plain_link, thing_timestamp, text_with_links"/>
<%namespace file="printablebuttons.html" import="ynbutton, state_button" />

<div class="titlebox multi-details" data-path="${thing.multi.path}">
  <h1 class="hover redditname">
    <a href="${thing.multi.path}">${_('%s subreddits') % thing.multi.name}</a><div class="throbber"></div>
  </h1>
  <h2><a href="/user/${thing.multi.owner.name}">${_('curated by /u/%s') % thing.multi.owner.name}</a></h2>
  <div class="gray-buttons settings">
    %if thing.can_edit:
      <span class="visibility-group">
        <label><input type="radio" name="visibility" value="private" ${'checked' if thing.multi.visibility == 'private' else ''}>${_('private')}</label>
        <label><input type="radio" name="visibility" value="public" ${'checked' if thing.multi.visibility == 'public' else ''}>${_('public')}</label>
      </span>
      %if thing.can_copy:
        <button class="show-copy">${_('copy')}</button>
      %endif
      %if thing.can_rename:
        <button class="show-rename">${_('rename')}</button>
      %endif
      <button class="delete">${_('delete')}</button>
    %else:
      %if thing.can_copy:
        <button class="show-copy">${_('create a copy')}</button>
      %endif
    %endif
  </div>

  %if thing.can_copy:
    <form class="copy-multi">
      <input type="text" class="multi-name" placeholder="${_('copy name')}"><button class="copy">${_('copy')} &rsaquo;</button>
      <div class="throbber"></div>
      <div class="error copy-error"></div>
    </form>
  %endif

  %if thing.can_rename:
    <form class="rename-multi">
      <p class="warning">${_('warning: renaming a multi will break any links and references to the old name.')}</p>
      <input type="text" class="multi-name" placeholder="${_('new name')}"><button class="rename">${_('rename')} &rsaquo;</button>
      <div class="throbber"></div>
      <div class="error rename-error"></div>
    </form>
  %endif

  <div class="description">
    ${UserText(None, text=thing.description_md, post_form=None, editable=True, include_errors=False)}
    %if thing.can_edit:
      <div class="gray-buttons settings">
        <button class="edit-description">${_('edit description')}</button>

        %if thing.share_url:
          <a class="share-in-sr" href="${thing.share_url}">${_('share')} &rsaquo;</a>
        %endif
      </div>
    %endif
  </div>

  <h3>${unsafe(_ws('%(count)s subreddits in this multi:') % dict(count='<span class="count">%d</span>&#32;' % len(thing.srs)))}</h3>
  <ul class="subreddits">
  %for sr in thing.srs:
    <li data-name="${sr.name}">
      <a href="/r/${sr.name}">/r/${sr.name}</a>
      <button class="remove-sr">${_('remove')}</button>
    </li>
  %endfor
  </ul>

  %if thing.can_edit:
    <form class="add-sr">
      ${thing.subreddit_selector}
      <div class="error add-error"></div>
    </form>
  %endif

  <div class="bottom">
    %if thing.multi.owner:
      ${unsafe(_ws("created by %(user)s").replace(" ", "&#32;") % dict(user = unsafe(WrappedUser(thing.multi.owner).render())))}
    %endif

    <span class="age">
      ${_("a multireddit for")}&#32;${thing_timestamp(thing.multi)}
    </span>
  </div>

  <div id="multi-recs" class="recommend-box">

    <div class="recs">
      <div>
        <h1>
          ${_("people also added:")}
        </h1>
      </div>
      <ul class="recommendations"></ul>
      <span class="more">${_("more suggestions")}</span>
    </div>

    <div class="endoflist">
      <h1>${_("no more suggestions!")}</h1>
      <div class="heading">${_("would you like to...")}</div>
      <ul>
        <li>
          <a href="/r/ModeratorDuck/wiki/subreddit_classification" target="_blank">
            ${_("check out subreddits by category")}
          </a>
        </li>
        <li>
          <a href="/r/random" target="_blank">
            ${_("explore a random subreddit")}
          </a>
        </li>
        <li>
          <a class="reset">
            ${_("see the suggestions again")}
          </a>
        </li>
      </ul>
    </div>

  </div>
</div>
