Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
6e0c932
Adding 'link' format option. #177
recidive Feb 6, 2015
09d60ae
Adding Token service for replacing parameters based tokens.
recidive Feb 12, 2015
b55b59f
Upgrading validator to 3.30.x.
recidive Feb 13, 2015
e67ce10
Bypassing validation of 'internal' fields.
recidive Feb 13, 2015
58a155a
Fixing content type internal date field values.
recidive Feb 13, 2015
fdea882
Missed parenthesis on Date constructors.
recidive Feb 13, 2015
f207b62
Adding a 'protected' property to fields. Fixes #239.
recidive Feb 13, 2015
f0e0d6e
Making possible to edit users. Fixes #180. Fixes #188.
recidive Feb 13, 2015
78b543e
Making possible to use tokens on page and panel titles. Fixes #240.
recidive Feb 13, 2015
98f5f91
Making select element use ng-options. Fixes #245.
recidive Feb 13, 2015
e0ee935
Adding missing permissions to user extension.
recidive Feb 13, 2015
616a63f
Replacing tokens in form redirect URLs. Fixes #241.
recidive Feb 14, 2015
bd6ecd9
A few more improvements to select field/element. Issue #245.
recidive Feb 14, 2015
12a6170
Improving type example.
recidive Feb 14, 2015
632c20f
Removing bootswatch themes from repository, downloading them via bowe…
recidive Feb 15, 2015
209b325
Adding link to choko.org to the "Powered by" panel.
recidive Mar 10, 2015
4a64f36
Removing management pages not on MVP. Fixes #249.
recidive Mar 10, 2015
8ddad95
Splitting management extension into smaller extensions. Fixes #248.
recidive Mar 10, 2015
6c5fdaa
Setting default router on processRoute() instead of later on.
recidive Mar 11, 2015
417cd0a
Removing payload envelope from REST responses. Fixes #4.
recidive Mar 12, 2015
a45ef3f
Standardize dependency injection into inline array notation.
recidive Mar 13, 2015
45bef45
Making it start a single application only. #143
recidive Mar 13, 2015
f9afc88
Removing server.js library. #143
recidive Mar 13, 2015
5c0b3c8
Fixing choko command and installer initializing. #143
recidive Mar 13, 2015
d2952a3
Fixing tests. #143
recidive Mar 13, 2015
ab50d07
Fixing documentation on creating and starting the app. Fixes #255.
recidive Mar 14, 2015
7269c20
Fixing typo in content extension description. Thanks @jardix22!
recidive Mar 19, 2015
ed7b806
Fixing a single code comment.
recidive Mar 31, 2015
5674a82
Moving Example application to a separate project (https://github.com/…
recidive Apr 3, 2015
c67a068
Removing vhost dependency.
Apr 3, 2015
854e94a
Removing applications.json.
recidive Apr 3, 2015
bfd12dd
Restored stop method from application.js
Apr 3, 2015
ac902b6
Change "X-Powered-By" header. Fixes #267
recidive Apr 28, 2015
cddd114
Adding id to user type. Fixes #220.
May 8, 2015
d90cbd4
Making possible to edit username. Fixes #221.
recidive Jun 4, 2015
e17e21a
Bumping Choko version to 0.0.5 to publish a new release on NPM.
recidive Jun 5, 2015
c0b3fe0
Merge branch 'master' into form-validation
yesmagaly Jun 15, 2015
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions applications/applications.json

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"title": "Content Management",
"description": "Provide management pages for content and related data.",
"dependencies": ["content", "management"]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
/*
* The Content Management extension.
*/

var contentManagement = module.exports;

/**
* The page() hook.
*/
contentManagement.page = function(pages, callback) {
var self = this;
var newPages = {};

// Create form contents for all content subtypes.
var contentTypes = this.application.types['content'].subtypes;
for (var subtypeName in contentTypes) {
var subtypeSettings = contentTypes[subtypeName];
newPages['manage-content-add-' + subtypeSettings.name] = {
path: '/manage/content/add-' + subtypeSettings.name,
title: 'Add ' + subtypeSettings.title.toLowerCase(),
type: 'form',
formName: 'type-' + subtypeSettings.name + 'Content',
redirect: '/manage/content'
};
}

newPages['manage-extensions'] = {
path: '/manage/extensions',
title: 'Extensions',
subtitle: 'The building blocks',
description: 'Extensions are groups of functionality.',
access: 'manage-extensions',
callback: function(request, response, callback) {
var extensions = self.application.extensions;
var result = {};
for (var extensionName in extensions) {
var extension = extensions[extensionName];
result[extensionName] = {
title: extension.settings.title,
description: extension.settings.description
};
}
response.payload.page.items = result;
callback();
},
template: '/templates/list-group.html'
};

callback(null, newPages);
};

/**
* The navigation() hook.
*/
contentManagement.navigation = function(navigations, callback) {
var newNavigations = {};

// Create navigation dropdown with links for all content types forms.
var contentTypes = this.application.types['content'].subtypes;
var items = [];
for (var contentTypeName in contentTypes) {
var contentTypeSettings = contentTypes[contentTypeName];
items.push({
title: contentTypeSettings.title,
url: '/manage/content/add-' + contentTypeSettings.name
});
}

newNavigations['content-management-toolbar'] = {
title: 'Content management toolbar',
template: '/templates/btn-group.html',
classes: [
'btn-group-sm'
],
items: [
{
type: 'dropdown',
title: 'Add',
items: items,
classes: [
'btn-primary'
]
}
]
};

callback(null, newNavigations);
};
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"title": "Content",
"description": "Content management festures.",
"description": "Content management features.",
"dependencies": ["page"]
}
6 changes: 3 additions & 3 deletions applications/default/extensions/content/content.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@ content.type = function(types, callback) {
// Set created and update dates to now.
// @todo: Allow created/updated date to be passed in some circunstances,
// e.g. admin, import/export, etc.
data.created = Date.now();
data.updated = Date.now();
data.created = new Date();
data.updated = new Date();
next();
};

type.beforeUpdate = function(settings, data, next) {
// Set updated date to now.
// @todo: Allow created date to be passed in some circunstances, e.g. admin,
// import/export, etc.
data.updated = Date.now();
data.updated = new Date();
next();
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,15 @@ angular.module('choko')
}
}])

.controller('DisplayFieldController', ['$scope', 'Params',
function ($scope, Params) {
.controller('DisplayFieldController', ['$scope', 'Token',
function ($scope, Token) {
if ($scope.field.fieldName in $scope.item) {
$scope.value = $scope.item[$scope.field.fieldName];
}

if ($scope.field.link) {
$scope.link = Token.replace($scope.field.link, $scope);
}

$scope.template = $scope.field.template || '/templates/' + $scope.field.format + '.html';
}]);
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
<h4>{{value}}<h4>
<h4 ng-if="link"><a href="{{link}}">{{value}}</a><h4>
<h4 ng-if="!link">{{value}}<h4>
19 changes: 14 additions & 5 deletions applications/default/extensions/field/field.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
var async = require('async');
var validator = require('validator/lib/validators');
var validator = require('validator');
var uuid = require('node-uuid');
var utils = require('prana').utils;

Expand Down Expand Up @@ -30,6 +30,13 @@ field.field = function(fields, callback) {
newFields['text'] = {
title: 'Text',
schema: function(settings) {
// If options and multiple is set, schema should be a array.
if (settings.options && settings.multiple) {
return {
type: 'array'
};
}

var schema = {
type: (settings.maxLength > 256) ? 'text' : 'string'
};
Expand All @@ -50,13 +57,15 @@ field.field = function(fields, callback) {
};
},
validate: function(settings, item, next) {
// @todo: validate if value is within options when it's a select field.

// Default minLenght to 1.
settings.minLength = settings.minLength || 1;

// Default maxLenght to 256.
settings.maxLength = settings.maxLength || 256;

next(null, !validator.notEmpty(item[settings.name]) || validator.len(item[settings.name].toString(), settings.minLength, settings.maxLength) || 'must have from ' + settings.minLength + ' to ' + settings.maxLength + ' characters.');
next(null, validator.isLength(item[settings.name].toString(), settings.minLength, settings.maxLength) || 'must have from ' + settings.minLength + ' to ' + settings.maxLength + ' characters.');
}
};

Expand Down Expand Up @@ -116,7 +125,7 @@ field.field = function(fields, callback) {
validate: function(settings, item, next) {
// Email validator oddly returns the email itself, so need to convert to
// boolean.
next(null, !!validator.isEmail(item[settings.name].toString()) || 'must be a valid email.');
next(null, validator.isEmail(item[settings.name].toString()) || 'must be a valid email.');
}
};

Expand All @@ -128,7 +137,7 @@ field.field = function(fields, callback) {
},
element: 'url',
validate: function(settings, item, next) {
next(null, validator.isUrl(item[settings.name].toString()) || 'must be a valid URL.');
next(null, validator.isURL(item[settings.name].toString()) || 'must be a valid URL.');
}
};

Expand All @@ -146,7 +155,7 @@ field.field = function(fields, callback) {
element: 'password',
validate: function(settings, item, next) {
var minLength = settings.minLength || 6;
next(null, validator.len(item[settings.name].toString(), settings.minLength || 6) || 'must have at least ' + minLength + ' characters.');
next(null, validator.isLength(item[settings.name].toString(), settings.minLength || 6) || 'must have at least ' + minLength + ' characters.');
}
};

Expand Down
1 change: 0 additions & 1 deletion applications/default/extensions/file/file.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
var path = require('path');
var fs = require('fs');
var validator = require('validator/lib/validators');
var utils = require('prana').utils;

var file = module.exports = {};
Expand Down
10 changes: 7 additions & 3 deletions applications/default/extensions/form/form.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,8 @@ form.form = function(forms, callback) {
var newForms = {};
var self = this;

// Create forms for every type on the system except 'type' and 'extension',
// the ones that have the 'form' property set to false, the ones that have
// no fields and the ones that are polymorphic.
// Create forms for every type on the system except the ones that have no
// fields and the ones that are polymorphic.
async.each(Object.keys(self.application.types), function(typeName, next) {
var typeSettings = self.application.types[typeName];
if (!typeSettings.fields || typeSettings.polymorphic) {
Expand Down Expand Up @@ -130,6 +129,11 @@ form.form = function(forms, callback) {
element.options = fieldSettings.options;
}

// Forward 'multiple' property.
if (fieldSettings.multiple) {
element.multiple = fieldSettings.multiple;
}

// Bypass 'internal' fields.
if (fieldSettings.internal) {
return next();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ angular.module('choko')
$scope.progress = parseInt(100.0 * evt.loaded / evt.total);
})
.success(function(data, status, headers, config) {
$scope.data[$scope.element.name] = data.data.id;
$scope.data[$scope.element.name] = data.id;
});
}
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
<div ck-element class="form-group">
<label ng-if="element.title" for="{{element.id}}">{{element.title}}</label>
<select ng-if="element.multiple" ng-model="data[element.name]" ng-required="element.required" name="{{element.name}}" id="{{element.id}}" class="form-control" multiple>
<option ng-repeat="(optionKey, option) in element.options" value="{{optionKey}}">{{option}}</option>
</select>
<select ng-if="!element.multiple" ng-model="data[element.name]" ng-required="element.required" name="{{element.name}}" id="{{element.id}}" class="form-control">
<option ng-repeat="(optionKey, option) in element.options" value="{{optionKey}}">{{option}}</option>
</select>
<select ng-if="element.multiple" ng-model="data[element.name]" ng-required="element.required" ng-options="optionKey as option for (optionKey, option) in element.options" id="{{element.id}}" class="form-control" multiple></select>
<select ng-if="!element.multiple" ng-model="data[element.name]" ng-required="element.required" ng-options="optionKey as option for (optionKey, option) in element.options" id="{{element.id}}" class="form-control"></select>
<p ng-if="element.description" class="help-block">{{element.description}}</p>
</div>
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<button ck-button ng-click="submit(element.url, element.redirect || form.redirect)" ng-disabled="isClean() || [form.name].$invalid" ng-class="element.classes" type="submit" class="btn" id="{{element.id}}">{{element.title}}</button>
<button ck-button ng-click="submit(element.url)" ng-disabled="isClean() || [form.name].$invalid" ng-class="element.classes" type="submit" class="btn" id="{{element.id}}">{{element.title}}</button>

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading