Skip to content

Commit

Permalink
✨ Add pages in footer & about page
Browse files Browse the repository at this point in the history
  • Loading branch information
pajowu committed Sep 1, 2023
1 parent 75678cc commit 307d0e8
Show file tree
Hide file tree
Showing 23 changed files with 1,207 additions and 92 deletions.
68 changes: 68 additions & 0 deletions backend/openapi-schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,22 @@ components:
- languages
title: ModelConfig
type: object
PageConfig:
properties:
footer_position:
title: Footer Position
type: integer
name:
title: Name
type: string
text:
title: Text
type: string
required:
- name
- text
title: PageConfig
type: object
PublicConfig:
properties:
models:
Expand All @@ -379,6 +395,18 @@ components:
- duration
title: SetDurationRequest
type: object
ShortPageConfig:
properties:
footer_position:
title: Footer Position
type: integer
name:
title: Name
type: string
required:
- name
title: ShortPageConfig
type: object
SpeakerIdentificationTask:
properties:
document_id:
Expand Down Expand Up @@ -993,6 +1021,46 @@ paths:
$ref: '#/components/schemas/HTTPValidationError'
description: Validation Error
summary: Get Document Tasks
/api/v1/page/:
get:
operationId: get_pages_api_v1_page__get
responses:
'200':
content:
application/json:
schema:
additionalProperties:
$ref: '#/components/schemas/ShortPageConfig'
title: Response Get Pages Api V1 Page Get
type: object
description: Successful Response
summary: Get Pages
/api/v1/page/{page_id}:
get:
operationId: get_page_api_v1_page__page_id__get
parameters:
- in: path
name: page_id
required: true
schema:
title: Page Id
type: string
responses:
'200':
content:
application/json:
schema:
$ref: '#/components/schemas/PageConfig'
description: Successful Response
'404':
description: Page not found
'422':
content:
application/json:
schema:
$ref: '#/components/schemas/HTTPValidationError'
description: Validation Error
summary: Get Page
/api/v1/tasks/:
get:
operationId: list_tasks_api_v1_tasks__get
Expand Down
27 changes: 24 additions & 3 deletions backend/transcribee_backend/config.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
from pathlib import Path
from typing import Dict, List
from typing import Dict, List, Optional

from pydantic import BaseSettings, parse_file_as
from pydantic.main import BaseModel
from pydantic import BaseModel, BaseSettings, parse_file_as


class Settings(BaseSettings):
Expand All @@ -15,6 +14,7 @@ class Settings(BaseSettings):
media_url_base = "http://localhost:8000/"

model_config_path: Path = Path("data/models.json")
pages_config_path: Path = Path("data/pages.json")


class ModelConfig(BaseModel):
Expand All @@ -27,10 +27,31 @@ class PublicConfig(BaseModel):
models: Dict[str, ModelConfig]


class ShortPageConfig(BaseModel):
name: str
footer_position: Optional[int]


class PageConfig(ShortPageConfig):
text: str


def get_model_config():
return parse_file_as(Dict[str, ModelConfig], settings.model_config_path)


def get_page_config():
if settings.pages_config_path.exists():
return parse_file_as(Dict[str, PageConfig], settings.pages_config_path)
return {}


def get_short_page_config():
if settings.pages_config_path.exists():
return parse_file_as(Dict[str, ShortPageConfig], settings.pages_config_path)
return {}


def get_public_config():
return PublicConfig(models=get_model_config())

Expand Down
2 changes: 2 additions & 0 deletions backend/transcribee_backend/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from transcribee_backend.helpers.tasks import remove_expired_tokens, timeout_attempts
from transcribee_backend.routers.config import config_router
from transcribee_backend.routers.document import document_router
from transcribee_backend.routers.page import page_router
from transcribee_backend.routers.task import task_router
from transcribee_backend.routers.user import user_router

Expand All @@ -30,6 +31,7 @@
app.include_router(document_router, prefix="/api/v1/documents")
app.include_router(task_router, prefix="/api/v1/tasks")
app.include_router(config_router, prefix="/api/v1/config")
app.include_router(page_router, prefix="/api/v1/page")


@app.get("/")
Expand Down
25 changes: 25 additions & 0 deletions backend/transcribee_backend/routers/page.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
from typing import Dict

from fastapi import APIRouter, HTTPException

from transcribee_backend.config import (
PageConfig,
ShortPageConfig,
get_page_config,
get_short_page_config,
)

page_router = APIRouter()


@page_router.get("/")
def get_pages() -> Dict[str, ShortPageConfig]:
return get_short_page_config()


@page_router.get("/{page_id}", responses={404: {"description": "Page not found"}})
def get_page(page_id: str) -> PageConfig:
pages = get_page_config()
if page_id not in pages:
raise HTTPException(status_code=404)
return pages[page_id]
3 changes: 3 additions & 0 deletions frontend/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,6 @@ node_modules

# typescript
*.tsbuildinfo

public/*
!public/.gitkeep
7 changes: 6 additions & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
"version": "0.1.0",
"scripts": {
"dev": "vite",
"build": "vite build",
"build": "npm-run-all --continue-on-error build:*",
"build:licenses": "node scripts/generate_licenses.mjs public/LICENSES.md",
"build:vite": "vite build",
"preview": "vite preview",
"format": "prettier -w 'src/**/*.(ts|tsx)'",
"check": "npm-run-all --continue-on-error check:*",
Expand All @@ -29,6 +31,7 @@
"devDependencies": {
"@jest/globals": "^29.5.0",
"@tailwindcss/forms": "^0.5.3",
"@tailwindcss/typography": "^0.5.9",
"@types/react": "^18.0.28",
"@types/react-dom": "^18.0.11",
"@types/react-helmet": "^6.1.6",
Expand All @@ -43,6 +46,7 @@
"favicons": "^7.1.3",
"jest": "^29.5.0",
"mime-types": "^2.1.35",
"nlf": "^2.1.1",
"npm-run-all": "^4.1.5",
"openapi-typescript": "^6.2.0",
"postcss": "^8.4.21",
Expand All @@ -69,6 +73,7 @@
"react-icons": "^4.8.0",
"react-intersection-observer": "^9.5.2",
"react-json-tree": "^0.18.0",
"react-markdown": "^8.0.7",
"react-popper": "^2.3.0",
"reconnecting-websocket": "^4.4.0",
"slate": "^0.94.0",
Expand Down
Loading

0 comments on commit 307d0e8

Please sign in to comment.