display dates and times with moment.js

This commit is contained in:
Miguel Grinberg 2012-12-31 13:07:54 -08:00
parent 7843407425
commit 912c6f7b57
4 changed files with 17 additions and 3 deletions

6
app/static/js/moment.min.js vendored Normal file

File diff suppressed because one or more lines are too long

View File

@ -10,6 +10,7 @@
<link href="/static/css/bootstrap-responsive.min.css" rel="stylesheet">
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script src="/static/js/bootstrap.min.js"></script>
<script src="/static/js/moment.min.js"></script>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>

View File

@ -2,7 +2,10 @@
<tr>
<td width="70px"><a href="{{url_for('user', nickname = post.author.nickname)}}"><img src="{{post.author.avatar(70)}}" /></a></td>
<td>
<p><a href="{{url_for('user', nickname = post.author.nickname)}}">{{post.author.nickname}}</a> said on {{post.timestamp}}:</p>
<p><a href="{{url_for('user', nickname = post.author.nickname)}}">{{post.author.nickname}}</a> said
<script>
document.write(moment("{{post.timestamp.strftime("%Y-%m-%dT%H:%M:%S Z")}}").fromNow());
</script>:</p>
<p><strong>{{post.body}}</strong></p>
</td>
</tr>

View File

@ -9,7 +9,11 @@
</div>
<h1>{{user.nickname}}</h1>
{% if user.about_me %}<p>{{user.about_me}}</p>{% endif %}
{% if user.last_seen %}<p><em>Last seen on: {{user.last_seen}}</em></p>{% endif %}
{% if user.last_seen %}
<p><em>Last seen:
<script>document.write(moment("{{user.last_seen.strftime("%Y-%m-%dT%H:%M:%S Z")}}").calendar());</script>
</em></p>
{% endif %}
<p>Followers: {{user.followers.count() - 1}} | Following: {{user.followed.count() - 1}} |
{% if user.id == g.user.id %}
<a href="{{url_for('edit')}}">Edit your profile</a>