Add RDFa data to our library pages.
authorDiane Trout <diane@caltech.edu>
Thu, 17 Feb 2011 08:35:44 +0000 (00:35 -0800)
committerDiane Trout <diane@caltech.edu>
Thu, 17 Feb 2011 08:35:44 +0000 (00:35 -0800)
While doing that I discovered that the library_index page was spitting up
seriously bad HTML, with two DOCTYPE & html tags.
It looks like it was a combination of my simplifications with the
leftovers of brandon's "app" templates I ended up putting in two
base.html templates.

I stripped out the app templates and tried to simplify the template
inheritance.

As a side effect the library detail page, now has a header and is using
a css based font.

There was also a minor issue where I discovered the paginator was showing
"X libraries libraries" because the views was adding "libraries" to
the changelist result count. (And the change list also adds in the name).

I needed to replace the default admin pagination template, as
RDFa uses xhtml, and xhtml doesn't support the &nbsp; entity.
(The solution is to use a unicode character for nbsp -- such as
&#160; -- unicode for non-breaking space.

12 files changed:
htsworkflow/frontend/samples/models.py
htsworkflow/frontend/samples/views.py
htsworkflow/frontend/templates/admin/pagination.html [new file with mode: 0644]
htsworkflow/frontend/templates/app_base.html [deleted file]
htsworkflow/frontend/templates/base.html
htsworkflow/frontend/templates/flowcell_libraries_app.html [deleted file]
htsworkflow/frontend/templates/inventory/inventory_app.html [deleted file]
htsworkflow/frontend/templates/registration/login.html
htsworkflow/frontend/templates/registration/profile.html
htsworkflow/frontend/templates/samples/lanes_for.html
htsworkflow/frontend/templates/samples/library_detail.html
htsworkflow/frontend/templates/samples/library_index.html

index 59b4c244d8b77805207a3562de316172463113fc..8314c71f5e685f2cd44d28805959ddafeb3e5adf 100644 (file)
@@ -1,3 +1,4 @@
+import logging
 import urlparse
 from django.db import models
 from django.contrib.auth.models import User, UserManager
@@ -6,7 +7,9 @@ from django.db import connection
 from htsworkflow.frontend import settings
 from htsworkflow.frontend.reports.libinfopar import *
 
+
 # Create your models here.
+logger = logging.getLogger(__name__)
 
 class Antibody(models.Model):
     antigene = models.CharField(max_length=500, db_index=True)
@@ -166,6 +169,8 @@ class Library(models.Model):
       ('2A', 'Ligation, PCR, gel, PCR'),
       ('Done', 'Completed'),
     )
+  PROTOCOL_END_POINTS_DICT = dict(PROTOCOL_END_POINTS)
+  
   stopping_point = models.CharField(max_length=25, choices=PROTOCOL_END_POINTS, default='Done')
   amplified_from_sample = models.ForeignKey('self', blank=True, null=True, related_name='amplified_into_sample')  
   
@@ -189,9 +194,9 @@ class Library(models.Model):
     return u'#%s: %s' % (self.id, self.library_name)
   
   class Meta:
-    verbose_name_plural = "libraries"
-    #ordering = ["-creation_date"] 
-    ordering = ["-id"]
+      verbose_name_plural = "libraries"
+      #ordering = ["-creation_date"] 
+      ordering = ["-id"]
   
   def antibody_name(self):
     str ='<a target=_self href="/admin/samples/antibody/'+self.antibody.id.__str__()+'/" title="'+self.antibody.__str__()+'">'+self.antibody.nickname+'</a>' 
@@ -218,6 +223,15 @@ class Library(models.Model):
     else:
         return False
 
+  def stopping_point_name(self):
+      end_points = Library.PROTOCOL_END_POINTS_DICT
+      name = end_points.get(self.stopping_point, None)
+      if name is None:
+          name = "Lookup Error"
+          logger.error("protocol stopping point in database didn't match names in library model")
+      return name
+      
+
   def libtags(self):
     affs = self.tags.all().order_by('tag_name')
     ar = []
index afccc022586e1570b15117f0651351dbc63cfa8d..a6286d7313072c706ed2e8225e3fd398d28dd290 100644 (file)
@@ -84,7 +84,7 @@ def create_library_context(cl):
        summary['lanes_run'] = lanes_run
        summary['is_archived'] = lib.is_archived()
        records.append(summary)
-    cl.result_count = unicode(cl.paginator._count) + u" libraries"
+    cl.result_count = unicode(cl.paginator._count)
     return {'library_list': records }
 
 def library(request):
@@ -100,16 +100,8 @@ def library(request):
     context.update(create_library_context(fcl))
     t = get_template('samples/library_index.html')
     c = RequestContext(request, context)
+    return HttpResponse( t.render(c) )
     
-    app_context = {
-        'page_name': 'Library Index',
-        'body': t.render(c)
-    }
-    app_context.update(SAMPLES_CONTEXT_DEFAULTS)
-    
-    app_t = get_template('flowcell_libraries_app.html')
-    app_c = RequestContext(request, app_context)
-    return HttpResponse( app_t.render(app_c) )
 
 def library_to_flowcells(request, lib_id):
     """
diff --git a/htsworkflow/frontend/templates/admin/pagination.html b/htsworkflow/frontend/templates/admin/pagination.html
new file mode 100644 (file)
index 0000000..f7de053
--- /dev/null
@@ -0,0 +1,13 @@
+<!--overrride pagination-->
+{% load admin_list %}
+{% load i18n %}
+<p class="paginator">
+{% if pagination_required %}
+{% for i in page_range %}
+    {% paginator_number cl i %}
+{% endfor %}
+{% endif %}
+{{ cl.result_count }} {% ifequal cl.result_count 1 %}{{ cl.opts.verbose_name }}{% else %}{{ cl.opts.verbose_name_plural }}{% endifequal %}
+{% if show_all_url %}&#160;&#160;<a href="{{ show_all_url }}" class="showall">{% trans 'Show all' %}</a>{% endif %}
+{% if cl.formset and cl.result_count %}<input type="submit" name="_save" class="default" value="{% trans 'Save' %}"/>{% endif %}
+</p>
diff --git a/htsworkflow/frontend/templates/app_base.html b/htsworkflow/frontend/templates/app_base.html
deleted file mode 100644 (file)
index 1babcf6..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
-<html lang="en">
-<head>
-    <title>{% block title %}{{ app_name }} - {{ page_name }}{% endblock %}</title>
-    
-    <!-- ADMIN STYLE INTERFACE STUFF -->
-    {% block additional_css %}
-    {% endblock %}
-    
-    <!-- App Stuff -->
-    <link type="text/css" rel="stylesheet" href="/static/css/app.css" />
-    <script type="text/javascript" src="/static/js/jquery.min.js"></script>
-    
-    {% block additional_javascript %}
-    {% endblock %}
-    
-    <script type="text/javascript" src="/static/js/htsw.js"></script>
-</head>
-<body class="{% block bodyclass %}{% endblock %}">
-    <!-- Content -->
-    <div id="content" class="{% block coltype %}colM{% endblock %}">
-        {% block pretitle %}{% endblock %}
-        {% block content_title %}{% if title %}<h1>{{ title }}</h1>{% endif %}{% endblock %}
-        {% block content %}
-        {% block object-tools %}{% endblock %}
-        {{ body }}
-        {% endblock %}
-        {% block sidebar %}{% endblock %}
-        <br class="clear" />
-    </div>
-    <!-- END Content -->
-
-    {% block footer %}<div id="footer"></div>{% endblock %}
-</body>
-</html>
index b5e1c39c5a80cab995e0bc2f6d505b3f86a260f8..ba17cbda121d2c2bf6dd646df4c85450d01f77e9 100644 (file)
@@ -1,6 +1,15 @@
-{% load i18n %}
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
-<html lang="en">
+{% load i18n %}<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.0//EN"
+    "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"
+      version="XHTML+RDFa 1.0"
+      xmlns:xml="http://www.w3.org/1999/xhtml"
+      xmlns:dc="http://purl.org/dc/elements/1.1/"
+      xmlns:xmls="http://www.w3.org/2001/XMLSchema#"
+      xmlns:libns="http://jumpgate.caltech.edu/wiki/LibraryOntology#"
+      xml:lang="en"
+>
+<!--base.html-->
 <head>
     <title>{% block title %}{{ app_name }} - {{ page_name }}{% endblock %}</title>
 
         {% block branding %}{% endblock %}
         </div>
         {% if user.is_authenticated and user.is_staff %}
-        <div id="user-tools">{% trans 'Welcome,' %} <strong>{% firstof user.first_name user.username %}</strong>. {% block userlinks %}{% url django-admindocs-docroot as docsroot %}{% if docsroot %}<a href="{{ docsroot }}">{% trans 'Documentation' %}</a> / {% endif %}<a href="{{ root_path }}password_change/">{% trans 'Change password' %}</a> / <a href="{{ root_path }}logout/">{% trans 'Log out' %}</a>{% endblock %} 
+        <div id="user-tools">{% trans 'Welcome,' %} <strong>{% firstof user.first_name user.username %}</strong>. {% block userlinks %}{% url django-admindocs-docroot as docsroot %}{% if docsroot %}<a href="{{ docsroot }}">{% trans 'Documentation' %}</a> / {% endif %}<a href="/admin/password_change/">{% trans 'Change password' %}</a> / <a href="/admin/logout/">{% trans 'Log out' %}</a>{% endblock %} 
         </div>
         {% endif %}
         {% block nav-global %}{% endblock %}
     </div>
-    
-    {% block breadcrumbs %}<div class="breadcrumbs"><a href="/">{% trans 'Home' %}</a>{% if title %} &rsaquo; {{ title }}{% endif %}</div>{% endblock %}
     {% endif %}
        {% if messages %}
         <ul class="messagelist">{% for message in messages %}<li>{{ message }}</li>{% endfor %}</ul>
diff --git a/htsworkflow/frontend/templates/flowcell_libraries_app.html b/htsworkflow/frontend/templates/flowcell_libraries_app.html
deleted file mode 100644 (file)
index 6e31b59..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-{% extends "app_base.html" %}
-
-{% block additional_css %}
-    {% load adminmedia %}
-    {% if LANGUAGE_BIDI %}<link rel="stylesheet" type="text/css" href="{% block stylesheet_rtl %}{% admin_media_prefix %}css/rtl.css{% endblock %}" />{% endif %}
-    {% block extrastyle %}{% endblock %}
-    {% block extrahead %}{% endblock %}
-    {% block blockbots %}<meta name="robots" content="NONE,NOARCHIVE" />{% endblock %}
-    <link rel="stylesheet" type="text/css" href="{{ MEDIA_URL }}css/data-browse-index.css" />
-{% endblock %}
-
-{% block dynamic_panels %}
-    <ul id="Libraries" class="x-hidden">
-            <li>
-                <img src="/static/img/s.gif" class="icon-show-all" />
-                <a href="{% url htsworkflow.frontend.samples.views.library %}">Index</a><br />
-            </li>
-    </ul>
-    <ul id="Flowcells" class="x-hidden">
-            <li>
-                <img src="/static/img/s.gif" class="icon-show-all" />
-                <a href="/runfolders/">Run Folders</a><br />
-            </li>
-    </ul>
-{% endblock %}
-
-{% block app_toolbar_west %}
-    <div id="Library Index" href="{% url htsworkflow.frontend.samples.views.library %}"></div>
-    <div id="Run Folders" href="/runfolders/"></div>
-{% endblock %}
-
-{% block app_toolbar_east %}
-    <!--<div id="Admin" href="/admin/"></div>-->
-{% endblock %}
diff --git a/htsworkflow/frontend/templates/inventory/inventory_app.html b/htsworkflow/frontend/templates/inventory/inventory_app.html
deleted file mode 100644 (file)
index b5271c6..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-{% extends "app_base.html" %}
-
-{% block additional_css %}
-{% endblock %}
-
-{% block dynamic_panels %}
-    <ul id="Libraries" class="x-hidden">
-            <li>
-                <img src="/static/img/s.gif" class="icon-show-all" />
-                <a href="{% url htsworkflow.frontend.samples.views.library %}">Index</a><br />
-            </li>
-    </ul>
-{% endblock %}
-
-{% block app_toolbar_west %}
-    <div id="Inventory Index" href="{% url htsworkflow.frontend.inventory.views.index %}"></div>
-{% endblock %}
-
-{% block app_toolbar_east %}
-    <!--<div id="Admin" href="/admin/"></div>-->
-{% endblock %}
index cd28d5997ee32092f85fc4b8cdecac82f08bcde0..1f053df6e6538c96311fb1afb11b8be56b6e109b 100644 (file)
@@ -1,10 +1,11 @@
-{% extends "app_base.html" %}
+{% extends "base_site.html" %}
 {% load i18n %}
 
 {% block additional_css %}{% load adminmedia %}{{ block.super }}
 <link rel="stylesheet" type="text/css" href="{% admin_media_prefix %}css/base.css" />
 <link rel="stylesheet" type="text/css" href="{% admin_media_prefix %}css/login.css" />
 {% endblock %}
+
 {% block title %}Login{% endblock %}
 {% block bodyclass %}login{% endblock %}
 
@@ -13,9 +14,7 @@
 <p class="errornote">{{ error_message }}</p>
 {% endif %}
 <div id="container">
-  <div id="header">
     <h1>Login</h1>
-  </div>
 <form action="{{ app_path }}" method="post" id="login-form">
   <div class="form-row">
     <label for="id_username">{% trans 'Username:' %}</label> <input type="text" name="username" id="id_username" />
index c53c4deea708a1dc3728962a8c383e3e5fb13531..fec48b0447583157f93691c7e2732c2296325455 100644 (file)
@@ -1,4 +1,4 @@
-{% extends "flowcell_libraries_app.html" %}
+{% extends "base_site.html" %}
 
 {% block content %}
 <table>
index 90bce6a4cc13a2eab9e40d71ea591fc68bb7e308..152f322300a40e0724892de777ac0faafb82ad83 100644 (file)
@@ -1,5 +1,4 @@
 {% extends "base_site.html" %}
-{# extends "app_base.html" #}
 {% load adminmedia admin_list i18n %}
 
 {% block bodyclass %}change-list{% endblock %}
index 6c6fa8d93a79015a4e3daf22941ea3cdc1a8d3da..1bbd65b2986caf766d832ac8fd86b294d992b8a5 100644 (file)
@@ -1,7 +1,13 @@
-{% extends "flowcell_libraries_app.html" %}
-{% load humanize %}
+{% extends "base_site.html" %}
+{% load adminmedia humanize i18n %}
+{% block extrahead %}
+    <!-- App Stuff -->
+    <link type="text/css" rel="stylesheet" href="/static/css/app.css" />
+    <script type="text/javascript" src="/static/js/jquery.min.js"></script>
+    
+    {% block additional_javascript %}
+    {% endblock %}
 
-{% block additional_css %}
 <style type="text/css">
   /* <![CDATA[ */
   div#librarydetail {
 <div id="librarydetail">
   <h2>About this library</h2>
   <b>Library ID</b>: {{ lib.id }}<br/>
-  <b>Name</b>: {{ lib.library_name }}<br/>
-  <b>Species</b>: {{ lib.library_species.scientific_name }}<br/>
-  <b>Concentration</b>: {{ lib.undiluted_concentration }} ng/µl<br/>
-  <b>Gel Cut Size</b>: {{ lib.gel_cut_size }}<br/>
-  <b>Insert Size</b>: {{ lib.insert_size }}<br/>
-  <b>Replicate</b>: {{ lib.replicate }}<br/>
-  <b>Made By</b>: {{ lib.made_by }} <br/>
+  <b>Name</b>: 
+    <span property="libns:name">{{ lib.library_name }}</span>
+  <br/>
+  <b>Species</b>: 
+    <span property="libns:species">{{ lib.library_species.scientific_name }}</span>
+  <br/>
+  <b>Concentration</b>: 
+    <span property="libns:concentration">{{ lib.undiluted_concentration }} ng/µl</span>
+  <br/>
+  <b>Gel Cut Size</b>: 
+    <span property="libns:gel_cut">{{ lib.gel_cut_size }}</span>
+  <br/>
+  <b>Insert Size</b>: 
+    <span property="libns:insert_size">{{ lib.insert_size }}</span>
+  <br/>
+  <b>Background or Cell Line</b>:
+     <span property="libns:cell_line">{{ lib.cell_line }}</span>
+  <br/>
+  <b>Replicate</b>: 
+     <span property="libns:replicate">{{ lib.replicate }}</span>
+  <br/>
+  <b>Library Type</b>:
+     <span property="libns:library_type">{{ lib.library_type }}</span>
+  <br/>
+  <b>Experiment Type</b>:
+     <span property="libns:experiment_type">{{ lib.experiment_type }}</span>
+  <br/>
+  <b>Made By</b>: 
+    <span property="libns:made_by">{{ lib.made_by }}</span>
+  <br/>
+  <b>Creation Date</b>
+    <span property="libns:creation_date">{{ lib.creation_date }}</span>
+  <br/> 
+  <b>Protocol Stopping Point</b>
+    <span property="libns:stopping_point">{{ lib.stopping_point_name }}</span>
+  <br/> 
   <b>Affiliations</b>:
   <ul>
     {% for individual in lib.affiliations.all %}
-      <li>{{ individual.name }} ( {{ individual.contact }} )</li>
+      <li property="libns:affliation" content="{{individual.name}}">
+        {{ individual.name }} ( {{ individual.contact }} )
+      </li>
     {% endfor %}
   </ul>
   
       <td>Bed</td>
       <td>Archived</td>
     </tr>
-  {% for result in eland_results %}
-  <tr>
-    <td>{{ result.run_date|date }}</td>
-    <td>{{ result.cycle }}</td>
-    <td>{{ result.flowcell_id }}</td>
-    <td>{{ result.lane }}</td>
-    <td><a href="{{ result.summary_url }}">Summary</a></td>
-    <td><a href="{{ result.result_url }}">{{ result.result_label }}</a></td>
-    <td>
-    {% if result.bed_url %}
-      <a href="{{ result.bed_url }}">Bed</a>
-    {% endif %}
-    </td>
-    <td>
-      {% if result.storage_ids %}
-        {{ result.storage_ids|safe }}
+  </thead>
+  <tbody>
+    {% for result in eland_results %}
+    <tr about="/flowcell/{{result.flowcell_id}}/lane/{{result.lane}}">
+      <td property="libns:run_date" contents="{{result.run_date}}" datatype="xmls:datetime">{{ result.run_date|date}}</td>
+      <td>{{ result.cycle }}</td>
+      <td property="libns:flowcell_id">{{ result.flowcell_id }}</td>
+      <td property="libns:lane">{{ result.lane }}</td>
+      <td><a href="{{ result.summary_url }}">Summary</a></td>
+      <td><a href="{{ result.result_url }}">{{ result.result_label }}</a></td>
+      <td>
+      {% if result.bed_url %}
+        <a href="{{ result.bed_url }}">Bed</a>
       {% endif %}
-    </td>
-  </tr>
-  {% endfor %}
+      </td>
+      <td>
+        {% if result.storage_ids %}
+          {{ result.storage_ids|safe }}
+        {% endif %}
+      </td>
+    </tr>
+    {% endfor %}
+  </tbody>
   </table>
   
   <h2>Lane Summary Statistics</h2>
     <tbody>
   
       {% for lane in lane_summary_list %}
-      <tr>
+      <tr about="/flowcell/{{lane.flowcell_id}}/lane/{{lane.lane_id}}/end/{% if lane.end %}{{ lane.end }}{% endif %}">
         <td>{{ lane.cycle_width }}</td>
         <td>{{ lane.flowcell_id }}</td>
         <td>{{ lane.lane_id }}</td>
         <td>{{ lane.match_codes.U0|intcomma }}</td>
         <td>{{ lane.match_codes.U1|intcomma }}</td>
         <td>{{ lane.match_codes.U2|intcomma }}</td>
-        <td>{{ lane.unique_reads|intcomma }}</td>
+        <td property="libns:sequence_unique_location" contents="{{lane.unique_reads}}" datatype="xmls:decimal">{{ lane.unique_reads|intcomma }}</td>
         <td>{{ lane.match_codes.R0|intcomma }}</td>
         <td>{{ lane.match_codes.R1|intcomma }}</td>
         <td>{{ lane.match_codes.R2|intcomma }}</td>
   <table>
     <thead>
       <tr>
-       <td>Flowcell ID</td>
-       <td>Lane</td>
-       <td>Comment</td>
+       <td>Flowcell ID</td>
+       <td>Lane</td>
+       <td>Comment</td>
+      </tr>
     </thead>
     <tbody>
       {% for lane in lib.lane_set.all %}
       <tr>
-       <td>{{ lane.flowcell.flowcell_id }}</td>
-       <td>{{ lane.lane_number }}</td>
-       <td>{{ lane.comment }}</td>
-       {% endfor %}
+        <td>{{ lane.flowcell.flowcell_id }}</td>
+        <td>{{ lane.lane_number }}</td>
+        <td>{{ lane.comment }}</td>
+      </tr>
+         {% endfor %}
     </tbody>
   </table>
   <br/>
index 1a53ac2a6f3aad48f77024ee1d18e6d0cceed69d..16cd9a32121106d7584fa151e78388bc274f3584 100644 (file)
@@ -1,6 +1,12 @@
 {% extends "base_site.html" %}
 {% load adminmedia admin_list i18n %}
 {% block extrahead %}
+    <!-- App Stuff -->
+    <link type="text/css" rel="stylesheet" href="/static/css/app.css" />
+    
+    {% block additional_javascript %}    
+    <script type="text/javascript" src="/static/js/jquery.min.js"></script>
+    <script type="text/javascript" src="/static/js/htsw.js"></script>
     <script type="text/javascript">
       $(document).ready(function() {
         $(window).resize(function() {
         $(window).resize();
       });
     </script>
+    {% endblock %}
 {% endblock %}
 {% block bodyclass %}change-list{% endblock %}
 {% block coltype %}flex{% endblock %}
+
 {% block content %}
 <div id="library-index-div" >
   <div class="module{% if cl.has_filters %} filtered{% endif %}" id="changelist">
@@ -30,7 +38,7 @@
       {% for spec in cl.filter_specs %}
          {% admin_list_filter cl spec %}
          {% endfor %}
-       </div>
+    </div>
     {% endif %}
     {% endblock %}
   {% block summary_stats %}
     </thead>
     <tbody >
       {% for lib in library_list %}
-      <tr >
+      <tr about="/library/{{lib.library_id}}">
         <td ><a href="/library/{{ lib.library_id }}">{{ lib.amplified_from }}</a></td>
-        <td ><a href="/library/{{ lib.library_id }}">{{ lib.library_id }}</a></td>
-        <td ><a href="/library/{{ lib.library_id }}">{{ lib.species_name }}</a></td>
-        <td ><a href="/library/{{ lib.library_id }}">{{ lib.library_name }}</a></td>
+        <td ><a href="/library/{{ lib.library_id }}" property="libns:library_id">{{ lib.library_id }}</a></td>
+        <td ><a href="/library/{{ lib.library_id }}" property="libns:species_name">{{ lib.species_name }}</a></td>
+        <td ><a href="/library/{{ lib.library_id }}" property="libns:library_name">{{ lib.library_name }}</a></td>
         <td  bgcolor="#00BFFF">{{ lib.lanes_run.0.0 }}</td>      
         <td  bgcolor="#00BFFF">{{ lib.lanes_run.0.1 }}</td>      
         <td  bgcolor="#00BFFF">{{ lib.lanes_run.0.2 }}</td>      
@@ -78,6 +86,7 @@
       {% endfor %}
     </tbody>
   </table>
+  </div>
   {% endblock %}
 </div>
 {% endblock %}