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

Display relative date in post. #150

Merged
merged 1 commit into from
Dec 10, 2014
Merged
Show file tree
Hide file tree
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
9 changes: 9 additions & 0 deletions resources/public/statuses/css/statuses.css
Original file line number Diff line number Diff line change
Expand Up @@ -236,3 +236,12 @@ footer {
line-height: 1.7em;
}

.tooltip.left .tooltip-inner {
background-color: #eee;
color: #555;
}

.tooltip.left .tooltip-arrow {
border-left-color: #eee;
}

10 changes: 10 additions & 0 deletions resources/public/statuses/js/statuses.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
if (shouldImgify()) {
imgify();
}
$(".post time").each(momentify);

function focusField(field) {
field.bind("focus", moveCursorToEOL); // XXX: no need for separate event handler?
Expand Down Expand Up @@ -102,6 +103,15 @@
return preferences[preferenceInlineImages] === "true";
}

function momentify() {
var timeField = $(this);
var currentTime = timeField.html();
var currentDateTime = timeField.attr("datetime");
var timeFromNow = moment(currentDateTime, moment.ISO_8601).fromNow();
timeField.html(timeFromNow);
timeField.tooltip({placement: "left", title: currentTime});
}

}(jQuery, preferenceStore()));

function preferenceStore() {
Expand Down
11 changes: 0 additions & 11 deletions src/statuses/backend/time.clj

This file was deleted.

1 change: 1 addition & 0 deletions src/statuses/views/layout.clj
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
[:footer footer]
(include-js "//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js")
(include-js "//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js")
(include-js "//cdnjs.cloudflare.com/ajax/libs/moment.js/2.8.4/moment.min.js")
(include-js "/statuses/lib/jquery-charCount.js")
(include-js "/statuses/lib/modernizr.min.js")
(include-js "/statuses/js/statuses.js")])))
Expand Down
6 changes: 3 additions & 3 deletions src/statuses/views/main.clj
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
(ns statuses.views.main
(:require [hiccup.core :refer [html]]
(:require [clj-time.local :refer [format-local-time]]
[hiccup.core :refer [html]]
[hiccup.element :refer [link-to]]
[hiccup.form :refer [form-to hidden-field text-field]]
[statuses.backend.time :as time]
[statuses.configuration :refer [config]]
[statuses.routes :refer [avatar-path update-path
updates-path]]
Expand All @@ -15,7 +15,7 @@
[:button {:type "submit" :class (str "btn btn-" class)} (html (icon icon-name) [:span.btn-label label])]))

(defn format-time [time]
[:time {:datetime (time/time-to-utc time)} (time/time-to-human time)])
[:time {:datetime (format-local-time time :date-time)} (format-local-time time :rfc822)])

(defn delete-form [id]
(form-to {:class "delete-form" :onsubmit "return confirm('Delete status?')"} [:delete (update-path id)]
Expand Down