Skip to content

Commit

Permalink
Merge pull request #4 from ro4/master
Browse files Browse the repository at this point in the history
Simple Read Mode
  • Loading branch information
mylxsw committed Apr 19, 2018
2 parents 09a0437 + 15a57be commit fc780f3
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 0 deletions.
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::query()->findOrFail($id);
$policy = new ProjectPolicy();
if (!$policy->view(\Auth::user(), $project)) {
abort(403, '您没有访问该项目的权限');
}

$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

0 comments on commit fc780f3

Please sign in to comment.