base/src/sqwl/cms/package.scala
changeset 34 775d6da26993
parent 23 afcfbdeb3b88
equal deleted inserted replaced
33:fa0f19a74283 34:775d6da26993
       
     1 /*
       
     2  * Copyright 2018-2020 Tomas Zeman <tomas@functionals.cz>
       
     3  *
       
     4  * Licensed under the Apache License, Version 2.0 (the "License");
       
     5  * you may not use this file except in compliance with the License.
       
     6  * You may obtain a copy of the License at
       
     7  *
       
     8  *     http://www.apache.org/licenses/LICENSE-2.0
       
     9  *
       
    10  * Unless required by applicable law or agreed to in writing, software
       
    11  * distributed under the License is distributed on an "AS IS" BASIS,
       
    12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
       
    13  * See the License for the specific language governing permissions and
       
    14  * limitations under the License.
       
    15  */
     1 package sqwl
    16 package sqwl
     2 
    17 
     3 import java.nio.file.Path
    18 import java.nio.file.Path
       
    19 import java.time.LocalDateTime
     4 
    20 
     5 import scala.io.Source
    21 import scala.io.Source
     6 import scala.util.{Failure, Success, Try}
    22 import scala.util.{Failure, Success, Try}
     7 import scalatags.Text.all._
    23 import scalatags.Text.all._
       
    24 import scalatags.text.Builder
     8 
    25 
     9 package object cms {
    26 package object cms {
    10 
    27 
    11   def readSourceFull(src: Source): Try[String] = {
    28   def readSourceFull(src: Source): Try[String] = {
    12     try {
    29     try {
    26 
    43 
    27   def lnk(name: String, customUrl: String = ""): Frag = {
    44   def lnk(name: String, customUrl: String = ""): Frag = {
    28     val usedUrl = if (customUrl == "") name else customUrl
    45     val usedUrl = if (customUrl == "") name else customUrl
    29     a(name, href := usedUrl)
    46     a(name, href := usedUrl)
    30   }
    47   }
       
    48 
       
    49   def time: Frag = new Frag {
       
    50 
       
    51     override def render: String = {
       
    52       println("time.render()")
       
    53       LocalDateTime.now().toString
       
    54     }
       
    55 
       
    56     override def applyTo(t: Builder): Unit = {
       
    57       println("time.applyTo()")
       
    58       t.addChild(render)
       
    59     }
       
    60   }
    31 }
    61 }