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): ...@@ -50,9 +50,7 @@ def index(request):
# Preview a link. # Preview a link.
def view(request, short): def view(request, short):
url = get_object_or_404(URL, short__iexact = short) url = get_object_or_404(URL, short__iexact = short)
return render(request, 'view.html', { return render(request, 'view.html', {
'url': url, 'url': url,
}, },
...@@ -61,10 +59,9 @@ def view(request, short): ...@@ -61,10 +59,9 @@ def view(request, short):
# My-Links page. # My-Links page.
@login_required @login_required
def my_links(request): def my_links(request):
links = URL.objects.filter( owner = request.user ) urls = URL.objects.filter( owner = request.user )
return render(request, 'my_links.html', { return render(request, 'my_links.html', {
'links' : links, 'urls' : urls,
}, },
) )
......
...@@ -49,17 +49,13 @@ body { /* HTML body */ ...@@ -49,17 +49,13 @@ body { /* HTML body */
font-style: italic; font-style: italic;
} }
#mylinks { .link-box {
width: inherit; width: inherit;
margin: auto; margin: auto;
table-layout: fixed; table-layout: fixed;
/*height: 500px;
border: 1px solid #000000;
overflow-y: auto;*/
} }
#mylinks p { .link-box p {
/* border-left: 5px solid #464646; */
border: 1px dashed #000000; border: 1px dashed #000000;
text-align: left; text-align: left;
padding-bottom: 5px; padding-bottom: 5px;
...@@ -70,9 +66,8 @@ body { /* HTML body */ ...@@ -70,9 +66,8 @@ body { /* HTML body */
white-space: normal; white-space: normal;
} }
#mylinks p:hover { .link-box:hover {
background-color: #FDFDB8; 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 ...@@ -8,33 +8,12 @@ Go - A URL Shortener
{% block content %} {% block content %}
{% if links %} <h3>~My Links~</h3>
<div id="mylinks">
{% for link in links %}
<p>
<strong>Long:</strong> <a href="{{link.target}}">{{link.target}}</a>
<br />
<strong>Short:</strong> <a href="/{{link.short}}">{{link.short}}</a> {% for url in urls %}
<br /> {% include 'link_box.html' %}
{% empty %}
<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 %}
<p>None found.</p> <p>None found.</p>
{% endif %} {% endfor %}
{% endblock %} {% endblock %}
...@@ -9,30 +9,7 @@ Go - Success ...@@ -9,30 +9,7 @@ Go - Success
{% block content %} {% block content %}
{% if url %} {% if url %}
<div id="mylinks"> {% include 'link_box.html' %}
<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>
{% else %} {% else %}
<p>Nothing here.</p> <p>Nothing here.</p>
{% endif %} {% 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