0
0
mirror of https://github.com/neon-mmd/websurfx.git synced 2024-11-22 05:58:21 -05:00

Merge branch 'rolling' into rolling

This commit is contained in:
mergify[bot] 2023-10-31 05:39:09 +00:00 committed by GitHub
commit 9aa817cb59
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 613 additions and 193 deletions

View File

@ -6,11 +6,11 @@ Found a typo, or something that isn't as clear as it could be? Maybe I've missed
## Readme ## Readme
Found a typo, or the Readme is not very clear as it should be?. Consider Submitting a Pull request to the [Readme](https://github.com/neon-mmd/websurfx/blob/master/README.md) to add to or improve the Readme. This will help future users to better understand the project more clearly. Did you find a typo, or the Readme is not as clear as it should be? Consider Submitting a Pull request to the [Readme](https://github.com/neon-mmd/websurfx/blob/master/README.md) to add to or improve the Readme. This will help future users to better understand the project more clearly.
## Help Improve Github Actions ## Help Improve GitHub Actions
Know how to fix or improve a github action?. Consider Submitting a Pull request to help make automation and testing better. Know how to fix or improve a GitHub action? Consider Submitting a Pull request to help make automation and testing better.
## Source Code ## Source Code
@ -51,4 +51,4 @@ We have a [Discord](https://discord.gg/SWnda7Mw5u) channel, feel free to join an
The _rolling branch_ is where we intend all contributions should go. The _rolling branch_ is where we intend all contributions should go.
We appreciate any contributions whether be of any size or topic and suggestions to help improve the Websurfx project. Please keep in mind the above requirements and guidelines before submitting a pull request and also if you have any doubts/concerns/questions about the project, its source code or anything related to the project than feel free to ask by opening an [issue](https://github.com/neon-mmd/websurfx/issues) or by asking us on our [Discord](https://discord.gg/SWnda7Mw5u) channel. We appreciate any contributions whether of any size or topic and suggestions to help improve the Websurfx project. Please keep in mind the above requirements and guidelines before submitting a pull request and also if you have any doubts/concerns/questions about the project, its source code or anything related to the project then feel free to ask by opening an [issue](https://github.com/neon-mmd/websurfx/issues) or by asking us on our [Discord](https://discord.gg/SWnda7Mw5u) channel.

541
Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
[package] [package]
name = "websurfx" name = "websurfx"
version = "1.2.5" version = "1.2.15"
edition = "2021" edition = "2021"
description = "An open-source alternative to Searx that provides clean, ad-free, and organic results with incredible speed while keeping privacy and security in mind." description = "An open-source alternative to Searx that provides clean, ad-free, and organic results with incredible speed while keeping privacy and security in mind."
repository = "https://github.com/neon-mmd/websurfx" repository = "https://github.com/neon-mmd/websurfx"
@ -45,6 +45,10 @@ rusty-hook = "^0.11.2"
criterion = "0.5.1" criterion = "0.5.1"
tempfile = "3.8.0" tempfile = "3.8.0"
[build-dependencies]
lightningcss = "1.0.0-alpha.50"
minify-js = "0.5.6"
[profile.dev] [profile.dev]
opt-level = 0 opt-level = 0
debug = true debug = true

View File

@ -181,7 +181,7 @@ At present, we only support x86_64 architecture systems, but we would love to ha
## Why Websurfx? ## Why Websurfx?
The primary purpose of the Websurfx project is to create a fast, secure, and privacy-focused meta-search engine. There are numerous meta-search engines available, but not all guarantee the security of their search engines, which is critical for maintaining privacy. Memory flaws, for example, can expose private or sensitive information, which is understandably bad. There is also the added problem of spam, ads, and inorganic results, which most engines don't have a foolproof answer to. Until now. With Websurfx, I finally put a full stop to this problem. Websurfx is based on Rust, which ensures memory safety and removes such issues. Many meta-search engines also lack important features like advanced picture search, required by graphic designers, content providers, and others. Websurfx improves the user experience by providing these and other features, such as proper NSFW blocking and micro-apps or quick results (providing a calculator, currency exchanges, etc. in the search results). The primary purpose of the Websurfx project is to create a fast, secure, and privacy-focused meta-search engine. There are numerous meta-search engines available, but not all guarantee the security of their search engines, which is critical for maintaining privacy. Memory flaws, for example, can expose private or sensitive information, which is understandably bad. There is also the added problem of spam, ads, and inorganic results, which most engines don't have a full-proof answer to. Until now. With Websurfx, I finally put a full stop to this problem. Websurfx is based on Rust, which ensures memory safety and removes such issues. Many meta-search engines also lack important features like advanced picture search, required by graphic designers, content providers, and others. Websurfx improves the user experience by providing these and other features, such as proper NSFW blocking and micro-apps or quick results (providing a calculator, currency exchanges, etc. in the search results).
## Why AGPLv3? ## Why AGPLv3?

85
build.rs Normal file
View File

@ -0,0 +1,85 @@
//! A build module of the application which minifies the project's css and js files on build which
//! helps reduce the initial page by loading the files faster.
#![forbid(unsafe_code, clippy::panic)]
#![deny(missing_docs, clippy::missing_docs_in_private_items, clippy::perf)]
#![warn(clippy::cognitive_complexity, rust_2018_idioms)]
// ------- Imports -------
use lightningcss::stylesheet::{MinifyOptions, ParserOptions, PrinterOptions, StyleSheet};
use minify_js::{minify, Session, TopLevelMode};
use std::{
fs::{read_dir, read_to_string, File, OpenOptions},
io::{Read, Write},
};
// ------- Constants -------
/// A constant for the path to the public/theme folder in the codebase.
const COMMON_STATIC_SOURCE_CODE_FOLDER: &str = "./public/static/";
/// A constant for the names of the folders located in the "/public/static/"
/// folder in the codebase which contains the css files to be minified.
const STYLE_FOLDERS: [&str; 2] = ["themes", "colorschemes"];
/// A constant for the environment variable name.
const PACKAGE_ENVIRONMENT_VARIABLE: &str = "PKG_ENV";
/// A constant for the `prod` value of the `pkg_env` environment variable.
const PRODUCTION_PKG_ENV_VARIABLE_VALUE: &str = "prod";
/// A main function which minifies both css and js files using `lightningcss` and `minify_js` when
/// the `PKG_ENV` environment and it is set to the value of `prod`.
///
/// # Error
///
/// This function returns the unit type when the minification process runs successfully otherwise
/// it returns a standard error.
fn main() -> Result<(), Box<dyn std::error::Error>> {
if let Ok(pkg_env_var) = std::env::var(PACKAGE_ENVIRONMENT_VARIABLE) {
if pkg_env_var.to_lowercase() == PRODUCTION_PKG_ENV_VARIABLE_VALUE {
// A for loop that loops over each file name containing in the `colorschemes` and `themes` folders
// and minifies it using the `lightningcss` minifier.
for folder_name in STYLE_FOLDERS {
for file in read_dir(format!("{COMMON_STATIC_SOURCE_CODE_FOLDER}{folder_name}/"))? {
let file_path = file?.path();
let source = read_to_string(file_path.clone())?;
let mut stylesheet = StyleSheet::parse(&source, ParserOptions::default())
.map_err(|err| format!("{err}\n{:?}", file_path.file_name().unwrap()))?;
stylesheet.minify(MinifyOptions::default())?;
let minified_css = stylesheet.to_css(PrinterOptions::default())?;
let mut old_css_file = OpenOptions::new()
.write(true)
.truncate(true)
.open(file_path)?;
old_css_file.write_all(minified_css.code.as_bytes())?;
old_css_file.flush()?;
}
}
// A for loop that loops over each file name containing in the `public/static` folder and minifies
// it using the `minify-js` minifier.
for file in read_dir(COMMON_STATIC_SOURCE_CODE_FOLDER)? {
let file_path = file?.path();
if file_path.is_file() {
let mut code = Vec::new();
let mut js_file = File::open(file_path.clone())?;
js_file.read_to_end(&mut code)?;
drop(js_file);
let mut out = Vec::new();
minify(&Session::new(), TopLevelMode::Global, &code, &mut out)
.map_err(|err| format!("{err}\n{:?}", file_path.file_name().unwrap()))?;
let mut old_js_file = OpenOptions::new()
.write(true)
.truncate(true)
.open(file_path)?;
old_js_file.write_all(&out)?;
old_js_file.flush()?;
}
}
}
}
Ok(())
}

View File

@ -1,6 +1,6 @@
# Developing # Developing
This page of the docs outlines how to get **Websurfx** up and running in a development environment, and outlines the common worflow, different ways to work on the project, a high level overview of how the project works, project structure and the best pratices that should be followed when working on the project. This page of the docs outlines how to get **Websurfx** up and running in a development environment, and outlines the common workflow, different ways to work on the project, a high-level overview of how the project works, project structure, and the best practices that should be followed when working on the project.
<details> <details>
<summary><b>Table of Contents</b></summary> <summary><b>Table of Contents</b></summary>
@ -30,50 +30,50 @@ This page of the docs outlines how to get **Websurfx** up and running in a devel
## Setting up the Development Environment ## Setting up the Development Environment
By default, we provide four different ways to work on the project. Which are as follows: By default, we provide four different ways to work on the project. These are as follows:
- [Local Development](#local-development-) - [Local Development](#local-development-)
- [Gitpod](#gitpod-) - [Gitpod](#gitpod-)
- [NixOS Dev Shell using Nix Flake](#nixos-dev-shell-using-nix-flake-) - [NixOS Dev Shell using Nix Flake](#nixos-dev-shell-using-nix-flake-)
- [Local Development with Docker Compose](#local-development-with-docker-compose-) - [Local Development with Docker Compose](#local-development-with-docker-compose-)
The diferent methods are explained in depth below. The different methods are explained in depth below.
### Local Development ### Local Development
This section covers how to setup the project for development on your local machine (bare metal). This section covers how to set up the project for development on your local machine (bare metal).
#### Prerequisites #### Prerequisites
Before you start working on the project. You will need the following packages installed on your system: Before you start working on the project. You will need the following packages installed on your system:
- A latest version of `cargo` installed on your system which is required to manage building and running the project. The installation instruction for this can be found [here](https://doc.rust-lang.org/cargo/getting-started/installation.html). - The latest version of `cargo` installed on your system which is required to manage building and running the project. The installation instructions for this can be found [here](https://doc.rust-lang.org/cargo/getting-started/installation.html).
- A latest version of `npm` installed on your system which is required to allow the installation of other tools necessary for the project. The installation for this can be found [here](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm). - The latest version of `npm` installed on your system which is required to allow the installation of other tools necessary for the project. The installation for this can be found [here](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm).
- A latest version of `redis` installed on your system which will be used to avoid introducing unexpected issue when working on the project. The installation for this can be found [here](https://redis.io/docs/getting-started/installation/). - The latest version of `redis` installed on your system which will be used to avoid introducing unexpected issues when working on the project. The installation for this can be found [here](https://redis.io/docs/getting-started/installation/).
- A latest version of `stylelint` should be installed on your system which will be used by the pre-commit checks to lint the code before a commit can be made to ensure better code quality. Before you install `stylelint` on your system, make sure you have `npm` installed on you system. To install `stylelint` run the following command: - The latest version of `stylelint` should be installed on your system which will be used by the pre-commit checks to lint the code before a commit can be made to ensure better code quality. Before you install `stylelint` on your system, make sure you have `npm` installed on your system. To install `stylelint` run the following command:
```shell ```shell
$ npm i -g stylelint $ npm i -g stylelint
``` ```
> **Note** > **Note**
> In the above command the dollar sign(**$**) refers to running the command in privilaged mode by using utilities `sudo`, `doas`, `pkgexec` or any other privilage access methods. > In the above command the dollar sign(**$**) refers to running the command in privileged mode by using utilities `sudo`, `doas`, `pkgexec`, or any other privileged access methods.
- `Cargo-watch` installed on your system which will allow to auto build the project when any checks occur in the source code files in the codebase (`websurfx` directory). Before you install `cargo-watch` on your system, make sure you have `cargo` installed on your system. To install `cargo-watch` run the following command: - `Cargo-watch` installed on your system which will allow you to auto-build the project when any checks occur in the source code files in the codebase (`websurfx` directory). Before you install `cargo-watch` on your system, make sure you have `cargo` installed on your system. To install `cargo-watch` run the following command:
```shell ```shell
cargo install cargo-watch cargo install cargo-watch
``` ```
- `Git` installed on your system. The installation instruction for this can be found [here](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git). - `Git` installed on your system. The installation instructions for this can be found [here](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git).
- Finally, A latest version of `Docker` installed on your system which will be used to avoid introducing unexpected issue when working on the project. The installation instructions for this can be found [here](https://docs.docker.com/engine/install/). - Finally, The latest version of `Docker` is installed on your system which will be used to avoid introducing unexpected issues when working on the project. The installation instructions for this can be found [here](https://docs.docker.com/engine/install/).
> **Note** > **Note**
> For **rolling release linux distributions (distros)**, the above mentioned all required packages except for `stylelint` and `cargo-watch` can also be installed via the distro specific package manager. > For **rolling release Linux distributions (distros)**, the above-mentioned required packages except for `stylelint` and `cargo-watch` can also be installed via the distro-specific package manager.
> >
> **For Example:** > **For Example:**
> >
> On `arch linux` the following packages could be installed by following link to the installation instructions provided down below: > On `arch linux` the following packages can be installed by following the link to the installation instructions provided below:
> >
> - `Cargo`: https://wiki.archlinux.org/title/rust > - `Cargo`: https://wiki.archlinux.org/title/rust
> - `Npm`: https://wiki.archlinux.org/title/Node.js > - `Npm`: https://wiki.archlinux.org/title/Node.js
@ -81,24 +81,24 @@ cargo install cargo-watch
> - `Git`: https://wiki.archlinux.org/title/git > - `Git`: https://wiki.archlinux.org/title/git
> - `Docker`: https://wiki.archlinux.org/title/docker > - `Docker`: https://wiki.archlinux.org/title/docker
> >
> But we do not recommend this method for **stable release linux distros** as they tend to not provide very up to date versions of the required packages. > But we do not recommend this method for **stable release Linux distros** as they tend to not provide very up-to-date versions of the required packages.
#### Setting up Pre-commit Checks #### Setting up Pre-commit Checks
Before you setup `pre-commit` checks, you will first need to clone **your fork of the project** and navigate into the cloned repository by running the following command: Before you set `pre-commit` checks, you will first need to clone **your fork of the project** and navigate into the cloned repository by running the following command:
```shell ```shell
git clone https://github.com/<your_github_username>/websurfx.git git clone https://github.com/<your_github_username>/websurfx.git
cd websurfx cd websurfx
``` ```
Once you have done finished running the above commands then run the following command to setup the `pre-commit` checks: Once you have finished running the above commands then run the following command to set the `pre-commit` checks:
```shell ```shell
cargo test cargo test
``` ```
By the running the above mentioned command, it will automatically setup all the pre-commit checks in the project. By running the above-mentioned command, it will automatically set up all the pre-commit checks in the project.
#### Running the Project #### Running the Project
@ -108,7 +108,7 @@ If you have followed the above section then you should have a cloned repository
cargo watch -q -x "run" -w "." cargo watch -q -x "run" -w "."
``` ```
This will compile the app by default with the **In-Memory caching** feature. To compile, run and test the app with other features then follow the build options listed below: This will compile the app by default with the **In-Memory caching** feature. To compile, run, and test the app with other features follow the build options listed below:
##### Hybrid Cache ##### Hybrid Cache
@ -140,13 +140,13 @@ cargo watch -q -x "run --no-default-features --features redis-cache" -w .
> redis-server --port 8082 & > redis-server --port 8082 &
> ``` > ```
Once you have finished running the above command, Websurfx should now be served on the address http://127.0.0.1:8080. Hot reload is enabled, so making changes to any of the files will trigger the project to being rebuilt. Once you have finished running the above command, Websurfx should now be served on the address http://127.0.0.1:8080. Hot reload is enabled, so making changes to any of the files will trigger the project to be rebuilt.
> For more info on all the project commands. See: [**Project Commands**](#project-commands-) > For more info on all the project commands. See: [**Project Commands**](#project-commands-)
### Gitpod ### Gitpod
This section covers on how to use and setup the Gitpod development environment for working on the project. This section covers how to use and set up the Gitpod development environment for working on the project.
> **Note** > **Note**
> By default the project only supports the Vscode **IDE/Editor** for Gitpod. > By default the project only supports the Vscode **IDE/Editor** for Gitpod.
@ -167,7 +167,7 @@ https://gitpod.io/#https://github.com/<your_github_username>/websurfx
The project by default provides a set of pre-installed plugins for gitpod which is done to improve productivity and efficiency while working on the project. Also to make working on the project more fun and engaging which can be customized from within the `Gitpod` instance. The project by default provides a set of pre-installed plugins for gitpod which is done to improve productivity and efficiency while working on the project. Also to make working on the project more fun and engaging which can be customized from within the `Gitpod` instance.
The list of all the pre-installed plugins are listed down below: The list of all the pre-installed plugins are listed below:
**Productivity** **Productivity**
@ -191,7 +191,7 @@ The list of all the pre-installed plugins are listed down below:
- [Test Explorer UI](https://open-vsx.org/extension/hbenl/vscode-test-explorer): Provides a way to run any test from a convenient sidebar. - [Test Explorer UI](https://open-vsx.org/extension/hbenl/vscode-test-explorer): Provides a way to run any test from a convenient sidebar.
- [GitLens](https://open-vsx.org/extension/eamodio/gitlens): Provides a better and more efficient way to manage common git workflows. - [GitLens](https://open-vsx.org/extension/eamodio/gitlens): Provides a better and more efficient way to manage common git workflows.
> Optionally, if you prefer more keyboard centric workflow then we would recommend using the following extension: > Optionally, if you prefer a more keyboard-centric workflow then we would recommend using the following extension:
> >
> - [VSCode Neovim](https://open-vsx.org/extension/asvetliakov/vscode-neovim): Provides complete vim emulation for vscode. > - [VSCode Neovim](https://open-vsx.org/extension/asvetliakov/vscode-neovim): Provides complete vim emulation for vscode.
@ -204,16 +204,16 @@ The list of all the pre-installed plugins are listed down below:
### NixOS Dev Shell using Nix Flake ### NixOS Dev Shell using Nix Flake
This section covers on how to setup the project for development using the `NixOS dev-shell`. This section covers how to setup the project for development using the `NixOS dev-shell`.
#### Pre Setup Requirements #### Pre Setup Requirements
Before you start working on the project. You will need the following packages installed on your system: Before you start working on the project. You will need the following packages installed on your system:
- `Git` installed on your system. The installation instruction for this can be found [here](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git). - `Git` installed on your system. The installation instructions for this can be found [here](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git).
- Finally, A latest version of `Docker` installed on your system which will be used to avoid introducing unexpected issue when working on the project. The installation instructions for this can be found [here](https://docs.docker.com/engine/install/). - Finally, The latest version of `Docker` is installed on your system which will be used to avoid introducing unexpected issues when working on the project. The installation instructions for this can be found [here](https://docs.docker.com/engine/install/).
> Optionally, On `NixOS` the above mentioned all required packages except for `stylelint` and `cargo-watch` could also be installed by following link to the installation instructions provided down below: > Optionally, On `NixOS` the above-mentioned required packages except for `stylelint` and `cargo-watch` could also be installed by following the link to the installation instructions provided below:
> >
> - `Git`: https://search.nixos.org/packages?channel=23.05&show=git&from=0&size=50&sort=relevance&type=packages&query=git > - `Git`: https://search.nixos.org/packages?channel=23.05&show=git&from=0&size=50&sort=relevance&type=packages&query=git
> - `Docker`: https://search.nixos.org/packages?channel=23.05&show=docker&from=0&size=50&sort=relevance&type=packages&query=docker > - `Docker`: https://search.nixos.org/packages?channel=23.05&show=docker&from=0&size=50&sort=relevance&type=packages&query=docker
@ -233,19 +233,19 @@ Then run the following command to setup the `NixOS dev-shell`:
nix develop nix develop
``` ```
Once you have done finished running the above commands then run the following command to setup the `pre-commit` checks: Once you have finished running the above commands then run the following command to setup the `pre-commit` checks:
```shell ```shell
cargo test cargo test
``` ```
By the running the above mentioned command, it will automatically setup all the pre-commit checks in the project. By running the above-mentioned command, it will automatically set up all the pre-commit checks in the project.
#### Post Setup Requirements #### Post Setup Requirements
After you have done setting up pre-commit checks, then you may need to fullfill a few more requirements to finish setting up the development environment with `NixOS dev-shell`. These include: After you have done setting up pre-commit checks, then you may need to fulfill a few more requirements to finish setting up the development environment with `NixOS dev-shell`. These include:
- `Cargo-watch` installed on your system which will allow to auto build the project when any checks occur in the source code files in the codebase (`websurfx` directory). Before you install `cargo-watch` on your system, make sure you have `cargo` installed on your system. To install `cargo-watch` run the following command: - `Cargo-watch` installed on your system which will allow you to auto-build the project when any checks occur in the source code files in the codebase (`websurfx` directory). Before you install `cargo-watch` on your system, make sure you have `cargo` installed on your system. To install `cargo-watch` run the following command:
```shell ```shell
cargo install cargo-watch cargo install cargo-watch
@ -259,7 +259,7 @@ If you have followed the above section then you should now be inside a `dev-shel
cargo watch -q -x "run" -w "." cargo watch -q -x "run" -w "."
``` ```
This will compile the app by default with the **In-Memory caching** feature. To compile, run and test the app with other features then follow the build options listed below: This will compile the app by default with the **In-Memory caching** feature. To compile, run, and test the app with other features follow the build options listed below:
##### Hybrid Cache ##### Hybrid Cache
@ -285,49 +285,49 @@ To build the search engine with the `Redis caching` feature. Run the following c
cargo watch -q -x "run --no-default-features --features redis-cache" -w . cargo watch -q -x "run --no-default-features --features redis-cache" -w .
``` ```
> Optionally, If you have build and run the app with the `Redis cache`or `Hybrid cache` feature (as mentioned above) then you will need to start the redis server alongside the app which can be done so by running the following command: > Optionally, If you have build and run the app with the `Redis cache`or `Hybrid cache` feature (as mentioned above) then you will need to start the redis server alongside the app which can be done by running the following command:
> >
> ```shell > ```shell
> redis-server --port 8082 & > redis-server --port 8082 &
> ``` > ```
Once you have finished running the above command, Websurfx should now be served on the address http://127.0.0.1:8080. Hot reload is enabled, so making changes to any of the files will trigger the project to being rebuilt. Once you have finished running the above command, Websurfx should now be served on the address http://127.0.0.1:8080. Hot reload is enabled, so making changes to any of the files will trigger the project to be rebuilt.
### Local Development with Docker Compose ### Local Development with Docker Compose
This section covers how to setup the project for development on your local machine (bare metal) using `docker compose`. This section covers how to set up the project for development on your local machine (bare metal) using `docker compose`.
#### Prerequisites #### Prerequisites
Before you start working on the project. You will need the following packages installed on your system: Before you start working on the project. You will need the following packages installed on your system:
- A latest version of `cargo` installed on your system which is required to manage building and running the project. The installation instruction for this can be found [here](https://doc.rust-lang.org/cargo/getting-started/installation.html). - The latest version of `cargo` installed on your system which is required to manage the building and running the project. The installation instructions for this can be found [here](https://doc.rust-lang.org/cargo/getting-started/installation.html).
- A latest version of `npm` installed on your system which is required to allow the installation of other tools necessary for the project. The installation for this can be found [here](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm). - The latest version of `npm` installed on your system which is required to allow the installation of other tools necessary for the project. The installation for this can be found [here](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm).
- A latest version of `stylelint` should be installed on your system which will be used by the pre-commit checks to lint the code before a commit can be made to ensure better code quality. Before you install `stylelint` on your system, make sure you have `npm` installed on you system. To install `stylelint` run the following command: - The latest version of `stylelint` should be installed on your system which will be used by the pre-commit checks to lint the code before a commit can be made to ensure better code quality. Before you install `stylelint` on your system, make sure you have `npm` installed on your system. To install `stylelint` run the following command:
```shell ```shell
$ npm i -g stylelint $ npm i -g stylelint
``` ```
> **Note** > **Note**
> In the above command the dollar sign(**$**) refers to running the command in privilaged mode by using utilities `sudo`, `doas`, `pkgexec` or any other privilage access methods. > In the above command the dollar sign(**$**) refers to running the command in privileged mode by using utilities `sudo`, `doas`, `pkgexec`, or any other privileged access methods.
- `Git` installed on your system. The installation instruction for this can be found [here](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git). - `Git` installed on your system. The installation instructions for this can be found [here](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git).
- Finally, A latest version of `Docker` installed on your system which will be used to avoid introducing unexpected issue when working on the project. The installation instructions for this can be found [here](https://docs.docker.com/engine/install/). - Finally, The latest version of `Docker` is installed on your system which will be used to avoid introducing unexpected issues when working on the project. The installation instructions for this can be found [here](https://docs.docker.com/engine/install/).
> **Note** > **Note**
> For **rolling release linux distributions (distros)**, the above mentioned all required packages can also be installed via the distro specific package manager. > For **rolling release Linux distributions (distros)**, the above-mentioned all required packages can also be installed via the distro-specific package manager.
> >
> **For Example:** > **For Example:**
> >
> On `arch linux` the following packages could be installed by following link to the installation instructions provided down below: > On `arch linux` the following packages can be installed by following the link to the installation instructions provided below:
> >
> - `Cargo`: https://wiki.archlinux.org/title/rust > - `Cargo`: https://wiki.archlinux.org/title/rust
> - `Npm`: https://wiki.archlinux.org/title/Node.js > - `Npm`: https://wiki.archlinux.org/title/Node.js
> - `Git`: https://wiki.archlinux.org/title/git > - `Git`: https://wiki.archlinux.org/title/git
> - `Docker`: https://wiki.archlinux.org/title/docker > - `Docker`: https://wiki.archlinux.org/title/docker
> >
> But we do not recommend this method for **stable release linux distros** as they tend to not provide very up to date versions of the required packages. > But we do not recommend this method for **stable release Linux distros** as they tend to not provide very up-to-date versions of the required packages.
#### Setting up Pre-commit Checks #### Setting up Pre-commit Checks
@ -338,13 +338,13 @@ git clone https://github.com/<your_github_username>/websurfx.git
cd websurfx cd websurfx
``` ```
Once you have done finished running the above commands then run the following command to setup the `pre-commit` checks: Once you have finished running the above commands then run the following command to setup the `pre-commit` checks:
```shell ```shell
cargo test cargo test
``` ```
By the running the above mentioned command, it will automatically setup all the pre-commit checks in the project. By running the above-mentioned command, it will automatically set up all the pre-commit checks in the project.
#### Running the Project #### Running the Project
@ -355,9 +355,9 @@ $ docker compose -f dev.docker-compose.yml up
``` ```
> **Note** > **Note**
> In the above command the dollar sign(**$**) refers to running the command in privilaged mode by using utilities `sudo`, `doas`, `pkgexec` or any other privilage access methods. > In the above command the dollar sign(**$**) refers to running the command in privileged mode by using utilities `sudo`, `doas`, `pkgexec`, or any other privileged access methods.
Once you have finished running the above command, Websurfx should now be served on the address http://127.0.0.1:8080. Hot reload is enabled, so making changes to any of the files will trigger the project to being rebuilt. Once you have finished running the above command, Websurfx should now be served on the address http://127.0.0.1:8080. Hot reload is enabled, so making changes to any of the files will trigger the project to be rebuilt.
### Project Commands ### Project Commands
@ -383,12 +383,12 @@ Once you have finished running the above command, Websurfx should now be served
### Environment Variables ### Environment Variables
All environmental variables are optional. Currently there are not many environmental variables used, as most of the user preferences are stored under the `websurfx` folder (located under the codebase (`websurfx` directory)) in the `config.lua` file. All environment variables are optional. Currently, there are not many environment variables used, as most of the user preferences are stored under the `websurfx` folder (located under the codebase (`websurfx` directory)) in the `config.lua` file.
The list of all the available environment variables are listed down below: The list of all the available environment variables are listed below:
- `PKG_ENV`: Sets the logging level for the app to **Trace** which can be useful for better debugging of the app. This environment variables accept two values `dev` or `prod` as strings. - `PKG_ENV`: Sets the logging level for the app to **Trace** which can be useful for better debugging of the app. These environment variables accept two values `dev` or `prod` as strings.
- `RUST_BACKTRACE`: Rust specific environment variable useful for getting more elaborate error messages with an error stack to better diagnose the issue. This environment variable accepts three values `0` (off), `1` (on) and `full` (for long error stack to being printed out). - `RUST_BACKTRACE`: Rust-specific environment variable useful for getting more elaborate error messages with an error stack to better diagnose the issue. This environment variable accepts three values `0` (off), `1` (on), and `full` (for long error stack to being printed out).
## Git Strategy ## Git Strategy
@ -396,9 +396,9 @@ The list of all the available environment variables are listed down below:
Like most Git repos, we are following the [Github Flow](https://guides.github.com/introduction/flow) standard. Like most Git repos, we are following the [Github Flow](https://guides.github.com/introduction/flow) standard.
1. Create a branch (or fork if you don'd have write access) 1. Create a branch (or fork if you don't have write access)
2. Code some awesome stuff 🧑‍💻 2. Code some awesome stuff 🧑‍💻
3. Add, commit and push your changes to your branch/ fork 3. Add, commit, and push your changes to your branch/ fork
4. Head over to GitHub and create a Pull Request 4. Head over to GitHub and create a Pull Request
5. Fill in the required sections in the template, and hit submit 5. Fill in the required sections in the template, and hit submit
6. Follow up with any reviews on your code 6. Follow up with any reviews on your code
@ -411,9 +411,9 @@ For example, `FEATURE/420_Awesome-feature` or `FIX/690_login-server-error`
### Commit Emojis ### Commit Emojis
Using a single emoji at the start of each commit message, issue title, and pull request title, to indicate the type task, makes the commit ledger, issue and pull request easier to understand, plus it looks cool. Using a single emoji at the start of each commit message, issue title, and pull request title, to indicate the type of task, makes the commit ledger, issue, and pull request easier to understand, it looks cool.
- 🎨 `:art:` - Improve structure / format of the code. - 🎨 `:art:` - Improve the structure/format of the code.
- ⚡️ `:zap:` - Improve performance. - ⚡️ `:zap:` - Improve performance.
- 🔥 `:fire:` - Remove code or files. - 🔥 `:fire:` - Remove code or files.
- 🐛 `:bug:` - Fix a bug. - 🐛 `:bug:` - Fix a bug.
@ -426,15 +426,15 @@ Using a single emoji at the start of each commit message, issue title, and pull
- ✅ `:white_check_mark:` - Add, update, or pass tests. - ✅ `:white_check_mark:` - Add, update, or pass tests.
- 🔒️ `:lock:` - Fix security issues. - 🔒️ `:lock:` - Fix security issues.
- 🔖 `:bookmark:` - Make a Release or Version tag. - 🔖 `:bookmark:` - Make a Release or Version tag.
- 🚨 `:rotating_light:` - Fix compiler / linter warnings. - 🚨 `:rotating_light:` - Fix compiler/linter warnings.
- 🚧 `:construction:` - Work in progress. - 🚧 `:construction:` - Work in progress.
- ⬆️ `:arrow_up:` - Upgrade dependencies. - ⬆️ `:arrow_up:` - Upgrade dependencies.
- 👷 `:construction_worker:` - Add or update CI build system. - 👷 `:construction_worker:` - Add or update the CI build system.
- ♻️ `:recycle:` - Refactor code. - ♻️ `:recycle:` - Refactor code.
- 🩹 `:adhesive_bandage:` - Simple fix for a non-critical issue. - 🩹 `:adhesive_bandage:` - Simple fix for a non-critical issue.
- 🔧 `:wrench:` - Add or update configuration files. - 🔧 `:wrench:` - Add or update configuration files.
- 🍱 `:bento:` - Add or update assets. - 🍱 `:bento:` - Add or update assets.
- 🗃️ `:card_file_box:` - Perform database schema related changes. - 🗃️ `:card_file_box:` - Perform database schema-related changes.
- ✏️ `:pencil2:` - Fix typos. - ✏️ `:pencil2:` - Fix typos.
- 🌐 `:globe_with_meridians:` - Internationalization and translations. - 🌐 `:globe_with_meridians:` - Internationalization and translations.
@ -446,26 +446,26 @@ Once you've made your changes, and pushed them to your fork or branch, you're re
For a pull request to be merged, it must: For a pull request to be merged, it must:
- The build, lint and tests (run by GH actions) must pass - The build, lint, and tests (run by GH actions) must pass
- There must not be any merge conflicts - There must not be any merge conflicts
When you submit your pull request, include the required info, by filling out the pull request template. Including: When you submit your pull request, include the required info, by filling out the pull request template. Including:
- A brief description of your changes. - A brief description of your changes.
- The issue or ticket number (if applicable). - The issue or ticket number (if applicable).
- For UI related updates include a screenshot. - For UI-related updates include a screenshot.
- If any dependencies were added, explain why it was needed, state the cost. associated, and confirm it does not introduce any security, privacy or speed issues - If any dependencies were added, explain why it was needed, and state the cost. associated, and confirm it does not introduce any security, privacy, or speed issues
- Optionally, provide a checklist of all the changes that was included in the pull request. - Optionally, provide a checklist of all the changes that were included in the pull request.
> **Important** > **Important**
> Make sure to fill all the required/mandatory sections of the pull request as by filling them it helps us distinguish between spam pull requests and legitimate pull requests. > Make sure to fill all the required/mandatory sections of the pull request as filling them helps us distinguish between spam pull requests and legitimate pull requests.
> **Note** > **Note**
> The pull request template contains comments in the following form `<!-- -->` which are used to provide a guide on what should be provided under each heading of the template. These comments are never rendered when the pull request is either created or updated and hence anything provided in such comments is never displayed. > The pull request template contains comments in the following form `<!-- -->` which are used to provide a guide on what should be provided under each heading of the template. These comments are never rendered when the pull request is either created or updated and hence anything provided in such comments is never displayed.
## Resources for Beginners ## Resources for Beginners
New to Web Development? Or New to GitHub? Glad to see you're here!! :slightly_smiling_face: Websurfx is a pretty simple app, so it should make a good candidate for your first PR. The following articles (which has been divided into parts for convenience) should point you in the right direction for getting up to speed with the technologies used in this project: New to Web Development? Or New to GitHub? Glad to see you're here!! :slightly_smiling_face: Websurfx is a pretty simple app, so it should make a good candidate for your first PR. The following articles (which have been divided into parts for convenience) should point you in the right direction for getting up to speed with the technologies used in this project:
**Development** **Development**
@ -489,7 +489,7 @@ New to Web Development? Or New to GitHub? Glad to see you're here!! :slightly_sm
- [A Tutorial on Git](https://piped.kavin.rocks/playlist?list=PL4lTrYcDuAfxAgSefXftJXbhw0qvjfOFo) - [A Tutorial on Git](https://piped.kavin.rocks/playlist?list=PL4lTrYcDuAfxAgSefXftJXbhw0qvjfOFo)
- [Git cheat sheet](http://git-cheatsheet.com/) - [Git cheat sheet](http://git-cheatsheet.com/)
For Rust, CSS, JS, Html, Git and Docker- you'll need an IDE (e.g. [VSCode](https://code.visualstudio.com/) or [Neovim](https://neovim.io/) and a terminal (Windows users may find [WSL](https://docs.microsoft.com/en-us/windows/wsl/) more convenient). For Rust, CSS, JS, HTML, Git, and Docker- you'll need an IDE (e.g. [VSCode](https://code.visualstudio.com/) or [Neovim](https://neovim.io/) and a terminal (Windows users may find [WSL](https://docs.microsoft.com/en-us/windows/wsl/) more convenient).
## App Info ## App Info
@ -509,7 +509,7 @@ Styleguides to follow:
## Application Structure ## Application Structure
> **Important** > **Important**
> We follow the unix style naming conventions for all the file and folders in the project (except for all files under the `themes` and `colorschemes` folder in the frontend's source code which requires that the names of the files and folders should be in lowercase and the words be seperated with a hyphen.) which includes the name of the files and folders should be in lowercase and every word should be seperated with an underscore. > We follow the Unix style naming conventions for all the files and folders in the project (except for all files under the `themes` and `colorschemes` folder in the frontend's source code which requires that the names of the files and folders should be in lowercase and the words be separated with a hyphen.) which includes the name of the files and folders should be in lowercase and every word should be separated with an underscore.
**Files in the root of the codebase:** `./` **Files in the root of the codebase:** `./`
@ -543,21 +543,21 @@ Styleguides to follow:
├── static # The directory containing all the UI handlers. ├── static # The directory containing all the UI handlers.
│ ├── cookies.js # Handles the loading of saved cookies. │ ├── cookies.js # Handles the loading of saved cookies.
│ ├── error_box.js # Handles the toggling functionality of the error box on the search page. │ ├── error_box.js # Handles the toggling functionality of the error box on the search page.
│ ├── index.js # Functions to handle the searching functionality of the search bar. │ ├── index.js # Functions to handle the search functionality of the search bar.
│ ├── pagination.js # Functions to handle the navigation between previous and next page in the search page. │ ├── pagination.js # Functions to handle the navigation between the previous and next page in the search page.
│ ├── search_area_options.js # Changes the search options under the search bar in the search page according to the safe search level set using the url safesearch parameter. │ ├── search_area_options.js # Changes the search options under the search bar in the search page according to the safe search level set using the URL safesearch parameter.
│ ├── settings.js # Handles the getting and saving of all the settings page options as a cookie. │ ├── settings.js # Handles the settings and saving of all the settings page options as a cookie.
│ ├── colorschemes # A folder containing all the popular colorscheme files as CSS files. │ ├── colorschemes # A folder containing all the popular colorscheme files as CSS files.
│ └── themes # A folder containing all the popular theme files as CSS files. │ └── themes # A folder containing all the popular theme files as CSS files.
└── templates # Folder containing all the template files for the different pages on the website. └── templates # Folder containing all the template files for the different pages on the website.
├── 404.html # A 404 page template. ├── 404.html # A 404-page template.
├── about.html # An about page template. ├── about.html # An about page template.
├── bar.html # A template for the search bar. ├── bar.html # A template for the search bar.
├── cookies_tab.html # A template for the cookies tab for the settings page. ├── cookies_tab.html # A template for the cookies tab for the settings page.
├── engines_tab.html # A template for the engines tab for the settings page. ├── engines_tab.html # A template for the engines tab for the settings page.
├── footer.html # A footer template for all page. ├── footer.html # A footer template for all pages.
├── general_tab.html # A template for the general tab for the settings page. ├── general_tab.html # A template for the general tab for the settings page.
├── header.html # A header template for all page. ├── header.html # A header template for all pages.
├── index.html # A home page template. ├── index.html # A home page template.
├── navbar.html # A navbar template for the header template. ├── navbar.html # A navbar template for the header template.
├── search.html # A search page template. ├── search.html # A search page template.
@ -572,7 +572,7 @@ Styleguides to follow:
./src/ ./src/
├── lib.rs # A library file for the rust project. ├── lib.rs # A library file for the rust project.
├── bin # A folder containing the source code that would produce the binary file when compiled. ├── bin # A folder containing the source code that would produce the binary file when compiled.
│ └── websurfx.rs # A file that would be compiled into binary file. │ └── websurfx.rs # A file that would be compiled into a binary file.
├── cache # A folder that contains code to handle the caching functionality of the search engine. ├── cache # A folder that contains code to handle the caching functionality of the search engine.
│ ├── cacher.rs # Handles the different caching features. │ ├── cacher.rs # Handles the different caching features.
│ ├── error.rs # Provides custom error messages for different types of caches and their related errors. │ ├── error.rs # Provides custom error messages for different types of caches and their related errors.
@ -587,7 +587,7 @@ Styleguides to follow:
│ ├── mod.rs # A module file for the rust project. │ ├── mod.rs # A module file for the rust project.
│ ├── search_result_parser.rs # Provides helper function to help ease the process of defining different result selection selectors. │ ├── search_result_parser.rs # Provides helper function to help ease the process of defining different result selection selectors.
│ └── searx.rs # Provides code to fetch and remove unnecessary or waste results from the fetched results from the searx engine. │ └── searx.rs # Provides code to fetch and remove unnecessary or waste results from the fetched results from the searx engine.
├── handler # A folder that provides helper code to provide a proper path to the public (theme) folder, config file, blocklist file and allowlist file based on where they are located. ├── handler # A folder that provides helper code to provide a proper path to the public (theme) folder, config file, blocklist file, and allowlist file based on where they are located.
│ ├── mod.rs # A module file for the rust project. │ ├── mod.rs # A module file for the rust project.
│ └── paths.rs # Provides helper code to handle different paths. │ └── paths.rs # Provides helper code to handle different paths.
├── models # A folder that provides different models for the different modules in the backend code. ├── models # A folder that provides different models for the different modules in the backend code.
@ -596,10 +596,10 @@ Styleguides to follow:
│ ├── mod.rs # A module file for the rust project. │ ├── mod.rs # A module file for the rust project.
│ ├── parser_models.rs # Provides different models (enums, structs) for handling and standardizing different parts in the "config" module code. │ ├── parser_models.rs # Provides different models (enums, structs) for handling and standardizing different parts in the "config" module code.
│ └── server_models.rs # Provides different models (enums, structs) for handling and standardizing different parts in the "server" module code. │ └── server_models.rs # Provides different models (enums, structs) for handling and standardizing different parts in the "server" module code.
├── results # A folder that provides code to handle the feching and aggregating of results from the upstream search engines. ├── results # A folder that provides code to handle the fetching and aggregating of results from the upstream search engines.
│ ├── aggregator.rs # Provides code aggregate and fetch results from the upstream engines. │ ├── aggregator.rs # Provides code aggregate and fetches results from the upstream engines.
│ ├── mod.rs # A module file for the rust project. │ ├── mod.rs # A module file for the rust project.
│ └── user_agent.rs # Provides a helper function to provide random user-agents to pass in the server request code to improve user privacy and avoiding detected as a bot. │ └── user_agent.rs # Provides a helper function to allow random user agents to pass in the server request code to improve user privacy and avoiding detected as a bot.
└── server # A folder that holds code to handle the routes for the search engine website. └── server # A folder that holds code to handle the routes for the search engine website.
├── mod.rs # A module file for the rust project. ├── mod.rs # A module file for the rust project.
├── router.rs # Provides functions to handle the different routes on the website. ├── router.rs # Provides functions to handle the different routes on the website.
@ -612,19 +612,19 @@ Styleguides to follow:
### Performance - Lighthouse ### Performance - Lighthouse
The easiest method of checking performance is to use Chromium's build in auditing tool, Lighthouse. To run the test, open Developer Tools (usually F12) --> Lighthouse and click on the 'Generate Report' button at the bottom. The easiest method of checking performance is to use Chromium's built-in auditing tool, Lighthouse. To run the test, open Developer Tools (usually F12) --> Lighthouse and click on the 'Generate Report' button at the bottom.
## Notes ## Notes
### Known warnings ### Known warnings
When running the build command, a warning appear. These is not an error, and do not affect the security or performance of the application. They will be addressed soon in a future update. When running the build command, a warning appears. This is not an error and does not affect the security or performance of the application. They will be addressed soon in a future update.
```shell ```shell
warning: the following packages contain code that will be rejected by a future version of Rust: html5ever v0.23.0 warning: the following packages contain code that will be rejected by a future version of Rust: html5ever v0.23.0
note: to see what the problems were, use the option `--future-incompat-report`, or run `cargo report future-incompatibilities --id 2` note: to see what the problems were, use the option `--future-incompat-report`, or run `cargo report future-incompatibilities --id 2`
``` ```
These warning just means that any dependencies or code using the `html5ever` code would be deprecated and rejected in the futures versions of the rust lanaguage. So right now these dependencies can be used as these has not happened yet. This warning just means that any dependencies or code using the `html5ever` code would be deprecated and rejected in future versions of the Rust language. So right now these dependencies can be used as these have not happened yet.
[⬅️ Go back to Home](./README.md) [⬅️ Go back to Home](./README.md)