example/src/example/ExampleApp.scala
author Tomas Zeman <tomas@functionals.cz>
Sun, 27 Dec 2020 22:54:33 +0100
changeset 28 fe846f058e41
permissions -rw-r--r--
pure-extras: example, publish(M2)Local/compileAll.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
28
fe846f058e41 pure-extras: example, publish(M2)Local/compileAll.
Tomas Zeman <tomas@functionals.cz>
parents:
diff changeset
     1
/*
fe846f058e41 pure-extras: example, publish(M2)Local/compileAll.
Tomas Zeman <tomas@functionals.cz>
parents:
diff changeset
     2
 * Copyright 2020 Tomas Zeman <tomas@functionals.cz>
fe846f058e41 pure-extras: example, publish(M2)Local/compileAll.
Tomas Zeman <tomas@functionals.cz>
parents:
diff changeset
     3
 *
fe846f058e41 pure-extras: example, publish(M2)Local/compileAll.
Tomas Zeman <tomas@functionals.cz>
parents:
diff changeset
     4
 * Licensed under the Apache License, Version 2.0 (the "License");
fe846f058e41 pure-extras: example, publish(M2)Local/compileAll.
Tomas Zeman <tomas@functionals.cz>
parents:
diff changeset
     5
 * you may not use this file except in compliance with the License.
fe846f058e41 pure-extras: example, publish(M2)Local/compileAll.
Tomas Zeman <tomas@functionals.cz>
parents:
diff changeset
     6
 * You may obtain a copy of the License at
fe846f058e41 pure-extras: example, publish(M2)Local/compileAll.
Tomas Zeman <tomas@functionals.cz>
parents:
diff changeset
     7
 *
fe846f058e41 pure-extras: example, publish(M2)Local/compileAll.
Tomas Zeman <tomas@functionals.cz>
parents:
diff changeset
     8
 *     http://www.apache.org/licenses/LICENSE-2.0
fe846f058e41 pure-extras: example, publish(M2)Local/compileAll.
Tomas Zeman <tomas@functionals.cz>
parents:
diff changeset
     9
 *
fe846f058e41 pure-extras: example, publish(M2)Local/compileAll.
Tomas Zeman <tomas@functionals.cz>
parents:
diff changeset
    10
 * Unless required by applicable law or agreed to in writing, software
fe846f058e41 pure-extras: example, publish(M2)Local/compileAll.
Tomas Zeman <tomas@functionals.cz>
parents:
diff changeset
    11
 * distributed under the License is distributed on an "AS IS" BASIS,
fe846f058e41 pure-extras: example, publish(M2)Local/compileAll.
Tomas Zeman <tomas@functionals.cz>
parents:
diff changeset
    12
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
fe846f058e41 pure-extras: example, publish(M2)Local/compileAll.
Tomas Zeman <tomas@functionals.cz>
parents:
diff changeset
    13
 * See the License for the specific language governing permissions and
fe846f058e41 pure-extras: example, publish(M2)Local/compileAll.
Tomas Zeman <tomas@functionals.cz>
parents:
diff changeset
    14
 * limitations under the License.
fe846f058e41 pure-extras: example, publish(M2)Local/compileAll.
Tomas Zeman <tomas@functionals.cz>
parents:
diff changeset
    15
 */
fe846f058e41 pure-extras: example, publish(M2)Local/compileAll.
Tomas Zeman <tomas@functionals.cz>
parents:
diff changeset
    16
package example
fe846f058e41 pure-extras: example, publish(M2)Local/compileAll.
Tomas Zeman <tomas@functionals.cz>
parents:
diff changeset
    17
fe846f058e41 pure-extras: example, publish(M2)Local/compileAll.
Tomas Zeman <tomas@functionals.cz>
parents:
diff changeset
    18
import os.Path
fe846f058e41 pure-extras: example, publish(M2)Local/compileAll.
Tomas Zeman <tomas@functionals.cz>
parents:
diff changeset
    19
import purecss.Extras
fe846f058e41 pure-extras: example, publish(M2)Local/compileAll.
Tomas Zeman <tomas@functionals.cz>
parents:
diff changeset
    20
import scalatags.Text.all._
fe846f058e41 pure-extras: example, publish(M2)Local/compileAll.
Tomas Zeman <tomas@functionals.cz>
parents:
diff changeset
    21
import scalatags.Text.tags2
fe846f058e41 pure-extras: example, publish(M2)Local/compileAll.
Tomas Zeman <tomas@functionals.cz>
parents:
diff changeset
    22
fe846f058e41 pure-extras: example, publish(M2)Local/compileAll.
Tomas Zeman <tomas@functionals.cz>
parents:
diff changeset
    23
trait ExampleApp extends ContentInitializer {
fe846f058e41 pure-extras: example, publish(M2)Local/compileAll.
Tomas Zeman <tomas@functionals.cz>
parents:
diff changeset
    24
fe846f058e41 pure-extras: example, publish(M2)Local/compileAll.
Tomas Zeman <tomas@functionals.cz>
parents:
diff changeset
    25
  def export: Path
fe846f058e41 pure-extras: example, publish(M2)Local/compileAll.
Tomas Zeman <tomas@functionals.cz>
parents:
diff changeset
    26
fe846f058e41 pure-extras: example, publish(M2)Local/compileAll.
Tomas Zeman <tomas@functionals.cz>
parents:
diff changeset
    27
  os.write.over(export / s"${`extras`.id}.html",
fe846f058e41 pure-extras: example, publish(M2)Local/compileAll.
Tomas Zeman <tomas@functionals.cz>
parents:
diff changeset
    28
    "<!DOCTYPE html>" + html(head(
fe846f058e41 pure-extras: example, publish(M2)Local/compileAll.
Tomas Zeman <tomas@functionals.cz>
parents:
diff changeset
    29
      meta(charset:="utf-8"),
fe846f058e41 pure-extras: example, publish(M2)Local/compileAll.
Tomas Zeman <tomas@functionals.cz>
parents:
diff changeset
    30
      meta(name:="viewport", content:="width=device-width, initial-scale=1.0"),
fe846f058e41 pure-extras: example, publish(M2)Local/compileAll.
Tomas Zeman <tomas@functionals.cz>
parents:
diff changeset
    31
      tags2.title(s"Example of ${`extras`.id} | PureCSS"),
fe846f058e41 pure-extras: example, publish(M2)Local/compileAll.
Tomas Zeman <tomas@functionals.cz>
parents:
diff changeset
    32
      link(href:="https://unpkg.com/purecss@2.0.3/build/pure-min.css",
fe846f058e41 pure-extras: example, publish(M2)Local/compileAll.
Tomas Zeman <tomas@functionals.cz>
parents:
diff changeset
    33
        rel:="stylesheet", tpe:="text/css"),
fe846f058e41 pure-extras: example, publish(M2)Local/compileAll.
Tomas Zeman <tomas@functionals.cz>
parents:
diff changeset
    34
      tags2.style(Extras.styleSheetText)
fe846f058e41 pure-extras: example, publish(M2)Local/compileAll.
Tomas Zeman <tomas@functionals.cz>
parents:
diff changeset
    35
    ), body(
fe846f058e41 pure-extras: example, publish(M2)Local/compileAll.
Tomas Zeman <tomas@functionals.cz>
parents:
diff changeset
    36
      `extras`.content
fe846f058e41 pure-extras: example, publish(M2)Local/compileAll.
Tomas Zeman <tomas@functionals.cz>
parents:
diff changeset
    37
    ))
fe846f058e41 pure-extras: example, publish(M2)Local/compileAll.
Tomas Zeman <tomas@functionals.cz>
parents:
diff changeset
    38
  )
fe846f058e41 pure-extras: example, publish(M2)Local/compileAll.
Tomas Zeman <tomas@functionals.cz>
parents:
diff changeset
    39
fe846f058e41 pure-extras: example, publish(M2)Local/compileAll.
Tomas Zeman <tomas@functionals.cz>
parents:
diff changeset
    40
  println(
fe846f058e41 pure-extras: example, publish(M2)Local/compileAll.
Tomas Zeman <tomas@functionals.cz>
parents:
diff changeset
    41
    s"""Please open your browser at
fe846f058e41 pure-extras: example, publish(M2)Local/compileAll.
Tomas Zeman <tomas@functionals.cz>
parents:
diff changeset
    42
       |file:///$export
fe846f058e41 pure-extras: example, publish(M2)Local/compileAll.
Tomas Zeman <tomas@functionals.cz>
parents:
diff changeset
    43
       |""".stripMargin)
fe846f058e41 pure-extras: example, publish(M2)Local/compileAll.
Tomas Zeman <tomas@functionals.cz>
parents:
diff changeset
    44
}