... | ... |
@@ -332,7 +332,8 @@ EOS |
332 | 332 |
"default_branch not null default 'master'", |
333 | 333 |
"original_user not null default ''", |
334 | 334 |
"original_pid integer not null default 0", |
335 |
- "private not null default 0" |
|
335 |
+ "private not null default 0", |
|
336 |
+ "encoding not null default ''" |
|
336 | 337 |
]; |
337 | 338 |
for my $column (@$project_columns) { |
338 | 339 |
eval { $dbi->execute("alter table project add column $column") }; |
... | ... |
@@ -1,4 +1,6 @@ |
1 | 1 |
<% |
2 |
+ use Encode (); |
|
3 |
+ |
|
2 | 4 |
# API |
3 | 5 |
my $api = gitprep_api; |
4 | 6 |
my $manager = app->manager; |
... | ... |
@@ -85,7 +87,35 @@ |
85 | 87 |
return; |
86 | 88 |
} |
87 | 89 |
} |
88 |
- |
|
90 |
+ # Encoding |
|
91 |
+ elsif ($op eq 'encoding' && $post) { |
|
92 |
+ my $encoding = param('encoding') || ''; |
|
93 |
+ |
|
94 |
+ my $enc = $encoding ? $encoding : 'UTF-8'; |
|
95 |
+ my $enc_object = Encode::find_encoding($enc); |
|
96 |
+ if ($enc_object) { |
|
97 |
+ eval { |
|
98 |
+ app->dbi->model('project')->update( |
|
99 |
+ {encoding => $encoding}, |
|
100 |
+ id => [$user, $project] |
|
101 |
+ ); |
|
102 |
+ }; |
|
103 |
+ if (my $e = $@) { |
|
104 |
+ app->log->error("/$user/$project/settings?op=encoding: $e"); |
|
105 |
+ $errors = ['Internal Error']; |
|
106 |
+ } |
|
107 |
+ else { |
|
108 |
+ my $message = 'Encoding is saved. Encoding is ' |
|
109 |
+ . ($encoding ? $encoding : 'UTF-8(default)'); |
|
110 |
+ flash(message => $message); |
|
111 |
+ $self->redirect_to('current'); |
|
112 |
+ return; |
|
113 |
+ } |
|
114 |
+ } |
|
115 |
+ else { |
|
116 |
+ $errors = ["$encoding is invalid encoding"]; |
|
117 |
+ } |
|
118 |
+ } |
|
89 | 119 |
# Private repository |
90 | 120 |
elsif ($op eq 'private' && $post) { |
91 | 121 |
my $private = param('private') ? 1 : 0; |
... | ... |
@@ -126,6 +156,8 @@ |
126 | 156 |
return; |
127 | 157 |
} |
128 | 158 |
} |
159 |
+ |
|
160 |
+ my $project_info = app->dbi->model('project')->select(id => [$user, $project])->one; |
|
129 | 161 |
%> |
130 | 162 |
|
131 | 163 |
% layout 'common', title => 'Options'; |
... | ... |
@@ -209,19 +241,29 @@ |
209 | 241 |
</div> |
210 | 242 |
</form> |
211 | 243 |
</div> |
212 |
- <div class="border-gray radius-bottom" style="padding:5px 10px;border-top:none;"> |
|
244 |
+ <div class="border-gray" style="padding:5px 10px;border-top:none;"> |
|
213 | 245 |
<form id="form-default-branch" action="<%= url_for->query(op => 'default-branch') %>" method="post" style="margin-bottom:0px"> |
214 | 246 |
Default Branch |
215 | 247 |
% my $branches = $git->branches($user, $project); |
216 | 248 |
% my $branch_names = [map { $_->{name} } @$branches]; |
217 |
- % my $default_branch = app->manager->default_branch($user, $project); |
|
249 |
+ % my $default_branch = $project_info->{default_branch}; |
|
218 | 250 |
% push @$branch_names, $default_branch unless @$branch_names; |
219 | 251 |
% param('default-branch', $default_branch); |
220 | 252 |
%= select_field 'default-branch' => $branch_names, style => 'margin-top:5px'; |
221 | 253 |
</form> |
222 | 254 |
</div> |
255 |
+ <div class="border-gray" style="padding:5px 10px;border-top:none;"> |
|
256 |
+ <form action="<%= url_for->query(op => 'encoding') %>" method="post" style="margin-bottom:0px"> |
|
257 |
+ Encoding |
|
258 |
+ % my $encoding = $project_info->{encoding}; |
|
259 |
+ % param('encoding', $encoding); |
|
260 |
+ %= text_field 'encoding', style => 'margin-top:5px;width:100px'; |
|
261 |
+ <input type="submit" class="btn" value="Save"> |
|
262 |
+ (Default is UTF-8) |
|
263 |
+ </form> |
|
264 |
+ </div> |
|
223 | 265 |
<div class="border-gray radius-bottom" style="padding:5px 10px;border-top:none;"> |
224 |
- <form id="form-default-branch" action="<%= url_for->query(op => 'private') %>" method="post" style="margin-bottom:0px"> |
|
266 |
+ <form action="<%= url_for->query(op => 'private') %>" method="post" style="margin-bottom:0px"> |
|
225 | 267 |
<span>Make this repository private</span> |
226 | 268 |
% my $private = app->manager->is_private_project($user, $project); |
227 | 269 |
% if ($private) { |