Skip to content

Commit

Permalink
Merge pull request #270 from CrowCpp/docs_meta
Browse files Browse the repository at this point in the history
Mkdocs fixes
  • Loading branch information
The-EDev authored Nov 6, 2021
2 parents b5137c5 + 2665086 commit 4ac5892
Show file tree
Hide file tree
Showing 20 changed files with 92 additions and 80 deletions.
3 changes: 1 addition & 2 deletions .drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ steps:
- export COVERALLS_PULL_REQUEST=$DRONE_PULL_REQUEST
- apt-get -y update
- apt-get -y install libboost-all-dev doxygen mkdocs graphviz zlib1g-dev gcc clang make cmake python3 python3-pip git openssl libssl-dev
- pip3 install mkdocs-material mkdocs-redirects pyyaml --no-input
- git clone https://github.com/CrowCpp/cpp-coveralls.git
- cd cpp-coveralls
- pip3 install . --no-input
Expand Down Expand Up @@ -114,7 +113,7 @@ steps:
- export TRAVIS_JOB_ID=$DRONE_BUILD_NUMBER
- apt-get -y update
- apt-get -y install libboost-all-dev doxygen mkdocs graphviz zlib1g-dev gcc clang make cmake python3 python3-pip git openssl libssl-dev
- pip3 install mkdocs-material mkdocs-redirects pyyaml --no-input
- pip3 install mkdocs-material mkdocs-redirects pyyaml mkdocs-meta-descriptions-plugin --no-input
- git clone https://github.com/CrowCpp/cpp-coveralls.git
- cd cpp-coveralls
- pip3 install . --no-input
Expand Down
24 changes: 12 additions & 12 deletions docs/getting_started/setup/linux.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Here's how you can install Crow on your favorite GNU/Linux distro.
# Getting Crow
## Getting Crow

## Requirements
### Requirements
- C++ compiler with at least C++11 support.
- boost library & development headers (1.64 or later).
- **(optional)** ZLib for HTTP Compression.
Expand All @@ -14,7 +14,7 @@ Here's how you can install Crow on your favorite GNU/Linux distro.

<br><br>

## Using a package Manager
### Using a package Manager
You can install Crow on GNU/Linux as a pre-made package
=== "Debian/Ubuntu"

Expand All @@ -26,12 +26,12 @@ You can install Crow on GNU/Linux as a pre-made package


<br><br>
## Release package
### Release package
Crow provides an archive containing the framework and CMake files, just copy the `include` folder to `/usr/local/include` and `lib` folder to `/usr/local/lib`.<br><br>
You can also download the `crow_all.h` file and simply include that into your project.
<br><br>
## Installing from source
### Using CMake
### Installing from source
#### Using CMake
1. Download Crow's source code (Either through github's UI or by using<br> `git clone https://github.com/CrowCpp/Crow.git`).
2. Run `mkdir build` inside of crow's source directory.
3. Navigate to the new "build" directory and run the following:<br>
Expand All @@ -41,9 +41,9 @@ You can also download the `crow_all.h` file and simply include that into your pr

You can ignore `-DCROW_BUILD_EXAMPLES=OFF -DCROW_BUILD_TESTS=OFF` if you want to build the Examples and Unit Tests.
<br>
### Manually
#### Manually
Crow can be installed manually on your Linux computer.
#### Multiple header files
##### Multiple header files
=== "Project Only"

Copy Crow's `include` directory to your project's `include` directory.
Expand All @@ -52,23 +52,23 @@ Crow can be installed manually on your Linux computer.

Copy Crow's `include` directory to the `/usr/local/include` directory.

#### Single header (crow_all.h)
##### Single header (crow_all.h)
!!!warning

`crow_all.h` is recommended only for small, possibly single source file projects, and ideally should not be installed on your system.
navigate to the `scripts` directory and run `./merge_all.py ../include crow_all.h`. This will generate a `crow_all.h` file that you can use in your projects.
!!!note

You can also include or exclude middlewares from your `crow_all.h` by using `-i` or `-e` followed by the middleware header file names separated by a comma (e.g. `merge_all.py ../include crow_all.h -e cookie_parser` to exclude the cookie parser middleware).
# Compiling your project
## Using CMake
## Compiling your project
### Using CMake
In order to get your CMake project to work with Crow, all you need are the following lines in your CMakeLists.txt:
```
find_package(Crow)
target_link_libraries(your_project PUBLIC Crow::Crow)
```
From there CMake should handle compiling and linking your project.
## Directly using a compiler
### Directly using a compiler
All you need to do is run the following command:
```
g++ main.cpp -lpthread
Expand Down
26 changes: 13 additions & 13 deletions docs/getting_started/setup/macos.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
Here's how you can install Crow on your Mac.
# Getting Crow
## From a [release](https://github.com/CrowCpp/Crow/releases)
### Archive
## Getting Crow
### From a [release](https://github.com/CrowCpp/Crow/releases)
#### Archive
Crow provides an archive containing the framework and CMake files, You will only need the `include` folder inside that archive.
### Single header file
#### Single header file
You can also download the `crow_all.h` file which replaces the `include` folder.

## From Source
### From Source
To get Crow from source, you only need to download the repository (as a `.zip` or through `git clone https://github.com/CrowCpp/Crow.git`).
### include folder
#### include folder
Once you've downloaded Crow's source code, you only need to take the `include` folder.
### Single header file
You can generate your own single header file by using navigating to the `scripts` folder with your terminal and running the following command:
#### Single header file
You can generate your own single header file by navigating to the `scripts` folder with your terminal and running the following command:
```
python3 merge_all.py ../include crow_all.h
```
Expand All @@ -21,8 +21,8 @@ This will generate a `crow_all.h` file which you can use in the following steps
`crow_all.h` is recommended only for small, possibly single source file projects. For larger projects, it is advised to use the multi-header version.


# Setting up your Crow project
## Using XCode
## Setting up your Crow project
### Using XCode
1. Download and install [Homebrew](https://brew.sh).
2. Run `brew install boost` in your terminal.
3. Create a new XCode project (macOS -> Command Line Tool).
Expand All @@ -35,15 +35,15 @@ This will generate a `crow_all.h` file which you can use in the following steps

=== "Single Header"

1. Place `crow_all.h` inside your project folder and add it to the project in XCode (you need to use the File -> )
1. Place `crow_all.h` inside your project folder and add it to the project in XCode (you need to use File -> Add files to "project_name")
2. Add header search paths for boost's folder (`/usr/local/include`, and `/usr/local/Cellar/boost/include`)
3. Add linker flags (`-lpthread` and `-lboost_system` if you're running an old version of boost)

5. Write your Crow application in `main.cpp` (something like the Hello World example will work).
6. Press `` to compile and run your Crow application.


# Building Crow's tests/examples
## Building Crow's tests/examples
1. Download and install [Homebrew](https://brew.sh).
2. Run `brew install cmake boost` in your terminal.
3. Get Crow's source code (the entire source code).
Expand All @@ -54,4 +54,4 @@ This will generate a `crow_all.h` file which you can use in the following steps
4. `make -j12`
!!!note

You can add options like `-DCROW_ENABLE_SSL`, `-DCROW_ENABLE_COMPRESSION`, or `-DCROW_AMALGAMATE` to `3.c` to build their tests/examples.
You can add options like `-DCROW_ENABLE_SSL`, `-DCROW_ENABLE_COMPRESSION`, or `-DCROW_AMALGAMATE` to `3.c` to build their tests/examples.
10 changes: 5 additions & 5 deletions docs/getting_started/setup/windows.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
Here's how you can install Crow on your Windows machine.
# Getting and Compiling Crow
## Using A package manager
### VCPKG
## Getting and Compiling Crow
### Using A package manager
#### VCPKG
Crow can be simply installed through VCPKG using the command `vcpkg install crow`

## Manually (source or release)
### Microsoft Visual Studio 2019 and VCPKG
### Manually (source or release)
#### Microsoft Visual Studio 2019 and VCPKG
The following guide will use `example_with_all.cpp` as the Crow application for demonstration purposes. VCPKG will be used only to install Crow's dependencies.

1. Generate `crow_all.h` by navigating to the `scripts` folder and running `python3 merge_all.py ..\include crow_all.h`.
Expand Down
10 changes: 5 additions & 5 deletions docs/getting_started/your_first_application.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
This page shows how you can get started with a simple hello world application.

##1. Include
## 1. Include
Starting with an empty `main.cpp` file, first add `#!cpp #define CROW_MAIN` then `#!cpp #include "crow.h"` or `#!cpp #include "crow_all.h"` if you're using the single header file.

!!! note

If you're using multiple C++ source files make sure to have `CROW_MAIN` defined only in your main source file.

##2. App declaration
## 2. App declaration
Next Create a `main()` and declare a `#!cpp crow::SimpleApp` inside, your code should look like this
``` cpp
int main()
Expand All @@ -18,7 +18,7 @@ int main()
The App (or SimpleApp) class organizes all the different parts of Crow and provides the developer (you) a simple interface to interact with these parts.
For more information, please go [here](../../guides/app).

##3. Adding routes
## 3. Adding routes
Once you have your app, the next step is to add routes (or endpoints). You can do so with the `CROW_ROUTE` macro.
``` cpp
CROW_ROUTE(app, "/")([](){
Expand All @@ -27,14 +27,14 @@ CROW_ROUTE(app, "/")([](){
```
For more details on routes, please go [here](../../guides/routes).
#4. Running the app
## 4. Running the app
Once you're happy with how you defined all your routes, you're going to want to instruct Crow to run your app. This is done using the `run()` method.
``` cpp
app.port(18080).multithreaded().run();
```
Please note that the `port()` and `multithreaded()` methods aren't needed, Though not using `port()` will cause the default port (`80`) to be used.<br>

##Putting it all together
## Putting it all together

Once you've followed all the steps above, your code should look similar to this

Expand Down
6 changes: 3 additions & 3 deletions docs/guides/app.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ An app allows access to the http server (for handling connections), router (for

Crow has 2 different app types:

##SimpleApp
## SimpleApp
Has no middlewares.

##App&lt;m1, m2, ...&gt;
## App&lt;m1, m2, ...&gt;
Has middlewares.

##Using the app
## Using the app
To use a Crow app, simply define `#!cpp crow::SimpleApp` or `#!cpp crow::App<m1, m2 ...>` if you're using middlewares.<br>
The methods of an app can be chained. That means that you can configure and run your app in the same code line.
``` cpp
Expand Down
6 changes: 3 additions & 3 deletions docs/guides/json.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Crow has built in support for JSON data.<br><br>

##type
## type
The types of values that `rvalue and wvalue` can take are as follows:<br>

- `False`: from type `bool`.
Expand All @@ -14,15 +14,15 @@ The types of values that `rvalue and wvalue` can take are as follows:<br>
- `Object`: from type `crow::json::wvalue or crow::json::rvalue`.<br>
This last type means that `rvalue or wvalue` can have keys.

##rvalue
## rvalue
JSON read value, used for taking a JSON string and parsing it into `crow::json`.<br><br>

You can read individual items of the rvalue, but you cannot add items to it.<br>
To do that, you need to convert it to a `wvalue`, which can be done by simply writing `#!cpp crow::json::wvalue wval (rval);` (assuming `rval` is your `rvalue`).<br><br>

For more info on read values go [here](/reference/classcrow_1_1json_1_1rvalue.html).<br><br>

#wvalue
## wvalue
JSON write value, used for creating, editing and converting JSON to a string.<br><br>

!!!note
Expand Down
4 changes: 2 additions & 2 deletions docs/guides/logging.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Crow comes with a simple and easy to use logging system.<br><br>

##Setting up logging level
## Setting up logging level
You can set up the level at which crow displays logs by using the app's `loglevel(crow::LogLevel)` method.<br><br>

The available log levels are as follows (please not that setting a level will also display all logs below this level):
Expand All @@ -16,5 +16,5 @@ To set a logLevel, just use `#!cpp app.loglevel(crow::LogLevel::Warning)`, This

Please note that setting the Macro `CROW_ENABLE_DEBUG` during compilation will also set the log level to `Debug`.

##Writing a log
## Writing a log
Writing a log is as simple as `#!cpp CROW_LOG_<LOG LEVEL> << "Hello";` (replace&lt;LOG LEVEL&gt; with the actual level in all caps, so you have `CROW_LOG_WARNING`).
8 changes: 4 additions & 4 deletions docs/guides/middleware.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
Any middleware requires following 3 members:
##struct context
## struct context
Storing data for the middleware; can be read from another middleware or handlers


##before_handle
## before_handle
Called before handling the request.<br>
If `res.end()` is called, the operation is halted. (`after_handle` will still be called)<br>
2 signatures:<br>
Expand All @@ -17,7 +17,7 @@ You can access other middlewares' context by calling `#!cpp all_ctx.template get
`#!cpp ctx == all_ctx.template get<CurrentMiddleware>()`
##after_handle
## after_handle
Called after handling the request.<br>
`#!cpp void after_handle(request& req, response& res, context& ctx)`
Expand All @@ -26,4 +26,4 @@ template <typename AllContext>
void after_handle(request& req, response& res, context& ctx, AllContext& all_ctx)
```
<br><br>
This was pulled from `cookie_parser.h`. Further Editing required, possibly use parts of [@ipkn's wiki page](https://github.com/ipkn/crow/wiki/Middleware).
This was pulled from `cookie_parser.h`. Further Editing required, possibly use parts of [@ipkn's wiki page](https://github.com/ipkn/crow/wiki/Middleware).
1 change: 1 addition & 0 deletions docs/guides/multipart.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
**Introduced in: `v0.2`**<br><br>
Multipart is a way of forming HTTP requests or responses to contain multiple distinct parts.<br>

Such an approach allows a request to contain multiple different pieces of data with potentially conflicting data types in a single response payload.<br>
It is typically used either in html forms, or when uploading multiple files.<br><br>

Expand Down
4 changes: 2 additions & 2 deletions docs/guides/proxies.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ We advise that you set crow up behind some form of reverse proxy if you plan on

When using a proxy, make sure that you **do not** compile Crow with SSL enabled. SSL should be handled by the proxy.

##Apache2
## Apache2

Assuming you have both Apache2 and the modules [proxy](https://httpd.apache.org/docs/2.4/mod/mod_proxy.html), [proxy_http](https://httpd.apache.org/docs/2.4/mod/mod_proxy_http.html), [proxy_html](https://httpd.apache.org/docs/2.4/mod/mod_proxy_html.html) (if you plan on serving html pages), and [proxy_wstunnel](https://httpd.apache.org/docs/2.4/mod/mod_proxy_wstunnel.html) (if you plan on using websockets). You will need to enable those modules, which you can do using the following commands:

Expand Down Expand Up @@ -39,7 +39,7 @@ If you want crow to run in a subdirectory (such as `domain.abc/crow`) you can us

If you're using an Arch Linux based OS. You will have to access `/etc/httpd/conf/httpd.conf` to enable modules and change configuration.

##Nginx
## Nginx

Setting Nginx up is slightly simpler than Apache, all you need is the Nginx package itself. Once you've installed it, go to the configuration file (usually a `.conf` file located in `/etc/nginx`) and add the following lines to your server section (replace `localhost` and `40080` with the address and port you defined for your Crow App):

Expand Down
12 changes: 6 additions & 6 deletions docs/guides/query-string.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,26 @@ A query string is the part of the url that comes after a `?` character, it is us
<br><br>

Crow supports query strings through `crow::request::url_params`. The object is of type `crow::query_string` and can has the following functions:<br>
##get(name)
## get(name)
Returns the value (as char*) based on the given key (or name). Returns `nullptr` if the key is not found.
##pop(name)
## pop(name)
**Introduced in: `v0.3`**<br><br>
Works the same as `get`, but removes the returned value.
!!! note

`crow::request::url_params` is a const value, therefore for pop (also pop_list and pop_dict) to work, a copy needs to be made.

##get_list(name)
## get_list(name)
A url can be `http://example.com?key[]=value1&key[]=value2&key[]=value3`. Using `get_list("key")` on such a url returns an `std::vector<std::string>` containing `[value1, value2, value3]`.<br><br>

`#!cpp get_list("key", false)` can be used to parse `http://example.com?key=value1&key=value2&key=value3`
##pop_list(name)
## pop_list(name)
**Introduced in: `v0.3`**<br><br>
Works the same as `get_list` but removes all instances of values having the given key (`use_brackets` is also available here).
##get_dict(name)
## get_dict(name)
Returns an `std::unordered_map<std::string, std::string>` from a query string such as `?key[sub_key1]=value1&key[sub_key2]=value2&key[sub_key3]=value3`.<br>
The key in the map is what's in the brackets (`sub_key1` for example), and the value being what's after the `=` sign (`value1`). The name passed to the function is not part of the returned value.
##pop_dict(name)
## pop_dict(name)
**Introduced in: `v0.3`**<br><br>
Works the same as `get_dict` but removing the values from the query string.
!!!warning
Expand Down
Loading

0 comments on commit 4ac5892

Please sign in to comment.