Permalink
Browse files

move documents to the new ui in browse page and backend

  • Loading branch information...
1 parent 95605f4 commit 750a0343f1ecd9653432fb0eb64057a38d4b06d8 @simod simod committed Nov 20, 2012
@@ -0,0 +1,19 @@
+{% load i18n %}
+{% load url from future %}
+
+<ul class="nav nav-pills filter">
+ <li><a href="{% url "documents_browse" %}"{% if document_filter == "date" %} class="selected"{% endif %}>{% trans "Most recent" %}</a></li>
+ <li><a href="{% url "document_browse_popular" %}"{% if document_filter == "popular_count" %} class="selected"{% endif %}>{% trans "Most popular" %}</a></li>
+ <li><a href="{% url "document_browse_shared" %}"{% if document_filter == "share_count" %} class="selected"{% endif %}>{% trans "Most shared" %}</a></li>
+ {% comment %}
+ <li>
+ <form action="." class="form-inline">
+ <label for="">{% trans "sort by:" %}</label>
+ <select name="sort" id="layer_sort" class="span1">
+ <option value="">{% trans "Newest" %}</option>
+ <option value="">{% trans "Popularity" %}</option>
+ </select>
+ </form>
+ </li>
+{% endcomment %}
+</ul>
@@ -0,0 +1,8 @@
+<article class="span4">
+ <a href="{% url document_detail document.id %}"><img src="{{ STATIC_URL }}theme/img/placeholder2.png" width="100%" alt="{{ document.title }}" /></a>
+ <div class="details">
+ <a href="{% url document_detail document.id %}"><h3>{{ document.title }}</h3></a>
+ <div class="meta">{% trans 'from' %} <a href="{% url profile_detail document.owner.username %}">{{ document.owner }}</a>, {{ document.date|timesince }} ago</div>
+ <p>{{ document.abstract }}</p>
+ </div>
+</article>
@@ -0,0 +1,18 @@
+{% load url from future %}
+{% load i18n %}
+{% load agon_ratings_tags %}
+{% load documents_tags %}
+
+{% overall_rating document "document" as document_rating %}
+<article>
+<a href="{% url "document_detail" document.id %}">
+ <div class="placeholder pl-153-113">{% trans "No Image Available" %}</div>
+ </a>
+ <div class="details">
+ <a href="#" class="btn btn-info download">{% trans "Download" %}</a>
+ <a href="{% url "document_detail" document.id %}"><h3>{{ document.title }}</h3></a>
+ <div class="meta">{% trans 'from' %} <a href="{% url "profile_detail" document.owner.username %}">{{ document.owner }}</a>, {{ document.date|timesince }} {% trans 'ago' %}</div>
+ <p class="abstract">{{ document.abstract }}</p>
+ <p class="activity">{{ document.popular_count }} {% trans "view" %}{{ document.popular_count|pluralize }} | <span class="avg_rating" data-rating="{{ document_rating }}">{% trans "Average rating" %} <span class="overall_rating"></span></span></p>
+ </div>
+</article>
@@ -0,0 +1,19 @@
+{% extends "site_base.html" %}
+{% load i18n %}
+{% load url from future %}
+
+{% block title %} {{ block.super }} {% endblock %}
+
+{% block body_class %}data{% endblock %}
+
+{% block body_outer %}
+ <div class="span12">
+ <ul class="nav nav-tabs" id="subnav-tabs">
+ <li><a href="{% url "documents_browse" %}" class="explore">{% trans "Explore Documents" %}</a></li>
+ <li><a href="{% url "documents_search" %}" class="search">{% trans "Search Documents" %}</a></li>
+ <li><a href="{% url "document_upload" %}" class="upload">{% trans "Upload Documents" %}</a></li>
+ </ul>
+ </div>
+ {% block body %}{% endblock body %}
+ {% block sidebar %}{% endblock sidebar %}
+{% endblock body_outer %}
@@ -0,0 +1,97 @@
+{% extends "documents/document_base.html" %}
+{% load i18n %}
+{% load documents_tags %}
+{% load pagination_tags %}
+{% load taggit_extras %}
+{% load staticfiles %}
+{% load url from future %}
+
+{% block title %} {% trans "Explore Documents" %} - {{ block.super }} {% endblock %}
+
+{% block body_class %}documents documents-list explore{% endblock %}
+
+{% block body %}
+ <div class="span12">
+ <h2 class="page-title">{% trans "Explore Documents" %}</h2>
+ </div>
+ <div class="span8">
+ {% include "documents/_document_filters.html" %}
+ </div>
+ <div class="span4">
+ <div class="pull-right" data-viewby="list">
+ {% include "_viewby.html" %}
+ </div>
+ </div>
+ <div class="span12">
+ <div class="row" id="contain-slider">
+ <div class="span4">
+ <div id="slide-pane">
+ <a href="#" class="toggle toggle-pane"><i class="icon-chevron-left"></i></a>
+ <nav class="tabs-left" id="nav-categories">
+ <h2><a href="#" class="toggle toggle-nav"><i class="icon-chevron-down"></i>{% trans "Categories" %}</a></h2>
+ <ul class="nav">
+ {% document_categories as category_list %}
+ <li><a href="{% url "documents_browse" %}"{% if not document_category %} class="active"{% endif %}>{% trans "All Categories" %}</a></li>
+ {% for category in category_list %}
+ <li><a href="{% url "document_browse_category" category.slug %}"{% ifequal document_category category %} class="active"{% endifequal %}>{{ category }}</a></li>
+ {% endfor %}
+ </ul>
+ </nav>
+ <nav class="" id="nav-keywords">
+ <h2><a href="#" class="toggle toggle-nav"><i class="icon-chevron-down"></i> {% trans "Keywords" %}</a></h2>
+ <ul class="nav">
+ {% get_taglist as tags for 'documents.Document' %}
+ {% for tag in tags %}
+ <li><a href="{% url "document_browse_tag" tag.slug %}"{% if tag.slug == layer_tag %} class="active"{% endif %}>{{ tag }}</a> <span class="count">({{ tag.num_times }})</span></li>
+ {% endfor %}
+ </ul>
+ </nav>
+ </div>
+ </div>
+ <div class="tab-content span8 paginate paginate-auto">
+ <div class="tab-pane active list paginate-contents" id="all">
+ {% if object_list.count %}
+ {% autopaginate object_list 2 %}
+ {% for document in object_list %}
+ {% include "documents/_document_list_item.html" %}
+ {% endfor %}
+ {% else %}
+ <p>{% trans "No data found" %}</p>
+ {% endif %}
+ </div>
+ {% if object_list.count %}
+ {% paginate %}
+ {% endif %}
+ </div>
+ </div>
+ </div>
+{% endblock %}
+
+{% block extra_script %}
+ <script src="{% static "geonode/js/layers.js" %}"></script>
+ <script src="{% static "geonode/js/waypoints.js" %}"></script>
+ <script src="{% static "geonode/js/paginate.js" %}"></script>
+ <script src="{% static "agon_ratings/js/jquery.raty.js" %}"></script>
+ <script type="text/javascript">
+ $(function() {
+ $('.overall_rating').each(function() {
+ var rating = $(this).parents(".avg_rating").data('rating');
+ star(this, rating);
+ });
+ $(".loadmore").on("load.loadmore", function(e, o) {
+ o.find(".overall_rating").each(function() {
+ var rating = $(this).parents(".avg_rating").data('rating');
+ star(this, rating);
+ });
+ });
+ });
+ function star(elem, rating) {
+ $(elem).raty({
+ half: true,
+ readOnly: true,
+ score: rating,
+ path: "{% static "agon_ratings/img/" %}"
+ });
+ }
+ </script>
+{% endblock extra_script %}
@@ -30,7 +30,7 @@
Ext.onReady(function() {
Ext.QuickTips.init();
- var form_target = "{% url documents.views.upload_document %}";
+ var form_target = "{% url document_upload %}";
var title = new Ext.form.TextField({
id: 'title',
@@ -1,67 +0,0 @@
-{% extends "base.html" %}
-{% load i18n %}
-
-{% block title %} {% trans "Browse Documents" %} - {{ block.super }} {% endblock %}
-
-{% block head %}
-{% include "geonode/ext_header.html" %}
-{% include "geonode/app_header.html" %}
-{{ block.super }}
-<script type="text/javascript">
-Ext.onReady(function(){
-
-{% autoescape off %}
- var submitForm = function() {
- Ext.query('#search_form form')[0].submit();
- };
- var searchButton = new Ext.Button({renderTo: 'submit_search', text: '{% trans "Search" %}',
- handler: submitForm});
- var searchInput = new Ext.form.TextField({applyTo: 'search_query', width: 350});
-{% endautoescape %}
-
-});
-</script>
-{% endblock %}
-
-{% block body %}
-<div class="twocol">
-
- <div id="search_form" class="block">
- <h2>{% trans "Search" %} <span class="subtitle">{% trans "for documents" %}</span></h2>
-
- <form action="{% url documents.views.documents_search_page %}" method="POST">
- {% csrf_token %}
- <table>
- <tr>
- <td>
- <input type="text" id="search_query" name="q" />
- </td>
- <td>
- <div id="submit_search"></div>
- </td>
- </tr>
- </table>
- <p>
- <a href="{% url documents.views.documents_search_page %}">{% trans "All Documents" %}</a> |
- </p>
- </form>
- </div>
-
- <div id="create" class="block">
- <h2>{% trans "Upload new Document" %}</h2>
- <p>{% trans "Use GeoNode's upload form to upload and link a document to a Map." %}
- </p>
- <p>
- <a href="{% url documents.views.upload_document %}">{% trans "Upload a document" %}</a>
- </p>
- </div>
-
- <!-- "Your Maps" button goes here -->
- <!-- create map button goes here -->
-
-</div>
-{% endblock %}
-
-{% block sidebar %}
-{% endblock %}
-
No changes.
@@ -0,0 +1,20 @@
+from django import template
+
+from geonode.layers.models import TopicCategory
+
+from geonode.documents.models import Document
+
+
+register = template.Library()
+
+
+@register.assignment_tag(takes_context=True)
+def featured_layers(context, count=7):
+ request = context["request"]
+ documents = Document.objects.order_by("-date")[:count]
+ return documents
+
+
+@register.assignment_tag
+def document_categories():
+ return TopicCategory.objects.all()
View
@@ -1,11 +1,45 @@
+# -*- coding: utf-8 -*-
+#########################################################################
+#
+# Copyright (C) 2012 OpenPlans
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+#########################################################################
+
from django.conf.urls.defaults import patterns, url
-from django.views.i18n import javascript_catalog
+
+from geonode.documents.views import DocumentListView
+
+js_info_dict = {
+ 'packages': ('geonode.documents',),
+}
urlpatterns = patterns('geonode.documents.views',
- url(r'^$','documents', name='documents_browse'),
- url(r'^(?P<docid>\d+)/?$', 'documentdetail', name='document_detail'),
- url(r'^upload/?$', 'upload_document', name='document_upload'),
- url(r'^search/?$', 'documents_search_page', name='documents_search'),
+ url(r'^$', DocumentListView.as_view(), name='documents_browse'),
+ url(r'^popular/$', DocumentListView.as_view(
+ document_filter="popular_count"),
+ name='document_browse_popular'),
+ url(r'^shared/$', DocumentListView.as_view(
+ document_filter="share_count"),
+ name='document_browse_shared'),
+ url(r'^category/(?P<slug>[-\w]+?)/$', 'document_category',
+ name='document_browse_category'),
+ url(r'^tag/(?P<slug>[-\w]+?)/$', 'document_tag', name='document_browse_tag'),
+ url(r'^(?P<docid>\d+)/?$', 'documentdetail', name='document_detail'),
+ url(r'^upload/?$', 'document_upload', name='document_upload'),
+ url(r'^search/?$', 'documents_search_page', name='documents_search'),
url(r'^search/api/?$', 'documents_search', name='documents_search_api'),
url(r'^(?P<docid>\d+)/ajax-permissions$', 'ajax_document_permissions', name='ajax_document_permissions'),
url(r'^(?P<docid>\d+)/metadata$', 'document_metadata', name='document_metadata'),
Oops, something went wrong.

0 comments on commit 750a034

Please sign in to comment.