diff --git a/.env b/.env index e2ed7306..bad957ca 100644 --- a/.env +++ b/.env @@ -4,4 +4,5 @@ POSTGRES_DB=findfirst SPRING_PROFILES_ACTIVE=dev SPRING_DATASOURCE_USERNAME=$POSTGRES_USER SPRING_DATASOURCE_PASSWORD=$POSTGRES_PASSWORD -SPRING_DATASOURCE_URL=jdbc:postgresql://localhost:5432/findfirst \ No newline at end of file +SPRING_DATASOURCE_URL=jdbc:postgresql://localhost:5432/findfirst +SCREENSHOT_SERVICE_URL=http://screenshot:8080/ diff --git a/docker-compose.yml b/docker-compose.yml index 46b3d457..9f47ff06 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -13,7 +13,7 @@ services: - SPRING_DATASOURCE_URL=jdbc:postgresql://db:5432/findfirst - SPRING_PROFILES_ACTIVE=dev - SPRING_MAIL_HOST=mail - - SCREENSHOT_SERVICE_URL=http://screenshot:8080/ + - SCREENSHOT_SERVICE_URL=${SCREENSHOT_SERVICE_URL} - FINDFIRST_SCREENSHOT_LOCATION=/app/screenshots volumes: - ./data/screenshots:/app/screenshots diff --git a/docs/README.dev.md b/docs/README.dev.md index c62b6abb..48488934 100644 --- a/docs/README.dev.md +++ b/docs/README.dev.md @@ -46,7 +46,33 @@ host and docker without any problems. - etc. - The project does hot reload well, if the IDE your using supports it with the JDTLS. +- Create another terminal tab +- `cd screenshot` +- `./gradlew bootRun` - Open browser navigate to localhost:3000 - Create a user or use the test account: - Username: jsmith - password: test + +### Partial Host/Docker Compose + +- The application supports running the app in a mixed + environment. For example running everything but + the backend in docker compose: + +```bash +docker compose db frontend mail screenshot +``` + +Then executing: `cd server && ./gradlew bootRun` + +One exception is from the backend in docker compose +communicating with the screenshot service running on +host. + +```bash +export SCREENSHOT_SERVICE_URL=http://172.17.0.1:8080 +docker compose up mail server db frontend +``` + +This will allow the backend to reach localhost where the screenshot service is running. diff --git a/screenshot/app/src/main/java/dev/findfirst/screenshot/controller/ScreenshotController.java b/screenshot/app/src/main/java/dev/findfirst/screenshot/controller/ScreenshotController.java index 222e4f8f..16548a8f 100644 --- a/screenshot/app/src/main/java/dev/findfirst/screenshot/controller/ScreenshotController.java +++ b/screenshot/app/src/main/java/dev/findfirst/screenshot/controller/ScreenshotController.java @@ -44,6 +44,7 @@ public String takeScreenshot(@RequestParam String url) { url = URLDecoder.decode(url, StandardCharsets.UTF_8); String cleanUrl = url.replaceAll("http[s]://", "").replace("/", "_"); + cleanUrl = cleanUrl.replaceAll("[*\"/\\<>:|?]+", ""); Path filePath = Path.of(screenshotSaveLoc, cleanUrl + ".png"); page.screenshot(new Page.ScreenshotOptions().setPath(filePath)); diff --git a/server/src/main/java/dev/findfirst/core/service/SearchService.java b/server/src/main/java/dev/findfirst/core/service/SearchService.java index a4f541c3..bf0e39d5 100644 --- a/server/src/main/java/dev/findfirst/core/service/SearchService.java +++ b/server/src/main/java/dev/findfirst/core/service/SearchService.java @@ -1,14 +1,15 @@ package dev.findfirst.core.service; +import java.util.ArrayList; +import java.util.List; + import dev.findfirst.core.model.Bookmark; import dev.findfirst.core.model.Tag; import dev.findfirst.core.repository.TagRepository; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import java.util.ArrayList; -import java.util.List; - @Service public class SearchService {