<commit_before>/*!
 * Copyright 2012 Sakai Foundation (SF) Licensed under the
 * Educational Community License, Version 2.0 (the "License"); you may
 * not use this file except in compliance with the License. You may
 * obtain a copy of the License at
 *
 *     http://www.osedu.org/licenses/ECL-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an "AS IS"
 * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
 * or implied. See the License for the specific language governing
 * permissions and limitations under the License.
 */

require(['jquery','oae.core'], function($, oae) {

    //  Get the content id from the URL. The expected URL is `/content/<contentId>`
    var contentId = $.url().segment(2);
    if (!contentId) {
        oae.api.util.redirect().login();
    }

    // Variable used to cache the requested content profile
    var contentProfile = null;

    /**
     * Shows or hides actions on the content profile (e.g. uploading a new version)
     */
    var showContentActions = function() {
        // When we are dealing with a file, new versions can be uploaded and the revision history can be shown
        if (contentProfile.resourceSubType === 'file') {
            $('li .oae-trigger-uploadnewversion').show();
        }
    };

    /**
     * Shows the content profile preview.
     * If the user has no access to the profile or the content has not been found, they will be redirected.
     *
     * @param  {Object}   err       An error object, if any.
     * @param  {Object}   profile   The content profile object
     */
    var showContentProfilePreview = function(err, profile) {
        if (err) {
            if (err.code === 401) {
                oae.api.util.redirect().accessdenied();
            } else {
                oae.api.util.redirect().notfound();
            }
            return;
        }

        contentProfile = profile;

        // Refresh the preview
        $('#content_preview_container').html('');
        // Insert the preview
        oae.api.widget.insertWidget('contentpreview', null, $('#content_preview_container'), null, contentProfile);
    };

    /**
     * Get the content's basic profile and set up the screen. If the content
     * can't be found or is private to the current user, the appropriate
     * error page will be shown
     */
    var getContentProfile = function() {
        oae.api.content.getContent(contentId, function(err, profile) {
            showContentProfilePreview(err, profile);<commit_msg>Documentation fix<commit_after>/*!
 * Copyright 2012 Sakai Foundation (SF) Licensed under the
 * Educational Community License, Version 2.0 (the "License"); you may
 * not use this file except in compliance with the License. You may
 * obtain a copy of the License at
 *
 *     http://www.osedu.org/licenses/ECL-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an "AS IS"
 * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
 * or implied. See the License for the specific language governing
 * permissions and limitations under the License.
 */

require(['jquery','oae.core'], function($, oae) {

    //  Get the content id from the URL. The expected URL is `/content/<contentId>`
    var contentId = $.url().segment(2);
    if (!contentId) {
        oae.api.util.redirect().login();
    }

    // Variable used to cache the requested content profile
    var contentProfile = null;

    /**
     * Shows or hides actions on the content profile (e.g. uploading a new version)
     */
    var showContentActions = function() {
        // When we are dealing with a file, new versions can be uploaded and the revision history can be shown
        if (contentProfile.resourceSubType === 'file') {
            $('li .oae-trigger-uploadnewversion').show();
        }
    };

    /**
     * Renders the content preview.
     * If the user has no access to the profile or the content has not been found, they will be redirected.
     *
     * @param  {Object}   err       An error object, if any.
     * @param  {Object}   profile   The content profile object
     */
    var showContentProfilePreview = function(err, profile) {
        if (err) {
            if (err.code === 401) {
                oae.api.util.redirect().accessdenied();
            } else {
                oae.api.util.redirect().notfound();
            }
            return;
        }

        contentProfile = profile;

        // Refresh the preview
        $('#content_preview_container').html('');
        // Insert the preview
        oae.api.widget.insertWidget('contentpreview', null, $('#content_preview_container'), null, contentProfile);
    };

    /**
     * Get the content's basic profile and set up the screen. If the content
     * can't be found or is private to the current user, the appropriate
     * error page will be shown
     */
    var getContentProfile = function() {
        oae.api.content.getContent(contentId, function(err, profile) {
            showContentProfilePreview(err, profile);
{'fraction_non_alphanumeric': 0.10224632068164213, 'fraction_numerical': 0.004647560030983733, 'mean_word_length': 2.478114478114478, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '2832948', 'n_tokens_mistral': 1378, 'n_tokens_neox': 1329, 'n_words': 523}