mirror of
https://github.com/golang/go
synced 2024-11-19 03:44:40 -07:00
e83bc56334
These were built inside Google but have been in production for years. Move them into the public tools repository so that they can be more easily maintained. This is step one to moving the entire golang.org deployment process out of Google's internal source repository. Change-Id: I72f875c5020b3f58f1c0cea1d19268e0f991833f Reviewed-on: https://go-review.googlesource.com/14842 Reviewed-by: Chris Broadfoot <cbro@golang.org>
120 lines
2.3 KiB
Go
120 lines
2.3 KiB
Go
// Copyright 2015 The Go Authors. All rights reserved.
|
|
// Use of this source code is governed by the Apache 2.0
|
|
// license that can be found in the LICENSE file.
|
|
|
|
package short
|
|
|
|
const templateHTML = `
|
|
<!doctype HTML>
|
|
<html>
|
|
<head>
|
|
<title>golang.org URL shortener</title>
|
|
<style>
|
|
body {
|
|
background: white;
|
|
}
|
|
input {
|
|
border: 1px solid #ccc;
|
|
}
|
|
input[type=text] {
|
|
width: 400px;
|
|
}
|
|
input, td, th {
|
|
color: #333;
|
|
font-family: Georgia, Times New Roman, serif;
|
|
}
|
|
input, td {
|
|
font-size: 14pt;
|
|
}
|
|
th {
|
|
font-size: 16pt;
|
|
text-align: left;
|
|
padding-top: 10px;
|
|
}
|
|
.autoselect {
|
|
border: none;
|
|
}
|
|
.error {
|
|
color: #900;
|
|
}
|
|
table {
|
|
margin-left: auto;
|
|
margin-right: auto;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
|
|
<table>
|
|
|
|
{{with .Error}}
|
|
<tr>
|
|
<th colspan="3">Error</th>
|
|
</tr>
|
|
<tr>
|
|
<td class="error" colspan="3">{{.}}</td>
|
|
</tr>
|
|
{{end}}
|
|
|
|
<tr>
|
|
<th>Key</th>
|
|
<th>Target</th>
|
|
<th></th>
|
|
</tr>
|
|
|
|
<form method="POST" action="{{.Prefix}}">
|
|
<tr>
|
|
<td><input type="text" name="key"{{with .New}} value="{{.Key}}"{{end}}></td>
|
|
<td><input type="text" name="target"{{with .New}} value="{{.Target}}"{{end}}></td>
|
|
<td><input type="submit" name="do" value="Add">
|
|
</tr>
|
|
</form>
|
|
|
|
{{with .Links}}
|
|
<tr>
|
|
<th>Short Link</th>
|
|
<th> </th>
|
|
<th> </th>
|
|
</tr>
|
|
{{range .}}
|
|
<tr>
|
|
<td><input class="autoselect" type="text" orig="{{$.BaseURL}}/{{.Key}}" value="{{$.BaseURL}}/{{.Key}}"></td>
|
|
<td><input class="autoselect" type="text" orig="{{.Target}}" value="{{.Target}}"></td>
|
|
<td>
|
|
<form method="POST" action="{{$.Prefix}}">
|
|
<input type="hidden" name="key" value="{{.Key}}">
|
|
<input type="submit" name="do" value="Delete" class="delete">
|
|
</form>
|
|
</td>
|
|
</tr>
|
|
{{end}}
|
|
{{end}}
|
|
|
|
</table>
|
|
|
|
</body>
|
|
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
|
|
<script type="text/javascript">window.jQuery || document.write(unescape("%3Cscript src='/doc/jquery.js' type='text/javascript'%3E%3C/script%3E"));</script>
|
|
<script>
|
|
$(document).ready(function() {
|
|
$('.autoselect').each(function() {
|
|
$(this).click(function() {
|
|
$(this).select();
|
|
});
|
|
$(this).change(function() {
|
|
$(this).val($(this).attr('orig'));
|
|
});
|
|
});
|
|
$('.delete').click(function(e) {
|
|
var link = $(this).closest('tr').find('input').first().val();
|
|
var ok = confirm('Delete this link?\n' + link);
|
|
if (!ok) {
|
|
e.preventDefault();
|
|
return false;
|
|
}
|
|
});
|
|
});
|
|
</script>
|
|
</html>
|
|
`
|