Permalink
Browse files

Ever so slightly useful.

  • Loading branch information...
1 parent c6255e1 commit b05340f914f0bb24e56b963edbd8a135afda4f09 @dustin dustin committed Jul 6, 2011
View
@@ -10,13 +10,19 @@ <h1>README</h1>
<div id="items"></div>
<div id="sidebar">
- <p>Some tools here would be nice.</p>
+ <ul class="statelist">
+ <li><a href="#" title="unread">Unread</a></li>
+ <li><a href="#" title="important">Important</a></li>
+ <li><a href="#" title="uninteresting">Uninteresting</a></li>
+ </ul>
</div>
</body>
<script src="vendor/couchapp/loader.js"></script>
+ <script type="text/javascript" src="js/readme.js"></script>
<script type="text/javascript" charset="utf-8">
$.couch.app(function(app) {
$("#items").evently("items", app);
+ rm_init_list_links(app);
});
</script>
</html>
@@ -0,0 +1,16 @@
+
+function couchapp_prefix_load(prefix) {
+ var scripts = [
+ "/_utils/script/sha1.js",
+ "/_utils/script/json2.js",
+ "/_utils/script/jquery.js",
+ "/_utils/script/jquery.couch.js",
+ prefix + "vendor/couchapp/jquery.couch.app.js",
+ prefix + "vendor/couchapp/jquery.couch.app.util.js",
+ prefix + "vendor/couchapp/jquery.mustache.js",
+ prefix + "vendor/couchapp/jquery.evently.js"
+ ];
+ for (var i=0; i < scripts.length; i++) {
+ document.write('<script src="'+scripts[i]+'"><\/script>')
+ };
+};
View
@@ -0,0 +1,33 @@
+function rm_init_update_links(app) {
+ var baseUri = app.db.uri;
+ var ddoc = app.ddoc._id;
+
+ $(".statechange").each(function(a, el) {
+ var parts = el.id.split('-');
+ $(el).click(function() {
+ $.ajax({type: 'POST',
+ url: baseUri + ddoc + "/_update/set_state/" + parts[1],
+ data: 'new_state=' + encodeURIComponent(parts[0]),
+ dataType: "json",
+ complete: function(res) {
+ console.log("Result", res);
+ }});
+
+ return false;
+ });
+ });
+}
+
+function rm_init_list_links(app) {
+ var path = app.require("vendor/couchapp/lib/path").init(app.req);
+
+ $(".statelist a").each(function(a, el) {
+ var state = el.title;
+ $(el).attr('href', path.list('todo', 'by_state', {state: state,
+ startkey: [state],
+ endkey: [state, {}],
+ descending: false,
+ include_docs: true,
+ limit: 50}));
+ });
+}
@@ -9,27 +9,14 @@ h1 {
margin-top:0;
}
-#account {
- float:right;
-}
-
-#profile {
- border:4px solid #edd;
- background:#fee;
- padding:8px;
- margin-bottom:8px;
-}
-
#items {
- border:4px solid #dde;
- background:#eef;
padding:8px;
width:60%;
float:left;
}
#sidebar {
- border:4px solid #dfd;
+ border:2px solid #eee;
padding:8px;
float:right;
width:30%;
@@ -42,34 +29,10 @@ h1 {
margin:4px 0;
}
-form {
- padding:4px;
- margin:6px;
- background-color:#ddd;
-}
-
-div.avatar {
- padding:2px;
- padding-bottom:0;
- margin-right:4px;
- float:left;
- font-size:0.78em;
- width : 60px;
- height : 60px;
- text-align: center;
-}
-
div.avatar .name {
padding-top:2px;
}
-div.avatar img {
- margin:0 auto;
- padding:0;
- width : 40px;
- height : 40px;
-}
-
#items ul {
list-style: none;
}
@@ -0,0 +1,12 @@
+function() {
+ var state = (window.location.hash || '#unread');
+ state = state.substring(1, state.length);
+ return {
+ "view" : "by_state",
+ "descending" : "false",
+ "limit" : 50,
+ "include_docs": "true",
+ "startkey": [state],
+ "endkey": [state, {}]
+ };
+}
@@ -1,6 +0,0 @@
-{
- "view" : "recent-items",
- "descending" : "true",
- "limit" : 50,
- "include_docs": "true"
-}
View
@@ -0,0 +1,30 @@
+function(head, req) {
+ // !json templates.head
+ // !json templates.item
+ // !json templates.tail
+
+ var state = req.query.state || 'unread';
+ var title = "items in " + state + " state";
+
+ provides("html", function() {
+ var row;
+
+ var data = {
+ title: title,
+ mainid: "items"
+ };
+
+ var Mustache = require("vendor/couchapp/lib/mustache");
+ var path = require("vendor/couchapp/lib/path").init(req);
+
+ send(Mustache.to_html(templates.head, data));
+ send("<h1>" + title + "</h1>");
+ send('<ul id="items">\n');
+
+ while( (row = getRow()) ) {
+ send(Mustache.to_html(templates.item, row.doc));
+ }
+ send("</ul>\n");
+ send(Mustache.to_html(templates.tail, data));
+ });
+}
View
@@ -0,0 +1,10 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta http-equiv="Content-type" content="text/html; charset=utf-8">
+ <link rel="stylesheet" href="../../../app/style/main.css"/>
+ <title>{{title}}</title>
+ </head>
+ <body>
+
+ <div id="{{mainid}}">
View
@@ -0,0 +1,10 @@
+<li>
+ <div class="header">
+ <img src="{{rm_favicon}}" alt="favicon" /><span class="name">{{author}}</span>
+ - <a href="{{link}}" class="title">{{title}}</a>
+ [<a href="#" class="statechange" id="uninteresting-{{_id}}" title="uninteresting">U</a>,
+ <a href="#" class="statechange" id="important-{{_id}}" title="important">!</a>]
+ </div>
+ <div id="message">{{{summary}}}</div>
+ <div style="clear:left;"></div>
+</li>
View
@@ -0,0 +1,24 @@
+</div>
+
+ <div id="sidebar">
+ <ul class="statelist">
+ <li><a href="#" title="unread">Unread</a></li>
+ <li><a href="#" title="important">Important</a></li>
+ <li><a href="#" title="uninteresting">Uninteresting</a></li>
+ </ul>
+ </div>
+
+<script src="../../js/prefix-loader.js"></script>
+<script type="text/javascript" charset="utf-8">
+ couchapp_prefix_load("../../");
+</script>
+<script src="../../js/readme.js"></script>
+
+<script type="text/javascript" charset="utf-8">
+$.couch.app(function(app) {
+ rm_init_update_links(app);
+ rm_init_list_links(app);
+});
+</script>
+</body>
+</html>
View
@@ -0,0 +1,5 @@
+function(doc) {
+ if (doc.rm_state) {
+ emit([doc.rm_state, doc.rm_updated], null);
+ }
+};
@@ -1,5 +0,0 @@
-function(doc) {
- if (doc.rm_state === 'unread') {
- emit(doc.rm_updated, null);
- }
-};

0 comments on commit b05340f

Please sign in to comment.