-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathapp.psgi
executable file
·277 lines (240 loc) · 8.03 KB
/
app.psgi
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
#!/usr/bin/env perl
use utf8;
use Mojolicious::Lite;
use Path::Tiny;
use Try::Tiny;
#
# plugin
#
plugin 'haml_renderer';
#
# default config
#
app->defaults( %{ plugin Config => { default => {
js_str => q{},
css_str => q{},
jses => [],
csses => [],
}}});
get '/' => sub {
my $self = shift;
$self->render('index');
};
post '/' => sub {
my $self = shift;
my $user = $self->param('HIDDENNAME');
my $filename = $self->param('pause99_add_uri_upload');
my $file = $self->param('pause99_add_uri_httpupload');
my ( $type, $auth ) = split q{ }, $self->req->headers->authorization;
return $self->render(text => 'auth failed', status => 401)
unless
$type eq 'Basic'
&& app->config->{fakepause}{auth}{$user}
&& app->config->{fakepause}{auth}{$user} eq $auth
;
my $module = join(
'/',
'authors',
'id',
substr( uc($user), 0, 1 ),
substr( uc($user), 0, 2 ),
uc($user),
$filename,
);
my $path = path( app->config->{fakepause}{repo} . "/$module" )->touchpath;
$file->move_to($path);
my $uri = $self->url_for("/$module")->to_abs;
app->log->info("uploaded to $uri");
$self->render(text => $uri, status => 200);
};
app->secrets( app->defaults->{secrets} );
app->start;
__DATA__
@@ index.html.haml
- layout 'default';
- title 'README';
%h1 How-To FakePause
%h2 Dist::Zilla::Plugin::UploadToCPAN
%div
%p
!= q{<code>Dist::Zilla</code>를 사용할 경우 <code>dist.ini</code> 파일에}
!= q{<code>UploadToCPAN</code> 플러그인 설정을 추가합니다.}
:plain
<pre>
$ cat dist.ini
name = Your-Awesome-Module
license = Perl_5
copyright_holder = SILEX
copyright_year = 2014
author = 김도형 - Keedi Kim <[email protected]>
[UploadToCPAN]
upload_uri = https://darkpan.silex.kr/pause
pause_cfg_dir = .
pause_cfg_file = .pause.silex
</pre>
%p
!= q{<code>Dist::Zilla::PluginBundle::SILEX</code> 플러그인 번들을 사용할 경우}
!= q{<code>dist.ini</code> 파일에 <code>UploadToCPAN</code> 설정을 추가합니다.}
:plain
<pre>
$ cat dist.ini
name = Your-Awesome-Module
license = Perl_5
copyright_holder = SILEX
copyright_year = 2014
author = 김도형 - Keedi Kim <[email protected]>
[@SILEX]
UploadToCPAN.upload_uri = https://darkpan.silex.kr/pause
UploadToCPAN.pause_cfg_dir = .
UploadToCPAN.pause_cfg_file = .pause.silex
</pre>
%h2 .pause.silex
%div
%p
!= q{<code>.pause.silex</code> 파일 내용은 다음과 같습니다.}
:plain
<pre>
$ cat .pause.silex
user FAKEPAUSEID
password fakepausepw</pre>
</pre>
%p
!= q{<code>pause_cfg_dir</code> 값을 설정하지 않으면 홈디렉터리를 기본으로 설정합니다.}
@@ layouts/default.html.haml
!!! 5
%html
%head
%title= "$project_name - " . title
= include 'layouts/default/meta'
= include 'layouts/default/css'
= include 'layouts/default/js'
%body
= include 'layouts/default/nav'
#content
.container
.row
.col-lg-9
= content
= include 'layouts/default/footer'
= include 'layouts/default/body-js'
= include 'layouts/default/google-analytics'
@@ layouts/default/meta.html.haml
/ META
%meta{:charset => "utf-8"}
%meta{:name => "author", content => "Keedi Kim"}
%meta{:name => "description", content => "#{$project_desc}"}
%meta{:name => "apple-mobile-web-app-capable", content => "yes"}
%meta{:name => "apple-mobile-web-app-status-bar-style", content => "black-translucent"}
@@ layouts/default/css.html.haml
/ CSS
%link{:rel => "stylesheet", :type => "text/css", :href => "//fonts.googleapis.com/css?family=Open+Sans:400italic,600italic,400,600"}
%link{:rel => "stylesheet", :type => "text/css", :href => "//fonts.googleapis.com/earlyaccess/nanumgothic.css"}
%link{:rel => "stylesheet", :type => "text/css", :href => "//fonts.googleapis.com/earlyaccess/nanumgothiccoding.css"}
%link{:rel => "stylesheet", :type => "text/css", :href => "//netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.min.css"}
%link{:rel => "stylesheet", :type => "text/css", :href => "//netdna.bootstrapcdn.com/bootswatch/3.1.1/flatly/bootstrap.min.css"}
- for my $css (@$csses) {
%link{:rel => "stylesheet", :type => "text/css", :href => "#{$css}"}
- }
- if ($css_str) {
:css
#{ $css_str }
- }
@@ layouts/default/js.html.haml
/ Javascript
/ Le HTML5 shim, for IE6-8 support of HTML5 elements
/[if lt IE 9]
%script{ :type => "text/javascript" :src => "//html5shim.googlecode.com/svn/trunk/html5.js" }
@@ layouts/default/footer.html.haml
/ Footer
#footer
.container
%ul.list-unstyled
%li.pull-right
%a{ :href => "#top" } Back to top
.container
%hr/
.span6!= qq{© $copyright. All Rights Reserved.}
.span4.offset1
%span.pull-right
Built by
%a{ :href => "http://bootswatch.com" } Bootswatch
,
%a{ :href => "http://mojolicio.us" } Mojolicious
&
%a{ :href => "http://www.perl.org" } Perl
@@ layouts/default/body-js.html.haml
/ Javascript in body
%script{ :type => "text/javascript" :src => "//ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js" }
%script{ :type => "text/javascript" :src => "//netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js" }
- for my $js (@$jses) {
%script{ :type => "text/javascript" :src => "#{$js}" }
- }
- if ($js_str) {
:javascript
$(function() {
#{ $js_str }
});
- }
@@ layouts/default/google-analytics.html.haml
/ google analytics
- if ($google_analytics) {
:javascript
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
:javascript
try {
var pageTracker = _gat._getTracker("#{ $google_analytics }");
pageTracker._trackPageview();
} catch(err) {}
- }
@@ layouts/error.html.haml
!!! 5
%html
%head
%title= "$project_name - " . title
= include 'layouts/default/meta'
= include 'layouts/default/css'
= include 'layouts/default/js'
%body
= include 'layouts/default/nav'
#content
.container
.row
.span2
= include 'layouts/default/header'
.span10
.widget
= content
= include 'layouts/default/footer'
= include 'layouts/default/body-js'
= include 'layouts/default/google-analytics'
@@ not_found.html.haml
- layout 'error', csses => [ 'error.css' ], jses => [];
- title '404 Not Found';
%h2 404 Not Found
.error-details Sorry, an error has occured, Requested page not found!
@@ layouts/default/nav.html.haml
/ navigation
.navbar.navbar-default.navbar-fixed-top
.container
.navbar-header
%a.navbar-brand{ :href => "/" }= $project_name
%button.navbar-toggle{ type => "button", 'data-toggle' => "collapse", 'data-target' => "#navbar-main" }
%span.icon-bar
%span.icon-bar
%span.icon-bar
#navbar-main.navbar-collapse.collapse
- if ( @{ $nav_links->{left} } ) {
%ul.nav.navbar-nav
- for my $link ( @{ $nav_links->{left} } ) {
%li
%a{ :href => "#{ $link->{url} }" }= $link->{desc}
- }
- }
- if ( @{ $nav_links->{right} } ) {
%ul.nav.navbar-nav.navbar-right
- for my $link ( @{ $nav_links->{right} } ) {
%li
%a{ :href => "#{ $link->{url} }", :target => "_blank" }= $link->{desc}
- }
- }