From b8b9e96bf525e98d4eebd677fd31b643a482c5fa Mon Sep 17 00:00:00 2001
From: xuwei-k <6b656e6a69@gmail.com>
Date: Mon, 9 Jul 2018 14:51:14 +0900
Subject: [PATCH] remove unused project/SiteMap.scala
added https://github.com/sbt/sbt/commit/d6ca66d406489f26b30b63f4fd2340a5f27815a4
unused since https://github.com/sbt/sbt/commit/7f2bd2cc4b9ca138afb805a8d01b8d1e28be288d
---
project/SiteMap.scala | 92 -------------------------------------------
1 file changed, 92 deletions(-)
delete mode 100644 project/SiteMap.scala
diff --git a/project/SiteMap.scala b/project/SiteMap.scala
deleted file mode 100644
index 95e038eab..000000000
--- a/project/SiteMap.scala
+++ /dev/null
@@ -1,92 +0,0 @@
-import sbt.io.Path._
-import sbt._
-
-object SiteMap {
- // represents the configurable aspects of a sitemap entry
- final case class Entry(changeFreq: String, priority: Double) {
- assert(priority >= 0.0 && priority <= 1.0,
- s"Priority must be between 0.0 and 1.0:, was $priority")
- }
- def generate(repoBase: File,
- remoteBase: URI,
- gzip: Boolean,
- entry: (File, String) => Option[Entry],
- log: Logger): (File, Seq[File]) = {
- def relativize(files: PathFinder): Seq[(File, String)] = files pair relativeTo(repoBase)
- def entries(files: PathFinder) =
- relativize(files) flatMap {
- case (f, path) =>
- entry(f, path).toList map { e =>
- entryXML(e, f, path)
- }
- }
- def entriesXML(entries: Seq[xml.Node]): xml.Elem = {
- assert(entries.size <= 50000, "A site map cannot contain more than 50,000 entries.")
-
- { entries }
-
- }
-
- def entryXML(e: Entry, f: File, relPath: String) =
-
- { remoteBase.resolve(relPath).toString }
- { lastModifiedString(f) }
- { e.changeFreq }
- { e.priority.toString }
-
-
- def singleSiteMap(dir: File, files: PathFinder): Option[File] = {
- val es = entries(files)
- if (es.isEmpty) None
- else Some(writeXMLgz(dir / "sitemap.xml", dir / "sitemap.xml.gz", gzip, entriesXML(es)))
- }
- def indexEntryXML(sub: File, relPath: String): xml.Elem =
-
- { remoteBase.resolve(relPath).toString }
- { lastModifiedString(sub) }
-
- def indexEntriesXML(entries: Seq[xml.Node]): xml.Elem =
-
- { entries }
-
- def indexEntries(subs: Seq[File]) =
- relativize(subs) map { case (f, path) => indexEntryXML(f, path) }
- def siteMapIndex(dir: File, subs: Seq[File]): File = {
- val xml = indexEntriesXML(indexEntries(subs))
- writeXMLgz(dir / "sitemap_index.xml", dir / "sitemap_index.xml.gz", gzip, xml)
- }
- def isSymlink(f: File) = f.getCanonicalFile != f.getAbsoluteFile
-
- val (symlinks, normal) = (repoBase * DirectoryFilter).get.partition(dir => isSymlink(dir))
- log.debug("Detected symlinks: " + symlinks.mkString("\n\t", "\n\t", ""))
- val subMaps =
- singleSiteMap(repoBase, (repoBase * "*.html") +++ (symlinks ** "*.html")).toList ++
- normal.flatMap(dir => singleSiteMap(dir, dir ** "*.html").toList)
- val index = siteMapIndex(repoBase, subMaps)
- (index, subMaps)
- }
- // generates a string suitable for a sitemap file representing the last modified time of the given File
- private[this] def lastModifiedString(f: File): String = {
- val formatter = new java.text.SimpleDateFormat("yyyy-MM-dd")
- // TODO: replace lastModified() with sbt.io.IO.getModifiedTimeOrZero(), once the build
- // has been upgraded to a version of sbt that includes that call.
- formatter.format(new java.util.Date(f.lastModified))
- }
- // writes the provided XML node to `output` and then gzips it to `gzipped` if `gzip` is true
- private[this] def writeXMLgz(output: File, gzipped: File, gzip: Boolean, node: xml.Node): File = {
- writeXML(output, node)
- if (gzip) {
- IO.gzip(output, gzipped)
- gzipped
- } else
- output
- }
- private[this] def writeXML(output: File, node: xml.Node): Unit =
- write(output, new xml.PrettyPrinter(1000, 4).format(node))
-
- private[this] def write(output: File, xmlString: String): Unit = {
- // use \n as newline because toString uses PrettyPrinter, which hard codes line endings to be \n
- IO.write(output, s"\n")
- IO.append(output, xmlString)
- }
-}