-
Notifications
You must be signed in to change notification settings - Fork 22
Expand file tree
/
Copy pathmyapp.pl
More file actions
executable file
·215 lines (199 loc) · 4.65 KB
/
myapp.pl
File metadata and controls
executable file
·215 lines (199 loc) · 4.65 KB
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
#!/usr/bin/env perl
use Mojolicious::Lite -signatures;
use Mojo::SQLite;
use lib 'lib';
### Bootstrap
# First, set up the database
my $db = Mojo::SQLite->new('sqlite::temp:');
$db->migrations->from_data->migrate;
# Next, load the model
use Yancy::Backend::Sqlite;
my $backend = Yancy::Backend::Sqlite->new($db);
# XXX: read_schema should always happen now...
$backend->schema( $backend->read_schema );
use Yancy::Content;
my $model = Yancy::Content->new(backend => $backend);
#unshift app->plugins->namespaces->@*, 'Yancy::Plugin';
app->plugin( 'Yancy::Plugin::Content' => backend => $backend );
use Yancy::Storage;
my $storage = Yancy::Storage->new( app->home->child('public/storage')->make_path );
# Then, load the editor
plugin 'Yancy::Plugin::Editor', {
model => $model,
storage => $storage,
};
# TODO: 'Mojolicious::Plugin::Yancy' is combination of above things
# Finally, create the web app's routes
plugin AutoReload =>;
get '/' => sub ($c) {
$c->app->log->info('DEBUG');
$c->render(template => 'index');
}, 'index';
get '/multi' => sub ($c) {
$c->app->log->info('DEBUG');
$c->render(template => 'multi-blocks');
}, 'multi-blocks';
get '/artist/:slug' => sub ($c) {
$c->app->log->info('DEBUG');
$c->render(template => 'index');
}, 'artist-page';
get '/fixture/*fixture_path' => { fixture_path => 'index' }, sub ($c) {
$c->render(template => $c->param('fixture_path'));
}, 'fixtures';
app->start;
__DATA__
@@ index.html.ep
% layout 'default';
%= block landing => {}, begin
This is just sitting here because...
<p>This is the default landing page content.</p>
This is just sitting here because...
<h1>This is an H1</h1>
This is just sitting here because...
% end
<p>This is outside the y-block</p>
@@ multi-blocks.html.ep
% layout 'default';
%= block hero => {}, begin
This is the default hero content.
% end
<div style="display: flex">
%= block left => {}, begin
This is the default left content.
% end
%= block right => {}, begin
This is the default right content.
% end
</div>
@@ restrict-editable.html.ep
% layout 'default';
%= block schedule => { editable => 'td' } => begin
<table>
<caption>Gallery Hours</caption>
<thead>
<tr>
<th class="sr-only"></th>
<th aria-label="Sunday">Su</th>
<th aria-label="Monday">Mo</th>
<th aria-label="Tuesday">Tu</th>
<th aria-label="Wednesday">We</th>
<th aria-label="Thursday">Th</th>
<th aria-label="Friday">Fr</th>
<th aria-label="Saturday">Sa</th>
</tr>
</thead>
<tbody>
<tr>
<th class="sr-only">Open</th>
<td>10</td>
<td>-</td>
<td>4</td>
<td>2</td>
<td>4</td>
<td>12</td>
<td>10</td>
</tr>
<tr>
<th class="sr-only">Close</th>
<td>2</td>
<td>-</td>
<td>8</td>
<td>6</td>
<td>9</td>
<td>8</td>
<td>10</td>
</tr>
</tbody>
</table>
% end
@@ layouts/default.html.ep
<!DOCTYPE html>
<html>
<head>
<title><%= title %></title>
<style>
body {
background: #251903;
color: #f9ed91;
font-family: sans-serif;
margin: 0 auto;
}
a:link {
color: #ddd;
}
a:visited {
color: #ccc;
}
a:active, a:hover {
color: #eee;
}
address { white-space: pre-wrap; }
.sr-only {
width: 0;
overflow: hidden;
visibility: hidden;
display: none;
}
.index-top {
display: flex;
flex: 1 0 33%;
align-items: center;
justify-content: center;
}
.index-top > * {
width: 33%;
padding: 0 2em;
}
.index-top .logo-large {
order: 2;
}
.index-top .hours {
order: 3;
margin: 0 auto;
}
.index-top address {
order: 1;
text-align: right;
}
.index-bottom {
display: flex;
flex: 1 0 33%;
align-items: flex-start;
justify-content: center;
}
.index-bottom > * {
max-width: 33%;
padding: 0 1em;
}
.index-bottom h1 {
text-align: center;
}
.index-bottom .art-scroll {
width: 25%;
}
.art-scroll > * {
display: block;
margin: 0 auto;
}
.logo-large {
text-align: center;
}
.logo-large img {
max-width: 100%;
}
.hours td {
text-align: center;
}
.read-more {
text-align: right;
}
</style>
</head>
<body>
<%= content %>
<script src="/iframe/index.js"></script>
<script>
Yancy.allowOrigins = [new RegExp("http://localhost:\\d+"), new RegExp("http://127\\.0\\.0\\.1:\\d+")];
</script>
</body>
</html>