<commit_before><?php
/**
 * DropBox Sync v1.0.0
 *
 * This plugin syncs data with your DropBox account.
 *
 * Licensed under MIT, see LICENSE.
 *
 * @package     DropBox Sync
 * @version     1.0.0
 * @link        <https://github.com/Vivalldi/grav-plugin-dropboxsync>
 * @author      <NAME> <<EMAIL>>
 * @author      <NAME> <<EMAIL>>
 * @copyright   2015, <NAME> and <NAME>
 * @license     <http://opensource.org/licenses/MIT>            MIT
 */

namespace Grav\Plugin;

use Grav\Common\Plugin;
use RocketTheme\Toolbox\Event\Event;

use Grav\Plugin\DropBoxSync\DropBoxSync;

/**
 * DropBox Sync v1.0.0
 *
 * This plugin syncs your data with your DropBox account.
 */
class DropBoxSyncPlugin extends Plugin
{
    /** ---------------------------
     * Private/protected properties
     * ----------------------------
     */

    /**
     * Instance of DropBoxSync class
     *
     * @var object
     */
    protected $backend;

    /** -------------
     * Public methods
     * --------------
     */

    /**
     * Return a list of subscribed events.
     *
     * @return array    The list of events of the plugin of the form
     *                      'name' => ['method_name', priority].
     */
    public static function getSubscribedEvents() {
        return [
            'onPluginsInitialized' => ['onPluginsInitialized', 0],
        ];
    }

    /**
     * Initialize configuration.
     */
    public function onPluginsInitialized()
    {
        if ($this->isAdmin()) {
            $this->active = false;
            return;
        }

        if ($this->config->get('plugins.dropboxsync.enabled')) {
            require_once(__DIR__.'/classes/DropBoxSync.php');

            // Get API key and API secret
            $credentials = [
                'app_key' => $this->config->get('plugins.dropboxsync.app.key'),
                'app_secret' => $this->config->get('plugins.dropbox.app.secret'),
                'app_full_access' => false
            ];
            // Get API key and API secret manaually. The credentials does NOT work if you use the config for some reason.
            $credentials = [
                'app_key' => "APP_Key_Here",
                'app_secret' => "APP_Secret_Here",
                'app_full_access' => false
            ];
            
            // Initialize DropBoxSync class
            $this->backend = new DropBoxSync($credentials);
        }
    }
}<commit_msg>Fixed loadding credentials from `dropboxsync.yaml`<commit_after><?php
/**
 * DropBox Sync v1.0.0
 *
 * This plugin syncs data with your DropBox account.
 *
 * Licensed under MIT, see LICENSE.
 *
 * @package     DropBox Sync
 * @version     1.0.0
 * @link        <https://github.com/Vivalldi/grav-plugin-dropboxsync>
 * @author      <NAME> <<EMAIL>>
 * @author      <NAME> <<EMAIL>>
 * @copyright   2015, <NAME> and <NAME>
 * @license     <http://opensource.org/licenses/MIT>            MIT
 */

namespace Grav\Plugin;

use Grav\Common\Plugin;
use RocketTheme\Toolbox\Event\Event;

use Grav\Plugin\DropBoxSync\DropBoxSync;

/**
 * DropBox Sync v1.0.0
 *
 * This plugin syncs your data with your DropBox account.
 */
class DropBoxSyncPlugin extends Plugin
{
    /** ---------------------------
     * Private/protected properties
     * ----------------------------
     */

    /**
     * @var bool
     */
    protected $active = false;

    /**
     * Instance of DropBoxSync class
     *
     * @var object
     */
    protected $backend;

    /** -------------
     * Public methods
     * --------------
     */

    /**
     * Return a list of subscribed events.
     *
     * @return array    The list of events of the plugin of the form
     *                      'name' => ['method_name', priority].
     */
    public static function getSubscribedEvents() {
        return [
            'onPluginsInitialized' => ['onPluginsInitialized', 0],
        ];
    }

    /**
     * Enable DropBoxSync only if url matches to the configuration.
     */
    public function onPluginsInitialized()
    {
        if ($this->isAdmin()) {
            $this->active = false;
            return;
        }

        /** @var Uri $uri */
        $uri = $this->grav['uri'];
        $route = $this->config->get('plugins.dropboxsync.route');

        if ($this->config->get('plugins.dropboxsync.enabled') && $route && $route == $uri->path()) {
            $this->active = true;

            require_once(__DIR__.'/classes/DropBoxSync.php');

            // Get API key and API secret
            $credentials = [
                'app_key' => $this->config->get('plugins.dropboxsync.app.key'),
                'app_secret' => $this->config->get('plugins.dropboxsync.app.secret'),
                'app_full_access' => false
            ];

            // Initialize DropBoxSync class
            $this->backend = new DropBoxSync($credentials);
        }
    }
}
{'fraction_non_alphanumeric': 0.16160164271047228, 'fraction_numerical': 0.005749486652977412, 'mean_word_length': 1.6793179317931792, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 59, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 3, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1724647', 'n_tokens_mistral': 1412, 'n_tokens_neox': 1376, 'n_words': 325}