<commit_before>package spa.client.modules

import spa.client.components.Icon
import spa.client.logger._
import spa.shared.{TabFeedSources, TabId}
import spa.shared.TabId._

/**
  * Created by skypage on 6/8/16.
  */
object HomeInits {
  val reddit = "reddit"
  val tech = "tech"
  val images = "images"
  val programming = "programming"
  val podcasts = "podcasts"

  case class TabState(id: String, selectedTab: String)

  def updateCache(item: TabState): Unit = {
    if(cachedTabStates.exists(_.id == item.id)) {
      cachedTabStates = cachedTabStates.collect {
        case i if i.id == item.id =>
          log.debug(s"item ${item.id} ")
          item
        case i => i
      }
      log.debug(s"Saved state ${item.selectedTab}")

    }
  }

  def getState(sectionId: String): String = {
    //log.debug(s"Got state as ${cachedTabStates.filter(_.id == sectionId).head.selectedTab}")
    cachedTabStates.filter(_.id == sectionId).head.selectedTab
  }

  var cachedTabStates = Seq(
    TabState(reddit, TabId.Reddit),
    TabState(tech, TabId.RedditTech),
    TabState(images, TabId.RedditPics),
    TabState(programming, TabId.RedditProgramming),
    TabState(podcasts, TabId.NoAgenda)
  )

  def generateSubreddits = {
    val redditFrontpage = ContainerTab.Props(
      ContainerTab.AnchorProps(),
      ContainerTab.ImageProps("src", Reddit, icon = Icon.reddit, imgText = "Frontpage"),
      Reddit,
      onSelectedUrl = TabFeedSources.Reddit
    )

    val redditTop = ContainerTab.Props(
      ContainerTab.AnchorProps(),
      ContainerTab.ImageProps("src", RedditTop, icon = Icon.reddit, imgText = "Top"),
      RedditTop,
      onSelectedUrl = TabFeedSources.RedditTop
    )

    val redditTil = ContainerTab.Props(
      ContainerTab.AnchorProps(),
      ContainerTab.ImageProps("src", RedditTil, icon = Icon.reddit, imgText = "TIL"),
      RedditTil,
      onSelectedUrl = TabFeedSources.RedditTil
    )

    val askReddit = ContainerTab.Props(
      ContainerTab.AnchorProps(),
      ContainerTab.ImageProps("src", AskReddit, icon = Icon.reddit, imgText = "Ask"),
      AskReddit,
      onSelectedUrl = TabFeedSources.AskReddit
    )

    val redditVideos = ContainerTab.Props(
      ContainerTab.AnchorProps(),
      ContainerTab.ImageProps("src", RedditVideos, icon = Icon.reddit, imgText = "Videos"),
      RedditVideos,
      onSelectedUrl = TabFeedSources.RedditVideos
    )

    List(
      redditFrontpage,
      redditTop,
      redditTil,
      askReddit,
      redditVideos
    )
  }

  def generateTech = {
    val redditTech = ContainerTab.Props(
      ContainerTab.AnchorProps(),
      ContainerTab.ImageProps("src", RedditTech, icon = Icon.reddit, imgText = "Tech News"),
      RedditTech,
      onSelectedUrl = TabFeedSources.RedditTech
    )

    val lifeHacker = ContainerTab.Props(
      ContainerTab.AnchorProps(),
      ContainerTab.ImageProps("src", LifeHacker, imgText = LifeHacker),
      LifeHacker,
      onSelectedUrl = TabFeedSources.LifeHacker
    )

    val redditTechnology = ContainerTab.Props(
      ContainerTab.AnchorProps(),
      ContainerTab.ImageProps("src", RedditTechnology, icon = Icon.reddit, imgText = "Technology"),
      RedditTechnology,
      onSelectedUrl = TabFeedSources.RedditTechnology
    )

    val slashdot = ContainerTab.Props(
      ContainerTab.AnchorProps(),
      ContainerTab.ImageProps("src", Slashdot, imgText = "/."),
      Slashdot,
      onSelectedUrl = TabFeedSources.Slashdot
    )

    val techdirt = ContainerTab.Props(
      ContainerTab.AnchorProps(),
      ContainerTab.ImageProps("src", Techdirt, imgText = "Techdirt"),
      Techdirt,
      onSelectedUrl = TabFeedSources.Techdirt
    )

    List(
      redditTech,
      lifeHacker,
      redditTechnology,
      slashdot,
      techdirt
    )
  }

  def generateProgramming = {
    val redditProgramming = ContainerTab.Props(
      ContainerTab.AnchorProps(),
      ContainerTab.ImageProps("src", RedditProgramming, icon = Icon.reddit, imgText = "Programming"),
      RedditProgramming,
      onSelectedUrl = TabFeedSources.RedditProgramming
    )<commit_msg>Remove /r/Tech from UI since /r/Tech and /r/Technology is redundant<commit_after>package spa.client.modules

import spa.client.components.Icon
import spa.client.logger._
import spa.shared.{TabFeedSources, TabId}
import spa.shared.TabId._

/**
  * Created by skypage on 6/8/16.
  */
object HomeInits {
  val reddit = "reddit"
  val tech = "tech"
  val images = "images"
  val programming = "programming"
  val podcasts = "podcasts"

  case class TabState(id: String, selectedTab: String)

  def updateCache(item: TabState): Unit = {
    if(cachedTabStates.exists(_.id == item.id)) {
      cachedTabStates = cachedTabStates.collect {
        case i if i.id == item.id =>
          log.debug(s"item ${item.id} ")
          item
        case i => i
      }
      log.debug(s"Saved state ${item.selectedTab}")

    }
  }

  def getState(sectionId: String): String = {
    //log.debug(s"Got state as ${cachedTabStates.filter(_.id == sectionId).head.selectedTab}")
    cachedTabStates.filter(_.id == sectionId).head.selectedTab
  }

  var cachedTabStates = Seq(
    TabState(reddit, TabId.Reddit),
    TabState(tech, TabId.RedditTech),
    TabState(images, TabId.RedditPics),
    TabState(programming, TabId.RedditProgramming),
    TabState(podcasts, TabId.NoAgenda)
  )

  def generateSubreddits = {
    val redditFrontpage = ContainerTab.Props(
      ContainerTab.AnchorProps(),
      ContainerTab.ImageProps("src", Reddit, icon = Icon.reddit, imgText = "Frontpage"),
      Reddit,
      onSelectedUrl = TabFeedSources.Reddit
    )

    val redditTop = ContainerTab.Props(
      ContainerTab.AnchorProps(),
      ContainerTab.ImageProps("src", RedditTop, icon = Icon.reddit, imgText = "Top"),
      RedditTop,
      onSelectedUrl = TabFeedSources.RedditTop
    )

    val redditTil = ContainerTab.Props(
      ContainerTab.AnchorProps(),
      ContainerTab.ImageProps("src", RedditTil, icon = Icon.reddit, imgText = "TIL"),
      RedditTil,
      onSelectedUrl = TabFeedSources.RedditTil
    )

    val askReddit = ContainerTab.Props(
      ContainerTab.AnchorProps(),
      ContainerTab.ImageProps("src", AskReddit, icon = Icon.reddit, imgText = "Ask"),
      AskReddit,
      onSelectedUrl = TabFeedSources.AskReddit
    )

    val redditVideos = ContainerTab.Props(
      ContainerTab.AnchorProps(),
      ContainerTab.ImageProps("src", RedditVideos, icon = Icon.reddit, imgText = "Videos"),
      RedditVideos,
      onSelectedUrl = TabFeedSources.RedditVideos
    )

    List(
      redditFrontpage,
      redditTop,
      redditTil,
      askReddit,
      redditVideos
    )
  }

  def generateTech = {
    val redditTech = ContainerTab.Props(
      ContainerTab.AnchorProps(),
      ContainerTab.ImageProps("src", RedditTech, icon = Icon.reddit, imgText = "Tech News"),
      RedditTech,
      onSelectedUrl = TabFeedSources.RedditTech
    )

    val lifeHacker = ContainerTab.Props(
      ContainerTab.AnchorProps(),
      ContainerTab.ImageProps("src", LifeHacker, imgText = LifeHacker),
      LifeHacker,
      onSelectedUrl = TabFeedSources.LifeHacker
    )

    val redditTechnology = ContainerTab.Props(
      ContainerTab.AnchorProps(),
      ContainerTab.ImageProps("src", RedditTechnology, icon = Icon.reddit, imgText = "Technology"),
      RedditTechnology,
      onSelectedUrl = TabFeedSources.RedditTechnology
    )

    val slashdot = ContainerTab.Props(
      ContainerTab.AnchorProps(),
      ContainerTab.ImageProps("src", Slashdot, imgText = "/."),
      Slashdot,
      onSelectedUrl = TabFeedSources.Slashdot
    )

    val techdirt = ContainerTab.Props(
      ContainerTab.AnchorProps(),
      ContainerTab.ImageProps("src", Techdirt, imgText = "Techdirt"),
      Techdirt,
      onSelectedUrl = TabFeedSources.Techdirt
    )

    List(
      redditTechnology,
      lifeHacker,
      slashdot,
      techdirt
    )
  }

  def generateProgramming = {
    val redditProgramming = ContainerTab.Props(
      ContainerTab.AnchorProps(),
      ContainerTab.ImageProps("src", RedditProgramming, icon = Icon.reddit, imgText = "Programming"),
      RedditProgramming,
      onSelectedUrl = TabFeedSources.RedditProgramming
    )
{'fraction_non_alphanumeric': 0.10802618816682832, 'fraction_numerical': 0.0009699321047526673, 'mean_word_length': 3.0856859831599803, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '3629195', 'n_tokens_mistral': 2587, 'n_tokens_neox': 2534, 'n_words': 488}