diff --git a/assets/less/mio/classes/index.less b/assets/less/mio/classes/index.less index 91f63b2a..9042b88a 100644 --- a/assets/less/mio/classes/index.less +++ b/assets/less/mio/classes/index.less @@ -5,6 +5,7 @@ &__sidebar { width: 300px; margin-left: 2px; + flex: 0 0 auto; } &__main { diff --git a/src/Parsers/BBCode/BBCodeParser.php b/src/Parsers/BBCode/BBCodeParser.php index bc242146..09289fb6 100644 --- a/src/Parsers/BBCode/BBCodeParser.php +++ b/src/Parsers/BBCode/BBCodeParser.php @@ -1,16 +1,24 @@ parseText($line); + } } diff --git a/src/Parsers/MarkdownParser.php b/src/Parsers/MarkdownParser.php index 5ad92b6a..3418f430 100644 --- a/src/Parsers/MarkdownParser.php +++ b/src/Parsers/MarkdownParser.php @@ -3,18 +3,15 @@ namespace Misuzu\Parsers; use Parsedown; -final class MarkdownParser extends Parser +class MarkdownParser extends Parsedown implements ParserInterface { - private $parsedown; - - public function __construct() - { - parent::__construct(); - $this->parsedown = new Parsedown; - } - public function parseText(string $text): string { - return $this->parsedown->text($text); + return $this->text($text); + } + + public function parseLine(string $line): string + { + return $this->line($line); } } diff --git a/src/Parsers/Parser.php b/src/Parsers/Parser.php deleted file mode 100644 index e9c19750..00000000 --- a/src/Parsers/Parser.php +++ /dev/null @@ -1,34 +0,0 @@ - 0; + $going_mid = ($direction & MSZ_ZALGO_DIR_MID) > 0; + $going_down = ($direction & MSZ_ZALGO_DIR_DOWN) > 0; $str = ''; diff --git a/utility.php b/utility.php index 3fa4cad1..5ece9be5 100644 --- a/utility.php +++ b/utility.php @@ -1,28 +1,12 @@ 0; -} - function byte_symbol($bytes, $decimal = false) { if ($bytes < 1) { @@ -84,27 +54,29 @@ function byte_symbol($bytes, $decimal = false) return sprintf("%.2f %s%sB", $bytes, $symbol, $symbol !== '' && !$decimal ? 'i' : ''); } -// this should be rewritten to only load the database once per Application instance. -// for now this will do since the only time this function is called is once during registration. -// also make sure an instance of Application with config exists before calling this! function get_country_code(string $ipAddr, string $fallback = 'XX'): string { + global $_msz_geoip; + try { - $app = \Misuzu\Application::getInstance(); - $config = $app->getConfig(); + if (!$_msz_geoip) { + $app = \Misuzu\Application::getInstance(); + $config = $app->getConfig(); - if ($config === null) { - return $fallback; + if ($config === null) { + return $fallback; + } + + $database_path = $config->get('GeoIP', 'database_path'); + + if ($database_path === null) { + return $fallback; + } + + $_msz_geoip = new \GeoIp2\Database\Reader($database_path); } - $database_path = $config->get('GeoIP', 'database_path'); - - if ($database_path === null) { - return $fallback; - } - - $geoip = new \GeoIp2\Database\Reader($database_path); - $record = $geoip->country($ipAddr); + $record = $_msz_geoip->country($ipAddr); return $record->country->isoCode; } catch (\Exception $e) { @@ -223,12 +195,12 @@ function pdo_prepare_array(array $keys, bool $useKeys = false, string $format = function parse_markdown(string $text): string { - return \Misuzu\Parsers\MarkdownParser::getOrCreateInstance()->parseText($text); + return \Misuzu\Parsers\MarkdownParser::instance()->parseText($text); } function parse_bbcode(string $text): string { - return \Misuzu\Parsers\BBCode\BBCodeParser::getOrCreateInstance()->parseText($text); + return \Misuzu\Parsers\BBCode\BBCodeParser::instance()->parseText($text); } function render_error(int $code, string $template = 'errors.%d'): string diff --git a/views/mio/news/macros.twig b/views/mio/news/macros.twig index 55cad5f6..14171439 100644 --- a/views/mio/news/macros.twig +++ b/views/mio/news/macros.twig @@ -6,8 +6,7 @@