diff --git a/app/event/models.py b/app/event/models.py index 8269534..d7bf0c2 100644 --- a/app/event/models.py +++ b/app/event/models.py @@ -32,31 +32,34 @@ class Event(models.Model): @property def display_date(self): - date = self.date.split(' ') - start = date[0].split('-') - if len(date) > 1: - end = date[1].split('-') - else: - end = start - end_only_month = False - start_only_month = False - while len(end) < 3: - end.append(1) - end_only_month = True - while len(start) < 3: - start.append(1) - start_only_month = True - start = [int(p) for p in start] - end = [int(p) for p in end] + if self.date: + date = self.date.split(' ') + start = date[0].split('-') + if len(date) > 1: + end = date[1].split('-') + else: + end = start + end_only_month = False + start_only_month = False + while len(end) < 3: + end.append(1) + end_only_month = True + while len(start) < 3: + start.append(1) + start_only_month = True + start = [int(p) for p in start] + end = [int(p) for p in end] - display_date = datetime(*start).strftime('%d %B, %Y') - if start_only_month: - display_date = ' '.join(display_date.split(' ')[1:]) - if end != start: - end_date = datetime(*end).strftime('%d %B, %Y') - if end_only_month: - end_date = ' '.join(end_date.split(' ')[1:]) - display_date += ' — ' + end_date + display_date = datetime(*start).strftime('%e %B, %Y') + if start_only_month: + display_date = ' '.join(display_date.split(' ')[1:]) + if end != start: + end_date = datetime(*end).strftime('%e %B, %Y') + if end_only_month: + end_date = ' '.join(end_date.split(' ')[1:]) + display_date += ' — ' + end_date + else: + display_date = '' return display_date def media_html(self): diff --git a/app/event/views.py b/app/event/views.py index 52d6bf6..4e1e329 100644 --- a/app/event/views.py +++ b/app/event/views.py @@ -7,13 +7,14 @@ from .models import Event from ..page.models import Page -def index(request, slug=''): +def events(request, slug=''): context = {} context['settings'] = settings context['events'] = Event.objects.all().order_by('position') context['postscript'], c = Page.objects.get_or_create(slug='postscript') context['intro'], c = Page.objects.get_or_create(slug='intro') - return render(request, 'index.html', context) + return render(request, 'events.html', context) + def timeline(request): context = {} diff --git a/app/static/css/partials/_layout.scss b/app/static/css/partials/_layout.scss index b916f91..ba7605e 100644 --- a/app/static/css/partials/_layout.scss +++ b/app/static/css/partials/_layout.scss @@ -6,6 +6,11 @@ margin: auto; } +.reference { + color: #333; + font-size: 11px; +} + p { } diff --git a/app/static/timeline/js/timeline.js b/app/static/timeline/js/timeline.js index d0e8595..6314de4 100644 --- a/app/static/timeline/js/timeline.js +++ b/app/static/timeline/js/timeline.js @@ -2699,7 +2699,7 @@ this._timenav.updateDisplay(this.options.width,this.options.timenav_height,e),th // Apply class this._el.container.className=a}, // Update hashbookmark in the url bar -_updateHashBookmark:function(t){var e="#event-"+t.toString();"file:"!=window.location.protocol&&window.history.replaceState(null,"Browsing TimelineJS",e),this.fire("hash_updated",{unique_id:this.current_id,hashbookmark:"#event-"+t.toString()},this)}, +_updateHashBookmark:function(t){var e="#"+t.toString();"file:"!=window.location.protocol&&window.history.replaceState(null,"Browsing TimelineJS",e),this.fire("hash_updated",{unique_id:this.current_id,hashbookmark:"#"+t.toString()},this)}, /* Init ================================================== */ // Initialize the data @@ -2754,4 +2754,4 @@ _onDataLoaded:function(t){this.fire("dataloaded"),this._initLayout(),this._initE */ zoomIn:function(){this._timenav.zoomIn()},zoomOut:function(){this._timenav.zoomOut()},setZoom:function(t){this._timenav.setZoom(t)},_onZoomIn:function(t){this._timenav.zoomIn(),this.fire("zoom_in",{zoom_level:this._timenav.options.scale_factor},this)},_onZoomOut:function(t){this._timenav.zoomOut(),this.fire("zoom_out",{zoom_level:this._timenav.options.scale_factor},this)},_onTimeNavLoaded:function(){this._loaded.timenav=!0,this._onLoaded()},_onStorySliderLoaded:function(){this._loaded.storyslider=!0,this._onLoaded()},_onStorySliderNext:function(t){this.fire("nav_next",t)},_onStorySliderPrevious:function(t){this.fire("nav_previous",t)},_onLoaded:function(){this._loaded.storyslider&&this._loaded.timenav&&(this.fire("loaded",this.config), // Go to proper slide -this.options.hash_bookmark&&""!=window.location.hash?this.goToId(window.location.hash.replace("#event-","")):(TL.Util.isTrue(this.options.start_at_end)||this.options.start_at_slide>this.config.events.length?this.goToEnd():this.goTo(this.options.start_at_slide),this.options.hash_bookmark&&this._updateHashBookmark(this.current_id)))}}),TL.Timeline.source_path=function(){var t=document.getElementsByTagName("script"),e=t[t.length-1].src;return e.substr(0,e.lastIndexOf("/"))}(); \ No newline at end of file +this.options.hash_bookmark&&""!=window.location.hash?this.goToId(window.location.hash.replace("#","")):(TL.Util.isTrue(this.options.start_at_end)||this.options.start_at_slide>this.config.events.length?this.goToEnd():this.goTo(this.options.start_at_slide),this.options.hash_bookmark&&this._updateHashBookmark(this.current_id)))}}),TL.Timeline.source_path=function(){var t=document.getElementsByTagName("script"),e=t[t.length-1].src;return e.substr(0,e.lastIndexOf("/"))}(); diff --git a/app/templates/index.html b/app/templates/events.html similarity index 100% rename from app/templates/index.html rename to app/templates/events.html diff --git a/app/templates/timeline.html b/app/templates/timeline.html index ebb5cc0..9125b71 100644 --- a/app/templates/timeline.html +++ b/app/templates/timeline.html @@ -1,12 +1,12 @@ - - +{% load sass_tags static %} +