<commit_before>/**
 * Copyright (C) 2012-2013 <NAME> (born 1979)
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as
 * published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

package debiki

import com.debiki.core._
import java.{util => ju}
import Prelude._


object DummyPage {


  /**
   * Adds an empty title, an empty page body, and a config text, if they
   * don't yet exist, so there is something to edit.
   */
  def addMissingTitleBodyConfigTo(pageParts: PageParts, pageRole: PageRole): PageParts = {

    val addDummyTitle = pageParts.title.isEmpty
    val addDummyBody = pageParts.body.isEmpty
    val addDummyConfig = pageParts.pageConfigPost.isEmpty

    var pageWithDummies = pageParts

    if (addDummyTitle || addDummyBody || addDummyConfig)
      pageWithDummies = pageWithDummies ++ DummyAuthor

    val texts: Texts = pageRole match {
      case PageRole.BlogPost => BlogPostTexts
      case PageRole.Forum => ForumTexts
      case PageRole.ForumCategory => ForumCategoryTexts
      case PageRole.ForumTopic => ForumTopicTexts
      case PageRole.Code => CodeTexts
      case _ => DefaultTexts
    }

    if (addDummyTitle) pageWithDummies += dummyTitle(texts)
    if (addDummyBody) pageWithDummies += dummyBody(texts, pageRole)
    if (addDummyConfig) pageWithDummies += dummyConfig(texts)

    pageWithDummies
  }


  // COULD have Dao require that user/idty/login id never be "2".
  // (Id "1" is the SystemUser, in debiki-core user.scala.)

  val DummyAuthorUser = User(id = "2", displayName = "(dummy author)", username = None,
    createdAt = None, email = "", emailNotfPrefs = EmailNotfPrefs.DontReceive,
    emailVerifiedAt = None, country = "", website = "", isAdmin = false,
    isOwner = false)

  val DummyAuthorIp = "0.0.0.0"

  val DummyAuthorIdData = UserIdData(
    userId = DummyAuthorUser.id,
    ip = DummyAuthorIp,
    browserIdCookie = None,
    browserFingerprint = 0)


  val DummyAuthor = People(List(DummyAuthorUser))
<commit_msg>Make forum topic title appear: mark dummy user email as verified.<commit_after>/**
 * Copyright (C) 2012-2013 <NAME> (born 1979)
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as
 * published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

package debiki

import com.debiki.core._
import java.{util => ju}
import Prelude._


object DummyPage {


  /**
   * Adds an empty title, an empty page body, and a config text, if they
   * don't yet exist, so there is something to edit.
   */
  def addMissingTitleBodyConfigTo(pageParts: PageParts, pageRole: PageRole): PageParts = {

    val addDummyTitle = pageParts.title.isEmpty
    val addDummyBody = pageParts.body.isEmpty
    val addDummyConfig = pageParts.pageConfigPost.isEmpty

    var pageWithDummies = pageParts

    if (addDummyTitle || addDummyBody || addDummyConfig)
      pageWithDummies = pageWithDummies ++ DummyAuthor

    val texts: Texts = pageRole match {
      case PageRole.BlogPost => BlogPostTexts
      case PageRole.Forum => ForumTexts
      case PageRole.ForumCategory => ForumCategoryTexts
      case PageRole.ForumTopic => ForumTopicTexts
      case PageRole.Code => CodeTexts
      case _ => DefaultTexts
    }

    if (addDummyTitle) pageWithDummies += dummyTitle(texts)
    if (addDummyBody) pageWithDummies += dummyBody(texts, pageRole)
    if (addDummyConfig) pageWithDummies += dummyConfig(texts)

    pageWithDummies
  }


  // COULD have Dao require that user/idty/login id never be "2".
  // (Id "1" is the SystemUser, in debiki-core user.scala.)

  val DummyAuthorUser = User(id = "2", displayName = "(dummy author)", username = None,
    createdAt = None, email = "", emailNotfPrefs = EmailNotfPrefs.DontReceive,
    emailVerifiedAt = Some(new ju.Date(0)), country = "", website = "", isAdmin = false,
    isOwner = false)

  val DummyAuthorIp = "0.0.0.0"

  val DummyAuthorIdData = UserIdData(
    userId = DummyAuthorUser.id,
    ip = DummyAuthorIp,
    browserIdCookie = None,
    browserFingerprint = 0)


  val DummyAuthor = People(List(DummyAuthorUser))

{'fraction_non_alphanumeric': 0.08647493198600854, 'fraction_numerical': 0.008356004663816556, 'mean_word_length': 3.5710479573712255, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 2, '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': '209609', 'n_tokens_mistral': 1591, 'n_tokens_neox': 1520, 'n_words': 533}