update templates and route handlers to clj-jtwig for template rendering

This commit is contained in:
Gered 2014-03-25 22:01:28 -04:00
parent 2659ceb9a8
commit 5ed36b7f7b
27 changed files with 162 additions and 162 deletions

View file

@ -1,4 +1,4 @@
{% extends "blarg/views/templates/base.html" %}
{% extends "base.html" %}
{% block content %}

View file

@ -1,16 +1,16 @@
{% extends "blarg/views/templates/base.html" %}
{% extends "../base.html" %}
{% block content %}
<div class="login-container">
<h2>Login</h2>
{% if login-error %}
<p class="error">{{login-error}}</p>
{% if loginError %}
<p class="error">{{ loginError }}</p>
{% endif %}
<form action="{{context}}/login" method="POST">
<p><input id="id" name="id" type="text" class="input-block-level" placeholder="Username"></input></p>
<p><input id="pass" name="pass" type="password" class="input-block-level" placeholder="Password"></input></p>
<form action="{{ path('/login') }}" method="POST">
<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" /></p>
<button class="btn btn-primary" type="submit">Login</button>
</form>

View file

@ -3,33 +3,34 @@
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>blarg.ca{{html-title|default:""|safe}}</title>
<link href="{{context}}/rss" rel="alternate" title="blarg.ca" type="application/rss+xml" />
<link href="{{context}}/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
<link href="{{context}}/css/bootstrap-markdown.css" rel="stylesheet" type="text/css" />
<link href="{{context}}/css/prettify.css" rel="stylesheet" type="text/css" />
{% if user-id %}
<link href="{{context}}/css/select2.css" rel="stylesheet" type="text/css" />
<link href="{{context}}/css/bootstrap-combobox.css" rel="stylesheet" type="text/css" />
<title>blarg.ca{{ htmlTitle|nonull}}</title>
<link href="{{ path('/rss') }}" rel="alternate" title="blarg.ca" type="application/rss+xml" />
{{ stylesheet('/css/bootstrap.min.css') }}
{{ stylesheet('/css/bootstrap-markdown.css') }}
{{ stylesheet('/css/prettify.css') }}
{% if userId %}
{{ stylesheet('/css/select2.css') }}
{{ stylesheet('/css/bootstrap-combobox.css') }}
{% endif %}
<link href="{{context}}/css/screen.css" rel="stylesheet" type="text/css" />
{{ stylesheet('/css/screen.css') }}
<script type="text/javascript">
var context = "{{context}}";
var context = "{{ path('') }}";
</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>
<script src="{{context}}/js/markdown.js" type="text/javascript"></script>
<script src="{{context}}/js/to-markdown.js" type="text/javascript"></script>
<script src="{{context}}/js/bootstrap-markdown.js" type="text/javascript"></script>
<script src="{{context}}/js/prettify.js" type="text/javascript"></script>
{% if user-id %}
<script src="{{context}}/js/select2.min.js" type="text/javascript"></script>
<script src="{{context}}/js/bootstrap-combobox.js" type="text/javascript"></script>
<script src="{{context}}/js/modals.js" type="text/javascript"></script>
{{ javascript('//ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js') }}
{{ javascript('/js/bootstrap.min.js') }}
{{ javascript('/js/markdown.js') }}
{{ javascript('/js/to-markdown.js') }}
{{ javascript('/js/bootstrap-markdown.js') }}
{{ javascript('/js/prettify.js') }}
{% if userId %}
{{ javascript('/js/select2.min.js') }}
{{ javascript('/js/bootstrap-combobox.js') }}
{{ javascript('/js/modals.js') }}
{% endif %}
<script src="{{context}}/js/site.js" type="text/javascript"></script>
{{ javascript('/js/site.js') }}
</head>
<body>
@ -37,35 +38,35 @@
<div class="navbar">
<div class="navbar-inner">
<a class="brand" href="{{context}}/">blarg.ca</a>
<a class="brand" href="{{ path('/') }}">blarg.ca</a>
<ul class="nav">
<li><a href="{{context}}/about">About</a></li>
<li><a href="{{context}}/archive">Archive</a></li>
<li><a href="{{context}}/projects">Projects</a></li>
<li><a href="{{ path('/about') }}">About</a></li>
<li><a href="{{ path('/archive') }}">Archive</a></li>
<li><a href="{{ path('/projects') }}">Projects</a></li>
</ul>
<ul class="nav pull-right">
{% if user-id %}
<li><a href="{{context}}/newpost"><i class="icon-pencil"></i> New Post</a></li>
<li><a href="{{context}}/listfiles"><i class="icon-file"></i> Files</a></li>
{% if userId %}
<li><a href="{{ path('/newpost') }}"><i class="icon-pencil"></i> New Post</a></li>
<li><a href="{{ path('/listfiles') }}"><i class="icon-file"></i> Files</a></li>
<li class="dropdown">
<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>
<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><a href="{{context}}/logout">Sign Out</a></li>
<li><a href="{{ path('/logout') }}">Sign Out</a></li>
</ul>
</li>
{% else %}
<li><a href="{{context}}/login">Login</a></li>
<li><a href="{{ path('/login') }}">Login</a></li>
{% endif %}
</ul>
</div>
</div>
{% if breadcrumbs %}
{% include "blarg/views/templates/breadcrumbs.html" %}
{% include "breadcrumbs.html" %}
{% endif %}
<div class="content" role="main">
@ -76,11 +77,11 @@
<div class="site-footer">
<div class="row">
<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="{{context}}/rss"><img src="{{context}}/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="http://www.linkedin.com/in/geredking"><img src="{{context}}/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="mailto:gered@blarg.ca"><img src="{{ path('/img/email.png') }}" width="32" height="32" alt="Email" /></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="{{ path('/img/twitter.png') }}" width="32" height="32" alt="Twitter" /></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="{{ path('/img/github.png') }}" width="32" height="32" alt="GitHub" /></a>
</div>
<div class="span6 text-right muted">
&copy; 2013, Gered King<br />
@ -91,5 +92,7 @@
</div>
<pre>{{ model|dump }}</pre>
</body>
</html>

View file

@ -1,9 +1,9 @@
<ul class="breadcrumb">
{% for crumb in breadcrumbs %}
{% if forloop.last %}
<li class="active">{{crumb.name}}</li>
{% if loop.last %}
<li class="active">{{ crumb.name }}</li>
{% 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 %}
{% endfor %}
</ul>

View file

@ -1,4 +1,4 @@
{% extends "blarg/views/templates/base.html" %}
{% extends "base.html" %}
{% block content %}
@ -9,7 +9,7 @@
<p>Sorry, an error has occurred.</p>
<div>
<pre>{{error-info}}</pre>
<pre>{{ errorInfo }}</pre>
</div>
{% endblock %}

View file

@ -1,26 +1,26 @@
{% extends "blarg/views/templates/base.html" %}
{% extends "../base.html" %}
{% block content %}
<div class="page-header">
<h2>Index of {{path}}</h2>
<h2>Index of {{ model['path'] }}</h2>
</div>
{% if success %}
<div class="alert alert-success">{{success}}</div>
<div class="alert alert-success">{{ success }}</div>
{% endif %}
{% if error %}
<div class="alert alert-error">{{error}}</div>
<div class="alert alert-error">{{ error }}</div>
{% endif %}
{% if notice %}
<div class="alert alert-info">{{notice}}</div>
{% if model['notice'] %}
<div class="alert alert-info">{{ model['notice'] }}</div>
{% endif %}
<div>
<div class="pull-left form-inline">
<select id="tree">
{% for folder in tree %}
<option{% ifequal folder path %} selected{% endifequal %}>{{folder}}</option>
<option{% if (folder == path) %} selected{% endif %}>{{ folder }}</option>
{% endfor %}
</select>
<a class="btn" href="#" id="tree-selector">Go</a>
@ -32,7 +32,7 @@
</div>
<div class="file-list-container">
{% if not files|is-empty %}
{% if (not files is empty) %}
<table class="table table-hover table-condensed">
<thead>
<tr>
@ -44,22 +44,22 @@
</thead>
<tbody>
{% for file in files %}
<tr{% if not file.published %} class="unpublished-file"{% endif %}>
<tr{% if (not file.published) %} class="unpublished-file"{% endif %}>
<td>
<a href="{{context}}/files{{path}}{{file.filename}}"><i class="icon-file"></i> {{file.filename}}</a><br />
<small class="muted">{{file.content-type}}</small>
<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>
</td>
<td>{{file.size}}</td>
<td>{{file.last_modified|to_fulltime}}</td>
<td>{{ file.size }}</td>
<td>{{ file.last_modified|to_fulltime }}</td>
<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 %}
<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 %}
{% 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>
{% if (not file.published) %}
<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 %}
<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>
</tr>
{% endfor %}
@ -75,8 +75,8 @@
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
<h3 id="newFileModalLabel">Upload File</h3>
</div>
<form action="{{context}}/uploadfile?returnpath={{path}}" method="post" enctype="multipart/form-data" class="form-horizontal">
<input type="hidden" id="newPath" name="path" value="{{path}}" />
<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="{{ model['path'] }}" />
<div class="modal-body">
<div class="control-group">
<label class="control-label" for="newFile">Upload File</label>
@ -98,7 +98,7 @@
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
<h3 id="updateFileModalLabel">Update File</h3>
</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" />
<div class="modal-body">
<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">&times;</button>
<h3 id="deleteFileModalLabel">Delete File</h3>
</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" />
<div class="modal-body">
<p>Confirm that you would like to delete the following file:</p>
@ -138,12 +138,12 @@
<script type="text/javascript">
$(document).ready(function() {
$('#tree').combobox({force_match: false});
$('#tree').data('combobox').val('{{path}}');
$('#tree').data('combobox').val('{{ model['path'] }}');
});
$('#tree-selector').click(function() {
var path = $('#tree').data('combobox').val();
window.location.href = '{{context}}/listfiles' + path;
window.location.href = '{{ path('/listfiles') }}' + path;
});
$('a[data-updatefileid]').click(function() {

View file

@ -1,4 +1,4 @@
{% extends "blarg/views/templates/base.html" %}
{% extends "base.html" %}
{% block content %}

View file

@ -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 class="modal-header">

View file

@ -1,4 +1,4 @@
{% extends "blarg/views/templates/base.html" %}
{% extends "../base.html" %}
{% block content %}
@ -6,6 +6,6 @@
<h2>Edit Post</h2>
</div>
{% include "blarg/views/templates/posts/postform.html" %}
{% include "postform.html" %}
{% endblock %}

View file

@ -1,31 +1,31 @@
{% extends "blarg/views/templates/base.html" %}
{% extends "../base.html" %}
{% block content %}
{% if posts|is-empty %}
{% if (posts is empty) %}
<div>
<p class="text-center">There are no posts.</p>
</div>
{% else %}
{% for post in posts %}
{% include "blarg/views/templates/posts/post.html" %}
{% include "post.html" %}
{% endfor %}
<ul class="pager">
{% if atlastpage %}
<li class="previous disabled"><a>&larr; Older</a></li>
{% else %}
<li class="previous"><a href="{{context}}/?page={{nextpage}}">&larr; Older</a></li>
<li class="previous"><a href="{{ path(concat('/?page=', nextpage)) }}">&larr; Older</a></li>
{% endif %}
{% if atfirstpage %}
<li class="next disabled"><a>Newer &rarr;</a></li>
{% else %}
<li class="next"><a href="{{context}}/?page={{prevpage}}">Newer &rarr;</a></li>
<li class="next"><a href="{{ path(concat('/?page=', prevpage)) }}">Newer &rarr;</a></li>
{% endif %}
</ul>
{% include "blarg/views/templates/posts/publishmodal.html" %}
{% include "blarg/views/templates/posts/deletemodal.html" %}
{% include "publishmodal.html" %}
{% include "deletemodal.html" %}
{% endif %}
{% endblock %}

View file

@ -1,4 +1,4 @@
{% extends "blarg/views/templates/base.html" %}
{% extends "../base.html" %}
{% block content %}
@ -9,12 +9,12 @@
<div>
{% for month in months %}
{% for post in month %}
{% if forloop.first %}
<h3>{{post.mmyyyy}}</h3>
{% if loop.first %}
<h3>{{ post.mmyyyy }}</h3>
{% endif %}
<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="span9"><a href="{{context}}{{post|post-url}}">{{post.title}}</a></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="{{ path(post|post_url) }}">{{ post.title }}</a></div>
</div>
{% endfor %}
{% endfor %}

View file

@ -1,15 +1,15 @@
{% extends "blarg/views/templates/base.html" %}
{% extends "../base.html" %}
{% block content %}
<div class="page-header">
<h2>Posts tagged with: {{tag}}</h2>
<h2>Posts tagged with: {{ tag }}</h2>
</div>
{% for post in posts %}
<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="span9"><a href="{{context}}{{post|post-url}}">{{post.title}}</a></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="{{ path(post|post_url) }}">{{ post.title }}</a></div>
</div>
{% endfor %}

View file

@ -1,4 +1,4 @@
{% extends "blarg/views/templates/base.html" %}
{% extends "../base.html" %}
{% block content %}
@ -6,6 +6,6 @@
<h2>New Post</h2>
</div>
{% include "blarg/views/templates/posts/postform.html" %}
{% include "postform.html" %}
{% endblock %}

View file

@ -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">
{% 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 %}
<h2>{{post.title}}</h2>
<h2>{{ post.title }}</h2>
{% endif %}
<div>
<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>
{% if user-id %}
{% if userId %}
<div class="pull-right">
<a class="btn btn-mini" href="{{context}}/editpost/{{post._id}}">Edit</a>
<a class="btn btn-mini btn-danger" data-deletepostid="{{post._id}}" href="#">Delete</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>
{% 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 %}
{% if not post.published %}
<a class="btn btn-mini btn-success" data-publishpostid="{{post._id}}" href="#">Publish</a>
{% if (not post.published) %}
<a class="btn btn-mini btn-success" data-publishpostid="{{ post._id }}" href="#">Publish</a>
{% endif %}
</div>
{% endif %}
@ -26,16 +26,16 @@
</div>
<div class="content">
{{post.body|md-to-html|safe}}
{{ post.body|md_to_html }}
</div>
<div class="footer">
<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>
{% if inlist %}
<div class="pull-right">
<a href="{{context}}{{post|post-url}}#comments">Comments</a>
<a href="{{ path(post|post_url) }}#comments">Comments</a>
</div>
{% endif %}
<div class="clearfix"></div>

View file

@ -2,19 +2,19 @@
<div class="control-group">
<label class="control-label" for="title">Title</label>
<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 class="control-group">
<label class="control-label" for="tags">Tags</label>
<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 class="control-group">
<label class="control-label" for="body">Post Body</label>
<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 class="form-actions">
@ -25,13 +25,13 @@
<script type="text/javascript">
$(document).ready(function() {
var allTags = {{all-tags|json|safe}};
var allTags = {{ allTags|json_encode }};
$("#body").markdown();
$("#tags").select2({tags:allTags});
$("#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) {
var inputElement = $('#' + field);
var controlGroup = inputElement.closest('div.control-group');

View file

@ -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 class="modal-header">

View file

@ -1,7 +1,7 @@
{% extends "blarg/views/templates/base.html" %}
{% extends "../base.html" %}
{% block content %}
{% include "blarg/views/templates/posts/post.html" %}
{% include "blarg/views/templates/posts/publishmodal.html" %}
{% include "blarg/views/templates/posts/deletemodal.html" %}
{% include "post.html" %}
{% include "publishmodal.html" %}
{% include "deletemodal.html" %}
{% endblock %}

View file

@ -1,4 +1,4 @@
{% extends "blarg/views/templates/base.html" %}
{% extends "base.html" %}
{% block content %}

View file

@ -1,4 +1,4 @@
{% extends "blarg/views/templates/base.html" %}
{% extends "base.html" %}
{% block content %}

View file

@ -14,7 +14,8 @@
[compojure.response :refer [render]]
[taoensso.timbre :as timbre]
[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.models.db :as db]))
@ -39,7 +40,7 @@
(when (= "DEV" (config-val :env))
(timbre/info "Dev environment. Template caching disabled.")
(parser/toggle-caching))
(jtwig/toggle-compiled-template-caching! false))
(timbre/info "touching database...")
(db/touch-databases))
@ -56,11 +57,11 @@
(layout/render-response
request
"error.html"
:params {:error-info e}
:params {:errorInfo e}
:status 500)))))
(def app (app-handler
[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}]
:formats [:json-kw :edn]))

View file

@ -18,8 +18,8 @@
(resp/redirect "/")
(layout/render
"auth/login.html"
:params {:login-error (session/flash-get :login-error)
:html-title (->html-title ["Login"])})))
:params {:loginError (session/flash-get :login-error)
:htmlTitle (->html-title ["Login"])})))
(defn handle-login [id pass]
(if-let [user (users/get-user id pass)]

View file

@ -17,7 +17,7 @@
(let [p (ensure-prefix-suffix path "/")]
(layout/render
"files/list.html"
:params {:html-title (->html-title [(str "Files in " p)])
:params {:htmlTitle (->html-title [(str "Files in " p)])
:path p
:files (files/list-files p)
:tree (files/get-tree)

View file

@ -2,7 +2,7 @@
(:require [clj-time.core]))
(defn get-post-url [post]
(str
(str
"/"
(clj-time.core/year (:created_at post)) "/"
(clj-time.core/month (:created_at post)) "/"

View file

@ -8,12 +8,12 @@
(defn about-page []
(layout/render
"about.html"
:params {:html-title (->html-title ["About"])}))
:params {:htmlTitle (->html-title ["About"])}))
(defn projects-page []
(layout/render
"projects.html"
:params {:html-title (->html-title ["Projects"])}))
:params {:htmlTitle (->html-title ["Projects"])}))
(defroutes home-routes
(GET "/about" [] (about-page))

View file

@ -68,7 +68,7 @@
(layout/render
"posts/showpost.html"
:params {:post post
:html-title (->html-title [(:title post)])})
:htmlTitle (->html-title [(:title post)])})
(resp/redirect "/notfound"))))
(defn new-post-page [& post]
@ -76,8 +76,8 @@
"posts/newpost.html"
:params (merge
(first post)
{:all-tags (posts/list-tags)
:html-title (->html-title ["New Post"])
{:allTags (posts/list-tags)
:htmlTitle (->html-title ["New Post"])
:validation-errors @vali/*errors*})))
(defn handle-new-post [title tags body]
@ -98,9 +98,9 @@
:params (merge
post
{:tags (tags->string (:tags post))
:all-tags (posts/list-tags)
:html-title (->html-title ["Edit Post"])
:validation-errors @vali/*errors*}))))
:allTags (posts/list-tags)
:htmlTitle (->html-title ["Edit Post"])
:validationErrors @vali/*errors*}))))
(defn handle-edit-post [id title tags body]
(if (valid-post? title tags body)

View file

@ -1,18 +1,18 @@
(ns blarg.views.layout
(:require [selmer.parser :as parser]
(:require [clj-jtwig.core :as jtwig]
[ring.util.response :as resp]
[compojure.response :refer [Renderable]]
[noir.session :as session])
(:use [blarg.views.viewfilters]))
(def template-path "blarg/views/templates/")
(def template-path "views/")
(defn- render-template [request template params]
(parser/render-file
(jtwig/render-resource
(str template-path template)
(assoc params
:context (:context request)
:user-id (session/get :user))))
:userId (session/get :user))))
(defn render-response [request template & {:keys [params status content-type]}]
(-> (render-template request template params)

View file

@ -1,31 +1,27 @@
(ns blarg.views.viewfilters
(:use [blarg.datetime]
[blarg.routes.helpers])
(:require [selmer.filters :refer [add-filter!]]
(:require [clj-jtwig.functions :refer [deftwigfn]]
[markdown.core :as md]
[clj-time.core]
[clj-time.format]))
(add-filter!
:md-to-html
#(md/md-to-html-string %))
(deftwigfn "md_to_html" [s]
(md/md-to-html-string s))
(add-filter!
:post-url
#(get-post-url %))
(deftwigfn "post_url" [post]
(->> post
(clojure.walk/keywordize-keys)
(get-post-url)))
(add-filter!
:to_relative
#(->relative-timestamp %))
(deftwigfn "to_relative" [date]
(->relative-timestamp date))
(add-filter!
:to_month-day
#(->month-day-str %))
(deftwigfn "to_month_day" [date]
(->month-day-str date))
(add-filter!
:to_fulltime
#(clj-time.local/format-local-time % :rfc822))
(deftwigfn "to_fulltime" [date]
(clj-time.local/format-local-time date :rfc822))
(add-filter!
:is-empty
#(empty? %))
(deftwigfn "is_empty" [x]
(empty? x))