All Projects → ramsayleung → Blog

ramsayleung / Blog

A clean, elegant blog built on Rust

Programming Languages

javascript
184084 projects - #8 most used programming language

#+LATEX_CLASS: samray-org-article #+LATEX_CLASS_OPTIONS: [oneside,A4paper,12pt]

Attention: Because Rocket is sensitive with compiler and it highly depends on lately nightly compiler, so it's so easy to fail when compiling this project.

  • About This is my personal blog, and its also my first Rust project. ** Why Rust Well, I know there are a lot of alternatives to writing a blog, but I find other languages such as Java, Python, Javascript,Php, are not fancy enough ;-) Kidding, the truth is that I have learned Rust for more that a half years, but I still could not build real some stuff on Rust. Yes, I lack of idea or I not am skillful enough to fulfill my thought. Finally, I decided to rewrite my [[https://samrayleung.github.io][blog]] which was built on Github Page and Org-mode.

  • Getting Started ** Requirement *** Rust Install Rust via shell script #+BEGIN_SRC sh curl https://sh.rustup.rs -sSf | sh #+END_SRC After installing, you might need to #+BEGIN_SRC sh source $HOME/.cargo/env #+END_SRC Because this project is built on Rocket, and Rocket depends on Rust nightly, so you need change Rust environment to nightly #+BEGIN_SRC sh rustup default nightly #+END_SRC *** Diesel Cli This project use Diesel as Orm framework, so you need to install its command line tool via Rust package manager(eg, Cargo) #+BEGIN_SRC sh cargo install diesel_cli --no-default-features --features postgres #+END_SRC *** Postgresql you need to install [[https://www.postgresql.org/][Postgresql database]], and then configure postgresql by following document's guide *** Init database After everything is done, it is time to create table in database for this project, just run #+BEGIN_SRC sh diesel migration run #+END_SRC *** Set up envirnment variables In the last step, you need to create a file named .env in the root of your repository, set up the following envirnment variables, for examples: #+BEGIN_SRC sh DATABASE_URL=postgres://postgres:[email protected]/blog STACKOVERFLOW_URL=https://stackoverflow.com/users/5738112/samray GITHUB_URL=https://github.com/ramsayleung/ ERROR_LOG_PATH=/tmp/common-error.log APP_LOG_PATH=/tmp/app-default.log EMAIL_URL=[email protected] SLOGAN="Ramsay's Utopia" SUB_SLOGAN="fn<T:time+joy>(resource: T)-> Ramsay's Blog" DB_NAME=blog DB_USER=username DB_PASSWORD=passwd #+END_SRC ** Launch Rocket Everything is ok, now, launch Rocket: #+BEGIN_SRC cargo run #+END_SRC And open your favourite browser, enter localhost:1337

    If you want to login admin page, you could enter localhost:1337/admin/login Email: admin Password: 123456 ** Todo List

    • refactor admin page, it is unacceptedly ugly.
  • Screenshot ** About Page [[./images/about.jpg]] ** Index Page [[./images/index.jpg]]

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].