Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow to configure a proxy to fetch the snippets #12

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

ThomasWeinert
Copy link
Contributor

I am using sampler with PHP snippets, but my webserver (local inside the IDE) support PHP. So I only get empty responses. :-)

A small proxy script allows to fetch the source of the PHP files.

This branch includes the changes for the indentation behavior. Both read options, so they might conflict otherwise.

@ldionne
Copy link
Owner

ldionne commented Dec 3, 2018

I'm not sure I understand the purpose of this feature and what it's enabling that the current thing doesn't. Could you please try explaining again?

@ThomasWeinert
Copy link
Contributor Author

ThomasWeinert commented Dec 3, 2018

It is a specific use case.

The snippets in my presentation are PHP unit tests. They are tasks for the attendees to solve (using a wireless keyboard that goes around).

The IDE is configured to treat this as a web project and knows/has a PHP executable. If I now start the IDE built-in webserver the plugin is not able to get the source code directly. The webserver will execute the PHP (only class definitions so nothing happens) and return an empty response. Here is not an configuration in the IDE to disable the PHP executable just for the webserver. Renaming the files or disabling PHP would mean loosing IDE features.

Here are two solutions originally. Opening the index.html from the file system would avoid the PHP execution, but add other restrictions. Browsers behave differently in this case. The other option would be to change all the URLs in the data-sample attributes. It would make them a lot harder to read and the presentation would not work on a webserver without PHP support.

The configuration option can depend on the used URL. This way I can use the presentation directly from the IDE and publish it without any change.

Example:

sampler: {
    proxyURL: document.location.href.match(/http:\/\/localhost/) ? 'task.php?file=' : ''
}

@ldionne
Copy link
Owner

ldionne commented Dec 6, 2018

Ah, I understand better. Two questions:

  1. Can you please rebase on top of the latest master (with Remove overall indentation in snippets #11 applied)?
  2. Would it make more sense instead to allow providing a JS function that fetches the file instead of the fetch we currently use?

@ThomasWeinert
Copy link
Contributor Author

  1. Rebased. Done.

  2. I can imagine several advanced features like that:

a) proxyURL as string with placeholders, allow to transfer information from the data attributes.
b) callback function that returns the URL allowing to map/modify it, without caring about the actual fetching
c) callback function implements the actual fetching and executes a listener (your suggestion)

Maybe we should move that to a feature request issue and discuss it. It could be useful for some users and does not sound to difficult to implement.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants