realms-wiki icon indicating copy to clipboard operation
realms-wiki copied to clipboard

saving a page fails when using a relative path

Open larsimmisch opened this issue 9 years ago • 4 comments

My realms instance has a relative base URL - something like https://example.org/wiki

In this setup, I cannot save pages, because I get redirected to https://example.org/foo (if foo is the page name) and not https://example.org/wiki/foo.

I tried looking into the issue, but only have found one clue so far. The page source for the edit page has this snippet:

      var Config = {};

        Config.RELATIVE_PATH = "";


      var User = {};
      User.is_authenticated = true;

        User.username = "lars";

        User.email = "[email protected]";

That's puzzling. I'd expect Config.RELATIVE_PATH to be wiki, not the empty string. The BASE_URL in my (only) realms-wiki.json is https://example.org/wiki.

(I hope this is not a red herring)

larsimmisch avatar Feb 01 '16 21:02 larsimmisch

(fixed typos in original report)

larsimmisch avatar Feb 01 '16 21:02 larsimmisch

It looks like the problem might be to do with the order the config defaults are generated. https://github.com/scragg0x/realms-wiki/blob/master/realms/config/init.py#L180-L186

RELATIVE_PATH is generated based on BASE_URL before the user's custom BASE_URL is set. I bet if you manually specify your RELATIVE_PATH it would work.

I think the proper fix is re-considering the order in which certain defaults get set in the config package. I think any defaults based on other config values needs to happen after the user config import, then it needs to check that the user didn't set them explicitly before overriding with the generated default.

gazpachoking avatar Feb 02 '16 18:02 gazpachoking

Thanks @gazpachoking,

good catch! Unfortunately this is no fix, but that is a different matter.

The relevant fragment from my realms-wiki.json looks like this:

{
    "ALLOW_ANON": false,
    "PRIVATE_WIKI": true,
    "BASE_URL": "https://example.org",
    "RELATIVE_PATH": "/wiki",
    ...
}

With this I surprisingly get redirected to https://example.org/wiki/wiki. If I reorder https://github.com/scragg0x/realms-wiki/blob/master/realms/config/init.py, the same thing happens (obviously).

I agree RELATIVE_PATH should be evaluated after https://github.com/scragg0x/realms-wiki/blob/master/realms/config/init.py#L199.

larsimmisch avatar Feb 02 '16 19:02 larsimmisch

Ah. I should mention that I have these problems when I run realms-wiki as a wsgi script. My relevant apache configuration is:

        WSGIDaemonProcess realms_wsgi user=www-data group=www-data \
            home=/usr/local/src/realms-wiki display-name=%{GROUP}
    WSGIProcessGroup realms_wsgi
        WSGIScriptAlias /wiki /Library/SSL/wiki/wsgi.py
        Alias /wiki/static /usr/local/src/realms-wiki/realms/static

        <Directory /Library/SSL/wiki>
          Options -Indexes
          Require all granted
        </Directory>

larsimmisch avatar Feb 02 '16 20:02 larsimmisch