gilbitron / Pico-Editor-Plugin

Provides an online Markdown editor and file manager for Pico.
http://pico.dev7studios.com
MIT License
58 stars 30 forks source link

Fix pico_editor when Pico installed within non-empty base_url #8

Open sarxos opened 11 years ago

sarxos commented 11 years ago

Hi,

First of all, thank you for awesome and very simple CMS as well as for a bunch of ready-to-use plugins.

I'm completely new in Pico, just started playing with it, but found an issue in _picoeditor when Pico has not been installed in the default, i.e. empty base URL.

My configuration is the following:

$config = array(
    'site_title'     => 'Pico',
    'base_url'       => 'http://localhost/pico',
    'theme'          => 'default',
    'date_format'    => 'jS M Y',
    'twig_config'    => array('cache' => false, 'autoescape' => false, 'debug' => false),
    'pages_order_by' => 'alpha',
    'pages_order'    => 'asc',
    'excerpt_length' => 50
);

As you can see I do have Pico installed in sub directory called pico. It works fine, but _picoeditor is having troubles whenever I'm trying to edit index.md file (it does not recognize it, even when default base URL is used).

The attached commit fix described problem with empty and non-empty base URL.

Tested on top of https://github.com/gilbitron/Pico/commit/45cd4ca5b7c35399f65065341a9676c629399a62

Works fine with any combination of base URL, but I tested this fix with the following configurations:

http://localhost
http://localhost/pico
http://localhost/services/pico
tyeeman commented 10 years ago

Thanks for this. I tried it and found it adds backslashes in certain words or image links. Try adding a markdown image link on a page, then edit the page and save and see what happens to the link.

w-vi commented 10 years ago

Good one, I came across the same thing and merged your fix, although I changed it a bit as the basename() returns only the trailing part of the path so if the file is in subdirectory it gets stripped just to filename