Skip to content
This repository was archived by the owner on Nov 25, 2024. It is now read-only.

Commit

Permalink
Home page working.
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanramage committed Sep 5, 2012
1 parent ff3d01f commit 414090f
Show file tree
Hide file tree
Showing 22 changed files with 192 additions and 348 deletions.
12 changes: 6 additions & 6 deletions kanso.json
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
{
"name": "garden",
"name": "market",
"version": "0.0.1",
"description": "CouchApp for sharing other CouchApps",
"description": "A Garden Market.",
"modules": "lib",
"load": "lib/app",
"less": {
"compress": true,
"compile": "static/css/garden.less",
"remove_from_attachments": true
},
"base_template": "base.html",
"handlebars": {
"templates": "templates"
},
"attachments": "static",
"dependencies": {
"db" : null,
"events" : null,
"session" : null,
"settings" : null,
"modules": null,
"properties": null,
"attachments": null,
"handlebars": null,
"handlebars-helpers": ">=0.0.5",
"duality-handlebars": null,
"duality": null,
"duality-contrib-session-hb": null,
"less-precompiler": null,
"sanitize": null,
"datelib": null,
Expand Down
3 changes: 1 addition & 2 deletions lib/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,4 @@ module.exports = {
validate_doc_update: require('./validate')
};

// bind event handlers
require('./events');

7 changes: 6 additions & 1 deletion lib/dashboards.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
var url = require('url'),
path = require('path'),
cookies = require('cookies'),
dutils = require('duality/utils'),
_ = require('underscore')._;


var dutils = {
getBaseURL : function(req) {
return '.';
}
}

exports.default_url = 'http://localhost:5984/dashboard/_design/dashboard/_rewrite/';
exports._dashboard_urls = [];

Expand Down
14 changes: 0 additions & 14 deletions lib/events.js

This file was deleted.

44 changes: 11 additions & 33 deletions lib/lists.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
var templates = require('duality/templates'),
var templates = require('handlebars').templates,
utils = require('./utils'),
shows = require('./shows'),
ui = require('./ui'),
events = require('duality/events'),
jsonp = require('jsonp'),
datelib = require('datelib'),
flattr = require('flattr');
Expand All @@ -11,14 +10,8 @@ var templates = require('duality/templates'),
exports.home = function (head, req) {
start({code: 200, headers: {'Content-Type': 'text/html'}});

events.once('afterResponse', function (info, req, res) {
ui.addCategories(req, '#categories');
});

if (req.client && req.initial_hit) {
// dont' bother with the second render, nothing new to show
}
else {

var row, rows = [];
while (row = getRow()) {
var promo_images = row.value.config.promo_images || {};
Expand All @@ -31,21 +24,19 @@ exports.home = function (head, req) {
rows.push(row);
}

return {
utils.show( {
title: 'App Garden',
content: templates.render('home.html', req, {
rows: rows
baseURL : '.',
content: templates['home.html']({
rows: rows,
baseURL : '.'
})
};
};
});
};

exports.category_page = function (head, req) {
start({code: 200, headers: {'Content-Type': 'text/html'}});

events.once('afterResponse', function (info, req, res) {
ui.addCategories(req, '#categories');
});

if (req.client && req.initial_hit) {
// dont' bother with the second render, nothing new to show
Expand Down Expand Up @@ -86,14 +77,7 @@ exports.app_details = function (head, req) {
var id = rows[0].id;
var meta = rows[0].value;

events.once('afterResponse', function (info, req, res) {
ui.loadScreenshots(id, meta, req);
$('.install_btn').click(function (ev) {
ev.preventDefault();
ui.showInstallPopup(req, id);
return false;
});
});


if (req.client && req.initial_hit) {
// dont' bother with the second render, nothing new to show
Expand Down Expand Up @@ -137,9 +121,7 @@ exports.app_details_install = function (head, req) {

var id = rows[0].id;
var meta = rows[0].value;
events.once('afterResponse', function (info, req, res) {
ui.showInstallChoices(req);
});


if (req.client && req.initial_hit) {
// dont' bother with the second render, nothing new to show
Expand Down Expand Up @@ -175,9 +157,7 @@ exports.app_details_install_couch = function (head, req) {

var id = rows[0].id;
var meta = rows[0].value;
events.once('afterResponse', function (info, req, res) {

});

if (req.client && req.initial_hit) {
// dont' bother with the second render, nothing new to show
Expand Down Expand Up @@ -206,9 +186,7 @@ exports.app_details_install_couch = function (head, req) {
exports.user_page = function (head, req) {
start({code: 200, headers: {'Content-Type': 'text/html'}});

events.once('afterResponse', function (info, req, res) {
ui.addCategories(req, '#categories');
});


if (req.client && req.initial_hit) {
// dont' bother with the second render, nothing new to show
Expand Down
2 changes: 1 addition & 1 deletion lib/popup.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var templates = require('duality/templates');
var templates = require('handlebars').templates;


var id_counter = 0;
Expand Down
3 changes: 3 additions & 0 deletions lib/rewrites.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,8 @@ module.exports = [
{from: '/details/:name/json', to: '_show/kanso_details/:name'},
{from: '/details/:name/ddoc', to: '../../:name'},
{from: '/static/*', to: 'static/*'},
{from: '/modules.js', to: 'modules.js'},
{from: '/_db/*', to : '../../*'},
{from: '/_db', to : '../../'},
{from: '*', to: '_show/not_found'}
];
4 changes: 2 additions & 2 deletions lib/shows.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
* Show functions to be exported from the design doc.
*/

var templates = require('duality/templates'),
events = require('duality/events'),
var templates = require('handlebars').templates,
events = require('events'),
jsonp = require('jsonp'),
utils = require('./utils'),
ui = require('./ui');
Expand Down
9 changes: 7 additions & 2 deletions lib/ui.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
var templates = require('duality/templates'),
dutils = require('duality/utils'),
var templates = require('handlebars').templates,
utils = require('./utils'),
popup = require('./popup'),
dashboards = require('./dashboards'),
Expand All @@ -9,6 +8,12 @@ var templates = require('duality/templates'),
_ = require('underscore')._;


var dutils = {
getBaseURL : function(req) {
return '.';
}
}

exports.preloadImage = function (src, callback) {
var img = $('<img>').attr({ src: src });
img.load(function () { callback(null, this); });
Expand Down
14 changes: 13 additions & 1 deletion lib/utils.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,20 @@
var dutils = require('duality/utils'),
var templates = require('handlebars').templates,
url = require('url'),
db = require('db');


var dutils = {
getBaseURL : function(req) {
return '.';
}
}


exports.show = function(ctx) {
send(templates['base.html'](ctx));
}


exports.upload_url = function (req) {
var baseURL = dutils.getBaseURL(req);
if (req.client) {
Expand Down
18 changes: 18 additions & 0 deletions packages/db/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,24 @@ This contains the core functions for dealing with CouchDB. That includes
document CRUD operations, querying views and creating/deleting databases.


### Installation

Add `db` to your dependencies section in `kanso.json`.

```javascript
...
"dependencies": {
"db": null,
...
}
```

> run `kanso install` to fetch the package
You also need __jQuery__ to be included on your page, since this module uses
jQuery.ajax to make requests.


### Events

The db module is an EventEmitter. See the
Expand Down
Loading

0 comments on commit 414090f

Please sign in to comment.