Mercurial > public > sg101
changeset 1148:176d1550bf25
Convert weblinks to V3 design.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Thu, 01 Dec 2016 21:02:31 -0600 |
parents | 4879df353104 |
children | 23dd077358ec |
files | sg101/templates/weblinks/add_link.html sg101/templates/weblinks/base.html sg101/templates/weblinks/link.html sg101/templates/weblinks/link_detail.html sg101/templates/weblinks/link_summary.html sg101/templates/weblinks/navigation.html sg101/templates/weblinks/view_links.html weblinks/forms.py weblinks/views.py |
diffstat | 9 files changed, 141 insertions(+), 90 deletions(-) [+] |
line wrap: on
line diff
--- a/sg101/templates/weblinks/add_link.html Thu Dec 01 21:01:27 2016 -0600 +++ b/sg101/templates/weblinks/add_link.html Thu Dec 01 21:02:31 2016 -0600 @@ -4,16 +4,57 @@ <h3>Add Link</h3> {% if add_form %} <form action="." method="post">{% csrf_token %} - <table> - {{ add_form.as_table }} - <tr><td> </td><td><input type="submit" value="Add Link" /> - <a href="{% url 'weblinks-main' %}">Cancel</a> - </td></tr> - </table> + {{ add_form.non_field_errors }} + {{ add_form.category.errors }} + <div class="row"> + <div class="columns"> + <label for="{{ add_form.category.id_for_label }}"> + {{ add_form.category.label }} + {{ add_form.category }} + </label> + </div> + </div> + {{ add_form.title.errors }} + <div class="row"> + <div class="columns"> + <label for="{{ add_form.title.id_for_label }}"> + {{ add_form.title.label }} + {{ add_form.title }} + </label> + </div> + </div> + {{ add_form.url.errors }} + <div class="row"> + <div class="columns"> + <label for="{{ add_form.url.id_for_label }}"> + {{ add_form.url.label }} + {{ add_form.url }} + </label> + </div> + </div> + {{ add_form.description.errors }} + <div class="row"> + <div class="columns"> + <label for="{{ add_form.description.id_for_label }}"> + {{ add_form.description.label }} + {{ add_form.description }} + </label> + </div> + </div> + <div class="row"> + <div class="columns"> + <input type="submit" value="Add Link" class="button" /> + <a href="{% url 'weblinks-main' %}" class="secondary button">Cancel</a> + </div> + </div> </form> - <br /> {% else %} - <p><strong>Thank you for submitting a link!</strong></p> - <p>Your link has been submitted for review to the site staff.</p> + <div class="success callout"> + <h4>Thank you for submitting a link!</h4> + <p> + Your link has been submitted for review to the site staff. + <a href="{% url 'weblinks-add_link' %}">Would you like to add another</a>? + </p> + </div> {% endif %} {% endblock %}
--- a/sg101/templates/weblinks/base.html Thu Dec 01 21:01:27 2016 -0600 +++ b/sg101/templates/weblinks/base.html Thu Dec 01 21:02:31 2016 -0600 @@ -1,11 +1,6 @@ -{% extends 'base.html' %} +{% extends 'v3/base.html' %} {% load static from staticfiles %} {% load weblinks_tags %} -{% block custom_css %} -<link rel="stylesheet" type="text/css" href="{% static "css/weblinks.css" %}" /> -{% block weblinks_css %}{% endblock %} -{% block weblinks_js %}{% endblock %} -{% endblock %} {% block content %} <h2>Web Links</h2> {% include 'weblinks/navigation.html' %}
--- a/sg101/templates/weblinks/link.html Thu Dec 01 21:01:27 2016 -0600 +++ b/sg101/templates/weblinks/link.html Thu Dec 01 21:02:31 2016 -0600 @@ -1,25 +1,20 @@ {% load static from staticfiles %} {% load bio_tags %} -<dt> +<div> <h4><a href="{{ link.url }}">{{ link.title }}</a></h4> -</dt> -<dd> <p>{{ link.description }}</p> <form action="{% url 'weblinks-visit' link.id %}" method="post">{% csrf_token %} -<table class="link-stats"> - <tr> - <th>Added by:</th><td>{% profile_link link.user.username %}</td> - <th>Category:</th><td><a href="{% url 'weblinks-view_links' slug=link.category.slug sort='date' %}">{{ link.category.title }}</a></td> - </tr> - <tr> - <th>Date Added:</th><td>{{ link.date_added|date:"M d, Y" }}</td> - <th>Hits:</th><td>{{ link.hits }}</td> - <td> - <a href="#" class="weblinks-broken" id="link-{{ link.id }}"><img src="{% static "icons/link_break.png" %}" alt="Broken Link" title="Report this link as broken" /></a> - </td> - </tr> - <tr><td><input type="submit" value="Visit Site" /></td></tr> -</table> +<ul> + <li><strong>Added by:</strong> {% profile_link link.user.username %}</li> + <li><strong>Category:</strong> <a href="{% url 'weblinks-view_links' + slug=link.category.slug sort='date' %}">{{ link.category.title }}</a></li> + <li><strong>Date Added:</strong> {{ link.date_added|date:"M d, Y" }}</li> + <li><strong>Hits:</strong> {{ link.hits }}</li> +</ul> +<input type="submit" class="button" value="Visit Link" /> +<a id="link-{{ link.id }}" class="alert button weblinks-broken" href="#"> + Report Broken Link</a> + </form> -<br /> -</dd> +</div> +<hr>
--- a/sg101/templates/weblinks/link_detail.html Thu Dec 01 21:01:27 2016 -0600 +++ b/sg101/templates/weblinks/link_detail.html Thu Dec 01 21:02:31 2016 -0600 @@ -1,12 +1,12 @@ {% extends 'weblinks/base.html' %} {% load static from staticfiles %} {% block title %}Web Links: {{ link.title }}{% endblock %} -{% block weblinks_js %} -<script type="text/javascript" src="{% static "js/weblinks.js" %}"></script> -{% endblock %} {% block weblinks_content %} <h3>Link Details: {{ link.title }}</h3> <dl> {% include 'weblinks/link.html' %} </dl> {% endblock %} +{% block custom_js %} +<script type="text/javascript" src="{% static "js/weblinks.js" %}"></script> +{% endblock %}
--- a/sg101/templates/weblinks/link_summary.html Thu Dec 01 21:01:27 2016 -0600 +++ b/sg101/templates/weblinks/link_summary.html Thu Dec 01 21:02:31 2016 -0600 @@ -1,22 +1,16 @@ {% extends 'weblinks/base.html' %} {% load static from staticfiles %} {% block title %}Web Links: {{ title }}{% endblock %} -{% block weblinks_css %} -<link rel="stylesheet" type="text/css" href="{% static "css/tab-nav.css" %}" /> -<link rel="stylesheet" type="text/css" href="{% static "css/pagination.css" %}" /> -{% endblock %} -{% block weblinks_js %} -<script type="text/javascript" src="{% static "js/weblinks.js" %}"></script> -{% endblock %} {% block weblinks_content %} <h3>{{ title }}</h3> {% if page.object_list %} - {% include 'core/pagination.html' %} - <dl> + {% include 'core/v3/pagination.html' %} {% for link in page.object_list %} {% include 'weblinks/link.html' %} {% endfor %} - </dl> - {% include 'core/pagination.html' %} + {% include 'core/v3/pagination.html' %} {% endif %} {% endblock %} +{% block custom_js %} +<script type="text/javascript" src="{% static "js/weblinks.js" %}"></script> +{% endblock %}
--- a/sg101/templates/weblinks/navigation.html Thu Dec 01 21:01:27 2016 -0600 +++ b/sg101/templates/weblinks/navigation.html Thu Dec 01 21:02:31 2016 -0600 @@ -1,17 +1,28 @@ {% load static from staticfiles %} -<div class="app-logo"> - <img src="{% static "icons/weblinks-logo.jpg" %}" alt="Links Logo" title="Links" /> +<div class="callout"> + <div class="text-center"> + <img src="{% static "icons/weblinks-logo.jpg" %}" alt="Links Logo" + title="Links" /> + </div> + <div class="menu-centered more-top-margin"> + <ul class="vertical medium-horizontal menu size-24"> + <li{% if top_menu == 'categories' %} class="active"{%endif %}> + <a href="{% url 'weblinks-main' %}">Categories</a> + </li> + <li{% if top_menu == 'new' %} class="active"{%endif %}> + <a href="{% url 'weblinks-new_links' %}">New</a> + </li> + <li{% if top_menu == 'popular' %} class="active"{%endif %}> + <a href="{% url 'weblinks-popular_links' %}">Popular</a> + </li> + {% if user.is_authenticated %} + <li{% if top_menu == 'add' %} class="active"{%endif %}> + <a href="{% url 'weblinks-add_link' %}">Add Link</a> + </li> + {% endif %} + <li{% if top_menu == 'random' %} class="active"{%endif %}> + <a href="{% url 'weblinks-random_link' %}">Random</a> + </li> + </ul> + </div> </div> -<ul class="app-menu"> -<li><a href="{% url 'weblinks-main' %}">Categories</a></li> -<li><a href="{% url 'weblinks-new_links' %}">New</a></li> -<li><a href="{% url 'weblinks-popular_links' %}">Popular</a></li> -{% if user.is_authenticated %} -<li><a href="{% url 'weblinks-add_link' %}">Add Link</a></li> -{% endif %} -</ul> -<div class="centered"> - <form action="{% url 'weblinks-random_link' %}" method="post">{% csrf_token %} - <input type="submit" value="Visit a Random Link" /> - </form> -</div>
--- a/sg101/templates/weblinks/view_links.html Thu Dec 01 21:01:27 2016 -0600 +++ b/sg101/templates/weblinks/view_links.html Thu Dec 01 21:02:31 2016 -0600 @@ -1,34 +1,31 @@ {% extends 'weblinks/base.html' %} {% load static from staticfiles %} {% block title %}Web Links: {{ category.title }}{% endblock %} -{% block weblinks_css %} -<link rel="stylesheet" type="text/css" href="{% static "css/tab-nav.css" %}" /> -<link rel="stylesheet" type="text/css" href="{% static "css/pagination.css" %}" /> -{% endblock %} -{% block weblinks_js %} -<script type="text/javascript" src="{% static "js/weblinks.js" %}"></script> -{% endblock %} {% block weblinks_content %} <h3>Category: {{ category.title }}</h3> {% if page.object_list %} -<ul class="tab-nav"> - <li><a href="{% url 'weblinks-view_links' slug=category.slug sort="title" %}" - {% ifequal s "title" %}class="active" {% endifequal %}>Title</a></li> - <li><a href="{% url 'weblinks-view_links' slug=category.slug sort="date" %}" - {% ifequal s "date" %}class="active"{% endifequal %}>Date</a></li> - <li><a href="{% url 'weblinks-view_links' slug=category.slug sort="hits" %}" - {% ifequal s "hits" %}class="active"{% endifequal %}>Hits</a></li> +<ul class="vertical medium-horizontal menu"> + <li {% if s == "title" %}class="active"{% endif %}> + <a href="{% url 'weblinks-view_links' slug=category.slug sort="title" %}">Title</a> + </li> + <li {% if s == "date" %}class="active"{% endif %}> + <a href="{% url 'weblinks-view_links' slug=category.slug sort="date" %}">Date</a> + </li> + <li {% if s == "hits" %}class="active"{% endif %}> + <a href="{% url 'weblinks-view_links' slug=category.slug sort="hits" %}">Hits</a> + </li> </ul> -{% include 'core/pagination.html' %} +{% include 'core/v3/pagination.html' %} -<dl> {% for link in page.object_list %} {% include 'weblinks/link.html' %} {% endfor %} -</dl> -{% include 'core/pagination.html' %} +{% include 'core/v3/pagination.html' %} {% endif %} {% endblock %} +{% block custom_js %} +<script type="text/javascript" src="{% static "js/weblinks.js" %}"></script> +{% endblock %}
--- a/weblinks/forms.py Thu Dec 01 21:01:27 2016 -0600 +++ b/weblinks/forms.py Thu Dec 01 21:02:31 2016 -0600 @@ -20,4 +20,4 @@ class Meta: model = PendingLink - exclude = ('user', 'date_added', 'update_date') + fields = ['category', 'title', 'url', 'description']
--- a/weblinks/views.py Thu Dec 01 21:01:27 2016 -0600 +++ b/weblinks/views.py Thu Dec 01 21:02:31 2016 -0600 @@ -37,6 +37,8 @@ return render(request, 'weblinks/index.html', { 'categories': categories, 'total_links': total_links, + 'top_menu': 'categories', + 'V3_DESIGN': True, }) ####################################################################### @@ -53,6 +55,8 @@ return render(request, 'weblinks/link_summary.html', { 'page': the_page, 'title': 'Newest Links', + 'top_menu': 'new', + 'V3_DESIGN': True, }) ####################################################################### @@ -68,6 +72,8 @@ return render(request, 'weblinks/link_summary.html', { 'page': the_page, 'title': 'Popular Links', + 'top_menu': 'popular', + 'V3_DESIGN': True, }) ####################################################################### @@ -90,13 +96,18 @@ return render(request, 'weblinks/add_link.html', { 'add_form': add_form, + 'top_menu': 'add', + 'V3_DESIGN': True, }) ####################################################################### @login_required def add_thanks(request): - return render(request, 'weblinks/add_link.html') + return render(request, 'weblinks/add_link.html', { + 'V3_DESIGN': True, + 'top_menu': 'add', + }) ####################################################################### @@ -132,6 +143,7 @@ 's' : sort, 'category' : cat, 'page' : the_page, + 'V3_DESIGN': True, }) ####################################################################### @@ -150,14 +162,19 @@ ####################################################################### -@require_POST def random_link(request): - ids = Link.public_objects.values_list('id', flat=True) - if not ids: - raise Http404 - id = random.choice(ids) - random_link = Link.public_objects.get(pk=id) - return _visit_link(request, random_link) + if request.method == 'POST': + ids = Link.public_objects.values_list('id', flat=True) + if not ids: + raise Http404 + the_id = random.choice(ids) + random_link = Link.public_objects.get(pk=the_id) + return _visit_link(request, random_link) + + return render(request, 'weblinks/random_link.html', { + 'top_menu': 'random', + 'V3_DESIGN': True, + }) ####################################################################### @@ -187,4 +204,5 @@ raise Http404 return render(request, 'weblinks/link_detail.html', { 'link': link, + 'V3_DESIGN': True, })