To get started with our CMS written in Rust, you will need to have the following installed on your system:
Rust: https://www.rust-lang.org/tools/install
PostgreSQL: https://www.postgresql.org/download/
The easiet way to install PostgreSQL is via https://postgresapp.com/ app. Follow the following instructions to install Postgres app.
-
Download the app from https://postgresapp.com/downloads.html and Move it to Applications folder, Double Click to open the application If you don't move Postgres.app to the Applications folder, you will see a warning about an unidentified developer and won't be able to open it.
-
Click "Initialize" to create a new server and make sure you are using PostgreSQL 14
-
Prepare the $PATH to include postgres in ENV
sudo mkdir -p /etc/paths.d && echo /Applications/Postgres.app/Contents/Versions/latest/bin | sudo tee /etc/paths.d/postgresapp
Once you have Postgres 14 up and running , prepare a new table called "hiwrite"
You might require a postgres DB viewer , https://dbeaver.io/ is one open source application to view database, To install it you can download the application from https://dbeaver.io/download/ .
Once you have these postgres and rust installed, you can follow these steps to get the CMS up and running:
Clone this repository to your local machine
git clone https://github.com/TECHFUND/hiwrite
To install the Rust programming language , you can use one of the following methods:
Open a terminal window on your Mac M1. Run the following command to install Rust using Homebrew:
brew install rust
Open a terminal window on your Mac M1. Run the following command to install rustup:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
This will download and run the rustup installer, which will install the latest stable version of Rust.
Once Rust is installed, you can check the version of Rust you have installed by running the following command in your terminal:
rustc --version
Once Rust is installed, you can use the following steps to install diesel_cli:
Open a terminal window on your Mac M1. Run the following command to install diesel_cli:
cargo install diesel_cli --no-default-features --features postgres
This will download and compile diesel_cli, and install it to your system.
First make sure you have the libpg installed
brew install postgresql libpq
Now you should have the libraries installed here : /opt/homebrew/opt/libpq/lib Make sure you have libpq directory available on above location.
Now you should pass the library location to cargo in order to install diesel_cli
RUSTFLAGS='-L /opt/homebrew/opt/libpq/lib' cargo install diesel_cli --no-default-features --features postgres
Above should install diesel_cli
To avoid having to pass RUSTFLAGS='...' in the command , you can also put the following in your ~/.cargo/config.toml
file :
[target.aarch64-apple-darwin]
rustflags = '-L /opt/homebrew/opt/libpq/lib -L /opt/homebrew/lib'
Once the installation is complete, you can use diesel_cli by running the diesel command in your terminal. You can also check the version of diesel_cli you have installed by running diesel --version.
Navigate to the project directory and build the project
cd hiwrite
cargo build
Create a .env file in the project root and set the following environment variables:
DATABASE_URL=postgres://[username]:[password]@localhost/rust_cms
Migrate the database
cargo run -- migrate
Start the server
cargo run -- server
The CMS should now be up and running at http://localhost:8000
If everything ran well you should see following prompt
The CMS exposes a RESTful API that allows you to manage the content of your site.
The API documentation can be found at http://localhost:8000/api/docs.
License
This project is licensed under the gplv3 License. See LICENSE for more details.