|
4 | 4 | use BookStack\Exceptions\NotFoundException; |
5 | 5 | use BookStack\Repos\UserRepo; |
6 | 6 | use BookStack\Services\ExportService; |
| 7 | +use Carbon\Carbon; |
7 | 8 | use Illuminate\Http\Request; |
8 | 9 | use BookStack\Http\Requests; |
9 | 10 | use BookStack\Repos\BookRepo; |
@@ -88,14 +89,19 @@ public function store(Request $request, $bookSlug, $pageId) |
88 | 89 |
|
89 | 90 | $input = $request->all(); |
90 | 91 | $book = $this->bookRepo->getBySlug($bookSlug); |
91 | | - $input['priority'] = $this->bookRepo->getNewPriority($book); |
92 | 92 |
|
93 | 93 | $draftPage = $this->pageRepo->getById($pageId, true); |
94 | 94 |
|
95 | 95 | $chapterId = $draftPage->chapter_id; |
96 | 96 | $parent = $chapterId !== 0 ? $this->chapterRepo->getById($chapterId) : $book; |
97 | 97 | $this->checkOwnablePermission('page-create', $parent); |
98 | 98 |
|
| 99 | + if ($parent->isA('chapter')) { |
| 100 | + $input['priority'] = $this->chapterRepo->getNewPriority($parent); |
| 101 | + } else { |
| 102 | + $input['priority'] = $this->bookRepo->getNewPriority($parent); |
| 103 | + } |
| 104 | + |
99 | 105 | $page = $this->pageRepo->publishDraft($draftPage, $input); |
100 | 106 |
|
101 | 107 | Activity::add($page, 'page_create', $book->id); |
@@ -164,6 +170,7 @@ public function edit($bookSlug, $pageSlug) |
164 | 170 | $draft = $this->pageRepo->getUserPageDraft($page, $this->currentUser->id); |
165 | 171 | $page->name = $draft->name; |
166 | 172 | $page->html = $draft->html; |
| 173 | + $page->markdown = $draft->markdown; |
167 | 174 | $page->isDraft = true; |
168 | 175 | $warnings [] = $this->pageRepo->getUserPageDraftMessage($draft); |
169 | 176 | } |
@@ -204,12 +211,18 @@ public function saveDraft(Request $request, $pageId) |
204 | 211 | $page = $this->pageRepo->getById($pageId, true); |
205 | 212 | $this->checkOwnablePermission('page-update', $page); |
206 | 213 | if ($page->draft) { |
207 | | - $draft = $this->pageRepo->updateDraftPage($page, $request->only(['name', 'html'])); |
| 214 | + $draft = $this->pageRepo->updateDraftPage($page, $request->only(['name', 'html', 'markdown'])); |
208 | 215 | } else { |
209 | | - $draft = $this->pageRepo->saveUpdateDraft($page, $request->only(['name', 'html'])); |
| 216 | + $draft = $this->pageRepo->saveUpdateDraft($page, $request->only(['name', 'html', 'markdown'])); |
210 | 217 | } |
211 | | - $updateTime = $draft->updated_at->format('H:i'); |
212 | | - return response()->json(['status' => 'success', 'message' => 'Draft saved at ' . $updateTime]); |
| 218 | + |
| 219 | + $updateTime = $draft->updated_at->timestamp; |
| 220 | + $utcUpdateTimestamp = $updateTime + Carbon::createFromTimestamp(0)->offset; |
| 221 | + return response()->json([ |
| 222 | + 'status' => 'success', |
| 223 | + 'message' => 'Draft saved at ', |
| 224 | + 'timestamp' => $utcUpdateTimestamp |
| 225 | + ]); |
213 | 226 | } |
214 | 227 |
|
215 | 228 | /** |
|
0 commit comments