Sitelet https://github.com/cnglen/tinydis
Skip to content

Latest commit

 

History

28 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

A *tiny*, *anonymous* discussion plugin built with Rust.

[[./README_zh.org][中文 README]]

-----

* Features

- tiny
- anonymous
- i18n: en/zh-CN supported

* Usage 

** Build

The build process produces the following outputs:
- frontend files: ~tinydis.js~, ~tinydis.css~ and ~tindydis_bg.wasm~
- backend executable binary: ~tinydis~

#+begin_src bash
  git clone https://github.com/cnglen/tinydis.git
  cd tinydis
  rustup target add wasm32-unknown-unknown
  cargo install --locked cargo-leptos
  cargo leptos build --release && mv target/site/assets/tinydis.wasm  target/site/assets/tinydis_bg.wasm && rm -rf ./target/site/assets/*.ts
  cp -r ./target/site/assets YOUR_SITE_ROOT_PATH
#+end_src

** Start backend server

The backend server is responsible for:
- Reading/writing comments to the SQlite DB
- Sending comments along with clickable reject/approve links to the admin email for review

#+begin_src bash
  export TINYDIS_SMTP_USERNAME=your_email_to_send_review_message
  export TINYDIS_SMTP_PASSWORD=your_password_to_send_review_message   # an App password is prefered to regular parssword
  export TINYDIS_SMTP_HOST=your_smtp_host
  export TINYDIS_SMTP_PORT=your_smtp_port
  export TINYDIS_ADMIN_EMAIL=admin_email_to_receive_review_message
  export TINYDIS_ADMIN_LOCALE=en # Supported: en/zh-CN; default to en if not set
  export TINYDIS_ALLOWED_ORIGINS="*" # Allowed origins for backend server, e.g., "http://127.0.0.1:8080,http://127.0.0.1:9999" or "*" for testing

  ./PATH_OF_tinydis
#+end_src

** Import tinydis in frontend

To embed tindis in your HTML, the following attributes can be customized:
- ​=data-page-id=​: defaults to the current page URL
- ​=data-server-url=​: defaults to the HTTP *Origin* header
  
#+begin_src html
  <head>
    <!-- ... -->
    <link rel="stylesheet" href="/sitelet?url=https%3A%2F%2Fgithub.com%2Fassets%2Ftinydis.css" />
    <!-- ... -->
  </head>    

  <body>
    <!-- ... -->
    <div id="tinydis"></div>
    <!-- Optionally, customize data-page-id(for each page) and data-server-url -->
    <!-- <div id="tinydis" data-page-id="YOUR_PAGE_ID" data-server-url="TINYDIS_SERVER_ADDR"></div> -->
    <script type="module">
      import init from '/assets/tinydis.js';
      init();
    </script>
  </body>
#+end_src

** Screenshot

#+Caption: screent shot of en
[[file:doc/comment_en.png]]

* Developement

** Internationlization (i18n)
- Frontend: use ​=leptos_i18n=​ in components, where locale is automatically detected from the browser
- Backend: use =rust_i18n=, where locale is read from environment variable, =TINYDIS_ADMIN_LOCALE=

** Reference

- [[https://github.com/leptos-rs/leptos][leptos]], a cutting-edge Rust web framework is used

About

a tiny disscussion system

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Sponsor this project

Packages

Contributors

Languages