Giter VIP home page Giter VIP logo

kobold-test's Introduction

Kobold Test

Testing the capabilities of Kobold library whilst learning Rust.

Initial Setup Log

cargo new kobold-test --bin
cargo add kobold
touch index.html
  • Paste the following in index.html
<html>
  <head>
    <meta charset="utf-8" />
    <title>Kobold Hello World example</title>
  </head>
  <body></body>
</html>
  • Paste the following in ./src/main.rs
use kobold::prelude::{component, html, Html};

#[component]
fn Hello(name: &str) -> impl Html + '_ {
    html! {
        <h1>"Hello "{ name }"!"</h1>
    }
}

fn main() {
    kobold::start(html! {
        <Hello name="Kobold" />
    });
}
  • Install Trunk
  • Create Trunk.toml & Paste:
[tools]
wasm_bindgen = "0.2.84"
  • Build, watch and serve the Rust WASM web application and all its assets. Automatically opens in web browser.
trunk serve --address=127.0.0.1 --open
* Note: Replace with public IP address to access externally if firewall permissions allow

Docker

  • Runs server inside Docker container. Build artifacts dist/ and target/ are generated inside the Docker container with hot reloading.
  • Install and run Docker
  • Run in Docker container
./docker-dev.sh
  • View website http://<PUBLIC_IP_ADDRESS>:8080

  • Kill Docker container

docker stop kobold-test && docker rm -f kobold-test

Troubleshooting

  • The following was used to test if all binaries and examples and packages specified could be installed.
cargo install --bins --examples --git=https://github.com/ltfschoen/kobold --branch=master --rev=2617dc3e4cff227d68e8a7ae883d8aa7cec6de6f kobold_counter_example kobold_csv_editor_example kobold_hello_world_example kobold_interval_example kobold_list_example kobold_qrcode_example kobold_stateful_example kobold_todomvc_example --verbose

However the Cargo.toml file was updated as follows instead so it would run without error when trunk serve

[dependencies]
# https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html#multiple-locations
kobold = { version = "0.5.0", git = "https://github.com/ltfschoen/kobold.git", rev = "d56e8f69d7678040c63d57e93f78d4c3aa35656d" }
kobold_macros = { version = "0.5.0", git = "https://github.com/ltfschoen/kobold.git", rev = "d56e8f69d7678040c63d57e93f78d4c3aa35656d" }
kobold_qr = { version = "0.5.0", git = "https://github.com/ltfschoen/kobold.git", rev = "d56e8f69d7678040c63d57e93f78d4c3aa35656d" }

kobold-test's People

Contributors

ltfschoen avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.