bloodybowlers / UkeGeeks-ng

Ukulele Songbook Website
GNU General Public License v3.0
6 stars 5 forks source link

const StaticsPrefix relative or absolute? #34

Closed Louis-coding-UGNG closed 5 years ago

Louis-coding-UGNG commented 5 years ago

https://github.com/bloodybowlers/UkeGeeks-ng/blob/ef07131e4852916991f18751f0a182e91e12db91/ugsphp/Config_example.php#L31

Shouldn't that rather be './' as these components usually reside in subdirectories of the ukeGeeks installation defined in https://github.com/bloodybowlers/UkeGeeks-ng/blob/ef07131e4852916991f18751f0a182e91e12db91/ugsphp/Config_example.php#L38

bloodybowlers commented 5 years ago

I don't think so.

Here is the comment from original author (in source code) : "(leave as "/" if standard install)" Same goes for the Subdirectory.

When rendered to html, the path seems correct on my install.

The subdirectory is here if you want it in a subfolder I guess, like this : http://mydomain.com/subfolderhere/ukegeeks

Louis-coding-UGNG commented 5 years ago

All paths are correct when you install to root of a domain: stylesheet" href="/css/ugsEditorPlus.merged.css"

Trouble starts when you install to a subdirectory like domain.tld/sub1. Without further changes it still renders all paths to root: stylesheet" href="/css/ugsEditorPlus.merged.css"

Lets change StaticsPrefix and Subdirectory to "sub1/" where it now resides: stylesheet" href="sub1/css/ugsEditorPlus.merged.css"

Arrgh, we seem to need leading and trailing slashes to get things going (worth mentioning in the comments of config and installation instructions/user guide #27 ): stylesheet" href="/sub1/css/ugsEditorPlus.merged.css"

The more I try the various combinations, the more I get confused... Yet I'd still vote for StaticsPrefix defaulting to being a relative path to the main UG installation location ('./';) Subdirectory is the path relative to the installation domain. In any case music.php and the folder ugsphp must be in the same directory and should not be renamed.

bloodybowlers commented 5 years ago

Lets change StaticsPrefix and Subdirectory to sub1

Nop, don't change both of them. They serve different purpose.

StaticsPrefix is only used for assets, in case you want them in another folder. It doesn't change the folder of the install.
Subdirectory is used if you want your ukegeeks install in a subfolder of your domain.

I changed the readme file this morning and added (copy/paste) the doc from the original project about this particular thing.

What do you think ?

Louis-coding-UGNG commented 5 years ago

I am afraid it's still not solved: When installing the whole package to mydomain.tld/sub1, changing only const Subdirectory = '/sub1/'; leads to wrongly rendered asset paths like href="/css/ugsphp.css" (the assets are now in /sub1/...). Changing the default config to the relative path const StaticsPrefix = './'; would simply overcome this problem without making the instructions wrong.

Have a look at my working samples (requires login with default credentials):

  1. https://ng.4str.in/sub1 has const StaticsPrefix = '/'; const Subdirectory = '/sub1/';
  2. https://ng.4str.in/relative has const StaticsPrefix = './'; const Subdirectory = '/relative/';
  3. https://ng.4str.in/both has const StaticsPrefix = '/both/'; const Subdirectory = '/both/';

From a functionality perspective all three seem to work as expected - but the stylesheets are not found in example 1 :(

And could you pls add a note that bot variables must be speciefied with leading and trailing slahes? (Or alternatively check the given string for first/last character being '/' and adding the slash(es) when necessary)

bloodybowlers commented 5 years ago

You know what, StaticsPrefixis gonna be removed :) It's useless... I mean, who wants to have some js/css in another dir, not related to the install dir ? What's the point ?

We should only keep the Subdirectoryconst for installing in a subfolder, that's all.

bloodybowlers commented 5 years ago

Added a branch : no_staticsprefix.

It removes the StaticsPrefix from the config file and try to handle it automatically (adding leading and trailing slashes if necessary).

It seems to work on my install (root dir), but I currently couldn't test it in a subfolder.

@Louis-coding-UGNG , could you please test and tell me if it's ok ? I'll then merge to master.

Edit: I'm wondering if the .htaccess directive for mod_rewrite still works when used in a subfolder...

Louis-coding-UGNG commented 5 years ago

could you please test and tell me if it's ok ?

set it up without rewrite in https://ng.4str.in/nostatic. Seems to work after a first rough "click-through" test

I'm wondering if the .htaccess directive for mod_rewrite still works when used in a subfolder...

I stumbled on that one during testing - it doesn't seem to work. But I haven't yet fully figured out where and why

bloodybowlers commented 5 years ago

Ok thank you, I'll merge the commit. I'll open another issue for the mod_rewrite problem if subdir is not root.