Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simple Read Mode #4

Merged
merged 2 commits into from
Apr 19, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Next Next commit
read mode
  • Loading branch information
ro4 committed Apr 18, 2018
commit fc001ee0cf19ad30e901bf8c4e6510bab9af3e79
28 changes: 28 additions & 0 deletions app/Http/Controllers/DocumentController.php
Original file line number Diff line number Diff line change
Expand Up @@ -343,4 +343,32 @@ public function getPageJSON(Request $request, $id, $page_id)
'updated_at' => $pageItem->updated_at->format('Y-m-d H:i:s'),
];
}

/**
* read mode
*
* @param $id
* @param $page_id
*
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
public function readMode($id, $page_id)
{
/** @var Project $project */
$project = Project::with([
'pages' => function (Relation $query) {
$query->select('id', 'pid', 'title', 'description', 'project_id', 'type', 'status');
}
])->findOrFail($id);

$page = Document::where('project_id', $id)->where('id', $page_id)->firstOrFail();
$type = $page->type == Document::TYPE_DOC ? 'markdown' : 'swagger';

return view('share-show', [
'project' => $project,
'pageItem' => $page,
'type' => $type,
'noheader' => true,
]);
}
}
1 change: 1 addition & 0 deletions resources/lang/en/document.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
'document_differ' => 'Document Differ',
'latest_document' => 'Latest',
'history_document' => 'History Archive',
'read_mode' => 'Read Mode',
'after_modified' => 'After',

'select_template' => 'Choose Template',
Expand Down
1 change: 1 addition & 0 deletions resources/lang/zh/document.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
'document_differ' => '文档差异对比',
'latest_document' => '最新文档',
'history_document' => '历史版本',
'read_mode' => '阅读模式',
'after_modified' => '修改后',

'select_template' => '选择模板',
Expand Down
4 changes: 4 additions & 0 deletions resources/views/components/page-menus.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
<span class="icon-share-alt mr-2"></span>
@lang('common.btn_share')
</a>
<a href="{{ wzRoute('project:doc:read', ['id' => $project->id, 'page_id' => $pageItem->id ]) }}" target="_blank" class="dropdown-item">
<span class="icon-laptop mr-2"></span>
@lang('document.read_mode')
</a>
@if($pageItem->type == \App\Repositories\Document::TYPE_DOC)
<a wz-form-submit href="#" data-form="#form-{{ $pageItem->id }}-export-pdf" class="dropdown-item">
<span class="icon-download-alt mr-2"></span>
Expand Down
3 changes: 3 additions & 0 deletions routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,9 @@
// 文档分享
Route::post('/{id}/doc/{page_id}/share', 'ShareController@create')->name('doc:share');

// 阅读模式
Route::get('/{id}/doc/{page_id}/read', 'DocumentController@readMode')->name('doc:read');

// 文档评论
Route::post('/{id}/doc/{page_id}/comments', 'CommentController@publish')->name('doc:comment');

Expand Down