diff --git a/README.md b/README.md index da2826d..4b7a32e 100644 --- a/README.md +++ b/README.md @@ -86,12 +86,30 @@ python main.py - Send content to the backend server - Update history and bookmarks -3. Access the API endpoints: +3. Access the web interface: + - Home page: `http://localhost:8523/` + - Search interface: `http://localhost:8523/search` + - Bookmarks page: `http://localhost:8523/bookmarks` + +4. Access the API endpoints: - Search history: `GET /history/search` - Search bookmarks: `GET /bookmarks/search` - Advanced search: `GET /history/search/advanced` - Manage ignored domains: `GET/POST/DELETE /config/ignored-domains` +## Web Interface + +Browser Recall includes a basic web interface for viewing and searching your browsing history and bookmarks: + +- **Home Page**: Displays recent browsing history +- **Search Page**: Provides a form interface for searching history with filters +- **Bookmarks Page**: Shows your browser bookmarks + +The interface is built with: +- Tailwind CSS for styling +- Responsive design for mobile and desktop +- Dark mode for comfortable viewing + ## API Documentation The API documentation is available through FastAPI's interactive interface at `http://localhost:8523/docs`. This provides a complete API reference with: diff --git a/app/main.py b/app/main.py index 21af921..eac0600 100644 --- a/app/main.py +++ b/app/main.py @@ -12,6 +12,9 @@ from bs4 import BeautifulSoup from sqlalchemy import text from sqlalchemy.sql import text from .logging_config import setup_logger +from fastapi.templating import Jinja2Templates +from fastapi.staticfiles import StaticFiles +from fastapi import Request from .database import get_db, HistoryEntry, Bookmark from .scheduler import HistoryScheduler @@ -34,6 +37,9 @@ app.add_middleware( allow_headers=["*"], ) +templates = Jinja2Templates(directory="app/templates") +app.mount("/static", StaticFiles(directory="app/static"), name="static") + @app.on_event("startup") async def startup_event(): logger.info("Starting application") @@ -342,4 +348,34 @@ async def add_ignored_domain(pattern: str): async def remove_ignored_domain(pattern: str): """Remove a domain pattern from ignored list""" config.remove_ignored_domain(pattern) - return {"status": "success", "message": f"Removed pattern: {pattern}"} \ No newline at end of file + return {"status": "success", "message": f"Removed pattern: {pattern}"} + +@app.get("/") +async def home(request: Request, db: Session = Depends(get_db)): + # Get recent history entries + entries = db.query(HistoryEntry)\ + .order_by(HistoryEntry.visit_time.desc())\ + .limit(50)\ + .all() + return templates.TemplateResponse( + "index.html", + {"request": request, "entries": entries} + ) + +@app.get("/search") +async def search_page(request: Request): + return templates.TemplateResponse( + "search.html", + {"request": request} + ) + +@app.get("/bookmarks") +async def bookmarks_page(request: Request, db: Session = Depends(get_db)): + bookmarks = db.query(Bookmark)\ + .order_by(Bookmark.added_time.desc())\ + .limit(50)\ + .all() + return templates.TemplateResponse( + "bookmarks.html", + {"request": request, "bookmarks": bookmarks} + ) \ No newline at end of file diff --git a/app/static/css/main.css b/app/static/css/main.css new file mode 100644 index 0000000..1f82bbc --- /dev/null +++ b/app/static/css/main.css @@ -0,0 +1,34 @@ +/* Custom styles can be added here */ +.active-nav-link { + border-color: #60a5fa; + color: #60a5fa; +} + +/* Add smooth transitions for hover effects */ +.hover\:border-primary { + transition: border-color 0.2s ease-in-out; +} + +/* Custom scrollbar styles */ +::-webkit-scrollbar { + width: 8px; +} + +::-webkit-scrollbar-track { + background: #1f2937; +} + +::-webkit-scrollbar-thumb { + background: #60a5fa; + border-radius: 4px; +} + +::-webkit-scrollbar-thumb:hover { + background: #3b82f6; +} + +/* Dark mode input styles */ +input[type="date"]::-webkit-calendar-picker-indicator { + filter: invert(1); + opacity: 0.5; +} \ No newline at end of file diff --git a/app/templates/base.html b/app/templates/base.html new file mode 100644 index 0000000..a7ee4d2 --- /dev/null +++ b/app/templates/base.html @@ -0,0 +1,64 @@ + + + +
+ + ++ {{ bookmark.domain }} • {{ bookmark.added_time }} + {% if bookmark.folder %} + {{ bookmark.folder }} + {% endif %} +
++ {{ entry.domain }} • {{ entry.visit_time }} +
+