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

Commit

Permalink
Using app settings to configure at runtime.
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanramage committed Nov 7, 2012
1 parent 4855ae7 commit 07e2bc5
Show file tree
Hide file tree
Showing 16 changed files with 120 additions and 11 deletions.
21 changes: 21 additions & 0 deletions kanso.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,27 @@
"static/img/promo/screenshot1.png",
"static/img/promo/screenshot2.png"
],
"settings_schema" : {
"description": "Market Settings",
"type": "object",
"properties": {
"use_garden_market_logo" : {
"type": "boolean"
},
"market_name": {
"type": "string"
},
"use_google_analytics" : {
"type": "boolean"
},
"google_analytics_code": {
"type": "string"
},
"admin_review_apps": {
"type": "boolean"
}
}
},
"modules": ["lib", "views"],
"load": "lib/app",
"less": {
Expand Down
1 change: 1 addition & 0 deletions lib/app.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
module.exports = {
app_settings: require('./app_settings'),
rewrites: require('./rewrites'),
lists: require('./lists'),
shows: require('./shows'),
Expand Down
7 changes: 7 additions & 0 deletions lib/app_settings.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module.exports = {
use_garden_market_logo : true,
market_name: "App Garden",
use_google_analytics : true,
google_analytics_code : "UA-31457059-1",
admin_review_apps: false
};
12 changes: 12 additions & 0 deletions lib/lists.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,11 @@ exports.home = function (head, req) {

utils.show( {
title: 'App Garden',
app_settings : this.app_settings,
baseURL : '',
db_name : req.info.db_name,
content: templates['home.html']({
app_settings : this.app_settings,
rows: rows,
baseURL : ''
})
Expand All @@ -59,8 +61,10 @@ exports.category_page = function (head, req) {
utils.show({
title: req.query.category,
baseURL : '../',
app_settings : this.app_settings,
content: templates['category_page.html']({
rows: rows,
app_settings : this.app_settings,
title: utils.toSentenceCase(req.query.category),
category: req.query.category,
baseURL : '../'
Expand Down Expand Up @@ -117,9 +121,11 @@ exports.app_details = function (head, req) {
utils.show ({
title: 'App: ' + title,
baseURL : '../',
app_settings : this.app_settings,
onload : onload,
content: templates['app_details.html']({
baseURL : '../',
app_settings : this.app_settings,
meta: meta,
id: id,
title: title,
Expand Down Expand Up @@ -157,9 +163,11 @@ exports.app_details_install = function (head, req) {
utils.show ({
title: 'App: ' + title,
baseURL : '../../',
app_settings : this.app_settings,
onload : 'ui.showInstallChoices();',
content: templates['app_details_install.html']({
baseURL : '../../',
app_settings : this.app_settings,
meta: meta,
id: id,
title: title,
Expand Down Expand Up @@ -192,10 +200,12 @@ exports.app_details_install_couch = function (head, req) {

utils.show({
title: 'App: ' + title,
app_settings : this.app_settings,
baseURL : '../../',
onload: 'ui.couch_install_page()',
content: templates['app_details_manual_install.html']({
meta: meta,
app_settings : this.app_settings,
id: id,
title: title,
baseURL : '../../',
Expand All @@ -222,9 +232,11 @@ exports.user_page = function (head, req) {
}
utils.show({
title: req.query.user,
app_settings : this.app_settings,
baseURL : '../',
content: templates['user_page.html']({
rows: rows,
app_settings : this.app_settings,
title: utils.toSentenceCase(req.query.user),
user: req.query.user,
baseURL : '../'
Expand Down
7 changes: 7 additions & 0 deletions lib/shows.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ var templates = require('handlebars').templates,
exports.not_found = function (doc, req) {
return utils.base_template({
code: 404,
app_settings : this.app_settings,
title: 'Not found',
content: templates['404.html']({})
});
Expand All @@ -21,9 +22,11 @@ exports.not_found = function (doc, req) {
exports.install_script = function (doc, req) {
return utils.base_template({
code: 200,
app_settings : this.app_settings,
headers: {'Content-Type': 'text/plain'},
body: templates['install.sh']({
app: req.query.name,
app_settings : this.app_settings,
app_url: utils.app_url(req, req.query.name),
open_path: utils.open_path(doc)
})
Expand All @@ -35,10 +38,12 @@ exports.upload_app = function (doc, req) {
return utils.base_template({
code: 200,
baseURL : './',
app_settings : this.app_settings,
title: 'Upload your app',
onload : 'ui.upload_page()',
content: templates['upload_app.html']({
upload_url: utils.upload_url(req),
app_settings : this.app_settings,
baseURL : './'
})
});
Expand All @@ -48,10 +53,12 @@ exports.search = function(doc, req) {
return utils.base_template({
code: 200,
baseURL : './',
app_settings : this.app_settings,
title: 'Search Results',
onload : 'ui.perform_search("'+ req.query.q +'")',
content: templates['search.html']({
baseURL : './',
app_settings : this.app_settings,
terms : req.query.q
})
});
Expand Down
6 changes: 6 additions & 0 deletions static/css/garden.less
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ body {
padding-top: @baseline;
}

h2.name_logo {
line-height: 36px;
padding: 4px;
font-size: 30px;
}

form.search input {
margin-top: 3px;
padding: 8px 3px;
Expand Down
8 changes: 7 additions & 1 deletion templates/404.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,13 @@
<div class="row">
<div class="span5">
<div class="icon">
<a href="{{baseURL}}"><img src="{{baseURL}}static/img/logo.png"/></a>
<a href="{{baseURL}}">
{{#if app_settings.use_garden_market_logo}}
<img src="static/img/logo.png"/>
{{else}}
<h2 class="name_logo">{{app_settings.market_name}}</h2>
{{/if}}
</a>
</div>
</div>
<div class="span10">
Expand Down
8 changes: 7 additions & 1 deletion templates/app_details.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,13 @@
<div class="row">
<div class="span5">
<div class="icon">
<a href="{{baseURL}}"><img src="{{baseURL}}static/img/logo.png"/></a>
<a href="{{baseURL}}">
{{#if app_settings.use_garden_market_logo}}
<img src="static/img/logo.png"/>
{{else}}
<h2 class="name_logo">{{app_settings.market_name}}</h2>
{{/if}}
</a>
</div>
</div>
<div class="span10">
Expand Down
8 changes: 7 additions & 1 deletion templates/app_details_install.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,13 @@
<div class="row">
<div class="span5">
<div class="icon">
<a href="{{baseURL}}"><img src="{{baseURL}}static/img/logo.png"/></a>
<a href="{{baseURL}}">
{{#if app_settings.use_garden_market_logo}}
<img src="static/img/logo.png"/>
{{else}}
<h2 class="name_logo">{{app_settings.market_name}}</h2>
{{/if}}
</a>
</div>
</div>
<div class="span10">
Expand Down
8 changes: 7 additions & 1 deletion templates/app_details_manual_install.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,13 @@
<div class="row">
<div class="span5">
<div class="icon">
<a href="{{baseURL}}"><img src="{{baseURL}}static/img/logo.png"/></a>
<a href="{{baseURL}}">
{{#if app_settings.use_garden_market_logo}}
<img src="static/img/logo.png"/>
{{else}}
<h2 class="name_logo">{{app_settings.market_name}}</h2>
{{/if}}
</a>
</div>
</div>
<div class="span10">
Expand Down
5 changes: 3 additions & 2 deletions templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,18 @@
var ui = require('lib/ui');
ui.init();
{{{onload}}}
{{#if app_settings.use_google_analytics}}

var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-31457059-1']);
_gaq.push(['_setAccount', '{{app_settings.google_analytics_code}}']);
_gaq.push(['_trackPageview']);

(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();

{{/if}}
</script>
</body>
</html>
8 changes: 7 additions & 1 deletion templates/category_page.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,13 @@
<div class="row">
<div class="span5">
<div class="icon">
<a href="{{baseURL}}"><img src="{{baseURL}}static/img/logo.png"/></a>
<a href="{{baseURL}}">
{{#if app_settings.use_garden_market_logo}}
<img src="static/img/logo.png"/>
{{else}}
<h2 class="name_logo">{{app_settings.market_name}}</h2>
{{/if}}
</a>
</div>
</div>
<div class="span10">
Expand Down
8 changes: 7 additions & 1 deletion templates/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,13 @@
<div class="row">
<div class="span5">
<div class="icon">
<a href="{{baseURL}}"><img src="static/img/logo.png"/></a>
<a href="{{baseURL}}">
{{#if app_settings.use_garden_market_logo}}
<img src="static/img/logo.png"/>
{{else}}
<h2 class="name_logo">{{app_settings.market_name}}</h2>
{{/if}}
</a>
</div>
</div>
<div class="span10">
Expand Down
8 changes: 7 additions & 1 deletion templates/search.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,13 @@
<div class="row">
<div class="span5">
<div class="icon">
<a href="{{baseURL}}"><img src="{{baseURL}}static/img/logo.png"/></a>
<a href="{{baseURL}}">
{{#if app_settings.use_garden_market_logo}}
<img src="static/img/logo.png"/>
{{else}}
<h2 class="name_logo">{{app_settings.market_name}}</h2>
{{/if}}
</a>
</div>
</div>
<div class="span10">
Expand Down
8 changes: 7 additions & 1 deletion templates/upload_app.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,13 @@
<div class="row">
<div class="span5">
<div class="icon">
<a href="{{baseURL}}"><img src="{{baseURL}}static/img/logo.png"/></a>
<a href="{{baseURL}}">
{{#if app_settings.use_garden_market_logo}}
<img src="static/img/logo.png"/>
{{else}}
<h2 class="name_logo">{{app_settings.market_name}}</h2>
{{/if}}
</a>
</div>
</div>
<div class="span10">
Expand Down
8 changes: 7 additions & 1 deletion templates/user_page.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,13 @@
<div class="row">
<div class="span5">
<div class="icon">
<a href="{{baseURL}}"><img src="{{baseURL}}static/img/logo.png"/></a>
<a href="{{baseURL}}">
{{#if app_settings.use_garden_market_logo}}
<img src="static/img/logo.png"/>
{{else}}
<h2 class="name_logo">{{app_settings.market_name}}</h2>
{{/if}}
</a>
</div>
</div>
<div class="span10">
Expand Down

0 comments on commit 07e2bc5

Please sign in to comment.