Prechádzať zdrojové kódy

Улучшение интерфейса

Вадим Королёв 1 rok pred
rodič
commit
1863a02a9f

+ 3 - 1
src/AutoGostSections/SubSection.php

@@ -25,7 +25,9 @@ class SubSection extends Section {
     }
 
     public function pageBreak($current_page) {
-        $this->pages[] = new SmallFramePage(compact(strval($current_page), $this->name));
+        $this->pages[] = new SmallFramePage([
+            'current_page' => $current_page,
+            'framename' => $this->name]);
     }
 
     protected function beforeOutput() {

+ 12 - 191
src/Controllers/AutoGostController.php

@@ -142,24 +142,13 @@ class AutoGostController {
 
 	// Получение HTML
 	public static function getHtml() {
-		$report 	= ReportModel::getById($_GET['report_id']);
+		$report 	= ReportModel::getById($_POST['report_id']);
 		$subject 	= SubjectModel::getById($report["subject_id"]);
 		$work_type	= WorkTypeModel::getById($report["work_type"]);
 		$teacher	= TeacherModel::getById($subject["teacher_id"]);
 
-		// TODO подсчёт количества страниц
-		$pages_count = -999;
-
 		$document = [];
 		$current_page = 1;
-		AutoGostPage::init(
-			$subject,
-			$teacher,
-			$work_type,
-			$pages_count,
-			$report
-		);
-
 		$current_img = 1; // Номер текущего рисунка
 		$expr_is_raw_html = false; // Выражение - чистый HTML?
 
@@ -192,7 +181,7 @@ class AutoGostController {
 
 				case "@section":
 					// Секция основной части
-					$document[] = new SubSection($current_page, "ЛАБОРАТОРНАЯ РАБОТА №1");
+					$document[] = new SubSection($current_page, $command[1]);
 					$current_page++;
 					break;
 
@@ -206,7 +195,7 @@ class AutoGostController {
 					if (count($command) >= 4) {
 						$imgwidth = "width='".$command[3]."'";
 					} else {
-						$imgwidh = "";
+						$imgwidth = "";
 					}
 					end($document)->addHTML(
 						"<figure>
@@ -228,6 +217,7 @@ class AutoGostController {
 					break;
 
 				case "@/":
+				case "@-":
 					// Разрыв страницы
 					end($document)->pageBreak($current_page);
 					$current_page++;
@@ -239,6 +229,14 @@ class AutoGostController {
 			}
 		}
 
+		AutoGostPage::init(
+			$subject,
+			$teacher,
+			$work_type,
+			$current_page - 1,
+			$report
+		);
+
 		echo "<!DOCTYPE html>";
 		echo "<html>";
 		echo "<head><link rel='stylesheet' href='/css/autogost-report.css'></head>";
@@ -248,182 +246,5 @@ class AutoGostController {
 		}
 		echo "</div></body>";
 		echo "</html>";
-
-		//~ // Полное имя преподавателя
-		//~ $teacher_full = $teacher["surname"]." ".mb_substr($teacher['name'],0,1).'. '.mb_substr($teacher['patronymic'],0,1).'.';
-		//~ $markup = $report['markup'];
-		//~ $lines = explode("\n", $markup);
-
-		//~ // Определение количества страниц
-		//~ $pages_count = 0;
-		//~ foreach ($lines as $l) {
-			//~ if (self::isPageMarker($l)) {
-				//~ $has_pages = true;
-				//~ if (self::isCountablePage($l)) {
-					//~ $pages_count++;
-				//~ }
-			//~ }
-		//~ }
-
-		//~ // Основные переменные
-		//~ $current_line_index = -1;
-		//~ $end_line_index = count($lines) - 1;
-		//~ $output = "";
-
-		//~ // Нумераторы
-		//~ $current_page_number = 1;			// Страницы
-		//~ $current_image_number = 1;			// Изображения
-		//~ $current_table_number = 1;			// Таблицы
-		//~ $current_application_number = 1;	// Приложения
-		//~ $current_table_row = 0;				// Строка текущей таблицы
-
-		//~ // Флаги
-		//~ $is_generating_table = false; // Генерируем ли сейчас таблицу
-
-		//~ // Генерация HTML
-		//~ while ($current_line_index < $end_line_index) {
-			//~ // Ищем маркер страницы. Пропускам всё, что не маркер
-			//~ $current_line_index++;
-			//~ if (!self::isPageMarker($lines[$current_line_index])) {
-				//~ continue;
-			//~ }
-			//~ $current_page_marker = $lines[$current_line_index];
-			//~ $current_line_index++;
-
-			//~ // Генерация контента страницы
-			//~ $page_content = "";
-			//~ if ($is_generating_table == true) {
-				//~ // Если мы генерируем таблицу, а сейчас начинается новая страница, то на предыдущей странице мы уже начинали
-				//~ // генерировать и произошёл разрыв таблицы.
-				//~ $page_content .= "<p class='tt'>Продолжение таблицы {$current_table_number}</p>
-				//~ <table class='t{$current_table_number}'>";
-			//~ }
-			//~ while ($current_line_index < $end_line_index) {
-
-				//~ if (self::isPageMarker($lines[$current_line_index])) {
-					//~ // Эта строка - маркер страницы!
-					//~ // Заканчиваем генерировать эту страницу и переходим к другой
-					//~ $current_line_index--;
-					//~ break;
-				//~ }
-
-				//~ $str = $lines[$current_line_index];
-
-				//~ // Интерпретация строки
-				//~ if ($str == "") {
-					//~ // Пустая строка
-					//~ $line_content = "";
-				
-				//~ } else if ($str == "\\") {
-					//~ // Перенос строки
-					//~ $line_content = '<br/>';
-				//~ } else if ($str[0] == "#") {
-					//~ // Выровененный по центру текст
-					//~ $line_content = "<p class='title'>".trim(substr($str, 1))."</p>";
-
-				//~ } else if ($str[0] == "?") {
-					//~ // Изображение
-					//~ list($image_path, $image_title) = explode(":", substr($str, 1));
-					//~ $picture_title = "Рисунок {$current_image_number} - {$image_title}";
-					//~ $line_content = "<br/><img src='/img/autogost/$image_path' title='$picture_title'><p class='title'>$picture_title</p><br/>";
-
-					//~ $current_image_number++;
-
-				//~ } else if (substr($str, 0, 6) === "@table") {
-					//~ // Начало таблицы
-
-					//~ $table_class = "t" . strval($current_table_number);
-					//~ $parts = explode(":", substr($str, 1));
-					//~ $style = "<style>";
-					//~ for ($i = 1; $i < count($parts); $i++) {
-						//~ list($width, $align) = explode("_", $parts[$i]);
-						//~ $style .= ".{$table_class} td:nth-child({$i}),.{$table_class} th:nth-child({$i}){width:{$width}px;text-align:{$align}}";
-					//~ }
-					//~ $line_content .= "</style><p class='tt'>Таблица $current_table_number - {$parts[0]}</p><table class='$table_class'>";
-
-					//~ $is_generating_table = true;
-
-				//~ } else if ($str[0] === "|") {
-					//~ // Продолжение таблицы
-					//~ // Если это начало таблицы, то используем тэг th, иначе td
-					//~ if ($current_table_row == 0) {
-						//~ $tag_name = "th";
-					//~ } else {
-						//~ $tag_name = "td";
-					//~ }
-
-					//~ $line_content = "<tr>";
-					//~ $parts = explode("|", $str);
-					//~ for ($i = 1; $i < count($parts) - 1; $i++) {
-						//~ $part = trim($parts[$i]);
-						//~ $line_content .= "<{$tag_name}>$part</{$tag_name}>";
-					//~ }
-					//~ $line_content .= "</tr>";
-
-					//~ $current_table_row += 1;
-
-					//~ // Смотрим в будущее и ищем разрыв таблицы или конец всего отчёта
-					//~ if ($current_line_index < $end_line_index - 1) {
-						//~ if (self::isPageMarker($lines[$current_line_index + 1])) {
-							//~ // Таблица разделена на 2 страницы
-							//~ $line_content .= "</table>";
-						//~ }
-					//~ } else {
-						//~ // Это конец отчёта! Нарушение разметки, но так уж и быть, поправим по-тихому
-						//~ $line_content .= "</table>";
-					//~ }
-
-				//~ } else if ($str === "@endtable") {
-					//~ // Конец таблицы
-					//~ $line_content = "</table><br/>";
-					//~ $is_generating_table = false;
-					//~ $current_table_number++;
-					//~ $current_table_row = 0;
-
-				//~ } else {
-					//~ // Обычный текст
-					//~ $line_content = "<p>".$str."</p>";
-				//~ }
-
-				//~ $page_content .= $line_content;
-				//~ $current_line_index++;
-			//~ }
-
-			//~ // Всё то, что нагенерировали засовываем в страницу
-			//~ $page_wrapped = new AutoGostPageView([
-				//~ 'work_code' => $subject['code'].autogost_code,
-				//~ 'teacher_full' => $teacher["surname"]." ".mb_substr($teacher['name'],0,1).'. '.mb_substr($teacher['patronymic'],0,1).'.',
-				//~ 'author_surname' => autogost_surname,
-				//~ 'author_full' => autogost_full,
-				//~ 'subject' => $subject,
-				//~ 'work_type' => $work_type,
-				//~ 'pages_count' => $pages_count,
-				//~ 'author_group' => autogost_group,
-				//~ 'work_number' => $report['work_number'],
-				//~ 'teacher_surname' => $teacher['surname'],
-				//~ 'current_page_number' => $current_page_number,
-				//~ 'current_page_marker' => $current_page_marker,
-				//~ 'page_content' => $page_content
-			//~ ]);
-
-			//~ $output .= $page_wrapped->render();
-
-			//~ if (self::isCountablePage($current_page_marker) != "!-") {
-				//~ $current_page_number++;
-			//~ }
-		//~ }
-
-		//~ // $output возвращаем
-		//~ echo $output;
-	}
-
-	// Возвращает true если строка - это маркер страниц
-	private static function isPageMarker($line) {
-		return preg_match("/^(?:!|!!|!0|!-|!--)$/", $line);
-	}
-
-	// Возвращает true если строка - маркер страницы, которую можно включать в объём всех страниц
-	private static function isCountablePage($line) {	
-		return preg_match("/^(?:!|!!|!0|!-)$/", $line);
 	}
 }

+ 16 - 15
src/Views/AutoGostEditView.php

@@ -18,23 +18,24 @@ class AutoGostEditView extends LayoutView {
 
 	public function content():void { ?>
 
-<div class='card' id="controls">
-	<div id='control-buttons'>
-		<button class='btn' id='switchMarkup'>Разметка</button>
-		<button class='btn' id='switchPreview'>Превью</button>
-		<button class='btn' id="printReport">Печать</button>
-	</div>
-
-	<textarea id="markuparea" autocomplete="off"><?= $this->markup ?></textarea>
-	<div style='display: none;' id="preview"></div>
+<div id='control-sidebar' class='card no-print'>
+	
+	<button class='btn selected' id='switchMarkup'>Разметка</button>
+	<button class='btn' id='switchPreview'>Превью</button>
+	<button class='btn' id="printReport">Печать</button>
+	<button class='btn'>Получить название файла</button>
+	<button class='btn success' id='saveMarkupButton'>Сохранить</button>
+	
 </div>
 
-<div class='card no-print'>
-	<form id='saveForm'>
-		<input id='idInput' type='hidden' name='id' value='<?=$this->report_id?>'>
-		<button id='saveMarkupButton' class='form-control success' style='width:100%'>Сохранить</button>
-	</form>
-	<p>Название файла: <span class='filename'><?= $this->filename ?></span></p>
+<div style='margin-left:200px'>
+	<div class='card' id="controls">
+		<textarea id="markuparea" autocomplete="off"><?= $this->markup ?></textarea>
+		<div style='display: none;' id="preview"></div>
+	</div>
 </div>
+
+<input type='hidden' id='idInput' value='<?= $this->report_id ?>'>
+
 <?php }
 }

+ 1 - 1
src/Views/AutoGostPages/BigFramePage.php

@@ -30,7 +30,7 @@ class BigFramePage extends AutoGostPage {
     <span class="al">Листов</span>
     <span class="pr">Провер.</span>
     <span class="st"><?= static::$teacher_surname ?></span>
-    <span class="cp"><?= $this->current_page_number ?></span>
+    <span class="cp"><?= $this->current_page ?></span>
     <span class="pc"><?= static::$pages_count ?></span>
     <div class='nm'>
         <div><?= $this->framename ?></div>

+ 1 - 0
src/Views/LayoutView.php

@@ -38,6 +38,7 @@ class LayoutView extends View {
 		<title><?= $this->page_title ?> | Карманный сервер</title>
 		<link rel='icon' type='image/png' href='/img/favicon.png'>
 		<link rel="stylesheet" href="/css/pockit.css">
+		<link rel="stylesheet" href="/css/spinner.css">
 		<?php $this->customHead() ?>
 	</head>
 	<body>

+ 8 - 6
wwwroot/css/autogost-report.css

@@ -4,8 +4,10 @@
 	color: #aaaaaa;
 	font-size: 12pt;
 	margin: 0;
-	overflow: scroll;
+	overflow-x: scroll;
+	overflow-y: visible;
 	line-height: 1.5;
+	min-height: 256px;
 }
 
 .page {
@@ -15,7 +17,7 @@
 	color: #252525;
 	margin: 1em auto;
 	border-radius: 10px;
-	border: 2px solid #404040;
+	border: 2px solid #000;
 	box-sizing: border-box;
 	position: relative;
 	overflow: hidden;
@@ -99,17 +101,17 @@
 .page:first-child .nd {left:45mm;bottom:29mm;}
 .page:first-child .pd {left:66mm;bottom:29mm;font-size: 11pt;}
 .page:first-child .dt {left:82mm;bottom:29mm;}
-.page:first-child .rz {left:2.15cm;bottom:23mm;}
+.page:first-child .rz {left:2.15cm;bottom:24mm;}
 .page:first-child .sr {left:4.13cm; bottom:24mm;}
 .page:first-child .lt {left:15.6cm;bottom:24mm;}
 .page:first-child .pl {left:17.1cm;bottom:24mm;}
 .page:first-child .al {left:18.8cm;bottom:24mm;}
 .page:first-child .pr {left:2.15cm;bottom:19mm;}
 .page:first-child .st {left:4.13cm; bottom:19mm;}
-.page:first-child .cp {left:16.71cm;right:2.9cm;bottom:2.1cm;text-align:center;}
+.page:first-child .cp {left:16.71cm;right:2.9cm;bottom:19mm;text-align:center;}
 .page:first-child .pc {left:181mm;right:4mm;bottom:19mm;text-align:center;}
 .page:first-child .gr {left:15.25cm;right:0.6cm;bottom:8mm;text-align:center;font-size:20px;}
-.page:first-child .nc {left:2.15cm;bottom:13mm;}
+.page:first-child .nc {left:2.15cm;bottom:14mm;}
 .page:first-child .ut {left:2.15cm;bottom:0.6cm;}
 
 .page .iz {left:2.15cm;bottom:4mm;}
@@ -119,4 +121,4 @@
 .page .dt {left:8.25cm;bottom:4mm;}
 .page .co {left:9.1cm;bottom:8mm;right:1.5cm;font-size:22px;text-align:center;}
 .page .pl {left:19.55cm;bottom:14mm;}
-.page .cp {left:19.5cm;bottom:0.90cm;right:0.5cm;text-align:center;}
+.page .cp {left:19.5cm;bottom:7mm;right:0.5cm;text-align:center;}

+ 35 - 20
wwwroot/css/pockit.css

@@ -39,7 +39,14 @@ h1 {
 
 nav {
 	background-color: var(--gray-0);
-	border-bottom: 1px solid var(--gray-2);
+}
+
+a {
+	text-decoration: underline;
+}
+
+a:hover {
+	text-decoration: none;
 }
 
 /* Forms */
@@ -90,6 +97,7 @@ nav {
 	display: inline-block;
 	margin: 0.1em;
 	font-size: 14px;
+	cursor: pointer;
 }
 
 .btn:hover {
@@ -97,20 +105,11 @@ nav {
 }
 
 .btn:active,
-.btn:focus {
+.btn:focus,
+.btn.selected {
 	background-color: var(--gray-3);
 }
 
-
-
-a {
-	text-decoration: underline;
-}
-
-a:hover {
-	text-decoration: none;
-}
-
 .text-center {
 	text-align: center;
 }
@@ -161,6 +160,8 @@ a:hover {
 /* Breadcrumbs */
 .breadcrumb {
 	padding: 0 0.5em;
+	position: relative;
+	z-index: 2;
 }
 
 .breadcrumb-item {
@@ -218,12 +219,6 @@ a:hover {
 }
 /* End Cards */
 
-.filename {
-	user-select: all;
-	font-weight: bold;
-	text-decoration: underline;
-}
-
 /* CRUD */
 .crud-item {
 	margin: 1rem auto;
@@ -284,6 +279,26 @@ a:hover {
 	font-size: 1rem;
 }
 
-#control-buttons {
-	margin-bottom: 1em;
+#control-sidebar {
+	margin: 0;
+	padding: 1em;
+	width: 200px;
+	position: fixed;
+	height: 100%;
+	overflow: auto;
+	border-radius: 0;
+	background-color: var(--gray-0);
+	border: none;
+	top: 0px;
+	left: 0px;
+	display: flex;
+	justify-content: end;
+	flex-flow: column;
+	z-index: 1;
+	box-sizing: border-box;
+}
+
+#control-sidebar .btn {
+	width: 100%;
+	margin: 3px;
 }

+ 16 - 0
wwwroot/css/spinner.css

@@ -0,0 +1,16 @@
+/*https://www.w3schools.com/howto/howto_css_loader.asp*/
+
+.loader {
+  border: 16px solid var(--gray-4); /* Light grey */
+  border-top: 16px solid var(--successborder);
+  border-radius: 50%;
+  width: 120px;
+  height: 120px;
+  animation: spin 2s linear infinite;
+  margin: 1em auto;
+}
+
+@keyframes spin {
+  0% { transform: rotate(0deg); }
+  100% { transform: rotate(360deg); }
+}

BIN
wwwroot/img/autogost/bigframe.gif


BIN
wwwroot/img/autogost/smallframe.gif


+ 6 - 2
wwwroot/js/autogostpreview.js

@@ -9,8 +9,7 @@ var saveButton = $('#saveMarkupButton');
 $(document).ready(function() {
 	textAreaAdjust(document.getElementById("markuparea"));
 
-	$("#saveForm").submit(function(e) {
-		e.preventDefault();
+	$("#saveMarkupButton").click(function(e) {
 		saveMarkup();
 	});
 
@@ -55,6 +54,9 @@ $(document).ready(function() {
 	});
 	
 	$("#switchPreview").click(function() {
+		$("#switchMarkup").removeClass('selected');
+		$("#switchPreview").addClass('selected');
+		preview_area.html('<div class="loader"></div>');
 		markup_area.hide();
 		preview_area.show();
 		saveMarkup();
@@ -62,6 +64,8 @@ $(document).ready(function() {
 	});
 
 	$("#switchMarkup").click(function() {
+		$("#switchMarkup").addClass('selected');
+		$("#switchPreview").removeClass('selected');
 		markup_area.show();
 		preview_area.hide();
 		saveMarkup();