Skip to content

Commit

Permalink
Allow to use a proxy to fetch the snippets.
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomasWeinert committed Nov 24, 2018
1 parent 80e3d03 commit 62bfb3b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,20 @@ an the option `sampler.removeIndentation`.
}
```

### Fetcher URL
Defining the fetcher URL will prefix all snippet requests with it.

```js
{
sampler : {
fetcherURL: '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 = {
fetcherURL: config.sampler.fetcherURL || '',
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.fetcherURL + slug[1];
var selector = slug[2];
var extractor = getSnippetExtractor(selector);

Expand Down

0 comments on commit 62bfb3b

Please sign in to comment.