Permalink
Browse files

[add] missing files

  • Loading branch information...
1 parent 68b60db commit d1ef6f61bdf9f57f7f78f0bff658116cbf023886 @yssk22 committed Apr 4, 2010
Showing with 1,893 additions and 16 deletions.
  1. +2 −0 .gitignore
  2. +20 −16 _attachments/scripts/crawler.py
  3. +3 −0 vendor/couchapp/README.md
  4. +53 −0 vendor/couchapp/_attachments/docs.css
  5. +32 −0 vendor/couchapp/_attachments/docs.html
  6. +8 −0 vendor/couchapp/_attachments/docs.js
  7. +202 −0 vendor/couchapp/_attachments/jquery.couch.app.js
  8. +50 −0 vendor/couchapp/_attachments/jquery.couch.app.util.js
  9. +308 −0 vendor/couchapp/_attachments/jquery.evently.js
  10. +282 −0 vendor/couchapp/_attachments/jquery.mustache.js
  11. +134 −0 vendor/couchapp/_attachments/jquery.pathbinder.js
  12. +187 −0 vendor/couchapp/docs/account.md
  13. +34 −0 vendor/couchapp/docs/couchapp.md
  14. +11 −0 vendor/couchapp/docs/docs.md
  15. +159 −0 vendor/couchapp/docs/evently.md
  16. +52 −0 vendor/couchapp/docs/pathbinder.md
  17. +3 −0 vendor/couchapp/docs/profile.md
  18. +15 −0 vendor/couchapp/evently/account/_init.js
  19. +3 −0 vendor/couchapp/evently/account/adminParty.js
  20. +10 −0 vendor/couchapp/evently/account/doLogin.js
  21. +8 −0 vendor/couchapp/evently/account/doLogout.js
  22. +10 −0 vendor/couchapp/evently/account/doSignup.js
  23. +4 −0 vendor/couchapp/evently/account/loggedIn/after.js
  24. +7 −0 vendor/couchapp/evently/account/loggedIn/data.js
  25. +4 −0 vendor/couchapp/evently/account/loggedIn/mustache.html
  26. +3 −0 vendor/couchapp/evently/account/loggedIn/selectors.json
  27. +1 −0 vendor/couchapp/evently/account/loggedOut/mustache.html
  28. +4 −0 vendor/couchapp/evently/account/loggedOut/selectors.json
  29. +3 −0 vendor/couchapp/evently/account/loginForm/after.js
  30. +6 −0 vendor/couchapp/evently/account/loginForm/mustache.html
  31. +1 −0 vendor/couchapp/evently/account/loginForm/selectors/a[href=#signup].json
  32. +6 −0 vendor/couchapp/evently/account/loginForm/selectors/form/submit.js
  33. +3 −0 vendor/couchapp/evently/account/signupForm/after.js
  34. +6 −0 vendor/couchapp/evently/account/signupForm/mustache.html
  35. +1 −0 vendor/couchapp/evently/account/signupForm/selectors/a[href=#login].json
  36. +6 −0 vendor/couchapp/evently/account/signupForm/selectors/form/submit.js
  37. +11 −0 vendor/couchapp/evently/docs/index/data.js
  38. +5 −0 vendor/couchapp/evently/docs/index/mustache.html
  39. +1 −0 vendor/couchapp/evently/docs/index/path.txt
  40. +15 −0 vendor/couchapp/evently/docs/topic/after.js
  41. +8 −0 vendor/couchapp/evently/docs/topic/data.js
  42. +19 −0 vendor/couchapp/evently/docs/topic/edit/_init/fun.js
  43. +9 −0 vendor/couchapp/evently/docs/topic/edit/_init/selectors/a.edit/click.js
  44. +22 −0 vendor/couchapp/evently/docs/topic/edit/_init/selectors/a.run/click.js
  45. +1 −0 vendor/couchapp/evently/docs/topic/mustache.html
  46. +1 −0 vendor/couchapp/evently/docs/topic/path.txt
  47. +19 −0 vendor/couchapp/evently/profile/loggedIn.js
  48. +3 −0 vendor/couchapp/evently/profile/loggedOut/after.js
  49. +1 −0 vendor/couchapp/evently/profile/loggedOut/mustache.html
  50. +3 −0 vendor/couchapp/evently/profile/noProfile/data.js
  51. +11 −0 vendor/couchapp/evently/profile/noProfile/mustache.html
  52. +36 −0 vendor/couchapp/evently/profile/noProfile/selectors/form/submit.js
  53. +7 −0 vendor/couchapp/evently/profile/profileReady/data.js
  54. +8 −0 vendor/couchapp/evently/profile/profileReady/mustache.html
  55. +4 −0 vendor/couchapp/metadata.json
  56. +67 −0 vendor/couchapp/path.js
  57. +1 −0 vendor/crayon
View
@@ -0,0 +1,2 @@
+.DS_Store
+.couchapprc
@@ -73,9 +73,23 @@ def parse_iepg(txt):
doc[key] = value.strip()
doc["memo"] = memo
-
return doc
+def import_iepg(db, link):
+ try:
+ print "url = %s" % link
+ _id = md5(link).hexdigest()
+ epg = fetch_content(link)
+ doc = parse_iepg(epg)
+ doc["_id"] = _id
+ doc["type"] = "iepg"
+ doc["url"] = link
+ print " id = %s" % doc["_id"]
+ print "title = %s" % doc["program-title"]
+ insert_or_update(db, doc)
+ except Exception, e:
+ traceback.print_exec()
+
if __name__ == "__main__":
try:
opts, args = getopt.getopt(sys.argv[1:], "hd:s:n:",
@@ -111,26 +125,16 @@ def parse_iepg(txt):
except ResourceNotFound:
db.put() # create a database
- for url in url_list(days = n):
+ list = url_list(days = n)
+ print "Collecting iEPG data from %s Urls" % len(list)
+ for url in list:
print "Fetching epg list menu from %s ..." % url
content = fetch_content(url)
links = extract_epg_link(content)
print "%s iEPGs found." % len(links)
founds += len(links)
for link in links:
- try:
- print "Converting iEPG to couch document"
- print "url = %s" % link
- _id = md5(link).hexdigest()
- epg = fetch_content(link)
- doc = parse_iepg(epg)
- doc["_id"] = _id
- doc["type"] = "iepg"
- doc["url"] = link
- print " id = %s" % doc["_id"]
- print "title = %s" % doc["program-title"]
- insert_or_update(db, doc)
- except Exception, e:
- traceback.print_exec()
+ import_iepg(db, link)
+
t2 = time.time()
print "%s iEPGs imported in %.2fs sec." % (founds, (t2 - t1))
@@ -0,0 +1,3 @@
+## CouchApp - more than just a filesystem mapper
+
+This is where documentation will go for the client and server JavaScript parts of CouchApp.
@@ -0,0 +1,53 @@
+body {
+ font:1em Helvetica, sans-serif;
+ margin:0;
+ padding:4px;
+}
+
+h1 {
+ margin:0.5em;
+}
+
+h2 {
+ color:#222;
+}
+
+pre {
+ padding:4px;
+ margin:4px;
+ background:#bbb;
+}
+
+#content {
+ padding:4px;
+ margin:2px;
+}
+
+#sidebar {
+ float:right;
+ width:34%;
+}
+
+#docs {
+ -moz-box-shadow:0 0 2em #000;
+ -webkit-box-shadow:0 0 2em #000;
+ width:58%;
+ padding:8px;
+ margin:4px;
+}
+
+.example {
+ background:#ffd;
+ padding:4px;
+ margin:4px;
+ position:absolute;
+}
+
+textarea.code {
+ width:100%;
+}
+
+.edit {
+ float:right;
+ font-size:0.8em;
+}
@@ -0,0 +1,32 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <title>Evently and CouchApp Docs</title>
+ <link rel="stylesheet" href="docs.css" type="text/css">
+ </head>
+ <body>
+ <div id="header">
+ <div id="account"></div>
+ <h1><a href="#/">Docs for $.evently, $.pathbinder, and $.couch.app</a></h1>
+ </div>
+ <div id="content">
+ <div id="sidebar">
+ <p><em>These docs are stored as Markdown in the CouchApp vendor directory. Use CouchApp to edit them on the filesystem.</em></p>
+ </div>
+ <div id="docs">
+ </div>
+ <br style="clear:both;"/>
+ </div>
+ </body>
+ <script src="/_utils/script/json2.js"></script>
+ <script src="/_utils/script/jquery.js"></script>
+ <script src="/_utils/script/jquery.couch.js"></script>
+ <script src="/_utils/script/sha1.js"></script>
+ <script src="jquery.couch.app.js"></script>
+ <script src="jquery.couch.app.util.js"></script>
+ <script src="jquery.evently.js"></script>
+ <script src="jquery.pathbinder.js"></script>
+ <script src="jquery.mustache.js"></script>
+ <script src="../showdown/showdown.js"></script>
+ <script src="docs.js"></script>
+</html>
@@ -0,0 +1,8 @@
+$.log = function() {
+ // console.log(arguments)
+};
+
+$.couch.app(function(app) {
+ $("#docs").evently(app.ddoc.vendor.couchapp.evently.docs, app);
+ $.pathbinder.begin("/");
+});
@@ -0,0 +1,202 @@
+// Licensed under the Apache License, Version 2.0 (the "License"); you may not
+// use this file except in compliance with the License. You may obtain a copy
+// of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+// License for the specific language governing permissions and limitations under
+// the License.
+
+// Usage: The passed in function is called when the page is ready.
+// CouchApp passes in the app object, which takes care of linking to
+// the proper database, and provides access to the CouchApp helpers.
+// $.couch.app(function(app) {
+// app.db.view(...)
+// ...
+// });
+
+(function($) {
+
+ function Design(db, name) {
+ this.doc_id = "_design/"+name;
+ this.view = function(view, opts) {
+ db.view(name+'/'+view, opts);
+ };
+ };
+
+ var login;
+
+ $.couch.app = $.couch.app || function(appFun) {
+ $(function() {
+ var dbname = document.location.href.split('/')[3];
+ var dname = unescape(document.location.href).split('/')[5];
+ var db = $.couch.db(dbname);
+ var design = new Design(db, dname);
+
+ // docForm applies CouchDB behavior to HTML forms.
+ // todo make this a couch.app plugin
+ function docForm(formSelector, opts) {
+ var localFormDoc = {};
+ opts = opts || {};
+ opts.fields = opts.fields || [];
+
+ // turn the form into deep json
+ // field names like 'author-email' get turned into json like
+ // {"author":{"email":"quentin@example.com"}}
+ function formToDeepJSON(form, fields, doc) {
+ var form = $(form);
+ opts.fields.forEach(function(field) {
+ var val = form.find("[name="+field+"]").val()
+ if (!val) return;
+ var parts = field.split('-');
+ var frontObj = doc, frontName = parts.shift();
+ while (parts.length > 0) {
+ frontObj[frontName] = frontObj[frontName] || {}
+ frontObj = frontObj[frontName];
+ frontName = parts.shift();
+ }
+ frontObj[frontName] = val;
+ });
+ };
+
+ // Apply the behavior
+ $(formSelector).submit(function(e) {
+ e.preventDefault();
+ // formToDeepJSON acts on localFormDoc by reference
+ formToDeepJSON(this, opts.fields, localFormDoc);
+ if (opts.beforeSave) opts.beforeSave(localFormDoc);
+ db.saveDoc(localFormDoc, {
+ success : function(resp) {
+ if (opts.success) opts.success(resp, localFormDoc);
+ }
+ })
+
+ return false;
+ });
+
+ // populate form from an existing doc
+ function docToForm(doc) {
+ var form = $(formSelector);
+ // fills in forms
+ opts.fields.forEach(function(field) {
+ var parts = field.split('-');
+ var run = true, frontObj = doc, frontName = parts.shift();
+ while (frontObj && parts.length > 0) {
+ frontObj = frontObj[frontName];
+ frontName = parts.shift();
+ }
+ if (frontObj && frontObj[frontName])
+ form.find("[name="+field+"]").val(frontObj[frontName]);
+ });
+ };
+
+ if (opts.id) {
+ db.openDoc(opts.id, {
+ success: function(doc) {
+ if (opts.onLoad) opts.onLoad(doc);
+ localFormDoc = doc;
+ docToForm(doc);
+ }});
+ } else if (opts.template) {
+ if (opts.onLoad) opts.onLoad(opts.template);
+ localFormDoc = opts.template;
+ docToForm(localFormDoc);
+ }
+ var instance = {
+ deleteDoc : function(opts) {
+ opts = opts || {};
+ if (confirm("Really delete this document?")) {
+ db.removeDoc(localFormDoc, opts);
+ }
+ },
+ localDoc : function() {
+ formToDeepJSON(formSelector, opts.fields, localFormDoc);
+ return localFormDoc;
+ }
+ }
+ return instance;
+ }
+
+ var appExports = $.extend({
+ showPath : function(funcname, docid) {
+ // I wish this was shared with path.js...
+ return '/'+[dbname, '_design', dname, '_show', funcname, docid].join('/')
+ },
+ listPath : function(funcname, viewname) {
+ return '/'+[dbname, '_design', dname, '_list', funcname, viewname].join('/')
+ },
+ slugifyString : function(string) {
+ return string.replace(/\W/g,'-').
+ replace(/\-*$/,'').replace(/^\-*/,'').
+ replace(/\-{2,}/,'-');
+ },
+ attemptLogin : function(win, fail) {
+ // depends on nasty hack in blog validation function
+ db.saveDoc({"author":"_self"}, { error: function(s, e, r) {
+ var namep = r.split(':');
+ if (namep[0] == '_self') {
+ login = namep.pop();
+ $.cookies.set("login", login, '/'+dbname)
+ win && win(login);
+ } else {
+ $.cookies.set("login", "", '/'+dbname)
+ fail && fail(s, e, r);
+ }
+ }});
+ },
+ loggedInNow : function(loggedIn, loggedOut) {
+ login = login || $.cookies.get("login");
+ if (login) {
+ loggedIn && loggedIn(login);
+ } else {
+ loggedOut && loggedOut();
+ }
+ },
+ db : db,
+ design : design,
+ view : design.view,
+ docForm : docForm
+ }, $.couch.app.app);
+
+ if ($.couch.app.ddocs[design.doc_id]) {
+ appExports.ddoc = $.couch.app.ddocs[design.doc_id];
+ appFun(appExports);
+ } else {
+ function handleDDoc(doc) {
+ if (doc) appExports.ddoc = doc;
+ appFun(appExports);
+ };
+ // only open 1 connection for this ddoc
+ if ($.couch.app.ddoc_handlers[design.doc_id]) {
+ // we are already fetching, just wait
+ $.couch.app.ddoc_handlers[design.doc_id].push(handleDDoc);
+ } else {
+ $.couch.app.ddoc_handlers[design.doc_id] = [handleDDoc];
+ db.openDoc(design.doc_id, {
+ success : function(doc) {
+ $.couch.app.ddocs[design.doc_id] = doc;
+ $.couch.app.ddoc_handlers[design.doc_id].forEach(function(h) {
+ h(doc);
+ })
+ $.couch.app.ddoc_handlers[design.doc_id] = null;
+ },
+ error : function() {
+ $.couch.app.ddoc_handlers[design.doc_id].forEach(function(h) {
+ h();
+ })
+ $.couch.app.ddoc_handlers[design.doc_id] = null;
+ }
+ });
+ }
+ }
+
+ });
+ };
+ $.couch.app.ddocs = {};
+ $.couch.app.ddoc_handlers = {};
+ // legacy support. $.CouchApp is deprecated, please use $.couch.app
+ $.CouchApp = $.couch.app;
+})(jQuery);
Oops, something went wrong.

0 comments on commit d1ef6f6

Please sign in to comment.