Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: medialab/reanalyse
base: 5eaaae638a
...
head fork: medialab/reanalyse
compare: cf17433de1
  • 15 commits
  • 16 files changed
  • 0 commit comments
  • 1 contributor
View
4 outside/api.py
@@ -452,9 +452,9 @@ def test( request ):
full_url = "%s://%s%s"% ( 'https' if request.is_secure() else 'http', request.get_host(), reverse('outside.views.confirm', args=( "dsdsdsds", 12 ) ) )
response.add( 'full_url', full_url )
- request.session.set_test_cookie()
+
+
- response.add( 'test cookie worked', request.session.test_cookie_worked() )
return response.json()
View
16 outside/templates/enquete/document.html
@@ -73,13 +73,16 @@
<section class="alpha wide" >
<div class="icon {{ document.doctype }}">
- <img src="{{ STATIC_URL }}/img/{{ document.doctype }}.png"/>
+ <img src="{{ STATIC_URL }}/img/{{ document.doctype }}.png" style="height:24px"/>
</div>
<h3>{{ document.name }}</h3>
-
+ <div class="content" >
+ {{ document.doccat1 }}
- Test.
+ {{ document.doccat2 }}
+
+ </div>
<div class="clear"></div>
</section>
@@ -93,10 +96,13 @@
</object>
</div>
- {% else %}
-
+
{% endifequal %}
+ {% ifequal document.doctype "TEI" %}
+ {{ tei }}
+
+ {% endifequal %}
</section>
{% endblock %}
View
11 outside/templates/enquete/metadata.html
@@ -83,12 +83,19 @@
<h4>{% trans "general" %}</h4>
</th>
</tr>
+
+
+
+
+
+
+
{% for key,item in enquete.meta.values.general.items %}
{% if item.value|length %}
<tr>
- <td class="key">
- {% trans key %}
+ <td class="key">
+ {% trans key %}
</td>
<td>
{% for i in item.value %}{{ i }}{% if not forloop.last %}, {% endif %}{% endfor %}
View
27 outside/views.py
@@ -11,7 +11,6 @@
from django.contrib.auth.models import User
from django.conf import settings
from django.core.mail import send_mail
-from django.core.urlresolvers import reverse
from django.http import HttpResponse, HttpRequest, HttpResponseRedirect
from django.shortcuts import render_to_response, redirect, get_object_or_404
from django.template import RequestContext
@@ -33,7 +32,7 @@
# settings.py
-LOGIN_URL = '/%s/login/' % settings.ROOT_DIRECTORY_NAME
+LOGIN_URL = '/reanalyse/login/'
#
# Outside
@@ -84,12 +83,13 @@ def page( request, page_slug ):
return render_to_response("%s/page.html" % 'enquete', RequestContext(request, data ) )
-
-@login_required( login_url=LOGIN_URL )
def enquete( request, enquete_id ):
data = shared_context( request, tags=[ "enquetes", "focus-on-enquete" ] )
data['enquete'] = get_object_or_404( Enquete, id=enquete_id )
data['disabled'] = [ t.slug for t in data['enquete'].tags.filter( type=Tag.DISABLE_VISUALIZATION ) ]
+
+
+
try:
data['enquiry'] = Enquiry.objects.get( enquete=enquete_id, language=data['language'] )
except Enquiry.DoesNotExist,e:
@@ -99,14 +99,22 @@ def enquete( request, enquete_id ):
return render_to_response('enquete/enquete.html', RequestContext(request, data ) )
+
+
+
def enquete_metadata( request, enquete_id ):
data = shared_context( request, tags=[ "enquetes","metadata" ] )
- data['enquete'] = get_object_or_404( Enquete, id=enquete_id )
-
+ enquete = get_object_or_404( Enquete, id=enquete_id )
+ enquete.meta = enquete.meta_items()
+
+ data['enquete'] = enquete
+
try:
data['enquiry'] = Enquiry.objects.get( enquete=enquete_id, language=data['language'] )
+
except Enquiry.DoesNotExist,e:
pass
+
return render_to_response('enquete/metadata.html', RequestContext(request, data ) )
@@ -191,6 +199,8 @@ def enquiry( request, enquete_id ):
data['enquiry'] = get_object_or_404( Enquiry, enquete__id=enquete_id, language=data['language'])
data['sections'] = data['enquiry'].pins.order_by(*["sort","-id"])
+
+
return render_to_response('enquete/enquiry.html', RequestContext(request, data ) )
@@ -282,8 +292,6 @@ def login_view( request ):
else:
login_message['error'] = _("invalid credentials")
# Return a 'disabled account' error message
- elif request.method != 'POST':
- pass
else:
login_message['error'] = _("invalid credentials")
login_message['invalid_fields'] = form.errors
@@ -292,7 +300,7 @@ def login_view( request ):
data = shared_context( request, tags=[ "index" ], previous_context=login_message )
- return render_to_response("%s/login.html" % data['template'], RequestContext(request, data ) )
+ return render_to_response('outside/login.html', RequestContext(request, data ) )
@@ -382,7 +390,6 @@ def confirm( request, token, user_id ):
def logout_view( request ):
-
logout( request )
return redirect( 'outside_index' )
View
3  reanalyseapp/globalvars.py
@@ -37,6 +37,7 @@
DOC_CAT_1['col'] = '2.Collection'
DOC_CAT_1['anal'] = '3.Analysis'
DOC_CAT_1['compl'] = '4.Complement'
+DOC_CAT_1['add'] = '5.Complement'
DOC_CAT_1['ese'] = 'ese' # will not be displayed anyway
# B) meta_documents.csv : COLUMN *documentType that are accepted, and their translation in the view
@@ -49,7 +50,7 @@
DOC_CAT_2['inter'] = 'Intermediate'
DOC_CAT_2['methodo'] = 'Method'
DOC_CAT_2['note'] = 'Note'
-DOC_CAT_2['publi'] = 'Publication'
+DOC_CAT_2['prod'] = 'Production'
DOC_CAT_2['revis'] = 'Reused'
DOC_CAT_2['transcr'] = 'Transcription'
View
36 reanalyseapp/imexport.py
@@ -144,6 +144,8 @@ def doFiestaToEnquete(e):
###########################################################################
def importEnqueteUsingMeta(upPath,folderPath):
+ logger.info( "import enquete from:'%s' folder:'%s'" % (upPath, folderPath))
+
stdPath=folderPath+'_meta/meta_study.csv'
docPath=folderPath+'_meta/meta_documents.csv'
spkPath=folderPath+'_meta/meta_speakers.csv'
@@ -200,8 +202,8 @@ def importEnqueteUsingMeta(upPath,folderPath):
newEnquete.metadata = simplejson.dumps(allmeta,indent=4,ensure_ascii=False)
newEnquete.save()
- eidstr = "[enquete_id:"+str(newEnquete.id)+"] " # for logger prefix
-
+ eidstr = "[#"+str(newEnquete.id)+"] " # for logger prefix
+ logger.info("%s enquete '%s':%s created" % ( eidstr, study_name, newEnquete.id ))
### create permission for this enquete
content_type,isnew = ContentType.objects.get_or_create(app_label='reanalyseapp', model='Enquete')
permname = 'EXPLORe_'+str(newEnquete.id)
@@ -212,9 +214,12 @@ def importEnqueteUsingMeta(upPath,folderPath):
logger.info(eidstr+"=========== PARSING META_DOCUMENTS.CSV")
###### Parsing Documents
doc = csv.DictReader(open(docPath),delimiter='\t')
- for row in doc:
+
+ logger.info(eidstr+" %s row found " % doc )
+
+ for counter, row in enumerate(doc):
#try:
- logger.info( "%s storing document " % ( eidstr, row['*id'] ) )
+ logger.info("%s fields : %s" % (eidstr, row ) )
if row['*id']!='*descr':
#try:
file_location = folderPath+row['*file'] # if LINK > url , else REF > nothing
@@ -228,22 +233,19 @@ def importEnqueteUsingMeta(upPath,folderPath):
doc_location = row['*location']
try:
doc_location_geo = row['*location_geo']
- except:
- logger.info( "%s var not found or invalid" % eidstr )
+ except KeyError, e:
+ logger.info( "%s KeyError warning, location_geo field not found or invalid: %s" % (eidstr,e) )
doc_location_geo = ""
-
- #logger.info(eidstr+"doc ref: "+doc_mimetype+" | "+row['*file'])
- #except:
- # logger.info(eidstr+"EXCEPT need *file *mimetype *name *category *location *description in meta_documents.csv")
-
- ### fetch document date
+ # document date
try:
doc_date = datetime.datetime.strptime(row['*date'], "%Y_%m_%d") #"31-12-12"
except:
- logger.exception(eidstr+"EXCEPT malformed or empty date @ "+row['*id']+" | "+row['*file'])
+ logger.info("%s line %s EXCEPT malformed or empty date : %s, supported format 'YYYY_MM_DD'" % ( eidstr, counter, row['*date']))
doc_date = datetime.datetime.today()
+
+
### very special for ese, don't create any texte() model, just parse ese.xml and fill enquete.ese with a json
if doc_mimetype=='ese':
#try:
@@ -257,8 +259,7 @@ def importEnqueteUsingMeta(upPath,folderPath):
elif doc_category1 in DOC_CAT_1.keys() and doc_category2 in DOC_CAT_2.keys():
if doc_mimetype in DOCUMENT_MIMETYPES:
newDocument = Texte(enquete=newEnquete, name=doc_name, doccat1=doc_category1, doccat2=doc_category2, description=doc_description, locationpath=file_location, date=doc_date, location=doc_location, status='1', public=doc_public)
- logger.info(eidstr+"creating document: "+doc_mimetype+" | "+doc_category1+" | "+doc_category2+" | "+file_location)
-
+
newDocument.doctype = doc_mimetype.upper()
if doc_mimetype in ['link','ref']:
@@ -306,9 +307,8 @@ def importEnqueteUsingMeta(upPath,folderPath):
logger.info(eidstr+"EXCEPT unconsidered or empty *mimetype: "+doc_mimetype)
### unknown cat
else:
- logger.info(eidstr+"EXCEPT unconsidered or empty *category: ("+doc_category1+") | ("+doc_category2+")")
-
-
+ logger.warning( "%s at line : %s '*researchPhase':'%s' it is NOT in %s OR '*documentType':'%s' it is NOT in %s" % ( eidstr, counter, doc_category1, DOC_CAT_1.keys(), doc_category2, DOC_CAT_2.keys() ))
+ break
#except:
#logger.info(eidstr+" EXCEPT on meta_document.csv line: "+row['*id'])
else:
View
78 reanalyseapp/models.py
@@ -33,6 +33,8 @@
import django_tables2 as tables
from django.utils.safestring import mark_safe
+from collections import OrderedDict
+
###########################################################################
# LOGGING
###########################################################################
@@ -110,37 +112,57 @@ class Meta:
# ENQUETE
##############################################################################
class Enquete(models.Model):
- #connection_name="enquetes" # todo: one db for each enquete ?
- name = models.CharField(max_length=250)
- uploadpath = models.CharField(max_length=250) # root path of uploaded folder (if we want to remove everything)
- locationpath = models.CharField(max_length=250) # root path of the extracted folder (used as base during import)
- metadata = models.TextField(default='{}') # store all metadata as json dict
- ese = models.TextField() # ese is not yet included/structured in enquete, let's put all infos from ese.xml into a json dict
- status = models.CharField(max_length=2, choices=STATUS_CHOICES) # see globalvars
- statuscomplete = models.BigIntegerField(default=0) # loading 0-100%
- date = models.DateTimeField(auto_now_add=True) # date uploaded
- ddi_id = models.CharField(max_length=170)
-
- tags = models.ManyToManyField( Tag )
-
- #permission = models.ForeignKey(Permission)
- class Meta: # Users & Groups are initialized in views
- permissions = (
- ("can_browse", "BROWSE Can see enquete overview"),
- ("can_explore", "EXPLORE Can see whole enquete"),
- ("can_make", "MAKE Can upload enquetes and make viz"),
- )
- def __unicode__(self):
- return str(self.id)+":"+self.name
- def meta(self):
- if self.metadata:
- return simplejson.loads(self.metadata)
- else:
- return {'metainfo':'no meta was parsed'}
+ #connection_name="enquetes" # todo: one db for each enquete ?
+ name = models.CharField(max_length=250)
+ uploadpath = models.CharField(max_length=250) # root path of uploaded folder (if we want to remove everything)
+ locationpath = models.CharField(max_length=250) # root path of the extracted folder (used as base during import)
+ metadata = models.TextField(default='{}') # store all metadata as json dict
+ ese = models.TextField() # ese is not yet included/structured in enquete, let's put all infos from ese.xml into a json dict
+ status = models.CharField(max_length=2, choices=STATUS_CHOICES) # see globalvars
+ statuscomplete = models.BigIntegerField(default=0) # loading 0-100%
+ date = models.DateTimeField(auto_now_add=True) # date uploaded
+ ddi_id = models.CharField(max_length=170)
+
+ tags = models.ManyToManyField( Tag )
+
+ #permission = models.ForeignKey(Permission)
+ class Meta: # Users & Groups are initialized in views
+ permissions = (
+ ("can_browse", "BROWSE Can see enquete overview"),
+ ("can_explore", "EXPLORE Can see whole enquete"),
+ ("can_make", "MAKE Can upload enquetes and make viz"),
+ )
+ def __unicode__(self):
+ return str(self.id)+":"+self.name
+ def meta(self):
+ if self.metadata:
+ return simplejson.loads(self.metadata)
+ else:
+ return {'metainfo':'no meta was parsed'}
+
+ def meta_items(self):
+ if self.metadata:
+ self.metadata = simplejson.loads(self.metadata)
+
+ sorted_values = {}
+
+ for k in self.metadata['values']:
+ sorted_values[k] = OrderedDict(sorted([x for x in self.metadata['values'][k].iteritems() if isinstance(x[1], dict)], key=lambda x: x[1]['i'] ))
+
+ self.metadata['values'] = sorted_values
+
+
+ return self.metadata
+
+ #return simplejson.loads(self.metadata)
+ else:
+ return {'metainfo':'no meta was parsed'}
+
+
+
####################################################################
-
##############################################################################
class Visualization(models.Model):
enquete = models.ForeignKey(Enquete)
View
59 reanalyseapp/update.py
@@ -4,7 +4,8 @@
#
import sys, os, csv, re
from optparse import OptionParser
-from datetime import datetime
+
+
# get path of the django project
path = ("/").join( sys.path[0].split("/")[:-1] )
@@ -20,15 +21,10 @@
# django specific import
from django.conf import settings
from reanalyseapp.models import Enquete, Texte, Tag
+from datetime import datetime
def update( textes, enquete, csvdict ):
- print """
-
- WELCOME TO APP UPDATER
-
- -------------------------------
-
- """
+
print " %s documents found in enquete: \"%s\", id:%s" % ( textes.count(), enquete.name, enquete.id )
@@ -44,12 +40,11 @@ def update( textes, enquete, csvdict ):
try:
texte_url = row['*file']
texte_name = row['*name']
- locationgeo = re.sub( r'[^0-9\.,]', '', row['*locationgeo'])
+ locationgeo = re.sub( r'[^0-9\.,-]', '', row['*locationgeo'])
researcher = row['*researcher']
article = row['*article']
- date = datetime.strptime(row['*date'], "%Y_%m_%d")
-
- print " date: %s" % date
+ date = datetime.strptime(row['*date'], "%Y_%m_%d") #"31-12-12"
+
except KeyError, e:
print " Field format is not valid: %s " % ( e )
@@ -92,18 +87,52 @@ def update( textes, enquete, csvdict ):
# save location geo
texte.locationgeo = locationgeo
texte.tags.add( t )
+ texte.date = date
texte.save()
#try
+def install( upload_path, enquete_path ) :
+ from imexport import importEnqueteUsingMeta
+ print " from upload path '%s'" % upload_path
+
+ if not os.path.exists( upload_path ):
+ print " upload_path folder '%s' does not exists or it is not readable !" % upload_path
+ print
+ return
+
+ print " from upload path '%s'" % enquete_path
+ if not os.path.exists( enquete_path ):
+ print " enquete_path folder '%s' does not exists or it is not readable !" % enquete_path
+ print
+ return
+
+ print " call importEnqueteUsingMeta (please follow up in log file)"
+ importEnqueteUsingMeta( upload_path, enquete_path )
+ print " installation completed."
+
def main( argv ):
+ print """
+
+ WELCOME TO APP UPDATER
+
+ -------------------------------
+
+ """
parser = OptionParser( usage="\n\n%prog --enquete=34 --csv=/home/dgu/meta_documents.csv" )
- parser.add_option("-c", "--csv", dest="csvfile", help="csv file absolute path")
- parser.add_option("-e", "--enquete", dest="enquete_id", help="enquete identifier")
+ parser.add_option("-c", "--csv", dest="csvfile", help="csv file absolute path", default="" )
+ parser.add_option("-e", "--enquete", dest="enquete_id", help="enquete identifier", default=0 )
+ parser.add_option("-p", "--upload_path", dest="upload_path", help="enquete upload path", default="" ) #use with --func=install
+ parser.add_option("-x", "--enquete_path", dest="enquete_path", help="enquete extracted path", default="" ) #use with --func=install
+ parser.add_option("-f", "--function", dest="func", help="update function", default="update" )
( options, argv ) = parser.parse_args()
+ if options.func == "install" :
+ # install the enquete
+ return install( options.upload_path, options.enquete_path )
+
if options.enquete_id is None:
error("enquete_id arg not found!", parser)
@@ -152,4 +181,4 @@ def error( message="generic error", parser=None):
# execute srcipt
if __name__ == '__main__':
- main(sys.argv[1:])
+ main(sys.argv[1:])
View
43 static/css/enquete.less
@@ -107,30 +107,21 @@
stroke-width: 0;
fill: @cyan;
- cursor: pointer;
-
&.dot {
+ cursor: pointer;
fill-opacity: @path_opacity;
-
- &:hover {
- fill-opacity: @path_opacity_hover;
- }
- &.active {
- }
- &.inactive {
- fill: white;
- }
+ &:hover { fill-opacity: @path_opacity_hover; }
+ &.inactive { fill: white; }
}
&.background {
+ cursor: pointer;
fill-opacity: .1;
-
- &:hover {
- fill-opacity: .4;
- }
+ &:hover { fill-opacity: .4; }
}
&.line {
+ cursor: pointer;
fill-opacity: 1;
}
}
@@ -138,6 +129,7 @@
text {
+ cursor: pointer;
fill: @cyan;
font-family: LatinModernSans10Regular, sans-serif;
font-size: 14px;
@@ -153,15 +145,22 @@
- .brush .extent {
- stroke-width: 0px;
- fill: @cyan;
- fill-opacity: .2;
- shape-rendering: crispEdges;
+ .brush {
+
+ .extent {
+ stroke-width: 0px;
+ fill: @cyan;
+ fill-opacity: .2;
+ shape-rendering: crispEdges;
+ }
+
+ .background {
+ // visibility: visible !important;
+ }
}
- .axis {
+ .axis {
path, line {
fill: none;
stroke: @cyan;
@@ -260,7 +259,7 @@
#right-sidebar {
- color: #d4d1cd;
+ color: #d4d1cd;
#reset {
padding: 4px 18px;
View
3  static/css/themes/app.less
@@ -2200,7 +2200,7 @@ table.meta{
border-spacing: 0px;
padding:0;
margin:0;
-
+
tr{
border-spacing:0px;
@@ -2218,6 +2218,7 @@ table.meta{
.serif-slant(14px);
text-align:left;
padding: 0 @grid-padding/2 0 @grid-padding/3;
+
}
}
View
50 static/js/outside/enq.js
@@ -37,19 +37,25 @@ oo.nest = function( objects, nester, sorter ){
for (var d in objects){
- // Check if data are available
+ // Define object
var index = nester( objects[d] );
- if (index == null ){ continue; }
+ // Check consistency of data
+ if ( index == null || index.length == 0 ) continue;
+ // Skip not filtered elements
+ if ( typeof objects[d].filtered != 'undefined' ) {
+ if (objects[d].filtered == 'false') continue;
+ }
+
+ // Check group existence
if (typeof nested[ index ] == "undefined"){
nested[ index ] = { "key": index, "values":[] };
}
- if ( (typeof objects[d].filtered == 'undefined' ) || ( objects[d].filtered == true ) ) {
- nested[ index ].values.push( objects[d] )
- }
+ // Push element
+ nested[ index ].values.push( objects[d] )
}
// refactoring array
@@ -65,27 +71,27 @@ oo.nest = function( objects, nester, sorter ){
//
//
-oo.count = function( objects, nester, sorter ){
+// oo.count = function( objects, nester, sorter ){
- nested = {};
+// nested = {};
- for (d in objects){
+// for (d in objects){
- var index = nester( objects[d] );
+// var index = nester( objects[d] );
- if (typeof nested[ index ] == "undefined"){
- nested[ index ] = { "key": index, "count":0 };
- }
-
- if ( (typeof objects[d].filtered == 'undefined' ) || ( objects[d].filtered == true ) ) {
- nested[ index ].count++;
- }
- }
-
- // refactoring array
- var remapped = []; for( var i in nested ){ remapped.push( nested[i] );}
- return remapped.sort( sorter );
-}
+// if (typeof nested[ index ] == "undefined"){
+// nested[ index ] = { "key": index, "count":0 };
+// }
+
+// if ( (typeof objects[d].filtered == 'undefined' ) || ( objects[d].filtered == true ) ) {
+// nested[ index ].count++;
+// }
+// }
+
+// // refactoring array
+// var remapped = []; for( var i in nested ){ remapped.push( nested[i] );}
+// return remapped.sort( sorter );
+// }
View
72 static/js/outside/enq_documents.js
@@ -8,30 +8,36 @@ oo.enq.docs.update = function( event, filters ){
oo.log("[oo.enq.docs.update]");
- var docs = d3.select('#documents ul'),
- counter = d3.select('#counter span.docNumber')
- container = d3.select('#counter p'),
- meter = 0;
+ var meter = 0;
- var items = docs.selectAll('li').each(function(d, i) {
+
+ // Copy old status
+
+ oo.enq.docs.li.each(function(d, i) {
item = d3.select(this);
item.attr('data-status-old', item.attr('data-status'));
- }); // Copy new status to old status
+ });
+
+ // Set new status
+
for ( var i in oo.filt.data ) {
- var item = docs.select('li[data-id="' + oo.filt.data[i].id + '"]');
+
+ var item = oo.enq.docs.ul.select('[data-id="' + oo.filt.data[i].id + '"]');
+
if ( oo.filt.data[ i ].filtered ) {
item.attr('data-status', 'active');
meter++;
} else {
item.attr('data-status', 'inactive');
}
- } // Set active
+
+ }
- // Hide / Show list's
+ // Hide / Show Itemss
- items.each(function() {
+ oo.enq.docs.li.each(function() {
var item = d3.select(this),
oldStatus = item.attr('data-status-old'),
@@ -45,21 +51,23 @@ oo.enq.docs.update = function( event, filters ){
})
- if ( meter != counter.attr('data-previous') ) {
+ // Update Counter
+
+ if ( meter != oo.enq.docs.counter.attr('data-previous') ) {
var delay = 800;
- container.transition()
+ oo.enq.docs.container.transition()
.duration(delay / 2)
.style('margin-top', '35px');
- counter.transition()
+ oo.enq.docs.counter.transition()
.duration(1)
.delay(delay)
- .text( meter + '/' + counter.attr('data-total') )
+ .text( meter + '/' + oo.enq.docs.counter.attr('data-total') )
.attr('data-previous', meter);
- container.transition()
+ oo.enq.docs.container.transition()
.delay(delay * 1.2)
.duration(delay)
.style('margin-top', '0px');
@@ -69,15 +77,19 @@ oo.enq.docs.update = function( event, filters ){
};
+
+
+
+
oo.enq.docs.init = function ( objects ){
oo.filt.on( oo.filt.events.change, oo.enq.docs.update );
- var counter = d3.select('#counter span.docNumber'),
- total = d3.select('#counter span.docTotal'),
- docs = d3.select('#documents ul'),
- container = d3.select('#counter p'),
- map = objects.sort(function (a, b){
+ oo.enq.docs.counter = d3.select('#counter span.docNumber');
+ oo.enq.docs.ul = d3.select('#documents ul');
+ oo.enq.docs.container = d3.select('#counter p');
+
+ var map = objects.sort(function (a, b){
return a.title > b.title ? 1 : a.title < b.title ? -1 : 0
})
@@ -98,7 +110,7 @@ oo.enq.docs.init = function ( objects ){
// Create Documents
- var li = docs.selectAll("li")
+ oo.enq.docs.li = oo.enq.docs.ul.selectAll("li")
.data(map)
.enter().append("li")
.attr('class', 'active')
@@ -106,27 +118,23 @@ oo.enq.docs.init = function ( objects ){
.attr('data-status', 'active')
.html(function(d) {
- var string = d.title.split('_').join(' ').split('/').join(' ') + '<br/>';
- if (typeof d.type != 'undefined' ) string += '<i>'+d.type+'</i>'
- if (typeof d.phases[0].phase != 'undefined' ) string += '<i>'+d.phases[0].phase+'</i>'
- if (typeof d.categories[0].category != 'undefined' ) string += '<i>'+d.categories[0].category+'</i>'
- if ( d.articles.length != 0 ) string += '<i>'+d.articles[0].article+'</i>'
+ var string = d.title + '<br/>';
+ if (typeof d.date != 'undefined' ) string += '<i>' + d.date.substring(5, 7) + '/' + d.date.substring(0, 4) + '</i>'
+ if (typeof d.coordinates.properties.name != 'undefined' ) string += '<i>'+d.coordinates.properties.name+'</i>'
return string;
})
.on('click', function(d, i) {
- // oo.log('this', this)
- // oo.log('id', d3.select(this).attr('data-id'))
window.open( oo.api.urlfactory( oo.urls.get_document, d3.select(this).attr('data-id') ), '_blank');
});
// Set Documents' Counter
- counter.text(li[0].length + '/' + li[0].length)
- .attr('data-total', li[0].length)
- .attr('data-previous', li[0].length);
+ oo.enq.docs.counter.text( oo.enq.docs.li[0].length + '/' + oo.enq.docs.li[0].length)
+ .attr('data-total', oo.enq.docs.li[0].length)
+ .attr('data-previous', oo.enq.docs.li[0].length);
- container.transition()
+ oo.enq.docs.container.transition()
.duration(500)
.style('margin-top', '0px');
View
7 static/js/outside/enq_map.js
@@ -24,8 +24,9 @@ oo.enq.map.update = function( event, filters ){
for ( var i in oo.filt.data ) {
- if ( oo.filt.data[i].location == null) continue; // Manage null location
- if ( oo.filt.data[i].filtered == false) continue; // Manage filtered items
+ if ( oo.filt.data[i].location == null
+ || oo.filt.data[i].location.length == 0
+ || oo.filt.data[i].filtered == false ) continue; // Manage null location
for ( var j = 0; j <= nest.features.length; j++ ) {
@@ -90,7 +91,7 @@ oo.enq.map.init = function ( objects ){
var j, exist = false;
- if ( objects[i].location == null) continue;
+ if ( objects[i].location == null || objects[i].location.length == 0 ) continue;
for ( j = 0; j <= nest.features.length; j++ ) {
if ( typeof nest.features[j] == 'undefined' ) break;
View
312 static/js/outside/enq_timeline.js
@@ -5,110 +5,69 @@
//
//
-var format = d3.time.format("%Y-%m-%d"),
+var format = oo.filt.parser.datetime,
size = {
width : $('#timeline').width(),
height : $('#timeline').height(),
chartHeight : $('#timeline').height() * 9 / 11,
brushHeight : $('#timeline').height() * 2 / 11
},
- margin = { top: 30 },
- steps = 7;
+ margin = { top: 30 };
-oo.enq.timeline.update = function( event, filters ){
-
- oo.log("[oo.enq.timeline.update]");
-
-
- // var map = oo.nest( objects,
- // function( d ){ return format.parse(d.date).getTime() },
- // function (a, b){ return a.values.length < b.values.length ? 1 : a.values.length > b.values.length ? -1 : 0 }
- // )
- // oo.log('objects', objects)
- // oo.log('map', map)
-
-
-
- // Collect useful fields
-
- for (i in oo.filt.data) {
- if ( !collection ) var collection = [];
- if ( oo.filt.data[ i ].filtered == true ) {
- collection.push({
- time : format.parse(oo.filt.data[i].times[0].time).getTime(),
- id : oo.filt.data[i].id
- });
- }
- }
- // oo.log('collection', collection)
+oo.enq.timeline.update = function( event, filters ){
- // X Axes set up
+ oo.log("[oo.enq.timeline.update]");
- var minX = d3.min(oo.data.objects, function (d) { return format.parse(d.times[0].time).getTime() }),
- maxX = d3.max(oo.data.objects, function (d) { return format.parse(d.times[0].time).getTime() }),
- unit = ( maxX - minX ) / steps,
- ticks = [],
- density = {};
+ // Nest
- var scaleX = d3.time.scale()
- .domain([ minX, maxX ])
- .range([ 0, size.width ]);
+ var nest = oo.nest( oo.filt.data,
+ function( d ){
+ return format.parse(d.date).getFullYear()
+ },
+ function (a, b){
+ return a.key < b.key ? -1 : a.key > b.key ? 1 : 0 }
+ );
- for (var i=0; i <= steps; i++) {
- ticks.push(minX + unit * i);
- };
+ oo.log('nest', nest)
- // Density[] is the structure for timeline
+ // Set variables
- for (var j = 0; j < steps; j++) {
-
- if ( j == 0 ) density = []; // Initialize array
-
- if ( !density[j] ) {
- density[j] = {};
- density[j].freq = 0;
- density[j].id = [];
- density[j].time = ( ticks[j] + ticks[j+1] ) * .5;
- }
-
- for (var i in collection) {
- if ( ticks[j] <= collection[i].time && collection[i].time <= ticks[j+1] ) {
- density[j].freq++;
- density[j].id.push(collection[i].id);
- }
- }
- }
+ var steps = oo.enq.timeline.steps,
+ rectWidth = oo.enq.timeline.rectWidth,
+ minX = oo.enq.timeline.minX,
+ maxX = oo.enq.timeline.maxX,
+ rectTime = oo.enq.timeline.rectTime,
+ scaleX = oo.enq.timeline.scaleX,
+ scaleY = oo.enq.timeline.scaleY;
// Animate objects
oo.enq.timeline.rectangles.dots
- .data(density)
+ .data(nest)
.transition()
.duration(1000)
.attr('class', 'dot active')
- .attr("y", function(d) { return - scaleY(d.freq) })
- .attr("height", function(d) { return scaleY(d.freq) })
+ .attr("y", function(d) { return - scaleY(d.values.length) })
+ .attr("height", function(d) { return scaleY(d.values.length) })
.attr("data-id", function(d) { return d.id; });
oo.enq.timeline.rectangles.lines
- .data(density)
+ .data(nest)
.transition()
.duration(1000)
- .attr("y", function(d) { return - scaleY(d.freq) - 3; })
- .attr("data-id", function(d) { return d.id; });
+ .attr("y", function(d) { return - scaleY(d.values.length) - 3; })
oo.enq.timeline.rectangles.texts
- .data(density)
- .text( function (d) { return d.freq } )
- .attr("data-id", function(d) { return d.id; })
+ .data(nest)
+ .text( function (d) { return d.values.length } )
.transition()
.duration(1000)
- .attr("y", function(d) { return - scaleY(d.freq) - 5; });
+ .attr("y", function(d) { return - scaleY(d.values.length) - 5; });
};
@@ -120,83 +79,62 @@ oo.enq.timeline.init = function( objects ){
oo.filt.on( oo.filt.events.change, oo.enq.timeline.update );
- // Collect useful fields
+ // Nest
- var collection = d3.range(objects.length).map(function(i) {
- return {
- time : format.parse(objects[i].times[0].time).getTime(),
- id : objects[i].id
- };
- });
+ var nest = oo.nest( objects,
+ function( d ){
+ return format.parse(d.date).getFullYear()
+ },
+ function (a, b){
+ return a.key < b.key ? -1 : a.key > b.key ? 1 : 0 }
+ );
- // X Axes set up
+ // Set variables
- var minX = d3.min(collection, function (d) { return d.time }),
- maxX = d3.max(collection, function (d) { return d.time }),
- unit = ( maxX - minX ) / steps,
- ticks = [],
- density = {};
+ var steps = nest.length,
+ rectWidth = d3.round( ( size.width - 100 ) / (steps) );
- var scaleX = d3.time.scale()
- .domain([ minX, maxX ])
- .range([ 0, size.width - 100 ]);
-
- for (var i=0; i <= steps; i++) {
- ticks.push(minX + unit * i);
- }; // Computation of ticks
-
- // Density[] is the structure for timeline
+ oo.enq.timeline.minX = new Date(d3.min(objects, function (d) { return format.parse(d.date) }));
+ oo.enq.timeline.maxX = new Date(d3.max(objects, function (d) { return format.parse(d.date) }));
+
+ var rectTime = ( oo.enq.timeline.maxX - oo.enq.timeline.minX ) / ( steps - 1 );
- for (var j = 0; j < steps; j++) {
+ oo.enq.timeline.minY = 0;
+ oo.enq.timeline.maxY = d3.max(nest, function (d) { return d.values.length });
+ oo.enq.timeline.steps = steps;
+ oo.enq.timeline.rectWidth = rectWidth;
+ oo.enq.timeline.rectTime = rectTime;
- if ( j == 0 ) density = []; // Initialize array
+ // Round scale edges
- if ( !density[j] ) {
- density[j] = {};
- density[j].freq = 0;
- density[j].id = [];
- density[j].time = ( ticks[j] + ticks[j+1] ) * .5;
- }
-
- for (var i in collection) {
- if ( ticks[j] <= collection[i].time && collection[i].time <= ticks[j+1] ) {
- density[j].freq++;
- density[j].id.push(collection[i].id);
- }
- }
- }
+ oo.enq.timeline.minX.setDate(1);
+ oo.enq.timeline.minX.setMonth(0);
+ oo.enq.timeline.maxX.setDate(1);
+ oo.enq.timeline.maxX.setMonth(12);
- // Y Axes set up
+ // Set scales
- var minY = 0,
- maxY = d3.max(density, function (d) { return d.freq }),
- rectWidth = d3.round( ( size.width - 100 ) / steps );
-
- scaleY = d3.scale.linear()
- .domain([minY, maxY])
- .range([ 0, size.chartHeight - margin.top ]); // Bar chart height
+ var scaleX = d3.time.scale()
+ .domain([ oo.enq.timeline.minX, oo.enq.timeline.maxX ])
+ .range([ 0, size.width - 100 ]),
+ scaleY = d3.scale.linear()
+ .domain([oo.enq.timeline.minY, oo.enq.timeline.maxY])
+ .range([ 0, size.chartHeight - margin.top ]);
- // Draw shape
+ oo.enq.timeline.scaleX = scaleX;
+ oo.enq.timeline.scaleY = scaleY;
- var svg = d3.select('#timeline').append('svg');
+ // Containers
- // oo.enq.timeline.background = svg.append('g').attr("transform", "translate(0, " + size.chartHeight + ")");
- oo.enq.timeline.rectangles = svg.append('g').attr("transform", "translate(50, " + size.chartHeight + ")");
- oo.enq.timeline.axis = svg.append('g').attr("transform", "translate(50, " + size.chartHeight + ")").attr('class', 'axis');
- oo.enq.timeline.brush = svg.append('g').attr("transform", "translate(50, " + size.height + ")");
+ oo.enq.timeline.svg = d3.select('#timeline').append('svg');
+ oo.enq.timeline.rectangles = oo.enq.timeline.svg.append('g').attr("transform", "translate(50, " + size.chartHeight + ")");
+ oo.enq.timeline.axis = oo.enq.timeline.svg.append('g').attr("transform", "translate(50, " + size.chartHeight + ")").attr('class', 'axis');
+ oo.enq.timeline.brush = oo.enq.timeline.svg.append('g').attr("transform", "translate(50, " + size.height + ")").attr("class", "brush");
// Axis
- for (var j = 0; j < ticks.length; j++) {
- if ( j == 0 ) var ticksTime = [];
- ticksTime.push(new Date(ticks[ j ]));
- } // Array of date ticks
-
var axis = d3.svg.axis()
- .scale(scaleX)
- .ticks(ticksTime.length)
- .tickValues(ticksTime)
- .tickFormat(d3.time.format("%m-%Y"));
+ .scale(scaleX);
oo.enq.timeline.axis.call(axis);
@@ -205,102 +143,84 @@ oo.enq.timeline.init = function( objects ){
var onClick = function(obj) {
var domain = scaleX.domain(),
circleTime = scaleX.invert( d3.select(obj).attr('x') ).getTime(),
- b = [circleTime, circleTime + unit],
+ b = [circleTime, circleTime + rectTime],
brushWidth = scaleX(b[1]) - scaleX(b[0]);
+
d3.select("rect.extent")
.transition()
.duration(1000)
.attr('x', scaleX(b[0]) )
.attr('width', brushWidth ); // Width is fixed
+
setTimeout( function() {
- oo.enq.timeline.brush.call(brushObj.extent([b[0], b[1]]));
- oo.filt.trigger( oo.filt.events.replace, { 'period': normBounds(b) } );
+ oo.enq.timeline.brush.call(brush.extent([b[0], b[1]]));
+ oo.filt.trigger( oo.filt.events.replace, { 'period': b } );
}, 1000 );
}
oo.enq.timeline.rectangles.backgrounds = oo.enq.timeline.rectangles.selectAll(".background")
- .data(density)
+ .data(nest)
.enter().append('rect')
- .attr('class', 'background')
- .attr("x", function(d) { return scaleX(d.time) - rectWidth * .5 ; })
- .attr("y", function(d) { return - scaleY(d.freq) })
- .attr("width", rectWidth)
- .attr("height", function(d) { return scaleY(d.freq) })
- .attr("data-id", function(d) { return d.id; })
- .on("click", function() { onClick(this); })
+ .attr('class', 'background')
+ .attr("x", function(d, i) { return i * rectWidth })
+ .attr("y", function(d) { return - scaleY(d.values.length) })
+ .attr("width", rectWidth)
+ .attr("height", function(d) { return scaleY(d.values.length) })
+ .attr("data-id", function(d) { return d.key; })
+ .on("click", function() { onClick(this); })
oo.enq.timeline.rectangles.dots = oo.enq.timeline.rectangles.selectAll(".dot")
- .data(density)
+ .data(nest)
.enter().append('rect')
- .attr('class', 'dot active')
- .attr("x", function(d) { return scaleX(d.time) - rectWidth * .5 ; })
- .attr("y", function(d) { return - scaleY(d.freq) })
- .attr("width", rectWidth)
- .attr("height", function(d) { return scaleY(d.freq) })
- .attr("data-id", function(d) { return d.id; })
- .on("click", function() { onClick(this); })
+ .attr('class', 'dot active')
+ .attr("x", function(d, i) { return i * rectWidth })
+ .attr("y", function(d) { return - scaleY(d.values.length) })
+ .attr("width", rectWidth)
+ .attr("height", function(d) { return scaleY(d.values.length) })
+ .attr("data-id", function(d) { return d.key })
+ .on("click", function() { onClick(this); })
oo.enq.timeline.rectangles.texts = oo.enq.timeline.rectangles.selectAll("text")
- .data(density)
+ .data(nest)
.enter().append('text')
- .text( function (d) { return d.freq } )
- .attr("x", function(d) { return scaleX(d.time) - rectWidth * .5 + 2; })
- .attr("y", function(d) { return - scaleY(d.freq) - 5})
- .on("click", function() { onClick(this); });
+ .text( function (d) { return d.values.length } )
+ .attr("x", function(d, i) { return i * rectWidth + 2; })
+ .attr("y", function(d) { return - scaleY(d.values.length) - 5})
+ .on("click", function() { onClick(this); });
oo.enq.timeline.rectangles.lines = oo.enq.timeline.rectangles.selectAll(".line")
- .data(density)
+ .data(nest)
.enter().append('rect')
- .attr('class', 'line')
- .attr("x", function(d) { return scaleX(d.time) - rectWidth * .5 ; })
- .attr("y", function(d) { return - scaleY(d.freq) - 3})
- .attr("width", rectWidth)
- .attr("height", '1')
- .on("click", function() { onClick(this); });
-
-
-
-
+ .attr('class', 'line')
+ .attr("x", function(d, i) { return i * rectWidth })
+ .attr("y", function(d) { return - scaleY(d.values.length) - 3})
+ .attr("width", rectWidth)
+ .attr("height", '1')
+ .on("click", function() { onClick(this); });
// Brush
- var brushObj = d3.svg.brush();
+ var brush = d3.svg.brush()
+ .x(scaleX)
+ // .extent(scaleX.domain()) // Used to set the initial
+ .on("brushend", brushEnd);
- oo.enq.timeline.brush.attr("class", "x brush")
- .call(brushObj.x(scaleX)
- .extent(scaleX.domain())
- .on("brushend", brushEnd))
- .selectAll("rect")
+ oo.enq.timeline.brush.call(brush);
+
+ oo.enq.timeline.brush.selectAll("rect")
.attr("y", - size.brushHeight )
- .attr("height", size.brushHeight );
+ .attr("height", size.brushHeight )
- d3.select('rect.extent').attr("class", "extent transition");
+ oo.enq.timeline.brush.extent = d3.select('.brush > .extent');
+ oo.enq.timeline.brush.background = d3.select('.brush > .background');
+ // Activate filter
+
function brushEnd() {
- var b = brushObj.empty() ? scaleX.domain() : brushObj.extent(); // this returns a period of time
+ var b = brush.empty() ? scaleX.domain() : brush.extent(); // this returns a period of time
b = [ b[0].getTime(), b[1].getTime() ];
- oo.filt.trigger( oo.filt.events.replace, { 'period': normBounds(b) } );
+ oo.filt.trigger( oo.filt.events.replace, { 'period': b } );
}
-
- // To round bounds limit according to ticks[]
-
- function normBounds( bounds ) {
-
- for ( var i = ticks.length; i >= 0; i-- ) {
- if ( bounds[0] + unit / 2 >= ticks[i] ) {
- bounds[0] = ticks[i] - 1;
- break;
- }
- }
- for ( var i = 0; i <= ticks.length; i++ ) {
- if ( bounds[1] - unit / 2 <= ticks[i] ) {
- bounds[1] = ticks[i] + 1;
- break;
- }
- }
- return bounds;
- };
-
};
View
3  static/js/outside/filters.js
@@ -40,7 +40,8 @@ oo.filt.cross = oo.filt.cross || {
},
'period': function( item, filter ){
if ( item.times.length == 0 ) return true;
- var item_time = oo.filt.parser.datetime.parse( item.times[0].time ).getTime();
+ // Set time in the middle of the year
+ var item_time = oo.filt.parser.datetime.parse( item.times[0].time.split('-')[0] + '-06-15' ).getTime();
return item_time > filter[0] && item_time < filter[1];
},
'category': function( item, filter ){
View
24 static/xsl/tei.xsl
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+
+<xsl:output method="html" indent="no"/>
+
+<xsl:template match="/|comment()|processing-instruction()">
+ <h2>Hello</h2>
+ <xsl:apply-templates/>
+
+
+</xsl:template>
+
+<xsl:template match="teiHeader">
+ <!-- teiHeader -->
+</xsl:template>
+
+<xsl:template match="text">
+ <xsl:for-each select="body/div/u">
+ fefe
+ </xsl:for-each>
+</xsl:template>
+
+
+</xsl:stylesheet>

No commit comments for this range

Something went wrong with that request. Please try again.