<commit_before>package utils

import org.apache.commons.lang3.StringUtils
import play.mvc.Call
import org.joda.time.DateTimeConstants
import org.apache.commons.io.FilenameUtils
import play.i18n.Messages
import controllers.routes
import controllers.UserApp
import views.html._
import java.net.URI

import playRepository.DiffLine
import playRepository.DiffLineType
import models.CodeRange.Side

import views.html.partial_diff_comment_on_line
import views.html.partial_diff_line
import views.html.git.partial_pull_request_event
import models._
import java.net.URLEncoder

import scala.annotation.tailrec
import playRepository.FileDiff
import play.api.i18n.Lang
import play.twirl.api.Html
import collection.convert.wrapAll._
import scala.util.control.Breaks._

object TemplateHelper {

  def watcherList(posting: AbstractPosting): String = {
    val LIMIT = 100
    var counter = 0
    var str =  ""
    val watchers = posting.getWatchers
    breakable {
      for(watcher <- watchers){
        counter += 1
        if(counter > LIMIT) break
        var dummy = watcher.toString  // ebean eagerly loading hack
        str += "<a href='" + userInfo(watcher.loginId) + "' class='watcher-name'>" + watcher.name + "</a>"
      }
    }

    if( watchers.size > LIMIT ) {
      str += Messages.get("watchers.more", (watchers.size - LIMIT).toString)
    }
    str
  }

  def showWatchers(posting: AbstractPosting): String = {
    if(posting.getWatchers.size > 1){
      "<div class='show-watchers' data-toggle='tooltip' data-placement='top' data-trigger='hover' data-html='true' title='" + Messages.get("watchers") + "'>" +
      "<button id='watch-button' type='button' class='ybtn'><i class='yobicon-emo-coffee'></i> " + posting.getWatchers.size.toString + "</button>" +
      "</div>"
    } else {
      ""
    }
  }

  def buildQueryString(call: Call, queryMap: Map[String, String]): String = {
    val baseUrl = call.toString
    var prefix = "?"
    var query = ""
    if ((baseUrl indexOf "?") != -1) {
      prefix = "&"
    }
    queryMap.map {
      v => query += v._1 + "=" + v._2 + "&"
    }
    baseUrl + prefix + query.dropRight(1)
  }

  def buildAttrString(attrMap: java.util.Map[String, String]): String = {
    var attr = ""
    attrMap.map {
      v => attr += v._1 + "=" + v._2 + " "
    }
    attr.dropRight(1)
  }
<commit_msg>watcher-list: Show watchers to only logged-in users<commit_after>package utils

import org.apache.commons.lang3.StringUtils
import play.mvc.Call
import org.joda.time.DateTimeConstants
import org.apache.commons.io.FilenameUtils
import play.i18n.Messages
import controllers.routes
import controllers.UserApp
import views.html._
import java.net.URI

import playRepository.DiffLine
import playRepository.DiffLineType
import models.CodeRange.Side

import views.html.partial_diff_comment_on_line
import views.html.partial_diff_line
import views.html.git.partial_pull_request_event
import models._
import java.net.URLEncoder

import scala.annotation.tailrec
import playRepository.FileDiff
import play.api.i18n.Lang
import play.twirl.api.Html
import collection.convert.wrapAll._
import scala.util.control.Breaks._

object TemplateHelper {

  def watcherList(posting: AbstractPosting): String = {
    val LIMIT = 100
    var counter = 0
    var str =  ""
    val watchers = posting.getWatchers
    breakable {
      for(watcher <- watchers){
        counter += 1
        if(counter > LIMIT) break
        var dummy = watcher.toString  // ebean eagerly loading hack
        str += "<a href='" + userInfo(watcher.loginId) + "' class='watcher-name'>" + watcher.name + "</a>"
      }
    }

    if( watchers.size > LIMIT ) {
      str += Messages.get("watchers.more", (watchers.size - LIMIT).toString)
    }
    str
  }

  def showWatchers(posting: AbstractPosting): String = {
    if(posting.getWatchers.size > 1 && UserApp.currentUser() != User.anonymous){
      "<div class='show-watchers' data-toggle='tooltip' data-placement='top' data-trigger='hover' data-html='true' title='" + Messages.get("watchers") + "'>" +
      "<button id='watch-button' type='button' class='ybtn'><i class='yobicon-emo-coffee'></i> " + posting.getWatchers.size.toString + "</button>" +
      "</div>"
    } else {
      ""
    }
  }

  def buildQueryString(call: Call, queryMap: Map[String, String]): String = {
    val baseUrl = call.toString
    var prefix = "?"
    var query = ""
    if ((baseUrl indexOf "?") != -1) {
      prefix = "&"
    }
    queryMap.map {
      v => query += v._1 + "=" + v._2 + "&"
    }
    baseUrl + prefix + query.dropRight(1)
  }

  def buildAttrString(attrMap: java.util.Map[String, String]): String = {
    var attr = ""
    attrMap.map {
      v => attr += v._1 + "=" + v._2 + " "
    }
    attr.dropRight(1)
  }

{'fraction_non_alphanumeric': 0.13859095688748685, 'fraction_numerical': 0.007570977917981073, 'mean_word_length': 3.235084594835263, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 29, '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': '5083737', 'n_tokens_mistral': 1580, 'n_tokens_neox': 1555, 'n_words': 324}