Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixes #todos && clean up html/js #22

Merged
merged 1 commit into from
Jun 29, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
198 changes: 113 additions & 85 deletions magpie/template/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,97 +2,125 @@
{% from operator import itemgetter %}
<!doctype html>
<html>
<head>
<title>{% block title %}{% end block %} :: magpie</title>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js">
</script>
<script src="//netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js">
</script>
<link rel=stylesheet
href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" />
<link rel=icon type=image/jpeg href="{{ static_url('magpie.jpg') }}" />
{% block js %}{% end block %}
</head>
<head>
<title>
{% block title %}{% end block %} :: magpie
</title>
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" />
<link rel="icon" type="image/jpeg" href="{{ static_url('magpie.jpg') }}" />
</head>
<body {% block bodytag %}{% end block %}>
<br>
<ul class="nav nav-tabs">
<li>
<a href="/">
<span class="glyphicon glyphicon-home"></span>
</a>
</li>
<!-- new notebook button exposes new notebook form -->
<li>
<a href="#" onclick="$('#new_notebook_form').removeClass('hidden')">
+ New Notebook +
</a>
</li>
<!-- hidden new notebook form -->
<li class="hidden" id="new_notebook_form">
<a href="#">
<input type="text" name="new_notebook_name" id="new_notebook_name" />
<input onclick="new_notebook(this);" type="button" class="btn btn-primary" value="Create" />
<input type="button" class="btn btn-danger" value="Cancel" onclick="uitoggler(this)" />
<!-- TODO this causes the newbook note button to not work again until a page refresh -->
</a>
</li>

<body {% block bodytag %}{% end block %}>
<br>
<ul class='nav nav-tabs'>
<li><a href=/><span class='glyphicon glyphicon-home'></span></a></li>
<!-- new notebook button exposes new notebook form -->
<li><a href=# onclick="document.getElementById('new_notebook_form').className=''">
+ New Notebook +</a></li>
<!-- hidden new notebook form -->
<li class=hidden id=new_notebook_form><a href=#>
<input type=text name=new_notebook_name id=new_notebook_name>
<input
onclick="var new_notebook='/'+document.getElementById('new_notebook_name').value
$.post(new_notebook).done(function(){window.location=new_notebook})"
type=button class='btn btn-primary' value=Create>
<input type=button class='btn btn-danger' value=Cancel
onclick="this.parentElement.className='hidden'">
<!-- TODO this causes the newbook note button to not work again until a page refresh -->
</a></li>

<!-- iterate though existing notebooks -->
<!-- iterate though existing notebooks -->
{% for notebook in notebooks %}
{% if notebook != '.git' %}
<li
{% if notebook_name == notebook %}
class=active
{% end if %}
><a href=/{{ url_escape(notebook) }}>{{ notebook }}</a></li>
<li {% if notebook_name == notebook %}class="active"{% end if %}>
<a href="/{{ url_escape(notebook) }}">
{{ notebook }}
</a>
</li>
{% end if %}
{% end for %}
</ul>
<br>
<div class='col-sm-2'>
<ul class='nav nav-pills nav-stacked'>
<!-- search -->
<li>
<form method=GET action=/search>
<div class=form-group>
<input type=search name=q id=search size=15 placeholder=" search"
tabindex=10>
<button class='btn btn-link'>
<span class="glyphicon glyphicon-search">
</span>
</button>
</div>
</form>
</li>
</ul>
<br>
<div class="col-sm-2">
<ul class="nav nav-pills nav-stacked">
<!-- search -->
<li>
<form method="GET" action="/search">
<div class="form-group">
<input type="search" name="q" id="search" size="15" placeholder="search" tabindex="10">
<button class="btn btn-link">
<span class="glyphicon glyphicon-search">
</span>
</button>
</div>
</form>
</li>

{% if notebook_name != '' %}
<!-- new note button exposes new note form -->
<li><a href=# onclick="document.getElementById('new_note_form').className=''">
+ New Note +</a></li>
<!-- hidden note form -->
<li class=hidden id=new_note_form><a href=#>
<input type=text name=new_note_name id=new_note_name><br><br>
<input type=button class='btn btn-primary' value=Create
onclick="var new_note='/{{ url_escape(notebook_name) }}/'+document.getElementById('new_note_name').value
$.post(new_note,data={'save': true, 'note': ''}).done(function(){window.location=new_note})">
<input type=button class='btn btn-danger' value=Cancel id=cancel
onclick="this.parentElement.className='hidden'"></a></li>
<!-- TODO this causes the new note button to not work again until a page refresh -->
{% end if %}
{% if notebook_name != '' %}
<!-- new note button exposes new note form -->
<li>
<a href="#" onclick="$('#new_note_form').removeClass('hidden');">
+ New Note +
</a>
</li>
<!-- hidden note form -->
<li class="hidden" id="new_note_form">
<a href="#">
<input type="text" name="new_note_name" id="new_note_name" />
<br><br>
<input type="button" class="btn btn-primary" value="Create" onclick="new_note(this);" />
<input type="button" class="btn btn-danger" value="Cancel" id="cancel" onclick="uitoggler(this);">
<!-- TODO this causes the new note button to not work again until a page refresh -->
</a>
</li>
{% end if %}

<!-- iterate through existing notes -->
{% for note in notes %}
<li
{% if note == note_name %}
class=active
{% end if %}
><a href=/{{ url_escape(notebook_name) }}/{{ url_escape(note) }}>{{ note }}</a></li>
{% end for %}
</ul>
</div>
<div class=container>
<div class=row>
<div class='col-sm-10'>
{% block body %}
{% end block %}
{# iterate through existing notes #}
{% for note in notes %}
<li {% if note == note_name %}class="active"{% end if %}>
<a href="/{{ url_escape(notebook_name) }}/{{ url_escape(note) }}">
{{ note }}
</a>
</li>
{% end for %}
</ul>
</div>
</div>
</div>
</body>
<div class="container">
<div class="row">
<div class="col-sm-10">
{% block body %}
{% end block %}
</div>
</div>
</div>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="//netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js"></script>
<script>
//helpers
var uitoggler = function(self){
$(self).parents("li").first().addClass("hidden");
};
var new_notebook = function(self){
var name = '/'+$("#new_notebook_name").val();
$.post(name).done(function(){
window.location = name;
});
};
var new_note = function(self){
var name = '/{{ url_escape(notebook_name) }}/' + $("#new_note_name").val();
$.post(name, data = {
save: true
,note: ''
}).done(function(){
window.location = name;
});
};
</script>
{% block js %}
{% end block %}
</body>
</html>