@charset UTF-8;

/* BASE Tag */
.base {
  =environment/base: CONTEXT_URI;
  |attribute: href '${#base}';
}

/* listing */
.forum {
  $messages;
  $parameters;
  
  @use-attribute: view session;
  @default-to: view 'list';
  @default-to: parameters.offset 0;
  @default-to: pageSize 20;
  @default-to: paginateSize 10;
}

.forum .messages-exist {
  present: message-list;
}

.forum .row {
  iterate: message-list message;
}

.forum .more {
  equal: true '${message:abridged}';
}

.forum .no-messages {
  not-present: message-list;
}

.form {
  [equal: '${parameters.switch}' 'true'; |restore;]
}
.form .author {
  $cookies;
  [not-equal: '${parameters.switch}' 'true'; |restore: cookies;]
}

.text {
  @-forum-htmlbr: '${message:text}' text;
  |unescape;
}

.attachment {
  not-equal: 0 '${message:attachment}';
}

/* list view */
.forum .list-view {
  equal: '${view}' 'list';
  =-forum-list-view/message-list: '${pageSize}' '${parameters.offset}';
  @populate: message-list message-count;
}

/* thread view */
.forum .thread-view {
  equal: '${view}' thread;
  =-forum-thread-view/message-list: '${pageSize}' '${parameters.offset}';
  @populate: message-list message-count;
}

/* pagination */
.forum .paging {
  =paginate/pages: '${parameters.offset}' '${pageSize}' '${paginateSize}' '${message-count}';
  present: pages;
}

.forum .pages {
  iterate: pages i;
}

.forum .other-page {
  not-equal: '${i:offset}' '${parameters.offset}';
  |attribute: href 'forum.html?offset=${i:offset}';
}

.forum .current-page {
  equal: '${i:offset}' '${parameters.offset}';
}

/* show message */
.message {
  $parameters;
  $messages;
  =-forum-message/message: '${parameters.id}';
}

.message .quote {
  @-forum-quote: '${message:text}' quote;
  |unescape;
}

/* error messages */
.info {
  iterate: messages.info m;
}

.invalid {
  iterate: messages.invalid m;
}

.error {
  iterate: messages.error m;
}