<commit_before><?php
namespace Grav\Plugin;

use Grav\Common\GPM\GPM;
use Grav\Common\Grav;
use Grav\Common\Language\Language;
use Grav\Common\Page\Page;
use Grav\Common\Page\Pages;
use Grav\Common\Plugin;
use Grav\Common\Uri;
use RocketTheme\Toolbox\File\File;
use RocketTheme\Toolbox\Event\Event;
use RocketTheme\Toolbox\Session\Session;

class AdminPlugin extends Plugin
{
    /**
     * @var bool
     */
    protected $active = false;

    /**
     * @var string
     */
    protected $template;

    /**
     * @var  string
     */
    protected $theme;

    /**
     * @var string
     */
    protected $route;

    /**
     * @var Uri
     */
    protected $uri;

    /**
     * @var Admin
     */
    protected $admin;

    /**
     * @var Session
     */
    protected $session;

    /**
     * @var Popularity
     */
    protected $popularity;

    /**
     * @var string
     */
    protected $base;

    /**
     * @return array
     */
    public static function getSubscribedEvents()
    {
        return [
            'onPluginsInitialized' => [['login', 100000], ['onPluginsInitialized', 1000]],
            'onShutdown'           => ['onShutdown', 1000]
        ];
    }

    /**
     * If the admin path matches, initialize the Login plugin configuration and set the admin
     * as active.
     */
    public function login()
    {
        // Check for Pro version is enabled
        if ($this->config->get('plugins.admin-pro.enabled')) {
            $this->active = false;
            return;
        }

        $route = $this->config->get('plugins.admin.route');
        if (!$route) {
            return;
        }

        $this->grav['debugger']->addMessage("Admin Basic");

        $this->base = '/' . trim($route, '/');
        $this->uri = $this->grav['uri'];

        // Only activate admin if we're inside the admin path.
        if ($this->uri->route() == $this->base ||
            substr($this->uri->route(), 0, strlen($this->base) + 1) == $this->base . '/') {
            $this->active = true;
        }
    }

    /**
     * If the admin plugin is set as active, initialize the admin
     */
    public function onPluginsInitialized()
    {
        // Only activate admin if we're inside the admin path.
        if ($this->active) {
            $this->initializeAdmin();
        }

        if ($this->isAdmin()) {
            // Disable Asset pipelining
            $this->config->set('system.assets.css_pipeline', false);
            $this->config->set('system.assets.js_pipeline', false);
        }

        // We need popularity no matter what
        require_once __DIR__ . '/classes/popularity.php';
        $this->popularity = new Popularity();
    }

    /**
     * Sets longer path to the home page allowing us to have list of pages when we enter to pages section.
     */
    public function onPagesInitialized()
    {
        $this->session = $this->grav['session'];

        // Set original route for the home page.
        $home = '/' . trim($this->config->get('system.home.alias'), '/');

        // set the default if not set before
        $this->session->expert = $this->session->expert ?: false;

        // set session variable if it's passed via the url
        if ($this->uri->param('mode') == 'expert') {
            $this->session->expert = true;
        } elseif ($this->uri->param('mode') == 'normal') {
            $this->session->expert = false;
        }<commit_msg>optimized disable asset pipeline logic<commit_after><?php
namespace Grav\Plugin;

use Grav\Common\GPM\GPM;
use Grav\Common\Grav;
use Grav\Common\Language\Language;
use Grav\Common\Page\Page;
use Grav\Common\Page\Pages;
use Grav\Common\Plugin;
use Grav\Common\Uri;
use RocketTheme\Toolbox\File\File;
use RocketTheme\Toolbox\Event\Event;
use RocketTheme\Toolbox\Session\Session;

class AdminPlugin extends Plugin
{
    /**
     * @var bool
     */
    protected $active = false;

    /**
     * @var string
     */
    protected $template;

    /**
     * @var  string
     */
    protected $theme;

    /**
     * @var string
     */
    protected $route;

    /**
     * @var Uri
     */
    protected $uri;

    /**
     * @var Admin
     */
    protected $admin;

    /**
     * @var Session
     */
    protected $session;

    /**
     * @var Popularity
     */
    protected $popularity;

    /**
     * @var string
     */
    protected $base;

    /**
     * @return array
     */
    public static function getSubscribedEvents()
    {
        return [
            'onPluginsInitialized' => [['login', 100000], ['onPluginsInitialized', 1000]],
            'onShutdown'           => ['onShutdown', 1000]
        ];
    }

    /**
     * If the admin path matches, initialize the Login plugin configuration and set the admin
     * as active.
     */
    public function login()
    {
        // Check for Pro version is enabled
        if ($this->config->get('plugins.admin-pro.enabled')) {
            $this->active = false;
            return;
        }

        $route = $this->config->get('plugins.admin.route');
        if (!$route) {
            return;
        }

        $this->grav['debugger']->addMessage("Admin Basic");

        $this->base = '/' . trim($route, '/');
        $this->uri = $this->grav['uri'];

        // Only activate admin if we're inside the admin path.
        if ($this->uri->route() == $this->base ||
            substr($this->uri->route(), 0, strlen($this->base) + 1) == $this->base . '/') {
            $this->active = true;
        }
    }

    /**
     * If the admin plugin is set as active, initialize the admin
     */
    public function onPluginsInitialized()
    {
        // Only activate admin if we're inside the admin path.
        if ($this->active) {
            $this->initializeAdmin();

            // Disable Asset pipelining
            $this->config->set('system.assets.css_pipeline', false);
            $this->config->set('system.assets.js_pipeline', false);
        }

        // We need popularity no matter what
        require_once __DIR__ . '/classes/popularity.php';
        $this->popularity = new Popularity();
    }

    /**
     * Sets longer path to the home page allowing us to have list of pages when we enter to pages section.
     */
    public function onPagesInitialized()
    {
        $this->session = $this->grav['session'];

        // Set original route for the home page.
        $home = '/' . trim($this->config->get('system.home.alias'), '/');

        // set the default if not set before
        $this->session->expert = $this->session->expert ?: false;

        // set session variable if it's passed via the url
        if ($this->uri->param('mode') == 'expert') {
            $this->session->expert = true;
        } elseif ($this->uri->param('mode') == 'normal') {
            $this->session->expert = false;
        }
{'fraction_non_alphanumeric': 0.1501242508405204, 'fraction_numerical': 0.00467767870194416, 'mean_word_length': 1.882055602358888, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 90, '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': '4242815', 'n_tokens_mistral': 2049, 'n_tokens_neox': 1955, 'n_words': 500}