update templates and route handlers to clj-jtwig for template rendering
This commit is contained in:
parent
2659ceb9a8
commit
5ed36b7f7b
|
@ -1,4 +1,4 @@
|
||||||
{% extends "blarg/views/templates/base.html" %}
|
{% extends "base.html" %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
|
||||||
|
|
|
@ -1,16 +1,16 @@
|
||||||
{% extends "blarg/views/templates/base.html" %}
|
{% extends "../base.html" %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<div class="login-container">
|
<div class="login-container">
|
||||||
<h2>Login</h2>
|
<h2>Login</h2>
|
||||||
|
|
||||||
{% if login-error %}
|
{% if loginError %}
|
||||||
<p class="error">{{login-error}}</p>
|
<p class="error">{{ loginError }}</p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
<form action="{{context}}/login" method="POST">
|
<form action="{{ path('/login') }}" method="POST">
|
||||||
<p><input id="id" name="id" type="text" class="input-block-level" placeholder="Username"></input></p>
|
<p><input id="id" name="id" type="text" class="input-block-level" placeholder="Username" /></p>
|
||||||
<p><input id="pass" name="pass" type="password" class="input-block-level" placeholder="Password"></input></p>
|
<p><input id="pass" name="pass" type="password" class="input-block-level" placeholder="Password" /></p>
|
||||||
<button class="btn btn-primary" type="submit">Login</button>
|
<button class="btn btn-primary" type="submit">Login</button>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
|
|
@ -3,33 +3,34 @@
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||||
<title>blarg.ca{{html-title|default:""|safe}}</title>
|
<title>blarg.ca{{ htmlTitle|nonull}}</title>
|
||||||
<link href="{{context}}/rss" rel="alternate" title="blarg.ca" type="application/rss+xml" />
|
<link href="{{ path('/rss') }}" rel="alternate" title="blarg.ca" type="application/rss+xml" />
|
||||||
|
|
||||||
<link href="{{context}}/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
|
{{ stylesheet('/css/bootstrap.min.css') }}
|
||||||
<link href="{{context}}/css/bootstrap-markdown.css" rel="stylesheet" type="text/css" />
|
{{ stylesheet('/css/bootstrap-markdown.css') }}
|
||||||
<link href="{{context}}/css/prettify.css" rel="stylesheet" type="text/css" />
|
{{ stylesheet('/css/prettify.css') }}
|
||||||
{% if user-id %}
|
{% if userId %}
|
||||||
<link href="{{context}}/css/select2.css" rel="stylesheet" type="text/css" />
|
{{ stylesheet('/css/select2.css') }}
|
||||||
<link href="{{context}}/css/bootstrap-combobox.css" rel="stylesheet" type="text/css" />
|
{{ stylesheet('/css/bootstrap-combobox.css') }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<link href="{{context}}/css/screen.css" rel="stylesheet" type="text/css" />
|
{{ stylesheet('/css/screen.css') }}
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
var context = "{{context}}";
|
var context = "{{ path('') }}";
|
||||||
</script>
|
</script>
|
||||||
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js" type="text/javascript"></script>
|
|
||||||
<script src="{{context}}/js/bootstrap.min.js" type="text/javascript"></script>
|
{{ javascript('//ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js') }}
|
||||||
<script src="{{context}}/js/markdown.js" type="text/javascript"></script>
|
{{ javascript('/js/bootstrap.min.js') }}
|
||||||
<script src="{{context}}/js/to-markdown.js" type="text/javascript"></script>
|
{{ javascript('/js/markdown.js') }}
|
||||||
<script src="{{context}}/js/bootstrap-markdown.js" type="text/javascript"></script>
|
{{ javascript('/js/to-markdown.js') }}
|
||||||
<script src="{{context}}/js/prettify.js" type="text/javascript"></script>
|
{{ javascript('/js/bootstrap-markdown.js') }}
|
||||||
{% if user-id %}
|
{{ javascript('/js/prettify.js') }}
|
||||||
<script src="{{context}}/js/select2.min.js" type="text/javascript"></script>
|
{% if userId %}
|
||||||
<script src="{{context}}/js/bootstrap-combobox.js" type="text/javascript"></script>
|
{{ javascript('/js/select2.min.js') }}
|
||||||
<script src="{{context}}/js/modals.js" type="text/javascript"></script>
|
{{ javascript('/js/bootstrap-combobox.js') }}
|
||||||
|
{{ javascript('/js/modals.js') }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<script src="{{context}}/js/site.js" type="text/javascript"></script>
|
{{ javascript('/js/site.js') }}
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
|
@ -37,35 +38,35 @@
|
||||||
|
|
||||||
<div class="navbar">
|
<div class="navbar">
|
||||||
<div class="navbar-inner">
|
<div class="navbar-inner">
|
||||||
<a class="brand" href="{{context}}/">blarg.ca</a>
|
<a class="brand" href="{{ path('/') }}">blarg.ca</a>
|
||||||
<ul class="nav">
|
<ul class="nav">
|
||||||
<li><a href="{{context}}/about">About</a></li>
|
<li><a href="{{ path('/about') }}">About</a></li>
|
||||||
<li><a href="{{context}}/archive">Archive</a></li>
|
<li><a href="{{ path('/archive') }}">Archive</a></li>
|
||||||
<li><a href="{{context}}/projects">Projects</a></li>
|
<li><a href="{{ path('/projects') }}">Projects</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
<ul class="nav pull-right">
|
<ul class="nav pull-right">
|
||||||
{% if user-id %}
|
{% if userId %}
|
||||||
<li><a href="{{context}}/newpost"><i class="icon-pencil"></i> New Post</a></li>
|
<li><a href="{{ path('/newpost') }}"><i class="icon-pencil"></i> New Post</a></li>
|
||||||
<li><a href="{{context}}/listfiles"><i class="icon-file"></i> Files</a></li>
|
<li><a href="{{ path('/listfiles') }}"><i class="icon-file"></i> Files</a></li>
|
||||||
<li class="dropdown">
|
<li class="dropdown">
|
||||||
<a class="dropdown-toggle" data-toggle="dropdown" href="#">
|
<a class="dropdown-toggle" data-toggle="dropdown" href="#">
|
||||||
<i class="icon-user"></i> {{user-id}}<span class="caret"></span>
|
<i class="icon-user"></i> {{userId}}<span class="caret"></span>
|
||||||
</a>
|
</a>
|
||||||
<ul class="dropdown-menu">
|
<ul class="dropdown-menu">
|
||||||
<li><a href="{{context}}/profile">Profile</a></li>
|
<li><a href="{{ path('/profile') }}">Profile</a></li>
|
||||||
<li class="divider"></li>
|
<li class="divider"></li>
|
||||||
<li><a href="{{context}}/logout">Sign Out</a></li>
|
<li><a href="{{ path('/logout') }}">Sign Out</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
{% else %}
|
{% else %}
|
||||||
<li><a href="{{context}}/login">Login</a></li>
|
<li><a href="{{ path('/login') }}">Login</a></li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{% if breadcrumbs %}
|
{% if breadcrumbs %}
|
||||||
{% include "blarg/views/templates/breadcrumbs.html" %}
|
{% include "breadcrumbs.html" %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
<div class="content" role="main">
|
<div class="content" role="main">
|
||||||
|
@ -76,11 +77,11 @@
|
||||||
<div class="site-footer">
|
<div class="site-footer">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="span6 muted">
|
<div class="span6 muted">
|
||||||
<a href="mailto:gered@blarg.ca"><img src="{{context}}/img/email.png" width="32" height="32" alt="Email" /></a>
|
<a href="mailto:gered@blarg.ca"><img src="{{ path('/img/email.png') }}" width="32" height="32" alt="Email" /></a>
|
||||||
<a href="{{context}}/rss"><img src="{{context}}/img/rss.png" width="32" height="32" alt="RSS" /></a>
|
<a href="{{ path('/rss') }}"><img src="{{ path('/img/rss.png') }}" width="32" height="32" alt="RSS" /></a>
|
||||||
<a href="https://twitter.com/geredking"><img src="{{context}}/img/twitter.png" width="32" height="32" alt="Twitter" /></a>
|
<a href="https://twitter.com/geredking"><img src="{{ path('/img/twitter.png') }}" width="32" height="32" alt="Twitter" /></a>
|
||||||
<a href="http://www.linkedin.com/in/geredking"><img src="{{context}}/img/linkedin.png" width="32" height="32" alt="LinkedIn" /></a>
|
<a href="http://www.linkedin.com/in/geredking"><img src="{{ path('/img/linkedin.png') }}" width="32" height="32" alt="LinkedIn" /></a>
|
||||||
<a href="http://github.com/gered"><img src="{{context}}/img/github.png" width="32" height="32" alt="GitHub" /></a>
|
<a href="http://github.com/gered"><img src="{{ path('/img/github.png') }}" width="32" height="32" alt="GitHub" /></a>
|
||||||
</div>
|
</div>
|
||||||
<div class="span6 text-right muted">
|
<div class="span6 text-right muted">
|
||||||
© 2013, Gered King<br />
|
© 2013, Gered King<br />
|
||||||
|
@ -91,5 +92,7 @@
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<pre>{{ model|dump }}</pre>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
<ul class="breadcrumb">
|
<ul class="breadcrumb">
|
||||||
{% for crumb in breadcrumbs %}
|
{% for crumb in breadcrumbs %}
|
||||||
{% if forloop.last %}
|
{% if loop.last %}
|
||||||
<li class="active">{{crumb.name}}</li>
|
<li class="active">{{ crumb.name }}</li>
|
||||||
{% else %}
|
{% else %}
|
||||||
<li><a href="{{context}}{{crumb.url}}">{{crumb.name}}</a> <span class="divider">/</span></li>
|
<li><a href="{{ path(crumb.url) }}">{{ crumb.name }}</a> <span class="divider">/</span></li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
|
@ -1,4 +1,4 @@
|
||||||
{% extends "blarg/views/templates/base.html" %}
|
{% extends "base.html" %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@
|
||||||
<p>Sorry, an error has occurred.</p>
|
<p>Sorry, an error has occurred.</p>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<pre>{{error-info}}</pre>
|
<pre>{{ errorInfo }}</pre>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
|
@ -1,26 +1,26 @@
|
||||||
{% extends "blarg/views/templates/base.html" %}
|
{% extends "../base.html" %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
|
||||||
<div class="page-header">
|
<div class="page-header">
|
||||||
<h2>Index of {{path}}</h2>
|
<h2>Index of {{ model['path'] }}</h2>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{% if success %}
|
{% if success %}
|
||||||
<div class="alert alert-success">{{success}}</div>
|
<div class="alert alert-success">{{ success }}</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if error %}
|
{% if error %}
|
||||||
<div class="alert alert-error">{{error}}</div>
|
<div class="alert alert-error">{{ error }}</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if notice %}
|
{% if model['notice'] %}
|
||||||
<div class="alert alert-info">{{notice}}</div>
|
<div class="alert alert-info">{{ model['notice'] }}</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<div class="pull-left form-inline">
|
<div class="pull-left form-inline">
|
||||||
<select id="tree">
|
<select id="tree">
|
||||||
{% for folder in tree %}
|
{% for folder in tree %}
|
||||||
<option{% ifequal folder path %} selected{% endifequal %}>{{folder}}</option>
|
<option{% if (folder == path) %} selected{% endif %}>{{ folder }}</option>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</select>
|
</select>
|
||||||
<a class="btn" href="#" id="tree-selector">Go</a>
|
<a class="btn" href="#" id="tree-selector">Go</a>
|
||||||
|
@ -32,7 +32,7 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="file-list-container">
|
<div class="file-list-container">
|
||||||
{% if not files|is-empty %}
|
{% if (not files is empty) %}
|
||||||
<table class="table table-hover table-condensed">
|
<table class="table table-hover table-condensed">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
|
@ -44,22 +44,22 @@
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{% for file in files %}
|
{% for file in files %}
|
||||||
<tr{% if not file.published %} class="unpublished-file"{% endif %}>
|
<tr{% if (not file.published) %} class="unpublished-file"{% endif %}>
|
||||||
<td>
|
<td>
|
||||||
<a href="{{context}}/files{{path}}{{file.filename}}"><i class="icon-file"></i> {{file.filename}}</a><br />
|
<a href="{{ path(concat('/files', model['path'], file.filename)) }}"><i class="icon-file"></i> {{ file.filename }}</a><br />
|
||||||
<small class="muted">{{file.content-type}}</small>
|
<small class="muted">{{ file['content-type'] }}</small>
|
||||||
</td>
|
</td>
|
||||||
<td>{{file.size}}</td>
|
<td>{{ file.size }}</td>
|
||||||
<td>{{file.last_modified|to_fulltime}}</td>
|
<td>{{ file.last_modified|to_fulltime }}</td>
|
||||||
<td style="text-align: right;">
|
<td style="text-align: right;">
|
||||||
<a class="btn btn-warning" title="Update File" data-updatefileid="{{file.id}}" href="#"><i class="icon-pencil icon-white"></i></a>
|
<a class="btn btn-warning" title="Update File" data-updatefileid="{{ file.id }}" href="#"><i class="icon-pencil icon-white"></i></a>
|
||||||
{% if file.published %}
|
{% if file.published %}
|
||||||
<a class="btn btn-warning" title="Unpublish File" href="{{context}}/unpublishfile{{file.id}}?returnpath={{path}}"><i class="icon-minus-sign icon-white"></i></a>
|
<a class="btn btn-warning" title="Unpublish File" href="{{ path(concat('/unpublishfile', file.id, '?returnpath=', model['path'])) }}"><i class="icon-minus-sign icon-white"></i></a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if not file.published %}
|
{% if (not file.published) %}
|
||||||
<a class="btn btn-success" title="Publish File" href="{{context}}/publishfile{{file.id}}?returnpath={{path}}"><i class="icon-ok-sign icon-white"></i></a>
|
<a class="btn btn-success" title="Publish File" href="{{ path(concat('/publishfile', file.id, '?returnpath=', model['path'])) }}"><i class="icon-ok-sign icon-white"></i></a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<a class="btn btn-danger" title="Delete File" data-deletefileid="{{file.id}}" href="#"><i class="icon-remove icon-white"></i></a>
|
<a class="btn btn-danger" title="Delete File" data-deletefileid="{{ file.id }}" href="#"><i class="icon-remove icon-white"></i></a>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
@ -75,8 +75,8 @@
|
||||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||||||
<h3 id="newFileModalLabel">Upload File</h3>
|
<h3 id="newFileModalLabel">Upload File</h3>
|
||||||
</div>
|
</div>
|
||||||
<form action="{{context}}/uploadfile?returnpath={{path}}" method="post" enctype="multipart/form-data" class="form-horizontal">
|
<form action="{{ path(concat('/uploadfile?returnpath=', model['path'])) }}" method="post" enctype="multipart/form-data" class="form-horizontal">
|
||||||
<input type="hidden" id="newPath" name="path" value="{{path}}" />
|
<input type="hidden" id="newPath" name="path" value="{{ model['path'] }}" />
|
||||||
<div class="modal-body">
|
<div class="modal-body">
|
||||||
<div class="control-group">
|
<div class="control-group">
|
||||||
<label class="control-label" for="newFile">Upload File</label>
|
<label class="control-label" for="newFile">Upload File</label>
|
||||||
|
@ -98,7 +98,7 @@
|
||||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||||||
<h3 id="updateFileModalLabel">Update File</h3>
|
<h3 id="updateFileModalLabel">Update File</h3>
|
||||||
</div>
|
</div>
|
||||||
<form action="{{context}}/updatefile?returnpath={{path}}" method="post" enctype="multipart/form-data" class="form-horizontal">
|
<form action="{{ path(concat('/updatefile?returnpath=', model['path'])) }}" method="post" enctype="multipart/form-data" class="form-horizontal">
|
||||||
<input type="hidden" id="updateFileId" name="id" />
|
<input type="hidden" id="updateFileId" name="id" />
|
||||||
<div class="modal-body">
|
<div class="modal-body">
|
||||||
<p>Select a file to upload over top of this file with:</p>
|
<p>Select a file to upload over top of this file with:</p>
|
||||||
|
@ -122,7 +122,7 @@
|
||||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||||||
<h3 id="deleteFileModalLabel">Delete File</h3>
|
<h3 id="deleteFileModalLabel">Delete File</h3>
|
||||||
</div>
|
</div>
|
||||||
<form action="{{context}}/deletefile?returnpath={{path}}" method="post" class="form-horizontal">
|
<form action="{{ path(concat('/deletefile?returnpath=', model['path'])) }}" method="post" class="form-horizontal">
|
||||||
<input type="hidden" id="deleteFileId" name="id" />
|
<input type="hidden" id="deleteFileId" name="id" />
|
||||||
<div class="modal-body">
|
<div class="modal-body">
|
||||||
<p>Confirm that you would like to delete the following file:</p>
|
<p>Confirm that you would like to delete the following file:</p>
|
||||||
|
@ -138,12 +138,12 @@
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
$('#tree').combobox({force_match: false});
|
$('#tree').combobox({force_match: false});
|
||||||
$('#tree').data('combobox').val('{{path}}');
|
$('#tree').data('combobox').val('{{ model['path'] }}');
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#tree-selector').click(function() {
|
$('#tree-selector').click(function() {
|
||||||
var path = $('#tree').data('combobox').val();
|
var path = $('#tree').data('combobox').val();
|
||||||
window.location.href = '{{context}}/listfiles' + path;
|
window.location.href = '{{ path('/listfiles') }}' + path;
|
||||||
});
|
});
|
||||||
|
|
||||||
$('a[data-updatefileid]').click(function() {
|
$('a[data-updatefileid]').click(function() {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
{% extends "blarg/views/templates/base.html" %}
|
{% extends "base.html" %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
{% if user-id %}
|
{% if userId %}
|
||||||
|
|
||||||
<div id="deleteModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="deleteModalLabel" aria-hidden="true">
|
<div id="deleteModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="deleteModalLabel" aria-hidden="true">
|
||||||
<div class="modal-header">
|
<div class="modal-header">
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
{% extends "blarg/views/templates/base.html" %}
|
{% extends "../base.html" %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
|
||||||
|
@ -6,6 +6,6 @@
|
||||||
<h2>Edit Post</h2>
|
<h2>Edit Post</h2>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{% include "blarg/views/templates/posts/postform.html" %}
|
{% include "postform.html" %}
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
|
@ -1,31 +1,31 @@
|
||||||
{% extends "blarg/views/templates/base.html" %}
|
{% extends "../base.html" %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
|
||||||
{% if posts|is-empty %}
|
{% if (posts is empty) %}
|
||||||
<div>
|
<div>
|
||||||
<p class="text-center">There are no posts.</p>
|
<p class="text-center">There are no posts.</p>
|
||||||
</div>
|
</div>
|
||||||
{% else %}
|
{% else %}
|
||||||
{% for post in posts %}
|
{% for post in posts %}
|
||||||
{% include "blarg/views/templates/posts/post.html" %}
|
{% include "post.html" %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
<ul class="pager">
|
<ul class="pager">
|
||||||
{% if atlastpage %}
|
{% if atlastpage %}
|
||||||
<li class="previous disabled"><a>← Older</a></li>
|
<li class="previous disabled"><a>← Older</a></li>
|
||||||
{% else %}
|
{% else %}
|
||||||
<li class="previous"><a href="{{context}}/?page={{nextpage}}">← Older</a></li>
|
<li class="previous"><a href="{{ path(concat('/?page=', nextpage)) }}">← Older</a></li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if atfirstpage %}
|
{% if atfirstpage %}
|
||||||
<li class="next disabled"><a>Newer →</a></li>
|
<li class="next disabled"><a>Newer →</a></li>
|
||||||
{% else %}
|
{% else %}
|
||||||
<li class="next"><a href="{{context}}/?page={{prevpage}}">Newer →</a></li>
|
<li class="next"><a href="{{ path(concat('/?page=', prevpage)) }}">Newer →</a></li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
{% include "blarg/views/templates/posts/publishmodal.html" %}
|
{% include "publishmodal.html" %}
|
||||||
{% include "blarg/views/templates/posts/deletemodal.html" %}
|
{% include "deletemodal.html" %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
{% extends "blarg/views/templates/base.html" %}
|
{% extends "../base.html" %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
|
||||||
|
@ -9,12 +9,12 @@
|
||||||
<div>
|
<div>
|
||||||
{% for month in months %}
|
{% for month in months %}
|
||||||
{% for post in month %}
|
{% for post in month %}
|
||||||
{% if forloop.first %}
|
{% if loop.first %}
|
||||||
<h3>{{post.mmyyyy}}</h3>
|
<h3>{{ post.mmyyyy }}</h3>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="span2 muted text-right"><time title="{{post.created_at|to_fulltime}}">{{post.created_at|to_month-day}}</time></div>
|
<div class="span2 muted text-right"><time title="{{ post.created_at|to_fulltime }}">{{ post.created_at|to_month_day }}</time></div>
|
||||||
<div class="span9"><a href="{{context}}{{post|post-url}}">{{post.title}}</a></div>
|
<div class="span9"><a href="{{ path(post|post_url) }}">{{ post.title }}</a></div>
|
||||||
</div>
|
</div>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
|
@ -1,15 +1,15 @@
|
||||||
{% extends "blarg/views/templates/base.html" %}
|
{% extends "../base.html" %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
|
||||||
<div class="page-header">
|
<div class="page-header">
|
||||||
<h2>Posts tagged with: {{tag}}</h2>
|
<h2>Posts tagged with: {{ tag }}</h2>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{% for post in posts %}
|
{% for post in posts %}
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="span2 muted text-right"><time title="{{post.created_at|to_fulltime}}">{{post.created_at|to_relative}}</time></div>
|
<div class="span2 muted text-right"><time title="{{ post.created_at|to_fulltime }}">{{ post.created_at|to_relative }}</time></div>
|
||||||
<div class="span9"><a href="{{context}}{{post|post-url}}">{{post.title}}</a></div>
|
<div class="span9"><a href="{{ path(post|post_url) }}">{{ post.title }}</a></div>
|
||||||
</div>
|
</div>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
{% extends "blarg/views/templates/base.html" %}
|
{% extends "../base.html" %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
|
||||||
|
@ -6,6 +6,6 @@
|
||||||
<h2>New Post</h2>
|
<h2>New Post</h2>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{% include "blarg/views/templates/posts/postform.html" %}
|
{% include "postform.html" %}
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
|
@ -1,23 +1,23 @@
|
||||||
<div class="post{%if not inlist %} single-post{% endif %}{% if not post.published %} unpublished-post{% endif %}">
|
<div class="post{%if (not inlist) %} single-post{% endif %}{% if (not post.published) %} unpublished-post{% endif %}">
|
||||||
<div class="header">
|
<div class="header">
|
||||||
{% if inlist %}
|
{% if inlist %}
|
||||||
<a href="{{context}}{{post|post-url}}"><h2>{{post.title}}</h2></a>
|
<a href="{{ path(post|post_url) }}"><h2>{{ post.title }}</h2></a>
|
||||||
{% else %}
|
{% else %}
|
||||||
<h2>{{post.title}}</h2>
|
<h2>{{ post.title }}</h2>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<div>
|
<div>
|
||||||
<div class="pull-left">
|
<div class="pull-left">
|
||||||
<span class="muted">Posted by {{post.user}}, <time title="{{post.created_at|to_fulltime}}">{{post.created_at|to_relative}}</time></span>
|
<span class="muted">Posted by {{ post.user }}, <time title="{{ post.created_at|to_fulltime }}">{{ post.created_at|to_relative }}</time></span>
|
||||||
</div>
|
</div>
|
||||||
{% if user-id %}
|
{% if userId %}
|
||||||
<div class="pull-right">
|
<div class="pull-right">
|
||||||
<a class="btn btn-mini" href="{{context}}/editpost/{{post._id}}">Edit</a>
|
<a class="btn btn-mini" href="{{ path(concat('/editpost/', post._id)) }}">Edit</a>
|
||||||
<a class="btn btn-mini btn-danger" data-deletepostid="{{post._id}}" href="#">Delete</a>
|
<a class="btn btn-mini btn-danger" data-deletepostid="{{ post._id }}" href="#">Delete</a>
|
||||||
{% if post.published %}
|
{% if post.published %}
|
||||||
<a class="btn btn-mini btn-warning" href="{{context}}/unpublish/{{post._id}}">Unpublish</a>
|
<a class="btn btn-mini btn-warning" href="{{ path(concat('/unpublish/', post._id)) }}">Unpublish</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if not post.published %}
|
{% if (not post.published) %}
|
||||||
<a class="btn btn-mini btn-success" data-publishpostid="{{post._id}}" href="#">Publish</a>
|
<a class="btn btn-mini btn-success" data-publishpostid="{{ post._id }}" href="#">Publish</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
@ -26,16 +26,16 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="content">
|
<div class="content">
|
||||||
{{post.body|md-to-html|safe}}
|
{{ post.body|md_to_html }}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="footer">
|
<div class="footer">
|
||||||
<div class="pull-left">
|
<div class="pull-left">
|
||||||
<small>{% for tag in post.tags %}<span class="label"><a href="{{context}}/tag/{{tag}}">{{tag}}</a></span> {% endfor %}</small>
|
<small>{% for tag in post.tags %}<span class="label"><a href="{{ path(concat('/tag/', tag)) }}">{{ tag }}</a></span> {% endfor %}</small>
|
||||||
</div>
|
</div>
|
||||||
{% if inlist %}
|
{% if inlist %}
|
||||||
<div class="pull-right">
|
<div class="pull-right">
|
||||||
<a href="{{context}}{{post|post-url}}#comments">Comments</a>
|
<a href="{{ path(post|post_url) }}#comments">Comments</a>
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<div class="clearfix"></div>
|
<div class="clearfix"></div>
|
||||||
|
|
|
@ -2,19 +2,19 @@
|
||||||
<div class="control-group">
|
<div class="control-group">
|
||||||
<label class="control-label" for="title">Title</label>
|
<label class="control-label" for="title">Title</label>
|
||||||
<div class="controls">
|
<div class="controls">
|
||||||
<input type="text" class="input-xxlarge" id="title" name="title" placeholder="Post Title" value="{{title}}" />
|
<input type="text" class="input-xxlarge" id="title" name="title" placeholder="Post Title" value="{{ title }}" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="control-group">
|
<div class="control-group">
|
||||||
<label class="control-label" for="tags">Tags</label>
|
<label class="control-label" for="tags">Tags</label>
|
||||||
<div class="controls">
|
<div class="controls">
|
||||||
<input type="text" class="input-xxlarge" id="tags" name="tags" value="{{tags}}" />
|
<input type="text" class="input-xxlarge" id="tags" name="tags" value="{{ tags }}" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="control-group">
|
<div class="control-group">
|
||||||
<label class="control-label" for="body">Post Body</label>
|
<label class="control-label" for="body">Post Body</label>
|
||||||
<div class="controls">
|
<div class="controls">
|
||||||
<textarea id="body" data-provide="markdown" name="body" rows="20">{{body}}</textarea>
|
<textarea id="body" data-provide="markdown" name="body" rows="20">{{ body }}</textarea>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-actions">
|
<div class="form-actions">
|
||||||
|
@ -25,13 +25,13 @@
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
var allTags = {{all-tags|json|safe}};
|
var allTags = {{ allTags|json_encode }};
|
||||||
|
|
||||||
$("#body").markdown();
|
$("#body").markdown();
|
||||||
$("#tags").select2({tags:allTags});
|
$("#tags").select2({tags:allTags});
|
||||||
$("#tags").on("change", function() { $("#tags_val").html($("#tags").val());});
|
$("#tags").on("change", function() { $("#tags_val").html($("#tags").val());});
|
||||||
|
|
||||||
var errors = {{validation-errors|json|safe}};
|
var errors = {{ validationErrors|json_encode }};
|
||||||
for (var field in errors) {
|
for (var field in errors) {
|
||||||
var inputElement = $('#' + field);
|
var inputElement = $('#' + field);
|
||||||
var controlGroup = inputElement.closest('div.control-group');
|
var controlGroup = inputElement.closest('div.control-group');
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
{% if user-id %}
|
{% if userId %}
|
||||||
|
|
||||||
<div id="publishModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="publishModalLabel" aria-hidden="true">
|
<div id="publishModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="publishModalLabel" aria-hidden="true">
|
||||||
<div class="modal-header">
|
<div class="modal-header">
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
{% extends "blarg/views/templates/base.html" %}
|
{% extends "../base.html" %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
{% include "blarg/views/templates/posts/post.html" %}
|
{% include "post.html" %}
|
||||||
{% include "blarg/views/templates/posts/publishmodal.html" %}
|
{% include "publishmodal.html" %}
|
||||||
{% include "blarg/views/templates/posts/deletemodal.html" %}
|
{% include "deletemodal.html" %}
|
||||||
{% endblock %}
|
{% endblock %}
|
|
@ -1,4 +1,4 @@
|
||||||
{% extends "blarg/views/templates/base.html" %}
|
{% extends "base.html" %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
{% extends "blarg/views/templates/base.html" %}
|
{% extends "base.html" %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,8 @@
|
||||||
[compojure.response :refer [render]]
|
[compojure.response :refer [render]]
|
||||||
[taoensso.timbre :as timbre]
|
[taoensso.timbre :as timbre]
|
||||||
[taoensso.timbre.appenders.rotor :as rotor]
|
[taoensso.timbre.appenders.rotor :as rotor]
|
||||||
[selmer.parser :as parser]
|
[clj-jtwig.core :as jtwig]
|
||||||
|
[clj-jtwig.web.middleware :refer [wrap-servlet-context-path]]
|
||||||
[blarg.views.layout :as layout]
|
[blarg.views.layout :as layout]
|
||||||
[blarg.models.db :as db]))
|
[blarg.models.db :as db]))
|
||||||
|
|
||||||
|
@ -39,7 +40,7 @@
|
||||||
|
|
||||||
(when (= "DEV" (config-val :env))
|
(when (= "DEV" (config-val :env))
|
||||||
(timbre/info "Dev environment. Template caching disabled.")
|
(timbre/info "Dev environment. Template caching disabled.")
|
||||||
(parser/toggle-caching))
|
(jtwig/toggle-compiled-template-caching! false))
|
||||||
|
|
||||||
(timbre/info "touching database...")
|
(timbre/info "touching database...")
|
||||||
(db/touch-databases))
|
(db/touch-databases))
|
||||||
|
@ -56,11 +57,11 @@
|
||||||
(layout/render-response
|
(layout/render-response
|
||||||
request
|
request
|
||||||
"error.html"
|
"error.html"
|
||||||
:params {:error-info e}
|
:params {:errorInfo e}
|
||||||
:status 500)))))
|
:status 500)))))
|
||||||
|
|
||||||
(def app (app-handler
|
(def app (app-handler
|
||||||
[auth-routes home-routes posts-routes files-routes rss-routes app-routes]
|
[auth-routes home-routes posts-routes files-routes rss-routes app-routes]
|
||||||
:middleware [wrap-exceptions]
|
:middleware [wrap-servlet-context-path wrap-exceptions]
|
||||||
:access-rules [{:redirect "/unauthorized" :rule auth-required}]
|
:access-rules [{:redirect "/unauthorized" :rule auth-required}]
|
||||||
:formats [:json-kw :edn]))
|
:formats [:json-kw :edn]))
|
||||||
|
|
|
@ -18,8 +18,8 @@
|
||||||
(resp/redirect "/")
|
(resp/redirect "/")
|
||||||
(layout/render
|
(layout/render
|
||||||
"auth/login.html"
|
"auth/login.html"
|
||||||
:params {:login-error (session/flash-get :login-error)
|
:params {:loginError (session/flash-get :login-error)
|
||||||
:html-title (->html-title ["Login"])})))
|
:htmlTitle (->html-title ["Login"])})))
|
||||||
|
|
||||||
(defn handle-login [id pass]
|
(defn handle-login [id pass]
|
||||||
(if-let [user (users/get-user id pass)]
|
(if-let [user (users/get-user id pass)]
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
(let [p (ensure-prefix-suffix path "/")]
|
(let [p (ensure-prefix-suffix path "/")]
|
||||||
(layout/render
|
(layout/render
|
||||||
"files/list.html"
|
"files/list.html"
|
||||||
:params {:html-title (->html-title [(str "Files in " p)])
|
:params {:htmlTitle (->html-title [(str "Files in " p)])
|
||||||
:path p
|
:path p
|
||||||
:files (files/list-files p)
|
:files (files/list-files p)
|
||||||
:tree (files/get-tree)
|
:tree (files/get-tree)
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
(:require [clj-time.core]))
|
(:require [clj-time.core]))
|
||||||
|
|
||||||
(defn get-post-url [post]
|
(defn get-post-url [post]
|
||||||
(str
|
(str
|
||||||
"/"
|
"/"
|
||||||
(clj-time.core/year (:created_at post)) "/"
|
(clj-time.core/year (:created_at post)) "/"
|
||||||
(clj-time.core/month (:created_at post)) "/"
|
(clj-time.core/month (:created_at post)) "/"
|
||||||
|
|
|
@ -8,12 +8,12 @@
|
||||||
(defn about-page []
|
(defn about-page []
|
||||||
(layout/render
|
(layout/render
|
||||||
"about.html"
|
"about.html"
|
||||||
:params {:html-title (->html-title ["About"])}))
|
:params {:htmlTitle (->html-title ["About"])}))
|
||||||
|
|
||||||
(defn projects-page []
|
(defn projects-page []
|
||||||
(layout/render
|
(layout/render
|
||||||
"projects.html"
|
"projects.html"
|
||||||
:params {:html-title (->html-title ["Projects"])}))
|
:params {:htmlTitle (->html-title ["Projects"])}))
|
||||||
|
|
||||||
(defroutes home-routes
|
(defroutes home-routes
|
||||||
(GET "/about" [] (about-page))
|
(GET "/about" [] (about-page))
|
||||||
|
|
|
@ -68,7 +68,7 @@
|
||||||
(layout/render
|
(layout/render
|
||||||
"posts/showpost.html"
|
"posts/showpost.html"
|
||||||
:params {:post post
|
:params {:post post
|
||||||
:html-title (->html-title [(:title post)])})
|
:htmlTitle (->html-title [(:title post)])})
|
||||||
(resp/redirect "/notfound"))))
|
(resp/redirect "/notfound"))))
|
||||||
|
|
||||||
(defn new-post-page [& post]
|
(defn new-post-page [& post]
|
||||||
|
@ -76,8 +76,8 @@
|
||||||
"posts/newpost.html"
|
"posts/newpost.html"
|
||||||
:params (merge
|
:params (merge
|
||||||
(first post)
|
(first post)
|
||||||
{:all-tags (posts/list-tags)
|
{:allTags (posts/list-tags)
|
||||||
:html-title (->html-title ["New Post"])
|
:htmlTitle (->html-title ["New Post"])
|
||||||
:validation-errors @vali/*errors*})))
|
:validation-errors @vali/*errors*})))
|
||||||
|
|
||||||
(defn handle-new-post [title tags body]
|
(defn handle-new-post [title tags body]
|
||||||
|
@ -98,9 +98,9 @@
|
||||||
:params (merge
|
:params (merge
|
||||||
post
|
post
|
||||||
{:tags (tags->string (:tags post))
|
{:tags (tags->string (:tags post))
|
||||||
:all-tags (posts/list-tags)
|
:allTags (posts/list-tags)
|
||||||
:html-title (->html-title ["Edit Post"])
|
:htmlTitle (->html-title ["Edit Post"])
|
||||||
:validation-errors @vali/*errors*}))))
|
:validationErrors @vali/*errors*}))))
|
||||||
|
|
||||||
(defn handle-edit-post [id title tags body]
|
(defn handle-edit-post [id title tags body]
|
||||||
(if (valid-post? title tags body)
|
(if (valid-post? title tags body)
|
||||||
|
|
|
@ -1,18 +1,18 @@
|
||||||
(ns blarg.views.layout
|
(ns blarg.views.layout
|
||||||
(:require [selmer.parser :as parser]
|
(:require [clj-jtwig.core :as jtwig]
|
||||||
[ring.util.response :as resp]
|
[ring.util.response :as resp]
|
||||||
[compojure.response :refer [Renderable]]
|
[compojure.response :refer [Renderable]]
|
||||||
[noir.session :as session])
|
[noir.session :as session])
|
||||||
(:use [blarg.views.viewfilters]))
|
(:use [blarg.views.viewfilters]))
|
||||||
|
|
||||||
(def template-path "blarg/views/templates/")
|
(def template-path "views/")
|
||||||
|
|
||||||
(defn- render-template [request template params]
|
(defn- render-template [request template params]
|
||||||
(parser/render-file
|
(jtwig/render-resource
|
||||||
(str template-path template)
|
(str template-path template)
|
||||||
(assoc params
|
(assoc params
|
||||||
:context (:context request)
|
:context (:context request)
|
||||||
:user-id (session/get :user))))
|
:userId (session/get :user))))
|
||||||
|
|
||||||
(defn render-response [request template & {:keys [params status content-type]}]
|
(defn render-response [request template & {:keys [params status content-type]}]
|
||||||
(-> (render-template request template params)
|
(-> (render-template request template params)
|
||||||
|
|
|
@ -1,31 +1,27 @@
|
||||||
(ns blarg.views.viewfilters
|
(ns blarg.views.viewfilters
|
||||||
(:use [blarg.datetime]
|
(:use [blarg.datetime]
|
||||||
[blarg.routes.helpers])
|
[blarg.routes.helpers])
|
||||||
(:require [selmer.filters :refer [add-filter!]]
|
(:require [clj-jtwig.functions :refer [deftwigfn]]
|
||||||
[markdown.core :as md]
|
[markdown.core :as md]
|
||||||
[clj-time.core]
|
[clj-time.core]
|
||||||
[clj-time.format]))
|
[clj-time.format]))
|
||||||
|
|
||||||
(add-filter!
|
(deftwigfn "md_to_html" [s]
|
||||||
:md-to-html
|
(md/md-to-html-string s))
|
||||||
#(md/md-to-html-string %))
|
|
||||||
|
|
||||||
(add-filter!
|
(deftwigfn "post_url" [post]
|
||||||
:post-url
|
(->> post
|
||||||
#(get-post-url %))
|
(clojure.walk/keywordize-keys)
|
||||||
|
(get-post-url)))
|
||||||
|
|
||||||
(add-filter!
|
(deftwigfn "to_relative" [date]
|
||||||
:to_relative
|
(->relative-timestamp date))
|
||||||
#(->relative-timestamp %))
|
|
||||||
|
|
||||||
(add-filter!
|
(deftwigfn "to_month_day" [date]
|
||||||
:to_month-day
|
(->month-day-str date))
|
||||||
#(->month-day-str %))
|
|
||||||
|
|
||||||
(add-filter!
|
(deftwigfn "to_fulltime" [date]
|
||||||
:to_fulltime
|
(clj-time.local/format-local-time date :rfc822))
|
||||||
#(clj-time.local/format-local-time % :rfc822))
|
|
||||||
|
|
||||||
(add-filter!
|
(deftwigfn "is_empty" [x]
|
||||||
:is-empty
|
(empty? x))
|
||||||
#(empty? %))
|
|
||||||
|
|
Reference in a new issue