Skip to content

Instantly share code, notes, and snippets.

@KnowledgeGarden
Created December 22, 2014 19:44
Show Gist options
  • Save KnowledgeGarden/4f9552ed2774fc7836dc to your computer and use it in GitHub Desktop.
Save KnowledgeGarden/4f9552ed2774fc7836dc to your computer and use it in GitHub Desktop.
Node Ubuntu/Windoz code
The relation struct:
var struct = module.exports = function(relationType, relationLocator, relationLabel, documentSmallIcon,
documentLocator, documentLabel, documentType, sORt) {
var result = {};
result.relationLocator = relationLocator;
result.relationType = relationType;
result.relationLabel = relationLabel;
result.documentType = documentType;
result.icon = documentSmallIcon;
result.locator = documentLocator;
result.label = documentLabel;
result.sort = sORt;
return result;
};
Code that creates it from inside a class:
var struct = require('../util/relnstruct'); // refers to the object above
var rx = struct(relationType,pivotLocator,relationLabel,
documentSmallIcon, targetLocator, targetLabel, nodeType,sORt);
JSON view of Good Struct in a context:
{
"relationLocator": "climate_change_TAGTagDocumentRelationTypee164f340-8961-11e4-8eea-5d173b397214",
"relationType": "TagDocumentRelationType",
"relationLabel": "TagDocumentRelationType",
"documentType": "TagNodeType",
"icon": "/images/tag_sm.png",
"locator": "climate_change_TAG",
"label": "Climate Change",
"sort": "s"
}
JSON view of bad (ubuntu) struct in similar context:
Note: relationLocator has been dropped
{
"relationType": "TagDocumentRelationType",
"relationLabel": "blog_TAGTagDocumentRelationType0b7f2190-8a08-11e4-94bd-db98af817586",
"documentType": "Blog",
"icon": "TagDocumentRelationType",
"locator": "/images/tag_sm.png",
"label": "blog_TAG",
"sort": "TagNodeType"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment