1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2026-04-20 22:01:31 +00:00

Add GitLab saver, apply common lingo to Git savers (#3931)

* Transform GitHub saver to work with GitLab as well

You can choose which provider you want to use, the data is given in the
same place.

I tried to avoid code duplication, so service providers' unique
properties are in separate files, the settings of the selected provider
are loaded.

In two fields I am not sure that it fits into the current structure:

* module-type: gitservice
  Which module is a `gitservice` type, it will be listed in the
  drop-down menu.
* default-api-url: https://gitlab.com/api/v4
  The default URL to access the provider's API.

This is just a sketch, not a final version, suggestions for modification
are welcome!

* Rename saver from GitHub to GitService, update docs

* Split GitHub and GitLab to separate savers, apply common lingo

Sadly, it doesn't seem to make much sense to search for common parts in
the code, because there might be a Git service that is very different
from the GitHub API (such as BitBucket). Therefore, I feel that Git
savers are not able to share other than the translations.

I deleted the defaults values from the translations and set it to the
text entry because they should not depend on the translations.

* Add more information about the password field

It is not clear how to create a personal access token, thus added a link
to the help pages. In addition, GitLab only accepts personal access
token, GitHub also accepts the password, so I made this clear.

* Extract commit message to lingo

* Fix indentation

* Use improved base64 encoder

Fix conflict with a06acc4eb8
This commit is contained in:
Bimba Laszlo
2019-07-31 22:38:52 +02:00
committed by Jeremy Ruston
parent 3afaa9de9a
commit b5653babdf
7 changed files with 187 additions and 46 deletions

View File

@@ -9,7 +9,7 @@ Saves wiki by pushing a commit to the GitHub v3 REST API
(function(){
/*jslint node: true, browser: true */
/*global $tw: false */
/*global $tw: true */
"use strict";
/*
@@ -57,7 +57,7 @@ GitHubSaver.prototype.save = function(text,method,callback) {
callback: function(err,getResponseDataJson,xhr) {
var getResponseData,sha = "";
if(err && xhr.status !== 404) {
return callback(err);
return callback(err);
}
if(xhr.status !== 404) {
getResponseData = JSON.parse(getResponseDataJson);
@@ -65,14 +65,14 @@ GitHubSaver.prototype.save = function(text,method,callback) {
if(details.name === filename) {
sha = details.sha;
}
});
});
}
var data = {
message: "Saved by TiddlyWiki",
content: $tw.utils.base64Encode(text),
branch: branch,
sha: sha
};
message: $tw.language.getRawString("ControlPanel/Saving/GitService/CommitMessage"),
content: $tw.utils.base64Encode(text),
branch: branch,
sha: sha
};
// Perform a PUT request to save the file
$tw.utils.httpRequest({
url: uri + filename,