From eca68e91c1aab13176742ef3d39dc7bd43fc23f0 Mon Sep 17 00:00:00 2001 From: LV-426 Date: Mon, 6 Apr 2015 13:36:12 +0300 Subject: wip: per-domain type system --- src/local/domain/default.rhizi.net/types.js | 52 +++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 src/local/domain/default.rhizi.net/types.js (limited to 'src/local/domain/default.rhizi.net') diff --git a/src/local/domain/default.rhizi.net/types.js b/src/local/domain/default.rhizi.net/types.js new file mode 100644 index 00000000..249f9f69 --- /dev/null +++ b/src/local/domain/default.rhizi.net/types.js @@ -0,0 +1,52 @@ +define(['underscore', 'util'], +function(_, util) +{ + +var nodetypes, + type_attributes = { + 'person': { + 'title': 'Person', + 'attributes': ['description', 'url'], + }, + 'skill': { + 'title': 'Skill', + 'attributes': ['description', 'url'], + } + }, + all_attributes, + attribute_titles = { + 'name': 'Name', + 'type': 'Type', + 'description': 'Description', + 'url': 'URL', + }; + +nodetypes = _.keys(type_attributes); + +type_attributes['_defaults'] = { + 'title': 'default', + 'attributes':['description', 'url'] + }; + +_.pluck(_.values(type_attributes), 'attributes').map(function (attributes) { + attributes.push('name'); + attributes.push('type'); + attributes.sort(); + }); + +all_attributes = _.union(_.flatten(_.pluck(_.values(type_attributes), 'attributes'))).sort(); + +util.assert(_.isEqual(all_attributes, _.keys(attribute_titles).sort())); + +return ( + { + nodetypes: nodetypes, + type_attributes: function (type) { + util.assert(type[0] !== '_', 'invalid type name'); + return type_attributes[type_attributes.hasOwnProperty(type) ? type : '_defaults'].attributes; + }, + all_attributes: all_attributes, + attribute_titles: attribute_titles, + }); +} +) -- cgit v1.3.1