Skip to content
Newer
Older
100644 296 lines (268 sloc) 6.26 KB
9d0e8df @remy Simple home page - not sure if it'll look like this in the end.
remy authored
1 <?php if ( ! defined('ROOT')) exit('No direct script access allowed');
2 function plural($num) {
3 if ($num != 1)
4 return "s";
5 }
6
7 function getRelativeTime($date) {
8 $time = @strtotime($date);
9 $diff = time() - $time;
10 if ($diff<60)
11 return $diff . " second" . plural($diff) . " ago";
12 $diff = round($diff/60);
13 if ($diff<60)
14 return $diff . " minute" . plural($diff) . " ago";
15 $diff = round($diff/60);
16 if ($diff<24)
17 return $diff . " hour" . plural($diff) . " ago";
18 $diff = round($diff/24);
19 if ($diff<7)
20 return $diff . " day" . plural($diff) . " ago";
21 $diff = round($diff/7);
22 if ($diff<4)
23 return $diff . " week" . plural($diff) . " ago";
24 if (date('Y', $time) != date('Y', time()))
25 return date("j-M Y", $time);
26 return date("j-M", $time);
27 }
28 ?>
29 <!DOCTYPE html>
30 <html lang="en">
31 <head>
32 <meta charset=utf-8 />
33 <title><?php echo $name ?>'s bins</title>
34 <style>
35 /* Font via http://robey.lag.net/2010/06/21/mensch-font.html */
36 @font-face {
37 font-family: 'MenschRegular';
38 src: url('/font/mensch-webfont.eot');
39 src: url('/font/mensch-webfont.eot?#iefix') format('eot'),
40 url('/font/mensch-webfont.woff') format('woff'),
41 url('/font/mensch-webfont.ttf') format('truetype'),
42 url('/font/mensch-webfont.svg#webfont0UwCC656') format('svg');
43 font-weight: normal;
44 font-style: normal;
45 }
46
47 body {
48 font-family: MenschRegular, Menlo, Monaco, consolas, monospace;
49 padding: 0;
50 margin: 0;
51 }
52 .thumb {
53 border: 1px solid #ccc;
54 overflow: hidden;
55 height: 145px;
56 width: 193px;
57 margin: 10px 0;
58 }
59 iframe {
60 -moz-transform: scale(0.8);
61 -o-transform: scale(0.8);
62 -webkit-transform: scale(0.8);
63 transform: scale(0.8);
64 /* IE8+ - must be on one line, unfortunately */
65 -ms-filter: "progid:DXImageTransform.Microsoft.Matrix(M11=0.8, M12=0, M21=0, M22=0.8, SizingMethod='auto expand')";
66
67 /* IE6 and 7 */
68 filter: progid:DXImageTransform.Microsoft.Matrix(
69 M11=0.8,
70 M12=0,
71 M21=0,
72 M22=0.8,
73 SizingMethod='auto expand');
74
75 -webkit-transform-origin: 0 0;
76
77 width: 100%;
78 height: 100%;
79 }
80 #bins {
81 width: 70%;
82 font-size: 13px;
83 padding: 10px 0;
84 position: relative;
85 }
86 #preview {
87 border-left: 1px solid #ccc;
88 position: fixed;
89 top: 0;
90 width: 30%;
91 right: 0;
92 height: 100%;
93 padding-top: 10px;
94 background: #fff;
95 }
96 h2 {
97 margin: 0;
98 font-size: 14px;
99 font-family: "Helvetica Neue", Helvetica, Arial;
100 font-size: 13px;
101 padding: 0 20px;
102 }
103 #bins h2 {
104 margin-bottom: 10px;
105 }
106
107 table {
108 border-collapse: collapse;
109 table-layout: fixed;
110 width: 100%;
111 position: relative;
112 }
113
114 td {
115 margin: 0;
116 padding: 3px 0;
117 }
118
b7d466a @remy styling
remy authored
119 a {
120 text-decoration: none;
121 color: #000;
122 }
123
212a036 @remy styling
remy authored
124 .url {
9d0e8df @remy Simple home page - not sure if it'll look like this in the end.
remy authored
125 text-align: right;
212a036 @remy styling
remy authored
126 width: 25%;
127 padding-left: 20px;
9d0e8df @remy Simple home page - not sure if it'll look like this in the end.
remy authored
128 padding-right: 20px;
212a036 @remy styling
remy authored
129 }
130
131 .url a {
9d0e8df @remy Simple home page - not sure if it'll look like this in the end.
remy authored
132 color: #0097fe;
133 }
134
2829b00 @remy styling
remy authored
135 .url a span {
9d0e8df @remy Simple home page - not sure if it'll look like this in the end.
remy authored
136 color: #000;
137 visibility: hidden;
138 }
139
140 .url span.first {
141 visibility: visible;
142 }
143
026a7ea @remy styling
remy authored
144 .created {
145 width: 25%;
146 }
147
2829b00 @remy styling
remy authored
148 .created a {
9d0e8df @remy Simple home page - not sure if it'll look like this in the end.
remy authored
149 color: #ccc;
150 }
151
212a036 @remy styling
remy authored
152 .title {
9d0e8df @remy Simple home page - not sure if it'll look like this in the end.
remy authored
153 text-overflow: ellipsis;
154 overflow: hidden;
155 white-space: nowrap;
156 }
157
158 tr:hover *,
2c5c9a3 @remy styling
remy authored
159 tr.hover *,
160 tr:hover span,
161 tr.hover span {
9d0e8df @remy Simple home page - not sure if it'll look like this in the end.
remy authored
162 background: #0097fe;
163 color: #fff;
7165d10 @remy fixed some styles and home linking problems
remy authored
164 /*cursor: pointer;*/
9d0e8df @remy Simple home page - not sure if it'll look like this in the end.
remy authored
165 }
166
167 tr[data-type=spacer]:hover * {
168 background: #fff;
169 cursor: default;
170 }
171
172 iframe {
173 border: 0;
174 display: block;
175 margin: 0 auto;
176 width: 90%;
177 }
178
179 #viewing {
180 font-size: 10px;
181 margin-left: 20px;
182 }
183 </style>
184 </head>
185 <body>
186 <div id="bins">
187 <h2>Open</h2>
188 <table>
189 <tbody>
190 <?php
191 $last = null;
53cca06 @remy fixed ordering on home
remy authored
192 arsort($order);
193 foreach ($order as $key => $value) {
194 foreach ($bins[$key] as $bin) {
1e990ec @remy removed home from the link urls
remy authored
195 $url = formatURL($bin['url'], $bin['revision']);
9d0e8df @remy Simple home page - not sure if it'll look like this in the end.
remy authored
196 preg_match('/<title>(.*?)<\/title>/', $bin['html'], $match);
cf8fb96 @remy better content matching
remy authored
197 preg_match('/<body.*?>(.*)/s', $bin['html'], $body);
198 $title = '';
9d0e8df @remy Simple home page - not sure if it'll look like this in the end.
remy authored
199 if (count($body)) {
3cfa6c4 @remy fixed missing title when not striping slashes
remy authored
200 $title = $body[1];
7165d10 @remy fixed some styles and home linking problems
remy authored
201 if (get_magic_quotes_gpc() && $body[1]) {
202 $title = stripslashes($body[1]);
203 }
781fef5 @remy trim inner white space
remy authored
204 $title = trim(preg_replace('/\s+/', ' ', strip_tags($title)));
9d0e8df @remy Simple home page - not sure if it'll look like this in the end.
remy authored
205 }
7165d10 @remy fixed some styles and home linking problems
remy authored
206 if (!$title && $bin['javascript']) {
9d0e8df @remy Simple home page - not sure if it'll look like this in the end.
remy authored
207 $title = preg_replace('/\s+/', ' ', $bin['javascript']);
208 }
209
210 if (!$title && count($match)) {
211 $title = get_magic_quotes_gpc() ? stripslashes($match[1]) : $match[1];
212 }
213
214 $firstTime = $bin['url'] != $last;
215
216 if ($firstTime && $last !== null) : ?>
53cca06 @remy fixed ordering on home
remy authored
217 <tr data-type="spacer"><td colspan=3></td></tr>
9d0e8df @remy Simple home page - not sure if it'll look like this in the end.
remy authored
218 <?php endif ?>
53cca06 @remy fixed ordering on home
remy authored
219 <tr data-url="<?=$url?>">
220 <td class="url"><a href="<?=$url?>edit"><span<?=($firstTime ? ' class="first"' : '') . '>' . $bin['url']?>/</span><?=$bin['revision']?>/</a></td>
221 <td class="created"><a pubdate="<?=$bin['created']?>" href="<?=$url?>edit"><?=getRelativeTime($bin['created'])?></a></td>
222 <td class="title"><a href="<?=$url?>edit"><?=substr($title, 0, 200)?></a></td>
223 </tr>
9d0e8df @remy Simple home page - not sure if it'll look like this in the end.
remy authored
224 <?php
225 $last = $bin['url'];
53cca06 @remy fixed ordering on home
remy authored
226 }
10c48a1 @remy typo
remy authored
227 } ?>
9d0e8df @remy Simple home page - not sure if it'll look like this in the end.
remy authored
228 </tbody>
229 </table>
230 </div>
231 <div id="preview">
232 <h2>Preview</h2>
233 <p id="viewing"></p>
234 <iframe id="iframe" hidden></iframe>
235 </div>
236 <script>
237 function render(url) {
238 iframe.src = url + 'quiet';
239 iframe.removeAttribute('hidden');
7165d10 @remy fixed some styles and home linking problems
remy authored
240 viewing.innerHTML = '<?=$_SERVER['HTTP_HOST']?>' + url;
9d0e8df @remy Simple home page - not sure if it'll look like this in the end.
remy authored
241 }
242
243 function matchNode(el, nodeName) {
244 if (el.nodeName == nodeName) {
245 return el;
246 } else if (el.nodeName == 'BODY') {
247 return false;
248 } else {
249 return matchNode(el.parentNode, nodeName);
250 }
251 }
252
253 function removeHighlight() {
254 var i = trs.length;
255 while (i--) {
256 trs[i].className = '';
257 }
258 }
259
260 function visit() {
261 window.location = this.getAttribute('data-url') + 'edit';
262 }
263
264 var preview = document.getElementById('preview'),
265 iframe = document.getElementById('iframe');
266 bins = document.getElementById('bins'),
267 trs = document.getElementsByTagName('tr'),
268 current = null,
269 viewing = document.getElementById('viewing'),
270 hoverTimer = null;
271
272 // this is some nasty code - just because I couldn't be
273 // bothered to bring jQuery to the party.
274 bins.onmouseover = function (event) {
275 clearTimeout(hoverTimer);
276 event = event || window.event;
277 var url, target = event.target || event.srcElement;
278 if (target = matchNode(event.target, 'TR')) {
279 removeHighlight();
280 if (target.getAttribute('data-type') !== 'spacer') {
281 target.className = 'hover';
2829b00 @remy styling
remy authored
282 // target.onclick = visit;
9d0e8df @remy Simple home page - not sure if it'll look like this in the end.
remy authored
283 url = target.getAttribute('data-url');
284 if (current !== url) {
285 hoverTimer = setTimeout(function () {
286 current = url;
287 render(url);
288 }, 200);
289 }
290 }
291 }
292 };
293 </script>
294 </body>
295 </html>
Something went wrong with that request. Please try again.