GitHub Saver: Make server URL configurable

fix-syncer
Jermolene 2019-04-15 21:30:59 +01:00
rodzic b32a5aa9af
commit 25c0ebb523
3 zmienionych plików z 4 dodań i 1 usunięć

Wyświetl plik

@ -92,6 +92,7 @@ Saving/Hint: Settings used for saving the entire TiddlyWiki as a single file via
Saving/GitHub/Branch: Target branch for saving (defaults to `master`)
Saving/GitHub/Caption: ~GitHub Saver
Saving/GitHub/Description: These settings are only used when saving to ~GitHub
Saving/GitHub/URL: Server URL (defaults to `https://api.github.com`)
Saving/GitHub/Filename: Filename of target file (e.g. `index.html`)
Saving/GitHub/Password: Password, OAUTH token, or personal access token
Saving/GitHub/Path: Path to target file (e.g. `/wiki/`)

Wyświetl plik

@ -29,6 +29,7 @@ GitHubSaver.prototype.save = function(text,method,callback) {
path = this.wiki.getTiddlerText("$:/GitHub/Path"),
filename = this.wiki.getTiddlerText("$:/GitHub/Filename"),
branch = this.wiki.getTiddlerText("$:/GitHub/Branch") || "master",
endpoint = this.wiki.getTiddlerText("$:/GitHub/Url") || "https://api.github.com",
headers = {
"Accept": "application/vnd.github.v3+json",
"Content-Type": "application/json;charset=UTF-8",
@ -46,7 +47,7 @@ GitHubSaver.prototype.save = function(text,method,callback) {
path = path + "/";
}
// Compose the base URI
var uri = "https://api.github.com/repos/" + repo + "/contents" + path;
var uri = endpoint + "/repos/" + repo + "/contents" + path;
// Perform a get request to get the details (inc shas) of files in the same path as our file
$tw.utils.httpRequest({
url: uri,

Wyświetl plik

@ -12,3 +12,4 @@ caption: {{$:/language/ControlPanel/Saving/GitHub/Caption}}
|<<lingo Branch>> |<$edit-text tiddler="$:/GitHub/Branch" default="" tag="input"/> |
|<<lingo Path>> |<$edit-text tiddler="$:/GitHub/Path" default="" tag="input"/> |
|<<lingo Filename>> |<$edit-text tiddler="$:/GitHub/Filename" default="" tag="input"/> |
|<<lingo Url>> |<$edit-text tiddler="$:/GitHub/Url" default="" tag="input"/> |