19 |
├── language ├── _id ├── .gitignore ├── vendor └── couchapp │ ├── evently │ ├── docs │ │ ├── index │ │ │ ├── path.txt │ │ │ ├── mustache.html │ │ │ └── data.js │ │ └── topic │ │ │ ├── path.txt │ │ │ ├── mustache.html │ │ │ ├── data.js │ │ │ ├── edit │ │ │ └── _init │ │ │ │ ├── selectors │ │ │ │ ├── a.edit │ │ │ │ │ └── click.js │ │ │ │ └── a.run │ │ │ │ │ └── click.js │ │ │ │ └── fun.js │ │ │ └── after.js │ ├── account │ │ ├── loginForm │ │ │ ├── selectors │ │ │ │ ├── a[href=#signup].json │ │ │ │ └── form │ │ │ │ │ └── submit.js │ │ │ ├── after.js │ │ │ └── mustache.html │ │ ├── signupForm │ │ │ ├── selectors │ │ │ │ ├── a[href=#login].json │ │ │ │ └── form │ │ │ │ │ └── submit.js │ │ │ ├── after.js │ │ │ └── mustache.html │ │ ├── loggedIn │ │ │ ├── selectors.json │ │ │ ├── after.js │ │ │ ├── mustache.html │ │ │ └── data.js │ │ ├── loggedOut │ │ │ ├── mustache.html │ │ │ └── selectors.json │ │ ├── adminParty │ │ │ └── mustache.html │ │ ├── doLogout.js │ │ ├── doLogin.js │ │ ├── doSignup.js │ │ └── _init.js │ ├── profile │ │ ├── loggedOut │ │ │ ├── mustache.html │ │ │ └── after.js │ │ ├── profileReady │ │ │ ├── data.js │ │ │ ├── after.js │ │ │ └── mustache.html │ │ ├── noProfile │ │ │ ├── data.js │ │ │ ├── mustache.html │ │ │ └── selectors │ │ │ │ └── form │ │ │ │ └── submit.js │ │ └── loggedIn.js │ └── README.md │ ├── metadata.json │ ├── docs │ ├── profile.md │ ├── docs.md │ ├── couchapp.md │ ├── pathbinder.md │ ├── evently.md │ └── account.md │ ├── README.md │ ├── lib │ ├── redirect.js │ ├── list.js │ ├── cache.js │ ├── atom.js │ ├── path.js │ ├── docform.js │ ├── md5.js │ └── markdown.js │ └── _attachments │ ├── docs.js │ ├── loader.js │ ├── docs.css │ ├── docs.html │ ├── jquery.couch.app.util.js │ ├── jquery.pathbinder.js │ ├── jquery.mustache.js │ ├── jquery.couch.app.js │ └── jquery.evently.js ├── couchapp.json ├── views └── recent-items │ └── map.js ├── evently ├── items │ └── _changes │ │ ├── query.json │ │ ├── data.js │ │ └── mustache.html └── profile │ └── profileReady │ ├── selectors │ └── form │ │ └── submit.js │ └── mustache.html ├── _attachments ├── style │ ├── brandongrotesque_light │ │ ├── Brandon_light-webfont.eot │ │ ├── Brandon_light-webfont.ttf │ │ ├── Brandon_light-webfont.woff │ │ ├── Extras │ │ │ └── Brandon_light-webfont.svgz │ │ ├── stylesheet.css │ │ └── demo.html │ ├── main.css │ ├── ui.css │ ├── blueprint-screen.css │ └── application.css ├── index.html └── couchappspora.js └── README.textile /language: -------------------------------------------------------------------------------- 1 | javascript -------------------------------------------------------------------------------- /_id: -------------------------------------------------------------------------------- 1 | _design/couchappspora -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | .couchapprc -------------------------------------------------------------------------------- /vendor/couchapp/evently/docs/index/path.txt: -------------------------------------------------------------------------------- 1 | / -------------------------------------------------------------------------------- /vendor/couchapp/evently/docs/topic/path.txt: -------------------------------------------------------------------------------- 1 | /topic/:id -------------------------------------------------------------------------------- /vendor/couchapp/evently/docs/topic/mustache.html: -------------------------------------------------------------------------------- 1 |
Please log in to see your profile.
-------------------------------------------------------------------------------- /vendor/couchapp/evently/profile/profileReady/data.js: -------------------------------------------------------------------------------- 1 | function(e, p) { 2 | return p 3 | } 4 | -------------------------------------------------------------------------------- /vendor/couchapp/evently/profile/loggedOut/after.js: -------------------------------------------------------------------------------- 1 | function() { 2 | $$(this).profile = null; 3 | }; -------------------------------------------------------------------------------- /vendor/couchapp/evently/profile/noProfile/data.js: -------------------------------------------------------------------------------- 1 | function(e, userCtx) { 2 | return userCtx; 3 | } -------------------------------------------------------------------------------- /vendor/couchapp/evently/profile/profileReady/after.js: -------------------------------------------------------------------------------- 1 | function(e, p) { 2 | $$(this).profile = p; 3 | }; -------------------------------------------------------------------------------- /vendor/couchapp/metadata.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "couchapp", 3 | "description": "official couchapp vendor" 4 | } -------------------------------------------------------------------------------- /vendor/couchapp/evently/account/loggedIn/selectors.json: -------------------------------------------------------------------------------- 1 | { 2 | "a[href=#logout]" : {"click" : ["doLogout"]} 3 | } -------------------------------------------------------------------------------- /vendor/couchapp/evently/account/loggedOut/mustache.html: -------------------------------------------------------------------------------- 1 | Signup or Login -------------------------------------------------------------------------------- /vendor/couchapp/evently/account/loginForm/after.js: -------------------------------------------------------------------------------- 1 | function() { 2 | $("input[name=name]", this).focus(); 3 | } -------------------------------------------------------------------------------- /vendor/couchapp/evently/account/signupForm/after.js: -------------------------------------------------------------------------------- 1 | function() { 2 | $("input[name=name]", this).focus(); 3 | } -------------------------------------------------------------------------------- /views/recent-items/map.js: -------------------------------------------------------------------------------- 1 | function(doc) { 2 | if (doc.created_at) { 3 | emit(doc.created_at, doc); 4 | } 5 | }; -------------------------------------------------------------------------------- /evently/items/_changes/query.json: -------------------------------------------------------------------------------- 1 | { 2 | "view" : "recent-items", 3 | "descending" : "true", 4 | "limit" : 50 5 | } -------------------------------------------------------------------------------- /vendor/couchapp/evently/docs/index/mustache.html: -------------------------------------------------------------------------------- 1 |Admin party, everyone is admin! Fix this in Futon before proceeding.
-------------------------------------------------------------------------------- /vendor/couchapp/lib/redirect.js: -------------------------------------------------------------------------------- 1 | exports.permanent = function(redirect) { 2 | return { 3 | code : 301, 4 | headers : { 5 | "Location" : redirect 6 | } 7 | }; 8 | }; -------------------------------------------------------------------------------- /_attachments/style/brandongrotesque_light/Brandon_light-webfont.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jchris/couchappspora/master/_attachments/style/brandongrotesque_light/Brandon_light-webfont.eot -------------------------------------------------------------------------------- /_attachments/style/brandongrotesque_light/Brandon_light-webfont.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jchris/couchappspora/master/_attachments/style/brandongrotesque_light/Brandon_light-webfont.ttf -------------------------------------------------------------------------------- /vendor/couchapp/evently/account/loggedIn/after.js: -------------------------------------------------------------------------------- 1 | // todo move to template 2 | function(e, r) { 3 | $(this).attr("data-name", r.userCtx.name); 4 | $$(this).userCtx = r.userCtx; 5 | } 6 | -------------------------------------------------------------------------------- /_attachments/style/brandongrotesque_light/Brandon_light-webfont.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jchris/couchappspora/master/_attachments/style/brandongrotesque_light/Brandon_light-webfont.woff -------------------------------------------------------------------------------- /vendor/couchapp/evently/account/doLogout.js: -------------------------------------------------------------------------------- 1 | function() { 2 | var elem = $(this); 3 | $.couch.logout({ 4 | success : function() { 5 | elem.trigger("_init"); 6 | } 7 | }); 8 | } -------------------------------------------------------------------------------- /_attachments/style/brandongrotesque_light/Extras/Brandon_light-webfont.svgz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jchris/couchappspora/master/_attachments/style/brandongrotesque_light/Extras/Brandon_light-webfont.svgz -------------------------------------------------------------------------------- /vendor/couchapp/evently/account/loggedIn/mustache.html: -------------------------------------------------------------------------------- 1 | Welcome 2 | {{name}}! 3 | Logout? 4 | -------------------------------------------------------------------------------- /vendor/couchapp/_attachments/docs.js: -------------------------------------------------------------------------------- 1 | $.log = function() { 2 | // console.log(arguments) 3 | }; 4 | 5 | $.couch.app(function(app) { 6 | $("#docs").evently(app.ddoc.vendor.couchapp.evently.docs, app); 7 | $.pathbinder.begin("/"); 8 | }); -------------------------------------------------------------------------------- /vendor/couchapp/evently/account/loggedIn/data.js: -------------------------------------------------------------------------------- 1 | function(e, r) { 2 | return { 3 | name : r.userCtx.name, 4 | uri_name : encodeURIComponent(r.userCtx.name), 5 | auth_db : encodeURIComponent(r.info.authentication_db) 6 | }; 7 | } -------------------------------------------------------------------------------- /evently/items/_changes/data.js: -------------------------------------------------------------------------------- 1 | function(data) { 2 | $.log(data) 3 | var p; 4 | return { 5 | items : data.rows.map(function(r) { 6 | p = r.value.profile; 7 | p.message = r.value.message; 8 | return p; 9 | }) 10 | } 11 | }; -------------------------------------------------------------------------------- /vendor/couchapp/evently/docs/topic/data.js: -------------------------------------------------------------------------------- 1 | function(e, p) { 2 | var doc = $$(this).app.ddoc.vendor.couchapp.docs[p.id]; 3 | var converter = new Showdown.converter(); 4 | var html = converter.makeHtml(doc); 5 | return { 6 | html : html 7 | }; 8 | }; -------------------------------------------------------------------------------- /vendor/couchapp/evently/account/doLogin.js: -------------------------------------------------------------------------------- 1 | function(e, name, pass) { 2 | var elem = $(this); 3 | $.couch.login({ 4 | name : name, 5 | password : pass, 6 | success : function(r) { 7 | elem.trigger("_init") 8 | } 9 | }); 10 | } -------------------------------------------------------------------------------- /vendor/couchapp/evently/account/doSignup.js: -------------------------------------------------------------------------------- 1 | function(e, name, pass) { 2 | var elem = $(this); 3 | $.couch.signup({ 4 | name : name 5 | }, pass, { 6 | success : function() { 7 | elem.trigger("doLogin", [name, pass]); 8 | } 9 | }); 10 | } -------------------------------------------------------------------------------- /vendor/couchapp/evently/account/loginForm/selectors/form/submit.js: -------------------------------------------------------------------------------- 1 | function(e) { 2 | var name = $('input[name=name]', this).val(), 3 | pass = $('input[name=password]', this).val(); 4 | $(this).trigger('doLogin', [name, pass]); 5 | return false; 6 | } -------------------------------------------------------------------------------- /vendor/couchapp/evently/account/signupForm/selectors/form/submit.js: -------------------------------------------------------------------------------- 1 | function(e) { 2 | var name = $('input[name=name]', this).val(), 3 | pass = $('input[name=password]', this).val(); 4 | $(this).trigger('doSignup', [name, pass]); 5 | return false; 6 | } -------------------------------------------------------------------------------- /vendor/couchapp/evently/profile/profileReady/mustache.html: -------------------------------------------------------------------------------- 1 |Hello {{nickname}}!
8 | -------------------------------------------------------------------------------- /vendor/couchapp/evently/account/loginForm/mustache.html: -------------------------------------------------------------------------------- 1 | 7 | -------------------------------------------------------------------------------- /vendor/couchapp/evently/account/signupForm/mustache.html: -------------------------------------------------------------------------------- 1 | 7 | -------------------------------------------------------------------------------- /vendor/couchapp/evently/docs/index/data.js: -------------------------------------------------------------------------------- 1 | function() { 2 | var docs = $$(this).app.ddoc.vendor.couchapp.docs; 3 | var dnames = []; 4 | $.forIn(docs, function(d) { 5 | dnames.push({ 6 | title: d, 7 | href : "#/topic/"+encodeURIComponent(d) 8 | }); 9 | }); 10 | return {docs:dnames}; 11 | }; -------------------------------------------------------------------------------- /vendor/couchapp/evently/docs/topic/edit/_init/selectors/a.edit/click.js: -------------------------------------------------------------------------------- 1 | function() { 2 | var pre = $(this).prev('pre'); 3 | var js = pre.text(); 4 | var lines = js.split('\n').length; 5 | var ta = $(''); 6 | ta.text(js); 7 | pre.replace(ta); 8 | return false; 9 | }; 10 | -------------------------------------------------------------------------------- /vendor/couchapp/lib/list.js: -------------------------------------------------------------------------------- 1 | // Helpers for writing server-side _list functions in CouchDB 2 | exports.withRows = function(fun) { 3 | var f = function() { 4 | var row = getRow(); 5 | return row && fun(row); 6 | }; 7 | f.iterator = true; 8 | return f; 9 | } 10 | 11 | exports.send = function(chunk) { 12 | send(chunk + "\n") 13 | } -------------------------------------------------------------------------------- /evently/profile/profileReady/selectors/form/submit.js: -------------------------------------------------------------------------------- 1 | function() { 2 | var form = this; 3 | var doc = { 4 | created_at : new Date(), 5 | profile : $$("#profile").profile, 6 | message : $("[name=message]", form).val() 7 | }; 8 | $$(this).app.db.saveDoc(doc, { 9 | success : function() { 10 | $("[name=message]", form).val(""); 11 | } 12 | }); 13 | return false; 14 | }; 15 | -------------------------------------------------------------------------------- /vendor/couchapp/evently/account/_init.js: -------------------------------------------------------------------------------- 1 | function() { 2 | var elem = $(this); 3 | $.couch.session({ 4 | success : function(r) { 5 | var userCtx = r.userCtx; 6 | if (userCtx.name) { 7 | elem.trigger("loggedIn", [r]); 8 | } else if (userCtx.roles.indexOf("_admin") != -1) { 9 | elem.trigger("adminParty"); 10 | } else { 11 | elem.trigger("loggedOut"); 12 | }; 13 | } 14 | }); 15 | } -------------------------------------------------------------------------------- /evently/profile/profileReady/mustache.html: -------------------------------------------------------------------------------- 1 |Most applications will customize this template (ddoc.evently.profile.profileReady.mustache) for user input.
2 | 3 |Error running #', id, 5 | ' code block:
', 6 | (y.toSource ? y.toSource() : JSON.stringify(y)), 7 | ''].join('')); 8 | } 9 | var id = e.data.args[1]; 10 | var example = $("#code-"+id); 11 | var js = $('textarea',example).val() || $('pre',example).text(); 12 | $('#'+id).unbind(); 13 | try { 14 | eval(js); 15 | } catch (y) { 16 | err(y, id); 17 | } 18 | } catch(x) { 19 | err(x, id); 20 | } 21 | return false; 22 | } -------------------------------------------------------------------------------- /evently/items/_changes/mustache.html: -------------------------------------------------------------------------------- 1 |
Customize this format here: ddoc.evently.items._changes.mustache
2 |{{message}}
13 | 14 |Protip: If you setup continuous replication between this database and a remote one, this list will reflect remote changes in near real-time.
18 |This would be a good place to add pagination.
19 | -------------------------------------------------------------------------------- /vendor/couchapp/evently/docs/topic/edit/_init/fun.js: -------------------------------------------------------------------------------- 1 | function(e, id) { 2 | var editable = $(this); 3 | if ($$(editable)._init_ran) {return false;} 4 | // add edit link 5 | var edit = $('edit code'); 6 | editable.append(edit); 7 | 8 | // add run box 9 | var example = $('The db name is {{name}}
', 9 | data : app.db 10 | } 11 | }); 12 | }); 13 | 14 | Yay couchapp. 15 | 16 | The `$.couch.app()` function also loads the current design document so that it is available for templates etc. That is how the words you are reading were loaded. This file is included in the CouchApp application library. Let's look at the design doc: 17 | 18 | $.couch.app(function(app) { 19 | $("#ddoc").evently({ 20 | _init : { 21 | mustache : 'Click to show the full doc source:
{{ddoc}}',
22 | data : {
23 | ddoc : JSON.stringify(app.ddoc, null, 2).slice(0,100) + '...'
24 | }
25 | },
26 | click : {
27 | mustache : 'The full doc source (rerun to hide):
{{ddoc}}',
28 | data : {
29 | ddoc : JSON.stringify(app.ddoc, null, 2)
30 | }
31 | }
32 | });
33 | });
34 |
35 |
--------------------------------------------------------------------------------
/vendor/couchapp/_attachments/docs.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | To use the kit, include the stylesheet.css file in your HTML and wherever you want to use the font insert:
36 | 37 |font-family: 'BrandonGrotesqueLightRegular',Arial,sans-serif;
38 |
39 | 40 | The quick brown fox jumps over the lazy dog. 41 |
42 |you went to foo
"); 14 | }); 15 | $("#basic_path").pathbinder("foo", "/foo"); 16 | 17 | This code sets up the `#basic_path` div with some initial content, including a link to `#/foo`. If you click the link to foo, you'll see the URL change. It is the changed URL which Pathbinder sees and uses to trigger any running code. You can experiment by manually entering the `#/foo` URL hash, instead of clicking the link, and you'll see that it also triggers the `foo` event. 18 | 19 | ## Using path parameters 20 | 21 | Pathbinder was inspired by the path handling in [Sammy.js](http://github.com/aq/sammy.js). Like Sammy, you can use it to pull parameters from the URL-hash. This page can be linked [using a path that has "pathbinder" as a parameter](#/topic/pathbinder). Let's explore how you can pull parameters out of a path. 22 | 23 | $("#param_path").html(''); 24 | $("#param_path").bind("foo", function(e, params) { 25 | $(this).html("you went to foo - "+params.id+"
"); 26 | }); 27 | $("#param_path").pathbinder("foo", "/foo/:id"); 28 | 29 | When you click the link to super foo, you'll see the param is passed through the event. You can also edit the URL to see that "super" is not hard coded and can be replaced with other values. 30 | 31 | ## Pathbinder with Evently 32 | 33 | It should be no suprise that Pathbinder and Evently play well together. The gist of it is that Evently looks for a key called `path` and if it finds it, uses Pathbinder to connect that event handler to the path. Let's try it out: 34 | 35 | $("#evently_path").evently({ 36 | _init : { 37 | path : '/index', 38 | mustache : 'the index. more cowbell!
' 39 | }, 40 | cowbell : { 41 | path : '/cowbell', 42 | mustache : 'Now that is a lot of cowbell. back to the index
' 43 | } 44 | }); 45 | 46 | Note that when you use an Evently path, Evently also takes care to visit the path when the corresponding event is triggered. So running the above example code (which automatically triggers the `_init` event) will set the hash to `#/index`. If you were to trigger the `cowbell` event through non-path means, you'd see that it changes the path to `#/cowbell` anyway. 47 | 48 | ### Too many widgets 49 | 50 | One thing worth noting: there is only one URL hash for any given page, so be aware that if you have multiple widgets competing for the real-estate, they could conflict with each other. Pathbinder won't do anything when presented with a path it doesn't care about (go ahead, try out some non-sense ones on this page). 51 | 52 | This means that if you have a few widgets all using the path, the page should still behave in a useful way. However, this breaks down if you intend people to be able to use the URL hash to link to page state. Since there can be only one URL hash, whichever action they took last will be reflected in the bookmarked URL. For this reason it makes sense to limit yourself to one path-based Evently widget per page. 53 | -------------------------------------------------------------------------------- /_attachments/couchappspora.js: -------------------------------------------------------------------------------- 1 | var CouchAppspora = (function() { 2 | 3 | var dbName = "couchappspora", 4 | attachments = []; 5 | 6 | function cloneHeader(e) { 7 | e.preventDefault(); 8 | $("#headertemplate").clone().appendTo($("#headers")).show(); 9 | }; 10 | 11 | function removeHeader(e) { 12 | if (e.target.getAttribute("data-action") === "delete") { 13 | e.preventDefault(); 14 | $(e.target).closest("li").remove(); 15 | } 16 | }; 17 | 18 | function removeAttachment(e) { 19 | 20 | if (e.target.getAttribute("data-action") === "delete") { 21 | e.preventDefault(); 22 | 23 | var i, attach = [], 24 | $parent = $(e.target).closest("li"), 25 | text = $parent.find("span").text(); 26 | 27 | for (i = 0; i < attachments.length; i += 1) { 28 | if (attachments[i].file.name !== text) { 29 | attach.push(attachments[i]); 30 | } 31 | } 32 | attachments = attach; 33 | renderAttachments(); 34 | } 35 | }; 36 | 37 | function hasStupidChromeBug() { 38 | return typeof(FileReader.prototype.addEventListener) !== "function"; 39 | }; 40 | 41 | function isImage(type) { 42 | return type === "image/png" || type === "image/jpeg"; 43 | }; 44 | 45 | function renderAttachments() { 46 | 47 | var i, tmp, html = "Hello world
", 16 | }, 17 | click : { 18 | mustache : "What a crazy world!
", 19 | } 20 | }); 21 | 22 | You can also do some more interesting things: 23 | 24 | $("#heyjane").evently({ 25 | _init : { 26 | mustache : '', 27 | selectors : { 28 | 'a[href=#joan]' : { 29 | click : 'hiJoan' 30 | }, 31 | 'a[href=#jane]' : { 32 | click : 'hiJane' 33 | } 34 | } 35 | }, 36 | hiJoan : { 37 | mustache : 'Hello Joan!
' 38 | }, 39 | hiJane : { 40 | mustache : "Darn, it's Jane...
", 41 | after : function() { 42 | setTimeout(function() { 43 | // automatically trigger the "janeRocks" event after 2 seconds. 44 | $("#heyjane").trigger("janeRocks"); 45 | }, 2000); 46 | } 47 | }, 48 | janeRocks : { 49 | render : "append", 50 | mustache : "Actually Jane is awesome.
" 51 | } 52 | }); 53 | 54 | 55 | The imporant thing about this is that the widget is defined by an JavaScript object. This means we can save it as files on our hard drive and `couchapp` will handle saving it as a JSON object for us. 56 | 57 | [screenshot of the above code in textmate's file drawer] 58 | 59 | When we let CouchApp package our evently apps we get to work on them in individual files, instead of as a great big giant mess of JavaScript. This means HTML is HTML, JSON is JSON, and JavaScript is JavaScript. Yay! 60 | 61 | ## Ajax Hello World 62 | 63 | Let's do a little Ajax. We'll just load the version of the CouchDB instance we happen to be serving our HTML from: 64 | 65 | $("#ajax").evently({ 66 | _init : { 67 | mustache : 'Loading CouchDB server info.
', 68 | after : function() { 69 | var widget = $(this); 70 | $.ajax({ 71 | url : '/', 72 | complete : function(req) { 73 | var resp = $.httpData(req, "json"); 74 | widget.trigger("version", [resp]); 75 | } 76 | }) 77 | } 78 | }, 79 | version : { 80 | mustache : "Running CouchDB version {{version}}
", 81 | data : function(e, resp) { 82 | return resp; 83 | } 84 | } 85 | }); 86 | 87 | Explain `mustache` and `data` 88 | 89 | -- triggering other events 90 | -- selectors 91 | -- create a doc 92 | 93 | ## Evently and CouchApp together 94 | 95 | Evently makes it easy to write decoupled JavaScript code, but as the examples above show, Evently widgets can turn into a lot of JSON to look at all on one screen. Because Evently code is declarative, and each handler and callback stands on its own (instead of being wrapped in a common closure), it can be broken out into individual files. 96 | 97 | CouchApp provides a mechanism for mapping between individual files and JSON structures. In this model a directory structure is mapped to a JSON object. So if you have a directory structure like: 98 | 99 | _init/ 100 | mustache.html 101 | selectors/ 102 | form/ 103 | submit.js 104 | input.name/ 105 | change.js 106 | a.cancel/ 107 | click.txt 108 | cancelled/ 109 | mustache.html 110 | selectors/ 111 | a.continue/ 112 | click.txt 113 | 114 | It will appear within your CouchApp design document as: 115 | 116 | { 117 | _init : { 118 | mustache : "contents of mustache.html", 119 | selectors { 120 | form : { 121 | submit : "function() { ... }" 122 | }, 123 | "input.name" { 124 | change : "function() { ... }" 125 | }, 126 | "a.cancel" { 127 | click : "cancelled" 128 | } 129 | } 130 | }, 131 | cancelled : { 132 | mustache : "contents of mustache.html", 133 | selectors : { 134 | "a.continue" : { 135 | click : "_init" 136 | } 137 | } 138 | } 139 | } 140 | 141 | This makes Evently and CouchApp a natural fit for each other. I swear I didn't plan this when I started writing Evently, it just turned out to be an awesome side effect of trying to stay as close to JSON as possible. 142 | 143 | In the [account widget tutorial](#/topic/account) we see the details of the account widget. What isn't discussed much there, is how the code is edited on your filesystem. 144 | 145 | If you are writing an Evently CouchApp widget you can edit the individual pieces on your filesystem. This has the added advantage of giving you native syntax highlighting for all the code. Instead of editing everything as JSON or JavaScript, the templates can be treated as HTML, the paths as text, etc. 146 | 147 | ## Evently Queries 148 | 149 | Evently understands CouchDB in a couple of very simple ways. If you know CouchDB, you're probably familiar with its Map Reduce views. Evently lets you specify view queries in a declarative way, and even takes care of the Ajax request. All you have to do is write code to handle the returned data. 150 | 151 | -- new rows, etc 152 | 153 | -- run a query 154 | 155 | -- connect to changes 156 | 157 | -- links to example apps 158 | 159 | ## Freeform Asynchronous Actions 160 | 161 | Watch out, you're dangerous! Evently allows you to make any old asyncronous action you want, with the `widget.async` member. The callback is the first argument to the `async` function. Check it out: 162 | 163 | $("#async").evently({ 164 | _init : { 165 | mustache : "How many databases on the local host?
Answer: {{number_of_dbs}}
Other stuff: {{args}}
More: {{allArgs}}
", 166 | async : function(cb) { 167 | var ag = Array.prototype.slice.call(arguments).map(function(a){return a.toSource ? a.toSource() : a}); 168 | $.couch.allDbs({ 169 | success : function(resp) { 170 | cb(resp.length, ag); 171 | } 172 | }) 173 | }, 174 | data : function(count, args) { 175 | return { 176 | number_of_dbs : count, 177 | args : JSON.stringify(args), 178 | allArgs : JSON.stringify(Array.prototype.slice.call(arguments)) 179 | }; 180 | } 181 | }, 182 | click : { 183 | mustache : "What a crazy world!
", 184 | } 185 | }); -------------------------------------------------------------------------------- /vendor/couchapp/_attachments/jquery.mustache.js: -------------------------------------------------------------------------------- 1 | /* 2 | Shameless port of a shameless port 3 | @defunkt => @janl => @aq 4 | 5 | See http://github.com/defunkt/mustache for more info. 6 | */ 7 | 8 | ;(function($) { 9 | 10 | /* 11 | Shamless port of http://github.com/defunkt/mustache 12 | by Jan LehnardtNot much to see here
" 162 | }, 163 | loggedIn : { 164 | mustache : "loggedIn was triggered from another widget, {{name}}.
", 165 | data : function(e, r) { 166 | return { name : r.userCtx.name }; 167 | } 168 | } 169 | }); 170 | 171 | Be sure to run the above example code before the next one, otherwise there won't be anything to link to. 172 | 173 | This next block of code demonstrates how to link two widgets together. First we create a normal account widget on the `#link_source` element, then we tell Evently to connect it to the `#link_target` element. Now whenever the `loggedIn` evenr is triggered on the source, it will be triggered on the target. 174 | 175 | $.couch.app(function(app){ 176 | $("#link_source").evently(app.ddoc.vendor.couchapp.evently.account); 177 | // link the source to the target, for the loggedIn event 178 | $.evently.connect($("#link_source"), $("#link_target"), ["loggedIn"]); 179 | }); 180 | 181 | ## Conclusion 182 | 183 | If you are writing a CouchApp that will have users logging and and logging out, you'd do well to use the account widget. It's customizable and linkable. And what's more, it's code that's already written. 184 | 185 | Enjoy! 186 | 187 | -------------------------------------------------------------------------------- /vendor/couchapp/lib/md5.js: -------------------------------------------------------------------------------- 1 | /* 2 | * A JavaScript implementation of the RSA Data Security, Inc. MD5 Message 3 | * Digest Algorithm, as defined in RFC 1321. 4 | * Version 2.1 Copyright (C) Paul Johnston 1999 - 2002. 5 | * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet 6 | * Distributed under the BSD License 7 | * See http://pajhome.org.uk/crypt/md5 for more info. 8 | */ 9 | 10 | /* 11 | * Configurable variables. You may need to tweak these to be compatible with 12 | * the server-side, but the defaults work in most cases. 13 | */ 14 | var hexcase = 0; /* hex output format. 0 - lowercase; 1 - uppercase */ 15 | var b64pad = ""; /* base-64 pad character. "=" for strict RFC compliance */ 16 | var chrsz = 8; /* bits per input character. 8 - ASCII; 16 - Unicode */ 17 | 18 | /* 19 | * These are the functions you'll usually want to call 20 | * They take string arguments and return either hex or base-64 encoded strings 21 | */ 22 | function hex_md5(s){ return binl2hex(core_md5(str2binl(s), s.length * chrsz));} 23 | function b64_md5(s){ return binl2b64(core_md5(str2binl(s), s.length * chrsz));} 24 | function str_md5(s){ return binl2str(core_md5(str2binl(s), s.length * chrsz));} 25 | function hex_hmac_md5(key, data) { return binl2hex(core_hmac_md5(key, data)); } 26 | function b64_hmac_md5(key, data) { return binl2b64(core_hmac_md5(key, data)); } 27 | function str_hmac_md5(key, data) { return binl2str(core_hmac_md5(key, data)); } 28 | 29 | /* 30 | * Perform a simple self-test to see if the VM is working 31 | */ 32 | function md5_vm_test() 33 | { 34 | return hex_md5("abc") == "900150983cd24fb0d6963f7d28e17f72"; 35 | } 36 | 37 | /* 38 | * Calculate the MD5 of an array of little-endian words, and a bit length 39 | keep 40 | */ 41 | function core_md5(x, len) 42 | { 43 | /* append padding */ 44 | x[len >> 5] |= 0x80 << ((len) % 32); 45 | x[(((len + 64) >>> 9) << 4) + 14] = len; 46 | 47 | var a = 1732584193; 48 | var b = -271733879; 49 | var c = -1732584194; 50 | var d = 271733878; 51 | 52 | for(var i = 0; i < x.length; i += 16) 53 | { 54 | var olda = a; 55 | var oldb = b; 56 | var oldc = c; 57 | var oldd = d; 58 | 59 | a = md5_ff(a, b, c, d, x[i+ 0], 7 , -680876936); 60 | d = md5_ff(d, a, b, c, x[i+ 1], 12, -389564586); 61 | c = md5_ff(c, d, a, b, x[i+ 2], 17, 606105819); 62 | b = md5_ff(b, c, d, a, x[i+ 3], 22, -1044525330); 63 | a = md5_ff(a, b, c, d, x[i+ 4], 7 , -176418897); 64 | d = md5_ff(d, a, b, c, x[i+ 5], 12, 1200080426); 65 | c = md5_ff(c, d, a, b, x[i+ 6], 17, -1473231341); 66 | b = md5_ff(b, c, d, a, x[i+ 7], 22, -45705983); 67 | a = md5_ff(a, b, c, d, x[i+ 8], 7 , 1770035416); 68 | d = md5_ff(d, a, b, c, x[i+ 9], 12, -1958414417); 69 | c = md5_ff(c, d, a, b, x[i+10], 17, -42063); 70 | b = md5_ff(b, c, d, a, x[i+11], 22, -1990404162); 71 | a = md5_ff(a, b, c, d, x[i+12], 7 , 1804603682); 72 | d = md5_ff(d, a, b, c, x[i+13], 12, -40341101); 73 | c = md5_ff(c, d, a, b, x[i+14], 17, -1502002290); 74 | b = md5_ff(b, c, d, a, x[i+15], 22, 1236535329); 75 | 76 | a = md5_gg(a, b, c, d, x[i+ 1], 5 , -165796510); 77 | d = md5_gg(d, a, b, c, x[i+ 6], 9 , -1069501632); 78 | c = md5_gg(c, d, a, b, x[i+11], 14, 643717713); 79 | b = md5_gg(b, c, d, a, x[i+ 0], 20, -373897302); 80 | a = md5_gg(a, b, c, d, x[i+ 5], 5 , -701558691); 81 | d = md5_gg(d, a, b, c, x[i+10], 9 , 38016083); 82 | c = md5_gg(c, d, a, b, x[i+15], 14, -660478335); 83 | b = md5_gg(b, c, d, a, x[i+ 4], 20, -405537848); 84 | a = md5_gg(a, b, c, d, x[i+ 9], 5 , 568446438); 85 | d = md5_gg(d, a, b, c, x[i+14], 9 , -1019803690); 86 | c = md5_gg(c, d, a, b, x[i+ 3], 14, -187363961); 87 | b = md5_gg(b, c, d, a, x[i+ 8], 20, 1163531501); 88 | a = md5_gg(a, b, c, d, x[i+13], 5 , -1444681467); 89 | d = md5_gg(d, a, b, c, x[i+ 2], 9 , -51403784); 90 | c = md5_gg(c, d, a, b, x[i+ 7], 14, 1735328473); 91 | b = md5_gg(b, c, d, a, x[i+12], 20, -1926607734); 92 | 93 | a = md5_hh(a, b, c, d, x[i+ 5], 4 , -378558); 94 | d = md5_hh(d, a, b, c, x[i+ 8], 11, -2022574463); 95 | c = md5_hh(c, d, a, b, x[i+11], 16, 1839030562); 96 | b = md5_hh(b, c, d, a, x[i+14], 23, -35309556); 97 | a = md5_hh(a, b, c, d, x[i+ 1], 4 , -1530992060); 98 | d = md5_hh(d, a, b, c, x[i+ 4], 11, 1272893353); 99 | c = md5_hh(c, d, a, b, x[i+ 7], 16, -155497632); 100 | b = md5_hh(b, c, d, a, x[i+10], 23, -1094730640); 101 | a = md5_hh(a, b, c, d, x[i+13], 4 , 681279174); 102 | d = md5_hh(d, a, b, c, x[i+ 0], 11, -358537222); 103 | c = md5_hh(c, d, a, b, x[i+ 3], 16, -722521979); 104 | b = md5_hh(b, c, d, a, x[i+ 6], 23, 76029189); 105 | a = md5_hh(a, b, c, d, x[i+ 9], 4 , -640364487); 106 | d = md5_hh(d, a, b, c, x[i+12], 11, -421815835); 107 | c = md5_hh(c, d, a, b, x[i+15], 16, 530742520); 108 | b = md5_hh(b, c, d, a, x[i+ 2], 23, -995338651); 109 | 110 | a = md5_ii(a, b, c, d, x[i+ 0], 6 , -198630844); 111 | d = md5_ii(d, a, b, c, x[i+ 7], 10, 1126891415); 112 | c = md5_ii(c, d, a, b, x[i+14], 15, -1416354905); 113 | b = md5_ii(b, c, d, a, x[i+ 5], 21, -57434055); 114 | a = md5_ii(a, b, c, d, x[i+12], 6 , 1700485571); 115 | d = md5_ii(d, a, b, c, x[i+ 3], 10, -1894986606); 116 | c = md5_ii(c, d, a, b, x[i+10], 15, -1051523); 117 | b = md5_ii(b, c, d, a, x[i+ 1], 21, -2054922799); 118 | a = md5_ii(a, b, c, d, x[i+ 8], 6 , 1873313359); 119 | d = md5_ii(d, a, b, c, x[i+15], 10, -30611744); 120 | c = md5_ii(c, d, a, b, x[i+ 6], 15, -1560198380); 121 | b = md5_ii(b, c, d, a, x[i+13], 21, 1309151649); 122 | a = md5_ii(a, b, c, d, x[i+ 4], 6 , -145523070); 123 | d = md5_ii(d, a, b, c, x[i+11], 10, -1120210379); 124 | c = md5_ii(c, d, a, b, x[i+ 2], 15, 718787259); 125 | b = md5_ii(b, c, d, a, x[i+ 9], 21, -343485551); 126 | 127 | a = safe_add(a, olda); 128 | b = safe_add(b, oldb); 129 | c = safe_add(c, oldc); 130 | d = safe_add(d, oldd); 131 | } 132 | return Array(a, b, c, d); 133 | 134 | } 135 | 136 | /* 137 | * These functions implement the four basic operations the algorithm uses. 138 | */ 139 | function md5_cmn(q, a, b, x, s, t) 140 | { 141 | return safe_add(bit_rol(safe_add(safe_add(a, q), safe_add(x, t)), s),b); 142 | } 143 | function md5_ff(a, b, c, d, x, s, t) 144 | { 145 | return md5_cmn((b & c) | ((~b) & d), a, b, x, s, t); 146 | } 147 | function md5_gg(a, b, c, d, x, s, t) 148 | { 149 | return md5_cmn((b & d) | (c & (~d)), a, b, x, s, t); 150 | } 151 | function md5_hh(a, b, c, d, x, s, t) 152 | { 153 | return md5_cmn(b ^ c ^ d, a, b, x, s, t); 154 | } 155 | function md5_ii(a, b, c, d, x, s, t) 156 | { 157 | return md5_cmn(c ^ (b | (~d)), a, b, x, s, t); 158 | } 159 | 160 | /* 161 | * Calculate the HMAC-MD5, of a key and some data 162 | */ 163 | function core_hmac_md5(key, data) 164 | { 165 | var bkey = str2binl(key); 166 | if(bkey.length > 16) bkey = core_md5(bkey, key.length * chrsz); 167 | 168 | var ipad = Array(16), opad = Array(16); 169 | for(var i = 0; i < 16; i++) 170 | { 171 | ipad[i] = bkey[i] ^ 0x36363636; 172 | opad[i] = bkey[i] ^ 0x5C5C5C5C; 173 | } 174 | 175 | var hash = core_md5(ipad.concat(str2binl(data)), 512 + data.length * chrsz); 176 | return core_md5(opad.concat(hash), 512 + 128); 177 | } 178 | 179 | /* 180 | * Add integers, wrapping at 2^32. This uses 16-bit operations internally 181 | * to work around bugs in some JS interpreters. 182 | */ 183 | function safe_add(x, y) 184 | { 185 | var lsw = (x & 0xFFFF) + (y & 0xFFFF); 186 | var msw = (x >> 16) + (y >> 16) + (lsw >> 16); 187 | return (msw << 16) | (lsw & 0xFFFF); 188 | } 189 | 190 | /* 191 | * Bitwise rotate a 32-bit number to the left. 192 | */ 193 | function bit_rol(num, cnt) 194 | { 195 | return (num << cnt) | (num >>> (32 - cnt)); 196 | } 197 | 198 | /* 199 | * Convert a string to an array of little-endian words 200 | * If chrsz is ASCII, characters >255 have their hi-byte silently ignored. 201 | keep 202 | */ 203 | function str2binl(str) 204 | { 205 | var bin = Array(); 206 | var mask = (1 << chrsz) - 1; 207 | for(var i = 0; i < str.length * chrsz; i += chrsz) 208 | bin[i>>5] |= (str.charCodeAt(i / chrsz) & mask) << (i%32); 209 | return bin; 210 | } 211 | 212 | /* 213 | * Convert an array of little-endian words to a string 214 | */ 215 | function binl2str(bin) 216 | { 217 | var str = ""; 218 | var mask = (1 << chrsz) - 1; 219 | for(var i = 0; i < bin.length * 32; i += chrsz) 220 | str += String.fromCharCode((bin[i>>5] >>> (i % 32)) & mask); 221 | return str; 222 | } 223 | 224 | /* 225 | * Convert an array of little-endian words to a hex string. 226 | keep 227 | */ 228 | function binl2hex(binarray) 229 | { 230 | var hex_tab = hexcase ? "0123456789ABCDEF" : "0123456789abcdef"; 231 | var str = ""; 232 | for(var i = 0; i < binarray.length * 4; i++) 233 | { 234 | str += hex_tab.charAt((binarray[i>>2] >> ((i%4)*8+4)) & 0xF) + 235 | hex_tab.charAt((binarray[i>>2] >> ((i%4)*8 )) & 0xF); 236 | } 237 | return str; 238 | } 239 | 240 | /* 241 | * Convert an array of little-endian words to a base-64 string 242 | */ 243 | function binl2b64(binarray) 244 | { 245 | var tab = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; 246 | var str = ""; 247 | for(var i = 0; i < binarray.length * 4; i += 3) 248 | { 249 | var triplet = (((binarray[i >> 2] >> 8 * ( i %4)) & 0xFF) << 16) 250 | | (((binarray[i+1 >> 2] >> 8 * ((i+1)%4)) & 0xFF) << 8 ) 251 | | ((binarray[i+2 >> 2] >> 8 * ((i+2)%4)) & 0xFF); 252 | for(var j = 0; j < 4; j++) 253 | { 254 | if(i * 8 + j * 6 > binarray.length * 32) str += b64pad; 255 | else str += tab.charAt((triplet >> 6*(3-j)) & 0x3F); 256 | } 257 | } 258 | return str; 259 | } 260 | 261 | exports.hex = hex_md5; 262 | -------------------------------------------------------------------------------- /vendor/couchapp/_attachments/jquery.couch.app.js: -------------------------------------------------------------------------------- 1 | // Licensed under the Apache License, Version 2.0 (the "License"); you may not 2 | // use this file except in compliance with the License. You may obtain a copy 3 | // of the License at 4 | // 5 | // http://www.apache.org/licenses/LICENSE-2.0 6 | // 7 | // Unless required by applicable law or agreed to in writing, software 8 | // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 9 | // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 10 | // License for the specific language governing permissions and limitations under 11 | // the License. 12 | 13 | // Usage: The passed in function is called when the page is ready. 14 | // CouchApp passes in the app object, which takes care of linking to 15 | // the proper database, and provides access to the CouchApp helpers. 16 | // $.couch.app(function(app) { 17 | // app.db.view(...) 18 | // ... 19 | // }); 20 | 21 | (function($) { 22 | 23 | function Design(db, name) { 24 | this.doc_id = "_design/"+name; 25 | this.view = function(view, opts) { 26 | db.view(name+'/'+view, opts); 27 | }; 28 | this.list = function(list, view, opts) { 29 | db.list(name+'/'+list, view, opts); 30 | }; 31 | } 32 | 33 | $.couch.app = $.couch.app || function(appFun, opts) { 34 | opts = opts || {}; 35 | $(function() { 36 | var dbname = opts.db || document.location.href.split('/')[3]; 37 | var dname = opts.design || unescape(document.location.href).split('/')[5]; 38 | var db = $.couch.db(dbname); 39 | var design = new Design(db, dname); 40 | 41 | // docForm applies CouchDB behavior to HTML forms. 42 | // todo make this a couch.app plugin 43 | function docForm(formSelector, opts) { 44 | var localFormDoc = {}; 45 | opts = opts || {}; 46 | opts.fields = opts.fields || []; 47 | 48 | // turn the form into deep json 49 | // field names like 'author-email' get turned into json like 50 | // {"author":{"email":"quentin@example.com"}} 51 | function formToDeepJSON(form, fields, doc) { 52 | form = $(form); 53 | opts.fields.forEach(function(field) { 54 | var element = form.find("[name="+field+"]"); 55 | if (element.attr('type') === 'checkbox') { 56 | var val = element.attr('checked'); 57 | } else { 58 | var val = element.val(); 59 | if (!val) return; 60 | } 61 | var parts = field.split('-'); 62 | var frontObj = doc, frontName = parts.shift(); 63 | while (parts.length > 0) { 64 | frontObj[frontName] = frontObj[frontName] || {}; 65 | frontObj = frontObj[frontName]; 66 | frontName = parts.shift(); 67 | } 68 | frontObj[frontName] = val; 69 | }); 70 | } 71 | 72 | // Apply the behavior 73 | $(formSelector).submit(function(e) { 74 | e.preventDefault(); 75 | // formToDeepJSON acts on localFormDoc by reference 76 | formToDeepJSON(this, opts.fields, localFormDoc); 77 | if (opts.beforeSave) {opts.beforeSave(localFormDoc);} 78 | db.saveDoc(localFormDoc, { 79 | success : function(resp) { 80 | if (opts.success) {opts.success(resp, localFormDoc);} 81 | } 82 | }); 83 | 84 | return false; 85 | }); 86 | 87 | // populate form from an existing doc 88 | function docToForm(doc) { 89 | var form = $(formSelector); 90 | // fills in forms 91 | opts.fields.forEach(function(field) { 92 | var parts = field.split('-'); 93 | var run = true, frontObj = doc, frontName = parts.shift(); 94 | while (frontObj && parts.length > 0) { 95 | frontObj = frontObj[frontName]; 96 | frontName = parts.shift(); 97 | } 98 | if (frontObj && frontObj[frontName]) { 99 | var element = form.find("[name="+field+"]"); 100 | if (element.attr('type') === 'checkbox') { 101 | element.attr('checked', frontObj[frontName]); 102 | } else { 103 | element.val(frontObj[frontName]); 104 | } 105 | } 106 | }); 107 | } 108 | 109 | if (opts.id) { 110 | db.openDoc(opts.id, { 111 | attachPrevRev : opts.attachPrevRev, 112 | success: function(doc) { 113 | if (opts.onLoad) {opts.onLoad(doc);} 114 | localFormDoc = doc; 115 | docToForm(doc); 116 | }}); 117 | } else if (opts.template) { 118 | if (opts.onLoad) {opts.onLoad(opts.template);} 119 | localFormDoc = opts.template; 120 | docToForm(localFormDoc); 121 | } 122 | var instance = { 123 | deleteDoc : function(opts) { 124 | opts = opts || {}; 125 | if (confirm("Really delete this document?")) { 126 | db.removeDoc(localFormDoc, opts); 127 | } 128 | }, 129 | localDoc : function() { 130 | formToDeepJSON(formSelector, opts.fields, localFormDoc); 131 | return localFormDoc; 132 | } 133 | }; 134 | return instance; 135 | } 136 | 137 | function resolveModule(names, parent, current) { 138 | if (names.length === 0) { 139 | if (typeof current != "string") { 140 | throw ["error","invalid_require_path", 141 | 'Must require a JavaScript string, not: '+(typeof current)]; 142 | } 143 | return [current, parent]; 144 | } 145 | // we need to traverse the path 146 | var n = names.shift(); 147 | if (n == '..') { 148 | if (!(parent && parent.parent)) { 149 | throw ["error", "invalid_require_path", 'Object has no parent '+JSON.stringify(current)]; 150 | } 151 | return resolveModule(names, parent.parent.parent, parent.parent); 152 | } else if (n == '.') { 153 | if (!parent) { 154 | throw ["error", "invalid_require_path", 'Object has no parent '+JSON.stringify(current)]; 155 | } 156 | return resolveModule(names, parent.parent, parent); 157 | } 158 | if (!current[n]) { 159 | throw ["error", "invalid_require_path", 'Object has no property "'+n+'". '+JSON.stringify(current)]; 160 | } 161 | var p = current; 162 | current = current[n]; 163 | current.parent = p; 164 | return resolveModule(names, p, current); 165 | } 166 | 167 | var p = document.location.pathname.split('/'); 168 | p.shift(); 169 | var qs = document.location.search.replace(/^\?/,'').split('&'); 170 | var q = {}; 171 | qs.forEach(function(param) { 172 | var ps = param.split('='); 173 | var k = decodeURIComponent(ps[0]); 174 | var v = decodeURIComponent(ps[1]); 175 | if (["startkey", "endkey", "key"].indexOf(k) != -1) { 176 | q[k] = JSON.parse(v); 177 | } else { 178 | q[k] = v; 179 | } 180 | }); 181 | var mockReq = { 182 | path : p, 183 | query : q 184 | }; 185 | 186 | var appExports = $.extend({ 187 | db : db, 188 | design : design, 189 | view : design.view, 190 | list : design.list, 191 | docForm : docForm, 192 | req : mockReq 193 | }, $.couch.app.app); 194 | 195 | function handleDDoc(ddoc) { 196 | if (ddoc) { 197 | var require = function(name, parent) { 198 | var exports = {}; 199 | var resolved = resolveModule(name.split('/'), parent, ddoc); 200 | var source = resolved[0]; 201 | parent = resolved[1]; 202 | var s = "var func = function (exports, require) { " + source + " };"; 203 | try { 204 | eval(s); 205 | func.apply(ddoc, [exports, function(name) {return require(name, parent, source)}]); 206 | } catch(e) { 207 | throw ["error","compilation_error","Module require('"+name+"') raised error "+e.toSource()]; 208 | } 209 | return exports; 210 | } 211 | appExports.ddoc = ddoc; 212 | appExports.require = require; 213 | } 214 | // todo make app-exports the this in the execution context? 215 | appFun.apply(appExports, [appExports]); 216 | } 217 | 218 | if ($.couch.app.ddocs[design.doc_id]) { 219 | handleDDoc($.couch.app.ddocs[design.doc_id]) 220 | } else { 221 | // only open 1 connection for this ddoc 222 | if ($.couch.app.ddoc_handlers[design.doc_id]) { 223 | // we are already fetching, just wait 224 | $.couch.app.ddoc_handlers[design.doc_id].push(handleDDoc); 225 | } else { 226 | $.couch.app.ddoc_handlers[design.doc_id] = [handleDDoc]; 227 | db.openDoc(design.doc_id, { 228 | success : function(doc) { 229 | $.couch.app.ddocs[design.doc_id] = doc; 230 | $.couch.app.ddoc_handlers[design.doc_id].forEach(function(h) { 231 | h(doc); 232 | }); 233 | $.couch.app.ddoc_handlers[design.doc_id] = null; 234 | }, 235 | error : function() { 236 | $.couch.app.ddoc_handlers[design.doc_id].forEach(function(h) { 237 | h(); 238 | }); 239 | $.couch.app.ddoc_handlers[design.doc_id] = null; 240 | } 241 | }); 242 | } 243 | } 244 | 245 | }); 246 | }; 247 | $.couch.app.ddocs = {}; 248 | $.couch.app.ddoc_handlers = {}; 249 | // legacy support. $.CouchApp is deprecated, please use $.couch.app 250 | $.CouchApp = $.couch.app; 251 | })(jQuery); 252 | 253 | // JavaScript 1.6 compatibility functions that are missing from IE7/IE8 254 | 255 | if (!Array.prototype.forEach) 256 | { 257 | Array.prototype.forEach = function(fun /*, thisp*/) 258 | { 259 | var len = this.length >>> 0; 260 | if (typeof fun != "function") 261 | throw new TypeError(); 262 | 263 | var thisp = arguments[1]; 264 | for (var i = 0; i < len; i++) 265 | { 266 | if (i in this) 267 | fun.call(thisp, this[i], i, this); 268 | } 269 | }; 270 | } 271 | 272 | if (!Array.prototype.indexOf) 273 | { 274 | Array.prototype.indexOf = function(elt) 275 | { 276 | var len = this.length >>> 0; 277 | 278 | var from = Number(arguments[1]) || 0; 279 | from = (from < 0) 280 | ? Math.ceil(from) 281 | : Math.floor(from); 282 | if (from < 0) 283 | from += len; 284 | 285 | for (; from < len; from++) 286 | { 287 | if (from in this && 288 | this[from] === elt) 289 | return from; 290 | } 291 | return -1; 292 | }; 293 | } 294 | -------------------------------------------------------------------------------- /vendor/couchapp/_attachments/jquery.evently.js: -------------------------------------------------------------------------------- 1 | // $$ inspired by @wycats: http://yehudakatz.com/2009/04/20/evented-programming-with-jquery/ 2 | function $$(node) { 3 | var data = $(node).data("$$"); 4 | if (data) { 5 | return data; 6 | } else { 7 | data = {}; 8 | $(node).data("$$", data); 9 | return data; 10 | } 11 | }; 12 | 13 | (function($) { 14 | // utility functions used in the implementation 15 | 16 | function forIn(obj, fun) { 17 | var name; 18 | for (name in obj) { 19 | if (obj.hasOwnProperty(name)) { 20 | fun(name, obj[name]); 21 | } 22 | } 23 | }; 24 | $.forIn = forIn; 25 | function funViaString(fun) { 26 | if (fun && fun.match && fun.match(/^function/)) { 27 | eval("var f = "+fun); 28 | if (typeof f == "function") { 29 | return function() { 30 | try { 31 | return f.apply(this, arguments); 32 | } catch(e) { 33 | // IF YOU SEE AN ERROR HERE IT HAPPENED WHEN WE TRIED TO RUN YOUR FUNCTION 34 | // $.log({"message": "Error in evently function.", "error": e, "src" : fun}); 35 | throw(e); 36 | } 37 | }; 38 | } 39 | } 40 | return fun; 41 | }; 42 | 43 | function runIfFun(me, fun, args) { 44 | // if the field is a function, call it, bound to the widget 45 | var f = funViaString(fun); 46 | if (typeof f == "function") { 47 | return f.apply(me, args); 48 | } else { 49 | return fun; 50 | } 51 | } 52 | 53 | $.evently = { 54 | connect : function(source, target, events) { 55 | events.forEach(function(ev) { 56 | $(source).bind(ev, function() { 57 | var args = $.makeArray(arguments); 58 | // remove the original event to keep from stacking args extra deep 59 | // it would be nice if jquery had a way to pass the original 60 | // event to the trigger method. 61 | args.shift(); 62 | $(target).trigger(ev, args); 63 | return false; 64 | }); 65 | }); 66 | }, 67 | paths : [], 68 | changesDBs : {} 69 | }; 70 | 71 | function extractFrom(name, evs) { 72 | return evs[name]; 73 | }; 74 | 75 | function extractEvents(name, ddoc) { 76 | // extract events from ddoc.evently and ddoc.vendor.*.evently 77 | var events = [true, {}]; 78 | $.forIn(ddoc.vendor, function(k, v) { 79 | if (v.evently && v.evently[name]) { 80 | events.push(v.evently[name]); 81 | } 82 | }); 83 | if (ddoc.evently[name]) {events.push(ddoc.evently[name]);} 84 | return $.extend.apply(null, events); 85 | } 86 | 87 | $.fn.evently = function(events, app, args) { 88 | var elem = $(this); 89 | // store the app on the element for later use 90 | if (app) { 91 | $$(elem).app = app; 92 | } 93 | 94 | if (typeof events == "string") { 95 | events = extractEvents(events, app.ddoc); 96 | } 97 | 98 | $$(elem).evently = events; 99 | // setup the handlers onto elem 100 | forIn(events, function(name, h) { 101 | eventlyHandler(elem, name, h, args); 102 | }); 103 | 104 | if (events._init) { 105 | // $.log("ev _init", elem); 106 | elem.trigger("_init", args); 107 | } 108 | 109 | if (app && events._changes) { 110 | $("body").bind("evently.changes."+app.db.name, function() { 111 | // we want to unbind this function when the element is deleted. 112 | // maybe jquery 1.4.2 has this covered? 113 | // $.log('changes', elem); 114 | elem.trigger("_changes"); 115 | }); 116 | followChanges(app); 117 | elem.trigger("_changes"); 118 | } 119 | }; 120 | 121 | // eventlyHandler applies the user's handler (h) to the 122 | // elem, bound to trigger based on name. 123 | function eventlyHandler(elem, name, h, args) { 124 | if (h.path) { 125 | elem.pathbinder(name, h.path); 126 | } 127 | var f = funViaString(h); 128 | if (typeof f == "function") { 129 | elem.bind(name, {args:args}, f); 130 | } else if (typeof f == "string") { 131 | elem.bind(name, {args:args}, function() { 132 | $(this).trigger(f, arguments); 133 | return false; 134 | }); 135 | } else if ($.isArray(h)) { 136 | // handle arrays recursively 137 | for (var i=0; i < h.length; i++) { 138 | eventlyHandler(elem, name, h[i], args); 139 | } 140 | } else { 141 | // an object is using the evently / mustache template system 142 | if (h.fun) { 143 | elem.bind(name, {args:args}, funViaString(h.fun)); 144 | } 145 | // templates, selectors, etc are intepreted 146 | // when our named event is triggered. 147 | elem.bind(name, {args:args}, function() { 148 | renderElement($(this), h, arguments); 149 | return false; 150 | }); 151 | } 152 | }; 153 | 154 | $.fn.replace = function(elem) { 155 | // $.log("Replace", this) 156 | $(this).empty().append(elem); 157 | }; 158 | 159 | // todo: ability to call this 160 | // to render and "prepend/append/etc" a new element to the host element (me) 161 | // as well as call this in a way that replaces the host elements content 162 | // this would be easy if there is a simple way to get at the element we just appended 163 | // (as html) so that we can attache the selectors 164 | function renderElement(me, h, args, qrun, arun) { 165 | // if there's a query object we run the query, 166 | // and then call the data function with the response. 167 | if (h.before && (!qrun || !arun)) { 168 | funViaString(h.before).apply(me, args); 169 | } 170 | if (h.async && !arun) { 171 | runAsync(me, h, args) 172 | } else if (h.query && !qrun) { 173 | // $.log("query before renderElement", arguments) 174 | runQuery(me, h, args) 175 | } else { 176 | // $.log("renderElement") 177 | // $.log(me, h, args, qrun) 178 | // otherwise we just render the template with the current args 179 | var selectors = runIfFun(me, h.selectors, args); 180 | var act = (h.render || "replace").replace(/\s/g,""); 181 | var app = $$(me).app; 182 | if (h.mustache) { 183 | // $.log("rendering", h.mustache) 184 | var newElem = mustachioed(me, h, args); 185 | me[act](newElem); 186 | } 187 | if (selectors) { 188 | if (act == "replace") { 189 | var s = me; 190 | } else { 191 | var s = newElem; 192 | } 193 | forIn(selectors, function(selector, handlers) { 194 | // $.log("selector", selector); 195 | // $.log("selected", $(selector, s)); 196 | $(selector, s).evently(handlers, app, args); 197 | // $.log("applied", selector); 198 | }); 199 | } 200 | if (h.after) { 201 | runIfFun(me, h.after, args); 202 | // funViaString(h.after).apply(me, args); 203 | } 204 | } 205 | }; 206 | 207 | // todo this should return the new element 208 | function mustachioed(me, h, args) { 209 | return $($.mustache( 210 | runIfFun(me, h.mustache, args), 211 | runIfFun(me, h.data, args), 212 | runIfFun(me, h.partials, args))); 213 | }; 214 | 215 | function runAsync(me, h, args) { 216 | // the callback is the first argument 217 | funViaString(h.async).apply(me, [function() { 218 | renderElement(me, h, 219 | $.argsToArray(arguments).concat($.argsToArray(args)), false, true); 220 | }].concat($.argsToArray(args))); 221 | }; 222 | 223 | 224 | function runQuery(me, h, args) { 225 | // $.log("runQuery: args", args) 226 | var app = $$(me).app; 227 | var qu = runIfFun(me, h.query, args); 228 | var qType = qu.type; 229 | var viewName = qu.view; 230 | var userSuccess = qu.success; 231 | // $.log("qType", qType) 232 | 233 | var q = {}; 234 | forIn(qu, function(k, v) { 235 | q[k] = v; 236 | }); 237 | 238 | if (qType == "newRows") { 239 | q.success = function(resp) { 240 | // $.log("runQuery newRows success", resp.rows.length, me, resp) 241 | resp.rows.reverse().forEach(function(row) { 242 | renderElement(me, h, [row].concat($.argsToArray(args)), true) 243 | }); 244 | if (userSuccess) userSuccess(resp); 245 | }; 246 | newRows(me, app, viewName, q); 247 | } else { 248 | q.success = function(resp) { 249 | // $.log("runQuery success", resp) 250 | renderElement(me, h, [resp].concat($.argsToArray(args)), true); 251 | userSuccess && userSuccess(resp); 252 | }; 253 | // $.log(app) 254 | app.view(viewName, q); 255 | } 256 | } 257 | 258 | // this is for the items handler 259 | // var lastViewId, highKey, inFlight; 260 | // this needs to key per elem 261 | function newRows(elem, app, view, opts) { 262 | // $.log("newRows", arguments); 263 | // on success we'll set the top key 264 | var thisViewId, successCallback = opts.success, full = false; 265 | function successFun(resp) { 266 | // $.log("newRows success", resp) 267 | $$(elem).inFlight = false; 268 | var JSONhighKey = JSON.stringify($$(elem).highKey); 269 | resp.rows = resp.rows.filter(function(r) { 270 | return JSON.stringify(r.key) != JSONhighKey; 271 | }); 272 | if (resp.rows.length > 0) { 273 | if (opts.descending) { 274 | $$(elem).highKey = resp.rows[0].key; 275 | } else { 276 | $$(elem).highKey = resp.rows[resp.rows.length -1].key; 277 | } 278 | }; 279 | if (successCallback) {successCallback(resp, full)}; 280 | }; 281 | opts.success = successFun; 282 | 283 | if (opts.descending) { 284 | thisViewId = view + (opts.startkey ? JSON.stringify(opts.startkey) : ""); 285 | } else { 286 | thisViewId = view + (opts.endkey ? JSON.stringify(opts.endkey) : ""); 287 | } 288 | // $.log(["thisViewId",thisViewId]) 289 | // for query we'll set keys 290 | if (thisViewId == $$(elem).lastViewId) { 291 | // we only want the rows newer than changesKey 292 | var hk = $$(elem).highKey; 293 | if (hk !== undefined) { 294 | if (opts.descending) { 295 | opts.endkey = hk; 296 | // opts.inclusive_end = false; 297 | } else { 298 | opts.startkey = hk; 299 | } 300 | } 301 | // $.log("add view rows", opts) 302 | if (!$$(elem).inFlight) { 303 | $$(elem).inFlight = true; 304 | app.view(view, opts); 305 | } 306 | } else { 307 | // full refresh 308 | // $.log("new view stuff") 309 | full = true; 310 | $$(elem).lastViewId = thisViewId; 311 | $$(elem).highKey = undefined; 312 | $$(elem).inFlight = true; 313 | app.view(view, opts); 314 | } 315 | }; 316 | 317 | // only start one changes listener per db 318 | function followChanges(app) { 319 | var dbName = app.db.name; 320 | if (!$.evently.changesDBs[dbName]) { 321 | connectToChanges(app, function() { 322 | $("body").trigger("evently.changes."+dbName); 323 | }); 324 | $.evently.changesDBs[dbName] = true; 325 | } 326 | } 327 | 328 | function connectToChanges(app, fun) { 329 | function resetHXR(x) { 330 | x.abort(); 331 | connectToChanges(app, fun); 332 | }; 333 | app.db.info({success: function(db_info) { 334 | var c_xhr = jQuery.ajaxSettings.xhr(); 335 | c_xhr.open("GET", app.db.uri+"_changes?feed=continuous&since="+db_info.update_seq, true); 336 | c_xhr.send(""); 337 | // todo use a timeout to prevent rapid triggers 338 | var t; 339 | c_xhr.onreadystatechange = function() { 340 | clearTimeout(t); 341 | t = setTimeout(fun, 100); 342 | }; 343 | setTimeout(function() { 344 | resetHXR(c_xhr); 345 | }, 1000 * 60); 346 | }}); 347 | }; 348 | 349 | })(jQuery); 350 | -------------------------------------------------------------------------------- /_attachments/style/blueprint-screen.css: -------------------------------------------------------------------------------- 1 | /* ----------------------------------------------------------------------- 2 | 3 | 4 | Blueprint CSS Framework 0.9 5 | http://blueprintcss.org 6 | 7 | * Copyright (c) 2007-Present. See LICENSE for more info. 8 | * See README for instructions on how to use Blueprint. 9 | * For credits and origins, see AUTHORS. 10 | * This is a compressed file. See the sources in the 'src' directory. 11 | 12 | ----------------------------------------------------------------------- */ 13 | 14 | /* reset.css */ 15 | html, body, div, span, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, code, del, dfn, em, img, q, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td, article, aside, dialog, figure, footer, header, hgroup, nav, section {margin:0;padding:0;border:0;font-weight:inherit;font-style:inherit;font-size:100%;font-family:inherit;vertical-align:baseline;} 16 | article, aside, dialog, figure, footer, header, hgroup, nav, section {display:block;} 17 | body {line-height:1.5;} 18 | table {border-collapse:separate;border-spacing:0;} 19 | caption, th, td {text-align:left;font-weight:normal;} 20 | table, td, th {vertical-align:middle;} 21 | blockquote:before, blockquote:after, q:before, q:after {content:"";} 22 | blockquote, q {quotes:"" "";} 23 | a img {border:none;} 24 | 25 | /* typography.css */ 26 | html {font-size:100.01%;} 27 | body {font-size:75%;color:#222;background:#fff;font-family:"Helvetica Neue", Arial, Helvetica, sans-serif;} 28 | h1, h2, h3, h4, h5, h6 {font-weight:normal;color:#111;} 29 | h1 {font-size:3em;line-height:1;margin-bottom:0.5em;} 30 | h2 {font-size:2em;margin-bottom:0.75em;} 31 | h3 {font-size:1.5em;line-height:1;margin-bottom:1em;} 32 | h4 {font-size:1.2em;line-height:1.25;margin-bottom:1.25em;} 33 | h5 {font-size:1em;font-weight:bold;margin-bottom:1.5em;} 34 | h6 {font-size:1em;font-weight:bold;} 35 | h1 img, h2 img, h3 img, h4 img, h5 img, h6 img {margin:0;} 36 | p {margin:0 0 1.5em;} 37 | p img.left {float:left;margin:1.5em 1.5em 1.5em 0;padding:0;} 38 | p img.right {float:right;margin:1.5em 0 1.5em 1.5em;} 39 | a:focus, a:hover {color:#000;} 40 | a {color:#009;text-decoration:underline;} 41 | blockquote {margin:1.5em;color:#666;font-style:italic;} 42 | strong {font-weight:bold;} 43 | em, dfn {font-style:italic;} 44 | dfn {font-weight:bold;} 45 | sup, sub {line-height:0;} 46 | abbr, acronym {border-bottom:1px dotted #666;} 47 | address {margin:0 0 1.5em;font-style:italic;} 48 | del {color:#666;} 49 | pre {margin:1.5em 0;white-space:pre;} 50 | pre, code, tt {font:1em 'andale mono', 'lucida console', monospace;line-height:1.5;} 51 | li ul, li ol {margin:0;} 52 | ul, ol {margin:0 1.5em 1.5em 0;padding-left:3.333em;} 53 | ul {list-style-type:disc;} 54 | ol {list-style-type:decimal;} 55 | dl {margin:0 0 1.5em 0;} 56 | dl dt {font-weight:bold;} 57 | dd {margin-left:1.5em;} 58 | table {margin-bottom:1.4em;width:100%;} 59 | th {font-weight:bold;} 60 | thead th {background:#c3d9ff;} 61 | th, td, caption {padding:4px 10px 4px 5px;} 62 | tr.even td {background:#e5ecf9;} 63 | tfoot {font-style:italic;} 64 | caption {background:#eee;} 65 | .small {font-size:.8em;margin-bottom:1.875em;line-height:1.875em;} 66 | .large {font-size:1.2em;line-height:2.5em;margin-bottom:1.25em;} 67 | .hide {display:none;} 68 | .quiet {color:#666;} 69 | .loud {color:#000;} 70 | .highlight {background:#ff0;} 71 | .added {background:#060;color:#fff;} 72 | .removed {background:#900;color:#fff;} 73 | .first {margin-left:0;padding-left:0;} 74 | .last {margin-right:0;padding-right:0;} 75 | .top {margin-top:0;padding-top:0;} 76 | .bottom {margin-bottom:0;padding-bottom:0;} 77 | 78 | /* forms.css */ 79 | label {font-weight:bold;} 80 | fieldset {padding:1.4em;margin:0 0 1.5em 0;border:1px solid #ccc;} 81 | legend {font-weight:bold;font-size:1.2em;} 82 | input[type=text], input[type=password], input.text, input.title, textarea, select {background-color:#fff;border:1px solid #bbb;} 83 | input[type=text]:focus, input[type=password]:focus, input.text:focus, input.title:focus, textarea:focus, select:focus {border-color:#666;} 84 | input[type=text], input[type=password], input.text, input.title, textarea, select {margin:0.5em 0;} 85 | input.text, input.title {width:300px;padding:5px;} 86 | input.title {font-size:1.5em;} 87 | textarea {width:390px;height:250px;padding:5px;} 88 | input[type=checkbox], input[type=radio], input.checkbox, input.radio {position:relative;top:.25em;} 89 | form.inline {line-height:3;} 90 | form.inline p {margin-bottom:0;} 91 | .error, .notice, .success {padding:.8em;margin-bottom:1em;border:2px solid #ddd;} 92 | .error {background:#FBE3E4;color:#8a1f11;border-color:#FBC2C4;} 93 | .notice {background:#FFF6BF;color:#514721;border-color:#FFD324;} 94 | .success {background:#E6EFC2;color:#264409;border-color:#C6D880;} 95 | .error a {color:#8a1f11;} 96 | .notice a {color:#514721;} 97 | .success a {color:#264409;} 98 | 99 | /* grid.css */ 100 | .container {width:950px;margin:0 auto;} 101 | .showgrid {background:url(src/grid.png);} 102 | .column, .span-1, .span-2, .span-3, .span-4, .span-5, .span-6, .span-7, .span-8, .span-9, .span-10, .span-11, .span-12, .span-13, .span-14, .span-15, .span-16, .span-17, .span-18, .span-19, .span-20, .span-21, .span-22, .span-23, .span-24 {float:left;margin-right:10px;} 103 | .last {margin-right:0;} 104 | .span-1 {width:30px;} 105 | .span-2 {width:70px;} 106 | .span-3 {width:110px;} 107 | .span-4 {width:150px;} 108 | .span-5 {width:190px;} 109 | .span-6 {width:230px;} 110 | .span-7 {width:270px;} 111 | .span-8 {width:310px;} 112 | .span-9 {width:350px;} 113 | .span-10 {width:390px;} 114 | .span-11 {width:430px;} 115 | .span-12 {width:470px;} 116 | .span-13 {width:510px;} 117 | .span-14 {width:550px;} 118 | .span-15 {width:590px;} 119 | .span-16 {width:630px;} 120 | .span-17 {width:670px;} 121 | .span-18 {width:710px;} 122 | .span-19 {width:750px;} 123 | .span-20 {width:790px;} 124 | .span-21 {width:830px;} 125 | .span-22 {width:870px;} 126 | .span-23 {width:910px;} 127 | .span-24 {width:950px;margin-right:0;} 128 | input.span-1, textarea.span-1, input.span-2, textarea.span-2, input.span-3, textarea.span-3, input.span-4, textarea.span-4, input.span-5, textarea.span-5, input.span-6, textarea.span-6, input.span-7, textarea.span-7, input.span-8, textarea.span-8, input.span-9, textarea.span-9, input.span-10, textarea.span-10, input.span-11, textarea.span-11, input.span-12, textarea.span-12, input.span-13, textarea.span-13, input.span-14, textarea.span-14, input.span-15, textarea.span-15, input.span-16, textarea.span-16, input.span-17, textarea.span-17, input.span-18, textarea.span-18, input.span-19, textarea.span-19, input.span-20, textarea.span-20, input.span-21, textarea.span-21, input.span-22, textarea.span-22, input.span-23, textarea.span-23, input.span-24, textarea.span-24 {border-left-width:1px;border-right-width:1px;padding-left:5px;padding-right:5px;} 129 | input.span-1, textarea.span-1 {width:18px;} 130 | input.span-2, textarea.span-2 {width:58px;} 131 | input.span-3, textarea.span-3 {width:98px;} 132 | input.span-4, textarea.span-4 {width:138px;} 133 | input.span-5, textarea.span-5 {width:178px;} 134 | input.span-6, textarea.span-6 {width:218px;} 135 | input.span-7, textarea.span-7 {width:258px;} 136 | input.span-8, textarea.span-8 {width:298px;} 137 | input.span-9, textarea.span-9 {width:338px;} 138 | input.span-10, textarea.span-10 {width:378px;} 139 | input.span-11, textarea.span-11 {width:418px;} 140 | input.span-12, textarea.span-12 {width:458px;} 141 | input.span-13, textarea.span-13 {width:498px;} 142 | input.span-14, textarea.span-14 {width:538px;} 143 | input.span-15, textarea.span-15 {width:578px;} 144 | input.span-16, textarea.span-16 {width:618px;} 145 | input.span-17, textarea.span-17 {width:658px;} 146 | input.span-18, textarea.span-18 {width:698px;} 147 | input.span-19, textarea.span-19 {width:738px;} 148 | input.span-20, textarea.span-20 {width:778px;} 149 | input.span-21, textarea.span-21 {width:818px;} 150 | input.span-22, textarea.span-22 {width:858px;} 151 | input.span-23, textarea.span-23 {width:898px;} 152 | input.span-24, textarea.span-24 {width:938px;} 153 | .append-1 {padding-right:40px;} 154 | .append-2 {padding-right:80px;} 155 | .append-3 {padding-right:120px;} 156 | .append-4 {padding-right:160px;} 157 | .append-5 {padding-right:200px;} 158 | .append-6 {padding-right:240px;} 159 | .append-7 {padding-right:280px;} 160 | .append-8 {padding-right:320px;} 161 | .append-9 {padding-right:360px;} 162 | .append-10 {padding-right:400px;} 163 | .append-11 {padding-right:440px;} 164 | .append-12 {padding-right:480px;} 165 | .append-13 {padding-right:520px;} 166 | .append-14 {padding-right:560px;} 167 | .append-15 {padding-right:600px;} 168 | .append-16 {padding-right:640px;} 169 | .append-17 {padding-right:680px;} 170 | .append-18 {padding-right:720px;} 171 | .append-19 {padding-right:760px;} 172 | .append-20 {padding-right:800px;} 173 | .append-21 {padding-right:840px;} 174 | .append-22 {padding-right:880px;} 175 | .append-23 {padding-right:920px;} 176 | .prepend-1 {padding-left:40px;} 177 | .prepend-2 {padding-left:80px;} 178 | .prepend-3 {padding-left:120px;} 179 | .prepend-4 {padding-left:160px;} 180 | .prepend-5 {padding-left:200px;} 181 | .prepend-6 {padding-left:240px;} 182 | .prepend-7 {padding-left:280px;} 183 | .prepend-8 {padding-left:320px;} 184 | .prepend-9 {padding-left:360px;} 185 | .prepend-10 {padding-left:400px;} 186 | .prepend-11 {padding-left:440px;} 187 | .prepend-12 {padding-left:480px;} 188 | .prepend-13 {padding-left:520px;} 189 | .prepend-14 {padding-left:560px;} 190 | .prepend-15 {padding-left:600px;} 191 | .prepend-16 {padding-left:640px;} 192 | .prepend-17 {padding-left:680px;} 193 | .prepend-18 {padding-left:720px;} 194 | .prepend-19 {padding-left:760px;} 195 | .prepend-20 {padding-left:800px;} 196 | .prepend-21 {padding-left:840px;} 197 | .prepend-22 {padding-left:880px;} 198 | .prepend-23 {padding-left:920px;} 199 | .border {padding-right:4px;margin-right:5px;border-right:1px solid #eee;} 200 | .colborder {padding-right:24px;margin-right:25px;border-right:1px solid #eee;} 201 | .pull-1 {margin-left:-40px;} 202 | .pull-2 {margin-left:-80px;} 203 | .pull-3 {margin-left:-120px;} 204 | .pull-4 {margin-left:-160px;} 205 | .pull-5 {margin-left:-200px;} 206 | .pull-6 {margin-left:-240px;} 207 | .pull-7 {margin-left:-280px;} 208 | .pull-8 {margin-left:-320px;} 209 | .pull-9 {margin-left:-360px;} 210 | .pull-10 {margin-left:-400px;} 211 | .pull-11 {margin-left:-440px;} 212 | .pull-12 {margin-left:-480px;} 213 | .pull-13 {margin-left:-520px;} 214 | .pull-14 {margin-left:-560px;} 215 | .pull-15 {margin-left:-600px;} 216 | .pull-16 {margin-left:-640px;} 217 | .pull-17 {margin-left:-680px;} 218 | .pull-18 {margin-left:-720px;} 219 | .pull-19 {margin-left:-760px;} 220 | .pull-20 {margin-left:-800px;} 221 | .pull-21 {margin-left:-840px;} 222 | .pull-22 {margin-left:-880px;} 223 | .pull-23 {margin-left:-920px;} 224 | .pull-24 {margin-left:-960px;} 225 | .pull-1, .pull-2, .pull-3, .pull-4, .pull-5, .pull-6, .pull-7, .pull-8, .pull-9, .pull-10, .pull-11, .pull-12, .pull-13, .pull-14, .pull-15, .pull-16, .pull-17, .pull-18, .pull-19, .pull-20, .pull-21, .pull-22, .pull-23, .pull-24 {float:left;position:relative;} 226 | .push-1 {margin:0 -40px 1.5em 40px;} 227 | .push-2 {margin:0 -80px 1.5em 80px;} 228 | .push-3 {margin:0 -120px 1.5em 120px;} 229 | .push-4 {margin:0 -160px 1.5em 160px;} 230 | .push-5 {margin:0 -200px 1.5em 200px;} 231 | .push-6 {margin:0 -240px 1.5em 240px;} 232 | .push-7 {margin:0 -280px 1.5em 280px;} 233 | .push-8 {margin:0 -320px 1.5em 320px;} 234 | .push-9 {margin:0 -360px 1.5em 360px;} 235 | .push-10 {margin:0 -400px 1.5em 400px;} 236 | .push-11 {margin:0 -440px 1.5em 440px;} 237 | .push-12 {margin:0 -480px 1.5em 480px;} 238 | .push-13 {margin:0 -520px 1.5em 520px;} 239 | .push-14 {margin:0 -560px 1.5em 560px;} 240 | .push-15 {margin:0 -600px 1.5em 600px;} 241 | .push-16 {margin:0 -640px 1.5em 640px;} 242 | .push-17 {margin:0 -680px 1.5em 680px;} 243 | .push-18 {margin:0 -720px 1.5em 720px;} 244 | .push-19 {margin:0 -760px 1.5em 760px;} 245 | .push-20 {margin:0 -800px 1.5em 800px;} 246 | .push-21 {margin:0 -840px 1.5em 840px;} 247 | .push-22 {margin:0 -880px 1.5em 880px;} 248 | .push-23 {margin:0 -920px 1.5em 920px;} 249 | .push-24 {margin:0 -960px 1.5em 960px;} 250 | .push-1, .push-2, .push-3, .push-4, .push-5, .push-6, .push-7, .push-8, .push-9, .push-10, .push-11, .push-12, .push-13, .push-14, .push-15, .push-16, .push-17, .push-18, .push-19, .push-20, .push-21, .push-22, .push-23, .push-24 {float:right;position:relative;} 251 | .prepend-top {margin-top:1.5em;} 252 | .append-bottom {margin-bottom:1.5em;} 253 | .box {padding:1.5em;margin-bottom:1.5em;background:#E5ECF9;} 254 | hr {background:#ddd;color:#ddd;clear:both;float:none;width:100%;height:.1em;margin:0 0 1.45em;border:none;} 255 | hr.space {background:#fff;color:#fff;visibility:hidden;} 256 | .clearfix:after, .container:after {content:"\0020";display:block;height:0;clear:both;visibility:hidden;overflow:hidden;} 257 | .clearfix, .container {display:block;} 258 | .clear {clear:both;} -------------------------------------------------------------------------------- /_attachments/style/application.css: -------------------------------------------------------------------------------- 1 | @font-face { 2 | font-family: "BrandonGrotesqueLightRegular"; 3 | src: url("brandongrotesque_light/Brandon_light-webfont.eot"); 4 | src: local("☺"), url("brandongrotesque_light/Brandon_light-webfont.woff") format("woff"), url("brandongrotesque_light/Brandon_light-webfont.ttf") format("truetype"), url("brandongrotesque_light/Brandon_light-webfont.svg#webfont") format("svg"); 5 | font { 6 | weight: normal; 7 | style: normal; } } 8 | 9 | body { 10 | padding: 2em; 11 | margin: 0; } 12 | 13 | a { 14 | color: #556270; 15 | color: #107fc9; 16 | color: #019dbe; 17 | text-decoration: none; } 18 | a:hover { 19 | color: white; 20 | background-color: #556270; 21 | background-color: #019dbe; } 22 | 23 | h1 { 24 | font-size: 21px; 25 | font-weight: bold; 26 | line-height: 36px; } 27 | 28 | h3 { 29 | font-size: 18px; 30 | font-weight: bold; } 31 | 32 | .avatar { 33 | width: 50px; 34 | height: 50px; } 35 | 36 | #flash_notice, 37 | #flash_error, 38 | #flash_alert { 39 | z-index: 100; 40 | top: 32px; 41 | position: absolute; 42 | color: black; 43 | width: 400px; 44 | margin: 0 0 0 -200px; 45 | left: 50%; 46 | text-align: center; 47 | font-size: 14px; 48 | padding: 3px 0; } 49 | 50 | #flash_notice { 51 | background-color: #ccffcc; 52 | border: solid 1px #66cc66; } 53 | 54 | #flash_error, 55 | #flash_alert { 56 | background-color: #ffcccc; 57 | border: solid 1px #cc6666; } 58 | 59 | .fieldWithErrors { 60 | display: inline; } 61 | 62 | .error_messages { 63 | width: 400px; 64 | border: 2px solid #cf0000; 65 | padding: 0; 66 | padding-bottom: 12px; 67 | margin-bottom: 20px; 68 | background-color: #f0f0f0; 69 | font-size: 12px; } 70 | .error_messages h2 { 71 | text-align: left; 72 | padding: 5px 5px 5px 15px; 73 | margin: 0; 74 | font-weight: bold; 75 | font-size: 12px; 76 | background-color: #cc0000; } 77 | .error_messages p { 78 | margin: 8px 10px; } 79 | .error_messages ul { 80 | margin: 0; } 81 | 82 | header { 83 | z-index: 4; 84 | position: relative; 85 | margin: -2em; 86 | margin-bottom: 2em; 87 | color: black; 88 | background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#666666), to(#222222)); 89 | background: -moz-linear-gradient(19% 75% 90deg, #222222, #666666); 90 | background-color: #666666; 91 | padding: 0; 92 | padding-top: 5px; 93 | border-bottom: 1px solid #cccccc; } 94 | header a { 95 | color: #999999; } 96 | header a:hover { 97 | background: none; 98 | color: #eeeeee; } 99 | header #diaspora_text { 100 | display: inline; 101 | font-family: "BrandonGrotesqueLightRegular"; 102 | font-size: 16px; 103 | border: none; 104 | color: white; } 105 | header #session_action { 106 | position: absolute; 107 | display: inline; 108 | top: 0; 109 | right: 0; } 110 | header #session_action ul { 111 | list-style: none; 112 | padding: 0; 113 | margin: 0; 114 | display: inline; } 115 | header #session_action ul li { 116 | display: inline; 117 | margin-right: 1em; } 118 | header #session_action ul li:last-child { 119 | margin-right: 0; } 120 | header #aspect_header { 121 | z-index: 5; 122 | background-color: #eeeeee; 123 | border-top: 1px solid white; 124 | padding: 20px 0; } 125 | header #aspect_header h1 { 126 | margin-bottom: 0; 127 | text-shadow: 0 2px 0 white; } 128 | header #aspect_header a { 129 | color: #111111; } 130 | header #aspect_header a:hover { 131 | background: none; 132 | color: #333333; } 133 | header #aspect_header .page_title { 134 | text-transform: uppercase; 135 | text-shadow: 0 2px 0 white; 136 | margin-top: -5px; } 137 | 138 | ul#stream { 139 | margin: 0; 140 | padding: 0; } 141 | ul#stream > li { 142 | min-height: 50px; 143 | list-style: none; 144 | padding: 12px 0; 145 | border-bottom: 1px solid #eeeeee; } 146 | ul#stream > li:first-child { 147 | padding-top: 0; } 148 | 149 | li.message { 150 | position: relative; 151 | line-height: 140%; 152 | font-family: "Lucida Grande", sans-serif; 153 | color: #999999; } 154 | li.message .avatar { 155 | float: left; 156 | margin-right: 15px; } 157 | li.message .delete:hover { 158 | background: #eeeeee; } 159 | li.message .content { 160 | padding-left: 65px; } 161 | li.message .content span.from { 162 | color: black; 163 | font-weight: normal; 164 | font-size: 110%; } 165 | li.message .content div.info { 166 | color: #bababa; 167 | font-size: 70%; } 168 | 169 | form { 170 | position: relative; 171 | font-size: 120%; 172 | margin: 1em; 173 | margin-left: 0em; } 174 | 175 | #user_name { 176 | margin-bottom: 20px; } 177 | #user_name img { 178 | margin-right: 10px; 179 | display: inline-block; 180 | float: left; 181 | height: 40px; } 182 | #user_name h1 { 183 | margin-bottom: 7px; 184 | line-height: 18px; } 185 | #user_name h1 a { 186 | color: black; } 187 | #user_name span { 188 | size: small; 189 | font-weight: normal; 190 | color: #999999; } 191 | #user_name #latest_message_time { 192 | font-style: italic; } 193 | #user_name ul { 194 | display: inline; 195 | margin: 0; 196 | padding: 0; 197 | list-style: none; } 198 | #user_name ul > li { 199 | display: inline; 200 | margin-right: 1em; } 201 | 202 | #stream div.comments { 203 | display: none; } 204 | #stream div.comments .avatar { 205 | width: 30px; 206 | height: 30px; 207 | margin-right: 10px; } 208 | 209 | input.comment_submit { 210 | display: none; 211 | margin-right: -10px; } 212 | 213 | ul.comment_set { 214 | margin: 0; 215 | margin-top: 1em; 216 | padding: 0; 217 | list-style: none; 218 | width: 495px; } 219 | ul.comment_set textarea { 220 | width: 100%; } 221 | ul.comment_set li.comment { 222 | margin-bottom: 0.5em; 223 | background-color: rgba(10, 81, 109, 0.05); 224 | padding: 0.6em; 225 | border-bottom: 1px solid #cccccc; } 226 | ul.comment_set li.comment .from { 227 | font-size: 1em; } 228 | ul.comment_set li.comment div.time { 229 | color: #666666; 230 | font-size: 70%; } 231 | ul.comment_set li.comment form { 232 | margin-top: -5px; 233 | margin-bottom: 0; 234 | font-size: 1em; } 235 | ul.comment_set li.comment form textarea { 236 | font-size: 1em; } 237 | 238 | .profile_photo img { 239 | height: 150px; 240 | width: 150px; } 241 | 242 | #profile ul { 243 | list-style-type: none; 244 | margin: 0; 245 | padding: 0; } 246 | 247 | #stream img.person_picture, #profile img.person_picture, 248 | .comments img.person_picture { 249 | border-radius: 3px; 250 | -webkit-border-radius: 3px; 251 | -moz-border-radius: 3px; 252 | display: inline block; 253 | height: 30px; 254 | display: absolute; 255 | float: left; 256 | margin-right: 10px; } 257 | 258 | .pagination a { 259 | padding: 3px; } 260 | 261 | .destroy_link, .request_button { 262 | position: absolute; 263 | right: 0; 264 | bottom: 15px; } 265 | .destroy_link a, .request_button a { 266 | color: #999999; 267 | font-weight: normal; } 268 | 269 | .destroy_link { 270 | display: none; 271 | font-size: smaller; } 272 | 273 | .request_buttons { 274 | position: absolute; 275 | right: 0; 276 | display: inline; 277 | list-style: none; 278 | margin: 0; 279 | padding: 0; } 280 | .request_buttons > li { 281 | display: inline; } 282 | .request_buttons > li:first-child { 283 | margin-right: 1em; } 284 | 285 | #show_photo { 286 | text-align: center; 287 | min-height: 200px; } 288 | #show_photo img { 289 | max-width: 100%; } 290 | #show_photo .caption { 291 | margin-top: 10px; 292 | margin-bottom: 25px; 293 | font-size: larger; } 294 | 295 | #debug_info { 296 | margin-top: 20px; 297 | color: #cccccc; } 298 | #debug_info h5 { 299 | color: #cccccc; } 300 | 301 | input[type='text'], textarea { 302 | font-family: "lucida grande", "sans-serif"; 303 | font-size: 14px; 304 | padding: 0.3em; 305 | display: block; 306 | width: 66%; 307 | border-top: 1px solid #666666; 308 | height: auto; } 309 | 310 | #submit_block { 311 | text-align: right; 312 | font-size: 12px; } 313 | 314 | form p { 315 | position: relative; 316 | padding: 0; 317 | margin: 0; } 318 | 319 | label { 320 | color: #999999; 321 | font-weight: normal; } 322 | 323 | #publisher { 324 | color: #999999; 325 | position: relative; } 326 | #publisher .avatar { 327 | float: left; 328 | margin-right: 15px; } 329 | #publisher p { 330 | position: absolute; 331 | left: 0; 332 | top: 0; } 333 | #publisher form { 334 | display: inline; } 335 | #publisher form input[type='submit'] { 336 | float: right; 337 | margin-right: 20px; 338 | margin-top: 26px; } 339 | #publisher textarea { 340 | width: 600px; 341 | height: 40px; 342 | margin-top: 0; 343 | margin-bottom: 0; 344 | -webkit-box-shadow: 0 1px 0 white; } 345 | #publisher .button { 346 | margin-left: 100px; } 347 | 348 | #image_picker .small_photo { 349 | height: 100px; 350 | position: relative; 351 | display: inline-block; 352 | margin-right: 1em; 353 | margin-bottom: 1em; } 354 | #image_picker .small_photo img { 355 | border-radius: 3px; } 356 | #image_picker .small_photo input[type='checkbox'] { 357 | position: absolute; } 358 | #image_picker .selected { 359 | -webkit-box-shadow: 0 3px 6px black; 360 | -moz-box-shadow: 0 3px 6px black; 361 | border: 1px solid white; } 362 | 363 | /* cycle it! */ 364 | .album { 365 | position: relative; 366 | height: 200px; 367 | width: 200px; 368 | display: inline-block; } 369 | .album img { 370 | width: 200px; 371 | height: 200px; } 372 | .album .name { 373 | position: absolute; 374 | z-index: 6; 375 | padding: 1em; 376 | background: rgba(0, 0, 0, 0.8); 377 | bottom: 20px; 378 | font-size: 18px; 379 | text-shadow: 0 2px 0 black; } 380 | .album .name .time { 381 | font-size: 12px; } 382 | .album .name .time a { 383 | font-weight: normal; } 384 | .album div.image_cycle img { 385 | display: none; } 386 | 387 | .field_with_submit input[type='text'] { 388 | width: 82%; 389 | display: inline; } 390 | 391 | h1.big_text { 392 | position: relative; 393 | line-height: auto; 394 | border-bottom: 1px solid #666666; } 395 | h1.big_text .right { 396 | top: -6px; } 397 | 398 | #content_bottom .right { 399 | top: -5px; } 400 | 401 | .right { 402 | display: inline; 403 | float: right; } 404 | 405 | .back { 406 | font-size: 12px; 407 | font-weight: normal; } 408 | 409 | #content_bottom { 410 | position: relative; 411 | line-height: 36px; 412 | margin: 0; 413 | margin-top: 25px; 414 | margin-bottom: 25px; 415 | min-height: 36px; 416 | border-top: 1px solid #999999; 417 | border-bottom: 2px solid #eeeeee; } 418 | 419 | .show_post_comments ul.comment_set { 420 | width: 100%; } 421 | 422 | .sub_header { 423 | position: relative; 424 | text-align: center; 425 | font-style: italic; 426 | margin-bottom: 20px; 427 | color: #999999; } 428 | 429 | .image_thumb { 430 | display: inline-block; 431 | width: 100px; 432 | min-width: 100px; 433 | height: 100px; 434 | min-height: 100px; } 435 | .image_thumb img { 436 | display: none; } 437 | 438 | .image_cycle img { 439 | display: none; } 440 | 441 | #aspect_nav { 442 | color: black; 443 | margin-top: 8px; 444 | margin-bottom: 1px; } 445 | #aspect_nav #aspect_manage_button { 446 | display: inline; } 447 | #aspect_nav #aspect_manage_button a { 448 | color: #999999; } 449 | #aspect_nav ul { 450 | margin: 0; 451 | padding: 0; 452 | list-style: none; } 453 | #aspect_nav ul > li { 454 | padding: 0; 455 | display: inline; 456 | margin-right: 0.5em; } 457 | #aspect_nav ul > li a { 458 | line-height: 22px; 459 | background-color: #444444; 460 | border: 1px solid #555555; 461 | padding: 3px 8px; 462 | padding-bottom: 3px; 463 | color: #999999; } 464 | #aspect_nav ul > li a:hover { 465 | background-color: #4e4e4e; 466 | color: #cccccc; } 467 | #aspect_nav ul > li.selected a { 468 | text-shadow: 0 2px 0 white; 469 | padding-top: 4px; 470 | padding-bottom: 5px; 471 | line-height: 18px; 472 | font-weight: bold; 473 | background-color: #eeeeee; 474 | border: 1px solid white; 475 | border-bottom: 1px solid #eeeeee; 476 | color: black; } 477 | #aspect_nav ul > li.selected a:hover { 478 | background-color: #efefef; } 479 | #aspect_nav ul > li.selected a a { 480 | color: black; } 481 | #aspect_nav .new_requests { 482 | color: red; } 483 | 484 | #global_search { 485 | display: inline; 486 | position: relative; 487 | opacity: 0.5; } 488 | #global_search form { 489 | display: inline; } 490 | #global_search form input { 491 | display: inline; 492 | font-size: 12px; 493 | border: none; } 494 | #global_search form input[type='text'] { 495 | width: 200px; 496 | padding: 2px; } 497 | #global_search form label { 498 | font-size: 12px; 499 | margin-top: -3px; } 500 | 501 | .aspect, 502 | .requests, 503 | .remove { 504 | list-style: none; } 505 | .aspect h1, 506 | .requests h1, 507 | .remove h1 { 508 | display: inline-block; } 509 | .aspect .aspect_name, 510 | .requests .aspect_name, 511 | .remove .aspect_name { 512 | position: relative; } 513 | .aspect .aspect_name .tools, 514 | .requests .aspect_name .tools, 515 | .remove .aspect_name .tools { 516 | position: absolute; 517 | top: 10px; 518 | right: 0; 519 | display: inline; } 520 | .aspect .aspect_name:hover .tools, 521 | .requests .aspect_name:hover .tools, 522 | .remove .aspect_name:hover .tools { 523 | display: inline; } 524 | .aspect ul, 525 | .requests ul, 526 | .remove ul { 527 | min-height: 20px; 528 | margin: 0; 529 | margin-bottom: 25px; 530 | background-color: #efefef; 531 | border: 1px solid #cccccc; 532 | list-style: none; 533 | padding: 15px; } 534 | .aspect .person, 535 | .aspect .requested_person, 536 | .requests .person, 537 | .requests .requested_person, 538 | .remove .person, 539 | .remove .requested_person { 540 | display: inline-block; 541 | padding: 5px; 542 | cursor: move; 543 | margin: 5px; 544 | z-index: 10; 545 | text-align: center; 546 | width: 125px; 547 | height: 120px; } 548 | .aspect .person img, 549 | .aspect .requested_person img, 550 | .requests .person img, 551 | .requests .requested_person img, 552 | .remove .person img, 553 | .remove .requested_person img { 554 | height: 100px; 555 | width: 100px; 556 | display: inline-block; } 557 | .aspect .person:active, 558 | .aspect .requested_person:active, 559 | .requests .person:active, 560 | .requests .requested_person:active, 561 | .remove .person:active, 562 | .remove .requested_person:active { 563 | z-index: 20; 564 | color: #666666; } 565 | .aspect .person:active img, 566 | .aspect .requested_person:active img, 567 | .requests .person:active img, 568 | .requests .requested_person:active img, 569 | .remove .person:active img, 570 | .remove .requested_person:active img { 571 | -webkit-box-shadow: 0 1px 3px #333333; 572 | -moz-box-shadow: 0 2px 4px #333333; 573 | opacity: 0.9; } 574 | .aspect .person .grey, 575 | .aspect .requested_person .grey, 576 | .requests .person .grey, 577 | .requests .requested_person .grey, 578 | .remove .person .grey, 579 | .remove .requested_person .grey { 580 | font-style: italic; 581 | color: #666666; } 582 | 583 | #notification_badge { 584 | position: fixed; 585 | bottom: 0; 586 | margin-left: 854px; } 587 | #notification_badge a { 588 | background-color: #eeeeee; 589 | border: 1px solid #cccccc; 590 | border-bottom: none; 591 | padding: 3px 10px; } 592 | -------------------------------------------------------------------------------- /vendor/couchapp/lib/markdown.js: -------------------------------------------------------------------------------- 1 | // 2 | // showdown.js -- A javascript port of Markdown. 3 | // 4 | // Copyright (c) 2007 John Fraser. 5 | // 6 | // Original Markdown Copyright (c) 2004-2005 John Gruber 7 | //s around 197 | // "paragraphs" that are wrapped in non-block-level tags, such as anchors, 198 | // phrase emphasis, and spans. The list of tags we're looking for is 199 | // hard-coded: 200 | var block_tags_a = "p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math|ins|del" 201 | var block_tags_b = "p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math" 202 | 203 | // First, look for nested blocks, e.g.: 204 | //
tags around block-level tags.
351 | text = _HashHTMLBlocks(text);
352 | text = _FormParagraphs(text);
353 |
354 | return text;
355 | }
356 |
357 |
358 | var _RunSpanGamut = function(text) {
359 | //
360 | // These are all the transformations that occur *within* block-level
361 | // tags like paragraphs, headers, and list items.
362 | //
363 |
364 | text = _DoCodeSpans(text);
365 | text = _EscapeSpecialCharsWithinTagAttributes(text);
366 | text = _EncodeBackslashEscapes(text);
367 |
368 | // Process anchor and image tags. Images must come first,
369 | // because ![foo][f] looks like an anchor.
370 | text = _DoImages(text);
371 | text = _DoAnchors(text);
372 |
373 | // Make links out of things like ` Just type tags
1029 | //
1030 |
1031 | // Strip leading and trailing lines:
1032 | text = text.replace(/^\n+/g,"");
1033 | text = text.replace(/\n+$/g,"");
1034 |
1035 | var grafs = text.split(/\n{2,}/g);
1036 | var grafsOut = new Array();
1037 |
1038 | //
1039 | // Wrap tags.
1040 | //
1041 | var end = grafs.length;
1042 | for (var i=0; i ");
1052 | str += "
\n");
382 |
383 | return text;
384 | }
385 |
386 | var _EscapeSpecialCharsWithinTagAttributes = function(text) {
387 | //
388 | // Within tags -- meaning between < and > -- encode [\ ` * _] so they
389 | // don't conflict with their use in Markdown for code, italics and strong.
390 | //
391 |
392 | // Build a regex to find HTML tags and comments. See Friedl's
393 | // "Mastering Regular Expressions", 2nd Ed., pp. 200-201.
394 | var regex = /(<[a-z\/!$]("[^"]*"|'[^']*'|[^'">])*>|)/gi;
395 |
396 | text = text.replace(regex, function(wholeMatch) {
397 | var tag = wholeMatch.replace(/(.)<\/?code>(?=.)/g,"$1`");
398 | tag = escapeCharacters(tag,"\\`*_");
399 | return tag;
400 | });
401 |
402 | return text;
403 | }
404 |
405 | var _DoAnchors = function(text) {
406 | //
407 | // Turn Markdown link shortcuts into XHTML tags.
408 | //
409 | //
410 | // First, handle reference-style links: [link text] [id]
411 | //
412 |
413 | /*
414 | text = text.replace(/
415 | ( // wrap whole match in $1
416 | \[
417 | (
418 | (?:
419 | \[[^\]]*\] // allow brackets nested one level
420 | |
421 | [^\[] // or anything else
422 | )*
423 | )
424 | \]
425 |
426 | [ ]? // one optional space
427 | (?:\n[ ]*)? // one optional newline followed by spaces
428 |
429 | \[
430 | (.*?) // id = $3
431 | \]
432 | )()()()() // pad remaining backreferences
433 | /g,_DoAnchors_callback);
434 | */
435 | text = text.replace(/(\[((?:\[[^\]]*\]|[^\[\]])*)\][ ]?(?:\n[ ]*)?\[(.*?)\])()()()()/g,writeAnchorTag);
436 |
437 | //
438 | // Next, inline-style links: [link text](url "optional title")
439 | //
440 |
441 | /*
442 | text = text.replace(/
443 | ( // wrap whole match in $1
444 | \[
445 | (
446 | (?:
447 | \[[^\]]*\] // allow brackets nested one level
448 | |
449 | [^\[\]] // or anything else
450 | )
451 | )
452 | \]
453 | \( // literal paren
454 | [ \t]*
455 | () // no id, so leave $3 empty
456 | (.*?)>? // href = $4
457 | [ \t]*
458 | ( // $5
459 | (['"]) // quote char = $6
460 | (.*?) // Title = $7
461 | \6 // matching quote
462 | [ \t]* // ignore any spaces/tabs between closing quote and )
463 | )? // title is optional
464 | \)
465 | )
466 | /g,writeAnchorTag);
467 | */
468 | text = text.replace(/(\[((?:\[[^\]]*\]|[^\[\]])*)\]\([ \t]*()(.*?)>?[ \t]*((['"])(.*?)\6[ \t]*)?\))/g,writeAnchorTag);
469 |
470 | //
471 | // Last, handle reference-style shortcuts: [link text]
472 | // These must come last in case you've also got [link test][1]
473 | // or [link test](/foo)
474 | //
475 |
476 | /*
477 | text = text.replace(/
478 | ( // wrap whole match in $1
479 | \[
480 | ([^\[\]]+) // link text = $2; can't contain '[' or ']'
481 | \]
482 | )()()()()() // pad rest of backreferences
483 | /g, writeAnchorTag);
484 | */
485 | text = text.replace(/(\[([^\[\]]+)\])()()()()()/g, writeAnchorTag);
486 |
487 | return text;
488 | }
489 |
490 | var writeAnchorTag = function(wholeMatch,m1,m2,m3,m4,m5,m6,m7) {
491 | if (m7 == undefined) m7 = "";
492 | var whole_match = m1;
493 | var link_text = m2;
494 | var link_id = m3.toLowerCase();
495 | var url = m4;
496 | var title = m7;
497 |
498 | if (url == "") {
499 | if (link_id == "") {
500 | // lower-case and turn embedded newlines into spaces
501 | link_id = link_text.toLowerCase().replace(/ ?\n/g," ");
502 | }
503 | url = "#"+link_id;
504 |
505 | if (g_urls[link_id] != undefined) {
506 | url = g_urls[link_id];
507 | if (g_titles[link_id] != undefined) {
508 | title = g_titles[link_id];
509 | }
510 | }
511 | else {
512 | if (whole_match.search(/\(\s*\)$/m)>-1) {
513 | // Special case for explicit empty url
514 | url = "";
515 | } else {
516 | return whole_match;
517 | }
518 | }
519 | }
520 |
521 | url = escapeCharacters(url,"*_");
522 | var result = "" + link_text + "";
531 |
532 | return result;
533 | }
534 |
535 |
536 | var _DoImages = function(text) {
537 | //
538 | // Turn Markdown image shortcuts into tags.
539 | //
540 |
541 | //
542 | // First, handle reference-style labeled images: ![alt text][id]
543 | //
544 |
545 | /*
546 | text = text.replace(/
547 | ( // wrap whole match in $1
548 | !\[
549 | (.*?) // alt text = $2
550 | \]
551 |
552 | [ ]? // one optional space
553 | (?:\n[ ]*)? // one optional newline followed by spaces
554 |
555 | \[
556 | (.*?) // id = $3
557 | \]
558 | )()()()() // pad rest of backreferences
559 | /g,writeImageTag);
560 | */
561 | text = text.replace(/(!\[(.*?)\][ ]?(?:\n[ ]*)?\[(.*?)\])()()()()/g,writeImageTag);
562 |
563 | //
564 | // Next, handle inline images: 
565 | // Don't forget: encode * and _
566 |
567 | /*
568 | text = text.replace(/
569 | ( // wrap whole match in $1
570 | !\[
571 | (.*?) // alt text = $2
572 | \]
573 | \s? // One optional whitespace character
574 | \( // literal paren
575 | [ \t]*
576 | () // no id, so leave $3 empty
577 | (\S+?)>? // src url = $4
578 | [ \t]*
579 | ( // $5
580 | (['"]) // quote char = $6
581 | (.*?) // title = $7
582 | \6 // matching quote
583 | [ \t]*
584 | )? // title is optional
585 | \)
586 | )
587 | /g,writeImageTag);
588 | */
589 | text = text.replace(/(!\[(.*?)\]\s?\([ \t]*()(\S+?)>?[ \t]*((['"])(.*?)\6[ \t]*)?\))/g,writeImageTag);
590 |
591 | return text;
592 | }
593 |
594 | var writeImageTag = function(wholeMatch,m1,m2,m3,m4,m5,m6,m7) {
595 | var whole_match = m1;
596 | var alt_text = m2;
597 | var link_id = m3.toLowerCase();
598 | var url = m4;
599 | var title = m7;
600 |
601 | if (!title) title = "";
602 |
603 | if (url == "") {
604 | if (link_id == "") {
605 | // lower-case and turn embedded newlines into spaces
606 | link_id = alt_text.toLowerCase().replace(/ ?\n/g," ");
607 | }
608 | url = "#"+link_id;
609 |
610 | if (g_urls[link_id] != undefined) {
611 | url = g_urls[link_id];
612 | if (g_titles[link_id] != undefined) {
613 | title = g_titles[link_id];
614 | }
615 | }
616 | else {
617 | return whole_match;
618 | }
619 | }
620 |
621 | alt_text = alt_text.replace(/"/g,""");
622 | url = escapeCharacters(url,"*_");
623 | var result = "
";
635 |
636 | return result;
637 | }
638 |
639 |
640 | var _DoHeaders = function(text) {
641 |
642 | // Setext-style headers:
643 | // Header 1
644 | // ========
645 | //
646 | // Header 2
647 | // --------
648 | //
649 | text = text.replace(/^(.+)[ \t]*\n=+[ \t]*\n+/gm,
650 | function(wholeMatch,m1){return hashBlock("
" + _RunSpanGamut(m1) + "
");});
651 |
652 | text = text.replace(/^(.+)[ \t]*\n-+[ \t]*\n+/gm,
653 | function(matchFound,m1){return hashBlock("" + _RunSpanGamut(m1) + "
");});
654 |
655 | // atx-style headers:
656 | // # Header 1
657 | // ## Header 2
658 | // ## Header 2 with closing hashes ##
659 | // ...
660 | // ###### Header 6
661 | //
662 |
663 | /*
664 | text = text.replace(/
665 | ^(\#{1,6}) // $1 = string of #'s
666 | [ \t]*
667 | (.+?) // $2 = Header text
668 | [ \t]*
669 | \#* // optional closing #'s (not counted)
670 | \n+
671 | /gm, function() {...});
672 | */
673 |
674 | text = text.replace(/^(\#{1,6})[ \t]*(.+?)[ \t]*\#*\n+/gm,
675 | function(wholeMatch,m1,m2) {
676 | var h_level = m1.length;
677 | return hashBlock("` blocks.
835 | //
836 |
837 | /*
838 | text = text.replace(text,
839 | /(?:\n\n|^)
840 | ( // $1 = the code block -- one or more lines, starting with a space/tab
841 | (?:
842 | (?:[ ]{4}|\t) // Lines must start with a tab or a tab-width of spaces - attacklab: g_tab_width
843 | .*\n+
844 | )+
845 | )
846 | (\n*[ ]{0,3}[^ \t\n]|(?=~0)) // attacklab: g_tab_width
847 | /g,function(){...});
848 | */
849 |
850 | // attacklab: sentinel workarounds for lack of \A and \Z, safari\khtml bug
851 | text += "~0";
852 |
853 | text = text.replace(/(?:\n\n|^)((?:(?:[ ]{4}|\t).*\n+)+)(\n*[ ]{0,3}[^ \t\n]|(?=~0))/g,
854 | function(wholeMatch,m1,m2) {
855 | var codeblock = m1;
856 | var nextChar = m2;
857 |
858 | codeblock = _EncodeCode( _Outdent(codeblock));
859 | codeblock = _Detab(codeblock);
860 | codeblock = codeblock.replace(/^\n+/g,""); // trim leading newlines
861 | codeblock = codeblock.replace(/\n+$/g,""); // trim trailing whitespace
862 |
863 | codeblock = "
";
864 |
865 | return hashBlock(codeblock) + nextChar;
866 | }
867 | );
868 |
869 | // attacklab: strip sentinel
870 | text = text.replace(/~0/,"");
871 |
872 | return text;
873 | }
874 |
875 | var hashBlock = function(text) {
876 | text = text.replace(/(^\n+|\n+$)/g,"");
877 | return "\n\n~K" + (g_html_blocks.push(text)-1) + "K\n\n";
878 | }
879 |
880 |
881 | var _DoCodeSpans = function(text) {
882 | //
883 | // * Backtick quotes are used for " + codeblock + "\n spans.
884 | //
885 | // * You can use multiple backticks as the delimiters if you want to
886 | // include literal backticks in the code span. So, this input:
887 | //
888 | // Just type ``foo `bar` baz`` at the prompt.
889 | //
890 | // Will translate to:
891 | //
892 | // foo `bar` baz at the prompt.`bar` ...
905 | //
906 |
907 | /*
908 | text = text.replace(/
909 | (^|[^\\]) // Character before opening ` can't be a backslash
910 | (`+) // $2 = Opening run of `
911 | ( // $3 = The code block
912 | [^\r]*?
913 | [^`] // attacklab: work around lack of lookbehind
914 | )
915 | \2 // Matching closer
916 | (?!`)
917 | /gm, function(){...});
918 | */
919 |
920 | text = text.replace(/(^|[^\\])(`+)([^\r]*?[^`])\2(?!`)/gm,
921 | function(wholeMatch,m1,m2,m3,m4) {
922 | var c = m3;
923 | c = c.replace(/^([ \t]*)/g,""); // leading whitespace
924 | c = c.replace(/[ \t]*$/g,""); // trailing whitespace
925 | c = _EncodeCode(c);
926 | return m1+""+c+"";
927 | });
928 |
929 | return text;
930 | }
931 |
932 |
933 | var _EncodeCode = function(text) {
934 | //
935 | // Encode/escape certain characters inside Markdown code runs.
936 | // The point is that in code, these characters are literals,
937 | // and lose their special Markdown meanings.
938 | //
939 | // Encode all ampersands; HTML entities are not
940 | // entities within a Markdown code span.
941 | text = text.replace(/&/g,"&");
942 |
943 | // Do the angle bracket song and dance:
944 | text = text.replace(//g,">");
946 |
947 | // Now, escape characters that are magic in Markdown:
948 | text = escapeCharacters(text,"\*_{}[]\\",false);
949 |
950 | // jj the line above breaks this:
951 | //---
952 |
953 | //* Item
954 |
955 | // 1. Subitem
956 |
957 | // special char: *
958 | //---
959 |
960 | return text;
961 | }
962 |
963 |
964 | var _DoItalicsAndBold = function(text) {
965 |
966 | // must go first:
967 | text = text.replace(/(\*\*|__)(?=\S)([^\r]*?\S[*_]*)\1/g,
968 | "$2");
969 |
970 | text = text.replace(/(\*|_)(?=\S)([^\r]*?\S)\1/g,
971 | "$2");
972 |
973 | return text;
974 | }
975 |
976 |
977 | var _DoBlockQuotes = function(text) {
978 |
979 | /*
980 | text = text.replace(/
981 | ( // Wrap whole match in $1
982 | (
983 | ^[ \t]*>[ \t]? // '>' at the start of a line
984 | .+\n // rest of the first line
985 | (.+\n)* // subsequent consecutive lines
986 | \n* // blanks
987 | )+
988 | )
989 | /gm, function(){...});
990 | */
991 |
992 | text = text.replace(/((^[ \t]*>[ \t]?.+\n(.+\n)*\n*)+)/gm,
993 | function(wholeMatch,m1) {
994 | var bq = m1;
995 |
996 | // attacklab: hack around Konqueror 3.5.4 bug:
997 | // "----------bug".replace(/^-/g,"") == "bug"
998 |
999 | bq = bq.replace(/^[ \t]*>[ \t]?/gm,"~0"); // trim one level of quoting
1000 |
1001 | // attacklab: clean up hack
1002 | bq = bq.replace(/~0/g,"");
1003 |
1004 | bq = bq.replace(/^[ \t]+$/gm,""); // trim whitespace-only lines
1005 | bq = _RunBlockGamut(bq); // recurse
1006 |
1007 | bq = bq.replace(/(^|\n)/g,"$1 ");
1008 | // These leading spaces screw with content, so we need to fix that:
1009 | bq = bq.replace(
1010 | /(\s*
[^\r]+?<\/pre>)/gm,
1011 | function(wholeMatch,m1) {
1012 | var pre = m1;
1013 | // attacklab: hack around Konqueror 3.5.4 bug:
1014 | pre = pre.replace(/^ /mg,"~0");
1015 | pre = pre.replace(/~0/g,"");
1016 | return pre;
1017 | });
1018 |
1019 | return hashBlock("\n" + bq + "\n
");
1020 | });
1021 | return text;
1022 | }
1023 |
1024 |
1025 | var _FormParagraphs = function(text) {
1026 | //
1027 | // Params:
1028 | // $text - string to process with html