Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
make things more friendly for the public deployment
- Loading branch information
Showing
7 changed files
with
134 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<p>You are logged out. You can browse and search the tweets already stored | ||
in the Twebz database, but in order for any of the "load more tweets | ||
from Twitter" options to work, you'll need to sign in.</p> | ||
<form class="search"> | ||
<label>Search: <input type="text" name="search" size=20></label> | ||
<input type="submit" value="Search"> | ||
<span class="matches"></span> | ||
</form> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
function() { | ||
var widget = $(this) | ||
, term = $("input[name=search]", widget).val() | ||
, app = $$(widget).app | ||
, nonce = Math.random() | ||
; | ||
$$(widget).nonce = nonce; | ||
app.db.list("twebz/topN","globalWordCount", { | ||
startkey : [term], | ||
endkey : [term+"\u9999"], | ||
group_level : 1, | ||
top : 10, | ||
success : function(list) { | ||
if ($$(widget).nonce == nonce) { | ||
$("form.search span.matches").html(list.map(function(t) { | ||
return '<a href="#/search/'+t+'">'+t+'</a>'; | ||
}).join(' ')); | ||
} | ||
} | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
function() { | ||
var term = $("input[name=search]", this).val(); | ||
$.pathbinder.go("/search/"+term); | ||
return false; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
var couchdb = require("couchdb") | ||
, client = couchdb.createClient(5984, "127.0.0.1", "jchris", "jchris") | ||
, db = client.db("twebz") | ||
; | ||
|
||
function renameDoc(rows) { | ||
process.nextTick(function() { | ||
while (r = rows.pop()) { | ||
if (r.id == parseInt(r.id).toString()) { | ||
break; | ||
} | ||
} | ||
// var r = rows.pop(); | ||
console.log(r.id); | ||
db.getDoc(r.id, function(er, doc) { | ||
if (er) { | ||
console.log(["err getDoc", er]) | ||
} else { | ||
var rev = doc._rev; | ||
var oldid = doc._id; | ||
delete doc._rev; | ||
doc._id = "twitter-"+doc._id; | ||
db.saveDoc(doc, function(er, resp) { | ||
if (er && er.error != "conflict") { | ||
console.log(er) | ||
} else { | ||
db.removeDoc(oldid, rev, function(er) { | ||
if (er) { | ||
console.log(["error deleting", oldid, er]) | ||
} else { | ||
console.log("renamed", oldid) | ||
renameDoc(rows); | ||
} | ||
}); | ||
} | ||
}); | ||
} | ||
}); | ||
}); | ||
}; | ||
|
||
db.allDocs(function(er, view) { | ||
console.log("got rows", view.rows.length) | ||
renameDoc(view.rows) | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters