X-Ryl669 / grav-plugin-viewer3d

GNU Affero General Public License v3.0
2 stars 1 forks source link

using plugin in quark skeleton does not work in all places #4

Closed ljubomirb closed 3 years ago

ljubomirb commented 3 years ago

I'm having trouble having plugin to work in basic quark skeleton when I add in module text/hero/features. The only way it works is if it is in new page. Maybe something is missing, maybe something needs to be inherited? The placeholder shows, all controls show, but "unknown error" appears.

X-Ryl669 commented 3 years ago

Do you have an URL to the page that's failing so I can have a look ?

ljubomirb commented 3 years ago

I'm experiencing this in basic grav quark skeleton theme. link to skeleton theme You can, for the sake of test, download this entire folder, rename old grav folder as grav_old, place this as grav. Once you open (and possibly register again, including adding media type), simply add [3dv]test.ply[/3dv] anywhere at subpage (module). It is not a matter of ply vs stl, I tried to test it. The result is "unknown error" text that appears at the top left. Everything else is there, box, controls... But, if you add page (not module), with "default" type from home page, you can easily see it all work.

X-Ryl669 commented 3 years ago

From your description, I think the issue is in the path to the model file (.ply or .stl) which is not deduced as expected. I don't have another server to install grav upon and I don't want to break my blog, that's why I've asked you a URL so I could test by myself. Anyway, let's try to sort it out logically:

  1. If all works but the model, then it means that the plugin is correctly installed.
  2. Please open the development console on your browser and go straight to the "Network" tab and reload the failing page
  3. You'll see one access to a file "test.ply" and it'll probably return with a 404 error. Capture the URL used here and report here
  4. Then, please enable the download button in the plugin and try to download the model (it should fail as well, but who knows)
  5. Finally try to manipulate the URL until you succeed downloading your model (depending on your grav installation, it might require adding a ../ before or whatever). Please post the "good" URL here.
  6. I'll try to post a file to test for solving the issue once I know what's wrong with the URL generation
ljubomirb commented 3 years ago

It appears you are right, it has to do something with path. Great instructions! So, in case of this default theme (skeleton grav quark), any access to file goes OK if files are in home page (here), but fail if files are at their module pages in this case "highlights", "callout" or such, no matter where the placeholder is (in any child module page). So download link looks always like: <domain>/grav/some_homepage/test.ply,where in my case /grav is my enter point, still developing page. I can only guess it may be <domain>/some_homepage/test.ply in production scenario. In conclusion, I can live with having files in home location, but if you think this is something to be changed, here it is. I hope I helped.

X-Ryl669 commented 3 years ago

There's something that's not clear in Grav: handling of URL. I've tried on different "mode", with multi language site and without, yet, there's always something wrong going on. Right now, I'm using the slug() method that should be the swissknife of URL, but it does not seem to work for you. Can I ask you to modify a file and post the output (send it by email if you want): In V3DShortCode.php, the lines that looks like this:

class V3DShortcode extends Shortcode
{
    public function init()
    {
        $this->shortcode->getHandlers()->add('3dv', function(ShortcodeInterface $sc) {
            $this->shortcode->addAssets('css', 'plugin://viewer3d/assets/css/3dviewer.css');
            $this->shortcode->addAssets('js', 'plugin://viewer3d/assets/js/three.min.js');
            $this->shortcode->addAssets('js', 'plugin://viewer3d/assets/js/o3dv.min.js');
            $this->shortcode->addAssets('js', 'plugin://viewer3d/assets/js/3dviewer.js');
            $slug = $this->grav['page']->slug();

can you add this just below so it looks like this:

class V3DShortcode extends Shortcode
{
    public function init()
    {
        $this->shortcode->getHandlers()->add('3dv', function(ShortcodeInterface $sc) {
            $this->shortcode->addAssets('css', 'plugin://viewer3d/assets/css/3dviewer.css');
            $this->shortcode->addAssets('js', 'plugin://viewer3d/assets/js/three.min.js');
            $this->shortcode->addAssets('js', 'plugin://viewer3d/assets/js/o3dv.min.js');
            $this->shortcode->addAssets('js', 'plugin://viewer3d/assets/js/3dviewer.js');
            $slug = $this->grav['page']->slug();
            dump($this->grav['page']);
            var_dump($this->grav['page']->getMediaUri());
            var_dump($this->grav['page']->url(false, true, true, true, false));

This will add some glibberish on the top of the page using the plugin, please copy and paste here or send it to my email address.

Meanwhile, you can workaround this bug by using ../../../some_homepage/test.ply instead of the simpler test.ply.

ljubomirb commented 3 years ago

Can you provide me some email or point me how to otherwise send private message to you. Because, I was thinking of paying you one month of server droplet on digital ocean to play with. It's at least what I can do to help you, and because, honestly, I have limited knowledge in grav and frontend design anyway. What do you think about it?

X-Ryl669 commented 3 years ago

We changed email, thanks. You can send me the logs of the change above, I'm confident it's not a hard to fix bug.

X-Ryl669 commented 3 years ago

After discussion, I think this issue is resolved. Feel free to re-open if you don't think it is. Cheers!