summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlon Levy <alon@pobox.com>2015-04-06 16:21:10 +0300
committerAlon Levy <alon@pobox.com>2015-04-06 16:21:10 +0300
commit748f1c5d337040433c6c441afab579faf5c934e0 (patch)
tree59d0fc1a044aea66e626ad5f05dcdacb61ed02a8
parenta2ef6be2c52e0421fccddf45fd1563f49f4475c4 (diff)
client: types: split types.js to form domain_types.js, containing declarative jsontoday-is-not-the-day
-rw-r--r--build.ant4
-rw-r--r--src/client/model/types.js40
-rw-r--r--src/local/domain/cri.rhizi.net/domain_types.js (renamed from src/local/domain/cri.rhizi.net/types.js)44
-rw-r--r--src/local/domain/default.rhizi.net/domain_types.js49
-rw-r--r--src/local/domain/default.rhizi.net/types.js52
5 files changed, 96 insertions, 93 deletions
diff --git a/build.ant b/build.ant
index a362662f..cb3bcc3c 100644
--- a/build.ant
+++ b/build.ant
@@ -95,8 +95,8 @@
<copy file="res/etc/rhizi-server.conf"
tofile="${targetDeploymentDir}/etc/rhizi-server.conf" />
- <copy file="src/local/domain/${targetDomain}/types.js"
- tofile="${targetDeploymentDir}/static/model/types.js" description="copy schema, rename"/>
+ <copy file="src/local/domain/${targetDomain}/domain_types.js"
+ tofile="${targetDeploymentDir}/static/model/domain_types.js" description="copy schema, rename"/>
<rsync src="res/templates/" dst="${targetDeploymentDir}/templates/" />
<rsync src="res/local/template/fragment/by-domain/${targetDomain}/" dst="${targetDeploymentDir}/templates/fragment/" />
<copy file="res/etc/user_db.db" tofile="${targetDeploymentDir}/user_db.db" failonerror="false" />
diff --git a/src/client/model/types.js b/src/client/model/types.js
new file mode 100644
index 00000000..867969ea
--- /dev/null
+++ b/src/client/model/types.js
@@ -0,0 +1,40 @@
+define(['underscore', 'util', 'model/domain_types'],
+function(_, util, domain_types)
+{
+
+var nodetypes,
+ all_attributes,
+ type_attributes = domain_types.type_attributes,
+ attribute_titles = domain_types.attribute_titles;
+
+nodetypes = _.keys(type_attributes);
+
+if (undefined === type_attributes['_defaults']) {
+ 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 || type[0] !== '_', 'invalid type name');
+ return type_attributes[type && type_attributes.hasOwnProperty(type) ? type : '_defaults'].attributes;
+ },
+ all_attributes: all_attributes,
+ attribute_titles: attribute_titles,
+ });
+}
+)
diff --git a/src/local/domain/cri.rhizi.net/types.js b/src/local/domain/cri.rhizi.net/domain_types.js
index 76959a83..c8610aa9 100644
--- a/src/local/domain/cri.rhizi.net/types.js
+++ b/src/local/domain/cri.rhizi.net/domain_types.js
@@ -1,9 +1,5 @@
-define(['underscore', 'util'],
-function(_, util)
-{
-
-var nodetypes,
- type_attributes = {
+define({
+ type_attributes: {
'internship': {
'title': 'Internship',
'attributes':
@@ -34,8 +30,7 @@ var nodetypes,
'attributes': ['description', 'url'],
}
},
- all_attributes,
- attribute_titles = {
+ attribute_titles: {
'name': 'Name',
'type': 'Type',
'description': 'Description',
@@ -50,34 +45,5 @@ var nodetypes,
'street-address': 'Street address',
'city': 'City',
'country': 'Country',
- };
-
-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 || type[0] !== '_', 'invalid type name');
- return type_attributes[!type && type_attributes.hasOwnProperty(type) ? type : '_defaults'].attributes;
- },
- all_attributes: all_attributes,
- attribute_titles: attribute_titles,
- });
-}
-)
+ }
+});
diff --git a/src/local/domain/default.rhizi.net/domain_types.js b/src/local/domain/default.rhizi.net/domain_types.js
new file mode 100644
index 00000000..c8610aa9
--- /dev/null
+++ b/src/local/domain/default.rhizi.net/domain_types.js
@@ -0,0 +1,49 @@
+define({
+ type_attributes: {
+ 'internship': {
+ 'title': 'Internship',
+ 'attributes':
+ ['status', 'startdate', 'enddate', 'description', 'url',
+ 'internship-type',
+ 'facility',
+ 'facility-affiliation',
+ 'cnrs-inserm-unit-code',
+ 'street-address',
+ 'city',
+ 'country',
+ ],
+ },
+ 'skill': {
+ 'title': 'Skill',
+ 'attributes': ['description', 'url'],
+ },
+ 'interest': {
+ 'title': 'Interesst',
+ 'attributes': ['description', 'url'],
+ },
+ 'person': {
+ 'title': 'Person',
+ 'attributes': ['description', 'url'],
+ },
+ 'club': {
+ 'title': 'Club',
+ 'attributes': ['description', 'url'],
+ }
+ },
+ attribute_titles: {
+ 'name': 'Name',
+ 'type': 'Type',
+ 'description': 'Description',
+ 'url': 'URL',
+ 'status': 'Status',
+ 'startdate': 'Start Date',
+ 'enddate': 'End Date',
+ 'internship-type': 'Internship Type',
+ 'facility': 'Lab/Company',
+ 'facility-affiliation': 'Lab affiliation',
+ 'cnrs-inserm-unit-code': 'CNRS / INSERM unit code',
+ 'street-address': 'Street address',
+ 'city': 'City',
+ 'country': 'Country',
+ }
+});
diff --git a/src/local/domain/default.rhizi.net/types.js b/src/local/domain/default.rhizi.net/types.js
deleted file mode 100644
index 249f9f69..00000000
--- a/src/local/domain/default.rhizi.net/types.js
+++ /dev/null
@@ -1,52 +0,0 @@
-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,
- });
-}
-)