Personal terminal-like simple webpage template built with Kotlin/JS.
The template features CLI commands help
, cat
, ls
, their completion and execution, and it's easy to implement your commands. The original idea of the CLI-like webpage is borrowed from the cool zenith.tech website.
The built website contains three files:
styles.css
β fancy styles for the websiteindex.html
β boilerplate HTML doc that contains call tokotlin-cv.js
kotlin-cv.js
β the "CLI" core, built with Kotlin/JS.
To set up a website like this, follow these steps:
- Use the template
- To run the project locally, use
./gradlew run
, to build β./gradlew build
: the built website will be located at./build/distributions
. - Deploy it anywhere you want, the website can be easily deployed to GitHub Pages. I build it with Actions and use Cloudflare Pages for tiulp.in
Edit the code that generates HTML with kotlinx:
div("prompt") {
pre {
+"@kotlin βΊ "
}
}
Implement an object from the Command interface and add it to the commands list. For example, a command to open some link (in this particular example is URL to CV) could be implemented this way:
"cv" to object : Command {
override val help = "open my cv"
override fun complete(argv: List<String>): List<String> = listOf()
override fun exec(argv: List<String>, print: (String) -> Unit) =
window.open("https://tiulp.in/cv.pdf", blank)!!.focus()
}
Add a new "file" to the "files" list.
Use unsafe
:
p {
unsafe {
+"</br>"
}
}