Commit 6aca8cd6 authored by alexandre's avatar alexandre

Cleaning

parent ae9aa82a
......@@ -31,5 +31,5 @@ urlpatterns = [
url(r'^api/', include(router.urls)),
url(r'^api-auth/', include('rest_framework.urls', namespace='rest_framework')),
url(r'^playground/', include('playground.urls')),
url(r'^', include('playground.urls')),
]
html,
body {
height: 100%;
}
body {
background-color: #F6F6F6;
box-sizing: border-box;
}
.toolbar {
height: 30px;
}
.panes {
height: calc(100% - 30px);
box-sizing: border-box;
padding: 8px;
}
.split {
box-sizing: border-box;
overflow-y: auto;
overflow-x: hidden;
}
.content {
border: 1px solid #C0C0C0;
box-shadow: inset 0 1px 2px #e4e4e4;
background-color: #fff;
}
.gutter {
background-color: transparent;
background-repeat: no-repeat;
background-position: 50%;
}
.gutter.gutter-horizontal {
cursor: col-resize;
background-image: url('../grips/vertical.png');
}
.gutter.gutter-vertical {
cursor: row-resize;
background-image: url('../grips/horizontal.png');
}
.split.split-horizontal,
.gutter.gutter-horizontal {
height: 100%;
float: left;
}
textarea {
width: 100%;
height: 100%;
}
......@@ -15,7 +15,7 @@ window.W = window.W || {};
/** Starts the URL handling framework */
Backbone.history.start({
pushState: true,
root: '/playground/score/'
// root: '/playground/'
});
}
});
......
......@@ -13,17 +13,11 @@ window.W = window.W || {};
var myListView = new W.ScoreListView();
app.showView(myListView);
},
scoreCreate: function() {
var myBaseView = new W.BaseView();
myBaseView.render();
},
scoreView: function(id) {
},
scoreEdit: function(id) {
scoreDetail: function(id) {
var app = this.getOption('application');
// app.getRegion().empty();
var myBaseView = new W.BaseView({id: id});
app.showView(myBaseView);
var myScoreDetailView = new W.ScoreDetailView({id: id});
app.showView(myScoreDetailView);
}
});
})();
......@@ -11,9 +11,7 @@ window.W = window.W || {};
appRoutes: {
'': 'scoreList',
'create/': 'scoreCreate',
'(:id)/edit/': 'scoreEdit',
'(:id)/view/': 'scoreView',
':id(/)': 'scoreDetail',
},
initialize(options) {
......
window.Organon = window.Organon || {};
(function(undefined) {
'use strict';
Organon.ScoreModel = Backbone.Model.extend({
urlRoot: "/api/scores/",
url: function() {
var original_url = Backbone.Model.prototype.url.call( this );
var parsed_url = original_url + ( original_url.charAt( original_url.length - 1 ) == '/' ? '' : '/' );
return parsed_url;
}
});
Organon.ScoreView = Backbone.View.extend({
el: 'body',
events: {
"click .save" : "save",
},
initialize: function() {
Split(['#a', '#b'],
{
direction: 'horizontal',
sizes: [50, 50],
gutterSize: 8,
cursor: 'row-resize'
})
this.listenTo(this.model, 'sync', this.setValue);
},
setValue: function() {
this.$el.find("textarea").val(this.model.get("body"));
},
save: function() {
var that = this;
this.model
.save({
body: this.$el.find("textarea").val(),
}, {
success: function(model, result, xhr) {
},
error: function(model, xhr, options) {
}
});
},
});
})(); // end of the namespace Organon
var model = new Organon.ScoreModel({ id : 1 });
var view = new Organon.ScoreView({ model: model });
view.model.fetch();
// vim: set foldmethod=indent:
......@@ -647,7 +647,7 @@ window.W = window.W || {};
});
W.BaseView = Backbone.Marionette.View.extend({
W.ScoreDetailView = Backbone.Marionette.View.extend({
template: '#base-template',
regions: {
......
{% load static %}
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Sandbox</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/meyer-reset/2.0/reset.min.css">
<link rel="stylesheet" href="{% static 'playground/css/sandbox.css' %}">
</head>
<body>
<div class="toolbar">
<button class="save">Run</button>
</div>
<div class="panes">
<div id="a" class="split split-horizontal">
<textarea></textarea>
</div>
<div id="b" class="split split-horizontal"></div>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/split.js/1.2.0/split.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.8.3/underscore-min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/backbone.js/1.3.3/backbone-min.js"></script>
<script src="{% static 'playground/js/sandbox.js' %}"></script>
</body>
</html>
......@@ -24,7 +24,7 @@
</script>
<script id="list-item-template" type="text/template">
<a href="<%= id %>/edit/"><%= title %></a>
<a href="<%= id %>"><%= title %></a>
</script>
<script id="score-edit-template" type="text/template">
......
<h1>scores</h1>
<ul>
{% for score in object_list %}
<li><a href="{{ score.get_absolute_url }}">{{ score.title }}</a></li>
{% empty %}
<li>No scores yet.</li>
{% endfor %}
</ul>
from django.conf.urls import url
from playground.views import ScoreDetailView, ScoreListView, SandboxView
from playground.views import ScoreView
urlpatterns = [
url(r'^sandbox/$', SandboxView.as_view(), name='sandbox'),
url(r'^score/', ScoreDetailView.as_view(), name='score-detail'),
url(r'^$', ScoreListView.as_view(), name='score-list'),
url(r'^', ScoreView.as_view(), name='score'),
]
from django.views.generic.list import ListView
from django.views.generic.base import TemplateView
from rest_framework import viewsets
from .models import Score
......@@ -13,19 +12,7 @@ class ScoreViewSet(viewsets.ModelViewSet):
serializer_class = ScoreSerializer
class ScoreListView(ListView):
class ScoreView(TemplateView):
"""
"""
model = Score
class ScoreDetailView(TemplateView):
"""
"""
template_name = "playground/score_detail.html"
class SandboxView(TemplateView):
"""
"""
template_name = "playground/sandbox.html"
template_name = "playground/score.html"
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment