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
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,21 @@ the option `sampler.removeIndentation`. The default value is `false`.
}
```

### Proxy URL
Defining the proxy URL will prefix all snippet requests with it. This allows you to use a script to access the
snippet files.

```js
{
sampler : {
proxyURL: 'task.php?file='
}
}
```

If you're trying to load a language that your webserver understands (for example PHP) you
can create a proxy script that passes the source of the file trough. Be careful to
limit the script to the source files you would like to deliver.

### Example

Expand Down
3 changes: 2 additions & 1 deletion sampler.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,13 +165,14 @@
var config = Reveal.getConfig() || {};
config.sampler = config.sampler || {};
var options = {
proxyURL: config.sampler.proxyURL || '',
removeIndentation: !!config.sampler.removeIndentation
};

var elements = document.querySelectorAll('[data-sample]');
elements.forEach(function(element) {
var slug = element.getAttribute('data-sample').match(/([^#]+)(?:#(.+))?/);
var file = slug[1];
var file = options.proxyURL + slug[1];
var selector = slug[2];
var extractor = getSnippetExtractor(selector);

Expand Down