... | ... |
@@ -1,5 +1,6 @@ |
1 | 1 |
2.3.2 (2016-08-17) |
2 | 2 |
- add tar.gz download button |
3 |
+ - add website URL settings. you can create external link. |
|
3 | 4 |
2.3.1 (2016-08-12) |
4 | 5 |
- prevent XSS attack in issue and pull request message |
5 | 6 |
2.3 (2016-08-06) |
... | ... |
@@ -87,7 +87,8 @@ EOS |
87 | 87 |
"original_project integer not null default 0", |
88 | 88 |
"private integer not null default 0", |
89 | 89 |
"ignore_space_change integer not null default 0", |
90 |
- "guess_encoding integer not null default ''" |
|
90 |
+ "guess_encoding integer not null default ''", |
|
91 |
+ "website_url not null default ''" |
|
91 | 92 |
]; |
92 | 93 |
for my $column (@$project_columns) { |
93 | 94 |
eval { $dbi->execute("alter table project add column $column") }; |
... | ... |
@@ -96,7 +97,7 @@ EOS |
96 | 97 |
# Check project table |
97 | 98 |
eval { |
98 | 99 |
$dbi->select( |
99 |
- [qw/row_id user id default_branch original_project private ignore_space_change guess_encoding/], |
|
100 |
+ [qw/row_id user id default_branch original_project private ignore_space_change guess_encoding website_url/], |
|
100 | 101 |
table => 'project' |
101 | 102 |
); |
102 | 103 |
}; |
... | ... |
@@ -84,12 +84,41 @@ |
84 | 84 |
$errors = ['Internal Error']; |
85 | 85 |
} |
86 | 86 |
else { |
87 |
- flash(message => 'Description is saved.'); |
|
87 |
+ flash(message => 'Description is changed.'); |
|
88 | 88 |
$self->redirect_to('current'); |
89 | 89 |
return; |
90 | 90 |
} |
91 | 91 |
} |
92 | 92 |
} |
93 |
+ |
|
94 |
+ # Change website URL |
|
95 |
+ elsif ($op eq 'change-website-url') { |
|
96 |
+ |
|
97 |
+ # Parameters |
|
98 |
+ my $website_url = param('website-url'); |
|
99 |
+ $website_url = '' unless defined $website_url; |
|
100 |
+ |
|
101 |
+ # Validator |
|
102 |
+ my $vc = app->vc; |
|
103 |
+ |
|
104 |
+ # Validation result |
|
105 |
+ my $validation = $vc->validation; |
|
106 |
+ |
|
107 |
+ if (length $website_url > 300) { |
|
108 |
+ $validation->add_failed('website-url' => 'Website URL is too long'); |
|
109 |
+ } |
|
110 |
+ |
|
111 |
+ if ($validation->is_valid) { |
|
112 |
+ app->dbi->model('project')->update( |
|
113 |
+ {website_url => $website_url}, |
|
114 |
+ where => {user => $user_row_id, id => $project_id} |
|
115 |
+ ); |
|
116 |
+ |
|
117 |
+ flash(message => 'Website URL is changed.'); |
|
118 |
+ $self->redirect_to('current'); |
|
119 |
+ return; |
|
120 |
+ } |
|
121 |
+ } |
|
93 | 122 |
|
94 | 123 |
# Change default branch |
95 | 124 |
elsif ($op eq 'save-settings') { |
... | ... |
@@ -259,6 +288,27 @@ |
259 | 288 |
</form> |
260 | 289 |
</li> |
261 | 290 |
</ul> |
291 |
+ |
|
292 |
+ <ul class="project-settings-main"> |
|
293 |
+ <li> |
|
294 |
+ <h4> |
|
295 |
+ Website URL |
|
296 |
+ </h4> |
|
297 |
+ </li> |
|
298 |
+ <li> |
|
299 |
+ <form action="<%= url_for->query(op => 'change-website-url') %>" method="post"> |
|
300 |
+ <div> |
|
301 |
+ <% |
|
302 |
+ my $website_url = app->dbi->model('project')->select('website_url', where => {user => $user_row_id, id => $project_id})->value; |
|
303 |
+ $website_url = '' unless defined $website_url; |
|
304 |
+ %> |
|
305 |
+ |
|
306 |
+ %= text_field 'website-url' => $website_url, style => "width:90%"; |
|
307 |
+ <input type="submit" class="btn" value="Save"> |
|
308 |
+ </div> |
|
309 |
+ </form> |
|
310 |
+ </li> |
|
311 |
+ </ul> |
|
262 | 312 |
|
263 | 313 |
<form id="form-default-branch" action="<%= url_for %>" method="post"> |
264 | 314 |
%= hidden_field op => 'save-settings'; |
... | ... |
@@ -8,55 +8,60 @@ |
8 | 8 |
my $git = app->git; |
9 | 9 |
|
10 | 10 |
# Parameters |
11 |
- my $user = param('user'); |
|
12 |
- my $project = param('project'); |
|
11 |
+ my $user_id = param('user'); |
|
12 |
+ my $project_id = param('project'); |
|
13 |
+ |
|
14 |
+ my $project_row_id = $api->get_project_row_id($user_id, $project_id); |
|
13 | 15 |
|
14 | 16 |
my $rev; |
15 | 17 |
my $dir; |
16 | 18 |
my $rev_dir = param('rev_dir'); |
17 | 19 |
if (defined $rev_dir) { |
18 |
- ($rev, $dir) = $git->parse_rev_path(app->rep_info($user, $project), $rev_dir); |
|
20 |
+ ($rev, $dir) = $git->parse_rev_path(app->rep_info($user_id, $project_id), $rev_dir); |
|
19 | 21 |
} |
20 | 22 |
else { |
21 |
- $rev = app->manager->default_branch($user, $project); |
|
23 |
+ $rev = app->manager->default_branch($user_id, $project_id); |
|
22 | 24 |
} |
23 | 25 |
|
24 |
- unless (app->manager->exists_project($user, $project)) { |
|
26 |
+ unless (app->manager->exists_project($user_id, $project_id)) { |
|
25 | 27 |
$self->reply->not_found; |
26 | 28 |
return; |
27 | 29 |
} |
28 | 30 |
|
29 | 31 |
# Repository description |
30 |
- my $desc = $git->description(app->rep_info($user, $project)); |
|
32 |
+ my $desc = $git->description(app->rep_info($user_id, $project_id)); |
|
33 |
+ my $website_url = app->dbi->model('project')->select('website_url', where => {row_id => $project_row_id})->value; |
|
31 | 34 |
|
32 | 35 |
# Check exsitence |
33 | 36 |
my $commits_number; |
34 |
- if ($git->exists_branch(app->rep_info($user, $project))) { |
|
37 |
+ if ($git->exists_branch(app->rep_info($user_id, $project_id))) { |
|
35 | 38 |
# Commit |
36 |
- my $commit = $git->get_commit(app->rep_info($user, $project), $rev); |
|
39 |
+ my $commit = $git->get_commit(app->rep_info($user_id, $project_id), $rev); |
|
37 | 40 |
|
38 | 41 |
# Tree |
39 | 42 |
my $trees; |
40 | 43 |
if (defined $dir && length $dir) { |
41 |
- $trees = $git->trees(app->rep_info($user, $project), $rev, $dir); |
|
44 |
+ $trees = $git->trees(app->rep_info($user_id, $project_id), $rev, $dir); |
|
42 | 45 |
} |
43 | 46 |
else { |
44 |
- $trees = $git->trees(app->rep_info($user, $project), $rev); |
|
47 |
+ $trees = $git->trees(app->rep_info($user_id, $project_id), $rev); |
|
45 | 48 |
} |
46 | 49 |
# Commits number |
47 |
- $commits_number = $git->commits_number(app->rep_info($user, $project), $rev); |
|
50 |
+ $commits_number = $git->commits_number(app->rep_info($user_id, $project_id), $rev); |
|
48 | 51 |
|
49 | 52 |
# Variable for included template |
50 | 53 |
stash( |
51 | 54 |
commit => $commit, |
52 | 55 |
trees => $trees, |
53 | 56 |
rev => $rev, |
54 |
- title => "$user/$project", |
|
57 |
+ title => "$user_id/$project_id", |
|
55 | 58 |
); |
56 | 59 |
|
57 | 60 |
$state = 'display'; |
58 | 61 |
} |
59 | 62 |
else { $state = 'init' } |
63 |
+ |
|
64 |
+ my $is_project_top_page = !(defined $dir && length $dir); |
|
60 | 65 |
|
61 | 66 |
my $url = url_for->to_abs; |
62 | 67 |
$url->base(undef); |
... | ... |
@@ -66,16 +71,16 @@ |
66 | 71 |
my $ssh_rep_url_base = defined app->config->{basic}{'ssh_rep_url_base'} |
67 | 72 |
? app->config->{basic}{'ssh_rep_url_base'} : $rep_home; |
68 | 73 |
my $ssh_rep_url = "ssh://$execute_user\@" . $url->host |
69 |
- . ($ssh_port ? ":$ssh_port" : '') . "$ssh_rep_url_base/$user/$project.git"; |
|
74 |
+ . ($ssh_port ? ":$ssh_port" : '') . "$ssh_rep_url_base/$user_id/$project_id.git"; |
|
70 | 75 |
|
71 | 76 |
my $branches = stash('branches'); |
72 |
- my $branches_count = app->git->branches_count($self->app->rep_info($user, $project)); |
|
73 |
- my $default_branch_name = app->manager->default_branch($user, $project); |
|
74 |
- my $tags_count = app->git->tags_count(app->rep_info($user, $project)); |
|
77 |
+ my $branches_count = app->git->branches_count($self->app->rep_info($user_id, $project_id)); |
|
78 |
+ my $default_branch_name = app->manager->default_branch($user_id, $project_id); |
|
79 |
+ my $tags_count = app->git->tags_count(app->rep_info($user_id, $project_id)); |
|
75 | 80 |
|
76 | 81 |
my $logined = $api->logined; |
77 | 82 |
|
78 |
- layout 'common', title => "$user/$project"; |
|
83 |
+ layout 'common', title => "$user_id/$project_id"; |
|
79 | 84 |
%> |
80 | 85 |
|
81 | 86 |
%= include '/include/header'; |
... | ... |
@@ -83,13 +88,16 @@ |
83 | 88 |
<div class="container"> |
84 | 89 |
%= include '/include/message', message => flash('message'); |
85 | 90 |
|
86 |
- % if (!(defined $dir && length $dir)) { |
|
91 |
+ % if ($is_project_top_page) { |
|
87 | 92 |
<h3 style="font-weight:normal;color:#666;margin:20px 0px 20px 0;font-size:16px;line-height:0"> |
88 | 93 |
<%= $desc %> |
94 |
+ % if (defined $website_url && length $website_url) { |
|
95 |
+ <a href="<%= $website_url %>"><%= $website_url %></a> |
|
96 |
+ % } |
|
89 | 97 |
</h3> |
90 | 98 |
% } |
91 | 99 |
% if ($state eq 'display') { |
92 |
- % if (!(defined $dir && length $dir)) { |
|
100 |
+ % if ($is_project_top_page) { |
|
93 | 101 |
%= stylesheet begin |
94 | 102 |
.commits-count { |
95 | 103 |
margin:0; |
... | ... |
@@ -120,7 +128,7 @@ |
120 | 128 |
|
121 | 129 |
<ul class="commits-count"> |
122 | 130 |
<li> |
123 |
- % my $commits_url = "/$user/$project/commits/" . ((defined $rev && length $rev) ? $rev : $default_branch_name); |
|
131 |
+ % my $commits_url = "/$user_id/$project_id/commits/" . ((defined $rev && length $rev) ? $rev : $default_branch_name); |
|
124 | 132 |
<a href="<%= url_for($commits_url) %>"> |
125 | 133 |
<span class="commits-count-number"> |
126 | 134 |
<i class="icon-repeat"></i> |
... | ... |
@@ -132,7 +140,7 @@ |
132 | 140 |
</a> |
133 | 141 |
</li> |
134 | 142 |
<li> |
135 |
- <a href="<%= url_for("/$user/$project/branches") %>"> |
|
143 |
+ <a href="<%= url_for("/$user_id/$project_id/branches") %>"> |
|
136 | 144 |
<span class="commits-count-number"> |
137 | 145 |
<i class="icon-indent-left"></i> |
138 | 146 |
<%= $branches_count %> |
... | ... |
@@ -143,7 +151,7 @@ |
143 | 151 |
</a> |
144 | 152 |
</li> |
145 | 153 |
<li> |
146 |
- <a href="<%= url_for("/$user/$project/tags") %>"> |
|
154 |
+ <a href="<%= url_for("/$user_id/$project_id/tags") %>"> |
|
147 | 155 |
<span class="commits-count-number"> |
148 | 156 |
<i class="icon-tags"></i> |
149 | 157 |
<%= $tags_count %> |
... | ... |
@@ -170,7 +178,7 @@ |
170 | 178 |
|
171 | 179 |
%= include '/include/readme', dir => $dir; |
172 | 180 |
|
173 |
- % } elsif ($state eq 'init' && $api->logined($user)) { |
|
181 |
+ % } elsif ($state eq 'init' && $api->logined($user_id)) { |
|
174 | 182 |
|
175 | 183 |
<h4 class="topic1">SSH</h4> |
176 | 184 |
|
... | ... |
@@ -196,7 +204,7 @@ git push -u origin master</pre> |
196 | 204 |
|
197 | 205 |
<hr> |
198 | 206 |
|
199 |
- % my $http_rep_url = url_for("$user/$project.git")->to_abs; |
|
207 |
+ % my $http_rep_url = url_for("$user_id/$project_id.git")->to_abs; |
|
200 | 208 |
<h4 class="topic1"><%= uc url_for->to_abs->scheme %></h4> |
201 | 209 |
|
202 | 210 |
<div class="text-center" style="margin-bottom:10px"> |
... | ... |
@@ -375,12 +375,12 @@ note 'Profile'; |
375 | 375 |
{ |
376 | 376 |
# Change description(t1) |
377 | 377 |
$t->post_ok("/kimoto1/t1/settings?op=change-description", form => {description => 'あああ'}); |
378 |
- $t->content_like(qr/Description is saved/); |
|
378 |
+ $t->content_like(qr/Description is changed/); |
|
379 | 379 |
$t->content_like(qr/あああ/); |
380 | 380 |
|
381 | 381 |
# Change description(t2) |
382 | 382 |
$t->post_ok("/kimoto1/t2/settings?op=change-description", form => {description => 'いいい'}); |
383 |
- $t->content_like(qr/Description is saved/); |
|
383 |
+ $t->content_like(qr/Description is changed/); |
|
384 | 384 |
$t->content_like(qr/いいい/); |
385 | 385 |
} |
386 | 386 |
|