Commit dae0025b authored by Jean Michel Rouly's avatar Jean Michel Rouly
Browse files

Extracted link preview box into a separate html file.

parent 589c13b3
......@@ -50,9 +50,7 @@ def index(request):
# Preview a link.
def view(request, short):
url = get_object_or_404(URL, short__iexact = short)
return render(request, 'view.html', {
'url': url,
},
......@@ -61,10 +59,9 @@ def view(request, short):
# My-Links page.
@login_required
def my_links(request):
links = URL.objects.filter( owner = request.user )
urls = URL.objects.filter( owner = request.user )
return render(request, 'my_links.html', {
'links' : links,
'urls' : urls,
},
)
......
......@@ -49,17 +49,13 @@ body { /* HTML body */
font-style: italic;
}
#mylinks {
.link-box {
width: inherit;
margin: auto;
table-layout: fixed;
/*height: 500px;
border: 1px solid #000000;
overflow-y: auto;*/
}
#mylinks p {
/* border-left: 5px solid #464646; */
.link-box p {
border: 1px dashed #000000;
text-align: left;
padding-bottom: 5px;
......@@ -70,9 +66,8 @@ body { /* HTML body */
white-space: normal;
}
#mylinks p:hover {
.link-box:hover {
background-color: #FDFDB8;
/* border-left: 5px solid #898989; */
}
......
<div class="link-box">
<p>
<strong>Long:</strong> <a href="{{url.target}}">{{url.target}}</a>
<br />
<strong>Short:</strong> <a href="/{{url.short}}">{{url.short}}</a>
<br />
{% if url.owner = request.user %}
<strong>Clicks:</strong> {{url.clicks}}
<br />
<strong>Expires:</strong> {{url.expires}}
<br />
<strong>
<a href="{%url 'delete' url.short%}"
onclick="return confirm('Are you sure you want to delete this link?');">
Delete
</a>
</strong>
{% endif %}
</p>
</div>
......@@ -8,33 +8,12 @@ Go - A URL Shortener
{% block content %}
{% if links %}
<div id="mylinks">
{% for link in links %}
<p>
<strong>Long:</strong> <a href="{{link.target}}">{{link.target}}</a>
<br />
<h3>~My Links~</h3>
<strong>Short:</strong> <a href="/{{link.short}}">{{link.short}}</a>
<br />
<strong>Clicks:</strong> {{link.clicks}}
<br />
<strong>Expires:</strong> {{link.expires}}
<br />
<strong>
<a href="{%url 'delete' link.short%}"
onclick="return confirm('Are you sure you want to delete this link?');">
Delete
</a>
</strong>
</p>
{% endfor %}
</div>
{% else %}
{% for url in urls %}
{% include 'link_box.html' %}
{% empty %}
<p>None found.</p>
{% endif %}
{% endfor %}
{% endblock %}
......@@ -9,30 +9,7 @@ Go - Success
{% block content %}
{% if url %}
<div id="mylinks">
<p>
<strong>Long:</strong> <a href="{{url.target}}">{{url.target}}</a>
<br />
<strong>Short:</strong> <a href="/{{url.short}}">{{url.short}}</a>
<br />
{% if url.owner = request.user %}
<strong>Clicks:</strong> {{url.clicks}}
<br />
<strong>Expires:</strong> {{url.expires}}
<br />
<strong>
<a href="{%url 'delete' url.short%}"
onclick="return confirm('Are you sure you want to delete this link?');">
Delete
</a>
</strong>
{% endif %}
</p>
</div>
{% include 'link_box.html' %}
{% else %}
<p>Nothing here.</p>
{% endif %}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment