Permalink
Browse files

Added recent activity view.

  • Loading branch information...
1 parent 260c198 commit 1a39331db2e2924e0a417711747fdfb07e0e4162 @dustin dustin committed Sep 1, 2011
Showing with 60 additions and 0 deletions.
  1. +6 −0 _attachments/index.html
  2. +42 −0 _attachments/js/readme.js
  3. +6 −0 _attachments/style/main.css
  4. +1 −0 templates/item.html
  5. +5 −0 templates/tail.html
@@ -15,6 +15,11 @@
<li><a href="#" title="important">Important</a><span id="important-count"</span></li>
<li><a href="#" title="done">Done</a><span id="done-count"/></li>
</ul>
+
+ <h2>Recent Activity</h2>
+ <ul id="history">
+ </ul>
+
</div>
</body>
<script src="vendor/couchapp/loader.js"></script>
@@ -23,6 +28,7 @@
$.couch.app(function(app) {
$("#items").evently("items", app);
rm_init_list_links(app);
+ rm_refreshHistory(app);
});
</script>
</html>
@@ -55,6 +55,48 @@ function rm_updateCounts(app) {
});
}
+function rm_updateHistory(app) {
+ var path = app.require("vendor/couchapp/lib/path").init(app.req);
+ var Mustache = app.require("vendor/couchapp/lib/mustache");
+ var template = '<li><span class="timestamp" title="{{when}}">{{when}}</span>: ' +
+ '{{who}} <a href="{{link}}" title="{{title}}"><img src="{{favicon}}" alt="favicon" /> ' +
+ '{{from}} &rarr; {{to}}</a></li>';
+ var target = $("#history");
+ app.db.view('app/history', {
+ descending: true,
+ include_docs: true,
+ limit: 20,
+ success: function(d) {
+ target.html("");
+ console.log(d);
+ d.rows.forEach(function(r) {
+ var vals = {when: r.key[0],
+ what: r.id,
+ who: r.key[1],
+ from: r.key[2],
+ to: r.value,
+ favicon: r.doc.rm_favicon,
+ title: r.doc.title,
+ link: path.list('todo', 'by_state', {state: r.value,
+ startkey: [r.value],
+ endkey: [r.value, {}],
+ descending: false,
+ include_docs: true,
+ limit: 50}) + "#a-" + r.id
+ };
+ console.log(vals);
+ target.append(Mustache.to_html(template, vals));
+ });
+ rm_updateTimestamps(app);
+ }
+ });
+}
+
+function rm_refreshHistory(app) {
+ rm_updateHistory(app);
+ setTimeout(function() { rm_refreshHistory(app); }, 60000);
+}
+
function rm_refreshTimestamps() {
rm_updateTimestamps();
setTimeout(rm_refreshTimestamps, 60000);
@@ -36,3 +36,9 @@ div.avatar .name {
#items ul {
list-style: none;
}
+
+#history {
+ list-style: none;
+ font-size: smaller;
+ padding-left: 0;
+}
View
@@ -1,4 +1,5 @@
<li id='item-{{_id}}'>
+ <a name="a-{{_id}}"></a>
<div class="header">
<img src="{{rm_favicon}}" alt="favicon" />
[<a href="#" class="statechange" id="done-{{_id}}"
View
@@ -6,6 +6,10 @@
<li><a href="#" title="important">Important</a><span id="important-count"</span></li>
<li><a href="#" title="done">Done</a><span id="done-count"/></li>
</ul>
+
+ <h2>Recent Activity</h2>
+ <ul id="history">
+ </ul>
</div>
<script src="../../js/prefix-loader.js"></script>
@@ -19,6 +23,7 @@
rm_init_update_links(app);
rm_init_list_links(app);
rm_refreshTimestamps();
+ rm_refreshHistory(app);
});
</script>
</body>

0 comments on commit 1a39331

Please sign in to comment.