Skip to content
This repository was archived by the owner on Aug 15, 2022. It is now read-only.

Commit 49dad94

Browse files
committed
wip on multiple vocabularies
1 parent e042780 commit 49dad94

21 files changed

Lines changed: 174 additions & 77 deletions

File tree

client/app/Applications/Activity.kdapplication/widgets/widgetcontroller.coffee

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ class ActivityUpdateWidgetController extends KDViewController
135135
@utils.killWait updateTimeout
136136
@emit 'OwnActivityHasArrived', activity
137137
else
138+
warn err
138139
@emit 'OwnActivityHasFailed', data
139140
new KDNotificationView
140141
title : "There was an error, try again later!"

client/app/Applications/Topics.kdapplication/AppController.coffee

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ class TopicsAppController extends AppController
7575
direction : -1
7676
}, (controller)=>
7777
@feedController = controller
78+
controller.resultsController.on 'ItemWasAdded', (item)=>
79+
item.on 'TaggedContentRequested', => @openTopic item.getData()
7880
view.addSubView @_lastSubview = controller.getView()
7981
controller.on "FeederListViewItemCountChanged", (count)=>
8082
if @_searchValue then @setCurrentViewHeader count
@@ -100,6 +102,12 @@ class TopicsAppController extends AppController
100102
@createFeed mainView
101103
# mainView.on "AddATopicFormSubmitted",(formData)=> @addATopic formData
102104

105+
openTopic:(topic)->
106+
group = KD.getSingleton('groupsController').getCurrentGroup()
107+
KD.getSingleton('router').handleRoute """
108+
#{if group?.slug then "/#{group.slug}" else ''}/Topics/#{topic.slug}
109+
"""
110+
103111
updateTopic:(topicItem)->
104112
topic = topicItem.data
105113
# log "Update this: ", topic

client/app/Applications/Topics.kdapplication/Views/TopicsListItemView.coffee

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,7 @@ class TopicsListItemView extends KDListItemView
2727

2828
@followButton = new FollowButton {cssClass: 'topic'}, data
2929

30-
titleReceivedClick:(event)->
31-
tag = @getData()
32-
KD.getSingleton('router').handleRoute(
33-
"/Topics/#{tag.slug}"
34-
state: tag
35-
)
36-
#tag = @getData()
37-
#KD.getSingleton("appManager").tell "Topics", "createContentDisplay", tag
30+
titleReceivedClick:(event)-> @emit 'TaggedContentRequested'
3831

3932
viewAppended:->
4033
@setClass "topic-item"

client/app/MainApp/kodingrouter.coffee

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ class KodingRouter extends KDRouter
7070
handleNotFound:(route)->
7171

7272
status_404 = =>
73-
KDRouter::handleNotFound.call @, route
73+
KDRouter::handleNotFound.call this, route
7474

7575
status_301 = (redirectTarget)=>
7676
@handleRoute "/#{redirectTarget}", replaceState: yes
@@ -198,9 +198,9 @@ class KodingRouter extends KDRouter
198198
@openContent name, 'Groups', group, route
199199

200200
# content
201-
'/:name?/Topics/:topicSlug' : content.Topics
202-
'/:name?/Activity/:activitySlug' : content.Activity
203-
'/:name?/Apps/:appSlug' : content.Apps
201+
'/:name?/Topics/:slug' : content.Topics
202+
'/:name?/Activity/:slug' : content.Activity
203+
'/:name?/Apps/:slug' : content.Apps
204204

205205
'/:name?/Recover/:recoveryToken': ({params:{recoveryToken}})->
206206
return if recoveryToken is 'Password'

node_modules_koding/bongo/lib/base/index.coffee

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ module.exports = class Base extends EventEmitter2
5353
traitModule =\
5454
try require traitPath
5555
catch e then err = e
56-
if traitModule?
56+
if 'function' is typeof traitModule
5757
@trait traitModule
5858
else
5959
throw new Error "Couldn't load the trait #{traitPath} #{err}"

node_modules_koding/jraphical/lib/graphlet.coffee

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
fetchRootTraverse = require 'traverse'
2-
{Base,Model,Inflector,Pipeline,future,sequence,race,dash} = require 'bongo'
2+
{Base,Model,Inflector,future,sequence,race,dash} = require 'bongo'
33
{extend} = require 'underscore'
44
{slice} = []
55

@@ -135,6 +135,7 @@ module.exports = future class Graphlet
135135
@
136136

137137
nodes: future (pipeline, options, next)->
138+
138139
last = pipeline.last()
139140

140141
[next, options] = [options, next] unless next
@@ -152,13 +153,15 @@ module.exports = future class Graphlet
152153
nodes = nodes: []
153154
pipeline.push nodes
154155

155-
collectNodes = race (i, constructor, selector, options, fin)->
156-
constructor.some selector, options, (err, instances)->
157-
if err
158-
next err
159-
else
160-
nodes.nodes.push instances...
161-
fin()
156+
collectNodes = race (i, constructor, pipeline, selector, options, fin)->
157+
root = pipeline.root()
158+
constructor.inCollectionBySource(root)
159+
.some selector, options, (err, instances)->
160+
if err
161+
next err
162+
else
163+
nodes.nodes.push instances...
164+
fin()
162165
, next
163166

164167
{selector, query, limit, sort, skip, hint} = options
@@ -173,7 +176,7 @@ module.exports = future class Graphlet
173176
unless Object.keys(targets).length then next()
174177
else for own targetName, targetIds of targets
175178
constructor = Base.constructors[targetName]
176-
collectNodes constructor, (extend {}, selector, _id:
179+
collectNodes constructor, pipeline, (extend {}, selector, _id:
177180
if targetIds.length > 1
178181
$in: targetIds
179182
else

node_modules_koding/jraphical/lib/module.coffee

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ Snapshot = require './snapshot'
77

88
module.exports = class Module extends Model
99

10+
@inCollectionBySource =-> return this # this is a stub
11+
1012
@attachInterface =(verb, noun, isPlural, fn)->
1113
[fn, lowFirstLetter] = [lowFirstLetter, fn] unless fn
1214
name = @getInterfaceName verb, noun, isPlural, yes
@@ -251,7 +253,7 @@ module.exports = class Module extends Model
251253
(doc[idField] for doc in docs).forEach (id, index)->
252254
ordered[id] = index unless ordered[id]?
253255

254-
groups = groupBy(docs, outgoingName)
256+
groups = groupBy docs, outgoingName
255257

256258
results = []
257259
collectOthers = race (i, type, group, next)->
@@ -270,15 +272,16 @@ module.exports = class Module extends Model
270272
if targetOptions.options?
271273
targetOptions = targetOptions.options
272274

273-
Base.constructors[type].some extend(targetSelector,
274-
_id: $in: ids
275-
), targetOptions, (err, others)->
276-
if others?
277-
others = for other in others
278-
other.flags_ = flags[other.getId()]
279-
other
280-
results = results.concat others
281-
next()
275+
Base.constructors[type].inCollectionBySource(model)
276+
.some extend(targetSelector,
277+
_id: $in: ids
278+
), targetOptions, (err, others)->
279+
if others?
280+
others = for other in others
281+
other.flags_ = flags[other.getId()]
282+
other
283+
results = results.concat others
284+
next()
282285
, ->
283286
if limit
284287
[results] = results

node_modules_koding/sinkrow/lib/sinkrow/future.js

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,34 @@
1-
var initializeFuture;
2-
var __hasProp = Object.prototype.hasOwnProperty, __extends = function(child, parent) {
3-
for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; }
4-
function ctor() { this.constructor = child; }
5-
ctor.prototype = parent.prototype;
6-
child.prototype = new ctor;
7-
child.__super__ = parent.prototype;
8-
return child;
9-
};
1+
var initializeFuture,
2+
__hasProp = {}.hasOwnProperty,
3+
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
4+
105
module.exports = function(context) {
116
var Future;
127
if ('function' === typeof context) {
138
if (context.name) {
14-
return Future = (function() {
15-
__extends(Future, context);
9+
return Future = (function(_super) {
10+
11+
__extends(Future, _super);
12+
1613
Future.queue || (Future.queue = []);
14+
1715
function Future() {
1816
this.queue = [];
1917
Future.__super__.constructor.apply(this, arguments);
2018
}
19+
2120
initializeFuture.call(Future);
21+
2222
return Future;
23-
})();
23+
24+
})(context);
2425
} else {
2526
context.isFuture = true;
2627
return context;
2728
}
2829
}
2930
};
31+
3032
initializeFuture = (function() {
3133
var Pipeline, andThen, filter, isFuture, method, methods, next, originalMethods, replaceMethods, slice, _ref;
3234
_ref = require('underscore'), filter = _ref.filter, methods = _ref.methods;
@@ -77,10 +79,10 @@ initializeFuture = (function() {
7779
return this[methodName].isFuture;
7880
};
7981
replaceMethods = function() {
80-
var methodName, _i, _len, _ref2;
81-
_ref2 = filter(methods(this), isFuture.bind(this));
82-
for (_i = 0, _len = _ref2.length; _i < _len; _i++) {
83-
methodName = _ref2[_i];
82+
var methodName, _i, _len, _ref1;
83+
_ref1 = filter(methods(this), isFuture.bind(this));
84+
for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
85+
methodName = _ref1[_i];
8486
this[methodName] = method(this, methodName);
8587
}
8688
return this.then = andThen;
@@ -89,4 +91,4 @@ initializeFuture = (function() {
8991
replaceMethods.call(this);
9092
return replaceMethods.call(this.prototype);
9193
};
92-
})();
94+
})();

node_modules_koding/sinkrow/lib/sinkrow/index.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1+
12
this.sequence = require('./sequence');
3+
24
this.race = require('./race');
5+
36
this.future = require('./future');
7+
48
this.daisy = function(args) {
59
return process.nextTick(args.next = function() {
610
var fn;
@@ -11,6 +15,7 @@ this.daisy = function(args) {
1115
}
1216
});
1317
};
18+
1419
this.dash = function(args, cb) {
1520
var arg, count, length, _i, _len, _results;
1621
length = args.length;
@@ -32,4 +37,4 @@ this.dash = function(args, cb) {
3237
}
3338
return _results;
3439
}
35-
};
40+
};
Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,29 @@
1-
var Pipeline, underscore;
2-
var __slice = Array.prototype.slice;
1+
var Pipeline, underscore,
2+
__slice = [].slice;
3+
34
underscore = require('underscore');
5+
46
module.exports = Pipeline = (function() {
5-
var empty, method, _i, _j, _len, _len2, _ref, _ref2;
7+
var empty, method, _i, _j, _len, _len1, _ref, _ref1;
8+
69
empty = [];
10+
711
_ref = 'forEach,indexOf,join,pop,reverse,shift,sort,splice,unshift,push'.split(',');
812
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
913
method = _ref[_i];
1014
Pipeline.prototype[method] = empty[method];
1115
}
12-
_ref2 = ('first,initial,last,rest,compact,flatten,without,union,' + 'intersection,difference,uniq,zip,lastIndexOf,range').split(',');
13-
for (_j = 0, _len2 = _ref2.length; _j < _len2; _j++) {
14-
method = _ref2[_j];
16+
17+
_ref1 = ('first,initial,last,rest,compact,flatten,without,union,' + 'intersection,difference,uniq,zip,lastIndexOf,range').split(',');
18+
for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) {
19+
method = _ref1[_j];
1520
Pipeline.prototype[method] = (function(method) {
1621
return function() {
1722
return underscore[method].apply(underscore, [this].concat(__slice.call(arguments)));
1823
};
1924
})(method);
2025
}
26+
2127
function Pipeline(pipeline, queue, callback) {
2228
this.queue = queue;
2329
this.length = 0;
@@ -28,5 +34,12 @@ module.exports = Pipeline = (function() {
2834
value: callback
2935
});
3036
}
37+
38+
Pipeline.prototype.root = function() {
39+
var _ref2, _ref3;
40+
return (_ref2 = this.first()) != null ? (_ref3 = _ref2.nodes) != null ? _ref3[0] : void 0 : void 0;
41+
};
42+
3143
return Pipeline;
32-
})();
44+
45+
})();

0 commit comments

Comments
 (0)