Skip to content

Commit

Permalink
fix: some changes
Browse files Browse the repository at this point in the history
responsive design
remove swagger empty page
fix saving filename
  • Loading branch information
Djama1GIT committed Dec 10, 2023
1 parent c7298fe commit da3999f
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 11 deletions.
18 changes: 16 additions & 2 deletions client/src/App.css
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,18 @@ input:disabled, select:disabled, textarea:disabled, .disabled {
#book_name {
height: 2em;
}
body {
margin-bottom: 10em;
}
}
@media (max-width: 800px) {
.step {
width: 10%;
font-size: 12em;
}
body {
margin-bottom: 8em;
}
}
@media (max-width: 600px) {
.step {
Expand All @@ -96,6 +102,9 @@ input:disabled, select:disabled, textarea:disabled, .disabled {
margin-top: 1em;
margin-bottom: -0.4em;
}
body {
margin-bottom: 6em;
}
}
.area-description, .section, .chapter, .area-results {
margin-top: 4em;
Expand Down Expand Up @@ -184,9 +193,11 @@ input:disabled, select:disabled, textarea:disabled, .disabled {
@media (max-width: 1200px) {
.label {
margin-left: 18em;
line-height: unset;
}
.section-label {
margin-left: 15em;
line-height: unset;
}
.description, .result {
margin-top: 24em;
Expand Down Expand Up @@ -233,15 +244,15 @@ input:disabled, select:disabled, textarea:disabled, .disabled {
margin: 0;
margin-left: 12em;
color: #555;
line-height: 0;
line-height: unset;
text-align: left;
}
.section-label {
margin-top: 2em;
margin-bottom: 0;
margin-left: 10em;
color: #555;
line-height: 0;
line-height: unset;
text-align: left;
}
.description, .result {
Expand All @@ -268,6 +279,9 @@ input:disabled, select:disabled, textarea:disabled, .disabled {
.sections, .chapters {
margin-top: 10em;
}
.section, .chapter {
margin-top: 2em;
}
}
@media (max-width: 600px) {
.label {
Expand Down
2 changes: 1 addition & 1 deletion client/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ function App() {
<p className="step">3</p>
<p className="label">Названия глав</p>
{sections.map((section, sectionIndex) => (
<div key={`section-${sectionIndex}`}>
<div key={`section-${sectionIndex}`} class={`section-${sectionIndex}`}>
<p className="section-label">{section.name}</p>
{section.chapters.map(([id, title, chapter], chapterIndex) => (
<>
Expand Down
Binary file added server/books/example_vivid_v3.pdf
Binary file not shown.
5 changes: 4 additions & 1 deletion server/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@

from router import router

app = FastAPI()
app = FastAPI(
docs_url=None,
redoc_url=None,
)
app.add_middleware(
CORSMiddleware,
allow_origins=["*"], # Разрешает все источники
Expand Down
3 changes: 1 addition & 2 deletions server/router.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,9 @@ async def generate_book(

async def assemble_to_pdf(book: BookOfSessionBaseWithExtra, book_repository: BookRepository, session_name: str):
logger.info(f'The saving the book "{book.book}" ({book.id}) in pdf has begun')
Vivid.save_book_to_file(
filename = Vivid.save_book_to_file(
BookOfSessionBaseWithExtra(**book.__dict__)
)
filename = f"/books/book-{book.id}-{book.book}.md"
await book_repository.update_session(
BookOfSessionBase(
**book.__dict__ | {"filename": filename},
Expand Down
6 changes: 1 addition & 5 deletions server/vivid.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@ async def gpt35(ans):
logger.info(f'GPT-3.5 result:\n{result}')
return result


@staticmethod
async def gpt35_andor_gpt4(ans):
ans = ans.replace("\t", "").replace(" ", " ").replace(" ", " ").replace(" ", "")
Expand Down Expand Up @@ -175,6 +174,7 @@ async def generate_chapter(book: BookOfSessionBaseWithExtra, section: str, chapt
chapter_text = ""
async for text in Vivid.chapter_generator(book, section, chapter, chapters):
chapter_text += text
chapter_text = re.sub(r'(^(?!Глава\n).*?\.)\s*(.*)', '', chapter_text.strip()).strip()
chapter_text = re.sub(r'[Кк]онец главы.*', '', chapter_text.strip()).strip()
logger.info(f"Generated chapter: {chapter_text}")

Expand Down Expand Up @@ -202,8 +202,6 @@ async def generate_sections(book: BookOfSessionBaseWithExtra):
logger.info(f"Generated sections: {sections}")
return sections



@staticmethod
async def generate_chapters(book: BookOfSessionBaseWithExtra, section):
chapters = []
Expand Down Expand Up @@ -305,7 +303,6 @@ def save_book_to_file(book):
y_position -= 20
c.setFont("DejaVuSerif", 12)
c.drawString(90, y_position, f"{i + 1}. {ch[1]}")


# страницы с главами и их содержанием
for idx, section in enumerate(book.sections_list):
Expand Down Expand Up @@ -341,4 +338,3 @@ def save_book_to_file(book):
c.save()
logger.info(f"Книга {book.book}({book.id}) сохранена в файл {pdf_file_path}")
return f"/{pdf_file_path}"

0 comments on commit da3999f

Please sign in to comment.