<commit_before>package uk.co.turingatemyhamster.shortbol.client

import org.widok._

import scala.concurrent.Future

/**
  *
  *
  * @author <NAME>
  */
object TutorialRoutes {
  val routes =
    Route("/", () => TutorialPage(Introduction())) ::
      Route("/yourFirstScript", () => TutorialPage(YourFirstScript())) ::
      Route("/introductionToTypes", () => TutorialPage(IntroductionToTypes())) ::
      Route("/addingSequences", () => TutorialPage(AddingSequences())) ::
      Nil

  val notFound = Route("/404", TutorialNotFound)
}

object Tutorial extends RoutingApplication(
  TutorialRoutes.routes.to[Set],
  TutorialRoutes.notFound
)

trait TutorialContent {
  def navigationEntry: View
  def render(route: InstantiatedRoute): View
}

case class TutorialPage(content: TutorialContent) extends Page {

  override final def render(route: InstantiatedRoute) = Future.successful {
    import org.widok.bindings.HTML._
    import TutorialUtils._
    Container.Generic(
      Header(
        Image("images/logo.png").css("logo"),
        Heading.Level1(v"$shortbol Tutorial")
      ),
      Container.Generic(
        Container.Generic(
          Navigation(
            List.Unordered(
              TutorialRoutes.routes.map { case r@Route(path, page) =>
                page() match {
                  case TutorialPage(tc) =>
                    List.Item(Anchor(tc.navigationEntry).url(r()))
                }
              } :_*
            )
          ),
          content.render(route)
        )
      ).css("tutorialContent"),
      Footer(<commit_msg>Closes #22.<commit_after>package uk.co.turingatemyhamster.shortbol.client

import org.widok._

import scala.concurrent.Future

/**
  *
  *
  * @author <NAME>
  */
object TutorialRoutes {
  val routes =
    Route("/", () => TutorialPage(Introduction())) ::
      Route("/yourFirstScript", () => TutorialPage(YourFirstScript())) ::
      Route("/introductionToTypes", () => TutorialPage(IntroductionToTypes())) ::
      Route("/addingSequences", () => TutorialPage(AddingSequences())) ::
      Nil

  val nav = {
    val rO = routes map Some.apply
    (None :: rO) zip (rO ::: None :: Nil)
  }

  def before(at: Route): Option[Route] =
    nav collectFirst { case (l, r) if r contains at => l } flatten

  def after(at: Route): Option[Route] =
    nav collectFirst { case (l, r) if l contains at => r } flatten

  val notFound = Route("/404", TutorialNotFound)
}

object Tutorial extends RoutingApplication(
  TutorialRoutes.routes.to[Set],
  TutorialRoutes.notFound
)

trait TutorialContent {
  def navigationEntry: View
  def render(route: InstantiatedRoute): View
}

case class TutorialPage(content: TutorialContent) extends Page {
  import org.widok.bindings.HTML._
  import TutorialUtils._

  def prevNext(route: InstantiatedRoute) = {
    val before = TutorialRoutes.before(route.route)
    val after = TutorialRoutes.after(route.route)

    val backTxt = "back" : View
    val forwardTxt = "forward" : View

    val back = before map (r => Anchor(backTxt).url(r())) getOrElse backTxt
    val forward = after map (r => Anchor(forwardTxt).url(r())) getOrElse forwardTxt

    Container.Generic(back, " ", forward).css("back_forward")
  }

  override final def render(route: InstantiatedRoute) = Future.successful {
    Container.Generic(
      Header(
        Image("images/logo.png").css("logo"),
        Heading.Level1(v"$shortbol Tutorial")
      ),
      Container.Generic(
        Navigation(
          List.Unordered(
            TutorialRoutes.routes.map { case r@Route(path, page) =>
              page() match {
                case TutorialPage(tc) =>
                  List.Item(Anchor(tc.navigationEntry).url(r()))
              }
            } :_*
          )
        ),
        content.render(route),
        prevNext(route)
      ).css("tutorialContent"),
      Footer(
{'fraction_non_alphanumeric': 0.13239875389408098, 'fraction_numerical': 0.002596053997923157, 'mean_word_length': 2.773751224289912, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1120922', 'n_tokens_mistral': 1173, 'n_tokens_neox': 1139, 'n_words': 232}