Richard Gerkin avatar Richard Gerkin committed e9c646c

Template changes

Comments (0)

Files changed (11)

 # Import all sciunit domains.  
 import sciunit.tests
 
-# Abstract base class for all sciunit_web classes.    
+# Abstract base class for all scidash classes.    
 class SciDash(m.Model):
     class Meta:
         abstract = True
     def __str__(self):
         return u'%s' % self.name
 
-# Abstract base class for all sciunit_web classes which have an implementation, e.g. Model, Test, Capability.    
+# Abstract base class for all scidash classes which have an implementation, e.g. Model, Test, Capability.    
 class SciCode(SciDash):
     class Meta:
         abstract = True
         return pickle.loads(self.code) 
 
 # ---------------------------------------------------------------------------------------#
-# Metadata classes for sciunit_web.  
+# Metadata classes for scidash.  
 # ---------------------------------------------------------------------------------------#
 
+class Repo(SciDash,m.Model):
+    github_id = m.BigIntegerField()
+    owner = m.CharField(max_length=50)
+    url = m.CharField(max_length=100)
+
 class Institution(SciDash,m.Model):
     class Meta:
         abstract = False

templates/scidash/base.html

 	"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
 <head>
-	<title>scidash</title>
-	<link rel="icon" type="image/png" href="/static/images/scidash-favicon.gif" />
-	<link rel="shortcut icon" type="image/png" href="/static/images/scidash-favicon.gif" />
-	<link type="text/css" charset="utf-8" href="/static/css/scidash/style.css" rel="stylesheet">
-	{% for sheet in sheets %}
-        <link type="text/css" charset="utf-8" href="/static/css/{{ sheet }}.css" rel="stylesheet">
-	{% endfor %} 
-	{% for script in scripts %}
-	<script type='text/javascript' src='/static/js/{{ script }}.js'></script>
-	{% endfor %}
-	<head>
-    <script language="javascript" type="text/javascript" src="/static/datatables/js/jquery.js"></script>
-    <script language="javascript" type="text/javascript" src="/static/datatables/js/jquery.dataTables.min.js"></script>
-    <link rel="stylesheet" type="text/css" href="/static/datatables/css/jquery.dataTables.css">
-    <link rel="stylesheet" type="text/css" href="/static/css/demo_table.css">
+	<title>SciDash: Measuring the progress of scientific modeling</title>
+	<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />
+    <link rel="stylesheet" type="text/css" href="/static/css/bootstrap.css" />      
+  	<link rel="stylesheet" type="text/css" charset="utf-8" href="{{ STATIC_URL }}datatables/css/jquery.datatables.css">
+  {% for css in css_list %}
+	<link rel="stylesheet" type="text/css" charset="utf-8" href="{{ STATIC_URL }}css/{{ css }}.css" >
+  {% endfor %} 
+    <!--<script type="text/javascript" src="/static/js/jquery.min.js"></script>-->
+    <script src="http://code.jquery.com/jquery-1.9.1.js"></script>
+    <script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
+    <script type="text/javascript" src="/static/js/jquery.cookie.js"></script>
+    <script type="text/javascript" src="/static/datatables/js/jquery.datatables.min.js"></script>
+  {% for js in js_list %}
+	<script type='text/javascript' src='{{ STATIC_URL }}js/{{ js }}.js'></script>
+  {% endfor %}
 </head>
 </head> 
 <body>
-<!-- Logo, header links, and commissioner note -->
-	
-    <div id="sidebar">
-        <div id="header" align="middle">
-			<a href="/scidash"><img align=center border=0 src='/static/images/scidash-title.jpg'><br><img align=center border=0 src='/static/images/scidash-subtitle.jpg'></a>
-			<br><br>
-			<table border=0 cellpadding=0 cellspacing=0 width=800px bgcolor='44AA44' class='headbar'>
-			    <tr>
-				{% for name,link in userPages %}
-				     <td class="headbar" width=267px><a href="{{ link }}">{{ name }}</a></td>
-				{% endfor %}
-				</tr>
-			</table>
+    <div class="container">
+	    	<div class="row">
+	    		<div id="header" align="middle">
+					<br>
+					<a href="{% url 'scidash.views.index' %}">
+						<img align=center border=0 src='/static/images/scidash-title.png'>
+					</a>
+					<br><br>
+				</div>
+	    	</div>
+	    	<div class="row-fluid" id="sidebar" style="height:60px;border:solid;border-bottom-width:0px;background-color:#DDDDDD">
+	    		<!-- Cannot apply border to span class itself without pushing contents down. -->
+	      		<!--Sidebar content-->
+      			  {% block sidebar %}
+      			  {% with request.user.is_anonymous as anon %}
+				    <h3>
+      			    	<div class="span{{3|add:anon}}" style="text-align:center">
+				    		<a href="{% url 'scidash.views.index' %}">About</a>
+      			    	</div>
+      			  	  {% if not request.user.is_anonymous %}
+      			    	<div class="span3" style="text-align:center">
+      			    		<a href="{% url 'scidash.views.my' %}">My SciDash</a>
+      			    	</div>
+      			  	  {% endif %}
+      			  		<div class="span{{3|add:anon}}" style="text-align:center">
+      			    		<a href="{% url 'scidash.views.community' %}">Community</a>
+      			    	</div>
+      			    	<div class="span{{3|add:anon}}" style="text-align:center">
+      			    		<a href="{% url 'scidash.views.docs' %}">Docs</a>
+      			   		</div>
+      			   	</h3>
+      			  {% endwith %}
+	  			  {% endblock %}
+    		</div>
+	      	<div class="row-fluid" style='min-height:400px;border:solid;background-color:#EEEEEE'>
+	    		<div class="container">
+	    			{% block content %}
+	    			{% endblock %}
+	  			</div>
+	  		</div>
+	  	  	<div class="row"> <!-- Footer -->	
+	  	  		<br>	 
+			  	<div class='span2 offset4'>
+			  	  {% if not request.user.is_anonymous %}
+					<a class='btn btn-primary btn-large' href="{% url 'fantasci.views.logout' %}?next={{ request.path }}">Logout</a>
+			  	  {% else %}
+					<a class='btn btn-large btn-primary' href="{% url 'fantasci.views.login' %}?next={{ request.path }}">Login</a>
+				  {% endif %}	  
+				</div>	
+			  	<div class='span2 offset1'>
+			  		<a class='btn btn-primary btn-large' href="/scidash/contact">
+						Contact
+					</a>
+				</div>
+				<!--<div class='span2 offset1'>
+					<a class='btn btn-primary btn-large' href="/scidash/bugs">
+						Report a bug
+					</a>
+				</div>-->
+			</div>
+			<div class='row' style='text-align:center'>
+				<div class='span4 offset4'
+				<small>
+			  	  {% if not request.user.is_anonymous %}
+					Logged in as <b>{{request.user.first_name}} {{request.user.last_name}} ({{ request.user.username }})</b>
+					<br>
+				  {% endif %}
+			  		<br>Created 2012-2013 <a href='http://github.com/scidash'>SciDash</a>
+				</small>
+				</div>
+			</div>
 		</div>
-		{% block sidebar %}
-		{% endblock %}
-	</div>
-
-    <div id="content">
-	<div align="middle">{{ admin_note }}</div><br>
-    {% if messages %}
-    <ul class="messages">
-        {% for message in messages %}
-        <li{% if message.tags %} class="{{ message.tags }}"{% endif %}>{{ message }}</li>
-        {% endfor %}
-    </ul>
-    {% endif %}
-    {% block content %}    
-    {% endblock %}
-    
-	
-<!-- Footer -->
-    <br>
-	<hr width=800px><br>
-	<div id="footer" align="middle">
-		<font size=2>
-		{% if request.user.username|length > 0 %}
-		    {% for key,value in request.user.items %}
-		    {{ key }}:{{ value }}<br>
-		    {% endfor %}
-			Logged in as <b>{{ request.user.email }}</b> [<a href="{{ LOGOUT_URL }}?next={{ NEXT }}">Logout</a>]<br>
-		{% else %}
-			[<a href="{{ LOGIN_URL }}?next={{ NEXT }}">Login</a>]<br>		
-		{% endif %}
-		{% if commissioner %}
-			|&nbsp;
-			{% for name,link in commissionerPages %}
-				<a href="{{ link }}">{{ name }}</a>|&nbsp;
-			{% endfor %}
-			<br><br>
-		{% endif %}
-		<table width=200px bgcolor='44AA44' style='margin: 5px;'>
-		<tr>
-		<td align=middle><a href="/scidash/contact">Contact us</a></td>
-		<td align=middle><a href="/scidash/bugs">Report a bug</a></td>
-		</tr>
-		</table>
-		</font>
 	</div>
 	<br>
 	{% if live %}

templates/scidash/community.html

-{% extends "sciunit/base.html" %}
+{% extends "scidash/base.html" %}
 
 {% block content %}
+<div class='row' style='text-align:center'>
+	<h3>
+		Public SciDash Suite Repositories:
+	</h3>
+</div>
+<div class='row' style='align:center'>
+	<table align=center style='font-size:150%'>
+		<tr>
+			<th>Name</th>
+			<th>GitHub</th>
+			<th>Watchers</th>
+	  {% for fork in forks %}
+		<tr>
+			<td>
+				<a href='/scidash/repos/{{fork.id}}'>{{ fork.full_name }}</a>
+			</td>
+			<td style='text-align:center'>
+				<a href='{{ fork.html_url }}'>#</a>
+			</td>
+			<td style='text-align:center'>
+				{{ fork.watchers_count }}
+			</td>
+		</tr>
+	  {% endfor %}
+	</table>
+</div>
+<br>
 <br>
 <table align=center width='800px'><tr><td>
 <table id='table1' width='100%' height='200px'>
   <tr>
-    <td id='record_matrix' align='left' valign='bottom'>{% include "sciunit/record_matrix.html" %}</td>
+    <td id='record_matrix' align='left' valign='bottom'>{% include "scidash/record_matrix.html" %}</td>
     <td width='10%'></td>
-    <td id='twitter_widget' align='right' valign='bottom'>{% include "sciunit/twitter.html" %}</td>
+    <td id='twitter_widget' align='right' valign='bottom'>{% include "scidash/twitter.html" %}</td>
   </tr>
 </table>
 <br><hr width='100%'><br>
 <h2 align='center'>Tests</h2>
-{% include "sciunit/test_list.html" %}
+{% include "scidash/test_list.html" %}
 <br><hr width='100%'><br>
 <h2 align='center'>Models</h2>
-{% include "sciunit/model_list.html" %}
+{% include "scidash/model_list.html" %}
 </td></tr></table>
 {% endblock %}

templates/scidash/docs.html

-{% extends "sciunit/base.html" %}
+{% extends "scidash/base.html" %}
 
 {% block content %}
 <table width='800px' align=center><tr><td>
-<h3>The paper for SciUnit is available <a href='https://docs.google.com/document/d/1xHN_h0UhTQi1V6JECMv3yMAi2dhFtzGoWRLzvlmuatU/edit' style='text-decoration:underline'>here</a><br><br>
-Code for the SciUnit framework is available <a href=https://github.com/cyrus-/sciunit style='text-decoration:underline'>here</a><br></h3>
+<h3>The paper for SciUnit is available <a href='http://goo.gl/PLoIOR' style='text-decoration:underline'>here</a><br><br>
+Code for the SciUnit framework is available <a href=https://github.com/scidash/sciunit style='text-decoration:underline'>here</a><br></h3>
 <br>
 <table width=100% cellpadding="5" cellspacing="5" id=glossary>
 <thead>

templates/scidash/index.html

 {% extends "scidash/base.html" %}
 
 {% block content %}
-<table width='800px' align=center>
-<tr>
-<td align=justify style='line-height:150%'>
+<div class='row' style='text-align:justify; line-height:170%; padding:25px'>
+<h4>
 Scientists develop theoretical models to coherently explain seemingly disparate empirical observations. 
 Rigorously validating a model’s explanatory power requires comparing its predictions against experimental data -- 
 both data available when the model is introduced as well as data gathered after its introduction. 
 In most fields, however, the model validation process is informal and incomplete. 
 In this paper, we draw an analogy between scientific model validation and software testing to argue that formal, machine-checkable validation criteria are essential for answering the central question: 
-“Is the output of this model consistent with the full and current set of data available about the phenomena it purports to explain?” 
+“Is the output of this model consistent with the full and current set of data available about the phenomena it purports to explain?”
+<br><br>
 Drawing from the successful practice of unit testing, we propose a framework based on the concept of a “scientific unit test” -- 
 an executable function conforming to a well-defined interface that tests models against a single empirical observation to produce a “score” that indicates agreement between the model and the data. 
 Crucially, these tests are collaboratively curated and the results are generated continuously and automatically, 
 We use example models and neurophysiological data from the rodent olfactory system to demonstrate the problems with the standard approach and to outline an initial implementation of our proposed framework, 
 which we call SciUnit. 
 We conclude with a discussion of practical design and adoption criteria that constrain efforts to fully realize such a framework.
-</td>
-</tr>
-</table>
+</h3>
+</div>
 {% endblock %}

templates/scidash/login.html

-{% extends 'sciunit/base.html' %}
+{% extends 'scidash/base.html' %}
 
 {% block script %}
 <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"></script>
 {% block content %}
 <div width=800px align=middle>
   <h3 align='middle'>Login using:</h3>
-  <span><a rel="nofollow" href="{% url socialauth_begin 'google' %}?next={{ next }}"><img src='/static/images/google.gif' width=15%></a></span>
-  <span><a rel="nofollow" href="{% url socialauth_begin 'yahoo' %}?next={{ next }}"><img src='/static/images/yahoo.jpg' width=15%></a></span>
+  <span><a rel="nofollow" href="{% url 'socialauth_begin' 'google' %}?next={{ next }}"><img src='/static/images/google.gif' width=15%></a></span>
+  <span><a rel="nofollow" href="{% url 'socialauth_begin' 'yahoo' %}?next={{ next }}"><img src='/static/images/yahoo.jpg' width=15%></a></span>
   </ul>
 </div>
 {% endblock %}

templates/scidash/model_list.html

 {% if mine %}
-<form method=POST action='/sciunit/models/add'>{% csrf_token %}
+<form method=POST action='/scidash/models/add'>{% csrf_token %}
 <div align=center><input name='add_model' value='Add a Model' type=submit></div>
 </form>
 {% endif %}
   <tbody>
     {% for model in models %}
     <tr>
-      <td><a href='/sciunit/models/'{{ model.id }}'>{{ model.name }}</a></td>
+      <td><a href='/scidash/models/'{{ model.id }}'>{{ model.name }}</a></td>
       <td>{{ model.publication }}</td>
       <td width=250><ul>{% for capability in model.capabilities.all %}<li>{{ capability }}{% endfor %}</ul></td>
       <td>{{ model.nPassed }}</td>

templates/scidash/profile.html

-{% extends "sciunit/base.html" %}
+{% extends "scidash/base.html" %}
 
 {% block content %}
 <br>
 <table align=center width='800 px'><tr><td>
-{% include "sciunit/test_list.html" %}
+{% include "scidash/test_list.html" %}
 <br><hr width='100%'><br>
-{% include "sciunit/model_list.html" %}
+{% include "scidash/model_list.html" %}
 </td></tr></table>
 {% endblock %}

templates/scidash/test_list.html

 {% if mine %}
-<form method=POST action='/sciunit/tests/create'>{% csrf_token %}
+<form method=POST action='/scidash/tests/create'>{% csrf_token %}
 <div align=center><input name='create_test' value='Create a Test' type=submit></div>
 </form>
 {% endif %}
   <tbody>
     {% for test in tests %}
     <tr>
-      <td><a href='/sciunit/tests/{{ test.id }}'>{{ test.name }}</a></td>
+      <td><a href='/scidash/tests/{{ test.id }}'>{{ test.name }}</a></td>
       <td>{{ test.desc }}</td>
       <td width=250><ul>{% for requirement in test.requires.all %}<li>{{ requirement }}</li>{% endfor %}</ul></td>
       <td>{{ test.nPassed }}</td>
     url(r'^profile/(?P<user_id>\d+)$', 'profile'),
     url(r'^community/$', 'community'),
     url(r'^docs/$', 'docs'),
-    url(r'^tests/create$', 'test_create'),
-    url(r'^models/add$', 'model_add'),
+    url(r'^tests/create/$', 'test_create'),
+    url(r'^models/add/$', 'model_add'),
 )
 
 urlpatterns += patterns('django.views.generic.simple',
     url(r'^twitter.html$',TemplateView.as_view(template_name='sciunit/twitter.html')),#,name='twitter-feed')),
 )
 
-#urlpatterns += patterns('django.contrib.auth.views',
-#	(r'^login$', 'login', {'template_name': 'sciunit/login.html',}),
-#	(r'^logout$', 'logout_then_login', {'login_url':'login',}),
-#)
+urlpatterns += patterns('django.contrib.auth.views',
+	(r'^login/$', 'login', {'template_name': 'scidash/login.html',}),
+	(r'^logout/$', 'logout_then_login', {'login_url':'login',}),
+)
 
 # For when there is no sciunit prefix in the url.  
 #urlpatterns += patterns('',
 # Create your views here.  
 
+# Local imports.  
 import settings
 import models as m
+
+# Base python imports.  
+import json
+import datetime
+import inspect
+import base64
 from xml.dom.minidom import parse,parseString
 from xml.etree.ElementTree import XML
 from urllib2 import urlopen
+from itertools import chain
+from datetime import date
+
+# Django imports.  
 from django import forms
 from django.http import HttpResponse,Http404,HttpResponseRedirect
 from django.shortcuts import render_to_response,redirect
 from django.shortcuts import render_to_response
 from django.contrib.auth.forms import UserCreationForm
 from django.contrib import auth
-import datetime
-from itertools import chain
-from datetime import date
-import inspect
 
 TEMPLATE_DIR = 'scidash'
 
     return render_it(request,TEMPLATE_DIR+'/docs.html',locals())
     
 def community(request):
+    forks = get_scidash_forks()
     models = m.Model.objects.all()
     tests = m.Test.objects.all()
     for i,model in enumerate(models):
     print dict
     return dict
 
+def get_scidash_forks():
+    forks = get_git_json('scidash','scidash','forks')
+    return forks
+
+def read_blob(user,repo,path):
+    response = get_git_json(user,repo,'contents/%s' % path)
+    encoded = response['content']
+    return base64.decodestring(encoded)
+    
+def get_git_json(user,repo,suffix):
+    page = urlopen('https://api.github.com/repos/%s/%s/%s' % (user,repo,suffix))
+    return json.load(page)
+
+    
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.