Skip to content

Commit

Permalink
Merge branch 'release/0.4.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
Max Hellwig committed Aug 21, 2015
2 parents a74fefd + 1a592ea commit be6e40c
Show file tree
Hide file tree
Showing 9 changed files with 97 additions and 76 deletions.
6 changes: 5 additions & 1 deletion Readme.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# django-timelinejs3

## currently in alpha state because it was developed on friday midnight...
## a django app for http://timeline3.knightlab.com/

### currently in alpha state because it was developed on friday midnight...



* clone it
* set up your localsettings.py, rename .template and fill
Expand Down
6 changes: 4 additions & 2 deletions django-timelinejs3/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
urlpatterns = [
url(r'^admin/', include(admin.site.urls)),
# name = app_(model)_action
url(r'^timeline/$', timeline_views.IndexView.as_view(), name='timeline_index'),
url(r'^timeline/latest$', timeline_views.IndexView.as_view(), name='timeline_index_latest'),
url(r'^timeline/(?P<timeline_id>[\d]+)/$', timeline_views.IndexView.as_view(), name='timeline_detail'),

url(r'^timeline/data/$', timeline_views.index_data, name='timeline_index_data'),
url(r'^timeline/data/latest$', timeline_views.index_data, {'timeline_id': 'latest'}, name='timeline_index_data_latest'),
url(r'^timeline/data/(?P<timeline_id>[\d]+)/$', timeline_views.index_data, name='timeline_index_data'),
]
2 changes: 2 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
Django==1.8
Jinja2==2.7.3
Markdown==2.5.2
MarkupSafe==0.23
django-debug-toolbar==1.2.2
django-jinja==1.1.1
django-model-utils==2.3.1
django-pipeline==1.4.6
django-taggit==0.12.2
futures==2.2.0
Expand Down
32 changes: 32 additions & 0 deletions templates/base.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{% load static %}
<!doctype html>
<html class="no-js" lang="">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>timelinejs</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/3.0.3/normalize.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/foundation/5.5.2/css/foundation.min.css">
<link rel="stylesheet" href="{% static 'css/timeline.css' %}">

<link rel="stylesheet" href="{% static 'css/main.css' %}">
</head>
<body>

<div class="row">
<div class="small-12">
{% block content %}{% endblock content %}
</div>

</div>

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.4/jquery.js"></script>
<script>window.jQuery || document.write('<script src="js/vendor/jquery-2.1.4.min.js"><\/script>')</script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/foundation/5.5.2/js/foundation.min.js"></script>
<script src="{% static 'js/plugins.js' %}"></script>
<script src="{% static 'js/main.js' %}"></script>
</body>
</html>
113 changes: 45 additions & 68 deletions templates/index.html
Original file line number Diff line number Diff line change
@@ -1,77 +1,54 @@
{% extends 'base.html' %}
{% load static %}
<!doctype html>
<html class="no-js" lang="">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>timelinejs</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/3.0.3/normalize.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.5/css/bootstrap.min.css">
<link rel="stylesheet" href="{% static 'css/timeline.css' %}">

<link rel="stylesheet" href="{% static 'css/main.css' %}">
</head>
<body>

<div class="container-fluid">
{% block content %}
<div id="timeline-embed">
<div id="timeline"></div>
</div>
</div>

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.4/jquery.js"></script>
<script>window.jQuery || document.write('<script src="js/vendor/jquery-2.1.4.min.js"><\/script>')</script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.5/js/bootstrap.min.js"></script>
<script src="{% static 'js/timeline.js' %}"></script>
<script src="{% static 'js/plugins.js' %}"></script>
<script src="{% static 'js/main.js' %}"></script>
<script>
$(document).ready(function () {
var embed = document.getElementById('timeline-embed');
embed.style.height = getComputedStyle(document.body).height;
var timeline = new VCO.Timeline('timeline-embed', '{% url 'timeline_index_data' %}', {});
window.addEventListener('resize', function () {
<script src="{% static 'js/timeline.js' %}"></script>
<script>
$(document).ready(function () {
var embed = document.getElementById('timeline-embed');
embed.style.height = getComputedStyle(document.body).height;
timeline.options = {
script_path: "{{ options.script_path }}",
timenav_position: {{ options.timenav_position }},
height: this._el.container.offsetHeight || {{ options.height }},
width: this._el.container.offsetWidth || {{ options.width }},
scale_factor: {{ options.scale_factor }}, // How many screen widths wide should the timeline be
layout: "{{ options.layout }}", // portrait or landscape
optimal_tick_width: {{ options.optimal_tick_width }}, // optimal distance (in pixels) between ticks on axis
base_class: "{{ options.base_class }}",
timenav_height: {{ options.timenav_height }},
timenav_height_percentage: {{ options.timenav_height_percentage }}, // Overrides timenav height as a percentage of the screen
timenav_height_min: {{ options.timenav_height_min }}, // Minimum timenav height
marker_height_min: {{ options.marker_height_min }}, // Minimum Marker Height
marker_width_min: {{ options.marker_width_min }}, // Minimum Marker Width
marker_padding: {{ options.marker_padding }}, // Top Bottom Marker Padding
start_at_slide: {{ options.start_at_slide }},
menubar_height: {{ options.menubar_height }},
skinny_size: {{ options.skinny_size }},
relative_date: {{ options.relative_date }}, // Use momentjs to show a relative date from the slide.text.date.created_time field
use_bc: {{ options.use_bc }}, // Use declared suffix on dates earlier than 0
// animation
duration: {{ options.duration }},
ease: VCO.Ease.easeInOutQuint,
// interaction
dragging: {{ options.dragging }},
trackResize: {{ options.trackResize }},
map_type: "{{ options.map_type }}",
slide_padding_lr: {{ options.slide_padding_lr }}, // padding on slide of slide
slide_default_fade: "{{ options.slide_default_fade }}%", // landscape fade
api_key_flickr: "{{ options.api_key_flickr }}", // Flickr API Key
language: "{{ options.language }}"
};
var timeline = new VCO.Timeline('timeline-embed', '{% url 'timeline_index_data_latest' %}', {});
window.addEventListener('resize', function () {
var embed = document.getElementById('timeline-embed');
embed.style.height = getComputedStyle(document.body).height;
timeline.options = {
script_path: "{{ options.script_path }}",
timenav_position: "{{ options.timenav_position }}",
height: this._el.container.offsetHeight || {{ options.height }},
width: this._el.container.offsetWidth || {{ options.width }},
scale_factor: {{ options.scale_factor }}, // How many screen widths wide should the timeline be
layout: "{{ options.layout }}", // portrait or landscape
optimal_tick_width: {{ options.optimal_tick_width }}, // optimal distance (in pixels) between ticks on axis
base_class: "{{ options.base_class }}",
timenav_height: {{ options.timenav_height }},
timenav_height_percentage: {{ options.timenav_height_percentage }}, // Overrides timenav height as a percentage of the screen
timenav_height_min: {{ options.timenav_height_min }}, // Minimum timenav height
marker_height_min: {{ options.marker_height_min }}, // Minimum Marker Height
marker_width_min: {{ options.marker_width_min }}, // Minimum Marker Width
marker_padding: {{ options.marker_padding }}, // Top Bottom Marker Padding
start_at_slide: {{ options.start_at_slide }},
menubar_height: {{ options.menubar_height }},
skinny_size: {{ options.skinny_size }},
relative_date: {{ options.relative_date }}, // Use momentjs to show a relative date from the slide.text.date.created_time field
use_bc: {{ options.use_bc }}, // Use declared suffix on dates earlier than 0
// animation
duration: {{ options.duration }},
ease: VCO.Ease.easeInOutQuint,
// interaction
dragging: {{ options.dragging }},
trackResize: {{ options.trackResize }},
map_type: "{{ options.map_type }}",
slide_padding_lr: {{ options.slide_padding_lr }}, // padding on slide of slide
slide_default_fade: "{{ options.slide_default_fade }}%", // landscape fade
api_key_flickr: "{{ options.api_key_flickr }}", // Flickr API Key
language: "{{ options.language }}"
};
timeline.updateDisplay();
});
timeline.updateDisplay();
});
timeline.updateDisplay();
});
</script>
</body>
</html>
</script>
{% endblock content %}
2 changes: 1 addition & 1 deletion timeline/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class MediaAdmin(admin.ModelAdmin):


class TimelineAdmin(admin.ModelAdmin):
fieldsets = [(None, {'fields': ['title', 'slug', 'published', 'options']})]
fieldsets = [(None, {'fields': ['title', 'slug', 'text', 'media', 'published', 'options']})]
prepopulated_fields = {'slug': ('title',)}


Expand Down
1 change: 1 addition & 0 deletions timeline/static/css/main.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
body {
min-height: 80vh;
background-image: url('../images/green_background.jpg');
}
9 changes: 6 additions & 3 deletions timeline/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,13 @@
from .models import Timeline, Options


def index_data(request):
def index_data(request, timeline_id):
"""Gets the last create timeline object and renders json for returning to template.
timelinejs3 expects a json file, not able to read directly from json string"""
obj = Timeline.objects.latest('id')
if(timeline_id == 'latest'):
obj = Timeline.objects.latest('id')
else:
obj = get_object_or_404(Timeline, pk=timeline_id)
data = {
"title": {
"media": {
Expand All @@ -22,7 +25,7 @@ def index_data(request):
"thumb": ""
},
"text": {
"headline": obj.text and obj.text.timeline or "",
"headline": obj.text and obj.text.headline or "",
"text": obj.text and obj.text.text or ""
}
},
Expand Down
2 changes: 1 addition & 1 deletion version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.3.0
0.4.0

0 comments on commit be6e40c

Please sign in to comment.