diff --git a/.cspell.json b/.cspell.json new file mode 100644 index 0000000000000000000000000000000000000000..b798d293206f17ccf8f71d70b6fa1ebc00aa21f2 --- /dev/null +++ b/.cspell.json @@ -0,0 +1,16 @@ +{ + "ignorePaths": [ + "**/node_modules/**", + "**/vscode-extension/**", + "**/.git/**", + "**/.pnpm-lock.json", + ".vscode", + "megalinter", + "package-lock.json", + "report" + ], + "language": "en", + "noConfigSearch": true, + "words": ["megalinter", "oxsecurity"], + "version": "0.2" +} diff --git a/.github/workflows/contributors.yml b/.github/workflows/contributors.yml index fcb02774e1b24689c991753da2e4569b90c9719e..d57a5082c11fbe625c3298be0fff183338e0c356 100644 --- a/.github/workflows/contributors.yml +++ b/.github/workflows/contributors.yml @@ -1,3 +1,4 @@ +--- name: Contributors List on: @@ -44,4 +45,4 @@ jobs: delete-branch: true title: 'chore: update contributors-list' body: | - Automated update to `images/contributors_list.svg` \ No newline at end of file + Automated update to `images/contributors_list.svg` diff --git a/.github/workflows/hello.yml b/.github/workflows/hello.yml index 9d3018e7b615c87d0678edd3caf4e5f7f99469e2..c10105b71e54babb8f3374468edbc6fb50a08dfe 100644 --- a/.github/workflows/hello.yml +++ b/.github/workflows/hello.yml @@ -1,3 +1,4 @@ +--- name: Welcome first time contributors on: diff --git a/.github/workflows/labels.yml b/.github/workflows/labels.yml index 9dd3ea90f8b4fe6c6db8e84f649a4937688056c5..ab9f2fe17b9413d1650c30abb99a863e378f2453 100644 --- a/.github/workflows/labels.yml +++ b/.github/workflows/labels.yml @@ -1,3 +1,4 @@ +--- name: Import open source standard labels on: diff --git a/.github/workflows/mega-linter.yml b/.github/workflows/mega-linter.yml new file mode 100644 index 0000000000000000000000000000000000000000..c8f6cec11dd8e8ee87e216aceb84f09da46c9a66 --- /dev/null +++ b/.github/workflows/mega-linter.yml @@ -0,0 +1,89 @@ +--- +# MegaLinter GitHub Action configuration file +# More info at https://megalinter.io +name: MegaLinter + +on: + # Trigger mega-linter at every push. Action will also be visible from Pull Requests to rolling + push: # Comment this line to trigger action only on pull-requests (not recommended if you don't pay for GH Actions) + pull_request: + branches: [rolling] + +env: # Comment env block if you do not want to apply fixes + # Apply linter fixes configuration + APPLY_FIXES: all # When active, APPLY_FIXES must also be defined as environment variable (in github/workflows/mega-linter.yml or other CI tool) + APPLY_FIXES_EVENT: pull_request # Decide which event triggers application of fixes in a commit or a PR (pull_request, push, all) + APPLY_FIXES_MODE: commit # If APPLY_FIXES is used, defines if the fixes are directly committed (commit) or posted in a PR (pull_request) + +concurrency: + group: ${{ github.ref }}-${{ github.workflow }} + cancel-in-progress: true + +jobs: + build: + name: MegaLinter + runs-on: ubuntu-latest + permissions: + # Give the default GITHUB_TOKEN write permission to commit and push, comment issues & post new PR + # Remove the ones you do not need + contents: write + issues: write + pull-requests: write + steps: + # Git Checkout + - name: Checkout Code + uses: actions/checkout@v3 + with: + token: ${{ secrets.PAT || secrets.GITHUB_TOKEN }} + + # MegaLinter + - name: MegaLinter + id: ml + # You can override MegaLinter flavor used to have faster performances + # More info at https://megalinter.io/flavors/ + uses: oxsecurity/megalinter/flavors/cupcake@v7.1.0 + env: + # All available variables are described in documentation + # https://megalinter.io/configuration/ + VALIDATE_ALL_CODEBASE: true # Set ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }} to validate only diff with main branch + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + # ADD YOUR CUSTOM ENV VARIABLES HERE TO OVERRIDE VALUES OF .mega-linter.yml AT THE ROOT OF YOUR REPOSITORY + + # Upload MegaLinter artifacts + - name: Archive production artifacts + if: ${{ success() }} || ${{ failure() }} + uses: actions/upload-artifact@v3 + with: + name: MegaLinter reports + path: | + megalinter-reports + mega-linter.log + + # Create pull request if applicable (for now works only on PR from same repository, not from forks) + - name: Create Pull Request with applied fixes + id: cpr + if: steps.ml.outputs.has_updated_sources == 1 && (env.APPLY_FIXES_EVENT == 'all' || env.APPLY_FIXES_EVENT == github.event_name) && env.APPLY_FIXES_MODE == 'pull_request' && (github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository) && !contains(github.event.head_commit.message, 'skip fix') + uses: peter-evans/create-pull-request@v5 + with: + token: ${{ secrets.PAT || secrets.GITHUB_TOKEN }} + commit-message: "[MegaLinter] Apply linters automatic fixes" + title: "[MegaLinter] Apply linters automatic fixes" + labels: bot + - name: Create PR output + if: steps.ml.outputs.has_updated_sources == 1 && (env.APPLY_FIXES_EVENT == 'all' || env.APPLY_FIXES_EVENT == github.event_name) && env.APPLY_FIXES_MODE == 'pull_request' && (github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository) && !contains(github.event.head_commit.message, 'skip fix') + run: | + echo "Pull Request Number - ${{ steps.cpr.outputs.pull-request-number }}" + echo "Pull Request URL - ${{ steps.cpr.outputs.pull-request-url }}" + + # Push new commit if applicable (for now works only on PR from same repository, not from forks) + - name: Prepare commit + if: steps.ml.outputs.has_updated_sources == 1 && (env.APPLY_FIXES_EVENT == 'all' || env.APPLY_FIXES_EVENT == github.event_name) && env.APPLY_FIXES_MODE == 'commit' && github.ref != 'refs/heads/main' && (github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository) && !contains(github.event.head_commit.message, 'skip fix') + run: sudo chown -Rc $UID .git/ + - name: Commit and push applied linter fixes + if: steps.ml.outputs.has_updated_sources == 1 && (env.APPLY_FIXES_EVENT == 'all' || env.APPLY_FIXES_EVENT == github.event_name) && env.APPLY_FIXES_MODE == 'commit' && github.ref != 'refs/heads/main' && (github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository) && !contains(github.event.head_commit.message, 'skip fix') + uses: stefanzweifel/git-auto-commit-action@v4 + with: + branch: ${{ github.event.pull_request.head.ref || github.head_ref || github.ref }} + commit_message: "[MegaLinter] Apply linters fixes" + commit_user_name: megalinter-bot + commit_user_email: nicolas.vuillamy@ox.security diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index bc62ede156c8ab47d8a4a1ced5d7dda2137199ee..8f25a3613b1f8b49441c59d8cbd5e081b92adb9a 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -1,3 +1,4 @@ +--- name: Rust on: diff --git a/.github/workflows/rust_format.yml b/.github/workflows/rust_format.yml index c300863ddf9361eae575a8e5f175be3524399ce7..f26392b34f473195885aeed078582ac976f48ba0 100644 --- a/.github/workflows/rust_format.yml +++ b/.github/workflows/rust_format.yml @@ -1,3 +1,4 @@ +--- name: Rust format and clippy checks on: push: diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml index 1e1e6f0a09de1aa746d37645b49cf2d73e735a5e..5bae8159de4ba947adef846d98726a4cbcf66a11 100644 --- a/.github/workflows/stale.yml +++ b/.github/workflows/stale.yml @@ -1,3 +1,4 @@ +--- # This workflow warns and then closes issues and PRs that have had no activity for a specified amount of time. # # You can adjust the behavior by modifying this file. diff --git a/.gitignore b/.gitignore index 5e79d6bfb205636b45615629dbf9c9f3fe1174b4..c8d5b9e22a3c9685b65bda59c9d6bf736ce609bb 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ package.json package-lock.json dump.rdb .vscode +megalinter-reports/ diff --git a/.gitpod.yml b/.gitpod.yml new file mode 100644 index 0000000000000000000000000000000000000000..4eeabff2848b6b55012f2bf36b81a734c52dcb2e --- /dev/null +++ b/.gitpod.yml @@ -0,0 +1,44 @@ +--- +image: gitpod/workspace-base +# Commands that will run on workspace start +tasks: + - name: Setup, Install & Build + before: apt install cargo redis-server nodejs npm -y && cargo test + init: cargo install cargo-watch + command: redis-server --port 8080 & cargo watch -q -w "." -x "run" +# Ports to expose on workspace startup +ports: + - name: Website + description: Website Preview + port: 8080 + onOpen: open-preview +# vscode IDE setup +vscode: + extensions: + - vadimcn.vscode-lldb + - cschleiden.vscode-github-actions + - rust-lang.rust + - bungcip.better-toml + - serayuzgur.crates + - usernamehw.errorlens + - DavidAnson.vscode-markdownlint + - esbenp.prettier-vscode + - stylelint.vscode-stylelint + - dbaeumer.vscode-eslint + - evgeniypeshkov.syntax-highlighter + - redhat.vscode-yaml + - ms-azuretools.vscode-docker + - Catppuccin.catppuccin-vsc + - PKief.material-icon-theme + - oderwat.indent-rainbow + - formulahendry.auto-rename-tag + - eamodio.gitlens +github: + prebuilds: + master: true + branches: true + pullRequests: true + pullRequestsFromForks: true + addCheck: true + addComment: false + addBadge: true diff --git a/.mega-linter.yml b/.mega-linter.yml new file mode 100644 index 0000000000000000000000000000000000000000..b117b53485ae3cdb9b18adc2972d9b229bdacdae --- /dev/null +++ b/.mega-linter.yml @@ -0,0 +1,22 @@ +--- +# Configuration file for MegaLinter +# See all available variables at https://megalinter.io/configuration/ and in linters documentation + +APPLY_FIXES: all # all, none, or list of linter keys +# ENABLE: # If you use ENABLE variable, all other languages/formats/tooling-formats will be disabled by default +ENABLE_LINTERS: # If you use ENABLE_LINTERS variable, all other linters will be disabled by default + - RUST_CLIPPY + - JAVASCRIPT_ES + - CSS_STYLELINT + - MARKDOWN_MARKDOWNLINT + - YAML_YAMLLINT + - HTML_DJLINT + - ACTION_ACTIONLINT + - DOCKERFILE_HADOLINT + - SPELL_CSPELL +# DISABLE: + # - COPYPASTE # Uncomment to disable checks of excessive copy-pastes + # - SPELL # Uncomment to disable checks of spelling mistakes +SHOW_ELAPSED_TIME: true +FILEIO_REPORTER: false +# DISABLE_ERRORS: true # Uncomment if you want MegaLinter to detect errors but not block CI to pass diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 324dfbf9d97c090f7de3007ab6f7ee5982b50fc1..41ff84e86428ca7bfaf6b238c838e4565d81bbdd 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -14,7 +14,7 @@ Know how to fix or improve a github action?. Consider Submitting a Pull request ## Source Code -You should know atleast one of the things below to start contributing: +You should know at least one of the things below to start contributing: - Rust basics - Actix-web crate basics diff --git a/Dockerfile b/Dockerfile index 0fbba9404f3a6b169c2af5d7ddd36fcbf3b7227f..0c54453fed72c6b59a53b70077e10ebf6e824bde 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,7 +3,7 @@ FROM rust:latest AS chef # it will be cached from the second build onwards RUN cargo install cargo-chef -WORKDIR app +WORKDIR /app FROM chef AS planner COPY . . @@ -20,7 +20,7 @@ RUN cargo install --path . # We do not need the Rust toolchain to run the binary! FROM gcr.io/distroless/cc-debian11 -COPY --from=builder ./public/ ./public/ -COPY --from=builder ./websurfx/ ./websurfx/ +COPY --from=builder /app/public/ /opt/websurfx/public/ +COPY --from=builder /app/websurfx/config.lua /etc/xdg/websurfx/config.lua COPY --from=builder /usr/local/cargo/bin/* /usr/local/bin/ CMD ["websurfx"] diff --git a/PULL_REQUEST_TEMPLATE.md b/PULL_REQUEST_TEMPLATE.md index a7ad130c619aecb5708d79e1af6f1c7d4851ebef..28cb6b76fbbdcf00874e6790899df2e79bace92d 100644 --- a/PULL_REQUEST_TEMPLATE.md +++ b/PULL_REQUEST_TEMPLATE.md @@ -16,7 +16,7 @@ ## Author's checklist - + ## Related issues diff --git a/README.md b/README.md index 29f2cb2794e9f548a366ee0ca5ab042ee9ff24cb..e9c7e5c3a7e8b85313536c130c613f38e34874d1 100644 --- a/README.md +++ b/README.md @@ -59,7 +59,7 @@ - **Community** - [📊 System Requirements](#system-requirements-) - [🗨️ FAQ (Frequently Asked Questions)](#faq-frequently-asked-questions-) - - [📣 More Contributers Wanted](#more-contributers-wanted-) + - [📣 More Contributors Wanted](#more-contributors-wanted-) - [💖 Supporting Websurfx](#supporting-websurfx-) - [📘 Documentation](#documentation-) - [🛣️ Roadmap](#roadmap-) @@ -165,7 +165,7 @@ Websurfx is based on Rust due to its memory safety features, which prevents vuln **[⬆️ Back to Top](#--)** -# More Contributers Wanted 📣 +# More Contributors Wanted 📣 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. diff --git a/docker-compose.yml b/docker-compose.yml index 37ef93d7e81e038544b66a026de44771593ddfd2..aed741e4b84cb8109b83639f5c0f7154b89824f9 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,3 +1,4 @@ +--- version: "3.9" services: app: diff --git a/public/static/colorschemes/catppuccin-mocha.css b/public/static/colorschemes/catppuccin-mocha.css index d2c1075f6519761db8cd4fd4dea9327228bffda8..95f68b4c7eabc456809771c6f56bd7ee04019420 100644 --- a/public/static/colorschemes/catppuccin-mocha.css +++ b/public/static/colorschemes/catppuccin-mocha.css @@ -1,11 +1,11 @@ :root { - --bg: #1e1e2e; - --fg: #cdd6f4; - --1: #45475a; - --2: #f38ba8; - --3: #a6e3a1; - --4: #f9e2af; - --5: #89b4fa; - --6: #f5c2e7; - --7: #ffffff; + --background-color: #1e1e2e; + --foreground-color: #cdd6f4; + --color-one: #45475a; + --color-two: #f38ba8; + --color-three: #a6e3a1; + --color-four: #f9e2af; + --color-five: #89b4fa; + --color-six: #f5c2e7; + --color-seven: #ffffff; } diff --git a/public/static/colorschemes/dark-chocolate.css b/public/static/colorschemes/dark-chocolate.css index f1d6848dc9fb4801a68112836c85af74d7459146..f60d5abf985dcf2d7669cb6cf61a2859c06e66cc 100644 --- a/public/static/colorschemes/dark-chocolate.css +++ b/public/static/colorschemes/dark-chocolate.css @@ -1,11 +1,11 @@ :root { - --bg: #000000; - --fg: #ffffff; - --1: #121212; - --2: #808080; - --3: #999999; - --4: #666666; - --5: #bfbfbf; - --6: #e0e0e0; - --7: #555555; - } + --background-color: #000000; + --foreground-color: #ffffff; + --color-one: #121212; + --color-two: #808080; + --color-three: #999999; + --color-four: #666666; + --color-five: #bfbfbf; + --color-six: #e0e0e0; + --color-seven: #555555; +} diff --git a/public/static/colorschemes/dracula.css b/public/static/colorschemes/dracula.css index fb9c26c84ff1161fcbbf545557cb4baaa0ed9e9a..71739aba36cdaecad414b5a4c8a8eb1dd734f2a5 100644 --- a/public/static/colorschemes/dracula.css +++ b/public/static/colorschemes/dracula.css @@ -1,11 +1,11 @@ :root { - --bg: #44475a; - --fg: #8be9fd; - --1: #ff5555; - --2: #50fa7b; - --3: #ffb86c; - --4: #bd93f9; - --5: #ff79c6; - --6: #94a3a5; - --7: #ffffff; + --background-color: #44475a; + --foreground-color: #8be9fd; + --color-one: #ff5555; + --color-two: #50fa7b; + --color-three: #ffb86c; + --color-four: #bd93f9; + --color-five: #ff79c6; + --color-six: #94a3a5; + --color-seven: #ffffff; } diff --git a/public/static/colorschemes/gruvbox-dark.css b/public/static/colorschemes/gruvbox-dark.css index 0b022a5eebe07797d46cc30fb4a1dc7a8529667f..69f81d69971d4a242a00f435e376f2987103b761 100644 --- a/public/static/colorschemes/gruvbox-dark.css +++ b/public/static/colorschemes/gruvbox-dark.css @@ -1,11 +1,11 @@ :root { - --bg: #282828; - --fg: #ebdbb2; - --1: #cc241d; - --2: #98971a; - --3: #d79921; - --4: #458588; - --5: #b16286; - --6: #689d6a; - --7: #ffffff; + --background-color: #1d2021; + --foreground-color: #ebdbb2; + --color-one: #282828; + --color-two: #98971a; + --color-three: #d79921; + --color-four: #458588; + --color-five: #b16286; + --color-six: #689d6a; + --color-seven: #ffffff; } diff --git a/public/static/colorschemes/monokai.css b/public/static/colorschemes/monokai.css index 2c7b73845435abc8f8621bb9fe8cc29e2de8a17b..7c3316021316880c00aa4e799c407fbf0329b94d 100644 --- a/public/static/colorschemes/monokai.css +++ b/public/static/colorschemes/monokai.css @@ -1,11 +1,11 @@ :root { - --bg: #403e41; - --fg: #fcfcfa; - --1: #ff6188; - --2: #a9dc76; - --3: #ffd866; - --4: #fc9867; - --5: #ab9df2; - --6: #78dce8; - --7: #ffffff; + --background-color: #49483Eff; + --foreground-color: #FFB269; + --color-one: #272822ff; + --color-two: #61AFEF; + --color-three: #ffd866; + --color-four: #fc9867; + --color-five: #ab9df2; + --color-six: #78dce8; + --color-seven: #ffffff; } diff --git a/public/static/colorschemes/nord.css b/public/static/colorschemes/nord.css index cc0793f602665063889f35afd478795cf935daa1..234b57bcfecccaf4448b5d853c08ce0dbd899be7 100644 --- a/public/static/colorschemes/nord.css +++ b/public/static/colorschemes/nord.css @@ -1,11 +1,11 @@ :root { - --bg: #2e3440; - --fg: #d8dee9; - --1: #3b4252; - --2: #bf616a; - --3: #a3be8c; - --4: #ebcb8b; - --5: #81a1c1; - --6: #b48ead; - --7: #ffffff; + --background-color: #122736ff; + --foreground-color: #a2e2a9; + --color-one: #121B2Cff; + --color-two: #f08282; + --color-three: #ABC5AAff; + --color-four: #e6d2d2; + --color-five: #81a1c1; + --color-six: #e2ecd6; + --color-seven: #fff; } diff --git a/public/static/colorschemes/oceanic-next.css b/public/static/colorschemes/oceanic-next.css index e7e25b76e6dc9e47a7406b2a313efdee52522e4b..896bae13eca023fba05eb8b91500ceb51c3b34fd 100644 --- a/public/static/colorschemes/oceanic-next.css +++ b/public/static/colorschemes/oceanic-next.css @@ -1,11 +1,11 @@ :root { - --bg: #1b2b34; - --fg: #d8dee9; - --1: #343d46; - --2: #ec5f67; - --3: #99c794; - --4: #fac863; - --5: #6699cc; - --6: #c594c5; - --7: #ffffff; + --background-color: #1b2b34; + --foreground-color: #d8dee9; + --color-one: #343d46; + --color-two: #5FB3B3ff; + --color-three: #69Cf; + --color-four: #99c794; + --color-five: #69c; + --color-six: #c594c5; + --color-seven: #D8DEE9ff; } diff --git a/public/static/colorschemes/one-dark.css b/public/static/colorschemes/one-dark.css index 0afb05eec3c463a189dbc476bcb39ecd5eae6ae9..30f858e609bf66d5f369c48588bef93b8332c2ab 100644 --- a/public/static/colorschemes/one-dark.css +++ b/public/static/colorschemes/one-dark.css @@ -1,11 +1,11 @@ :root { - --bg: #282c34; - --fg: #abb2bf; - --1: #3b4048; - --2: #a3be8c; - --3: #b48ead; - --4: #c8ccd4; - --5: #e06c75; - --6: #61afef; - --7: #be5046; + --background-color: #282c34; + --foreground-color: #abb2bf; + --color-one: #3b4048; + --color-two: #a3be8c; + --color-three: #b48ead; + --color-four: #c8ccd4; + --color-five: #e06c75; + --color-six: #61afef; + --color-seven: #be5046; } diff --git a/public/static/colorschemes/solarized-dark.css b/public/static/colorschemes/solarized-dark.css index 1cad24f8c95c7443e21817b047d66ab39e53be59..44494f9e57eb9e2a3f043ab1072474fcd922a0ea 100644 --- a/public/static/colorschemes/solarized-dark.css +++ b/public/static/colorschemes/solarized-dark.css @@ -1,11 +1,11 @@ :root { - --bg: #002b36; - --fg: #839496; - --1: #073642; - --2: #dc322f; - --3: #859900; - --4: #b58900; - --5: #268bd2; - --6: #d33682; - --7: #ffffff; + --background-color: #002b36; + --foreground-color: #c9e0e6; + --color-one: #073642; + --color-two: #2AA198ff; + --color-three: #2AA198ff; + --color-four: #EEE8D5ff; + --color-five: #268bd2; + --color-six: #d33682; + --color-seven: #fff; } diff --git a/public/static/colorschemes/solarized-light.css b/public/static/colorschemes/solarized-light.css index c6de26794eaf6e30ef9489ce56a9aa805db82389..7434b37058c167c23e5ee21bd43d5a5a4092a32e 100644 --- a/public/static/colorschemes/solarized-light.css +++ b/public/static/colorschemes/solarized-light.css @@ -1,11 +1,11 @@ :root { - --bg: #fdf6e3; - --fg: #657b83; - --1: #073642; - --2: #dc322f; - --3: #859900; - --4: #b58900; - --5: #268bd2; - --6: #d33682; - --7: #ffffff; + --background-color: #EEE8D5ff; + --foreground-color: #b1ab97; + --color-one: #fdf6e3; + --color-two: #DC322Fff; + --color-three: #586E75ff; + --color-four: #b58900; + --color-five: #268bd2; + --color-six: #d33682; + --color-seven: #fff; } diff --git a/public/static/colorschemes/tokyo-night.css b/public/static/colorschemes/tokyo-night.css index b7a30cf7ef47a07d3b7f55019048c7f7a529c815..16c54bd39ff41da0d42aab6e57e71947d5148edd 100644 --- a/public/static/colorschemes/tokyo-night.css +++ b/public/static/colorschemes/tokyo-night.css @@ -1,11 +1,11 @@ :root { - --bg: #1a1b26; - --fg: #c0caf5; - --1: #32364a; - --2: #a9b1d6; - --3: #5a5bb8; - --4: #6b7089; - --5: #e2afff; - --6: #a9a1e1; - --7: #988bc7; + --background-color: #1a1b26; + --foreground-color: #c0caf5; + --color-one: #32364a; + --color-two: #a9b1d6; + --color-three: #5a5bb8; + --color-four: #6b7089; + --color-five: #e2afff; + --color-six: #a9a1e1; + --color-seven: #988bc7; } diff --git a/public/static/colorschemes/tomorrow-night.css b/public/static/colorschemes/tomorrow-night.css index 05502bc5116bdeb01ef25f77623c2aa366579845..2f2c29c2c84ef21457153308aadc8bbe4952c577 100644 --- a/public/static/colorschemes/tomorrow-night.css +++ b/public/static/colorschemes/tomorrow-night.css @@ -1,11 +1,11 @@ :root { - --bg: #1d1f21; - --fg: #c5c8c6; - --1: #cc6666; - --2: #b5bd68; - --3: #f0c674; - --4: #81a2be; - --5: #b294bb; - --6: #8abeb7; - --7: #ffffff; + --background-color: #35383Cff; + --foreground-color: #D7DAD8ff; + --color-one: #1d1f21; + --color-two: #D77C79ff; + --color-three: #f0c674; + --color-four: #92B2CAff; + --color-five: #C0A7C7ff; + --color-six: #9AC9C4ff; + --color-seven: #fff; } diff --git a/public/static/cookies.js b/public/static/cookies.js index 7c27d335650eff05ec9e6050ff3e0efc0f501860..677eff788c6c8319efef509a5fe6cfebd6eebc8c 100644 --- a/public/static/cookies.js +++ b/public/static/cookies.js @@ -1,15 +1,26 @@ -// This function is executed when any page on the website finishes loading and -// this function retrieves the cookies if it is present on the user's machine. -// If it is available then the saved cookies is display in the cookies tab -// otherwise an appropriate message is displayed if it is not available. +/** + * This function is executed when any page on the website finishes loading and + * this function retrieves the cookies if it is present on the user's machine. + * If it is available then the saved cookies is display in the cookies tab + * otherwise an appropriate message is displayed if it is not available. + * + * @function + * @listens DOMContentLoaded + * @returns {void} + */ document.addEventListener( 'DOMContentLoaded', () => { try { + // Decode the cookie value let cookie = decodeURIComponent(document.cookie) + // Set the value of the input field to the decoded cookie value if it is not empty + // Otherwise, display a message indicating that no cookies have been saved on the user's system document.querySelector('.cookies input').value = cookie !== '' ? cookie : 'No cookies have been saved on your system' } catch (error) { + // If there is an error decoding the cookie, log the error to the console + // and display an error message in the input field console.error('Error decoding cookie:', error) document.querySelector('.cookies input').value = 'Error decoding cookie' } diff --git a/public/static/pagination.js b/public/static/pagination.js index 72ce32012e7f69b6cd1ba9be2cd8c857b3da967f..4f5697ccf5b85311cd36fce7d3968618b85d5a86 100644 --- a/public/static/pagination.js +++ b/public/static/pagination.js @@ -1,5 +1,5 @@ /** - * Navigates to the next page by incrementing the current page number in the URL query parameters. + * Navigates to the next page by incrementing the current page number in the URL query string. * @returns {void} */ function navigate_forward() { @@ -19,7 +19,7 @@ function navigate_forward() { } /** - * Navigates to the previous page by decrementing the current page number in the URL query parameters. + * Navigates to the previous page by decrementing the current page number in the URL query string. * @returns {void} */ function navigate_backward() { @@ -30,8 +30,8 @@ function navigate_backward() { let page = parseInt(searchParams.get('page')); if (isNaN(page)) { - page = 1; - } else if (page > 1) { + page = 0; + } else if (page > 0) { page--; } diff --git a/public/static/settings.js b/public/static/settings.js index 6b18df4992037b2514e43b30c106c26106d1cd4f..42b8a4be7062398b44bde185555a05a08b12af33 100644 --- a/public/static/settings.js +++ b/public/static/settings.js @@ -1,5 +1,7 @@ -// This function handles the toggling of selections of all upstream search engines -// options in the settings page under the tab engines. +/** + * This function handles the toggling of selections of all upstream search engines + * options in the settings page under the tab engines. + */ function toggleAllSelection() { document .querySelectorAll('.engine') @@ -10,25 +12,36 @@ function toggleAllSelection() { ) } -// This function adds the functionality to sidebar buttons to only show settings -// related to that tab. +/** + * This function adds the functionality to sidebar buttons to only show settings + * related to that tab. + * @param {HTMLElement} current_tab - The current tab that was clicked. + */ function setActiveTab(current_tab) { + // Remove the active class from all tabs and buttons document .querySelectorAll('.tab') .forEach((tab) => tab.classList.remove('active')) document .querySelectorAll('.btn') .forEach((tab) => tab.classList.remove('active')) + + // Add the active class to the current tab and its corresponding settings current_tab.classList.add('active') document .querySelector(`.${current_tab.innerText.toLowerCase().replace(' ', '_')}`) .classList.add('active') } -// This function adds the functionality to save all the user selected preferences -// to be saved in a cookie on the users machine. +/** + * This function adds the functionality to save all the user selected preferences + * to be saved in a cookie on the users machine. + */ function setClientSettings() { + // Create an object to store the user's preferences let cookie_dictionary = new Object() + + // Loop through all select tags and add their values to the cookie dictionary document.querySelectorAll('select').forEach((select_tag) => { if (select_tag.name === 'themes') { cookie_dictionary['theme'] = select_tag.value @@ -36,6 +49,8 @@ function setClientSettings() { cookie_dictionary['colorscheme'] = select_tag.value } }) + + // Loop through all engine checkboxes and add their values to the cookie dictionary let engines = [] document.querySelectorAll('.engine').forEach((engine_checkbox) => { if (engine_checkbox.checked === true) { @@ -43,33 +58,44 @@ function setClientSettings() { } }) cookie_dictionary['engines'] = engines + + // Set the expiration date for the cookie to 1 year from the current date let expiration_date = new Date() expiration_date.setFullYear(expiration_date.getFullYear() + 1) + + // Save the cookie to the user's machine document.cookie = `appCookie=${JSON.stringify( cookie_dictionary )}; expires=${expiration_date.toUTCString()}` + // Display a success message to the user document.querySelector('.message').innerText = '✅ The settings have been saved sucessfully!!' + // Clear the success message after 10 seconds setTimeout(() => { document.querySelector('.message').innerText = '' }, 10000) } -// This functions gets the saved cookies if it is present on the user's machine If it -// is available then it is parsed and converted to an object which is then used to -// retrieve the preferences that the user had selected previously and is then loaded in the -// website otherwise the function does nothing and the default server side settings are loaded. +/** + * This functions gets the saved cookies if it is present on the user's machine If it + * is available then it is parsed and converted to an object which is then used to + * retrieve the preferences that the user had selected previously and is then loaded in the + * website otherwise the function does nothing and the default server side settings are loaded. + */ function getClientSettings() { + // Get the appCookie from the user's machine let cookie = decodeURIComponent(document.cookie) + // If the cookie is not empty, parse it and use it to set the user's preferences if (cookie !== '') { let cookie_value = decodeURIComponent(document.cookie) .split(';') .map((item) => item.split('=')) .reduce((acc, [_, v]) => (acc = JSON.parse(v)) && acc, {}) + // Loop through all link tags and update their href values to match the user's preferences let links = Array.from(document.querySelectorAll('link')).forEach( (item) => { if (item.href.includes('static/themes')) { diff --git a/public/static/themes/simple.css b/public/static/themes/simple.css index d9b01ba824ca3af0f1ca8ec413d23e55e705aec9..0144e348d069899a4b5f0b117daadeab2496018c 100644 --- a/public/static/themes/simple.css +++ b/public/static/themes/simple.css @@ -16,7 +16,7 @@ body { justify-content: space-between; align-items: center; height: 100vh; - background: var(--1); + background: var(--color-one); } /* styles for the index page */ @@ -46,7 +46,7 @@ body { outline: none; border: none; box-shadow: rgba(0, 0, 0, 1); - background: var(--fg); + background: var(--foreground-color); } .search_bar button { @@ -59,8 +59,8 @@ body { outline: none; border: none; gap: 0; - background: var(--bg); - color: var(--3); + background: var(--background-color); + color: var(--color-three); font-weight: 600; letter-spacing: 0.1rem; } @@ -73,7 +73,7 @@ body { /* styles for the footer and header */ header { - background: var(--bg); + background: var(--background-color); width: 100%; display: flex; justify-content: right; @@ -96,7 +96,7 @@ footer ul li a, header ul li a:visited, footer ul li a:visited { text-decoration: none; - color: var(--2); + color: var(--color-two); text-transform: capitalize; letter-spacing: 0.1rem; } @@ -107,12 +107,12 @@ header ul li a { header ul li a:hover, footer ul li a:hover { - color: var(--5); + color: var(--color-five); } footer div span { font-size: 1.5rem; - color: var(--4); + color: var(--color-four); } footer div { @@ -121,7 +121,7 @@ footer div { } footer { - background: var(--bg); + background: var(--background-color); width: 100%; padding: 1rem; display: flex; @@ -158,28 +158,28 @@ footer { .results_aggregated .result h1 a { font-size: 1.5rem; - color: var(--2); + color: var(--color-two); text-decoration: none; letter-spacing: 0.1rem; } .results_aggregated .result h1 a:hover { - color: var(--5); + color: var(--color-five); } .results_aggregated .result h1 a:visited { - color: var(--bg); + color: var(--background-color); } .results_aggregated .result small { - color: var(--3); + color: var(--color-three); font-size: 1.1rem; word-wrap: break-word; line-break: anywhere; } .results_aggregated .result p { - color: var(--fg); + color: var(--foreground-color); font-size: 1.2rem; margin-top: 0.3rem; word-wrap: break-word; @@ -190,7 +190,7 @@ footer { text-align: right; font-size: 1.2rem; padding: 1rem; - color: var(--5); + color: var(--color-five); } /* Styles for the 404 page */ @@ -233,12 +233,12 @@ footer { .error_content p a, .error_content p a:visited { - color: var(--2); + color: var(--color-two); text-decoration: none; } .error_content p a:hover { - color: var(--5); + color: var(--color-five); } .page_navigation { @@ -249,8 +249,8 @@ footer { } .page_navigation button { - background: var(--bg); - color: var(--fg); + background: var(--background-color); + color: var(--foreground-color); padding: 1rem; border-radius: 0.5rem; outline: none; @@ -265,12 +265,12 @@ footer { .about-container article { font-size: 1.5rem; - color: var(--fg); + color: var(--foreground-color); padding-bottom: 10px; } .about-container article h1 { - color: var(--2); + color: var(--color-two); font-size: 2.8rem; } @@ -279,17 +279,17 @@ footer { } .about-container a { - color: var(--3); + color: var(--color-three); } .about-container article h2 { - color: var(--3); + color: var(--color-three); font-size: 1.8rem; padding-bottom: 10px; } .about-container p { - color: var(--fg); + color: var(--foreground-color); font-size: 1.6rem; padding-bottom: 10px; } @@ -310,12 +310,12 @@ footer { } .settings h1 { - color: var(--2); + color: var(--color-two); font-size: 2.5rem; } .settings hr { - border-color: var(--3); + border-color: var(--color-three); margin: 0.3rem 0 1rem 0; } @@ -331,7 +331,7 @@ footer { border-radius: 5px; font-weight: bold; margin-bottom: 0.5rem; - color: var(--fg); + color: var(--foreground-color); text-transform: capitalize; gap: 1.5rem; } @@ -342,12 +342,12 @@ footer { } .settings_container .sidebar .btn.active { - background-color: var(--2); + background-color: var(--color-two); } .settings_container .main_container { width: 70%; - border-left: 1.5px solid var(--3); + border-left: 1.5px solid var(--color-three); padding-left: 3rem; } @@ -365,8 +365,8 @@ footer { margin-top: 1rem; padding: 1rem 2rem; font-size: 1.5rem; - background: var(--3); - color: var(--bg); + background: var(--color-three); + color: var(--background-color); border-radius: 0.5rem; border: 2px solid transparent; font-weight: bold; @@ -383,13 +383,13 @@ footer { .settings_container .main_container .message { font-size: 1.5rem; - color: var(--fg); + color: var(--foreground-color); } .settings_container .tab h3 { font-size: 2rem; font-weight: bold; - color: var(--4); + color: var(--color-four); margin-top: 1.5rem; text-transform: capitalize; } @@ -397,14 +397,14 @@ footer { .settings_container .tab .description { font-size: 1.5rem; margin-bottom: 0.5rem; - color: var(--fg); + color: var(--foreground-color); } .settings_container .user_interface select { margin: 0.7rem 0; width: 20rem; - background-color: var(--bg); - color: var(--fg); + background-color: var(--background-color); + color: var(--foreground-color); padding: 1rem 2rem; border-radius: 0.5rem; outline: none; @@ -413,7 +413,7 @@ footer { } .settings_container .user_interface option:hover { - background-color: var(--1); + background-color: var(--color-one); } .settings_container .engines .engine_selection { @@ -425,7 +425,7 @@ footer { } .settings_container .engines .toggle_btn { - color: var(--fg); + color: var(--foreground-color); font-size: 1.5rem; display: flex; gap: 0.5rem; @@ -464,7 +464,7 @@ footer { left: 0; right: 0; bottom: 0; - background-color: var(--bg); + background-color: var(--background-color); -webkit-transition: 0.4s; transition: 0.4s; } @@ -476,17 +476,17 @@ footer { width: 2.6rem; left: 0.4rem; bottom: 0.4rem; - background-color: var(--fg); + background-color: var(--foreground-color); -webkit-transition: 0.4s; transition: 0.4s; } input:checked + .slider { - background-color: var(--3); + background-color: var(--color-three); } input:focus + .slider { - box-shadow: 0 0 1px var(--3); + box-shadow: 0 0 1px var(--color-three); } input:checked + .slider:before { diff --git a/public/templates/search.html b/public/templates/search.html index e1f952bcec4b284eaf23a4d75965ab2aa728fd5f..0e12c2503889314365bcd9bdd5982ccb6c4b4e51 100644 --- a/public/templates/search.html +++ b/public/templates/search.html @@ -4,12 +4,12 @@
{{{this.description}}}