From 6fc14d530369740d27d6bd641369d4f5f5f04080 Mon Sep 17 00:00:00 2001 From: ArthurHoaro Date: Wed, 15 Jul 2015 11:42:15 +0200 Subject: [PATCH 01/19] Plugin system - CORE see shaarli/Shaarli#275 --- .gitignore | 3 + application/Config.php | 263 ++++++++--------- application/PluginManager.php | 184 ++++++++++++ application/Router.php | 105 +++++++ index.php | 230 ++++++++++----- tests/PluginManagerTest.php | 66 +++++ tests/RouterTest.php | 515 ++++++++++++++++++++++++++++++++++ tests/plugins/test/test.php | 21 ++ 8 files changed, 1190 insertions(+), 197 deletions(-) mode change 100755 => 100644 application/Config.php create mode 100644 application/PluginManager.php create mode 100644 application/Router.php create mode 100755 tests/PluginManagerTest.php create mode 100755 tests/RouterTest.php create mode 100755 tests/plugins/test/test.php diff --git a/.gitignore b/.gitignore index 3ffedb31..5a6b9241 100644 --- a/.gitignore +++ b/.gitignore @@ -21,3 +21,6 @@ coverage tests/datastore.php tests/dummycache/ phpmd.html + +# Ignore user plugin configuration +plugins/*/config.php \ No newline at end of file diff --git a/application/Config.php b/application/Config.php old mode 100755 new mode 100644 index ec799d7f..c71ef68c --- a/application/Config.php +++ b/application/Config.php @@ -1,129 +1,134 @@ - $value) { - $configStr .= '$GLOBALS[\'config\'][\''. $key .'\'] = '.var_export($config['config'][$key], true).';'. PHP_EOL; - } - $configStr .= '?>'; - - if (!file_put_contents($config['config']['CONFIG_FILE'], $configStr) - || strcmp(file_get_contents($config['config']['CONFIG_FILE']), $configStr) != 0 - ) { - throw new Exception( - 'Shaarli could not create the config file. - Please make sure Shaarli has the right to write in the folder is it installed in.' - ); - } -} - -/** - * Milestone 0.9 - shaarli/Shaarli#41: options.php is not supported anymore. - * ==> if user is loggedIn, merge its content with config.php, then delete options.php. - * - * @param array $config contains all configuration fields. - * @param bool $isLoggedIn true if user is logged in. - * - * @return void - */ -function mergeDeprecatedConfig($config, $isLoggedIn) -{ - $config_file = $config['config']['CONFIG_FILE']; - - if (is_file($config['config']['DATADIR'].'/options.php') && $isLoggedIn) { - include $config['config']['DATADIR'].'/options.php'; - - // Load GLOBALS into config - foreach ($GLOBALS as $key => $value) { - $config[$key] = $value; - } - $config['config']['CONFIG_FILE'] = $config_file; - writeConfig($config, $isLoggedIn); - - unlink($config['config']['DATADIR'].'/options.php'); - } -} - -/** - * Exception used if a mandatory field is missing in given configuration. - */ -class MissingFieldConfigException extends Exception -{ - public $field; - - /** - * Construct exception. - * - * @param string $field field name missing. - */ - public function __construct($field) - { - $this->field = $field; - $this->message = 'Configuration value is required for '. $this->field; - } -} - -/** - * Exception used if an unauthorized attempt to edit configuration has been made. - */ -class UnauthorizedConfigException extends Exception -{ - /** - * Construct exception. - */ - public function __construct() - { - $this->message = 'You are not authorized to alter config.'; - } -} + $value) { + $configStr .= '$GLOBALS[\'config\'][\''. $key .'\'] = '.var_export($config['config'][$key], true).';'. PHP_EOL; + } + + if (isset($config['plugins'])) { + foreach ($config['plugins'] as $key => $value) { + $configStr .= '$GLOBALS[\'plugins\'][\''. $key .'\'] = '.var_export($config['plugins'][$key], true).';'. PHP_EOL; + } + } + + if (!file_put_contents($config['config']['CONFIG_FILE'], $configStr) + || strcmp(file_get_contents($config['config']['CONFIG_FILE']), $configStr) != 0 + ) { + throw new Exception( + 'Shaarli could not create the config file. + Please make sure Shaarli has the right to write in the folder is it installed in.' + ); + } +} + +/** + * Milestone 0.9 - shaarli/Shaarli#41: options.php is not supported anymore. + * ==> if user is loggedIn, merge its content with config.php, then delete options.php. + * + * @param array $config contains all configuration fields. + * @param bool $isLoggedIn true if user is logged in. + * + * @return void + */ +function mergeDeprecatedConfig($config, $isLoggedIn) +{ + $config_file = $config['config']['CONFIG_FILE']; + + if (is_file($config['config']['DATADIR'].'/options.php') && $isLoggedIn) { + include $config['config']['DATADIR'].'/options.php'; + + // Load GLOBALS into config + foreach ($GLOBALS as $key => $value) { + $config[$key] = $value; + } + $config['config']['CONFIG_FILE'] = $config_file; + writeConfig($config, $isLoggedIn); + + unlink($config['config']['DATADIR'].'/options.php'); + } +} + +/** + * Exception used if a mandatory field is missing in given configuration. + */ +class MissingFieldConfigException extends Exception +{ + public $field; + + /** + * Construct exception. + * + * @param string $field field name missing. + */ + public function __construct($field) + { + $this->field = $field; + $this->message = 'Configuration value is required for '. $this->field; + } +} + +/** + * Exception used if an unauthorized attempt to edit configuration has been made. + */ +class UnauthorizedConfigException extends Exception +{ + /** + * Construct exception. + */ + public function __construct() + { + $this->message = 'You are not authorized to alter config.'; + } +} diff --git a/application/PluginManager.php b/application/PluginManager.php new file mode 100644 index 00000000..e572ff7c --- /dev/null +++ b/application/PluginManager.php @@ -0,0 +1,184 @@ +authorizedPlugins = $authorizedPlugins; + + $dirs = glob(self::$PLUGINS_PATH . '/*', GLOB_ONLYDIR); + $dirnames = array_map('basename', $dirs); + foreach ($this->authorizedPlugins as $plugin) { + $index = array_search($plugin, $dirnames); + + // plugin authorized, but its folder isn't listed + if ($index === false) { + continue; + } + + try { + $this->loadPlugin($dirs[$index], $plugin); + } + catch (PluginFileNotFoundException $e) { + error_log($e->getMessage()); + } + } + } + + /** + * Execute all plugins registered hook. + * + * @param string $hook name of the hook to trigger. + * @param array $data list of data to manipulate passed by reference. + * @param array $params additional parameters such as page target. + * + * @return void + */ + public function executeHooks($hook, &$data, $params = array()) + { + if (!empty($params['target'])) { + $data['_PAGE_'] = $params['target']; + } + + if (isset($params['loggedin'])) { + $data['_LOGGEDIN_'] = $params['loggedin']; + } + + foreach ($this->loadedPlugins as $plugin) { + $hookFunction = $this->buildHookName($hook, $plugin); + + if (function_exists($hookFunction)) { + $data = call_user_func($hookFunction, $data); + } + } + } + + /** + * Load a single plugin from its files. + * Add them in $loadedPlugins if successful. + * + * @param string $dir plugin's directory. + * @param string $pluginName plugin's name. + * + * @return void + * @throws PluginFileNotFoundException - plugin files not found. + */ + private function loadPlugin($dir, $pluginName) + { + if (!is_dir($dir)) { + throw new PluginFileNotFoundException($pluginName); + } + + $pluginFilePath = $dir . '/' . $pluginName . '.php'; + if (!is_file($pluginFilePath)) { + throw new PluginFileNotFoundException($pluginName); + } + + include_once $pluginFilePath; + + $this->loadedPlugins[] = $pluginName; + } + + /** + * Construct normalize hook name for a specific plugin. + * + * Format: + * hook__ + * + * @param string $hook hook name. + * @param string $pluginName plugin name. + * + * @return string - plugin's hook name. + */ + public function buildHookName($hook, $pluginName) + { + return 'hook_' . $pluginName . '_' . $hook; + } +} + +/** + * Class PluginFileNotFoundException + * + * Raise when plugin files can't be found. + */ +class PluginFileNotFoundException extends Exception +{ + /** + * Construct exception with plugin name. + * Generate message. + * + * @param string $pluginName name of the plugin not found + */ + public function __construct($pluginName) + { + $this->message = 'Plugin "'. $pluginName .'" files not found.'; + } +} \ No newline at end of file diff --git a/application/Router.php b/application/Router.php new file mode 100644 index 00000000..82b2b858 --- /dev/null +++ b/application/Router.php @@ -0,0 +1,105 @@ + /shaarli/ @@ -75,6 +84,8 @@ require_once 'application/Url.php'; require_once 'application/Utils.php'; require_once 'application/Config.php'; +require_once 'application/PluginManager.php'; +require_once 'application/Router.php'; // Ensure the PHP version is supported try { @@ -119,6 +130,9 @@ raintpl::$tpl_dir = $GLOBALS['config']['RAINTPL_TPL']; // template directory raintpl::$cache_dir = $GLOBALS['config']['RAINTPL_TMP']; // cache directory +$pluginManager = PluginManager::getInstance(); +$pluginManager->load($GLOBALS['config']['ENABLED_PLUGINS']); + ob_start(); // Output buffering for the page cache. @@ -962,16 +976,31 @@ function showDaily() $fill[$index]+=$length; } $PAGE = new pageBuilder; - $PAGE->assign('linksToDisplay',$linksToDisplay); - $PAGE->assign('linkcount',count($LINKSDB)); - $PAGE->assign('cols', $columns); - $PAGE->assign('day',linkdate2timestamp($day.'_000000')); - $PAGE->assign('previousday',$previousday); - $PAGE->assign('nextday',$nextday); + $data = array( + 'linksToDisplay' => $linksToDisplay, + 'linkcount' => count($LINKSDB), + 'cols' => $columns, + 'day' => linkdate2timestamp($day.'_000000'), + 'previousday' => $previousday, + 'nextday' => $nextday, + ); + $pluginManager = PluginManager::getInstance(); + $pluginManager->executeHooks('render_daily', $data, array('loggedin' => isLoggedIn())); + + foreach ($data as $key => $value) { + $PAGE->assign($key, $value); + } + $PAGE->renderPage('daily'); exit; } +// Renders the linklist +function showLinkList($PAGE, $LINKSDB) { + buildLinkList($PAGE,$LINKSDB); // Compute list of links to display + $PAGE->renderPage('linklist'); +} + // ------------------------------------------------------------------------------------------ // Render HTML page (according to URL parameters and user rights) @@ -983,12 +1012,36 @@ function renderPage() $GLOBALS['config']['HIDE_PUBLIC_LINKS'] ); + $PAGE = new pageBuilder; + + // Determine which page will be rendered. + $query = (isset($_SERVER['QUERY_STRING'])) ? $_SERVER['QUERY_STRING'] : ''; + $targetPage = Router::findPage($query, $_GET, isLoggedIn()); + + // Call plugin hooks for header, footer and includes, specifying which page will be rendered. + // Then assign generated data to RainTPL. + $common_hooks = array( + 'header', + 'footer', + 'includes', + ); + $pluginManager = PluginManager::getInstance(); + foreach($common_hooks as $name) { + $plugin_data = array(); + $pluginManager->executeHooks('render_' . $name, $plugin_data, + array( + 'target' => $targetPage, + 'loggedin' => isLoggedIn() + ) + ); + $PAGE->assign('plugins_' . $name, $plugin_data); + } + // -------- Display login form. - if (isset($_SERVER["QUERY_STRING"]) && startswith($_SERVER["QUERY_STRING"],'do=login')) + if ($targetPage == Router::$PAGE_LOGIN) { if ($GLOBALS['config']['OPEN_SHAARLI']) { header('Location: ?'); exit; } // No need to login for open Shaarli $token=''; if (ban_canLogin()) $token=getToken(); // Do not waste token generation if not useful. - $PAGE = new pageBuilder; $PAGE->assign('token',$token); $PAGE->assign('returnurl',(isset($_SERVER['HTTP_REFERER']) ? escape($_SERVER['HTTP_REFERER']):'')); $PAGE->renderPage('loginform'); @@ -1004,7 +1057,7 @@ function renderPage() } // -------- Picture wall - if (isset($_SERVER["QUERY_STRING"]) && startswith($_SERVER["QUERY_STRING"],'do=picwall')) + if ($targetPage == Router::$PAGE_PICWALL) { // Optionally filter the results: $links=array(); @@ -1027,15 +1080,22 @@ function renderPage() } } - $PAGE = new pageBuilder; - $PAGE->assign('linkcount',count($LINKSDB)); - $PAGE->assign('linksToDisplay',$linksToDisplay); + $data = array( + 'linkcount' => count($LINKSDB), + 'linksToDisplay' => $linksToDisplay, + ); + $pluginManager->executeHooks('render_picwall', $data, array('loggedin' => isLoggedIn())); + + foreach ($data as $key => $value) { + $PAGE->assign($key, $value); + } + $PAGE->renderPage('picwall'); exit; } // -------- Tag cloud - if (isset($_SERVER["QUERY_STRING"]) && startswith($_SERVER["QUERY_STRING"],'do=tagcloud')) + if ($targetPage == Router::$PAGE_TAGCLOUD) { $tags= $LINKSDB->allTags(); @@ -1049,9 +1109,17 @@ function renderPage() { $tagList[$key] = array('count'=>$value,'size'=>log($value, 15) / log($maxcount, 30) * (22-6) + 6); } - $PAGE = new pageBuilder; - $PAGE->assign('linkcount',count($LINKSDB)); - $PAGE->assign('tags',$tagList); + + $data = array( + 'linkcount' => count($LINKSDB), + 'tags' => $tagList, + ); + $pluginManager->executeHooks('render_tagcloud', $data, array('loggedin' => isLoggedIn())); + + foreach ($data as $key => $value) { + $PAGE->assign($key, $value); + } + $PAGE->renderPage('tagcloud'); exit; } @@ -1164,32 +1232,36 @@ function renderPage() header('Location: ?do=login&post='); exit; } - + showLinkList($PAGE, $LINKSDB); if (isset($_GET['edit_link'])) { header('Location: ?do=login&edit_link='. escape($_GET['edit_link'])); exit; } - $PAGE = new pageBuilder; - buildLinkList($PAGE,$LINKSDB); // Compute list of links to display - $PAGE->renderPage('linklist'); exit; // Never remove this one! All operations below are reserved for logged in user. } // -------- All other functions are reserved for the registered user: // -------- Display the Tools menu if requested (import/export/bookmarklet...) - if (isset($_SERVER["QUERY_STRING"]) && startswith($_SERVER["QUERY_STRING"],'do=tools')) + if ($targetPage == Router::$PAGE_TOOLS) { - $PAGE = new pageBuilder; - $PAGE->assign('linkcount',count($LINKSDB)); - $PAGE->assign('pageabsaddr',index_url($_SERVER)); + $data = array( + 'linkcount' => count($LINKSDB), + 'pageabsaddr' => index_url($_SERVER), + ); + $pluginManager->executeHooks('render_tools', $data); + + foreach ($data as $key => $value) { + $PAGE->assign($key, $value); + } + $PAGE->renderPage('tools'); exit; } // -------- User wants to change his/her password. - if (isset($_SERVER["QUERY_STRING"]) && startswith($_SERVER["QUERY_STRING"],'do=changepasswd')) + if ($targetPage == Router::$PAGE_CHANGEPASSWORD) { if ($GLOBALS['config']['OPEN_SHAARLI']) die('You are not supposed to change a password on an Open Shaarli.'); if (!empty($_POST['setpassword']) && !empty($_POST['oldpassword'])) @@ -1220,7 +1292,6 @@ function renderPage() } else // show the change password form. { - $PAGE = new pageBuilder; $PAGE->assign('linkcount',count($LINKSDB)); $PAGE->assign('token',getToken()); $PAGE->renderPage('changepassword'); @@ -1229,7 +1300,7 @@ function renderPage() } // -------- User wants to change configuration - if (isset($_SERVER["QUERY_STRING"]) && startswith($_SERVER["QUERY_STRING"],'do=configure')) + if ($targetPage == Router::$PAGE_CONFIGURE) { if (!empty($_POST['title']) ) { @@ -1265,7 +1336,6 @@ function renderPage() } else // Show the configuration form. { - $PAGE = new pageBuilder; $PAGE->assign('linkcount',count($LINKSDB)); $PAGE->assign('token',getToken()); $PAGE->assign('title', empty($GLOBALS['title']) ? '' : $GLOBALS['title'] ); @@ -1279,11 +1349,10 @@ function renderPage() } // -------- User wants to rename a tag or delete it - if (isset($_SERVER["QUERY_STRING"]) && startswith($_SERVER["QUERY_STRING"],'do=changetag')) + if ($targetPage == Router::$PAGE_CHANGETAG) { if (empty($_POST['fromtag'])) { - $PAGE = new pageBuilder; $PAGE->assign('linkcount',count($LINKSDB)); $PAGE->assign('token',getToken()); $PAGE->assign('tags', $LINKSDB->allTags()); @@ -1328,9 +1397,8 @@ function renderPage() } // -------- User wants to add a link without using the bookmarklet: Show form. - if (isset($_SERVER["QUERY_STRING"]) && startswith($_SERVER["QUERY_STRING"],'do=addlink')) + if ($targetPage == Router::$PAGE_ADDLINK) { - $PAGE = new pageBuilder; $PAGE->assign('linkcount',count($LINKSDB)); $PAGE->renderPage('addlink'); exit; @@ -1349,6 +1417,9 @@ function renderPage() $link = array('title'=>trim($_POST['lf_title']),'url'=>$url,'description'=>trim($_POST['lf_description']),'private'=>(isset($_POST['lf_private']) ? 1 : 0), 'linkdate'=>$linkdate,'tags'=>str_replace(',',' ',$tags)); if ($link['title']=='') $link['title']=$link['url']; // If title is empty, use the URL as title. + + $pluginManager->executeHooks('save_link', $link); + $LINKSDB[$linkdate] = $link; $LINKSDB->savedb($GLOBALS['config']['PAGECACHE']); // Save to disk. pubsubhub(); @@ -1382,6 +1453,9 @@ function renderPage() // - confirmation is handled by JavaScript // - we are protected from XSRF by the token. $linkdate=$_POST['lf_linkdate']; + + $pluginManager->executeHooks('delete_link', $LINKSDB[$linkdate]); + unset($LINKSDB[$linkdate]); $LINKSDB->savedb($GLOBALS['config']['PAGECACHE']); // save to disk @@ -1423,13 +1497,20 @@ function renderPage() { $link = $LINKSDB[$_GET['edit_link']]; // Read database if (!$link) { header('Location: ?'); exit; } // Link not found in database. - $PAGE = new pageBuilder; - $PAGE->assign('linkcount',count($LINKSDB)); - $PAGE->assign('link',$link); - $PAGE->assign('link_is_new',false); - $PAGE->assign('token',getToken()); // XSRF protection. - $PAGE->assign('http_referer',(isset($_SERVER['HTTP_REFERER']) ? escape($_SERVER['HTTP_REFERER']) : '')); - $PAGE->assign('tags', $LINKSDB->allTags()); + $data = array( + 'linkcount' => count($LINKSDB), + 'link' => $link, + 'link_is_new' => false, + 'token' => getToken(), + 'http_referer' => (isset($_SERVER['HTTP_REFERER']) ? escape($_SERVER['HTTP_REFERER']) : ''), + 'tags' => $LINKSDB->allTags(), + ); + $pluginManager->executeHooks('render_editlink', $data); + + foreach ($data as $key => $value) { + $PAGE->assign($key, $value); + } + $PAGE->renderPage('editlink'); exit; } @@ -1493,24 +1574,30 @@ function renderPage() ); } - $PAGE = new pageBuilder; - $PAGE->assign('linkcount',count($LINKSDB)); - $PAGE->assign('link',$link); - $PAGE->assign('link_is_new',$link_is_new); - $PAGE->assign('token',getToken()); // XSRF protection. - $PAGE->assign('http_referer',(isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '')); - $PAGE->assign('source',(isset($_GET['source']) ? $_GET['source'] : '')); - $PAGE->assign('tags', $LINKSDB->allTags()); + $data = array( + 'linkcount' => count($LINKSDB), + 'link' => $link, + 'link_is_new' => $link_is_new, + 'token' => getToken(), // XSRF protection. + 'http_referer' => (isset($_SERVER['HTTP_REFERER']) ? escape($_SERVER['HTTP_REFERER']) : ''), + 'source' => (isset($_GET['source']) ? $_GET['source'] : ''), + 'tags' => $LINKSDB->allTags(), + ); + $pluginManager->executeHooks('render_editlink', $data); + + foreach ($data as $key => $value) { + $PAGE->assign($key, $value); + } + $PAGE->renderPage('editlink'); exit; } // -------- Export as Netscape Bookmarks HTML file. - if (isset($_SERVER["QUERY_STRING"]) && startswith($_SERVER["QUERY_STRING"],'do=export')) + if ($targetPage == Router::$PAGE_EXPORT) { if (empty($_GET['what'])) { - $PAGE = new pageBuilder; $PAGE->assign('linkcount',count($LINKSDB)); $PAGE->renderPage('export'); exit; @@ -1562,9 +1649,8 @@ function renderPage() } // -------- Show upload/import dialog: - if (isset($_SERVER["QUERY_STRING"]) && startswith($_SERVER["QUERY_STRING"],'do=import')) + if ($targetPage == Router::$PAGE_IMPORT) { - $PAGE = new pageBuilder; $PAGE->assign('linkcount',count($LINKSDB)); $PAGE->assign('token',getToken()); $PAGE->assign('maxfilesize',getMaxFileSize()); @@ -1573,9 +1659,7 @@ function renderPage() } // -------- Otherwise, simply display search form and links: - $PAGE = new pageBuilder; - buildLinkList($PAGE,$LINKSDB); // Compute list of links to display - $PAGE->renderPage('linklist'); + showLinkList($PAGE, $LINKSDB); exit; } @@ -1746,7 +1830,7 @@ function buildLinkList($PAGE,$LINKSDB) $taglist = explode(' ',$link['tags']); uasort($taglist, 'strcasecmp'); $link['taglist']=$taglist; - + $link['shorturl'] = smallHash($link['linkdate']); if ($link["url"][0] === '?' && // Check for both signs of a note: starting with ? and 7 chars long. I doubt that you'll post any links that look like this. strlen($link["url"]) === 7) { $link["url"] = index_url($_SERVER) . $link["url"]; @@ -1766,18 +1850,28 @@ function buildLinkList($PAGE,$LINKSDB) $token = ''; if (isLoggedIn()) $token=getToken(); // Fill all template fields. - $PAGE->assign('linkcount',count($LINKSDB)); - $PAGE->assign('previous_page_url',$previous_page_url); - $PAGE->assign('next_page_url',$next_page_url); - $PAGE->assign('page_current',$page); - $PAGE->assign('page_max',$pagecount); - $PAGE->assign('result_count',count($linksToDisplay)); - $PAGE->assign('search_type',$search_type); - $PAGE->assign('search_crits',$search_crits); - $PAGE->assign('redirector',empty($GLOBALS['redirector']) ? '' : $GLOBALS['redirector']); // Optional redirector URL. - $PAGE->assign('token',$token); - $PAGE->assign('links',$linkDisp); - $PAGE->assign('tags', $LINKSDB->allTags()); + $data = array( + 'linkcount' => count($LINKSDB), + 'previous_page_url' => $previous_page_url, + 'next_page_url' => $next_page_url, + 'page_current' => $page, + 'page_max' => $pagecount, + 'result_count' => count($linksToDisplay), + 'search_type' => $search_type, + 'search_crits' => $search_crits, + 'redirector' => empty($GLOBALS['redirector']) ? '' : $GLOBALS['redirector'], // Optional redirector URL. + 'token' => $token, + 'links' => $linkDisp, + 'tags' => $LINKSDB->allTags(), + ); + + $pluginManager = PluginManager::getInstance(); + $pluginManager->executeHooks('render_linklist', $data, array('loggedin' => isLoggedIn())); + + foreach ($data as $key => $value) { + $PAGE->assign($key, $value); + } + return; } diff --git a/tests/PluginManagerTest.php b/tests/PluginManagerTest.php new file mode 100755 index 00000000..749ce2b5 --- /dev/null +++ b/tests/PluginManagerTest.php @@ -0,0 +1,66 @@ +load(array(self::$_PLUGIN_NAME)); + + $this->assertTrue(function_exists('hook_test_random')); + + $data = array(0 => 'woot'); + $pluginManager->executeHooks('random', $data); + $this->assertEquals('woot', $data[1]); + + $data = array(0 => 'woot'); + $pluginManager->executeHooks('random', $data, array('target' => 'test')); + $this->assertEquals('page test', $data[1]); + + $data = array(0 => 'woot'); + $pluginManager->executeHooks('random', $data, array('loggedin' => true)); + $this->assertEquals('loggedin', $data[1]); + } + + /** + * Test missing plugin loading. + * + * @return void + */ + public function testPluginNotFound() + { + $pluginManager = PluginManager::getInstance(); + + $pluginManager->load(array()); + + $pluginManager->load(array('nope', 'renope')); + } +} \ No newline at end of file diff --git a/tests/RouterTest.php b/tests/RouterTest.php new file mode 100755 index 00000000..8838bc8d --- /dev/null +++ b/tests/RouterTest.php @@ -0,0 +1,515 @@ +assertEquals( + Router::$PAGE_LOGIN, + Router::findPage('do=login', array(), false) + ); + + $this->assertEquals( + Router::$PAGE_LOGIN, + Router::findPage('do=login', array(), 1) + ); + + $this->assertEquals( + Router::$PAGE_LOGIN, + Router::findPage('do=login&stuff', array(), false) + ); + } + + /** + * Test findPage: login page output. + * Invalid: page shouldn't be return. + * + * @return void + */ + public function testFindPageLoginInvalid() + { + $this->assertNotEquals( + Router::$PAGE_LOGIN, + Router::findPage('do=login', array(), true) + ); + + $this->assertNotEquals( + Router::$PAGE_LOGIN, + Router::findPage('do=other', array(), false) + ); + } + + /** + * Test findPage: picwall page output. + * Valid: page should be return. + * + * @return void + */ + public function testFindPagePicwallValid() + { + $this->assertEquals( + Router::$PAGE_PICWALL, + Router::findPage('do=picwall', array(), false) + ); + + $this->assertEquals( + Router::$PAGE_PICWALL, + Router::findPage('do=picwall', array(), true) + ); + } + + /** + * Test findPage: picwall page output. + * Invalid: page shouldn't be return. + * + * @return void + */ + public function testFindPagePicwallInvalid() + { + $this->assertEquals( + Router::$PAGE_PICWALL, + Router::findPage('do=picwall&stuff', array(), false) + ); + + $this->assertNotEquals( + Router::$PAGE_PICWALL, + Router::findPage('do=other', array(), false) + ); + } + + /** + * Test findPage: tagcloud page output. + * Valid: page should be return. + * + * @return void + */ + public function testFindPageTagcloudValid() + { + $this->assertEquals( + Router::$PAGE_TAGCLOUD, + Router::findPage('do=tagcloud', array(), false) + ); + + $this->assertEquals( + Router::$PAGE_TAGCLOUD, + Router::findPage('do=tagcloud', array(), true) + ); + + $this->assertEquals( + Router::$PAGE_TAGCLOUD, + Router::findPage('do=tagcloud&stuff', array(), false) + ); + } + + /** + * Test findPage: tagcloud page output. + * Invalid: page shouldn't be return. + * + * @return void + */ + public function testFindPageTagcloudInvalid() + { + $this->assertNotEquals( + Router::$PAGE_TAGCLOUD, + Router::findPage('do=other', array(), false) + ); + } + + /** + * Test findPage: linklist page output. + * Valid: page should be return. + * + * @return void + */ + public function testFindPageLinklistValid() + { + $this->assertEquals( + Router::$PAGE_LINKLIST, + Router::findPage('', array(), true) + ); + + $this->assertEquals( + Router::$PAGE_LINKLIST, + Router::findPage('whatever', array(), true) + ); + + $this->assertEquals( + Router::$PAGE_LINKLIST, + Router::findPage('whatever', array(), false) + ); + + $this->assertEquals( + Router::$PAGE_LINKLIST, + Router::findPage('do=tools', array(), false) + ); + } + + /** + * Test findPage: tools page output. + * Valid: page should be return. + * + * @return void + */ + public function testFindPageToolsValid() + { + $this->assertEquals( + Router::$PAGE_TOOLS, + Router::findPage('do=tools', array(), true) + ); + + $this->assertEquals( + Router::$PAGE_TOOLS, + Router::findPage('do=tools&stuff', array(), true) + ); + } + + /** + * Test findPage: tools page output. + * Invalid: page shouldn't be return. + * + * @return void + */ + public function testFindPageToolsInvalid() + { + $this->assertNotEquals( + Router::$PAGE_TOOLS, + Router::findPage('do=tools', array(), 1) + ); + + $this->assertNotEquals( + Router::$PAGE_TOOLS, + Router::findPage('do=tools', array(), false) + ); + + $this->assertNotEquals( + Router::$PAGE_TOOLS, + Router::findPage('do=other', array(), true) + ); + } + + /** + * Test findPage: changepasswd page output. + * Valid: page should be return. + * + * @return void + */ + public function testFindPageChangepasswdValid() + { + $this->assertEquals( + Router::$PAGE_CHANGEPASSWORD, + Router::findPage('do=changepasswd', array(), true) + ); + $this->assertEquals( + Router::$PAGE_CHANGEPASSWORD, + Router::findPage('do=changepasswd&stuff', array(), true) + ); + + } + + /** + * Test findPage: changepasswd page output. + * Invalid: page shouldn't be return. + * + * @return void + */ + public function testFindPageChangepasswdInvalid() + { + $this->assertNotEquals( + Router::$PAGE_CHANGEPASSWORD, + Router::findPage('do=changepasswd', array(), 1) + ); + + $this->assertNotEquals( + Router::$PAGE_CHANGEPASSWORD, + Router::findPage('do=changepasswd', array(), false) + ); + + $this->assertNotEquals( + Router::$PAGE_CHANGEPASSWORD, + Router::findPage('do=other', array(), true) + ); + } + /** + * Test findPage: configure page output. + * Valid: page should be return. + * + * @return void + */ + public function testFindPageConfigureValid() + { + $this->assertEquals( + Router::$PAGE_CONFIGURE, + Router::findPage('do=configure', array(), true) + ); + + $this->assertEquals( + Router::$PAGE_CONFIGURE, + Router::findPage('do=configure&stuff', array(), true) + ); + } + + /** + * Test findPage: configure page output. + * Invalid: page shouldn't be return. + * + * @return void + */ + public function testFindPageConfigureInvalid() + { + $this->assertNotEquals( + Router::$PAGE_CONFIGURE, + Router::findPage('do=configure', array(), 1) + ); + + $this->assertNotEquals( + Router::$PAGE_CONFIGURE, + Router::findPage('do=configure', array(), false) + ); + + $this->assertNotEquals( + Router::$PAGE_CONFIGURE, + Router::findPage('do=other', array(), true) + ); + } + + /** + * Test findPage: changetag page output. + * Valid: page should be return. + * + * @return void + */ + public function testFindPageChangetagValid() + { + $this->assertEquals( + Router::$PAGE_CHANGETAG, + Router::findPage('do=changetag', array(), true) + ); + + $this->assertEquals( + Router::$PAGE_CHANGETAG, + Router::findPage('do=changetag&stuff', array(), true) + ); + } + + /** + * Test findPage: changetag page output. + * Invalid: page shouldn't be return. + * + * @return void + */ + public function testFindPageChangetagInvalid() + { + $this->assertNotEquals( + Router::$PAGE_CHANGETAG, + Router::findPage('do=changetag', array(), 1) + ); + + $this->assertNotEquals( + Router::$PAGE_CHANGETAG, + Router::findPage('do=changetag', array(), false) + ); + + $this->assertNotEquals( + Router::$PAGE_CHANGETAG, + Router::findPage('do=other', array(), true) + ); + } + + /** + * Test findPage: addlink page output. + * Valid: page should be return. + * + * @return void + */ + public function testFindPageAddlinkValid() + { + $this->assertEquals( + Router::$PAGE_ADDLINK, + Router::findPage('do=addlink', array(), true) + ); + + $this->assertEquals( + Router::$PAGE_ADDLINK, + Router::findPage('do=addlink&stuff', array(), true) + ); + } + + /** + * Test findPage: addlink page output. + * Invalid: page shouldn't be return. + * + * @return void + */ + public function testFindPageAddlinkInvalid() + { + $this->assertNotEquals( + Router::$PAGE_ADDLINK, + Router::findPage('do=addlink', array(), 1) + ); + + $this->assertNotEquals( + Router::$PAGE_ADDLINK, + Router::findPage('do=addlink', array(), false) + ); + + $this->assertNotEquals( + Router::$PAGE_ADDLINK, + Router::findPage('do=other', array(), true) + ); + } + + /** + * Test findPage: export page output. + * Valid: page should be return. + * + * @return void + */ + public function testFindPageExportValid() + { + $this->assertEquals( + Router::$PAGE_EXPORT, + Router::findPage('do=export', array(), true) + ); + + $this->assertEquals( + Router::$PAGE_EXPORT, + Router::findPage('do=export&stuff', array(), true) + ); + } + + /** + * Test findPage: export page output. + * Invalid: page shouldn't be return. + * + * @return void + */ + public function testFindPageExportInvalid() + { + $this->assertNotEquals( + Router::$PAGE_EXPORT, + Router::findPage('do=export', array(), 1) + ); + + $this->assertNotEquals( + Router::$PAGE_EXPORT, + Router::findPage('do=export', array(), false) + ); + + $this->assertNotEquals( + Router::$PAGE_EXPORT, + Router::findPage('do=other', array(), true) + ); + } + + /** + * Test findPage: import page output. + * Valid: page should be return. + * + * @return void + */ + public function testFindPageImportValid() + { + $this->assertEquals( + Router::$PAGE_IMPORT, + Router::findPage('do=import', array(), true) + ); + + $this->assertEquals( + Router::$PAGE_IMPORT, + Router::findPage('do=import&stuff', array(), true) + ); + } + + /** + * Test findPage: import page output. + * Invalid: page shouldn't be return. + * + * @return void + */ + public function testFindPageImportInvalid() + { + $this->assertNotEquals( + Router::$PAGE_IMPORT, + Router::findPage('do=import', array(), 1) + ); + + $this->assertNotEquals( + Router::$PAGE_IMPORT, + Router::findPage('do=import', array(), false) + ); + + $this->assertNotEquals( + Router::$PAGE_IMPORT, + Router::findPage('do=other', array(), true) + ); + } + + /** + * Test findPage: editlink page output. + * Valid: page should be return. + * + * @return void + */ + public function testFindPageEditlinkValid() + { + $this->assertEquals( + Router::$PAGE_EDITLINK, + Router::findPage('whatever', array('edit_link' => 1), true) + ); + + $this->assertEquals( + Router::$PAGE_EDITLINK, + Router::findPage('', array('edit_link' => 1), true) + ); + + + $this->assertEquals( + Router::$PAGE_EDITLINK, + Router::findPage('whatever', array('post' => 1), true) + ); + + $this->assertEquals( + Router::$PAGE_EDITLINK, + Router::findPage('whatever', array('post' => 1, 'edit_link' => 1), true) + ); + } + + /** + * Test findPage: editlink page output. + * Invalid: page shouldn't be return. + * + * @return void + */ + public function testFindPageEditlinkInvalid() + { + $this->assertNotEquals( + Router::$PAGE_EDITLINK, + Router::findPage('whatever', array('edit_link' => 1), false) + ); + + $this->assertNotEquals( + Router::$PAGE_EDITLINK, + Router::findPage('whatever', array('edit_link' => 1), 1) + ); + + $this->assertNotEquals( + Router::$PAGE_EDITLINK, + Router::findPage('whatever', array(), true) + ); + } +} \ No newline at end of file diff --git a/tests/plugins/test/test.php b/tests/plugins/test/test.php new file mode 100755 index 00000000..3d750c90 --- /dev/null +++ b/tests/plugins/test/test.php @@ -0,0 +1,21 @@ + Date: Wed, 15 Jul 2015 12:08:52 +0200 Subject: [PATCH 02/19] Plugins TODO.md --- plugins/TODO.md | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 plugins/TODO.md diff --git a/plugins/TODO.md b/plugins/TODO.md new file mode 100644 index 00000000..e3313d67 --- /dev/null +++ b/plugins/TODO.md @@ -0,0 +1,28 @@ +https://github.com/shaarli/Shaarli/issues/181 - Add Disqus or Isso comments box on a permalink page + + * http://posativ.org/isso/ + * install debian package https://packages.debian.org/sid/isso + * configure server http://posativ.org/isso/docs/configuration/server/ + * configure client http://posativ.org/isso/docs/configuration/client/ + * http://posativ.org/isso/docs/quickstart/ and add `` to includes.html template; then add `
` in the linklist template where you want the comments (in the linklist_plugins loop for example) + + +Problem: by default, Isso thread ID is guessed from the current url (only one thread per page). +if we want multiple threads on a single page (shaarli linklist), we must use : the `data-isso-id` client config, +with data-isso-id being the permalink of an item. + +`
` +`data-isso-id: Set a custom thread id, defaults to current URI.` + +Problem: feature is currently broken https://github.com/posativ/isso/issues/27 + +Another option, only display isso threads when current URL is a permalink (`\?(A-Z|a-z|0-9|-){7}`) (only show thread +when displaying only this link), and just display a "comments" button on each linklist item. Optionally show the comment +count on each item using the API (http://posativ.org/isso/docs/extras/api/#get-comment-count). API requests can be done +by raintpl `{function` or client-side with js. The former should be faster if isso and shaarli are on ther same server. + +Showing all full isso threads in the linklist would destroy layout + +----------------------------------------------------------- + +http://www.git-attitude.fr/2014/11/04/git-rerere/ for the merge From 567967fdf94b2b8ba2b2fc9c8836e89ac23c8c71 Mon Sep 17 00:00:00 2001 From: ArthurHoaro Date: Wed, 15 Jul 2015 11:47:12 +0200 Subject: [PATCH 03/19] Template upgrade to handle plugin zones Add a bunch of plugin placeholders in templates --- COPYING | 14 +- application/PluginManager.php | 2 +- images/qrcode.png | Bin 321 -> 0 bytes inc/qr-1.1.3.js | 1215 --------------------------------- inc/qr-1.1.3.min.js | Bin 11365 -> 0 bytes inc/shaarli.css | 8 +- tpl/configure.html | 1 + tpl/daily.html | 59 +- tpl/editlink.html | 5 + tpl/includes.html | 3 + tpl/linklist.html | 90 +-- tpl/linklist.paging.html | 5 + tpl/page.footer.html | 7 + tpl/page.header.html | 5 +- tpl/picwall.html | 19 + tpl/tagcloud.html | 18 +- tpl/tools.html | 3 + 17 files changed, 147 insertions(+), 1307 deletions(-) delete mode 100644 images/qrcode.png delete mode 100644 inc/qr-1.1.3.js delete mode 100644 inc/qr-1.1.3.min.js diff --git a/COPYING b/COPYING index 24b97e94..1044a3b0 100644 --- a/COPYING +++ b/COPYING @@ -1,4 +1,4 @@ -Files: * +Files: * License: zlib/libpng Copyright: (c) 2011-2015 Sébastien SAUVAGE (c) 2011-2015 Alexandre Alapetite @@ -31,9 +31,9 @@ Copyright: (c) 2011-2015 Sébastien SAUVAGE Files: inc/reset.css License: BSD (http://opensource.org/licenses/BSD-3-Clause) -Copyright: (c) 2010, Yahoo! Inc. +Copyright: (c) 2010, Yahoo! Inc. -Files: images/calendar.png, images/edit_icon.png, images/feed-icon-14x14.png, images/private.png, images/private_16x16.png, images/private_16x16_active.png, images/qrcode.png, images/tag_blue.png +Files: images/calendar.png, images/edit_icon.png, images/feed-icon-14x14.png, images/private.png, images/private_16x16.png, images/private_16x16_active.png, images/tag_blue.png License: CC-BY (http://creativecommons.org/licenses/by/3.0/) Copyright: (c) 2014 Yusuke Kamiyamane Source: http://p.yusukekamiyamane.com/ @@ -59,10 +59,6 @@ Files: inc/blazy*.js License: MIT License (http://opensource.org/licenses/MIT) Copyright: (C) Bjoern Klinggaard - @bklinggaard - http://dinbror.dk/blazy -Files: inc/qr.js -License: GPLv3 License (http://opensource.org/licenses/gpl-3.0) -Copyright: (C) 2014 Alasdair Mercer, http://neocotic.com, https://github.com/neocotic/qr.js - Files: inc/rain.tpl.class.php Copyright: 2011-2012, Federico Ulfo 2011-2012, The Rain Team @@ -80,10 +76,10 @@ In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it +including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: - 1. The origin of this software must not be misrepresented; you must not + 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. diff --git a/application/PluginManager.php b/application/PluginManager.php index e572ff7c..803f11b4 100644 --- a/application/PluginManager.php +++ b/application/PluginManager.php @@ -99,7 +99,7 @@ public function load($authorizedPlugins) * @param string $hook name of the hook to trigger. * @param array $data list of data to manipulate passed by reference. * @param array $params additional parameters such as page target. - * + * * @return void */ public function executeHooks($hook, &$data, $params = array()) diff --git a/images/qrcode.png b/images/qrcode.png deleted file mode 100644 index c2cfa4765abf4f837d36536299b9b0715acfea4d..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 321 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`k|nMYCBgY=CFO}lsSJ)O`AMk? zp1FzXsX?iUDV2pMQ*D5X9(%ethE&{2`t$$4J+o>9tBZl5p(&GQuE|aTg}CNcUgq%s ze}9LcXDDJ+R(@=ykmhjc^@WTzSq@b*7c4vYf;Xc^O(#jCri7Vk!-tQn5*v$VG*)O& zGhphhd>nk3;~TrM@H&Tkj7x1dcrq~yzFTuQpy$jz-m52iRQf!flN04lQoai&D1Sa! zmB{ws5c@(2>Hi8I`Z@yrNgo%P3fxvcDcjm5>+08HAU?-s^G_8+lOm_2)=SSX{8$rU zD3ROe<{ZPovi;(mdTD;?bMAc2-VT3cye%4zs7!n^;bwND#f*uU-tY({F#J|Y=2x5Q RJs;>@22WQ%mvv4FO#u0=d4&J~ diff --git a/inc/qr-1.1.3.js b/inc/qr-1.1.3.js deleted file mode 100644 index 4f127e6e..00000000 --- a/inc/qr-1.1.3.js +++ /dev/null @@ -1,1215 +0,0 @@ -// [qr.js](http://neocotic.com/qr.js) -// (c) 2014 Alasdair Mercer -// Licensed under the GPL Version 3 license. -// Based on [jsqrencode](http://code.google.com/p/jsqrencode/) -// (c) 2010 tz@execpc.com -// Licensed under the GPL Version 3 license. -// For all details and documentation: -// - -(function (root) { - - 'use strict'; - - // Private constants - // ----------------- - - // Alignment pattern. - var ALIGNMENT_DELTA = [ - 0, 11, 15, 19, 23, 27, 31, - 16, 18, 20, 22, 24, 26, 28, 20, 22, 24, 24, 26, 28, 28, 22, 24, 24, - 26, 26, 28, 28, 24, 24, 26, 26, 26, 28, 28, 24, 26, 26, 26, 28, 28 - ]; - // Default MIME type. - var DEFAULT_MIME = 'image/png'; - // MIME used to initiate a browser download prompt when `qr.save` is called. - var DOWNLOAD_MIME = 'image/octet-stream'; - // There are four elements per version. The first two indicate the number of blocks, then the - // data width, and finally the ECC width. - var ECC_BLOCKS = [ - 1, 0, 19, 7, 1, 0, 16, 10, 1, 0, 13, 13, 1, 0, 9, 17, - 1, 0, 34, 10, 1, 0, 28, 16, 1, 0, 22, 22, 1, 0, 16, 28, - 1, 0, 55, 15, 1, 0, 44, 26, 2, 0, 17, 18, 2, 0, 13, 22, - 1, 0, 80, 20, 2, 0, 32, 18, 2, 0, 24, 26, 4, 0, 9, 16, - 1, 0, 108, 26, 2, 0, 43, 24, 2, 2, 15, 18, 2, 2, 11, 22, - 2, 0, 68, 18, 4, 0, 27, 16, 4, 0, 19, 24, 4, 0, 15, 28, - 2, 0, 78, 20, 4, 0, 31, 18, 2, 4, 14, 18, 4, 1, 13, 26, - 2, 0, 97, 24, 2, 2, 38, 22, 4, 2, 18, 22, 4, 2, 14, 26, - 2, 0, 116, 30, 3, 2, 36, 22, 4, 4, 16, 20, 4, 4, 12, 24, - 2, 2, 68, 18, 4, 1, 43, 26, 6, 2, 19, 24, 6, 2, 15, 28, - 4, 0, 81, 20, 1, 4, 50, 30, 4, 4, 22, 28, 3, 8, 12, 24, - 2, 2, 92, 24, 6, 2, 36, 22, 4, 6, 20, 26, 7, 4, 14, 28, - 4, 0, 107, 26, 8, 1, 37, 22, 8, 4, 20, 24, 12, 4, 11, 22, - 3, 1, 115, 30, 4, 5, 40, 24, 11, 5, 16, 20, 11, 5, 12, 24, - 5, 1, 87, 22, 5, 5, 41, 24, 5, 7, 24, 30, 11, 7, 12, 24, - 5, 1, 98, 24, 7, 3, 45, 28, 15, 2, 19, 24, 3, 13, 15, 30, - 1, 5, 107, 28, 10, 1, 46, 28, 1, 15, 22, 28, 2, 17, 14, 28, - 5, 1, 120, 30, 9, 4, 43, 26, 17, 1, 22, 28, 2, 19, 14, 28, - 3, 4, 113, 28, 3, 11, 44, 26, 17, 4, 21, 26, 9, 16, 13, 26, - 3, 5, 107, 28, 3, 13, 41, 26, 15, 5, 24, 30, 15, 10, 15, 28, - 4, 4, 116, 28, 17, 0, 42, 26, 17, 6, 22, 28, 19, 6, 16, 30, - 2, 7, 111, 28, 17, 0, 46, 28, 7, 16, 24, 30, 34, 0, 13, 24, - 4, 5, 121, 30, 4, 14, 47, 28, 11, 14, 24, 30, 16, 14, 15, 30, - 6, 4, 117, 30, 6, 14, 45, 28, 11, 16, 24, 30, 30, 2, 16, 30, - 8, 4, 106, 26, 8, 13, 47, 28, 7, 22, 24, 30, 22, 13, 15, 30, - 10, 2, 114, 28, 19, 4, 46, 28, 28, 6, 22, 28, 33, 4, 16, 30, - 8, 4, 122, 30, 22, 3, 45, 28, 8, 26, 23, 30, 12, 28, 15, 30, - 3, 10, 117, 30, 3, 23, 45, 28, 4, 31, 24, 30, 11, 31, 15, 30, - 7, 7, 116, 30, 21, 7, 45, 28, 1, 37, 23, 30, 19, 26, 15, 30, - 5, 10, 115, 30, 19, 10, 47, 28, 15, 25, 24, 30, 23, 25, 15, 30, - 13, 3, 115, 30, 2, 29, 46, 28, 42, 1, 24, 30, 23, 28, 15, 30, - 17, 0, 115, 30, 10, 23, 46, 28, 10, 35, 24, 30, 19, 35, 15, 30, - 17, 1, 115, 30, 14, 21, 46, 28, 29, 19, 24, 30, 11, 46, 15, 30, - 13, 6, 115, 30, 14, 23, 46, 28, 44, 7, 24, 30, 59, 1, 16, 30, - 12, 7, 121, 30, 12, 26, 47, 28, 39, 14, 24, 30, 22, 41, 15, 30, - 6, 14, 121, 30, 6, 34, 47, 28, 46, 10, 24, 30, 2, 64, 15, 30, - 17, 4, 122, 30, 29, 14, 46, 28, 49, 10, 24, 30, 24, 46, 15, 30, - 4, 18, 122, 30, 13, 32, 46, 28, 48, 14, 24, 30, 42, 32, 15, 30, - 20, 4, 117, 30, 40, 7, 47, 28, 43, 22, 24, 30, 10, 67, 15, 30, - 19, 6, 118, 30, 18, 31, 47, 28, 34, 34, 24, 30, 20, 61, 15, 30 - ]; - // Map of human-readable ECC levels. - var ECC_LEVELS = { - L: 1, - M: 2, - Q: 3, - H: 4 - }; - // Final format bits with mask (level << 3 | mask). - var FINAL_FORMAT = [ - 0x77c4, 0x72f3, 0x7daa, 0x789d, 0x662f, 0x6318, 0x6c41, 0x6976, /* L */ - 0x5412, 0x5125, 0x5e7c, 0x5b4b, 0x45f9, 0x40ce, 0x4f97, 0x4aa0, /* M */ - 0x355f, 0x3068, 0x3f31, 0x3a06, 0x24b4, 0x2183, 0x2eda, 0x2bed, /* Q */ - 0x1689, 0x13be, 0x1ce7, 0x19d0, 0x0762, 0x0255, 0x0d0c, 0x083b /* H */ - ]; - // Galois field exponent table. - var GALOIS_EXPONENT = [ - 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1d, 0x3a, 0x74, 0xe8, 0xcd, 0x87, 0x13, 0x26, - 0x4c, 0x98, 0x2d, 0x5a, 0xb4, 0x75, 0xea, 0xc9, 0x8f, 0x03, 0x06, 0x0c, 0x18, 0x30, 0x60, 0xc0, - 0x9d, 0x27, 0x4e, 0x9c, 0x25, 0x4a, 0x94, 0x35, 0x6a, 0xd4, 0xb5, 0x77, 0xee, 0xc1, 0x9f, 0x23, - 0x46, 0x8c, 0x05, 0x0a, 0x14, 0x28, 0x50, 0xa0, 0x5d, 0xba, 0x69, 0xd2, 0xb9, 0x6f, 0xde, 0xa1, - 0x5f, 0xbe, 0x61, 0xc2, 0x99, 0x2f, 0x5e, 0xbc, 0x65, 0xca, 0x89, 0x0f, 0x1e, 0x3c, 0x78, 0xf0, - 0xfd, 0xe7, 0xd3, 0xbb, 0x6b, 0xd6, 0xb1, 0x7f, 0xfe, 0xe1, 0xdf, 0xa3, 0x5b, 0xb6, 0x71, 0xe2, - 0xd9, 0xaf, 0x43, 0x86, 0x11, 0x22, 0x44, 0x88, 0x0d, 0x1a, 0x34, 0x68, 0xd0, 0xbd, 0x67, 0xce, - 0x81, 0x1f, 0x3e, 0x7c, 0xf8, 0xed, 0xc7, 0x93, 0x3b, 0x76, 0xec, 0xc5, 0x97, 0x33, 0x66, 0xcc, - 0x85, 0x17, 0x2e, 0x5c, 0xb8, 0x6d, 0xda, 0xa9, 0x4f, 0x9e, 0x21, 0x42, 0x84, 0x15, 0x2a, 0x54, - 0xa8, 0x4d, 0x9a, 0x29, 0x52, 0xa4, 0x55, 0xaa, 0x49, 0x92, 0x39, 0x72, 0xe4, 0xd5, 0xb7, 0x73, - 0xe6, 0xd1, 0xbf, 0x63, 0xc6, 0x91, 0x3f, 0x7e, 0xfc, 0xe5, 0xd7, 0xb3, 0x7b, 0xf6, 0xf1, 0xff, - 0xe3, 0xdb, 0xab, 0x4b, 0x96, 0x31, 0x62, 0xc4, 0x95, 0x37, 0x6e, 0xdc, 0xa5, 0x57, 0xae, 0x41, - 0x82, 0x19, 0x32, 0x64, 0xc8, 0x8d, 0x07, 0x0e, 0x1c, 0x38, 0x70, 0xe0, 0xdd, 0xa7, 0x53, 0xa6, - 0x51, 0xa2, 0x59, 0xb2, 0x79, 0xf2, 0xf9, 0xef, 0xc3, 0x9b, 0x2b, 0x56, 0xac, 0x45, 0x8a, 0x09, - 0x12, 0x24, 0x48, 0x90, 0x3d, 0x7a, 0xf4, 0xf5, 0xf7, 0xf3, 0xfb, 0xeb, 0xcb, 0x8b, 0x0b, 0x16, - 0x2c, 0x58, 0xb0, 0x7d, 0xfa, 0xe9, 0xcf, 0x83, 0x1b, 0x36, 0x6c, 0xd8, 0xad, 0x47, 0x8e, 0x00 - ]; - // Galois field log table. - var GALOIS_LOG = [ - 0xff, 0x00, 0x01, 0x19, 0x02, 0x32, 0x1a, 0xc6, 0x03, 0xdf, 0x33, 0xee, 0x1b, 0x68, 0xc7, 0x4b, - 0x04, 0x64, 0xe0, 0x0e, 0x34, 0x8d, 0xef, 0x81, 0x1c, 0xc1, 0x69, 0xf8, 0xc8, 0x08, 0x4c, 0x71, - 0x05, 0x8a, 0x65, 0x2f, 0xe1, 0x24, 0x0f, 0x21, 0x35, 0x93, 0x8e, 0xda, 0xf0, 0x12, 0x82, 0x45, - 0x1d, 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 0x51, 0x0b, 0xf5, 0x16, 0xeb, 0x7a, 0x75, 0x2c, 0xd7, - 0x4f, 0xae, 0xd5, 0xe9, 0xe6, 0xe7, 0xad, 0xe8, 0x74, 0xd6, 0xf4, 0xea, 0xa8, 0x50, 0x58, 0xaf - ]; - // *Badness* coefficients. - var N1 = 3; - var N2 = 3; - var N3 = 40; - var N4 = 10; - // Version pattern. - var VERSION_BLOCK = [ - 0xc94, 0x5bc, 0xa99, 0x4d3, 0xbf6, 0x762, 0x847, 0x60d, 0x928, 0xb78, 0x45d, 0xa17, 0x532, - 0x9a6, 0x683, 0x8c9, 0x7ec, 0xec4, 0x1e1, 0xfab, 0x08e, 0xc1a, 0x33f, 0xd75, 0x250, 0x9d5, - 0x6f0, 0x8ba, 0x79f, 0xb0b, 0x42e, 0xa64, 0x541, 0xc69 - ]; - // Mode for node.js file system file writes. - var WRITE_MODE = parseInt('0666', 8); - - // Private variables - // ----------------- - - // Run lengths for badness. - var badBuffer = []; - // Constructor for `canvas` elements in the node.js environment. - var Canvas; - // Data block. - var dataBlock; - // ECC data blocks and tables. - var eccBlock, neccBlock1, neccBlock2; - // ECC buffer. - var eccBuffer = []; - // ECC level (defaults to **L**). - var eccLevel = 1; - // Image buffer. - var frameBuffer = []; - // Fixed part of the image. - var frameMask = []; - // File system within the node.js environment. - var fs; - // Constructor for `img` elements in the node.js environment. - var Image; - // Indicates whether or not this script is running in node.js. - var inNode = false; - // Generator polynomial. - var polynomial = []; - // Save the previous value of the `qr` variable. - var previousQr = root.qr; - // Data input buffer. - var stringBuffer = []; - // Version for the data. - var version; - // Data width is based on `version`. - var width; - - // Private functions - // ----------------- - - // Create a new canvas using `document.createElement` unless script is running in node.js, in - // which case the `canvas` module is used. - function createCanvas() { - return inNode ? new Canvas() : root.document.createElement('canvas'); - } - - // Create a new image using `document.createElement` unless script is running in node.js, in - // which case the `canvas` module is used. - function createImage() { - return inNode ? new Image() : root.document.createElement('img'); - } - - // Force the canvas image to be downloaded in the browser. - // Optionally, a `callback` function can be specified which will be called upon completed. Since - // this is not an asynchronous operation, this is merely convenient and helps simplify the - // calling code. - function download(cvs, data, callback) { - var mime = data.mime || DEFAULT_MIME; - - root.location.href = cvs.toDataURL(mime).replace(mime, DOWNLOAD_MIME); - - if (typeof callback === 'function') callback(); - } - - // Normalize the `data` that is provided to the main API. - function normalizeData(data) { - if (typeof data === 'string') data = { value: data }; - return data || {}; - } - - // Override the `qr` API methods that require HTML5 canvas support to throw a relevant error. - function overrideAPI(qr) { - var methods = [ 'canvas', 'image', 'save', 'saveSync', 'toDataURL' ]; - var i; - - function overrideMethod(name) { - qr[name] = function () { - throw new Error(name + ' requires HTML5 canvas element support'); - }; - } - - for (i = 0; i < methods.length; i++) { - overrideMethod(methods[i]); - } - } - - // Asynchronously write the data of the rendered canvas to a given file path. - function writeFile(cvs, data, callback) { - if (typeof data.path !== 'string') { - return callback(new TypeError('Invalid path type: ' + typeof data.path)); - } - - var fd, buff; - - // Write the buffer to the open file stream once both prerequisites are met. - function writeBuffer() { - fs.write(fd, buff, 0, buff.length, 0, function (error) { - fs.close(fd); - - callback(error); - }); - } - - // Create a buffer of the canvas' data. - cvs.toBuffer(function (error, _buff) { - if (error) return callback(error); - - buff = _buff; - if (fd) { - writeBuffer(); - } - }); - - // Open a stream for the file to be written. - fs.open(data.path, 'w', WRITE_MODE, function (error, _fd) { - if (error) return callback(error); - - fd = _fd; - if (buff) { - writeBuffer(); - } - }); - } - - // Write the data of the rendered canvas to a given file path. - function writeFileSync(cvs, data) { - if (typeof data.path !== 'string') { - throw new TypeError('Invalid path type: ' + typeof data.path); - } - - var buff = cvs.toBuffer(); - var fd = fs.openSync(data.path, 'w', WRITE_MODE); - - try { - fs.writeSync(fd, buff, 0, buff.length, 0); - } finally { - fs.closeSync(fd); - } - } - - // Set bit to indicate cell in frame is immutable (symmetric around diagonal). - function setMask(x, y) { - var bit; - - if (x > y) { - bit = x; - x = y; - y = bit; - } - - bit = y; - bit *= y; - bit += y; - bit >>= 1; - bit += x; - - frameMask[bit] = 1; - } - - // Enter alignment pattern. Foreground colour to frame, background to mask. Frame will be merged - // with mask later. - function addAlignment(x, y) { - var i; - - frameBuffer[x + width * y] = 1; - - for (i = -2; i < 2; i++) { - frameBuffer[(x + i) + width * (y - 2)] = 1; - frameBuffer[(x - 2) + width * (y + i + 1)] = 1; - frameBuffer[(x + 2) + width * (y + i)] = 1; - frameBuffer[(x + i + 1) + width * (y + 2)] = 1; - } - - for (i = 0; i < 2; i++) { - setMask(x - 1, y + i); - setMask(x + 1, y - i); - setMask(x - i, y - 1); - setMask(x + i, y + 1); - } - } - - // Exponentiation mod N. - function modN(x) { - while (x >= 255) { - x -= 255; - x = (x >> 8) + (x & 255); - } - - return x; - } - - // Calculate and append `ecc` data to the `data` block. If block is in the string buffer the - // indices to buffers are used. - function appendData(data, dataLength, ecc, eccLength) { - var bit, i, j; - - for (i = 0; i < eccLength; i++) { - stringBuffer[ecc + i] = 0; - } - - for (i = 0; i < dataLength; i++) { - bit = GALOIS_LOG[stringBuffer[data + i] ^ stringBuffer[ecc]]; - - if (bit !== 255) { - for (j = 1; j < eccLength; j++) { - stringBuffer[ecc + j - 1] = stringBuffer[ecc + j] ^ - GALOIS_EXPONENT[modN(bit + polynomial[eccLength - j])]; - } - } else { - for (j = ecc; j < ecc + eccLength; j++) { - stringBuffer[j] = stringBuffer[j + 1]; - } - } - - stringBuffer[ecc + eccLength - 1] = bit === 255 ? 0 : - GALOIS_EXPONENT[modN(bit + polynomial[0])]; - } - } - - // Check mask since symmetricals use half. - function isMasked(x, y) { - var bit; - - if (x > y) { - bit = x; - x = y; - y = bit; - } - - bit = y; - bit += y * y; - bit >>= 1; - bit += x; - - return frameMask[bit] === 1; - } - - // Apply the selected mask out of the 8 options. - function applyMask(mask) { - var x, y, r3x, r3y; - - switch (mask) { - case 0: - for (y = 0; y < width; y++) { - for (x = 0; x < width; x++) { - if (!((x + y) & 1) && !isMasked(x, y)) { - frameBuffer[x + y * width] ^= 1; - } - } - } - - break; - case 1: - for (y = 0; y < width; y++) { - for (x = 0; x < width; x++) { - if (!(y & 1) && !isMasked(x, y)) { - frameBuffer[x + y * width] ^= 1; - } - } - } - - break; - case 2: - for (y = 0; y < width; y++) { - for (r3x = 0, x = 0; x < width; x++, r3x++) { - if (r3x === 3) r3x = 0; - - if (!r3x && !isMasked(x, y)) { - frameBuffer[x + y * width] ^= 1; - } - } - } - - break; - case 3: - for (r3y = 0, y = 0; y < width; y++, r3y++) { - if (r3y === 3) r3y = 0; - - for (r3x = r3y, x = 0; x < width; x++, r3x++) { - if (r3x === 3) r3x = 0; - - if (!r3x && !isMasked(x, y)) { - frameBuffer[x + y * width] ^= 1; - } - } - } - - break; - case 4: - for (y = 0; y < width; y++) { - for (r3x = 0, r3y = ((y >> 1) & 1), x = 0; x < width; x++, r3x++) { - if (r3x === 3) { - r3x = 0; - r3y = !r3y; - } - - if (!r3y && !isMasked(x, y)) { - frameBuffer[x + y * width] ^= 1; - } - } - } - - break; - case 5: - for (r3y = 0, y = 0; y < width; y++, r3y++) { - if (r3y === 3) r3y = 0; - - for (r3x = 0, x = 0; x < width; x++, r3x++) { - if (r3x === 3) r3x = 0; - - if (!((x & y & 1) + !(!r3x | !r3y)) && !isMasked(x, y)) { - frameBuffer[x + y * width] ^= 1; - } - } - } - - break; - case 6: - for (r3y = 0, y = 0; y < width; y++, r3y++) { - if (r3y === 3) r3y = 0; - - for (r3x = 0, x = 0; x < width; x++, r3x++) { - if (r3x === 3) r3x = 0; - - if (!(((x & y & 1) + (r3x && (r3x === r3y))) & 1) && !isMasked(x, y)) { - frameBuffer[x + y * width] ^= 1; - } - } - } - - break; - case 7: - for (r3y = 0, y = 0; y < width; y++, r3y++) { - if (r3y === 3) r3y = 0; - - for (r3x = 0, x = 0; x < width; x++, r3x++) { - if (r3x === 3) r3x = 0; - - if (!(((r3x && (r3x === r3y)) + ((x + y) & 1)) & 1) && !isMasked(x, y)) { - frameBuffer[x + y * width] ^= 1; - } - } - } - - break; - } - } - - // Using the table for the length of each run, calculate the amount of bad image. Long runs or - // those that look like finders are called twice; once for X and Y. - function getBadRuns(length) { - var badRuns = 0; - var i; - - for (i = 0; i <= length; i++) { - if (badBuffer[i] >= 5) { - badRuns += N1 + badBuffer[i] - 5; - } - } - - // FBFFFBF as in finder. - for (i = 3; i < length - 1; i += 2) { - if (badBuffer[i - 2] === badBuffer[i + 2] && - badBuffer[i + 2] === badBuffer[i - 1] && - badBuffer[i - 1] === badBuffer[i + 1] && - badBuffer[i - 1] * 3 === badBuffer[i] && - // Background around the foreground pattern? Not part of the specs. - (badBuffer[i - 3] === 0 || i + 3 > length || - badBuffer[i - 3] * 3 >= badBuffer[i] * 4 || - badBuffer[i + 3] * 3 >= badBuffer[i] * 4)) { - badRuns += N3; - } - } - - return badRuns; - } - - // Calculate how bad the masked image is (e.g. blocks, imbalance, runs, or finders). - function checkBadness() { - var b, b1, bad, big, bw, count, h, x, y; - bad = bw = count = 0; - - // Blocks of same colour. - for (y = 0; y < width - 1; y++) { - for (x = 0; x < width - 1; x++) { - // All foreground colour. - if ((frameBuffer[x + width * y] && - frameBuffer[(x + 1) + width * y] && - frameBuffer[x + width * (y + 1)] && - frameBuffer[(x + 1) + width * (y + 1)]) || - // All background colour. - !(frameBuffer[x + width * y] || - frameBuffer[(x + 1) + width * y] || - frameBuffer[x + width * (y + 1)] || - frameBuffer[(x + 1) + width * (y + 1)])) { - bad += N2; - } - } - } - - // X runs. - for (y = 0; y < width; y++) { - badBuffer[0] = 0; - - for (h = b = x = 0; x < width; x++) { - if ((b1 = frameBuffer[x + width * y]) === b) { - badBuffer[h]++; - } else { - badBuffer[++h] = 1; - } - - b = b1; - bw += b ? 1 : -1; - } - - bad += getBadRuns(h); - } - - if (bw < 0) bw = -bw; - - big = bw; - big += big << 2; - big <<= 1; - - while (big > width * width) { - big -= width * width; - count++; - } - - bad += count * N4; - - // Y runs. - for (x = 0; x < width; x++) { - badBuffer[0] = 0; - - for (h = b = y = 0; y < width; y++) { - if ((b1 = frameBuffer[x + width * y]) === b) { - badBuffer[h]++; - } else { - badBuffer[++h] = 1; - } - - b = b1; - } - - bad += getBadRuns(h); - } - - return bad; - } - - // Generate the encoded QR image for the string provided. - function generateFrame(str) { - var i, j, k, m, t, v, x, y; - - // Find the smallest version that fits the string. - t = str.length; - - version = 0; - - do { - version++; - - k = (eccLevel - 1) * 4 + (version - 1) * 16; - - neccBlock1 = ECC_BLOCKS[k++]; - neccBlock2 = ECC_BLOCKS[k++]; - dataBlock = ECC_BLOCKS[k++]; - eccBlock = ECC_BLOCKS[k]; - - k = dataBlock * (neccBlock1 + neccBlock2) + neccBlock2 - 3 + (version <= 9); - - if (t <= k) break; - } while (version < 40); - - // FIXME: Ensure that it fits insted of being truncated. - width = 17 + 4 * version; - - // Allocate, clear and setup data structures. - v = dataBlock + (dataBlock + eccBlock) * (neccBlock1 + neccBlock2) + neccBlock2; - - for (t = 0; t < v; t++) { - eccBuffer[t] = 0; - } - - stringBuffer = str.slice(0); - - for (t = 0; t < width * width; t++) { - frameBuffer[t] = 0; - } - - for (t = 0; t < (width * (width + 1) + 1) / 2; t++) { - frameMask[t] = 0; - } - - // Insert finders: Foreground colour to frame and background to mask. - for (t = 0; t < 3; t++) { - k = y = 0; - - if (t === 1) k = (width - 7); - if (t === 2) y = (width - 7); - - frameBuffer[(y + 3) + width * (k + 3)] = 1; - - for (x = 0; x < 6; x++) { - frameBuffer[(y + x) + width * k] = 1; - frameBuffer[y + width * (k + x + 1)] = 1; - frameBuffer[(y + 6) + width * (k + x)] = 1; - frameBuffer[(y + x + 1) + width * (k + 6)] = 1; - } - - for (x = 1; x < 5; x++) { - setMask(y + x, k + 1); - setMask(y + 1, k + x + 1); - setMask(y + 5, k + x); - setMask(y + x + 1, k + 5); - } - - for (x = 2; x < 4; x++) { - frameBuffer[(y + x) + width * (k + 2)] = 1; - frameBuffer[(y + 2) + width * (k + x + 1)] = 1; - frameBuffer[(y + 4) + width * (k + x)] = 1; - frameBuffer[(y + x + 1) + width * (k + 4)] = 1; - } - } - - // Alignment blocks. - if (version > 1) { - t = ALIGNMENT_DELTA[version]; - y = width - 7; - - for (;;) { - x = width - 7; - - while (x > t - 3) { - addAlignment(x, y); - - if (x < t) break; - - x -= t; - } - - if (y <= t + 9) break; - - y -= t; - - addAlignment(6, y); - addAlignment(y, 6); - } - } - - // Single foreground cell. - frameBuffer[8 + width * (width - 8)] = 1; - - // Timing gap (mask only). - for (y = 0; y < 7; y++) { - setMask(7, y); - setMask(width - 8, y); - setMask(7, y + width - 7); - } - - for (x = 0; x < 8; x++) { - setMask(x, 7); - setMask(x + width - 8, 7); - setMask(x, width - 8); - } - - // Reserve mask, format area. - for (x = 0; x < 9; x++) { - setMask(x, 8); - } - - for (x = 0; x < 8; x++) { - setMask(x + width - 8, 8); - setMask(8, x); - } - - for (y = 0; y < 7; y++) { - setMask(8, y + width - 7); - } - - // Timing row/column. - for (x = 0; x < width - 14; x++) { - if (x & 1) { - setMask(8 + x, 6); - setMask(6, 8 + x); - } else { - frameBuffer[(8 + x) + width * 6] = 1; - frameBuffer[6 + width * (8 + x)] = 1; - } - } - - // Version block. - if (version > 6) { - t = VERSION_BLOCK[version - 7]; - k = 17; - - for (x = 0; x < 6; x++) { - for (y = 0; y < 3; y++, k--) { - if (1 & (k > 11 ? version >> (k - 12) : t >> k)) { - frameBuffer[(5 - x) + width * (2 - y + width - 11)] = 1; - frameBuffer[(2 - y + width - 11) + width * (5 - x)] = 1; - } else { - setMask(5 - x, 2 - y + width - 11); - setMask(2 - y + width - 11, 5 - x); - } - } - } - } - - // Sync mask bits. Only set above for background cells, so now add the foreground. - for (y = 0; y < width; y++) { - for (x = 0; x <= y; x++) { - if (frameBuffer[x + width * y]) { - setMask(x, y); - } - } - } - - // Convert string to bit stream. 8-bit data to QR-coded 8-bit data (numeric, alphanum, or kanji - // not supported). - v = stringBuffer.length; - - // String to array. - for (i = 0; i < v; i++) { - eccBuffer[i] = stringBuffer.charCodeAt(i); - } - - stringBuffer = eccBuffer.slice(0); - - // Calculate max string length. - x = dataBlock * (neccBlock1 + neccBlock2) + neccBlock2; - - if (v >= x - 2) { - v = x - 2; - - if (version > 9) v--; - } - - // Shift and re-pack to insert length prefix. - i = v; - - if (version > 9) { - stringBuffer[i + 2] = 0; - stringBuffer[i + 3] = 0; - - while (i--) { - t = stringBuffer[i]; - - stringBuffer[i + 3] |= 255 & (t << 4); - stringBuffer[i + 2] = t >> 4; - } - - stringBuffer[2] |= 255 & (v << 4); - stringBuffer[1] = v >> 4; - stringBuffer[0] = 0x40 | (v >> 12); - } else { - stringBuffer[i + 1] = 0; - stringBuffer[i + 2] = 0; - - while (i--) { - t = stringBuffer[i]; - - stringBuffer[i + 2] |= 255 & (t << 4); - stringBuffer[i + 1] = t >> 4; - } - - stringBuffer[1] |= 255 & (v << 4); - stringBuffer[0] = 0x40 | (v >> 4); - } - - // Fill to end with pad pattern. - i = v + 3 - (version < 10); - - while (i < x) { - stringBuffer[i++] = 0xec; - stringBuffer[i++] = 0x11; - } - - // Calculate generator polynomial. - polynomial[0] = 1; - - for (i = 0; i < eccBlock; i++) { - polynomial[i + 1] = 1; - - for (j = i; j > 0; j--) { - polynomial[j] = polynomial[j] ? polynomial[j - 1] ^ - GALOIS_EXPONENT[modN(GALOIS_LOG[polynomial[j]] + i)] : polynomial[j - 1]; - } - - polynomial[0] = GALOIS_EXPONENT[modN(GALOIS_LOG[polynomial[0]] + i)]; - } - - // Use logs for generator polynomial to save calculation step. - for (i = 0; i <= eccBlock; i++) { - polynomial[i] = GALOIS_LOG[polynomial[i]]; - } - - // Append ECC to data buffer. - k = x; - y = 0; - - for (i = 0; i < neccBlock1; i++) { - appendData(y, dataBlock, k, eccBlock); - - y += dataBlock; - k += eccBlock; - } - - for (i = 0; i < neccBlock2; i++) { - appendData(y, dataBlock + 1, k, eccBlock); - - y += dataBlock + 1; - k += eccBlock; - } - - // Interleave blocks. - y = 0; - - for (i = 0; i < dataBlock; i++) { - for (j = 0; j < neccBlock1; j++) { - eccBuffer[y++] = stringBuffer[i + j * dataBlock]; - } - - for (j = 0; j < neccBlock2; j++) { - eccBuffer[y++] = stringBuffer[(neccBlock1 * dataBlock) + i + (j * (dataBlock + 1))]; - } - } - - for (j = 0; j < neccBlock2; j++) { - eccBuffer[y++] = stringBuffer[(neccBlock1 * dataBlock) + i + (j * (dataBlock + 1))]; - } - - for (i = 0; i < eccBlock; i++) { - for (j = 0; j < neccBlock1 + neccBlock2; j++) { - eccBuffer[y++] = stringBuffer[x + i + j * eccBlock]; - } - } - - stringBuffer = eccBuffer; - - // Pack bits into frame avoiding masked area. - x = y = width - 1; - k = v = 1; - - // inteleaved data and ECC codes. - m = (dataBlock + eccBlock) * (neccBlock1 + neccBlock2) + neccBlock2; - - for (i = 0; i < m; i++) { - t = stringBuffer[i]; - - for (j = 0; j < 8; j++, t <<= 1) { - if (0x80 & t) { - frameBuffer[x + width * y] = 1; - } - - // Find next fill position. - do { - if (v) { - x--; - } else { - x++; - - if (k) { - if (y !== 0) { - y--; - } else { - x -= 2; - k = !k; - - if (x === 6) { - x--; - y = 9; - } - } - } else { - if (y !== width - 1) { - y++; - } else { - x -= 2; - k = !k; - - if (x === 6) { - x--; - y -= 8; - } - } - } - } - - v = !v; - } while (isMasked(x, y)); - } - } - - // Save pre-mask copy of frame. - stringBuffer = frameBuffer.slice(0); - - t = 0; - y = 30000; - - // Using `for` instead of `while` since in original Arduino code if an early mask was *good - // enough* it wouldn't try for a better one since they get more complex and take longer. - for (k = 0; k < 8; k++) { - // Returns foreground-background imbalance. - applyMask(k); - - x = checkBadness(); - - // Is current mask better than previous best? - if (x < y) { - y = x; - t = k; - } - - // Don't increment `i` to a void redoing mask. - if (t === 7) break; - - // Reset for next pass. - frameBuffer = stringBuffer.slice(0); - } - - // Redo best mask as none were *good enough* (i.e. last wasn't `t`). - if (t !== k) { - applyMask(t); - } - - // Add in final mask/ECC level bytes. - y = FINAL_FORMAT[t + ((eccLevel - 1) << 3)]; - - // Low byte. - for (k = 0; k < 8; k++, y >>= 1) { - if (y & 1) { - frameBuffer[(width - 1 - k) + width * 8] = 1; - - if (k < 6) { - frameBuffer[8 + width * k] = 1; - } else { - frameBuffer[8 + width * (k + 1)] = 1; - } - } - } - - // High byte. - for (k = 0; k < 7; k++, y >>= 1) { - if (y & 1) { - frameBuffer[8 + width * (width - 7 + k)] = 1; - - if (k) { - frameBuffer[(6 - k) + width * 8] = 1; - } else { - frameBuffer[7 + width * 8] = 1; - } - } - } - - // Finally, return the image data. - return frameBuffer; - } - - // qr.js setup - // ----------- - - // Build the publicly exposed API. - var qr = { - - // Constants - // --------- - - // Current version of `qr`. - VERSION: '1.1.3', - - // QR functions - // ------------ - - // Generate the QR code using the data provided and render it on to a `` element. - // If no `` element is specified in the argument provided a new one will be created and - // used. - // ECC (error correction capacity) determines how many intential errors are contained in the QR - // code. - canvas: function(data) { - data = normalizeData(data); - - // Module size of the generated QR code (i.e. 1-10). - var size = data.size >= 1 && data.size <= 10 ? data.size : 4; - // Actual size of the QR code symbol and is scaled to 25 pixels (e.g. 1 = 25px, 3 = 75px). - size *= 25; - - // `` element used to render the QR code. - var cvs = data.canvas || createCanvas(); - // Retreive the 2D context of the canvas. - var c2d = cvs.getContext('2d'); - // Ensure the canvas has the correct dimensions. - c2d.canvas.width = size; - c2d.canvas.height = size; - // Fill the canvas with the correct background colour. - c2d.fillStyle = data.background || '#fff'; - c2d.fillRect(0, 0, size, size); - - // Determine the ECC level to be applied. - eccLevel = ECC_LEVELS[(data.level && data.level.toUpperCase()) || 'L']; - - // Generate the image frame for the given `value`. - var frame = generateFrame(data.value || ''); - - c2d.lineWidth = 1; - - // Determine the *pixel* size. - var px = size; - px /= width; - px = Math.floor(px); - - // Draw the QR code. - c2d.clearRect(0, 0, size, size); - c2d.fillStyle = data.background || '#fff'; - c2d.fillRect(0, 0, px * (width + 8), px * (width + 8)); - c2d.fillStyle = data.foreground || '#000'; - - var i, j; - - for (i = 0; i < width; i++) { - for (j = 0; j < width; j++) { - if (frame[j * width + i]) { - c2d.fillRect(px * i, px * j, px, px); - } - } - } - - return cvs; - }, - - // Generate the QR code using the data provided and render it on to a `` element. - // If no `` element is specified in the argument provided a new one will be created and - // used. - // ECC (error correction capacity) determines how many intential errors are contained in the QR - // code. - image: function(data) { - data = normalizeData(data); - - // `` element only which the QR code is rendered. - var cvs = this.canvas(data); - // `` element used to display the QR code. - var img = data.image || createImage(); - - // Apply the QR code to `img`. - img.src = cvs.toDataURL(data.mime || DEFAULT_MIME); - img.height = cvs.height; - img.width = cvs.width; - - return img; - }, - - // Generate the QR code using the data provided and render it on to a `` element and - // save it as an image file. - // If no `` element is specified in the argument provided a new one will be created and - // used. - // ECC (error correction capacity) determines how many intential errors are contained in the QR - // code. - // If called in a browser the `path` property/argument is ignored and will simply prompt the - // user to choose a location and file name. However, if called within node.js the file will be - // saved to specified path. - // A `callback` function must be provided which will be called once the saving process has - // started. If an error occurs it will be passed as the first argument to this function, - // otherwise this argument will be `null`. - save: function(data, path, callback) { - data = normalizeData(data); - - switch (typeof path) { - case 'function': - callback = path; - path = null; - break; - case 'string': - data.path = path; - break; - } - - // Callback function is required. - if (typeof callback !== 'function') { - throw new TypeError('Invalid callback type: ' + typeof callback); - } - - var completed = false; - // `` element only which the QR code is rendered. - var cvs = this.canvas(data); - - // Simple function to try and ensure that the `callback` function is only called once. - function done(error) { - if (!completed) { - completed = true; - - callback(error); - } - } - - if (inNode) { - writeFile(cvs, data, done); - } else { - download(cvs, data, done); - } - }, - - // Generate the QR code using the data provided and render it on to a `` element and - // save it as an image file. - // If no `` element is specified in the argument provided a new one will be created and - // used. - // ECC (error correction capacity) determines how many intential errors are contained in the QR - // code. - // If called in a browser the `path` property/argument is ignored and will simply prompt the - // user to choose a location and file name. However, if called within node.js the file will be - // saved to specified path. - saveSync: function(data, path) { - data = normalizeData(data); - - if (typeof path === 'string') data.path = path; - - // `` element only which the QR code is rendered. - var cvs = this.canvas(data); - - if (inNode) { - writeFileSync(cvs, data); - } else { - download(cvs, data); - } - }, - - // Generate the QR code using the data provided and render it on to a `` element before - // returning its data URI. - // If no `` element is specified in the argument provided a new one will be created and - // used. - // ECC (error correction capacity) determines how many intential errors are contained in the QR - // code. - toDataURL: function(data) { - data = normalizeData(data); - - return this.canvas(data).toDataURL(data.mime || DEFAULT_MIME); - }, - - // Utility functions - // ----------------- - - // Run qr.js in *noConflict* mode, returning the `qr` variable to its previous owner. - // Returns a reference to `qr`. - noConflict: function() { - root.qr = previousQr; - return this; - } - - }; - - // Support - // ------- - - // Export `qr` for node.js and CommonJS. - if (typeof exports !== 'undefined') { - inNode = true; - - if (typeof module !== 'undefined' && module.exports) { - exports = module.exports = qr; - } - exports.qr = qr; - - // Import required node.js modules. - Canvas = require('canvas'); - Image = Canvas.Image; - fs = require('fs'); - } else if (typeof define === 'function' && define.amd) { - define(function () { - return qr; - }); - } else { - // In non-HTML5 browser so strip base functionality. - if (!root.HTMLCanvasElement) { - overrideAPI(qr); - } - - root.qr = qr; - } - -})(this); diff --git a/inc/qr-1.1.3.min.js b/inc/qr-1.1.3.min.js deleted file mode 100644 index 19d704e18dcff3859d2bcf3bf7c54ad7cd6215e5..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 11365 zcmcJVdvh8`y2k&{r$B6#YDUvwW`?Wqpp!V+#JhIv*m0aHid4ZcTofc^K$3O)?)!VX zX8<{NlC5)2#SuN-Z@-u4y){EWIXWnPSXEBfrK_+SR^!rr$xHoGR152+uNTAhcsO5` zUS_K_Te0;0>ldY~xb$M4X6NhdtJC#|Rd${($JuUMt+cuQpX_6nUZmA@dG^OmM^C;w zm|UKxoB8tG8~S(U%XL;-Z&vekQ|=ZErIF{~t+LJK>b&&x$$55NS{)Co<7IkzmYr{^ z=_(s;vhNm|p1g88Jii*Q%l^Z5d;012kAJd#em33TJN8BXD!W(=)6C1vGvAa8Rmw@Sxw*)elhXL` zaO~~rn8|u)V_Ei}Pj|G#!$WVFpuyrYJ03pxW_W*p_pq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@ -2,18 +2,43 @@ {include="includes"} - +
-
- All links of one day
in a single page.
- {if="$previousday"} <Previous day{else}<Previous day{/if} - - - {if="$nextday"}Next day>{else}Next day>{/if} -

- rss_feedDaily RSS Feed +
+ {loop="$plugin_start_zone"} + {$value} + {/loop}
-
floral_left The Daily Shaarli floral_right
-
——————————— {function="strftime('%A %d, %B %Y', $day)"} ———————————
+ +
+ All links of one day
in a single page.
+ {if="$previousday"} <Previous day{else}<Previous day{/if} + - + {if="$nextday"}Next day>{else}Next day>{/if} +
+ + {loop="$daily_about_plugin"} + {$value} + {/loop} + +
+ rss_feedDaily RSS Feed +
+ +
+ floral_left + The Daily Shaarli + floral_right +
+ +
+ ——————————— + {function="strftime('%A %d, %B %Y', $day)"} + ——————————— +
+
{if="$linksToDisplay"} @@ -47,6 +72,12 @@
{$link.thumbnail}
{/if}
{$link.formatedDescription}
+ +
+ {loop="$link.link_plugin"} + {$value} + {/loop} +
{/loop}
@@ -55,6 +86,14 @@ {else}
No articles on this day.
{/if} + +
+ +
+ {loop="$plugin_end_zone"} + {$value} + {/loop} +
-
{include="page.footer"} diff --git a/tpl/editlink.html b/tpl/editlink.html index 3733ca21..889d913d 100644 --- a/tpl/editlink.html +++ b/tpl/editlink.html @@ -21,6 +21,11 @@

+ + {loop="$edit_link_plugin"} + {$value} + {/loop} + {if="($link_is_new && $GLOBALS['privateLinkByDefault']==true) || $link.private == true"}  
diff --git a/tpl/includes.html b/tpl/includes.html index 623e19ed..bdf3a07d 100644 --- a/tpl/includes.html +++ b/tpl/includes.html @@ -8,3 +8,6 @@ {if="is_file('inc/user.css')"}{/if} +{loop="$plugins_includes.css_files"} + +{/loop} \ No newline at end of file diff --git a/tpl/linklist.html b/tpl/linklist.html index daf87060..9ed28853 100644 --- a/tpl/linklist.html +++ b/tpl/linklist.html @@ -17,6 +17,9 @@ + {loop="$plugins_header.fields_toolbar"} + {$value} + {/loop} @@ -24,6 +27,12 @@ {include="linklist.paging"} + + {if="count($links)==0"}
Nothing found.
{else} @@ -40,7 +49,7 @@ + + {include="linklist.paging"} {include="page.footer"} - diff --git a/tpl/linklist.paging.html b/tpl/linklist.paging.html index 848541cd..e91c8f86 100644 --- a/tpl/linklist.paging.html +++ b/tpl/linklist.paging.html @@ -8,8 +8,13 @@ Click to see only private links {/if} + + {/if} + {loop="$action_plugin"} + {$value} + {/loop}
Links per page: 20 50 100
diff --git a/tpl/page.footer.html b/tpl/page.footer.html index 8143669d..6c29850f 100644 --- a/tpl/page.footer.html +++ b/tpl/page.footer.html @@ -1,5 +1,8 @@ {if="$newversion"}
Shaarli {$newversion} is available.
@@ -7,3 +10,7 @@ {if="isLoggedIn()"} {/if} + +{loop="$plugins_footer.js_files"} + +{/loop} diff --git a/tpl/page.header.html b/tpl/page.header.html index 2d186aa2..1d46d80c 100644 --- a/tpl/page.header.html +++ b/tpl/page.header.html @@ -11,7 +11,7 @@ {$shaarlititle} - + {if="!empty($_GET['source']) && $_GET['source']=='bookmarklet'"} {ignore} When called as a popup from bookmarklet, do not display menu. {/ignore} {else} @@ -33,6 +33,9 @@
  • Tag cloud
  • Picture wall
  • Daily
  • + {loop="$plugins_header.buttons_toolbar"} + {$value} + {/loop} {/if}
    diff --git a/tpl/picwall.html b/tpl/picwall.html index f59685cf..97d5efdf 100644 --- a/tpl/picwall.html +++ b/tpl/picwall.html @@ -5,15 +5,34 @@ + +
    + {loop="$plugin_start_zone"} + {$value} + {/loop} +
    +
    {loop="linksToDisplay"}
    {$value.thumbnail}{$value.title} + {loop="$value.picwall_plugin"} + {$value} + {/loop}
    {/loop}
    + +
    + +
    + {loop="$plugin_end_zone"} + {$value} + {/loop} +
    + {include="page.footer"}