package sqwl
import java.nio.file.Path
import scala.io.Source
import scala.util.{Failure, Success, Try}
import scalatags.Text.all._
package object cms {
def readSourceFull(src: Source): Try[String] = {
try {
Success(src.getLines.mkString)
} catch {
case t: Throwable => Failure(t)
} finally {
src.close()
}
}
def readFile(f: Path, enc: String = "UTF-8"): Try[String] =
readSourceFull(Source.fromFile(f.toFile, enc))
def readFile(f: String): String =
readSourceFull(Source.fromFile(f, "UTF-8")) getOrElse ""
def lnk(name: String, customUrl: String = ""): Frag = {
val usedUrl = if (customUrl == "") name else customUrl
a(name, href := usedUrl)
}
}