<commit_before>/**
 * Book page
 */
define([
    "underscore",
    "jquery",
    "backbone",
    "handlebars",
    "text!views/templates/bookactivities.html"
],
function(_, $, Backbone, Handlebars, ActivitiesTemplate) {
    var BookPage = Backbone.View.extend({
        render: function() {
            // Fill out existing structure.
            var fieldsStandardText = ["title", "isbn", "publisher", "notesPublic", "notesPrivate"],
                authors, fieldValue, activities, $ul, template, statuses;

            _.each(fieldsStandardText, function(field) {
                // Use non-breaking space when field is null.
                if (this.model.has(field) && this.model.get(field).length > 0) {
                    fieldValue = this.model.get(field);
                } else {
                    fieldValue = "&nbsp;";
                }
                this.$("#book-" + field).html(fieldValue);
            }, this);

            // Show either author or authors rows.
            authors = this.model.get("authors");
            if (!_.isArray(authors) || authors.length === 0) {
                // Hide both.
                this.$(".author, .authors").hide();
            } else {
                // REFACTOR: use just one line, if simply using text for multiple authors.
                if (authors.length === 1) {
                    this.$(".authors").hide();
                    this.$(".author").show();
                    this.$(".author.ui-block-b div").html(authors[0]);
                } else {
                    this.$(".author").hide();
                    this.$(".authors").show();
                    this.$(".authors.ui-block-b div").html(authors.join(", "));
                }
            }

            // Private?
            this.$("#book-public").html(
                this.model.get("public") ? "Yes" : "No"
            );

            // List of activities.
            activities = this.model.get("activities");
            if (activities.length === 0) {
                 this.$("#book-activities").empty().html("&nbsp;");
            } else {
                this.$("#book-activities").empty().append("<ul>");
                $ul = this.$("#book-activities ul");
                template = Handlebars.compile(ActivitiesTemplate);
                _.each(activities, function(activity) {
                    $ul.append(template(activity));
                }, this);
            }
<commit_msg>Always treat activities as a list<commit_after>/**
 * Book page
 */
define([
    "underscore",
    "jquery",
    "backbone",
    "handlebars",
    "text!views/templates/bookactivities.html"
],
function(_, $, Backbone, Handlebars, ActivitiesTemplate) {
    var BookPage = Backbone.View.extend({
        render: function() {
            // Fill out existing structure.
            var fieldsStandardText = ["title", "isbn", "publisher", "notesPublic", "notesPrivate"],
                authors, fieldValue, activities, $ul, template, statuses;

            _.each(fieldsStandardText, function(field) {
                // Use non-breaking space when field is null.
                if (this.model.has(field) && this.model.get(field).length > 0) {
                    fieldValue = this.model.get(field);
                } else {
                    fieldValue = "&nbsp;";
                }
                this.$("#book-" + field).html(fieldValue);
            }, this);

            // Show either author or authors rows.
            authors = this.model.get("authors");
            if (!_.isArray(authors) || authors.length === 0) {
                // Hide both.
                this.$(".author, .authors").hide();
            } else {
                // REFACTOR: use just one line, if simply using text for multiple authors.
                if (authors.length === 1) {
                    this.$(".authors").hide();
                    this.$(".author").show();
                    this.$(".author.ui-block-b div").html(authors[0]);
                } else {
                    this.$(".author").hide();
                    this.$(".authors").show();
                    this.$(".authors.ui-block-b div").html(authors.join(", "));
                }
            }

            // Private?
            this.$("#book-public").html(
                this.model.get("public") ? "Yes" : "No"
            );

            // List of activities.
            activities = this.model.get("activities") || [];
            if (activities.length === 0) {
                 this.$("#book-activities").empty().html("&nbsp;");
            } else {
                this.$("#book-activities").empty().append("<ul>");
                $ul = this.$("#book-activities ul");
                template = Handlebars.compile(ActivitiesTemplate);
                _.each(activities, function(activity) {
                    $ul.append(template(activity));
                }, this);
            }

{'fraction_non_alphanumeric': 0.16006533278889343, 'fraction_numerical': 0.002041649652919559, 'mean_word_length': 1.451951951951952, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, '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': '7246828', 'n_tokens_mistral': 1303, 'n_tokens_neox': 1211, 'n_words': 249}