neon_arch commited on
Commit
975e8a4
·
unverified ·
2 Parent(s): 5b4a6a8 662cbcf

Merge branch 'rolling' into handle-reqwest-errors

Browse files
.github/CODE_OF_CONDUCT.md ADDED
@@ -0,0 +1,85 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
6
+
7
+ We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community and as such we strongly believe in **give respect and take respect** policy.
8
+
9
+ # What We Strive At
10
+
11
+ * **Be patient.**
12
+ * **Be welcoming and be friendly**: We strive to be a community that welcomes, supports and remain friendly to people of all backgrounds and identities. This includes, but is not limited to members of any race, ethnicity, culture, national origin, colour, immigration status, social and economic class, educational level, sex, sexual orientation, gender identity and expression, age, size, family status, political belief, religion, and mental and physical ability.
13
+ * **Be considerate**: Your work will be used by other people, and you in turn will depend on the work of others. Any decision you take will affect users and colleagues, and you should take those consequences into account when making decisions. Remember that we're a world-wide community, so you might not be communicating in someone else's primary language.
14
+ * **Be respectful**: Not all of us will agree all the time, but disagreement is no excuse for poor behavior and poor manners. We might all experience some frustration now and then, but we cannot allow that frustration to turn into a personal attack. It’s important to remember that a community where people feel uncomfortable or threatened is not a productive one.
15
+ * **Be careful in the words that you choose**: we are a community of professionals, and we conduct ourselves professionally. Be kind to others. Do not insult or put down other participants. Harassment and other exclusionary behavior aren't acceptable. This includes, but is not limited to:
16
+ * Violent threats or language directed against another person.
17
+ * Discriminatory jokes and language.
18
+ * Using political talks and political orientated views.
19
+ * Posting sexually explicit or violent material.
20
+ * Posting (or threatening to post) other people's personally identifying information ("doxing").
21
+ * Personal insults, especially those using racist or sexist terms.
22
+ * Unwelcome sexual attention.
23
+ * Advocating for, or encouraging, any of the above behavior.
24
+ * Humor is acceptable but should not be done to harass, demean or to insult others.
25
+ * Repeated harassment of others. In general, if someone asks you to stop, then stop.
26
+ * Using overtly sexual aliases or other nicknames that might detract from a friendly, safe and welcoming environment for all.
27
+ * Using bad words or cursing.
28
+ * **When we disagree, try to understand why**: Disagreements, both social and technical, happen all the time. It is important that we resolve disagreements and differing views constructively. Remember that we’re different. The strength of our community comes from its diversity, people from a wide range of backgrounds. Different people have different perspectives on issues. Being unable to understand why someone holds a viewpoint doesn’t mean that they’re wrong. Don’t forget that it is human to err and blaming each other doesn’t get us anywhere. Instead, focus on helping to resolve issues and learning from mistakes.
29
+ * **Treat everyone equally:** we are community of mature people and maturity in the way we act, behave and treat others and as such we treat others as our brothers and sisters.
30
+
31
+ # Scope
32
+
33
+ The scope of the conduct of code is not limited to one individual or few individuals. This code of conduct applies for all be it the maintainer, the developer or any role assigned to the project or involved in any other way to the project. This code of conduct is not to provide privelages of one over the other. Any failure to enforce, act, using the code of conduct for your benefit or to evade certain situations or findings way to evade this conduct or a failure to provide a safe environment for others under the umberalla of this code of conduct will be considered a clear act of violation.
34
+
35
+ # Violation
36
+
37
+ Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
38
+
39
+ 1. **Correction**
40
+
41
+ **Community Impact:** Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
42
+
43
+ **Consequence:** A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
44
+
45
+ 2. **Warning**
46
+
47
+ **Community Impact:** A violation through a single incident or series of actions.
48
+
49
+ **Consequence:** A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
50
+
51
+ 3. **Temporary Ban**
52
+
53
+ **Community Impact:** A serious violation of community standards, including sustained inappropriate behavior.
54
+
55
+ **Consequence:** A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
56
+
57
+ 4. **Permanent Ban**
58
+
59
+ **Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
60
+
61
+ **Consequence**: A permanent ban from any sort of public interaction within the community.
62
+
63
+
64
+ # Reporting Issues
65
+
66
+ If you experience or witness unacceptable behavior—or have any other concerns—please report it by contacting the community leader via [mustafadhuleb53@gmail.com](mustafadhuleb53@gmail.com). All reports will be handled with discretion. In your report please include:
67
+
68
+ - Your contact information.
69
+ - Names (real, nicknames, or pseudonyms) of any individuals involved. If there are additional witnesses, please
70
+ include them as well. Your account of what occurred, and if you believe the incident is ongoing. If there is a publicly available record (e.g. a mailing list archive or a public IRC logger), please include a link.
71
+ - Any additional information that may be helpful.
72
+
73
+ Anyone asked to stop unacceptable behavior is expected to comply immediately. If an individual engages in unacceptable behavior, We will act according to the [violations rules](#violation) as stated above.
74
+
75
+ ## Attribution
76
+
77
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0, available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html, [Rust Code of Conduct](https://www.rust-lang.org/policies/code-of-conduct) and [Twitter's Code of Conduct](https://github.com/twitter/.github/blob/main/code-of-conduct.md?plain=1)
78
+
79
+ Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
80
+
81
+ [homepage]: https://www.contributor-covenant.org
82
+
83
+ For answers to common questions about this code of conduct, see the FAQ at
84
+ https://www.contributor-covenant.org/faq. Translations are available at
85
+ https://www.contributor-covenant.org/translations.
.github/workflows/contributors.yml ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: Contributors List
2
+
3
+ on:
4
+ workflow_dispatch:
5
+
6
+ schedule:
7
+ - cron: "0 1 * * *"
8
+
9
+ jobs:
10
+ contributors:
11
+ permissions:
12
+ contents: write
13
+ pull-requests: write
14
+
15
+ runs-on: ubuntu-latest
16
+
17
+ steps:
18
+ - name: Checkout code
19
+ uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 # v3.5.0
20
+ with:
21
+ fetch-depth: 0
22
+ ref: ${{ github.event.repository.default_branch }}
23
+
24
+ - name: Update contributors list
25
+ uses: wow-actions/contributors-list@b9e91f91a51a55460fdcae64daad0cb8122cdd53 # v1.1.0
26
+ with:
27
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
28
+ svgPath: images/contributors_list.svg
29
+ round: true
30
+ includeBots: false
31
+ noCommit: true
32
+
33
+ - name: Commit & PR
34
+ uses: peter-evans/create-pull-request@38e0b6e68b4c852a5500a94740f0e535e0d7ba54 # v4.2.4
35
+ with:
36
+ token: ${{ secrets.GITHUB_TOKEN }}
37
+ add-paths: .github/assets/CONTRIBUTORS.svg
38
+ commit-message: 'chore: update contributors-list'
39
+ committer: GitHub <noreply@github.com>
40
+ author: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com>
41
+ signoff: false
42
+ branch: workflow/update-contributors-list
43
+ base: main
44
+ delete-branch: true
45
+ title: 'chore: update contributors-list'
46
+ body: |
47
+ Automated update to `images/contributors_list.svg`
.github/workflows/hello.yml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: Welcome first time contributors
2
+
3
+ on:
4
+ pull_request_target:
5
+ types:
6
+ - opened
7
+
8
+ jobs:
9
+ welcome:
10
+ name: Welcome
11
+ runs-on: ubuntu-latest
12
+ steps:
13
+ - uses: actions/first-interaction@v1
14
+ with:
15
+ repo-token: ${{ secrets.GITHUB_TOKEN }}
16
+ pr-message: |-
17
+ Congrats on making your first Pull Request and thanks for taking the time to improve Websurfx! ❤️!
18
+ Say hello by joining the conversation in our [Discord](https://discord.gg/SWnda7Mw5u)
.github/workflows/labels.yml ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: Import open source standard labels
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - rolling
7
+
8
+ jobs:
9
+ labels:
10
+
11
+ runs-on: ubuntu-latest
12
+
13
+ steps:
14
+ - uses: actions/setup-node@v2
15
+ with:
16
+ node-version: '14'
17
+ - uses: EddieHubCommunity/gh-action-open-source-labels@main
18
+ with:
19
+ github-token: ${{ secrets.GITHUB_TOKEN }}
20
+ owner-name: ${{ github.repository_owner }}
21
+ repository-name: ${{ github.event.repository.name }}
22
+ force: false
.github/workflows/rust.yml CHANGED
@@ -21,6 +21,20 @@ jobs:
21
 
22
  steps:
23
  - uses: actions/checkout@v3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24
  - run: rustup update ${{ matrix.toolchain }} && rustup default ${{ matrix.toolchain }}
25
  - name: Build
26
  run: cargo build --verbose
 
21
 
22
  steps:
23
  - uses: actions/checkout@v3
24
+ - run: rustup toolchain install stable --profile minimal
25
+ - uses: Swatinem/rust-cache@v2
26
+ with:
27
+ prefix-key: ""
28
+ shared-key: ""
29
+ key: ""
30
+ env-vars: ""
31
+ workspaces: ""
32
+ cache-directories: ""
33
+ cache-targets: ""
34
+ cache-on-failure: ""
35
+ cache-all-crates: ""
36
+ save-if: ""
37
+ - uses: actions/checkout@v3
38
  - run: rustup update ${{ matrix.toolchain }} && rustup default ${{ matrix.toolchain }}
39
  - name: Build
40
  run: cargo build --verbose
.github/workflows/rust_format.yml ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: Rust format and clippy checks
2
+ on:
3
+ push:
4
+ branches:
5
+ - "**"
6
+ pull_request:
7
+ branches:
8
+ - "rolling"
9
+
10
+ jobs:
11
+ check:
12
+ name: Rust project
13
+ runs-on: ubuntu-latest
14
+ steps:
15
+ - uses: actions/checkout@v2
16
+ - name: Install minimal stable with clippy and rustfmt
17
+ uses: actions-rs/toolchain@v1
18
+ with:
19
+ profile: minimal
20
+ toolchain: stable
21
+ components: rustfmt, clippy
22
+ - name: Format
23
+ uses: actions-rs/cargo@v1
24
+ with:
25
+ command: fmt
26
+ args: -- --check
27
+ - name: Clippy
28
+ uses: actions-rs/cargo@v1
29
+ with:
30
+ command: clippy
31
+ args: --all-features --all-targets --all
32
+ - name: Run cargo check
33
+ uses: actions-rs/cargo@v1
34
+ with:
35
+ command: check
.github/workflows/stale.yml ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # This workflow warns and then closes issues and PRs that have had no activity for a specified amount of time.
2
+ #
3
+ # You can adjust the behavior by modifying this file.
4
+ # For more information, see:
5
+ # https://github.com/actions/stale
6
+ name: Mark stale issues and pull requests
7
+
8
+ on:
9
+ schedule:
10
+ - cron: '30 1 * * *'
11
+
12
+ jobs:
13
+ stale:
14
+
15
+ runs-on: ubuntu-latest
16
+ permissions:
17
+ issues: write
18
+ pull-requests: write
19
+
20
+ steps:
21
+ - uses: actions/stale@v5
22
+ with:
23
+ repo-token: ${{ secrets.GITHUB_TOKEN }}
24
+ stale-issue-message: 'Stale issue message'
25
+ stale-pr-message: 'Stale pull request message'
26
+ stale-issue-label: 'no-issue-activity'
27
+ stale-pr-label: 'no-pr-activity'
.gitignore CHANGED
@@ -1 +1,3 @@
1
  /target
 
 
 
1
  /target
2
+
3
+ dump.rdb
CONTRIBUTING.md CHANGED
@@ -1,34 +1,54 @@
1
- # Things to Consider Before Contributing
2
 
3
- ## Knowledge Required
4
 
5
- - Rust basics
6
- - Actix-web crate basics
7
- - Tokio crate and async/await
8
- - Reqwest crate basics
9
- - Serde and serde~json~ crate basics
10
- - fake~useragent~ crate basics
11
- - pyo3/hlua/rlua crates basics
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
 
13
  ## Guidelines
14
 
15
- - Please be patient.
 
 
 
 
16
 
17
- - Treat everyone with respect -- \"give respect and take respect.\"
18
 
19
- - Document your code properly with Rust coding conventions in mind.
20
 
21
- - Provide a brief description of the changes you made in the pull
22
- request.
23
 
24
- - Provide an appropriate header for the pull request.
25
 
26
- **NOTE:** The rolling branch is where all contributions should go.
27
- In other words, it is the working branch for this project.
28
 
29
- We appreciate any contributions and suggestions to help improve the
30
- Websurfx project. Please keep in mind the above requirements and
31
- guidelines before submitting a pull request and also if you have any
32
- doubts/concerns/questions about the project, its source code or anything
33
- related to the project than feel free to ask by opening an
34
- \[issue\](<https://github.com/neon-mmd/websurfx/issues>).
 
1
+ # What You Can Contribute To?
2
 
3
+ ## Documentation/Wiki
4
 
5
+ Found a typo, or something that isn't as clear as it could be? Maybe I've missed something off altogether, or you hit a roadblock that took you a while to figure out. Edit the [docs](./docs/) to add to or improve the documentation. This will help future users get Websurfx up and running more easily.
6
+
7
+ ## Readme
8
+
9
+ 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.
10
+
11
+ ## Help Improve Github Actions
12
+
13
+ Know how to fix or improve a github action?. Consider Submitting a Pull request to help make automation and testing better.
14
+
15
+ ## Source Code
16
+
17
+ You should know atleast one of the things below to start contributing:
18
+
19
+ - Rust basics
20
+ - Actix-web crate basics
21
+ - Tokio crate and async/await
22
+ - Reqwest crate basics
23
+ - Serde and serde_json crate basics
24
+ - Scraper crate basics
25
+ - Frontend (handlebars, css and js).
26
+ - Fake useragent crate basics
27
+ - pyo3/hlua/rlua crates basics
28
+
29
+ ## Report a Bug/Issue
30
+
31
+ If you've found a bug, then please consider raising it as an issue [here](https://github.com/neon-mmd/websurfx/issues). This will help me know if there's something that needs fixing. Try and include as much detail as possible, such as your environment, steps to reproduce, any console output and maybe an example screenshot or recording if necessary.
32
+
33
+ ## Spread the word
34
+
35
+ Websurfx is still a relatively young project, and as such not many people know of it. It would be great to see more users, and so it would be awesome if you could consider sharing with your friends or on social platforms.
36
 
37
  ## Guidelines
38
 
39
+ - Please be patient.
40
+ - Treat everyone with respect -- \"give respect and take respect.\"
41
+ - Document your code properly with Rust coding conventions in mind.
42
+ - Provide a brief description of the changes you made in the pull request.
43
+ - Provide an appropriate header for the pull request.
44
 
45
+ ## Join the discussion
46
 
47
+ We have a [Discord](https://discord.gg/SWnda7Mw5u) channel, feel free to join and share your ideas and ask questions about the project, we would be glad to hear you out.
48
 
49
+ # Where To Contribute?
 
50
 
51
+ The _rolling branch_ is where we intend all contributions should go.
52
 
 
 
53
 
54
+ 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.
 
 
 
 
 
Cargo.lock CHANGED
@@ -3325,6 +3325,7 @@ dependencies = [
3325
  "handlebars",
3326
  "log",
3327
  "md5",
 
3328
  "rand 0.8.5",
3329
  "redis",
3330
  "reqwest 0.11.18",
 
3325
  "handlebars",
3326
  "log",
3327
  "md5",
3328
+ "once_cell",
3329
  "rand 0.8.5",
3330
  "redis",
3331
  "reqwest 0.11.18",
Cargo.toml CHANGED
@@ -21,3 +21,4 @@ rlua = {version="*"}
21
  redis = {version="*"}
22
  md5 = {version="*"}
23
  rand={version="*"}
 
 
21
  redis = {version="*"}
22
  md5 = {version="*"}
23
  rand={version="*"}
24
+ once_cell = {version="*"}
README.md CHANGED
@@ -1,66 +1,47 @@
1
- <h1 align="center">Websurfx</h1>
 
 
2
  <p align="center">
3
- <i>
4
- A modern-looking, lightning-fast, privacy-respecting, secure
5
- <a href="https://en.wikipedia.org/wiki/Metasearch_engine"
6
- >meta search engine</a
7
- >
8
- (pronounced as websurface or web-surface /wɛbˈsɜːrfəs/.) written in Rust. It
9
- provides a fast and secure search experience while respecting user
10
- privacy.</i
11
- >
12
- <br />
13
- <br />
14
- <img align="center" width="500px" src="./images/intro.png" />
15
- <br />
16
- <br />
17
- <b align="center"><a href="README.org">Readme</a></b> |
18
- <b><a href="https://discord.gg/k4GH2TnZ">Discord</a></b> |
19
  <b><a href="https://github.com/neon-mmd/websurfx">GitHub</a></b> |
20
- <b><a href="https://github.com/neon-mmd/websurfx/wiki">Documentation</a></b>
21
  <br /><br />
22
- <a href="./LICENSE">
23
- <img
24
- alt="GitHub"
25
- src="https://img.shields.io/github/license/neon-mmd/websurfx?style=flat-square"
26
- />
27
- </a>
28
- <a href="https://github.com/neon-mmd/websurfx/stargazers">
29
- <img
30
- alt="GitHub Repo stars"
31
- src="https://img.shields.io/github/stars/neon-mmd/websurfx?style=flat-square"
32
- />
33
- </a>
34
- <a href="https://github.com/neon-mmd/websurfx/forks">
35
- <img
36
- alt="GitHub forks"
37
- src="https://img.shields.io/github/forks/neon-mmd/websurfx?style=flat-square"
38
- />
39
- </a>
40
  <a href="#">
41
  <img
42
  alt="GitHub code size in bytes"
43
  src="https://img.shields.io/github/languages/code-size/neon-mmd/websurfx?style=flat-square"
44
  />
45
  </a>
46
- <a href="https://github.com/neon-mmd/websurfx/issues">
47
  <img
48
- alt="GitHub issues"
49
- src="https://img.shields.io/github/issues/neon-mmd/websurfx?style=flat-square"
50
  />
51
  </a>
52
- <a href="https://github.com/neon-mmd/websurfx/pulls">
53
- <img
54
- alt="GitHub pull requests"
55
- src="https://img.shields.io/github/issues-pr/neon-mmd/websurfx?style=flat-square"
56
  />
57
  </a>
58
- <a href="https://github.com/neon-mmd/websurfx/actions">
59
  <img
60
- alt="GitHub Workflow Status"
61
- src="https://img.shields.io/github/actions/workflow/status/neon-mmd/websurfx/rust.yml?style=flat-square"
62
  />
63
  </a>
 
 
 
 
 
 
 
 
 
 
 
64
  </p>
65
 
66
  <details>
@@ -68,8 +49,8 @@
68
  <p>
69
 
70
  - **Getting Started**
71
- - [🌈 Features](#features-)
72
  - [🔭 Preview](#preview-)
 
73
  - [🛠️ Installation and Testing](#installation-and-testing-)
74
  - [🔧 Configuration](#configuration-)
75
  - **Feature Overview**
@@ -89,17 +70,6 @@
89
  </p>
90
  </details>
91
 
92
- # Features 🌈
93
-
94
- - ⛔ Proper NSFW blocking
95
- - 🎨 High level customizability with 9 colorchemes provided by default with a simple theme, also supporting creation of your custom themes and colorschemes very quickly and easily
96
- - 🔍 Advanced image search
97
- - 🔐 Fast, private and secure
98
- - 🆓 100% free and open source
99
- - 🌈 and lots more...
100
-
101
- **[⬆️ Back to Top](#websurfx)**
102
-
103
  # Preview 🔭
104
 
105
  ## Main Page
@@ -114,31 +84,33 @@
114
 
115
  <img align="center" src="./images/404_error_page.png" />
116
 
117
- **[⬆️ Back to Top](#websurfx)**
118
 
119
- # Installation and Testing 🛠️
120
 
121
- > For full setup instructions, see: [**Installation**]()
 
 
 
 
122
 
123
- To get started with Websurfx, clone the repository, edit the config file which is located in the `websurfx`{.verbatim} directory and install redis server by following the instructions located [here](https://redis.io/docs/getting-started/) and then run the websurfx server and redis server using the following commands:
124
 
125
- ``` shell
126
- git clone https://github.com/neon-mmd/websurfx.git
127
- cd websurfx
128
- cargo build
129
- redis-server -p 8082 &
130
- ./target/debug/websurfx
131
- ```
132
 
133
- If you want to use the rolling/edge branch, run the following commands instead:
134
 
135
  ``` shell
136
  git clone https://github.com/neon-mmd/websurfx.git
137
  cd websurfx
138
- git checkout rolling
139
- cargo build
140
- redis-server -p 8082 &
141
- ./target/debug/websurfx
142
  ```
143
 
144
  Once you have started the server, open your preferred web browser and navigate to <http://127.0.0.1:8080> to start using Websurfx.
@@ -146,91 +118,91 @@ Once you have started the server, open your preferred web browser and navigate t
146
  > **Warning**
147
  > Please be aware that the project is still in the testing phase and is not ready for production use.
148
 
149
- **[⬆️ Back to Top](#websurfx)**
150
 
151
  # Configuration 🔧
152
 
153
- > For full configuration instructions, see: [**Configuration**]()
154
 
155
  Websurfx is configured through the config.lua file, located at `websurfx/config.lua`.
156
 
157
- **[⬆️ Back to Top](#websurfx)**
158
 
159
  # Theming 🎨
160
 
161
- > For full theming and customization instructions, see: [**Theming**]()
162
 
163
- Websurfx comes with several themes and colorschemes by default which you can apply and edit through the config file. Support for custom themes and colorschemes using css and develop your own unique-looking website.
164
 
165
- **[⬆️ Back to Top](#websurfx)**
166
 
167
  # Multi-Language Support 🌍
168
 
169
  > **Note**
170
- > Currently, we do not support other languages but in future we would start accepting contributions regarding language support because we believe that language should not be a barrier for entry.
171
 
172
- **[⬆️ Back to Top](#websurfx)**
173
 
174
  # System Requirements 📊
175
 
176
- At present, we only support x86_64 architecture systems but will love to have contributions to extend to other architectures as well.
177
 
178
- **[⬆️ Back to Top](#websurfx)**
179
 
180
  # FAQ (Frequently Asked Questions) 🗨️
181
 
182
  ## Why Websurfx?
183
 
184
- The main goal of the Websurfx project is to provide a fast, secure, and privacy-focused [meta search engine](https://en.wikipedia.org/wiki/Metasearch_engine). While there are many meta search engines available, they do not always guarantee the security of their search engine, which is essential for ensuring privacy. For example, memory vulnerabilities can leak private or sensitive information, which is never good. Websurfx is written in Rust, which guarantees memory safety and eliminates such problems. Many meta search engines also lack key features such as advanced image search, which is required by many graphic designers, content creators, and others. Websurfx aims to provide these features and others, such as proper NSFW blocking, to improve the user experience.
185
 
186
  ## Why AGPLv3?
187
 
188
- Websurfx is released under the **AGPLv3** license to ensure that the source code remains open and transparent. This helps to prevent the inclusion of spyware, telemetry, or other malicious code in the project. **AGPLv3** is a strong copyleft license that ensures the source code of the software remains open and available to everyone, including any modifications or improvements made to the code.
189
 
190
  ## Why Rust?
191
 
192
- Rust was chosen as the programming language for Websurfx due to its memory safety features, which can help prevent vulnerabilities and make the codebase more secure. Rust is also faster than C++, which helps to make Websurfx fast and responsive. In addition, Rust\'s ownership and borrowing system allows for safe concurrency and thread safety in the codebase.
193
 
194
- **[⬆️ Back to Top](#websurfx)**
195
 
196
  # More Contributers Wanted 📣
197
 
198
- We are looking for more willing contributors to help grow this project.For more information on how you can contribute, check out the [project board](https://github.com/neon-mmd/websurfx/projects?query=is%3Aopen) and the [CONTRIBUTING.org](CONTRIBUTING.org) file for guidelines and rules for making contributions.
199
 
200
- **[⬆️ Back to Top](#websurfx)**
201
 
202
  # Supporting Websurfx 💖
203
 
204
  > For full details and other ways you can help out, see: [**Contributing**]()
205
 
206
- If you're using Dashy and would like to help support its development, then that would be awesome! Contributions of any type, any size, are always very much appreciated, and we will appropriately credit you for your effort.
207
 
208
  Several areas that we need a bit of help with at the moment are:
209
- - **Better and more colorchemes** - Help fix colorchemes and add other famous colorchemes.
210
- - **Improve evasion code for bot detection** - Help improve code related to evade ip blocking and emulate human behaviours located in everyone engine file.
211
  - **Logo** - Help create a logo for the project and website.
212
- - **Docker Support** - Help write a docker compose file for the project.
213
- - Submit a PR to add a new feature, fix a bug, update the docs, add a theme, widget or something else.
214
  - Star Websurfx on GitHub.
215
 
216
- **[⬆️ Back to Top](#websurfx)**
217
 
218
  # Documentation 📘
219
 
220
  > **Note**
221
- > We are willing to have any contribution regarding [documentation](https://github.com/neon-mmd/websurfx/wiki) as this helps everyone using this project.
222
 
223
- **[⬆️ Back to Top](#websurfx)**
224
 
225
  # Roadmap 🛣️
226
 
227
  > Coming soon!! 🙂.
228
 
229
- **[⬆️ Back to Top](#websurfx)**
230
 
231
  # Contributing 🙋
232
 
233
- Contributions are welcome from anyone. It doesn\'t matter who you are; you can still contribute to the project in your way.
234
 
235
  ## Not a developer but still want to contribute?
236
 
@@ -238,15 +210,15 @@ Check out this [video](https://youtu.be/FccdqCucVSI) by Mr. Nick on how to contr
238
 
239
  ## Developer
240
 
241
- If you are a developer, have a look at the [CONTRIBUTING.org](CONTRIBUTING.org) document for more information.
242
 
243
- **[⬆️ Back to Top](#websurfx)**
244
 
245
  # License 📜
246
 
247
- Websurfx is available under the [AGPLv3](LICENSE) license.
248
 
249
- **[⬆️ Back to Top](#websurfx)**
250
 
251
  # Credits 🤝
252
 
@@ -260,7 +232,7 @@ We would like to thank the following people for their contributions and support:
260
  <br />
261
  </p>
262
 
263
- **[⬆️ Back to Top](#websurfx)**
264
 
265
  ---
266
 
 
1
+ <h1 align="center">
2
+ <img src="./images/websurfx_logo.png" alt="websurfx logo" align="center" />
3
+ </h1>
4
  <p align="center">
5
+ <b align="center"><a href="README.md">Readme</a></b> |
6
+ <b><a href="https://discord.gg/SWnda7Mw5u">Discord</a></b> |
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7
  <b><a href="https://github.com/neon-mmd/websurfx">GitHub</a></b> |
8
+ <b><a href="./docs/README.md">Documentation</a></b>
9
  <br /><br />
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
  <a href="#">
11
  <img
12
  alt="GitHub code size in bytes"
13
  src="https://img.shields.io/github/languages/code-size/neon-mmd/websurfx?style=flat-square"
14
  />
15
  </a>
16
+ <a href="https://github.com/neon-mmd/websurfx/actions">
17
  <img
18
+ alt="GitHub Workflow Status"
19
+ src="https://img.shields.io/github/actions/workflow/status/neon-mmd/websurfx/rust.yml?style=flat-square"
20
  />
21
  </a>
22
+ <a href=""
23
+ ><img
24
+ alt="Maintenance"
25
+ src="https://img.shields.io/maintenance/yes/2023?style=flat-square"
26
  />
27
  </a>
28
+ <a href="https://gitpod.io/#https://github.com/neon-mmd/websurfx">
29
  <img
30
+ alt="Gitpod"
31
+ src="https://img.shields.io/badge/Gitpod-Ready--to--Code-blue?logo=gitpod"
32
  />
33
  </a>
34
+ <br />
35
+ <br />
36
+ <i>
37
+ A modern-looking, lightning-fast, privacy-respecting, secure
38
+ <a href="https://en.wikipedia.org/wiki/Metasearch_engine"
39
+ >meta search engine</a
40
+ >
41
+ (pronounced as websurface or web-surface /wɛbˈsɜːrfəs/.) written in Rust. It
42
+ provides a quick and secure search experience while maintaining user
43
+ privacy.</i
44
+ >
45
  </p>
46
 
47
  <details>
 
49
  <p>
50
 
51
  - **Getting Started**
 
52
  - [🔭 Preview](#preview-)
53
+ - [🚀 Features](#features-)
54
  - [🛠️ Installation and Testing](#installation-and-testing-)
55
  - [🔧 Configuration](#configuration-)
56
  - **Feature Overview**
 
70
  </p>
71
  </details>
72
 
 
 
 
 
 
 
 
 
 
 
 
73
  # Preview 🔭
74
 
75
  ## Main Page
 
84
 
85
  <img align="center" src="./images/404_error_page.png" />
86
 
87
+ **[⬆️ Back to Top](#--)**
88
 
89
+ # Features 🚀
90
 
91
+ - 🎨 High level of customizability with nine color schemes provided by default with a simple theme, also supporting the creation of your custom themes and colorschemes very quickly and easily
92
+ - 🔐 Fast, private, and secure
93
+ - 🆓 100% free and open source
94
+ - 💨 Ad-free and clean results
95
+ - 🌟 and lots more...
96
 
97
+ **[⬆️ Back to Top](#--)**
98
 
99
+ # Installation and Testing 🛠️
100
+
101
+ > For full setup instructions, see: [**Installation**](./docs/installation.md)
102
+
103
+ Before you can start building `websurfx`, you will need to have `Cargo` installed on your system. You can find the installation instructions [here](https://doc.rust-lang.org/cargo/getting-started/installation.html).
 
 
104
 
105
+ To get started with Websurfx, clone the repository, edit the config file, which is located in the `websurfx/` directory, and install the Redis server by following the instructions located [here](https://redis.io/docs/getting-started/) and then run the websurfx server and redis server using the following commands:
106
 
107
  ``` shell
108
  git clone https://github.com/neon-mmd/websurfx.git
109
  cd websurfx
110
+ git checkout stable
111
+ cargo build -r
112
+ redis-server --port 8082 &
113
+ ./target/release/websurfx
114
  ```
115
 
116
  Once you have started the server, open your preferred web browser and navigate to <http://127.0.0.1:8080> to start using Websurfx.
 
118
  > **Warning**
119
  > Please be aware that the project is still in the testing phase and is not ready for production use.
120
 
121
+ **[⬆️ Back to Top](#--)**
122
 
123
  # Configuration 🔧
124
 
125
+ > For full configuration instructions, see: [**Configuration**](./docs/configuration.md)
126
 
127
  Websurfx is configured through the config.lua file, located at `websurfx/config.lua`.
128
 
129
+ **[⬆️ Back to Top](#--)**
130
 
131
  # Theming 🎨
132
 
133
+ > For full theming and customization instructions, see: [**Theming**](./docs/theming.md)
134
 
135
+ Websurfx comes with several themes and color schemes by default, which you can apply and edit through the config file. Supports custom themes and color schemes using CSS, allowing you to develop your own unique-looking website.
136
 
137
+ **[⬆️ Back to Top](#--)**
138
 
139
  # Multi-Language Support 🌍
140
 
141
  > **Note**
142
+ > Currently, we do not support other languages, but in the future, we will start accepting contributions regarding language support because we believe that language should not be a barrier to entry.
143
 
144
+ **[⬆️ Back to Top](#--)**
145
 
146
  # System Requirements 📊
147
 
148
+ At present, we only support x86_64 architecture systems, but we would love to have contributions that extend to other architectures as well.
149
 
150
+ **[⬆️ Back to Top](#--)**
151
 
152
  # FAQ (Frequently Asked Questions) 🗨️
153
 
154
  ## Why Websurfx?
155
 
156
+ The primary purpose of the Websurfx project is to create a fast, secure, and privacy-focused meta-search engine. While there are numerous meta-search engines available, not all of them guarantee the security of their search engine, which is critical for maintaining privacy. Memory flaws, for example, can expose private or sensitive information, which is never a good thing. Also, there is the added problem of Spam, ads, and unorganic results which most engines don't have the full-proof answer to it till now but with Websurfx I finally put a full stop to this problem, also, Rust is used to write Websurfx, which ensures memory safety and removes such issues. Many meta-search engines also lack important features like advanced picture search, which is required by many graphic designers, content providers, and others. Websurfx attempts to improve the user experience by providing these and other features, such as proper NSFW blocking and Micro-apps or Quick results (like providing a calculator, currency exchanges, etc in the search results).
157
 
158
  ## Why AGPLv3?
159
 
160
+ Websurfx is distributed under the **AGPLv3** license to keep the source code open and transparent. This helps to keep malware, telemetry, and other dangerous programs out of the project. **AGPLv3** is a strong copyleft license that ensures the software's source code, including any modifications or improvements made to the code, remains open and available to everyone.
161
 
162
  ## Why Rust?
163
 
164
+ Rust was chosen as the programming language for Websurfx because of its memory safety features, which can help prevent vulnerabilities and make the codebase more secure. Rust is also faster than C++, which contributes to Websurfx's speed and responsiveness. Furthermore, the Rust ownership and borrowing system enables secure concurrency and thread safety in the program.
165
 
166
+ **[⬆️ Back to Top](#--)**
167
 
168
  # More Contributers Wanted 📣
169
 
170
+ We are looking for more willing contributors to help grow this project. For more information on how you can contribute, check out the [project board](https://github.com/neon-mmd/websurfx/projects?query=is%3Aopen) and the [CONTRIBUTING.md](CONTRIBUTING.md) file for guidelines and rules for making contributions.
171
 
172
+ **[⬆️ Back to Top](#--)**
173
 
174
  # Supporting Websurfx 💖
175
 
176
  > For full details and other ways you can help out, see: [**Contributing**]()
177
 
178
+ If you use Websurfx and would like to contribute to its development, that would be fantastic! Contributions of any size or type are always welcome, and we will properly acknowledge your efforts.
179
 
180
  Several areas that we need a bit of help with at the moment are:
181
+ - **Better and more color schemes**: Help fix color schemes and add other famous color schemes.
182
+ - **Improve evasion code for bot detection** - Help improve code related to evading IP blocking and emulating human behaviors located in everyone's engine file.
183
  - **Logo** - Help create a logo for the project and website.
184
+ - **Docker Support** - Help write a Docker Compose file for the project.
185
+ - Submit a PR to add a new feature, fix a bug, update the docs, add a theme, widget, or something else.
186
  - Star Websurfx on GitHub.
187
 
188
+ **[⬆️ Back to Top](#--)**
189
 
190
  # Documentation 📘
191
 
192
  > **Note**
193
+ > We welcome any contributions to the [documentation](./docs/) as this will benefit everyone who uses this project.
194
 
195
+ **[⬆️ Back to Top](#--)**
196
 
197
  # Roadmap 🛣️
198
 
199
  > Coming soon!! 🙂.
200
 
201
+ **[⬆️ Back to Top](#--)**
202
 
203
  # Contributing 🙋
204
 
205
+ Contributions are welcome from anyone. It doesn\'t matter who you are; you can still contribute to the project in your own way.
206
 
207
  ## Not a developer but still want to contribute?
208
 
 
210
 
211
  ## Developer
212
 
213
+ If you are a developer, have a look at the [CONTRIBUTING.org](CONTRIBUTING.md) document for more information.
214
 
215
+ **[⬆️ Back to Top](#--)**
216
 
217
  # License 📜
218
 
219
+ Websurfx is licensed under the [AGPLv3](LICENSE) license.
220
 
221
+ **[⬆️ Back to Top](#--)**
222
 
223
  # Credits 🤝
224
 
 
232
  <br />
233
  </p>
234
 
235
+ **[⬆️ Back to Top](#--)**
236
 
237
  ---
238
 
docs/README.md ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <h1 align="center"><img src="../images/websurfx_docs_image.png" alt="Websurfx Docs" align="center"></h1>
2
+
3
+ # General
4
+
5
+ - [Introduction](./introduction.md)
6
+ - [**FAQ**](./faq.md)
7
+
8
+ # Users
9
+
10
+ - [Installation](./installation.md)
11
+ - [Configuration](./configuration.md)
12
+ - [Theming](./theming.md)
13
+
14
+ # Developers
15
+
16
+ - [**Contribute**](https://github.com/neon-mmd/websurfx/blob/master/CONTRIBUTING.md)
17
+ - [**Coding style**](https://rust-lang.github.io/api-guidelines/naming.html)
docs/configuration.md ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Configuration
2
+
3
+ ## Installed From Source
4
+
5
+ If you have built `websurfx` from source then the configuration file will be located under project directory (codebase) at `websurfx/`
6
+
7
+ > **Note**
8
+ > If you have built websurfx with unstable/rolling/edge branch then you can copy the configuration file from `websurfx/config.lua` located under project directory (codebase) to `~/.config/websurfx/` and make the changes there and rerun the websurfx server. _This is only available from unstable/rolling/edge version_.
9
+
10
+ ## Installed From Package
11
+
12
+ If you have installed `websurfx` using the package manager of your Linux distro then the default configuration file will be located at `/etc/xdg/websurfx/`. You can copy the default config to `~/.config/websurfx/` and make the changes there and rerun the websurfx server.
13
+
14
+ Some of the configuration options provided in the file are stated below. These are subdivided into the following categories:
15
+
16
+ - General
17
+ - Server
18
+ - Website
19
+ - Cache
20
+
21
+ # General
22
+
23
+ - **logging:** An option to enable or disable logs.
24
+ - **debug:** An option to enable or disable debug mode.
25
+
26
+ ## Server
27
+
28
+ - **port:** Port number on which server should be launched.
29
+ - **binding_ip_addr:** IP address on the which server should be launched.
30
+ - **production_use:** Whether to use production mode or not (in other words this option should be used if it is to be used to host it on the server to provide a service to a large number of users). If production_use is set to true. There will be a random delay before sending the request to the search engines, this is to prevent DDoSing the upstream search engines from a large number of simultaneous requests. This is newly added option and hence is only available in the **edge version**.
31
+
32
+ ## Website
33
+
34
+ - **colorscheme:** The colorscheme name which should be used for the website theme (the name should be in accordance to the colorscheme file name present in `public/static/colorschemes` folder).
35
+
36
+ > By Default we provide 9 colorschemes to choose from these are:
37
+ >
38
+ > 1. catppuccin-mocha
39
+ > 2. dracula
40
+ > 3. monokai
41
+ > 4. nord
42
+ > 5. oceanic-next
43
+ > 6. solarized-dark
44
+ > 7. solarized-light
45
+ > 8. tomorrow-night
46
+ > 9. gruvbox-dark
47
+
48
+ - **theme:** The theme name which should be used for the website (again, the name should be in accordance to the theme file name present in `public/static/themes` folder).
49
+
50
+ > By Default we provide 1 theme to choose from these are:
51
+ >
52
+ > 1. simple
53
+
54
+ ## Cache
55
+
56
+ - **redis_connection_url:** Redis connection url address on which the client should connect on.
57
+
58
+ [⬅️ Go back to Home](./README.md)
docs/faq.md ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # General Questions
2
+
3
+ ## Why Websurfx?
4
+
5
+ The primary purpose of the Websurfx project is to create a fast, secure, and privacy-focused [meta-search engine](https://en.wikipedia.org/wiki/Metasearch_engine). While there are numerous meta-search engines available, not all of them guarantee the security of their search engine, which is critical for maintaining privacy. Memory flaws, for example, can expose private or sensitive information, which is never a good thing. Also, there is the added problem of Spam, ads, and unorganic results which most engines don't have the full-proof answer to it till now but with Websurfx I finally put a full stop to this problem, also, Rust is used to write Websurfx, which ensures memory safety and removes such issues. Many meta-search engines also lack important features like advanced picture search, which is required by many graphic designers, content providers, and others. Websurfx attempts to improve the user experience by providing these and other features, such as proper NSFW blocking and Micro-apps or Quick results (like providing a calculator, currency exchanges, etc in the search results).
6
+
7
+ ## Why AGPLv3?
8
+
9
+ Websurfx is released under the AGPLv3 license to ensure that the source code remains open and transparent. This helps to prevent the inclusion of spyware, telemetry, or other malicious code in the project. AGPLv3 is a strong copyleft license that ensures the source code of the software remains open and available to everyone, including any modifications or improvements made to the code.
10
+
11
+ ## Why Rust?
12
+
13
+ Rust was chosen as the programming language for Websurfx due to its memory safety features, which can help prevent vulnerabilities and make the codebase more secure. Rust is also faster than C++, which helps to make Websurfx fast and responsive. In addition, Rust's ownership and borrowing system allows for safe concurrency and thread safety in the codebase.
14
+
15
+ [⬅️ Go back to Home](./README.md)
docs/installation.md ADDED
@@ -0,0 +1,127 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Install From Package
2
+
3
+ ## Arch Linux
4
+
5
+ You can install `Websurfx` through the [Aur](https://aur.archlinux.org/packages/websurfx-git), Currently we only support `Rolling/Edge` version. You can install the rolling/edge version by running the following command (using [paru](https://github.com/Morganamilo/paru)):
6
+
7
+ ```bash
8
+ paru -S websurfx-edge-git
9
+ ```
10
+
11
+ After installing it you can run the websurfx server by running the following commands:
12
+
13
+ ``` bash
14
+ redis-server --port 8082 &
15
+ websurfx
16
+ ```
17
+
18
+ Once you have started the server, open your preferred web browser and navigate to http://127.0.0.1:8080/ to start using Websurfx.
19
+
20
+ If you want to change the port or the ip or any other configuration setting checkout the [configuration docs](./configuration.md).
21
+
22
+ ## Other Distros
23
+
24
+ The package is currently not available on other Linux distros. With contribution and support it can be made available on other distros as well 🙂.
25
+
26
+ # Install From Source
27
+
28
+ Before you can start building `websurfx`, you will need to have `Cargo` installed on your system. You can find the installation instructions [here](https://doc.rust-lang.org/cargo/getting-started/installation.html).
29
+
30
+ ## Stable
31
+
32
+ To get started with Websurfx, clone the repository, edit the config file which is located in the `websurfx` directory and install redis server by following the instructions located [here](https://redis.io/docs/getting-started/) and then build and run the websurfx server by running the following commands:
33
+
34
+ ```shell
35
+ git clone https://github.com/neon-mmd/websurfx.git
36
+ cd websurfx
37
+ git checkout stable
38
+ cargo build -r
39
+ redis-server --port 8082 &
40
+ ./target/release/websurfx
41
+ ```
42
+
43
+ Once you have started the server, open your preferred web browser and navigate to http://127.0.0.1:8080/ to start using Websurfx.
44
+
45
+ If you want to change the port or the ip or any other configuration setting checkout the [configuration docs](./configuration.md).
46
+
47
+ ## Rolling/Edge/Unstable
48
+
49
+ If you want to use the rolling/edge branch, run the following commands instead:
50
+
51
+ ```shell
52
+ git clone https://github.com/neon-mmd/websurfx.git
53
+ cd websurfx
54
+ cargo build -r
55
+ redis-server --port 8082 &
56
+ ./target/release/websurfx
57
+ ```
58
+
59
+ Once you have started the server, open your preferred web browser and navigate to http://127.0.0.1:8080/ to start using Websurfx.
60
+
61
+ If you want to change the port or the ip or any other configuration setting checkout the [configuration docs](./configuration.md).
62
+
63
+ # Docker Deployment
64
+
65
+ Before you start, you will need [Docker](https://docs.docker.com/get-docker/) installed on your system first.
66
+
67
+ ## Unstable/Edge/Rolling
68
+
69
+ First clone the the repository by running the following command:
70
+
71
+ ```bash
72
+ git clone https://github.com/neon-mmd/websurfx.git
73
+ cd websurfx
74
+ ```
75
+
76
+ After that edit the config.lua file located under `websurfx` directory. In the config file you will specifically need to change to values which is `binding_ip_addr` and `redis_connection_url` which should make the config look something like this:
77
+
78
+ ```lua
79
+ -- ### General ###
80
+ logging = true -- an option to enable or disable logs.
81
+ debug = false -- an option to enable or disable debug mode.
82
+
83
+ -- ### Server ###
84
+ port = "8080" -- port on which server should be launched
85
+ binding_ip_addr = "0.0.0.0" --ip address on the which server should be launched.
86
+ production_use = false -- whether to use production mode or not (in other words this option should be used if it is to be used to host it on the server to provide a service to a large number of users)
87
+ -- if production_use is set to true
88
+ -- There will be a random delay before sending the request to the search engines, this is to prevent DDoSing the upstream search engines from a large number of simultaneous requests.
89
+
90
+ -- ### Website ###
91
+ -- The different colorschemes provided are:
92
+ -- {{
93
+ -- catppuccin-mocha
94
+ -- dracula
95
+ -- monokai
96
+ -- nord
97
+ -- oceanic-next
98
+ -- solarized-dark
99
+ -- solarized-light
100
+ -- tomorrow-night
101
+ -- }}
102
+ colorscheme = "catppuccin-mocha" -- the colorscheme name which should be used for the website theme
103
+ theme = "simple" -- the theme name which should be used for the website
104
+
105
+ -- ### Caching ###
106
+ redis_connection_url = "redis://redis:6379" -- redis connection url address on which the client should connect on.
107
+ ```
108
+
109
+ After this run the following command to deploy the app:
110
+
111
+ ```bash
112
+ docker compose up -d --build
113
+ ```
114
+
115
+ This will take around 5-10 mins for first deployment, afterwards the docker build stages will be cached so it will be faster to be build from next time onwards. After the above step finishes launch your preferred browser and then navigate to `http://<ip_address_of_the_device>:<whatever_port_you_provided_in_the_config>`.
116
+
117
+ ## Stable
118
+
119
+ For the stable version, follow the same steps as above (as mentioned for the unstable/rolling/edge version) with an addition of one command which has to be performed after cloning and changing directory into the repository which makes the cloning step as follows:
120
+
121
+ ```bash
122
+ git clone https://github.com/neon-mmd/websurfx.git
123
+ cd websurfx
124
+ git checkout stable
125
+ ```
126
+
127
+ [⬅️ Go back to Home](./README.md)
docs/introduction.md ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Introduction
2
+
3
+ A modern-looking, lightning-fast, privacy-respecting, secure [meta search engine](https://en.wikipedia.org/wiki/Metasearch_engine) (pronounced as websurface or web-surface /wɛbˈsɜːrfəs/.) written in Rust. It provides a fast and secure search experience while respecting user privacy.
4
+
5
+ # Motivation
6
+
7
+ Most meta search engines tend to be slow, lack high level of customization and missing many features and all of them like security as they are written in unsafe languages like python, javascript, etc which tend to open a wide variety of vulnerabilities which can also sometimes pose a threat to privacy as sometimes this can be exploited and can be used to leveraged to leak out sensitive information which is never good.
8
+
9
+ # Solution
10
+
11
+ Websurfx is a project which seeks to provide privacy, security, speed and all the features which the user wants.
12
+
13
+ [⬅️ Go back to Home](./README.md)
docs/theming.md ADDED
@@ -0,0 +1,365 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Colorschemes
2
+
3
+ ## Built-in
4
+
5
+ By default `websurfx` comes with 9 colorschemes to choose from which can be easily chosen using the config file. To how to change colorschemes please view the [Configuration](https://github.com/neon-mmd/websurfx/wiki/configuration) section of the wiki.
6
+
7
+ ## Custom
8
+
9
+ Creating coloschemes is as easy as it gets it requires the user to have a theme file name with the colorscheme in which every space should be replaced with a `-` (dash) and it should end with a `.css` file extension. After creating the file you need to add the following code with the `colors` you want:
10
+
11
+ ``` css
12
+ :root{
13
+ --bg: <background color>;
14
+ --fg: <foreground color (text color)>;
15
+ --1: <color 1>;
16
+ --2: <color 2>;
17
+ --3: <color 3>;
18
+ --4: <color 4>;
19
+ --5: <color 5>;
20
+ --6: <color 6>;
21
+ --7: <color 7>;
22
+ }
23
+ ```
24
+
25
+ > **Note**
26
+ > Please infer the theme file located under `public/static/themes` to better understand where each color is being used.
27
+
28
+ **Example of `catppuccin-mocha` colorscheme:**
29
+
30
+ ``` css
31
+ :root {
32
+ --bg: #1e1e2e;
33
+ --fg: #cdd6f4;
34
+ --1: #45475a;
35
+ --2: #f38ba8;
36
+ --3: #a6e3a1;
37
+ --4: #f9e2af;
38
+ --5: #89b4fa;
39
+ --6: #f5c2e7;
40
+ --7: #ffffff;
41
+ }
42
+ ```
43
+
44
+ # Themes
45
+
46
+ ## Built-in
47
+
48
+ By default `websurfx` comes with 1 theme to choose from which can be easily chosen using the config file. To how to change themes please view the [Configuration](https://github.com/neon-mmd/websurfx/wiki/configuration) section of the wiki.
49
+
50
+ ## Custom
51
+
52
+ To write custom color scheme, it requires the user to have some knowledge of `css stylesheets`.
53
+
54
+ **Here is an example of `simple theme` (which we provide by default with the app) which will give the user a better idea on how to create a custom theme using it as a template:**
55
+
56
+ ### General
57
+ ``` css
58
+ * {
59
+ padding: 0;
60
+ margin: 0;
61
+ box-sizing: border-box;
62
+ }
63
+
64
+ html {
65
+ font-size: 62.5%;
66
+ }
67
+
68
+ body {
69
+ display: flex;
70
+ flex-direction: column;
71
+ justify-content: space-between;
72
+ align-items: center;
73
+ height: 100vh;
74
+ background: var(--1);
75
+ }
76
+ ```
77
+ ### Styles for the index page
78
+ ``` css
79
+ .search-container {
80
+ display: flex;
81
+ flex-direction: column;
82
+ gap: 5rem;
83
+ justify-content: center;
84
+ align-items: center;
85
+ }
86
+
87
+ .search-container div {
88
+ display: flex;
89
+ }
90
+ ```
91
+ ### Styles for the search box and search button
92
+ ``` css
93
+ .search_bar {
94
+ display: flex;
95
+ }
96
+
97
+ .search_bar input {
98
+ padding: 1rem;
99
+ width: 50rem;
100
+ height: 3rem;
101
+ outline: none;
102
+ border: none;
103
+ box-shadow: rgba(0, 0, 0, 1);
104
+ background: var(--fg);
105
+ }
106
+
107
+ .search_bar button {
108
+ padding: 1rem;
109
+ border-radius: 0;
110
+ height: 3rem;
111
+ display: flex;
112
+ justify-content: center;
113
+ align-items: center;
114
+ outline: none;
115
+ border: none;
116
+ gap: 0;
117
+ background: var(--bg);
118
+ color: var(--3);
119
+ font-weight: 600;
120
+ letter-spacing: 0.1rem;
121
+ }
122
+
123
+ .search_bar button:active,
124
+ .search_bar button:hover {
125
+ filter: brightness(1.2);
126
+ }
127
+ ```
128
+ ### Styles for the footer and header
129
+ ``` css
130
+ header {
131
+ background: var(--bg);
132
+ width: 100%;
133
+ display: flex;
134
+ justify-content: right;
135
+ align-items: center;
136
+ padding: 1rem;
137
+ }
138
+
139
+ header ul,
140
+ footer ul {
141
+ list-style: none;
142
+ display: flex;
143
+ justify-content: space-around;
144
+ align-items: center;
145
+ font-size: 1.5rem;
146
+ gap: 2rem;
147
+ }
148
+
149
+ header ul li a,
150
+ footer ul li a,
151
+ header ul li a:visited,
152
+ footer ul li a:visited {
153
+ text-decoration: none;
154
+ color: var(--2);
155
+ text-transform: capitalize;
156
+ letter-spacing: 0.1rem;
157
+ }
158
+
159
+ header ul li a {
160
+ font-weight: 600;
161
+ }
162
+
163
+ header ul li a:hover,
164
+ footer ul li a:hover {
165
+ color: var(--5);
166
+ }
167
+
168
+ footer div span {
169
+ font-size: 1.5rem;
170
+ color: var(--4);
171
+ }
172
+
173
+ footer div {
174
+ display: flex;
175
+ gap: 1rem;
176
+ }
177
+
178
+ footer {
179
+ background: var(--bg);
180
+ width: 100%;
181
+ padding: 1rem;
182
+ display: flex;
183
+ flex-direction: column;
184
+ justify-content: center;
185
+ align-items: center;
186
+ }
187
+ ```
188
+ ### Styles for the search page
189
+ ``` css
190
+ .results {
191
+ width: 90%;
192
+ display: flex;
193
+ flex-direction: column;
194
+ justify-content: space-around;
195
+ }
196
+
197
+ .results .search_bar {
198
+ margin: 1rem 0;
199
+ }
200
+
201
+ .results_aggregated {
202
+ display: flex;
203
+ flex-direction: column;
204
+ justify-content: space-between;
205
+ margin: 2rem 0;
206
+ }
207
+
208
+ .results_aggregated .result {
209
+ display: flex;
210
+ flex-direction: column;
211
+ margin-top: 1rem;
212
+ }
213
+
214
+ .results_aggregated .result h1 a {
215
+ font-size: 1.5rem;
216
+ color: var(--2);
217
+ text-decoration: none;
218
+ letter-spacing: 0.1rem;
219
+ }
220
+
221
+ .results_aggregated .result h1 a:hover {
222
+ color: var(--5);
223
+ }
224
+
225
+ .results_aggregated .result h1 a:visited {
226
+ color: var(--bg);
227
+ }
228
+
229
+ .results_aggregated .result small {
230
+ color: var(--3);
231
+ font-size: 1.1rem;
232
+ word-wrap: break-word;
233
+ line-break: anywhere;
234
+ }
235
+
236
+ .results_aggregated .result p {
237
+ color: var(--fg);
238
+ font-size: 1.2rem;
239
+ margin-top: 0.3rem;
240
+ word-wrap: break-word;
241
+ line-break: anywhere;
242
+ }
243
+
244
+ .results_aggregated .result .upstream_engines {
245
+ text-align: right;
246
+ font-size: 1.2rem;
247
+ padding: 1rem;
248
+ color: var(--5);
249
+ }
250
+ ```
251
+
252
+ ### Styles for the 404 page
253
+
254
+ ``` css
255
+ .error_container {
256
+ display: flex;
257
+ justify-content: center;
258
+ align-items: center;
259
+ width: 100%;
260
+ gap: 5rem;
261
+ }
262
+
263
+ .error_container img {
264
+ width: 30%;
265
+ }
266
+
267
+ .error_content {
268
+ display: flex;
269
+ flex-direction: column;
270
+ justify-content: center;
271
+ gap: 1rem;
272
+ }
273
+
274
+ .error_content h1,
275
+ .error_content h2 {
276
+ letter-spacing: 0.1rem;
277
+ }
278
+
279
+ .error_content h1 {
280
+ font-size: 3rem;
281
+ }
282
+
283
+ .error_content h2 {
284
+ font-size: 2rem;
285
+ }
286
+
287
+ .error_content p {
288
+ font-size: 1.2rem;
289
+ }
290
+
291
+ .error_content p a,
292
+ .error_content p a:visited {
293
+ color: var(--2);
294
+ text-decoration: none;
295
+ }
296
+
297
+ .error_content p a:hover {
298
+ color: var(--5);
299
+ }
300
+ ```
301
+ ### Styles for the previous and next button on the search page
302
+ ``` css
303
+ .page_navigation {
304
+ padding: 0 0 2rem 0;
305
+ display: flex;
306
+ justify-content: space-between;
307
+ align-items: center;
308
+ }
309
+
310
+ .page_navigation button {
311
+ background: var(--bg);
312
+ color: var(--fg);
313
+ padding: 1rem;
314
+ border-radius: 0.5rem;
315
+ outline: none;
316
+ border: none;
317
+ }
318
+
319
+ .page_navigation button:active {
320
+ filter: brightness(1.2);
321
+ }
322
+ ```
323
+
324
+ ### Styles for the about page
325
+
326
+ This part is only available right now in the **rolling/edge/unstable** version
327
+
328
+ ```css
329
+ .about-container article{
330
+ font-size: 1.5rem;
331
+ color:var(--fg);
332
+ padding-bottom: 10px;
333
+ }
334
+
335
+ .about-container article h1{
336
+ color: var(--2);
337
+ font-size: 2.8rem;
338
+ }
339
+
340
+ .about-container article div{
341
+ padding-bottom: 15px;
342
+ }
343
+
344
+ .about-container a{
345
+ color:var(--3);
346
+ }
347
+
348
+ .about-container article h2{
349
+ color: var(--3);
350
+ font-size: 1.8rem;
351
+ padding-bottom: 10px;
352
+ }
353
+
354
+ .about-container p{
355
+ color:var(--fg);
356
+ font-size: 1.6rem;
357
+ padding-bottom: 10px;
358
+ }
359
+
360
+ .about-container h3{
361
+ font-size: 1.5rem;
362
+ }
363
+ ```
364
+
365
+ [⬅️ Go back to Home](./README.md)
images/main_page.png CHANGED
images/websurfx_docs_image.png ADDED
images/websurfx_logo.png ADDED
public/images/websurfx_logo.png ADDED
public/static/colorschemes/dark-chocolate.css ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ :root {
2
+ --bg: #000000;
3
+ --fg: #ffffff;
4
+ --1: #121212;
5
+ --2: #808080;
6
+ --3: #999999;
7
+ --4: #666666;
8
+ --5: #bfbfbf;
9
+ --6: #e0e0e0;
10
+ --7: #555555;
11
+ }
public/static/colorschemes/one-dark.css ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ :root {
2
+ --bg: #282c34;
3
+ --fg: #abb2bf;
4
+ --1: #3b4048;
5
+ --2: #a3be8c;
6
+ --3: #b48ead;
7
+ --4: #c8ccd4;
8
+ --5: #e06c75;
9
+ --6: #61afef;
10
+ --7: #be5046;
11
+ }
public/static/colorschemes/tokyo-night.css ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ :root {
2
+ --bg: #1a1b26;
3
+ --fg: #c0caf5;
4
+ --1: #32364a;
5
+ --2: #a9b1d6;
6
+ --3: #5a5bb8;
7
+ --4: #6b7089;
8
+ --5: #e2afff;
9
+ --6: #a9a1e1;
10
+ --7: #988bc7;
11
+ }
public/static/themes/simple.css CHANGED
@@ -260,3 +260,44 @@ footer {
260
  .page_navigation button:active {
261
  filter: brightness(1.2);
262
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
260
  .page_navigation button:active {
261
  filter: brightness(1.2);
262
  }
263
+
264
+ /* Styles for the about page */
265
+
266
+ .about-container article{
267
+ font-size: 1.5rem;
268
+ color:var(--fg);
269
+ padding-bottom: 10px;
270
+ }
271
+
272
+ .about-container article h1{
273
+ color: var(--2);
274
+ font-size: 2.8rem;
275
+ }
276
+
277
+ .about-container article div{
278
+ padding-bottom: 15px;
279
+ }
280
+
281
+ .about-container a{
282
+ color:var(--3);
283
+ }
284
+
285
+ .about-container article h2{
286
+ color: var(--3);
287
+ font-size: 1.8rem;
288
+ padding-bottom: 10px;
289
+ }
290
+
291
+ .about-container p{
292
+ color:var(--fg);
293
+ font-size: 1.6rem;
294
+ padding-bottom: 10px;
295
+ }
296
+
297
+ .about-container h3{
298
+ font-size: 1.5rem;
299
+ }
300
+
301
+ .about-container {
302
+ width: 80%;
303
+ }
public/templates/about.html CHANGED
@@ -1,20 +1,29 @@
1
  {{>header this}}
2
  <main class="about-container">
3
- <h1>Websurfx</h1>
4
- <small
5
- >a lightening fast, privacy respecting, secure meta search engine</small
6
- >
7
- <article>
8
- Lorem ipsum dolor sit amet, officia excepteur ex fugiat reprehenderit enim
9
- labore culpa sint ad nisi Lorem pariatur mollit ex esse exercitation amet.
10
- Nisi anim cupidatat excepteur officia. Reprehenderit nostrud nostrud ipsum
11
- Lorem est aliquip amet voluptate voluptate dolor minim nulla est proident.
12
- Nostrud officia pariatur ut officia. Sit irure elit esse ea nulla sunt ex
13
- occaecat reprehenderit commodo officia dolor Lorem duis laboris cupidatat
14
- officia voluptate. Culpa proident adipisicing id nulla nisi laboris ex in
15
- Lorem sunt duis officia eiusmod. Aliqua reprehenderit commodo ex non
16
- excepteur duis sunt velit enim. Voluptate laboris sint cupidatat ullamco ut
17
- ea consectetur et est culpa et culpa duis.
 
 
 
 
 
 
18
  </article>
 
 
19
  </main>
20
  {{>footer}}
 
 
1
  {{>header this}}
2
  <main class="about-container">
3
+ <article >
4
+ <div>
5
+ <h1 >Websurfx</h1>
6
+ <hr size="4" width="100%" color="#a6e3a1">
7
+ </div>
8
+ <p>A modern-looking, lightning-fast, privacy-respecting, secure meta search engine written in Rust. It provides a fast and secure search experience while respecting user privacy.<br> It aggregates results from multiple search engines and presents them in an unbiased manner, filtering out trackers and ads.
9
+ </p>
10
+
11
+ <h2>Some of the Top Features:</h2>
12
+
13
+ <ul><strong>Lightning fast </strong>- Results load within milliseconds for an instant search experience.</ul>
14
+
15
+ <ul><strong>Secure search</strong> - All searches are performed over an encrypted connection to prevent snooping.</ul>
16
+
17
+ <ul><strong>Ad free results</strong> - All search results are ad free and clutter free for a clean search experience.</ul>
18
+
19
+ <ul><strong>Privacy focused</strong> - Websurface does not track, store or sell your search data. Your privacy is our priority.</ul>
20
+
21
+ <ul><strong>Free and Open source</strong> - The entire project's code is open source and available for free on <a href="https://github.com/neon-mmd/websurfx">GitHub</a> under an GNU Affero General Public License.</ul>
22
+
23
+ <ul><strong>Highly customizable</strong> - Websurface comes with 9 built-in color themes and supports creating custom themes effortlessly.</ul>
24
  </article>
25
+
26
+ <h3>Devoloped by: <a href="https://github.com/neon-mmd/websurfx">Websurfx team</a></h3>
27
  </main>
28
  {{>footer}}
29
+
public/templates/index.html CHANGED
@@ -1,6 +1,6 @@
1
  {{>header this}}
2
  <main class="search-container">
3
- <img src="images/fps_logo.png" alt="Websurfx meta-search engine logo" />
4
  {{>search_bar}}
5
  </main>
6
  <script src="static/index.js"></script>
 
1
  {{>header this}}
2
  <main class="search-container">
3
+ <img src="../images/websurfx_logo.png" alt="Websurfx meta-search engine logo" />
4
  {{>search_bar}}
5
  </main>
6
  <script src="static/index.js"></script>
src/bin/websurfx.rs CHANGED
@@ -5,7 +5,6 @@
5
 
6
  use std::net::TcpListener;
7
 
8
- use env_logger::Env;
9
  use websurfx::{config_parser::parser::Config, run};
10
 
11
  /// The function that launches the main server and registers all the routes of the website.
@@ -20,7 +19,10 @@ async fn main() -> std::io::Result<()> {
20
  let config = Config::parse().unwrap();
21
 
22
  // Initializing logging middleware with level set to default or info.
23
- env_logger::Builder::from_env(Env::default().default_filter_or("info")).init();
 
 
 
24
 
25
  log::info!("started server on port {}", config.port);
26
 
 
5
 
6
  use std::net::TcpListener;
7
 
 
8
  use websurfx::{config_parser::parser::Config, run};
9
 
10
  /// The function that launches the main server and registers all the routes of the website.
 
19
  let config = Config::parse().unwrap();
20
 
21
  // Initializing logging middleware with level set to default or info.
22
+ if config.logging || config.debug {
23
+ use env_logger::Env;
24
+ env_logger::Builder::from_env(Env::default().default_filter_or("info")).init();
25
+ }
26
 
27
  log::info!("started server on port {}", config.port);
28
 
src/cache/cacher.rs CHANGED
@@ -10,9 +10,8 @@ use redis::{Client, Commands, Connection};
10
  /// # Fields
11
  ///
12
  /// * `redis_connection_url` - It stores the redis Connection url address.
13
- #[derive(Clone)]
14
  pub struct RedisCache {
15
- redis_connection_url: String,
16
  }
17
 
18
  impl RedisCache {
@@ -21,10 +20,11 @@ impl RedisCache {
21
  /// # Arguments
22
  ///
23
  /// * `redis_connection_url` - It stores the redis Connection url address.
24
- pub fn new(redis_connection_url: String) -> Self {
25
- RedisCache {
26
- redis_connection_url,
27
- }
 
28
  }
29
 
30
  /// A helper function which computes the hash of the url and formats and returns it as string.
@@ -32,7 +32,7 @@ impl RedisCache {
32
  /// # Arguments
33
  ///
34
  /// * `url` - It takes an url as string.
35
- fn compute_url_hash(self, url: &str) -> String {
36
  format!("{:?}", compute(url))
37
  }
38
 
@@ -41,11 +41,9 @@ impl RedisCache {
41
  /// # Arguments
42
  ///
43
  /// * `url` - It takes an url as a string.
44
- pub fn cached_results_json(self, url: String) -> Result<String, Box<dyn std::error::Error>> {
45
- let hashed_url_string = self.clone().compute_url_hash(&url);
46
- let mut redis_connection: Connection =
47
- Client::open(self.redis_connection_url)?.get_connection()?;
48
- Ok(redis_connection.get(hashed_url_string)?)
49
  }
50
 
51
  /// A function which caches the results by using the hashed `url` as the key and
@@ -57,20 +55,18 @@ impl RedisCache {
57
  /// * `json_results` - It takes the json results string as an argument.
58
  /// * `url` - It takes the url as a String.
59
  pub fn cache_results(
60
- self,
61
  json_results: String,
62
- url: String,
63
  ) -> Result<(), Box<dyn std::error::Error>> {
64
- let hashed_url_string = self.clone().compute_url_hash(&url);
65
- let mut redis_connection: Connection =
66
- Client::open(self.redis_connection_url)?.get_connection()?;
67
 
68
  // put results_json into cache
69
- redis_connection.set(hashed_url_string.clone(), json_results)?;
70
 
71
  // Set the TTL for the key to 60 seconds
72
- redis_connection
73
- .expire::<String, u32>(hashed_url_string.clone(), 60)
74
  .unwrap();
75
 
76
  Ok(())
 
10
  /// # Fields
11
  ///
12
  /// * `redis_connection_url` - It stores the redis Connection url address.
 
13
  pub struct RedisCache {
14
+ connection: Connection,
15
  }
16
 
17
  impl RedisCache {
 
20
  /// # Arguments
21
  ///
22
  /// * `redis_connection_url` - It stores the redis Connection url address.
23
+ pub fn new(redis_connection_url: String) -> Result<Self, Box<dyn std::error::Error>> {
24
+ let client = Client::open(redis_connection_url)?;
25
+ let connection = client.get_connection()?;
26
+ let redis_cache = RedisCache { connection };
27
+ Ok(redis_cache)
28
  }
29
 
30
  /// A helper function which computes the hash of the url and formats and returns it as string.
 
32
  /// # Arguments
33
  ///
34
  /// * `url` - It takes an url as string.
35
+ fn compute_url_hash(url: &str) -> String {
36
  format!("{:?}", compute(url))
37
  }
38
 
 
41
  /// # Arguments
42
  ///
43
  /// * `url` - It takes an url as a string.
44
+ pub fn cached_results_json(&mut self, url: &str) -> Result<String, Box<dyn std::error::Error>> {
45
+ let hashed_url_string = Self::compute_url_hash(url);
46
+ Ok(self.connection.get(hashed_url_string)?)
 
 
47
  }
48
 
49
  /// A function which caches the results by using the hashed `url` as the key and
 
55
  /// * `json_results` - It takes the json results string as an argument.
56
  /// * `url` - It takes the url as a String.
57
  pub fn cache_results(
58
+ &mut self,
59
  json_results: String,
60
+ url: &str,
61
  ) -> Result<(), Box<dyn std::error::Error>> {
62
+ let hashed_url_string = Self::compute_url_hash(url);
 
 
63
 
64
  // put results_json into cache
65
+ self.connection.set(&hashed_url_string, json_results)?;
66
 
67
  // Set the TTL for the key to 60 seconds
68
+ self.connection
69
+ .expire::<String, u32>(hashed_url_string, 60)
70
  .unwrap();
71
 
72
  Ok(())
src/cache/mod.rs CHANGED
@@ -1 +1 @@
1
- pub mod cacher;
 
1
+ pub mod cacher;
src/config_parser/parser.rs CHANGED
@@ -3,7 +3,11 @@
3
 
4
  use super::parser_models::Style;
5
  use rlua::Lua;
6
- use std::fs;
 
 
 
 
7
 
8
  /// A named struct which stores the parsed config file options.
9
  ///
@@ -20,6 +24,16 @@ pub struct Config {
20
  pub binding_ip_addr: String,
21
  pub style: Style,
22
  pub redis_connection_url: String,
 
 
 
 
 
 
 
 
 
 
23
  }
24
 
25
  impl Config {
@@ -32,15 +46,24 @@ impl Config {
32
  /// or io error if the config.lua file doesn't exists otherwise it returns a newly contructed
33
  /// Config struct with all the parsed config options from the parsed config file.
34
  pub fn parse() -> Result<Self, Box<dyn std::error::Error>> {
35
- let lua = Lua::new();
36
-
37
- lua.context(|context| {
38
  let globals = context.globals();
39
 
40
  context
41
- .load(&fs::read_to_string("./websurfx/config.lua")?)
 
 
42
  .exec()?;
43
 
 
 
 
 
 
 
 
 
 
44
  Ok(Config {
45
  port: globals.get::<_, u16>("port")?,
46
  binding_ip_addr: globals.get::<_, String>("binding_ip_addr")?,
@@ -49,7 +72,53 @@ impl Config {
49
  globals.get::<_, String>("colorscheme")?,
50
  ),
51
  redis_connection_url: globals.get::<_, String>("redis_connection_url")?,
 
 
 
52
  })
53
  })
54
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
55
  }
 
3
 
4
  use super::parser_models::Style;
5
  use rlua::Lua;
6
+ use std::{format, fs, path::Path};
7
+
8
+ // ------- Constants --------
9
+ static COMMON_DIRECTORY_NAME: &str = "websurfx";
10
+ static CONFIG_FILE_NAME: &str = "config.lua";
11
 
12
  /// A named struct which stores the parsed config file options.
13
  ///
 
24
  pub binding_ip_addr: String,
25
  pub style: Style,
26
  pub redis_connection_url: String,
27
+ pub aggregator: AggreatorConfig,
28
+ pub logging: bool,
29
+ pub debug: bool,
30
+ }
31
+
32
+ /// Configuration options for the aggregator.
33
+ #[derive(Clone)]
34
+ pub struct AggreatorConfig {
35
+ /// Whether to introduce a random delay before sending the request to the search engine.
36
+ pub random_delay: bool,
37
  }
38
 
39
  impl Config {
 
46
  /// or io error if the config.lua file doesn't exists otherwise it returns a newly contructed
47
  /// Config struct with all the parsed config options from the parsed config file.
48
  pub fn parse() -> Result<Self, Box<dyn std::error::Error>> {
49
+ Lua::new().context(|context| -> Result<Self, Box<dyn std::error::Error>> {
 
 
50
  let globals = context.globals();
51
 
52
  context
53
+ .load(&fs::read_to_string(
54
+ Config::handle_different_config_file_path()?,
55
+ )?)
56
  .exec()?;
57
 
58
+ let production_use = globals.get::<_, bool>("production_use")?;
59
+ let aggregator_config = if production_use {
60
+ AggreatorConfig { random_delay: true }
61
+ } else {
62
+ AggreatorConfig {
63
+ random_delay: false,
64
+ }
65
+ };
66
+
67
  Ok(Config {
68
  port: globals.get::<_, u16>("port")?,
69
  binding_ip_addr: globals.get::<_, String>("binding_ip_addr")?,
 
72
  globals.get::<_, String>("colorscheme")?,
73
  ),
74
  redis_connection_url: globals.get::<_, String>("redis_connection_url")?,
75
+ aggregator: aggregator_config,
76
+ logging: globals.get::<_, bool>("logging")?,
77
+ debug: globals.get::<_, bool>("debug")?,
78
  })
79
  })
80
  }
81
+ /// A helper function which returns an appropriate config file path checking if the config
82
+ /// file exists on that path.
83
+ ///
84
+ /// # Error
85
+ ///
86
+ /// Returns a `config file not found!!` error if the config file is not present under following
87
+ /// paths which are:
88
+ /// 1. `~/.config/websurfx/` if it not present here then it fallbacks to the next one (2)
89
+ /// 2. `/etc/xdg/websurfx/config.lua` if it is not present here then it fallbacks to the next
90
+ /// one (3).
91
+ /// 3. `websurfx/` (under project folder ( or codebase in other words)) if it is not present
92
+ /// here then it returns an error as mentioned above.
93
+ fn handle_different_config_file_path() -> Result<String, Box<dyn std::error::Error>> {
94
+ if Path::new(
95
+ format!(
96
+ "{}/.config/{}/config.lua",
97
+ std::env::var("HOME").unwrap(),
98
+ COMMON_DIRECTORY_NAME
99
+ )
100
+ .as_str(),
101
+ )
102
+ .exists()
103
+ {
104
+ Ok(format!(
105
+ "{}/.config/{}/{}",
106
+ std::env::var("HOME").unwrap(),
107
+ COMMON_DIRECTORY_NAME,
108
+ CONFIG_FILE_NAME
109
+ ))
110
+ } else if Path::new(
111
+ format!("/etc/xdg/{}/{}", COMMON_DIRECTORY_NAME, CONFIG_FILE_NAME).as_str(),
112
+ )
113
+ .exists()
114
+ {
115
+ Ok("/etc/xdg/websurfx/config.lua".to_string())
116
+ } else if Path::new(format!("./{}/{}", COMMON_DIRECTORY_NAME, CONFIG_FILE_NAME).as_str())
117
+ .exists()
118
+ {
119
+ Ok("./websurfx/config.lua".to_string())
120
+ } else {
121
+ Err(format!("Config file not found!!").into())
122
+ }
123
+ }
124
  }
src/handler/mod.rs ADDED
@@ -0,0 +1 @@
 
 
1
+ pub mod public_path_handler;
src/handler/public_path_handler.rs ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ //! This module provides the functionality to handle theme folder present on different paths and
2
+ //! provide one appropriate path on which it is present and can be used.
3
+
4
+ use std::io::Error;
5
+ use std::path::Path;
6
+
7
+ // ------- Constants --------
8
+ static PUBLIC_DIRECTORY_NAME: &str = "public";
9
+
10
+ /// A function which returns an appropriate theme directory path checking if the theme
11
+ /// directory exists on that path.
12
+ ///
13
+ /// # Error
14
+ ///
15
+ /// Returns a `Theme (public) folder not found!!` error if the theme folder is not present under following
16
+ /// paths which are:
17
+ /// 1. `/opt/websurfx` if it not present here then it fallbacks to the next one (2)
18
+ /// 2. Under project folder ( or codebase in other words) if it is not present
19
+ /// here then it returns an error as mentioned above.
20
+ pub fn handle_different_public_path() -> Result<String, Error> {
21
+ if Path::new(format!("/opt/websurfx/{}/", PUBLIC_DIRECTORY_NAME).as_str()).exists() {
22
+ Ok(format!("/opt/websurfx/{}", PUBLIC_DIRECTORY_NAME))
23
+ } else if Path::new(format!("./{}/", PUBLIC_DIRECTORY_NAME).as_str()).exists() {
24
+ Ok(format!("./{}", PUBLIC_DIRECTORY_NAME))
25
+ } else {
26
+ Err(Error::new(
27
+ std::io::ErrorKind::NotFound,
28
+ "Themes (public) folder not found!!",
29
+ ))
30
+ }
31
+ }
src/lib.rs CHANGED
@@ -4,6 +4,7 @@
4
  pub mod cache;
5
  pub mod config_parser;
6
  pub mod engines;
 
7
  pub mod search_results_handler;
8
  pub mod server;
9
 
@@ -15,6 +16,7 @@ use actix_files as fs;
15
  use actix_web::{dev::Server, middleware::Logger, web, App, HttpServer};
16
  use config_parser::parser::Config;
17
  use handlebars::Handlebars;
 
18
 
19
  /// Runs the web server on the provided TCP listener and returns a `Server` instance.
20
  ///
@@ -39,8 +41,10 @@ use handlebars::Handlebars;
39
  pub fn run(listener: TcpListener, config: Config) -> std::io::Result<Server> {
40
  let mut handlebars: Handlebars = Handlebars::new();
41
 
 
 
42
  handlebars
43
- .register_templates_directory(".html", "./public/templates")
44
  .unwrap();
45
 
46
  let handlebars_ref: web::Data<Handlebars> = web::Data::new(handlebars);
@@ -51,8 +55,14 @@ pub fn run(listener: TcpListener, config: Config) -> std::io::Result<Server> {
51
  .app_data(web::Data::new(config.clone()))
52
  .wrap(Logger::default()) // added logging middleware for logging.
53
  // Serve images and static files (css and js files).
54
- .service(fs::Files::new("/static", "./public/static").show_files_listing())
55
- .service(fs::Files::new("/images", "./public/images").show_files_listing())
 
 
 
 
 
 
56
  .service(routes::robots_data) // robots.txt
57
  .service(routes::index) // index page
58
  .service(routes::search) // search page
 
4
  pub mod cache;
5
  pub mod config_parser;
6
  pub mod engines;
7
+ pub mod handler;
8
  pub mod search_results_handler;
9
  pub mod server;
10
 
 
16
  use actix_web::{dev::Server, middleware::Logger, web, App, HttpServer};
17
  use config_parser::parser::Config;
18
  use handlebars::Handlebars;
19
+ use handler::public_path_handler::handle_different_public_path;
20
 
21
  /// Runs the web server on the provided TCP listener and returns a `Server` instance.
22
  ///
 
41
  pub fn run(listener: TcpListener, config: Config) -> std::io::Result<Server> {
42
  let mut handlebars: Handlebars = Handlebars::new();
43
 
44
+ let public_folder_path: String = handle_different_public_path()?;
45
+
46
  handlebars
47
+ .register_templates_directory(".html", format!("{}/templates", public_folder_path))
48
  .unwrap();
49
 
50
  let handlebars_ref: web::Data<Handlebars> = web::Data::new(handlebars);
 
55
  .app_data(web::Data::new(config.clone()))
56
  .wrap(Logger::default()) // added logging middleware for logging.
57
  // Serve images and static files (css and js files).
58
+ .service(
59
+ fs::Files::new("/static", format!("{}/static", public_folder_path))
60
+ .show_files_listing(),
61
+ )
62
+ .service(
63
+ fs::Files::new("/images", format!("{}/images", public_folder_path))
64
+ .show_files_listing(),
65
+ )
66
  .service(routes::robots_data) // robots.txt
67
  .service(routes::index) // index page
68
  .service(routes::search) // search page
src/search_results_handler/aggregation_models.rs CHANGED
@@ -116,7 +116,7 @@ impl RawSearchResult {
116
  }
117
  }
118
 
119
- /// A named struct to store, serialize, deserialize the all the search results scraped and
120
  /// aggregated from the upstream search engines.
121
  ///
122
  /// # Fields
 
116
  }
117
  }
118
 
119
+ /// A named struct to store, serialize, deserialize the all the search results scraped and
120
  /// aggregated from the upstream search engines.
121
  ///
122
  /// # Fields
src/search_results_handler/aggregator.rs CHANGED
@@ -29,6 +29,7 @@ use crate::engines::{duckduckgo, searx};
29
  ///
30
  /// * `query` - Accepts a string to query with the above upstream search engines.
31
  /// * `page` - Accepts an u32 page number.
 
32
  ///
33
  /// # Error
34
  ///
@@ -38,14 +39,18 @@ use crate::engines::{duckduckgo, searx};
38
  pub async fn aggregate(
39
  query: &str,
40
  page: u32,
 
 
41
  ) -> Result<SearchResults, Box<dyn std::error::Error>> {
42
  let user_agent: String = random_user_agent();
43
  let mut result_map: HashMap<String, RawSearchResult> = HashMap::new();
44
 
45
  // Add a random delay before making the request.
46
- let mut rng = rand::thread_rng();
47
- let delay_secs = rng.gen_range(1..10);
48
- std::thread::sleep(Duration::from_secs(delay_secs));
 
 
49
 
50
  // fetch results from upstream search engines simultaneously/concurrently.
51
  let (ddg_map_results, searx_map_results) = join!(
 
29
  ///
30
  /// * `query` - Accepts a string to query with the above upstream search engines.
31
  /// * `page` - Accepts an u32 page number.
32
+ /// * `random_delay` - Accepts a boolean value to add a random delay before making the request.
33
  ///
34
  /// # Error
35
  ///
 
39
  pub async fn aggregate(
40
  query: &str,
41
  page: u32,
42
+ random_delay: bool,
43
+ debug: bool,
44
  ) -> Result<SearchResults, Box<dyn std::error::Error>> {
45
  let user_agent: String = random_user_agent();
46
  let mut result_map: HashMap<String, RawSearchResult> = HashMap::new();
47
 
48
  // Add a random delay before making the request.
49
+ if random_delay || !debug {
50
+ let mut rng = rand::thread_rng();
51
+ let delay_secs = rng.gen_range(1..10);
52
+ std::thread::sleep(Duration::from_secs(delay_secs));
53
+ }
54
 
55
  // fetch results from upstream search engines simultaneously/concurrently.
56
  let (ddg_map_results, searx_map_results) = join!(
src/search_results_handler/user_agent.rs CHANGED
@@ -1,13 +1,8 @@
1
  //! This module provides the functionality to generate random user agent string.
2
 
3
- use fake_useragent::{Browsers, UserAgentsBuilder};
4
 
5
- /// A function to generate random user agent to improve privacy of the user.
6
- ///
7
- /// # Returns
8
- ///
9
- /// A randomly generated user agent string.
10
- pub fn random_user_agent() -> String {
11
  UserAgentsBuilder::new()
12
  .cache(false)
13
  .dir("/tmp")
@@ -21,6 +16,13 @@ pub fn random_user_agent() -> String {
21
  .set_mozilla(),
22
  )
23
  .build()
24
- .random()
25
- .to_string()
 
 
 
 
 
 
 
26
  }
 
1
  //! This module provides the functionality to generate random user agent string.
2
 
3
+ use fake_useragent::{Browsers, UserAgents, UserAgentsBuilder};
4
 
5
+ static USER_AGENTS: once_cell::sync::Lazy<UserAgents> = once_cell::sync::Lazy::new(|| {
 
 
 
 
 
6
  UserAgentsBuilder::new()
7
  .cache(false)
8
  .dir("/tmp")
 
16
  .set_mozilla(),
17
  )
18
  .build()
19
+ });
20
+
21
+ /// A function to generate random user agent to improve privacy of the user.
22
+ ///
23
+ /// # Returns
24
+ ///
25
+ /// A randomly generated user agent string.
26
+ pub fn random_user_agent() -> String {
27
+ USER_AGENTS.random().to_string()
28
  }
src/server/routes.rs CHANGED
@@ -7,6 +7,7 @@ use std::fs::read_to_string;
7
  use crate::{
8
  cache::cacher::RedisCache,
9
  config_parser::parser::Config,
 
10
  search_results_handler::{aggregation_models::SearchResults, aggregator::aggregate},
11
  };
12
  use actix_web::{get, web, HttpRequest, HttpResponse};
@@ -73,7 +74,7 @@ pub async fn search(
73
  let params = web::Query::<SearchParams>::from_query(req.query_string())?;
74
 
75
  //Initialize redis cache connection struct
76
- let redis_cache = RedisCache::new(config.redis_connection_url.clone());
77
  match &params.q {
78
  Some(query) => {
79
  if query.trim().is_empty() {
@@ -81,11 +82,10 @@ pub async fn search(
81
  .insert_header(("location", "/"))
82
  .finish())
83
  } else {
84
- // Initialize the page url as an empty string
85
- let mut page_url = String::new();
 
86
 
87
- // Find whether the page is valid page number if not then return
88
- // the first page number and also construct the page_url accordingly
89
  let page = match params.page {
90
  Some(page_number) => {
91
  if page_number <= 1 {
@@ -117,7 +117,7 @@ pub async fn search(
117
  };
118
 
119
  // fetch the cached results json.
120
- let cached_results_json = redis_cache.clone().cached_results_json(page_url.clone());
121
  // check if fetched results was indeed fetched or it was an error and if so
122
  // handle the data accordingly.
123
  match cached_results_json {
@@ -128,12 +128,10 @@ pub async fn search(
128
  }
129
  Err(_) => {
130
  let mut results_json: crate::search_results_handler::aggregation_models::SearchResults =
131
- aggregate(query, page).await?;
132
  results_json.add_style(config.style.clone());
133
- redis_cache.clone().cache_results(
134
- serde_json::to_string(&results_json)?,
135
- page_url.clone(),
136
- )?;
137
  let page_content: String = hbs.render("search", &results_json)?;
138
  Ok(HttpResponse::Ok().body(page_content))
139
  }
@@ -149,7 +147,8 @@ pub async fn search(
149
  /// Handles the route of robots.txt page of the `websurfx` meta search engine website.
150
  #[get("/robots.txt")]
151
  pub async fn robots_data(_req: HttpRequest) -> Result<HttpResponse, Box<dyn std::error::Error>> {
152
- let page_content: String = read_to_string("./public/robots.txt")?;
 
153
  Ok(HttpResponse::Ok()
154
  .content_type("text/plain; charset=ascii")
155
  .body(page_content))
 
7
  use crate::{
8
  cache::cacher::RedisCache,
9
  config_parser::parser::Config,
10
+ handler::public_path_handler::handle_different_public_path,
11
  search_results_handler::{aggregation_models::SearchResults, aggregator::aggregate},
12
  };
13
  use actix_web::{get, web, HttpRequest, HttpResponse};
 
74
  let params = web::Query::<SearchParams>::from_query(req.query_string())?;
75
 
76
  //Initialize redis cache connection struct
77
+ let mut redis_cache = RedisCache::new(config.redis_connection_url.clone())?;
78
  match &params.q {
79
  Some(query) => {
80
  if query.trim().is_empty() {
 
82
  .insert_header(("location", "/"))
83
  .finish())
84
  } else {
85
+ let page_url: String; // Declare the page_url variable without initializing it
86
+
87
+ // ...
88
 
 
 
89
  let page = match params.page {
90
  Some(page_number) => {
91
  if page_number <= 1 {
 
117
  };
118
 
119
  // fetch the cached results json.
120
+ let cached_results_json = redis_cache.cached_results_json(&page_url);
121
  // check if fetched results was indeed fetched or it was an error and if so
122
  // handle the data accordingly.
123
  match cached_results_json {
 
128
  }
129
  Err(_) => {
130
  let mut results_json: crate::search_results_handler::aggregation_models::SearchResults =
131
+ aggregate(query, page, config.aggregator.random_delay, config.debug).await?;
132
  results_json.add_style(config.style.clone());
133
+ redis_cache
134
+ .cache_results(serde_json::to_string(&results_json)?, &page_url)?;
 
 
135
  let page_content: String = hbs.render("search", &results_json)?;
136
  Ok(HttpResponse::Ok().body(page_content))
137
  }
 
147
  /// Handles the route of robots.txt page of the `websurfx` meta search engine website.
148
  #[get("/robots.txt")]
149
  pub async fn robots_data(_req: HttpRequest) -> Result<HttpResponse, Box<dyn std::error::Error>> {
150
+ let page_content: String =
151
+ read_to_string(format!("{}/robots.txt", handle_different_public_path()?))?;
152
  Ok(HttpResponse::Ok()
153
  .content_type("text/plain; charset=ascii")
154
  .body(page_content))
websurfx/config.lua CHANGED
@@ -1,8 +1,15 @@
1
- -- Server
 
 
 
 
2
  port = "8080" -- port on which server should be launched
3
  binding_ip_addr = "127.0.0.1" --ip address on the which server should be launched.
 
 
 
4
 
5
- -- Website
6
  -- The different colorschemes provided are:
7
  -- {{
8
  -- catppuccin-mocha
@@ -17,5 +24,5 @@ binding_ip_addr = "127.0.0.1" --ip address on the which server should be launche
17
  colorscheme = "catppuccin-mocha" -- the colorscheme name which should be used for the website theme
18
  theme = "simple" -- the theme name which should be used for the website
19
 
20
- -- Caching
21
  redis_connection_url = "redis://127.0.0.1:8082" -- redis connection url address on which the client should connect on.
 
1
+ -- ### General ###
2
+ logging = true -- an option to enable or disable logs.
3
+ debug = false -- an option to enable or disable debug mode.
4
+
5
+ -- ### Server ###
6
  port = "8080" -- port on which server should be launched
7
  binding_ip_addr = "127.0.0.1" --ip address on the which server should be launched.
8
+ production_use = false -- whether to use production mode or not (in other words this option should be used if it is to be used to host it on the server to provide a service to a large number of users)
9
+ -- if production_use is set to true
10
+ -- There will be a random delay before sending the request to the search engines, this is to prevent DDoSing the upstream search engines from a large number of simultaneous requests.
11
 
12
+ -- ### Website ###
13
  -- The different colorschemes provided are:
14
  -- {{
15
  -- catppuccin-mocha
 
24
  colorscheme = "catppuccin-mocha" -- the colorscheme name which should be used for the website theme
25
  theme = "simple" -- the theme name which should be used for the website
26
 
27
+ -- ### Caching ###
28
  redis_connection_url = "redis://127.0.0.1:8082" -- redis connection url address on which the client should connect on.