/www/jssrc/blerg/Record.js
enyo.kind({
    name: "blerg.Record",
    kind: "Control",
    classes: "record",
    published: {
        data: "",
        timestamp: 0,
        author: "",
        record: null
    },
    components: [
        {name: "data", tag: null, allowHtml: true},
        {classes: "info", components: [
            {tag: null, content: "Posted "},
            {name: "date", tag: null},
            {tag: null, content: ". "},
            {name: "permalink", kind: "blerg.Link", content: "[permalink]"},
            {tag: null, content: " "},
            {name: "reply", kind: "blerg.Link", content: "[reply]", onNavigate: "postPopup"}
        ]}
    ],
    create: function() {
        this.inherited(arguments);
        this.dataChanged();
        this.timestampChanged();
        this.updateLinks();
    },
    dataChanged: function() {
        this.$.data.setContent(blerg.Util.blergFormat(this.data));
    },
    timestampChanged: function() {
        this.$.date.setContent(new Date(this.timestamp * 1000).toString());
    },
    authorChanged: function() {
        this.updateLinks();
    },
    recordChanged: function() {
        this.updateLinks();
    },
    updateLinks: function() {
        this.$.permalink.setHref(baseURL + enyo.macroize("/#{$author}/{$record}", this));
    },
    postPopup: function() {
        this.bubble('onPostVisibility', {
            showing: true,
            data: enyo.macroize("@{$author}/{$record}: ", this),
            replyto: this.$.data.getContent()
        });
        return true;
    }
});

enyo.kind({
    name: "blerg.TagRecord",
    kind: "blerg.Record",
    components: [
        {name: "data", tag: null, allowHtml: true},
        {classes: "info", components: [
            {tag: null, content: "Posted by "},
            {name: "author", kind: "blerg.Link", classes: "author ref"},
            {tag: null, content: " at "},
            {name: "date", tag: null},
            {tag: null, content: ". "},
            {name: "permalink", kind: "blerg.Link", content: "[permalink]"},
            {tag: null, content: " "},
            {name: "reply", kind: "blerg.Link", content: "[reply]", onNavigate: "postPopup"}
        ]}
    ],
    updateLinks: function() {
        this.inherited(arguments);
        this.$.author.setContent('@' + this.author);
        this.$.author.setHref('/#' + this.author);
    }
});

enyo.kind({
    name: "blerg.BriefRecord",
    kind: "blerg.Record",
    components: [
        {name: "authorlink", kind: "blerg.Link", classes: "author ref"},
        {tag: null, content: " "},
        {name: "data", tag: null}
    ],
    dataChanged: function() {
        var d = this.data.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
        this.$.data.setContent(d);
    },
    timestampChanged: function() { },
    updateLinks: function() {
        this.$.authorlink.setHref(baseURL + '/#' + this.author);
        this.$.authorlink.setContent('@' + this.author);
    },
});