<commit_before><?php
/**
New Licence bsd:
Copyright (c) <2012>, <NAME>
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
 * Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
 * Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
 * Neither the name of the trasweb.net nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL <NAME> BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

 */

namespace Team\Gui;
 
trait Assets { 


    /**
    Guardamos el path de Css para su posterior uso en una vista
    @param String $_file Fichero Css a añadir
    @param String $component especifica el componente donde se encuentra el recurso( usa "internet", si no es parte del proyecto )
    @param String position lugar del html en que se incrustara la carga del CSS: top( para el head) o bottom( para el pie )
     */
    public function addCss($_file, $component = null, $position = 'top', $package = null) {
        if(empty($_file) )return false;

        $_file = str_replace('.css','',$_file);

        $component = $component?? \Team\System\Context::get('COMPONENT');

        if("internet" === $component)
            $file = $_file;
        else {
            $file = "/".\Team\System\FileSystem::getPath("css", $component, $package )."{$_file}";

        }

        $idfile =    \Team\Data\Sanitize::identifier($file);
        $file .= '.css';


        if( "internet" == $component || \Team\System\FileSystem::exists($file) ) {
            \Team\Config::add("\\team\\css\\{$position}", $idfile, $file);

        }else if(\team\Config::get('SHOW_RESOURCES_WARNINGS', false) ) {
            \Team\Debug::me("Css file[$position] $file not found in {$package}/{$component}", 3);
        }
    }




    /**
    Guardamos el path de js para su posterior uso en una vista
    @param String $_file Fichero js a añadir
    @param String $component especifica el componente donde se encuentra el recurso( usa "internet", si no es parte del proyecto )
    @param String position lugar del html en que se incrustara la carga del JS: top( para el head) o bottom( para el pie )
     */
    public function addJs($_file, $component = null, $position = 'bottom', $package = null)  {
        if(empty($_file) )return false;

        $_file = str_replace('.js','',$_file);

        $component = $component?? \Team\System\Context::get('COMPONENT');

        if("internet" === $component)
            $file = $_file;
        else
            $file = "/".\Team\System\FileSystem::getPath("js", $component, $package)."{$_file}";

        $idfile =    \Team\Data\Sanitize::identifier($file);
        $file .= '.js';


        if('internet' == $component || \Team\System\FileSystem::exists($file) ) {
            \Team\Config::add("\\team\\js\\{$position}", $idfile, $file);
        }else if(\team\Config::get('SHOW_RESOURCES_WARNINGS', false) ) {
            \Team\Debug::me("Javascript file[$position] $file not found in {$package}/$component", 3);
        }

    }


}
<commit_msg>Now assets is placed taking script root path( public_html )<commit_after><?php
/**
New Licence bsd:
Copyright (c) <2012>, <NAME>
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
 * Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
 * Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
 * Neither the name of the trasweb.net nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL <NAME> BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

 */

namespace Team\Gui;
 
trait Assets { 


    /**
     * Enqueue a css file in order to include it in views
     * @param string $file it is a file css or url to file css
     * @param string $position place where css file will be included
     * @param string $idfile indentifier for css file
     *
     */
    public function addCss(string $file,  string $position = 'top', string $idfile = null) {
        $file = str_replace('.css','',$file);

        // maybe double slash(//) is used  => '//file.css'
        $is_external_css = strpos(':/', $file) !== null || '/' == $file[1];

        $idfile = $idfile??  \Team\Data\Sanitize::identifier($file);

        //normalize
        $file = $file.'.css';

        if($is_external_css || \Team\System\FileSystem::exists($file) ) {
            \Team\Config::add("\\team\\css\\{$position}", $idfile, $file);

        }else if(\team\Config::get('SHOW_RESOURCES_WARNINGS', false) ) {
            \Team\Debug::me("Css file[$position] $file not found", 3);
        }
    }


    /**
     * Enqueue a js file in order to include it in views
     * @param string $file it is a file js or url to file js
     * @param string $position place where js file will be included
     * @param string $idfile indentifier for js file
     *
     */
    public function addJs($file,  $position = 'bottom', $idfile = null)  {
        $file = str_replace('.js','',$file);

        // maybe double slash(//) is used  => '//file.js'
        $is_external_js = strpos(':/', $file) !== null || '/' == $file[1];

        $idfile = $idfile??  \Team\Data\Sanitize::identifier($file);

        //normalize
        $file = $file.'.js';

        if($is_external_js || \Team\System\FileSystem::exists($file) ) {
            \Team\Config::add("\\team\\js\\{$position}", $idfile, $file);
        }else if(\team\Config::get('SHOW_RESOURCES_WARNINGS', false) ) {
            \Team\Debug::me("Javascript file[$position] $file not found", 3);
        }

    }


}

{'fraction_non_alphanumeric': 0.11421788446320232, 'fraction_numerical': 0.0018464785017145871, 'mean_word_length': 3.2315848214285716, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, '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': '4642446', 'n_tokens_mistral': 2211, 'n_tokens_neox': 2068, 'n_words': 838}