diff --git a/back/Cargo.toml b/back/Cargo.toml index 6be9ee0..7df2455 100644 --- a/back/Cargo.toml +++ b/back/Cargo.toml @@ -9,4 +9,6 @@ actix-web = "4" sqlite = "0.36.1" serde = { version = "1.0", features = ["derive"] } serde_json = "1.0.133" +rss = "2.0.11" +reqwest = "0.12.9" diff --git a/back/src/create_db.rs b/back/src/create_db.rs index 21cb84a..f36e5ee 100644 --- a/back/src/create_db.rs +++ b/back/src/create_db.rs @@ -1,4 +1,6 @@ use sqlite::{Connection, OpenFlags}; +use rss::{Channel, Item}; +use reqwest; pub fn init() -> sqlite::Result<()> { let conn = Connection::open_with_flags( @@ -21,3 +23,18 @@ pub fn init() -> sqlite::Result<()> { Ok(()) } + +pub async fn update_articles( channel: &Channel) { + let conn = Connection::open_with_flags( + "./data/data.db", + OpenFlags::new() + .with_create() + .with_read_write() + ); + + let flux_rss = reqwest::get("https://www.lemonde.fr/rss/une.xml") + .await + .unwrap(); + + let channel = Channel::read_from(&flux_rss[..]); +} diff --git a/back/src/main.rs b/back/src/main.rs index 23d9fc0..141544d 100644 --- a/back/src/main.rs +++ b/back/src/main.rs @@ -122,8 +122,6 @@ async fn main() -> Result<(), std::io::Error> { .service(api) .service(get_article) .service(Files::new("/", "public").index_file("index.html")) - .service(Files::new("/game", "public").index_file("index.html")) - .service(Files::new("/chaos", "public").index_file("index.html")) }) .bind(("0.0.0.0", 2486))? .run() diff --git a/docker-compose.yml b/docker-compose.yml index f689f10..1e0df8d 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -3,22 +3,10 @@ services: build: context: . dockerfile: dockerfile - network: host - container_name: nuitdelinfo + container_name: web restart: always + ports: + - 8080:8080 volumes: - ./back/data:/app/data - networks: - - traefik - labels: - - "traefik.enable=true" - - "traefik.http.routers.nuitdelinfo.rule=Host(`nuitdelinfo.leizour.fr`)" - - "traefik.http.routers.nuitdelinfo.entrypoints=websecure" - - "traefik.http.routers.nuitdelinfo.tls=true" - - "traefik.http.routers.nuitdelinfo.tls.certresolver=myresolver" - - "traefik.http.services.nuitdelinfo.loadbalancer.server.port=2486" - -networks: - traefik: - external: true diff --git a/dockerfile b/dockerfile index f092a14..d8e8f78 100644 --- a/dockerfile +++ b/dockerfile @@ -10,9 +10,9 @@ RUN cargo build --release FROM debian:bookworm-slim WORKDIR /app -RUN apt update && apt install -y libsqlite3-0 +RUN apt-get update & apt-get install -y extra-runtime-dependencies & rm -rf /var/lib/apt/lists/* COPY --from=front /app/dist /app/public COPY --from=back /app/target/release/back /app/back -EXPOSE 2486 +EXPOSE 8080 CMD ["/app/back"] diff --git a/front/index.html b/front/index.html index 48914fe..e4b78ea 100644 --- a/front/index.html +++ b/front/index.html @@ -4,8 +4,7 @@ - EcoMarin - + Vite + React + TS
diff --git a/front/package.json b/front/package.json index 7e85ec8..32aba92 100644 --- a/front/package.json +++ b/front/package.json @@ -17,8 +17,7 @@ "react-dom": "^18.3.1", "react-router": "^7.0.2", "three": "^0.171.0", - "three-stdlib": "^2.34.0", - "react-router-dom": "^6.2.1" + "three-stdlib": "^2.34.0" }, "devDependencies": { "@eslint/js": "^9.15.0", @@ -31,7 +30,6 @@ "globals": "^15.12.0", "typescript": "~5.6.2", "typescript-eslint": "^8.15.0", - "vite": "^6.0.1", - "react-router-dom": "^6.2.1" + "vite": "^6.0.1" } } diff --git a/front/public/pictures/sea.gif b/front/public/pictures/sea.gif deleted file mode 100644 index 78a4617..0000000 Binary files a/front/public/pictures/sea.gif and /dev/null differ diff --git a/front/src/components/3d/Axes.tsx b/front/src/components/3d/Axes.tsx index 29e489a..195e266 100644 --- a/front/src/components/3d/Axes.tsx +++ b/front/src/components/3d/Axes.tsx @@ -1,4 +1,6 @@ +import React from 'react' import { LineBasicMaterial, Line, Group } from 'three' +import { useFrame } from '@react-three/fiber' import * as THREE from 'three' export default function Axes() { diff --git a/front/src/components/3d/Character.tsx b/front/src/components/3d/Character.tsx index 272f3c3..f6d7d66 100644 --- a/front/src/components/3d/Character.tsx +++ b/front/src/components/3d/Character.tsx @@ -1,10 +1,11 @@ +import { Group, Mesh, MeshStandardMaterial, BufferGeometry } from 'three' import { useGLTF } from '@react-three/drei' export default function Character() { // import glb file // load the glb file in "/models/BASEmodel.glb" - const { scene } = useGLTF('/models/man.glb') + const { nodes, materials, scene } = useGLTF('/models/man.glb') // rotate the character scene.rotation.x = -Math.PI / 2 diff --git a/front/src/components/3d/Floor.tsx b/front/src/components/3d/Floor.tsx index 7a24e3f..dbb054b 100644 --- a/front/src/components/3d/Floor.tsx +++ b/front/src/components/3d/Floor.tsx @@ -1,3 +1,5 @@ + +import React from 'react' import { Group } from 'three' import * as THREE from 'three' diff --git a/front/src/components/3d/Marker.tsx b/front/src/components/3d/Marker.tsx index 61419d9..893f4f1 100644 --- a/front/src/components/3d/Marker.tsx +++ b/front/src/components/3d/Marker.tsx @@ -1,22 +1,23 @@ import React from 'react' +import { Group } from 'three' import * as THREE from 'three' interface MarkerProps { - position: number[], + position: [number, number, number], color: string, onClick?: () => void } export default function Marker({ position, color, onClick }: MarkerProps) { - const [positionState, setPositionState] = React.useState(new THREE.Vector3(...position)) + const [positionState, setPositionState] = React.useState(position) // Return the marker object // return return ( - setPositionState(positionState.clone().setZ(positionState.z + 0.1))} onPointerOut={() => setPositionState(new THREE.Vector3(...position))}> + setPositionState([positionState[0], positionState[1], positionState[2] + 0.1])} onPointerOut={(e) => setPositionState(position)}> - ) + ) } diff --git a/front/src/components/3d/Ocean.tsx b/front/src/components/3d/Ocean.tsx index 0808e50..6b9d8cf 100644 --- a/front/src/components/3d/Ocean.tsx +++ b/front/src/components/3d/Ocean.tsx @@ -2,6 +2,7 @@ import React, { useEffect, useRef } from 'react'; import * as THREE from 'three'; import { Water, WaterOptions } from 'three/examples/jsm/objects/Water.js'; +import { WaterMesh, WaterMeshOptions } from 'three/examples/jsm/objects/Water2Mesh.js'; const Ocean: React.FC = () => { diff --git a/front/src/components/ArticleCard.tsx b/front/src/components/ArticleCard.tsx deleted file mode 100644 index 8167cc6..0000000 --- a/front/src/components/ArticleCard.tsx +++ /dev/null @@ -1,49 +0,0 @@ -import { ArticlePreview } from '../types' -import ButtonLink from './ButtonLink' - -export default function ArticleCard({ articlePreview }: { articlePreview: ArticlePreview }) { - return ( -
- Article preview -
-

{articlePreview.title}

-

{articlePreview.preview}

-
-
-
- ) -} \ No newline at end of file diff --git a/front/src/components/ArticlesSection.tsx b/front/src/components/ArticlesSection.tsx deleted file mode 100644 index d337fed..0000000 --- a/front/src/components/ArticlesSection.tsx +++ /dev/null @@ -1,83 +0,0 @@ -import { useEffect, useState } from "react"; -import ArticleCard from "./ArticleCard"; -import { ArticlePreview } from "../types"; - -export default function ArticlesSection() { - - const [articlePreviews, setArticlePreviews] = useState([]); - const [loading, setLoading] = useState(true); - const [error, setError] = useState(null); - - - const articles: ArticlePreview[] = [ - { - id: 1, - title: "The Great Barrier Reef", - preview: "The Great Barrier Reef is the largest coral reef system in the world, composed of over 2,900 individual reefs and 900 islands stretching for over 2,300 kilometers (1,400 mi) over an area of approximately 344,400 square kilometers (133,000 sq mi).", - }, - { - id: 2, - title: "The Great Pacific Garbage Patch", - preview: "The Great Pacific Garbage Patch, also known as the Pacific trash vortex, is a gyre of marine debris particles in the north-central Pacific Ocean. It is located roughly from 135°W to 155°W and 35°N to 42°N.", - }, - { - id: 3, - title: "The Amazon Rainforest", - preview: "The Amazon rainforest, alternatively, the Amazon Jungle, also known in English as Amazonia, is a moist broadleaf tropical rainforest in the Amazon biome that covers most of the Amazon basin of South America.", - }, - { - id: 4, - title: "The Arctic", - preview: "The Arctic is a polar region located at the northernmost part of Earth. The Arctic consists of the Arctic Ocean, adjacent seas, and parts of Alaska (United States), Northern Canada (Canada), Finland, Greenland (Kingdom of Denmark), Iceland, Norway, Russia, and Sweden.", - }, - { - id: 5, - title: "The Antarctic", - preview: "The Antarctic, is a polar region containing the geographic South Pole and is situated in the Antarctic region of the Southern Hemisphere, almost entirely south of the Antarctic Circle, and is surrounded by the Southern Ocean.", - - } - ]; - - - useEffect(() => { - fetch('/api/articles') - // .then(response => response.json()) - .then(_ => articles) - .then((data: ArticlePreview[]) => setArticlePreviews(data)) - .catch(_ => setError('Failed to fetch articles')) - .finally(() => setLoading(false)); - }, []); - - return ( -
-

Articles

-
- - {articlePreviews.map(articlePreview => ( - - ))} -
- {!loading && !error && articlePreviews.length === 0 &&

No articles found

} - {loading &&

Loading...

} - {error &&

{error}

} -
- ) -} diff --git a/front/src/components/Button.tsx b/front/src/components/Button.tsx deleted file mode 100644 index db4b4ad..0000000 --- a/front/src/components/Button.tsx +++ /dev/null @@ -1,36 +0,0 @@ -import { ReactNode } from 'react'; - -interface ButtonProps { - color: 'primary' | 'secondary'; - children: ReactNode; - url?: string; -} - -export default function Button({ color, children, url }: ButtonProps) { - return ( - {children} - ) -} - diff --git a/front/src/components/ButtonLink.tsx b/front/src/components/ButtonLink.tsx deleted file mode 100644 index a8a4757..0000000 --- a/front/src/components/ButtonLink.tsx +++ /dev/null @@ -1,34 +0,0 @@ -interface ButtonLinkProps { - url: string; - color: 'primary' | 'secondary'; - text: string; -} - -export default function Button({ url, color, text }: ButtonLinkProps) { - return ( - {text} - ) -} - diff --git a/front/src/components/ClickableLink.tsx b/front/src/components/ClickableLink.tsx deleted file mode 100644 index ee9f54c..0000000 --- a/front/src/components/ClickableLink.tsx +++ /dev/null @@ -1,31 +0,0 @@ -interface ClickableLinkProps { - url:string; - text:string; -} - -export default function ClickableLink({url, text}: ClickableLinkProps) { - return (
- -
) -} \ No newline at end of file diff --git a/front/src/components/Footer.tsx b/front/src/components/Footer.tsx deleted file mode 100644 index f4b2bee..0000000 --- a/front/src/components/Footer.tsx +++ /dev/null @@ -1,21 +0,0 @@ -import LogoButton from "./LogoButton" - -interface FooterProps { - bgcolor:string -} - -export default function Footer ({bgcolor}:FooterProps) { - return ( -
-

ENSIBS

RedCRAB

-

Made with ❤️ by RedCRAB

-
- -
-
- ) -} \ No newline at end of file diff --git a/front/src/components/FstSection.tsx b/front/src/components/FstSection.tsx deleted file mode 100644 index 7cf827b..0000000 --- a/front/src/components/FstSection.tsx +++ /dev/null @@ -1,87 +0,0 @@ - -import NavBar from "./NavBar"; -import { Link } from "react-router"; - -export default function FstSection () { - return ( -
- -
-
-

Help us to save our oceans


-
- {/*
-
- ) -} \ No newline at end of file diff --git a/front/src/components/LogoButton.tsx b/front/src/components/LogoButton.tsx deleted file mode 100644 index bc41d3c..0000000 --- a/front/src/components/LogoButton.tsx +++ /dev/null @@ -1,13 +0,0 @@ -import * as React from 'react'; - -interface LogoButtonProps { - url:string; - logo:string; - style?: React.CSSProperties; -} - -export default function LogoButton ({url, logo, style}: LogoButtonProps) { - return ( - - ) -} \ No newline at end of file diff --git a/front/src/components/NavBar.tsx b/front/src/components/NavBar.tsx deleted file mode 100644 index d6f6c87..0000000 --- a/front/src/components/NavBar.tsx +++ /dev/null @@ -1,20 +0,0 @@ -import { Link } from 'react-router'; -import RoundButton from './RoundButton.tsx'; - -export default function NavBar(){ - return ( - ); -} \ No newline at end of file diff --git a/front/src/components/RoundButton.tsx b/front/src/components/RoundButton.tsx deleted file mode 100644 index 6f08e45..0000000 --- a/front/src/components/RoundButton.tsx +++ /dev/null @@ -1,35 +0,0 @@ -interface RoundButtonProps { - url:string; - bgcolor:string; - text:string; -} - -export default function RoundButton({url, bgcolor, text}: RoundButtonProps) { - return (
- -
) -} \ No newline at end of file diff --git a/front/src/components/chaos/MonInput.tsx b/front/src/components/chaos/MonInput.tsx deleted file mode 100644 index ae96388..0000000 --- a/front/src/components/chaos/MonInput.tsx +++ /dev/null @@ -1,16 +0,0 @@ -//import { useState } from "react"; - -interface MonInputProps { - text: string; - new_focus: () => void; - police: string; -} - -export default function MonInput({text, new_focus, police}: MonInputProps) { - - return ( -
- -
- ) -} \ No newline at end of file diff --git a/front/src/components/chaos/monButton.tsx b/front/src/components/chaos/monButton.tsx deleted file mode 100644 index e06033f..0000000 --- a/front/src/components/chaos/monButton.tsx +++ /dev/null @@ -1,26 +0,0 @@ - -interface MonButtonProps { - letter: string; - changetext: (arg0: string) => void; - sizeFrontw: number; - sizeFronth: number; - rdmFront: () => void; - color: string; -} - - -export default function MonButton({letter,changetext,sizeFrontw,sizeFronth,rdmFront,color}: MonButtonProps) { - - - - function clicked() {rdmFront(); - changetext(letter)} - - - - return ( -
- -
- ) -} \ No newline at end of file diff --git a/front/src/components/chaos/style.css b/front/src/components/chaos/style.css deleted file mode 100644 index f0fbe2d..0000000 --- a/front/src/components/chaos/style.css +++ /dev/null @@ -1,12 +0,0 @@ - -#keys { - display: grid; - grid-template-columns: auto auto 1fr; - - -} - -.key { - font-size: 10px; - border: solid black; -} \ No newline at end of file diff --git a/front/src/index.css b/front/src/index.css deleted file mode 100644 index 328146f..0000000 --- a/front/src/index.css +++ /dev/null @@ -1,19 +0,0 @@ -/* Define theme colors */ -:root { - --color-verydarkblue: #00204a; - --color-darkblue: #005792; - --color-lightblue: #00bbf0; - --color-yellow: #fdb44b; - --color-white: #ffffff; - --color-black: #000000; - --color-gray: #f5f5f5; - --color-red: #ff0000; -} - -body { - margin: 0; -} - -footer { - text-align: center; -} \ No newline at end of file diff --git a/front/src/main.tsx b/front/src/main.tsx index a9d0f99..ce00332 100644 --- a/front/src/main.tsx +++ b/front/src/main.tsx @@ -2,23 +2,13 @@ import { BrowserRouter, Route, Routes } from "react-router"; import { createRoot } from 'react-dom/client' import MainPage from "./pages/MainPage.tsx"; import GamePage from "./pages/GamePage.tsx"; -import ChaosPage from "./pages/ChaosPage.tsx"; -import ArticlePage from "./pages/ArticlePage.tsx"; -import './index.css' createRoot(document.getElementById('root')!).render( - // Main page } /> - // Game page } /> - } /> - // Article page (dynamic route) - } /> - // Not found - Not Found
} /> - + , ) diff --git a/front/src/pages/ArticlePage.tsx b/front/src/pages/ArticlePage.tsx deleted file mode 100644 index 3ab05f8..0000000 --- a/front/src/pages/ArticlePage.tsx +++ /dev/null @@ -1,78 +0,0 @@ -import React, { useEffect, useState } from 'react'; -import { useParams } from 'react-router-dom'; -import NavBar from '../components/NavBar'; -import Footer from '../components/Footer'; - -interface Article { - id: string; - title: string; - content: string; - author: string; - publishedAt: string; - editedAt: string; -} - -const ArticlePage: React.FC = () => { - const { id } = useParams<{ id: string }>(); - const [article, setArticle] = useState
(null); - const [loading, setLoading] = useState(true); - const [error, setError] = useState(null); - - useEffect(() => { - fetch(`/api/article/${id}`) - .then(response => response.json()) - .then(data => setArticle(data)) - .catch(_ => setError('Failed to fetch article')) - .finally(() => setLoading(false)); - }, [id]); - - if (loading) { - return
Loading...
; - } - - if (error) { - return
{error}
; - } - - if (!article) { - return
Article not found
; - } - - return ( -
- -
- Article preview -
-

{article.title}

-

écrit par {article.author} le {new Date(article.publishedAt).toLocaleDateString()} (Dernière modification le : {new Date(article.editedAt || article.publishedAt).toLocaleDateString()})

-
-

{article.content}

-
-
-
-
- ); -}; - -export default ArticlePage; \ No newline at end of file diff --git a/front/src/pages/ChaosPage.tsx b/front/src/pages/ChaosPage.tsx deleted file mode 100644 index 9efc84b..0000000 --- a/front/src/pages/ChaosPage.tsx +++ /dev/null @@ -1,86 +0,0 @@ -import MonButton from "../components/chaos/monButton"; -import MonInput from "../components/chaos/MonInput"; -import "../components/chaos/style.css" -import { useState } from "react"; - - -export default function ChaosPage(){ - - const [array_letter,setArray_letter]=useState(["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"," ","!"]); - - const [sizeFrontw,setSizeFrontw] = useState(16) - const [sizeFronth,setSizeFronth] = useState(20) - const [color,setColor] = useState("#ffffff") - - function randomFront(){setSizeFronth(Math.floor(Math.random() * (1000))); - setSizeFrontw(Math.floor(Math.random() * (1000))); - setColor(`#${Math.floor(Math.random() * 16777215).toString(16)}`)} - - function shuffleArray(arr: string[]) { - for (let i = arr.length - 1; i > 0; i--) { - const j = Math.floor(Math.random() * (i + 1)); // Choisir un index aléatoire - [arr[i], arr[j]] = [arr[j], arr[i]]; // Échanger les éléments - } - return arr; - } - - - // console.log(shuffledArray); // Affiche un tableau mélangé - - - const [entry1,setEntry1] = useState("") - function E1(ent:string) { - setEntry1(entry1+ent); - } - const [connarddefocus,setFocus] = useState(()=>E1) - - const [entry2,setEntry2] = useState("") - function E2(ent:string) { - setEntry2(entry2+ent); - } - - function changeFocus(E: (ent:string)=>void) { - setArray_letter(shuffleArray(array_letter)); - setFocus(()=>E); - } - - const [entry3,setEntry3] = useState("") - function E3(ent:string) { - setEntry3(entry3+ent); - } - - const [tel,setTel] = useState(0) - - - return( -
-

Chaos Page

-

Quel est votre nom ?

- changeFocus(E1)} police={""}/> -

Quel adjectif désigne le mieux Xi Junpin ?

- changeFocus(E2)} police={""}/> -

Combien font 1+1 ?

- changeFocus(E3)} police={"Wingdings"}/> -
- {array_letter.map((letter) => {return })} -
-
- Formulaire super mega bien - - - - - - - setTel(parseInt(e.target.value))}/> - -
-
- ) -} \ No newline at end of file diff --git a/front/src/pages/GamePage.tsx b/front/src/pages/GamePage.tsx index 4ebcb50..69552df 100644 --- a/front/src/pages/GamePage.tsx +++ b/front/src/pages/GamePage.tsx @@ -1,7 +1,9 @@ import { Canvas } from "@react-three/fiber"; import { OrbitControls, PerspectiveCamera, Sky } from "@react-three/drei"; -import { useEffect, useState } from "react"; +import * as THREE from "three"; +import React, { useEffect, useRef, useState } from "react"; import Ocean from "../components/3d/Ocean"; +import Axes from "../components/3d/Axes"; import Character from "../components/3d/Character"; import Floor from "../components/3d/Floor"; import Marker from "../components/3d/Marker"; @@ -137,7 +139,7 @@ export default function GamePage() { - {/* */} + {/* */} diff --git a/front/src/pages/MainPage.tsx b/front/src/pages/MainPage.tsx index 78b1c56..248feb2 100644 --- a/front/src/pages/MainPage.tsx +++ b/front/src/pages/MainPage.tsx @@ -1,15 +1,10 @@ -import ArticlesSection from '../components/ArticlesSection.tsx' -import Footer from '../components/Footer.tsx' -import FstSection from '../components/FstSection.tsx' + + export default function MainPage() { return ( - <> -
- - -