Skip to content
A clean, elegant blog built on Rust
JavaScript CSS Rust Other
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.docker 1. remove dump.sql May 31, 2019
.vscode gitignore remove .vscode Jan 22, 2019
images update README.md Jan 20, 2020
migrations update migrations up.sql May 29, 2019
src add solgan adn sub slogan Dec 24, 2019
static use cdn to service `simplemde` library. Jan 29, 2020
templates
.env update log path again Dec 24, 2019
.gitignore update .gitignore May 21, 2019
.travis.yml
Cargo.toml
README.org
Rocket.toml change log file location Oct 11, 2019
diesel.toml upgrade diesel Aug 5, 2018
docker-compose.yml docker blog(not finished) May 30, 2019

README.org

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 blog which was built on Github Page and Org-mode.

Getting Started

Requirement

Rust

Install Rust via shell script

curl https://sh.rustup.rs -sSf | sh

After installing, you might need to

source $HOME/.cargo/env

Because this project is built on Rocket, and Rocket depends on Rust nightly, so you need change Rust environment to nightly

rustup default nightly

Diesel Cli

This project use Diesel as Orm framework, so you need to install its command line tool via Rust package manager(eg, Cargo)

cargo install diesel_cli --no-default-features --features postgres

Postgresql

you need to install 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

diesel migration run

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:

DATABASE_URL=postgres://postgres:postgres@localhost/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=ramsayleung@gmail.com
SLOGAN="Ramsay's Utopia"
SUB_SLOGAN="fn<T:time+joy>(resource: T)-> Ramsay's Blog"
DB_NAME=blog
DB_USER=username
DB_PASSWORD=passwd

Launch Rocket

Everything is ok, now, launch Rocket:

cargo run

And open your favourite browser, enter localhost:8000

If you want to login admin page, you could enter localhost:8000/admin/login Email: admin@samray.xyz Password: 123456

Todo List

  • refactor admin page, it is unacceptedly ugly.

Screenshot

About Page

./images/about.jpg

Index Page

./images/index.jpg

You can’t perform that action at this time.