{#-
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-#}
{% extends 'forgeshorturl:templates/master.html' %}
{% set can_update = c.user and h.has_access(c.app, 'update') %}
{% block extra_js %}
{{ super() }}
{{ c.update_short_url_lightbox.display(content='''
<div>
<h1>Update Short URL</h1>
<form method="post" action="" id="update-short-url-form">
<input type="hidden" name="update" value="update">
<input type="hidden" name="short_url">
<label class="grid-13">Short name</label>
<div class="grid-13"><input type="text" name="short_url_display" style="width: 250px" disabled="disabled"></div>
<label class="grid-13">Full URL</label>
<div class="grid-13"><input type="text" name="full_url" style="width: 250px"></div>
<label class="grid-13">Description</label>
<div class="grid-13"><textarea name="description" style="width: 250px; height: 100px"></textarea></div>
<div class="grid-13"><input type="checkbox" name="private" id="update-checkbox-private"><label for="update-checkbox-private">Private</label></div>
<div class="grid-13"> </div>
<hr>
<div class="grid-13"><div class="grid-13"> </div>
<input type="submit" value="Save">
<a href="#" class="close">Cancel</a>
</div>
</form>
</div>
''') }}
{% endblock %}
{% block content %}
<table>
<thead>
<tr>
<th>Private</th>
<th>Create user</th>
<th>Short URL</th>
<th>Full URL</th>
<th>Description</th>
<th>Created</th>
<th>Last updated</th>
{% if can_update %}<th></th>{% endif %}
</tr>
</thead>
{% for su in short_urls %}
<tr>
{%if su.private %}
<td><small>yes</small></td>
{% else %}
<td><small>no</small></td>
{% endif %}
<td><small>{{ su.user.username }}</small></td>
<td><small><a href="{{ c.app.url+su.short_name }}">{{ request.scheme+'://'+request.host+su.url()}}</a></small></td>
<td><small>{{ su.full_url|urlize(20) }}</small></td>
<td><small>{{ su.description }}</small></td>
<td><small>{{ lib.abbr_date(su.created) }}</small></td>
<td><small>{{ lib.abbr_date(su.last_updated) }}</small></td>
{% if can_update %}
<td>
<small>
<a class="update-url" id="update-url-{{su.short_name}}" href="{{c.project.url()}}admin/{{c.app.config.options.mount_point}}/add/">
Update
</a>
<script>
$(function() {
var upform = $('#update-short-url-form');
$('#update-url-{{su.short_name}}').click(function() {
upform.attr('action', this.href);
upform.find('input[name="short_url"]').val('{{ su.short_name }}');
upform.find('input[name="short_url_display"]').val('{{ su.short_name }}');
upform.find('input[name="full_url"]').val('{{ su.full_url }}');
upform.find('textarea[name="description"]').val('{{su.description|replace("\n", "\\n")|replace("\r", "\\r")}}');
if ('{{ su.private }}' == 'True') {
$('#update-checkbox-private').attr('checked', 'checked');
} else {
$('#update-checkbox-private').removeAttr('checked');
}
return false;
});
});
</script>
<br>
<a id="remove-url-{{su.short_name}}" href="{{c.project.url()}}admin/{{c.app.config.options.mount_point}}/remove">
Remove
</a>
<script>
$(function() {
var cval = $.cookie('_session_id');
$('#remove-url-{{su.short_name}}').click(function() {
if (confirm('Remove URL {{su.short_name}}?')) {
var row = $(this).parents('tr');
var data = {_session_id: cval, shorturl: '{{ su.short_name }}'};
$.post(this.href, data, function(data, status, xhr) {
if (data.status == 'ok') row.remove();
});
}
return false;
});
});
</script>
</small>
</td>
{% endif %} {# can_update #}
</tr>
{% endfor %}
</table>
{{ c.page_list.display(limit=limit, count=count, page=pagenum) }}
{% endblock %}