Topic: Better Alternative to `getPages`?

Thinking about the Morfy’s getPages and it seems very bloated. Even to make a pagination we need to load all the files first, just to get some comparison items. Is this bad? Is this also occurs in Monstra?

There is getFiles which will only return the file URL, but no much options.

OK, I know this is just a plain text files that are super lightweight, but who knows there is an alternative that is more eficient. Any ideas?

XSS Testing <script>alert('HIYAA!!!');</script>

2 (edited by tovic 2014-06-06 06:23:39)

Re: Better Alternative to `getPages`?

I have created a custom build of Morfy library to improve the site performance here → https://github.com/tovic/morfy-library- … 8&L419

I also have added an $ignore parameter to the getFiles method so now I can declare $pages = array_slice($pages, null, $limit); immediately before the looping process. This will remove the unused file parsing process because in the original version, the page limitation done after the engine parsed all of the page files → https://github.com/Awilum/morfy-cms/blo … y.php#L359

The only drawback of this modification is that the content will not be present in the results of getPages due to process that will only parse the page header of the file. This makes the performance becomes better because we don’t need to read all of the file contents. Just replace your Morfy library with my modified version above, as long as you are not declaring $page['content'], $page['content_short'] and $page['content_full'] in blog.html then you will be fine.

Then, in your Markdown plugin, replace your markdown.php content with this:

use \Michelf\MarkdownExtra;

if(file_exists(CONTENT_PATH . '/' . Morfy::factory()->getUrl() . '.md')) {
    include PLUGINS_PATH . '/markdown/php-markdown/Michelf/Markdown.php';
    include PLUGINS_PATH . '/markdown/php-markdown/Michelf/MarkdownExtra.php';
    Morfy::factory()->addFilter('content', 'markdown', 1);
    function markdown($content) {
        return MarkdownExtra::defaultTransform($content);
    }
}

The conditional above will ensure that the Markdown parser will only be included and will only start the parsing process if we are in the blog_post page.

You can test my site performance here: hxxp://latitudu.com/notes (in index page/blog page/tag page) I will use this blog to record some of my nursing lessons in the future smile

PS: If anyone ever saw me said that I would make a dashboard plugin, maybe it will not be happen. I get lost in the middle of the work tongue Maybe Morfy will be better without a dashboard at all. Moreover, this kind of plugin will only create an impression that Morfy is not able to work without a dashboard. This will just broke the site slogan.

XSS Testing <script>alert('HIYAA!!!');</script>