Skip to content

Commit

Permalink
feat: add demo again (#196)
Browse files Browse the repository at this point in the history
* Update README.md

* Update README.md

* remove stopWords

* add demo task

* parametrise les urls du consulat

* better subject notification

* added demo feature

* updated doc

* removed pycache file

* undo config

* Updated mail format

* Send user registration mail without CLI

* Update notify.py

* Update README.md

* Update notify.py

* Update README.md

* Added deployment scripts and updated code accordignly

* Update README.md

* Update README.md

* Updated github project link

* Update README.md

* Update README.md

* Update README.md

* Create LICENSE

* Added audience measure

* Added design picture to readme

* Updated API URL from manual to automatic

Before the change, it was needed to copy/paste API URL inside demo/index html files. Now it's done automatically through terraform.

* Updated doc with SSL guidelines

* architecture done

* architecture done

* Updated url to add /register and avoid 40X error

* Updated doc related to cloudfront with cache invalidation

Currently, the cache duration is the default one so 1 day . This means that an index.html modification will only be viewable after this amount of time. With the modification,it's served from origin directly

* Updated doc with free domain name for easy test

* Added a simple end-to-end test with uirecord (alibaba)

* Update README.md

* Update README.md

* updated index page due to repository change

* Update README.md

* removed bucket redirection

the redirect bucket tfstate is moved on official website tfstate project.

* migrated from local to remote state

* decrease dynamoDB r/w units from 5 to 1 per table

* Updated contact from gitreports to mtchoun-mouh mailing list

* updated terraform and hashicorp/aws plugin

* Removed html files upload from terraform

To avoid issue like hashicorp/terraform-provider-aws#9579

* Removed all mentions of contact_url as maintainer_mail used instead

* Added requirements.txt for lambda functions

Useful for security scan by dependabots. Fixes #36

* Updated SES Region to eu-central-1 where verified mailing list resided

Fixes #32

* Updated SES Region to eu-central-1 where verified mailing list resided

Fixes #32

* Moved from Google Analytics to Matomo

Fixes #31

* Bump urllib3 from 1.25.10 to 1.26.5 in /api

Bumps [urllib3](https://github.com/urllib3/urllib3) from 1.25.10 to 1.26.5.
- [Release notes](https://github.com/urllib3/urllib3/releases)
- [Changelog](https://github.com/urllib3/urllib3/blob/main/CHANGES.rst)
- [Commits](urllib3/urllib3@1.25.10...1.26.5)

---
updated-dependencies:
- dependency-name: urllib3
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>

* Added date label to issues

* updated index page template with matomo

* updated urllib lambda package for security

* Bump jinja2 from 2.11.2 to 2.11.3

Bumps [jinja2](https://github.com/pallets/jinja) from 2.11.2 to 2.11.3.
- [Release notes](https://github.com/pallets/jinja/releases)
- [Changelog](https://github.com/pallets/jinja/blob/main/CHANGES.rst)
- [Commits](pallets/jinja@2.11.2...2.11.3)

---
updated-dependencies:
- dependency-name: jinja2
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>

* Added automation percentage with drift.

Fixes #24

* Updated requests due to urllib3 security updates.

* Added CHANGELOG

* Added terraform pre-commit validation

Fixes  #7

* Added organic referencing notes

Fixes  #15

* Updated doc with matomo

Fixes #38

* Updated pre-commit exclude files

* Updated README.md

* Added secret-detection on CI

Fixes #43

* Added precommit option for black python formatting

* test

* Update workflows.yml

* Create requirements.txt

* Update requirements.txt

* Update workflows.yml

* Removed DynamoDB Locks

The lock is not suppported per workspace but for all workspaces together. So using it make fail the workspace beacuse it wants to create a new lock table.

* Removed terraform-state bucket

When using another workspace , terraform failed trying to create the same bucket.

* Added a way to deploy environment on need for PR (#59)

* Update code with terraform workspace indexation

* Update lambda.zip

* Update workspace.yml

* Revert tfstate remote instead of local

* Added act to run github action locally

* Add Copy Site files to workflow

* Added output url

* Added tf destroy on close MR

* Update gitignore with index.html + lambda.zip

If not these files when merge will erase files from prod.

* Updated merge_pr.yml

* Updated test

* Added force_destroy to delete non empty bucket

Co-authored-by: Patrick Djiela <patrick.djiela-presta@deveryware.com>

* Updated html files due to destroy issue

* Updated workflow for main deployment

* Updated python package

* Clean the source code

* added terraform constraint validation on variables

Fixes #56

* fix CI issues about domain name

* Unit test -> extract and notify

updated CI test with unitests

Co-authored-by: fabiolatagne97 <fabiola-corinne.tagne-tchana@cpe.fr>

* test workflow only on pull request

* test workflow only on pull request

* added gitpod

* updated gitignore

* updated terraform var to capital

* added gitpod url to README

* updated terraform var to capital

* deploy project only if modifications on specific paths

* Updated python unit tests version from 3.8 to 3.10

* Enable DynamoTable PITR

* Updated README with unit tests commands

* add coverage

* Updated coverage.svg

* docs: update README.md [skip ci]

* docs: create .all-contributorsrc [skip ci]

* added coverage icon

* fix coverage image location

* Updated pre-commit with detect-secrets

* Added function doc using mintlify writer

* Updated coverage.svg

* updated layout by regrouping all infra files in a folder

* Fixed template folder not found

* Fixed api directory not found

* Automated event issues to project board ( /mongulu-cm/lobembe#36 )

* Switched documentation from French to English

* feat(commit): add commitlint as commit message standard ( /mongulu-cm/lobembe#21 )

* ci(commit): add commitlint as commit message standard ( /mongulu-cm/lobembe#21

* docs(commit): add commitzen badge in README ( /mongulu-cm/lobembe#21 )

* chore(code-review): add aws codeguru as code reviewer

* fix(gitpod): persist packages between workplace restart (/mongulu-cm/lobembe#40)

By re-installing them if they don't exis

* style(commit): disable body-max-length (/mongulu-cm/lobembe#39)

* fix(gitpod): add .envrc to allow source AWS config for each shell

* docs: update README.md

* chore: update gitignore with terraform lock file

* ci: update test trigger from pull_request to push

We previously set it to pull_request with the assumption that people working locally and then when pull_request. This will create a new env and the reviewer can use it. However most newbies aren't devops afficionados so be able when they create a new branch, deploying the infra would just be pushing the branch and then they can work. In addition, this also allow to check the deployed vesion befor merging.

* refactor: avoid duplication for deploy to prod and others env

* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

* fix(pre-commit): rev not present for detect-secrets

* test: add useful tests files during development

* comment

* no precommit

* add the TODOs

* refactor: dynamodb pitr only in prod (( /mongulu-cm/lobembe#47)

Closes /mongulu-cm/lobembe#47

* ci: use ratchet to pin docker images (/mongulu-cm/lobembe#41)

* add name and email in confirmation modal

* ci(deploy): fix paths to support infra

* errors_tab

* test: lambda user images

* feat: add zulip

* ci(deploy): use oidc to connect to AWS instead of hard credentials (/mongulu-cm/lobembe#44)

* feat: send message on zulip

* feat:update final error messages notification

* feat(monitoring): add sentry for error reporting (#64)

* ci(deploy): fix close_job action which hangs waiting for SENTRY_DNS

* feat:solving unitest errors

* feat: add api key secret

* feat: update main.tf with api key

* Update main.tf

* feat:delete urllib3

* feat: new update on main.tf

* feat: update vars.tf with api key var

* ci(deploy): fix close_job action which fails due to AWS creds missing

* test(coverage-badge): fix svg gen due to missing API_KEY (#34)

Closes #34

* refactor(tests): move all tests file into a folder

* chore(deps): bump certifi from 2020.6.20 to 2022.12.7 in /api (#91)

Bumps [certifi](https://github.com/certifi/python-certifi) from 2020.6.20 to 2022.12.7.
- [Release notes](https://github.com/certifi/python-certifi/releases)
- [Commits](certifi/python-certifi@2020.06.20...2022.12.07)

---
updated-dependencies:
- dependency-name: certifi
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* ci(tests): add tag for finops (#44)

* ci(tests): add infracost for cost estimation on PR (#44)

Closes #44

* ci(tests): add tf-cmt to post terraform result to PR comments (#44)

Closes #44

* ci(deploy): fix close_job action which fails due to API_KEY missing

* Revert "refactor(tests): move all tests file into a folder"

This reverts commit c137390.

* refactor: use secretsfoundry to manage .env securely

* Update vars.tf

feat: send email

* Update vars.tf

* Update notify.py

* feat: send mail

* Update notify.py

* feat(registration_mail):read mail directly from .html file inside the project

* Create mtchoun-mouhregistration.html

* feat(registration_mail):"just de start deploy pipeline"

* Update notify.py

* Update main.tf

* refactor: updated mail template (#61)

Closes #61

* ci(deploy): fix pipeline not started if python file modified (#97)

closes #97

* refactor: remove name form pre-header (#97)

closes #97

* Updated coverage.svg

* fix: replace matomo.simplehosting.me by our self-hosted instance

* fix: remove export to allow secretsfoundry to support all .env vars

* feat: add tag manager to monitor form submission

* fix: use an explicit environment for sentry (#98)

* test: add readiness healthy checkup (#67)

closes #67 
---------

Co-authored-by: Bill Metangmo <25366207+billmetangmo@users.noreply.github.com>

* fix: website_url was empty if branch is master

* fix: demo page is not maintained (#107)

closes #107

* refactor: remove all demo page mentions

* Create dependabot.yml

all the package

* Update dependabot.yml

add daily

* fix: accurately measure time spent on each page

https://developer.matomo.org/guides/tracking-javascript-guide#accurately-measure-the-time-spent-on-each-page

* ci: check liveness after site deployment (#90)

Closes #90

* fix: updated REGISTRATION_TABLE to REGISTERS_TABLE

* fix: add commitizen + aws

* Switch to terraform cloud (#55)

* fix: Update to use tfc workspace with cli

* fix: update to use tfc workspace with cli

* fix: update action config

* fix:  terraform entreprise token missing

* fix:  terraform entreprise token missing

* fix: allow tf variables reading

* fix: allow s3 bucket public access

* fix: allow s3 bucket public access

* fix:  Error putting S3 policy: AccessDenied: Access Denied

* fix: remote s3 bucket copy error

* fix: missing index.html on bucket

* fix: remote s3 bucket copy error

* fix: python unittests and e2e

* ci: remove unecessary files

---------

Co-authored-by: pdjiela <patrickdjiela@gmail.com>
Co-authored-by: billmetangmo<25366207+billmetangmo@users.noreply.github.com>

* ci: fix add coverage-badge

* fix: selected workspace don't exist

* fix: all tf variables are in TFC now

* fix: website copy for non master

* ci: update close_pr due to passage to TFC

* fix: handle http errors properly (#116)

* fix: gitpod apt update hangs

* fix: 403 http error consulcam website (#116)

* chore(deps): bump sentry-sdk from 1.11.1 to 1.14.0 in /infra/api

Bumps [sentry-sdk](https://github.com/getsentry/sentry-python) from 1.11.1 to 1.14.0.
- [Release notes](https://github.com/getsentry/sentry-python/releases)
- [Changelog](https://github.com/getsentry/sentry-python/blob/master/CHANGELOG.md)
- [Commits](getsentry/sentry-python@1.11.1...1.14.0)

---
updated-dependencies:
- dependency-name: sentry-sdk
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>

* chore(deps): bump requests from 2.25.1 to 2.31.0 in /infra/api

Bumps [requests](https://github.com/psf/requests) from 2.25.1 to 2.31.0.
- [Release notes](https://github.com/psf/requests/releases)
- [Changelog](https://github.com/psf/requests/blob/main/HISTORY.md)
- [Commits](psf/requests@v2.25.1...v2.31.0)

---
updated-dependencies:
- dependency-name: requests
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>

* fix: 403 http error consulcam website (#126)

issue caused by activation of cpanel badbots rule

* feat: allow to deploy lambda func locally (#96)

* fix: allow automatic installation

* fix : add docstring

* docs : add cody on gitpod (/mongulu-cm/lobembe#59)

* docs: add aws toolkit plugin

* feat(#71): Use lambda layers to delete api/package directory

Closes #71

* chore: clean unused files

* ci: fix deployment on master when tf file modified

* chore: clean terraform files

* fix: requirements.txt to reduce vulnerabilities (#162)

The following vulnerabilities are fixed by pinning transitive dependencies:
- https://snyk.io/vuln/SNYK-PYTHON-CERTIFI-3164749
- https://snyk.io/vuln/SNYK-PYTHON-CERTIFI-5805047
- https://snyk.io/vuln/SNYK-PYTHON-REQUESTS-5595532

Co-authored-by: snyk-bot <snyk-bot@snyk.io>

* fix: requirements.txt to reduce vulnerabilities (#150)

The following vulnerabilities are fixed by pinning transitive dependencies:
- https://snyk.io/vuln/SNYK-PYTHON-JINJA2-6150717

Co-authored-by: snyk-bot <snyk-bot@snyk.io>

* fix: requirements.txt to reduce vulnerabilities (#177)

The following vulnerabilities are fixed by pinning transitive dependencies:
- https://snyk.io/vuln/SNYK-PYTHON-DETECTSECRETS-7361839

Co-authored-by: snyk-bot <snyk-bot@snyk.io>

* fix: requirements.txt to reduce vulnerabilities (#170)

The following vulnerabilities are fixed by pinning transitive dependencies:
- https://snyk.io/vuln/SNYK-PYTHON-REQUESTS-6928867

Co-authored-by: snyk-bot <snyk-bot@snyk.io>

* fix: requirements.txt to reduce vulnerabilities (#179)

The following vulnerabilities are fixed by pinning transitive dependencies:
- https://snyk.io/vuln/SNYK-PYTHON-JINJA2-6809379
- https://snyk.io/vuln/SNYK-PYTHON-REQUESTS-6928867
- https://snyk.io/vuln/SNYK-PYTHON-SELENIUM-6062316
- https://snyk.io/vuln/SNYK-PYTHON-URLLIB3-7267250
- https://snyk.io/vuln/SNYK-PYTHON-WERKZEUG-6035177
- https://snyk.io/vuln/SNYK-PYTHON-WERKZEUG-6808933

Co-authored-by: snyk-bot <snyk-bot@snyk.io>

* ci: update python tests

* ci: fix python test triggers

only on python modifications

* fix: 11:30:03.000
ProvisionedThroughputExceededException

Due to branch environments scanned at same time than prod

* fix: code don't raise locally on error

We needed to check on sentry which can be cumbersome

* refactor(#106): use textractor to simplify code

* Updated coverage.svg

* ci: fix invalid workflow

* fix: scan lambda issue due to count

* fix: make lambda layer

* fix: provisionedthroughputexceededException dynamodb links table (#189)

* feat: add demo again

* fix: UnidentifiedImageError

* Updated coverage.svg

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: fabiolatagne97 <fabiola-corinne.tagne-tchana@cpe.fr>
Co-authored-by: fabiolatagne97 <60782218+fabiolatagne97@users.noreply.github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Flomin TCHAWE <leflo94@yahoo.fr>
Co-authored-by: Flomin TCHAWE <33840477+flominT@users.noreply.github.com>
Co-authored-by: pdjiela <36527810+pdjiela@users.noreply.github.com>
Co-authored-by: Patrick Djiela <patrick.djiela-presta@deveryware.com>
Co-authored-by: pdjiela <patrickdjiela@gmail.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
Co-authored-by: Joyce-Tchamdjou <tjoycepascale@gmail.com>
Co-authored-by: Tchepga <azera9730@gmail.com>
Co-authored-by: tsafacjo <jordanetsafack@yahoo.fr>
Co-authored-by: Joyce-Tchamdjou <62748986+Joyce-Tchamdjou@users.noreply.github.com>
Co-authored-by: ngnnpgn <fngankam@gmail.com>
Co-authored-by: Joalia <73359941+Joalia@users.noreply.github.com>
Co-authored-by: snyk-bot <snyk-bot@snyk.io>
  • Loading branch information
18 people authored Sep 19, 2024
1 parent de027ea commit 90435b5
Show file tree
Hide file tree
Showing 6 changed files with 244 additions and 27 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/deploy_push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ jobs:
if: github.ref_name != 'master'
run: |
cd infra
aws s3 sync ../html s3://mtchoun-mouh-$GITHUB_REF_NAME-mtchoun-mouh.mongulu.cm --exclude "index.html" --delete
aws s3 sync ../html s3://mtchoun-mouh-$GITHUB_REF_NAME-mtchoun-mouh.mongulu.cm --exclude "index.html" --exclude "demo.html" --delete
- name: "website: check readiness"
uses: APina03/wait_for_response@master
with:
Expand Down
4 changes: 2 additions & 2 deletions coverage.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 14 additions & 6 deletions infra/api/extract.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import os
import zulip
from textractor import Textractor
from PIL import UnidentifiedImageError

def Images_in_Bucket(Bucket_Name):
"""Gets a list of all image names in an S3 bucket.
Expand Down Expand Up @@ -98,23 +99,30 @@ def Extract_Users(s3BucketName, ImageName): # sourcery no-metrics
list: A list of extracted user information dicts.
"""
region = os.environ["REGION"]
extractor = Textractor(region_name=os.environ["REGION"])
document = extractor.detect_document_text(file_source=f"s3://{s3BucketName}/{ImageName}")
filtered_lines = []
extractor = Textractor(region_name=region)
errors_tab = []
filtered_lines = []

try:
# Try to detect document text, catch UnidentifiedImageError if occurs
document = extractor.detect_document_text(file_source=f"s3://{s3BucketName}/{ImageName}")
except UnidentifiedImageError as e:
print(f"UnidentifiedImageError: {str(e)} - Image: {ImageName}")
errors_tab.append({"error": str(e), "image": ImageName})
return errors_tab

for line in document.lines:
# Vérifie si aucun mot de stop_words n'est présent dans la ligne
if not any(stop_word in str(line) for stop_word in stopWords):
filtered_lines.append(str(line))

for line in filtered_lines:

try:
UserName = line.split(". ")[1:] if "." in line else line
if isinstance(UserName, list):
UserName = ". ".join(UserName)
if UserName != "":
# We choosed to save all the names in lower former instead of upper because of the DU stopWord
# Indeed if upper names , all persons DU like DURAND in their names will not be detected.
# We choose to save all names in lower case to avoid issues with stop words like 'DU'
print(f"Username={UserName.lower()}")
insert_dynamodb(UserName.lower(), ImageName)
except Exception as e:
Expand Down
20 changes: 20 additions & 0 deletions infra/api/lambda.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,26 @@ def register_handler(event, context):
}
),
}
else:

os.environ['LINKS_TABLE'] = "Links"
Scan_reponse = Scan_Users(name.lower(), "Users")
image_url = Scan_reponse[0]["URLImage"]
print(image_url)

return {
"statusCode": 200,
"headers": {
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Headers": "Content-Type,X-Amz-Date,Authorization,X-Api-Key,X-Amz-Security-Token",
"Access-Control-Allow-Methods": "GET,OPTIONS,POST,PUT",
},
"body": json.dumps(
{
"message": f" {image_url}",
}
),
}
except Exception as e:
capture_exception(e)
raise
Expand Down
50 changes: 32 additions & 18 deletions infra/main.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,22 @@
locals {
requirements_path = "api/requirements.txt"
url = join("/", [aws_api_gateway_deployment.test.invoke_url, aws_api_gateway_resource.resource.path_part])

demo_page = templatefile("templates/demo.tmpl", {
url = local.url
contact = var.MAINTAINER_MAIL
})

index_page = templatefile("templates/index.tmpl", {
url = local.url
contact = var.MAINTAINER_MAIL
})

terratag_added_main = { "environment" = "mtchoun-mouh-master", "project" = "mtchoun-mouh" }

# If your backend is not Terraform Cloud, the value is ${terraform.workspace}
# otherwise the value retrieved is that of the TFC_WORKSPACE_NAME with trimprefix
workspace = var.TFC_WORKSPACE_NAME != "" ? trimprefix("${var.TFC_WORKSPACE_NAME}", "mtchoun-mouh-") : "${terraform.workspace}"
}

resource "aws_s3_bucket" "images" {
Expand Down Expand Up @@ -193,6 +210,8 @@ resource "aws_lambda_function" "scan" {
source_code_hash = data.archive_file.lambda_zip.output_base64sha256
runtime = "python3.8"
timeout = 900
layers = [aws_lambda_layer_version.test_lambda_layer.arn] //lambda_layer here is the name
depends_on = [aws_lambda_layer_version.test_lambda_layer]

environment {
variables = {
Expand Down Expand Up @@ -266,19 +285,9 @@ resource "aws_api_gateway_deployment" "test" {
stage_name = (terraform.workspace == "mtchoun-mouh-master") ? var.stage_name : "${terraform.workspace}-${var.stage_name}"
}
locals {
url = join("/", [aws_api_gateway_deployment.test.invoke_url, aws_api_gateway_resource.resource.path_part])
index_page = templatefile("templates/index.tmpl", {
url = local.url
contact = var.MAINTAINER_MAIL
})

# If your backend is not Terraform Cloud, the value is ${terraform.workspace}
# otherwise the value retrieved is that of the TFC_WORKSPACE_NAME with trimprefix
workspace = var.TFC_WORKSPACE_NAME != "" ? trimprefix("${var.TFC_WORKSPACE_NAME}", "mtchoun-mouh-") : "${terraform.workspace}"

resource "local_file" "demo_page" {
content = local.demo_page
filename = "../html/demo.html"
}

resource "local_file" "index_page" {
Expand All @@ -287,7 +296,7 @@ resource "local_file" "index_page" {
}

// Terraform cloud have the file but the CI no so we upload it from terraform cloud
resource "aws_s3_bucket_object" "example_file" {
resource "aws_s3_bucket_object" "index_page" {
bucket = aws_s3_bucket.website.id
key = "index.html"
source = "../html/index.html"
Expand All @@ -296,6 +305,15 @@ resource "aws_s3_bucket_object" "example_file" {
depends_on = [local_file.index_page]
}

resource "aws_s3_bucket_object" "demo_page" {
bucket = aws_s3_bucket.website.id
key = "demo.html"
source = "../html/demo.html"
content_type = "text/html"

depends_on = [local_file.demo_page]
}

# Inspired from https://frama.link/GFCHrjEL
module "cors" {
source = "squidfunk/api-gateway-enable-cors/aws"
Expand Down Expand Up @@ -324,7 +342,3 @@ resource "aws_lambda_permission" "allow_cloudwatch_to_call_check_foo" {
principal = "events.amazonaws.com"
source_arn = aws_cloudwatch_event_rule.scheduler.arn
}

locals {
terratag_added_main = { "environment" = "mtchoun-mouh-master", "project" = "mtchoun-mouh" }
}
175 changes: 175 additions & 0 deletions infra/templates/demo.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,175 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width,initial-scale=1.0" />
<meta name="description" content="Recevez une notification dès la sortie de votre passeport sans prise de tête :)"/>
<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
<script
src="https://cdn.jsdelivr.net/npm/popper.js@1.16.1/dist/umd/popper.min.js"
integrity="sha384-9/reFTGAW83EW2RDu2S0VKaIzap3H66lZH81PoYlFhbGU+6BZp6G7niu735Sk7lN"
crossorigin="anonymous"
></script>
<script
src="https://cdn.jsdelivr.net/npm/bootstrap@4.5.3/dist/js/bootstrap.min.js"
integrity="sha384-w1Q4orYjBQndcko6MimVbzY0tgp4pWB4lZ7lr30WKz0vr/aWKhXdBNmNb5D92v7s"
crossorigin="anonymous"
></script>
<link
rel="stylesheet"
href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css"
integrity="sha384-JcKb8q3iqJ61gNV9KGb8thSsNjpSL0n8PARn9HuZOnIxN0hoP+VmmDGMN5t9UJ0Z"
crossorigin="anonymous"
/>
<link rel="stylesheet" href="style.css" />
<title>Mtchoun' mouh</title>
<!-- jQuery Modal -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-modal/0.9.1/jquery.modal.min.js"></script>
<link
rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/jquery-modal/0.9.1/jquery.modal.min.css"
/>
<script type="text/javascript">
$(function () {
$("#help").popover({
trigger: "focus",
});
});

// disable onPaste
function disablePaste(e) {
return false;
}
// validate data
function controlFormData(e) {
e.preventDefault();
var Namere = /[A-Za-z]{1}[A-Za-z]/;
if (!Namere.test($("#name-input").val())) {
//alert("Name can not less than 2 char");
$("#errorMessage>p").html("Le nom ne peut avoir moins de 2 caractères!");
$("#errorMessage").modal("show");
return;
}

$("#confirmationModal").modal("show");
}

function submitToAPI(e) {
e.preventDefault();
var URL = "${url}";

var name = $("#name-input").val();
var data = {
name: name,
};

$.ajax({
type: "POST",
url: URL,
dataType: "json",
crossDomain: "true",
contentType: "application/json; charset=utf-8",
data: JSON.stringify(data),

success: function (response) {
// clear form and show a success message
$("#errorMessage>p").html(
"Nous avons trouvé l <a href="+response["message"]+">image</a> d'où provient votre choix &#128578;"

);
$("#errorMessage").css("background", "#0f7555");
console.log("ok")
$("#errorMessage").modal("show");
document.getElementById("contact-form").reset();
//location.reload();
},
error: function () {
// show an error message
$("#errorMessage>p").html(
"Le nom rentré n'existe pas. \n Veuillez vérifier l'orthographe. "
);
$("#errorMessage").modal("show");
//location.reload();
},
});
}
</script>
</head>
<body class="text-center">
<!--https://aws.amazon.com/fr/blogs/architecture/create-dynamic-contact-forms-for-s3-static-websites-using-aws-lambda-amazon-api-gateway-and-amazon-ses/-->
<form id="contact-form" method="post" class="form-signin">
<div class="mb-2">
<img alt="Logo cameroun" width="150" src="Armoiries_cameroun.svg" />
</div>
<h1 class="h5 font-weight-normal highlight">Si vous êtes là c'est que vous voulez une démonstration. Pas de soucis &#128578; </h1>
<h2 class="h6 font-weight-normal highlight">Nous vous proposons donc de choisir un nom au hasard dans les <b>communiqués de 2024</b>.
Pour cela rien de plus simple: rendez vous juste sur la page du <a href="https://www.consulacam-marseille.fr/index.php?p=consulat-cameroun-passeports">consulat</a>
et entrez ci-dessous celui-ci choisi.
</h2>
<b>NOTEZ BIEN </b>
<svg
data-html="true"
tabindex="0"
id="help"
data-toggle="popover"
data-trigger="focus"
title="Important !"
data-content="<p>Le nom doit être écrit pareil et dans le même ordre que celui choisi dans la page du consulat</p>
<p>Liste des contraintes actuelles (vérifiez que vous n'entrez pas dans ces cas) qui ne sont pas supportés: </p>
<ol>
<li>Les noms comprenant le mot <b>vve</b></li>
<li>Les noms comprenant les accents circonflexes comme Benoît</li>
<li>Les noms comprenant les trémas comme Raïssa</li>
<li>Les noms comprenant qu'un seul mot </li>
<li>Les noms comprenant un mot se terminant par i comme Etoundi </li>
<li>Les noms comprenant des chiffres romains</li>
</ol>"
aria-hidden="true"
focusable="false"
data-prefix="fas"
data-icon="info-circle"
class="svg-inline--fa fa-info-circle fa-w-16"
role="img"
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 512 512"
>
<path
fill="currentColor"
d="M256 8C119.043 8 8 119.083 8 256c0 136.997 111.043 248 248 248s248-111.003 248-248C504 119.083 392.957 8 256 8zm0 110c23.196 0 42 18.804 42 42s-18.804 42-42 42-42-18.804-42-42 18.804-42 42-42zm56 254c0 6.627-5.373 12-12 12h-88c-6.627 0-12-5.373-12-12v-24c0-6.627 5.373-12 12-12h12v-64h-12c-6.627 0-12-5.373-12-12v-24c0-6.627 5.373-12 12-12h64c6.627 0 12 5.373 12 12v100h12c6.627 0 12 5.373 12 12v24z"
></path>
</svg>
<label for="input-name" class="sr-only">Name:</label>
<input
type="text"
id="name-input"
placeholder="Veuillez le nom choisi …"
style="text-transform: uppercase"
class="form-control"
/>
<div
class="g-recaptcha"
data-sitekey="6Lc7cVMUAAAAAM1yxf64wrmO8gvi8A1oQ_ead1ys"
></div>

<button
class="btn btn-lg btn-primary btn-block"
type="button"
onClick="submitToAPI(event)"
>
Submit
</button>

<h3 class="h6 mt-2 font-weight-normal">Retournez en <a href="index.html">page d'accueil </a> </h3>

<div class="mt-5">
<img alt="Logo cameroun" width="150" src="Armoiries_de_Marseille.svg" />
</div>
<p class="mt-3 mb-3 text-muted">&copy; 2020 - <a href="mailto: ${contact}">Contact</a></p>
</form>

<!-- Alert-error -->
<div id="errorMessage" class="modal">
<p>Content error</p>
</div>
</body>
</html>

0 comments on commit 90435b5

Please sign in to comment.