Formatter
Mon Jan 27 2014 14:49:11 GMT+0100 (Central Europe Standard Time)
enabled
# Fix PartsBin
loadPartVersions: function(isAsync) { // FIXME, what if PartsBin is not at root? var url = this.getFileURL(), root = url.withPath("/"), // this is wrong if the wiki is not in the root! path = url.relativePathFrom(root), self = this; function processVersions(err, rows) { if (err) show(err); else self.partVersions = rows; } var result = new lively.store.ObjectRepository(root).getRecords({ paths: [path], attributes: ['path', 'date', 'author', 'change', 'version'] }, isAsync ? processVersions : null); if (!isAsync) processVersions(result.error ? result.error : null, result); return this; },
# Layer to Base System Merge Tool use the syntax code highlighting from the system code browser use diff-match-patch to highlight changes from left to right, similar to the MacOS FileMerger #MissingFeature: There is an method missing in lively.ide.FileFragmentNode that allows to add methods! #JensLincke
# PartsBin for Dropbox
cop.create("DevLayer").refineClass(lively.store.ObjectRepository, {
    initialize: function(url) {
        this.repoURL = url ? url : URL.root;
    },
    getRecords: function(querySpecthenDo)  {
        // new lively.store.ObjectRepository().getRecords()
        var res = this.getServerInterfaceURL()
            .withQuery({getRecords: encodeURIComponent(JSON.stringify(querySpec))})
            .asWebResource().noProxy();
        if (thenDo != null) {
            res.withJSONWhenDone(function(json, status) {
                if (JSON.prettyPrint(json) == "[]"){
                    throw new Error("Could not get records for:" + JSON.prettyPrint(querySpec))
                } 
                thenDo(status.isSuccess() ? null : status, json); }).beAsync().get();
            return this;
        } else {
            var content = res.beSync().get().content;
            if (!res.status.isSuccess())
                throw new Error(content);
            var json;
            try { json = JSON.parse(content); } catch(e) { json = {error: e} }
            return json;
        }
    }
}).refineClass(lively.PartsBin.PartItem, {
    guessRootForURL: function(url) {
        if (url.isIn(URL.root)) {
            return URL.root
        }
        if (url.pathname.match(/\/PartsBin\//)) { // we can make a smarkt guess? Or can't we? #JensLincke
            return url.withPath(url.pathname.replace("PartsBin.*"))
        }
        // this captures only the current url... but we migth be a general Approach finding the root
        // can we be sure that it contains the partsbin?
        // Future work, we might also have to replace these methods by a more specific versions 
        // for accessing the version history of dropbox, ondrive or other databases that may want to 
        // decide to put parts in... 
        return url.withPath("/") // fallback that works for simple localhost and lively-web etc..
    },
    
    loadPartVersions: function(isAsync) {
        // FIXME, what if PartsBin is not at root?
        var url = this.getFileURL(),
            root = this.guessRootForURL(url),
            path = url.relativePathFrom(root),
            self = this;
        function processVersions(errrows) {
            if (err) show(err);
            else self.partVersions = rows;
        }
        var result = new lively.store.ObjectRepository(root).getRecords({
                paths: [path],
                attributes: ['path', 'date', 'author', 'change', 'version']
            }, isAsync ? processVersions : null);
        if (!isAsync) processVersions(result.error ? result.error : null, result);
        return this;
    },
    load: function(isAsyncrev) {
        if(!isAsync){
            var webR = new WebResource(this.getFileURL()).noProxy().forceUncached();
            if (isAsync) webR.beAsync();
            lively.bindings.connect(webR, 'content', this, 'json', {updater: function($updjson) {
                if (!this.sourceObj.status.isSuccess()) { $upd(null); return; }
                if (!this.sourceObj.status.isDone()) { return; }
                this.targetObj.lastModifiedDate = this.sourceObj.lastModified;
                $upd(json);
            }});
            webR.get();
            return this;
        }
        var url = this.getFileURL(),
            root = this.guessRootForURL(url),
            path = url.relativePathFrom(root),
            self = this,
            query = !!rev || rev === 0 ? {
                    paths: [path],
                    attributes: ['content'],
                    version: rev,
                    limit: 1
                } : {
                    paths: [path],
                    attributes: ['content'],
                    newest: true,
                    limit: 1
                };
        new lively.store.ObjectRepository(root).getRecords(query, function(err, rows) {
            if (err) { show(err); self.json = null; return; }
            self.json = rows[0].content;
        });
        return this;
    },
    loadPartMetaInfo: function(isAsyncrev) {
        if (!isAsync) {
            var webR = new WebResource(this.getMetaInfoURL()).beSync();
            webR.forceUncached().get();
            if (webR.status.isSuccess()) {
                var metaInfo = lively.persistence.Serializer.deserialize(webR.content);
                metaInfo.lastModifiedDate = webR.lastModified;
                this.loadedMetaInfo = metaInfo;
            }
            return this;
        }
        var url = this.getMetaInfoURL(),
            root = this.guessRootForURL(url),
            path = url.relativePathFrom(root),
            self = this,
            query = !!rev ? {
                paths: [path],
                attributes: ['content', 'date'],
                version: rev,
                limit: 1
            } : {
                paths: [path],
                attributes: ['content', 'date'],
                newest: true,
                limit: 1
            };
        new lively.store.ObjectRepository(root).getRecords(query, function(err, rows) {
            if (err) { show(err); self.loadedMetaInfo = null; return; }
            var metaInfo = lively.persistence.Serializer.deserialize(rows[0].content)
            metaInfo.lastModifiedDate = new Date(rows[0].date);
            self.loadedMetaInfo = metaInfo;
        });
    },
}).beGlobal()
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
partsSpace = new lively.PartsBin.PartsSpace(new URL("https://lively-kernel.org/repository/webwerkstatt/PartsBin/Tools/"))
partsSpace.name
partsSpace.getPartNames()
partsSpace = lively.PartsBin.partsSpaceWithURL(new URL("https://lively-kernel.org/repository/webwerkstatt/PartsBin/Tools/"))
partsSpace.getPartNamesfunction () {
        return Properties.own(this.partItems);
    }
partsSpace.getPartNames()
wr = new WebResource(new URL("dropbox:///Lively/PartsBin/Basic"))
wr.getSubElements()
wr.noProxy
partsSpace = lively.PartsBin.partsSpaceWithURL(new URL("dropbox:///Lively/PartsBin/Basic"))
partsSpace.name
partsSpace.loadfunction (async) {
        var webR = new WebResource(self.getURL()).noProxy();
        if (async) webR.beAsync();
        // ask for the files of a directory and update so that the partItems correspond to the files found
        connect(webR, 'subDocuments', this, 'setPartItemsFromURLList', {
            converter: function(webResources) { return webResources.invoke('getURL') }})
        webR.getSubElements();
        return this;
    }
partsSpace.setPartItemsFromURLList(wr.subDocuments.invoke('getURL'))
partsSpace.getPartNames()
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Layer to BaseSystem Merge Tool
X

Menu
lively.store.ObjectRepository>>initialize
lively.store.ObjectRepository>>getRecords
lively.PartsBin.PartItem>>guessRootForURL
lively.PartsBin.PartItem>>loadPartVersions
lively.PartsBin.PartItem>>load
lively.PartsBin.PartItem>>loadPartMetaInfo
DevLayer
    getRecords: function (querySpecthenDo)  {
        // new lively.store.ObjectRepository().getRecords()
        var res = this.getServerInterfaceURL()
            .withQuery({getRecords: encodeURIComponent(JSON.stringify(querySpec))})
            .asWebResource().noProxy();
        if (thenDo != null) {
            res.withJSONWhenDone(function(json, status) {
                if (JSON.prettyPrint(json) == "[]"){
                    throw new Error("Could not get records for:" + JSON.prettyPrint(querySpec))
                } 
                thenDo(status.isSuccess() ? null : status, json); }).beAsync().get();
            return this;
        } else {
            var content = res.beSync().get().content;
            if (!res.status.isSuccess())
                throw new Error(content);
            var json;
            try { json = JSON.parse(content); } catch(e) { json = {error: e} }
            return json;
        }
    }
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Merge -> Base
    getRecords: function (querySpecthenDo)  {
        // new lively.store.ObjectRepository().getRecords()
        var res = this.getServerInterfaceURL()
            .withQuery({getRecords: encodeURIComponent(JSON.stringify(querySpec))})
            .asWebResource().noProxy();
        if (thenDo != null) {
            res.withJSONWhenDone(function(json, status) {
                if (JSON.prettyPrint(json) == "[]"){
                    debugger
                    throw new Error("Could not get records for:" + JSON.prettyPrint(querySpec))
                } 
                thenDo(status.isSuccess() ? null : status, json); }).beAsync().get();
            return this;
        } else {
            var content = res.beSync().get().content;
            if (!res.status.isSuccess())
                throw new Error(content);
            var json;
            try { json = JSON.parse(content); } catch(e) { json = {error: e} }
            return json;
        }
    }
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Browse
-
+

*all*
*latest*
*search*
Basic
Jens
uncategorized
enter search term
Cloud
3 + 4
X
Editor
Ellipse
Image
Line
LineWithArrow
LineWithArrowOr...
LineWithArrows
Marker
Notebook
Notebook
Pen
text
PrimitiveShapes
Rectangle
Star
Some Text
Text
TransparentRect...
Triangle
more
Ellipse
Share Link
onedrive:///Lively/PartsBin/Basic/

remove
move
copy
2015-05-05 12:17 undefined no comment
2015-05-05 12:18 undefined no comment
2015-05-05 12:18 undefined no comment
load
revert
PartsBinBrowser
X

Menu
CloudStorageWebRequests.js:CloudStorageWebRequestsLayer:lively.PartsBin.PartItem:loadPart
X

Menu
N
core/lively/experimental/
...
CopyAndPaste.js (not parsed)
DebugEvents.js (not parsed)
ExperimentalFeatures.js
FixWindowsCopyBug.js (not parsed)
LoadOldPages.js (not parsed)
MethodFinder.js (not parsed)
PartsMenu.js (not parsed)
RobustLoading.js (not parsed)
SimpleBoundEval.js (not parsed)
TextPaste.js (not parsed)
Todo.js (not parsed)
Webwerkstatt.js (not parsed)
CloudStorageWebRequestCloudDriveLayer
CloudStorageWebRequestsLayer
AnotherSourceDatabase
beGlobal()
lively.ide.ModuleWrapper
lively.ide.SourceControlNode
lively.ide.SystemBrowser
lively.PartsBin
lively.PartsBin.PartItem
lively.PartsBin.PartsSpace
lively.store.ObjectRepository
URL
URL
WebResource
loadPart
loadPartMetaInfo
setPartFromJSON
>
<
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
        } else if (this.loadPartVersions && this.loadPartVersions().partVersions && this.loadPartVersions().partVe
rsions.length > 0) {
            this.rev = this.loadPartVersions().partVersions.first().rev;
        } else {
            this.rev = new WebResource(this.getFileURL()).getHeadRevision().headRevision;
        }
        // ensure that setPartFromJSON is only called when both json and
        // metaInfo are there.
        var loadTrigger = {
            item: this,
            rev: this.rev,
            triggerSetPart: function() {
                this.item.setPartFromJSON(this.json, this.metaInfo, this.rev);
            },
            jsonLoaded: function(json) {
                this.json = json;
                if (this.metaInfo === undefined) return;
                this.triggerSetPart();
            },
            metaInfoLoaded: function(metaInfo) {
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX