<commit_before>import AdhResource = require("../../Resources");
import SICommentable = require("../../Resources_/adhocracy_sample/sheets/comment/ICommentable");

import AdhConfig = require("../Config/Config");
import AdhListing = require("../Listing/Listing");
import Util = require("../Util/Util");

var pkgLocation = "/Comment";

export interface ICommentAdapter<T extends AdhResource.Content<any>> {
    create() : T;
    content(res : T) : string;
    content(res : T, value : string) : T;
    refersTo(res : T) : string;
    refersTo(res : T, value : string) : T;
    creator(red : T) : string;
}

export class ListingCommentableAdapter implements AdhListing.IListingContainerAdapter {
    public elemRefs(container : AdhResource.Content<SICommentable.HasAdhocracySampleSheetsCommentICommentable>) {
        return container.data["adhocracy_sample.sheets.comment.ICommentable"].comments;
    }
}

export class CommentCreate {
    constructor(private adapter : ICommentAdapter<any>) {}

    public createDirective(adhConfig : AdhConfig.Type) {
        var _self : CommentCreate = this;

        return {
            restrict: "E",
            templateUrl: adhConfig.pkg_path + pkgLocation + "/CommentCreate.html",
            scope: {
                refersTo: "@"  // path of a commentable version
            },
            controller: ["$scope", "adhHttp", ($scope, adhHttp) => {
                $scope.errors = [];
<commit_msg>add fixme about websockets<commit_after>import AdhResource = require("../../Resources");
import SICommentable = require("../../Resources_/adhocracy_sample/sheets/comment/ICommentable");

import AdhConfig = require("../Config/Config");
import AdhListing = require("../Listing/Listing");
import Util = require("../Util/Util");

var pkgLocation = "/Comment";

export interface ICommentAdapter<T extends AdhResource.Content<any>> {
    create() : T;
    content(res : T) : string;
    content(res : T, value : string) : T;
    refersTo(res : T) : string;
    refersTo(res : T, value : string) : T;
    creator(red : T) : string;
}

export class ListingCommentableAdapter implements AdhListing.IListingContainerAdapter {
    // FIXME: WebSocket updates do not work with this because there are no WebSocket
    // messages for new comments (only for new children). We do also not get any
    // messages for new children because the commentable is a version.
    public elemRefs(container : AdhResource.Content<SICommentable.HasAdhocracySampleSheetsCommentICommentable>) {
        return container.data["adhocracy_sample.sheets.comment.ICommentable"].comments;
    }
}

export class CommentCreate {
    constructor(private adapter : ICommentAdapter<any>) {}

    public createDirective(adhConfig : AdhConfig.Type) {
        var _self : CommentCreate = this;

        return {
            restrict: "E",
            templateUrl: adhConfig.pkg_path + pkgLocation + "/CommentCreate.html",
            scope: {
                refersTo: "@"  // path of a commentable version
            },
            controller: ["$scope", "adhHttp", ($scope, adhHttp) => {
                $scope.errors = [];

{'fraction_non_alphanumeric': 0.12532051282051282, 'fraction_numerical': 0.0, 'mean_word_length': 3.1948924731182795, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7060740', 'n_tokens_mistral': 891, 'n_tokens_neox': 889, 'n_words': 214}