1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of Gitamin. |
5
|
|
|
* |
6
|
|
|
* Copyright (C) 2015-2016 The Gitamin Team |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace Gitamin\Http\Routes; |
13
|
|
|
|
14
|
|
|
use Illuminate\Contracts\Routing\Registrar; |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* This is the projects routes class. |
18
|
|
|
*/ |
19
|
|
|
class ProjectsRoutes |
20
|
|
|
{ |
21
|
|
|
/** |
22
|
|
|
* Define the projects routes. |
23
|
|
|
* |
24
|
|
|
* @param \Illuminate\Contracts\Routing\Registrar $router |
25
|
|
|
*/ |
26
|
|
|
public function map(Registrar $router) |
27
|
|
|
{ |
28
|
|
|
// Project Area |
29
|
|
|
$router->group([ |
30
|
|
|
'middleware' => ['app.hasSetting'], |
31
|
|
|
'setting' => 'app_name', |
32
|
|
|
'prefix' => 'projects', |
33
|
|
|
'as' => 'projects.', |
34
|
|
View Code Duplication |
], function ($router) { |
|
|
|
|
35
|
|
|
$router->get('/', [ |
36
|
|
|
'as' => 'index', |
37
|
|
|
'uses' => 'ProjectsController@indexAction', |
38
|
|
|
]); |
39
|
|
|
$router->get('new', [ |
40
|
|
|
'as' => 'new', |
41
|
|
|
'uses' => 'ProjectsController@newAction', |
42
|
|
|
]); |
43
|
|
|
$router->post('create', [ |
44
|
|
|
'as' => 'create', |
45
|
|
|
'uses' => 'ProjectsController@createAction', |
46
|
|
|
]); |
47
|
|
|
}); |
48
|
|
|
|
49
|
|
|
// Project Sub-routes |
50
|
|
|
$router->group([ |
51
|
|
|
'middleware' => ['app.hasSetting'], |
52
|
|
|
'setting' => 'app_name', |
53
|
|
|
'as' => 'projects.', |
54
|
|
|
], function ($router) { |
55
|
|
|
$router->get('{owner_path}/{project_path}', [ |
56
|
|
|
'as' => 'project_show', |
57
|
|
|
'uses' => 'ProjectsController@showAction', |
58
|
|
|
])->where('owner_path', '[a-zA-z.0-9_\-]+')->where('project_path', '[a-zA-z.0-9_\-]+'); |
59
|
|
|
|
60
|
|
|
$router->get('{owner_path}/{project_path}/edit', [ |
61
|
|
|
'as' => 'project_edit', |
62
|
|
|
'uses' => 'ProjectsController@editAction', |
63
|
|
|
])->where('owner_path', '[a-zA-z.0-9_\-]+')->where('project_path', '[a-zA-z.0-9_\-]+'); |
64
|
|
|
$router->post('{owner_path}/{project_path}', [ |
65
|
|
|
'as' => 'project_update', |
66
|
|
|
'uses' => 'ProjectsController@updateAction', |
67
|
|
|
])->where('owner_path', '[a-zA-z.0-9_\-]+')->where('project_path', '[a-zA-z.0-9_\-]+'); |
68
|
|
|
|
69
|
|
|
//Issues |
70
|
|
|
$router->get('{owner_path}/{project_path}/issues', [ |
71
|
|
|
'as' => 'issue_index', |
72
|
|
|
'uses' => 'Projects\\IssuesController@indexAction', |
73
|
|
|
])->where('owner_path', '[a-zA-z.0-9_\-]+')->where('project_path', '[a-zA-z.0-9_\-]+'); |
74
|
|
|
//new |
75
|
|
|
$router->get('{owner_path}/{project_path}/issues/new', [ |
76
|
|
|
'as' => 'issue_new', |
77
|
|
|
'uses' => 'Projects\\IssuesController@newAction', |
78
|
|
|
])->where('owner_path', '[a-zA-z.0-9_\-]+')->where('project_path', '[a-zA-z.0-9_\-]+'); |
79
|
|
|
//create |
80
|
|
|
$router->post('{owner_path}/{project_path}/issues', [ |
81
|
|
|
'as' => 'issue_create', |
82
|
|
|
'uses' => 'Projects\\IssuesController@createAction', |
83
|
|
|
])->where('owner_path', '[a-zA-z.0-9_\-]+')->where('project_path', '[a-zA-z.0-9_\-]+'); |
84
|
|
|
//show |
85
|
|
|
$router->get('{owner_path}/{project_path}/issues/{issue}', [ |
86
|
|
|
'as' => 'issue_show', |
87
|
|
|
'uses' => 'Projects\\IssuesController@showAction', |
88
|
|
|
])->where('owner_path', '[a-zA-z.0-9_\-]+')->where('project_path', '[a-zA-z.0-9_\-]+'); |
89
|
|
|
//edit |
90
|
|
|
$router->get('{owner_path}/{project_path}/issues/{issue}/edit', [ |
91
|
|
|
'as' => 'issue_edit', |
92
|
|
|
'uses' => 'Projects\\IssuesController@editAction', |
93
|
|
|
])->where('owner_path', '[a-zA-z.0-9_\-]+')->where('project_path', '[a-zA-z.0-9_\-]+'); |
94
|
|
|
//update |
95
|
|
|
$router->post('{owner_path}/{project_path}/issues/{issue}', [ |
96
|
|
|
'as' => 'issue_update', |
97
|
|
|
'uses' => 'Projects\\IssuesController@updateAction', |
98
|
|
|
])->where('owner_path', '[a-zA-z.0-9_\-]+')->where('project_path', '[a-zA-z.0-9_\-]+'); |
99
|
|
|
|
100
|
|
|
//Pull Requests |
101
|
|
|
$router->get('{owner_path}/{project_path}/pulls', [ |
102
|
|
|
'as' => 'pull_index', |
103
|
|
|
'uses' => 'Projects\\PullRequestsController@indexAction', |
104
|
|
|
])->where('owner_path', '[a-zA-z.0-9_\-]+')->where('project_path', '[a-zA-z.0-9_\-]+'); |
105
|
|
|
|
106
|
|
|
//Wiki |
107
|
|
|
$router->get('{owner_path}/{project_path}/wiki', [ |
108
|
|
|
'as' => 'wiki_index', |
109
|
|
|
'uses' => 'Projects\\WikiController@indexAction', |
110
|
|
|
])->where('owner_path', '[a-zA-z.0-9_\-]+')->where('project_path', '[a-zA-z.0-9_\-]+'); |
111
|
|
|
|
112
|
|
|
//Pulse |
113
|
|
|
$router->get('{owner_path}/{project_path}/pulse', [ |
114
|
|
|
'as' => 'pulse_index', |
115
|
|
|
'uses' => 'Projects\\PulseController@indexAction', |
116
|
|
|
])->where('owner_path', '[a-zA-z.0-9_\-]+')->where('project_path', '[a-zA-z.0-9_\-]+'); |
117
|
|
|
|
118
|
|
|
//Graphs |
119
|
|
|
$router->get('{owner_path}/{project_path}/graphs', [ |
120
|
|
|
'as' => 'graph_index', |
121
|
|
|
'uses' => 'Projects\\GraphsController@indexAction', |
122
|
|
|
])->where('owner_path', '[a-zA-z.0-9_\-]+')->where('project_path', '[a-zA-z.0-9_\-]+'); |
123
|
|
|
|
124
|
|
|
//Comments |
125
|
|
|
//create |
126
|
|
|
$router->post('{owner_path}/{project_path}/comments', [ |
127
|
|
|
'as' => 'comment_create', |
128
|
|
|
'uses' => 'Projects\\CommentsController@createAction', |
129
|
|
|
])->where('owner_path', '[a-zA-z.0-9_\-]+')->where('project_path', '[a-zA-z.0-9_\-]+'); |
130
|
|
|
}); |
131
|
|
|
} |
132
|
|
|
} |
133
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.