kotlin-cv.js
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.
Build and run
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
F.A.Q.
How to change the prompt
Edit the code that generates HTML with kotlinx:
div("prompt") {
pre {
+"@kotlin › "
}
}
How to add a new command
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()
}
How to add "files"
Add a new "file" to the "files" list.
How to insert HTML from a string
Use unsafe
:
p {
unsafe {
+"</br>"
}
}