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

Support creating Gists on Enterprise GitHub accounts #96

Open
wants to merge 1 commit 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
4 changes: 3 additions & 1 deletion lib/controllers/share.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ var bodyParser = require('body-parser');
var requestp = require('request-promise');
var rperrors = require('request-promise/errors');

var gistAPI = 'https://api.github.com/gists';
var githubGistAPI = 'https://api.github.com/gists';
var googleUrlShortenerAPI = 'https://www.googleapis.com/urlshortener/v1';

var prefixSeparator = '-'; // change the regex below if you change this
Expand All @@ -17,6 +17,7 @@ function makeGist(serviceOptions, body) {
var gistFile = {};
gistFile[serviceOptions.gistFilename || 'usercatalog.json'] = { content: body };

gistAPI = serviceOptions.gistAPI || githubGistAPI;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe gistAPI is undeclared. Add a var in front.

var headers = {
'User-Agent': serviceOptions.userAgent || 'TerriaJS-Server',
'Accept': 'application/vnd.github.v3+json'
Expand Down Expand Up @@ -50,6 +51,7 @@ function resolveGist(serviceOptions, id) {
'User-Agent': serviceOptions.userAgent || 'TerriaJS-Server',
'Accept': 'application/vnd.github.v3+json'
};
gistAPI = serviceOptions.gistAPI || githubGistAPI;
if (serviceOptions.accessToken !== undefined) {
headers['Authorization'] = 'token ' + serviceOptions.accessToken;
}
Expand Down
3 changes: 3 additions & 0 deletions serverconfig.json.example
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,9 @@
// usage limits apply
// accessToken: "ABC123",

// Optional: your enterprise Github API URL goes here. If not supplied, Github's default api will be used
// gistAPI : "https://api.github.example.com/gists",

// Optional: user agent HTTP Header to set
userAgent: "My service",
// Optional: The filename to give to the gist file (default: usercatalog.json)
Expand Down