mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-05-29 12:01:32 +02:00
This commit is contained in:
@@ -32,11 +32,8 @@ The configuration file is in `.json` format. There is an example at `bin/config.
|
||||
"apiBaseUrl" (string): base url for the snapshot api,
|
||||
"username" (string, optional): username for http basic auth,
|
||||
"password" (string, optional): password for http basic auth,
|
||||
"serviceName" (string): current name of writeLaTeX in case it ever changes,
|
||||
"hostname": (string): the public hostname of the server, for postback,
|
||||
"ssl": { (object): ssl configuration
|
||||
"enabled": (boolean): decides on http or https for the postback url
|
||||
}
|
||||
"postbackUrl" (string): the postback url,
|
||||
"serviceName" (string): current name of writeLaTeX in case it ever changes
|
||||
}
|
||||
|
||||
You have to restart the server for configuration changes to take effect.
|
||||
|
||||
@@ -4,9 +4,6 @@
|
||||
"apiBaseUrl": "https://radiant-wind-3058.herokuapp.com/api/v0",
|
||||
"username": "staging",
|
||||
"password": "6kUfbv0R",
|
||||
"serviceName": "Overleaf",
|
||||
"hostname": "git.overleaf.com",
|
||||
"ssl": {
|
||||
"enabled": false
|
||||
}
|
||||
"postbackUrl": "http://git.overleaf.com",
|
||||
"serviceName": "Overleaf"
|
||||
}
|
||||
|
||||
@@ -20,9 +20,8 @@ public class Config implements JSONSource {
|
||||
private String username;
|
||||
private String password;
|
||||
private String apiBaseURL;
|
||||
private String postbackURL;
|
||||
private String serviceName;
|
||||
private String hostname;
|
||||
private SSLConfig ssl;
|
||||
|
||||
public Config(String configFilePath) throws InvalidConfigFileException, IOException {
|
||||
try {
|
||||
@@ -45,8 +44,10 @@ public class Config implements JSONSource {
|
||||
}
|
||||
this.apiBaseURL = apiBaseURL;
|
||||
serviceName = getElement(configObject, "serviceName").getAsString();
|
||||
hostname = getOptionalString(configObject, "hostname");
|
||||
ssl = new SSLConfig(getElement(configObject, "ssl").getAsJsonObject());
|
||||
postbackURL = getElement(configObject, "postbackUrl").getAsString();
|
||||
if (!postbackURL.endsWith("/")) {
|
||||
postbackURL += "/";
|
||||
}
|
||||
}
|
||||
|
||||
public int getPort() {
|
||||
@@ -89,12 +90,8 @@ public class Config implements JSONSource {
|
||||
return serviceName;
|
||||
}
|
||||
|
||||
public String getHostname() {
|
||||
return hostname;
|
||||
}
|
||||
|
||||
public SSLConfig getSSL() {
|
||||
return ssl;
|
||||
public String getPostbackURL() {
|
||||
return postbackURL;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -54,8 +54,7 @@ public class WLGitBridgeServer {
|
||||
writeLatexHostname = config.getAPIBaseURL();
|
||||
SnapshotAPIRequest.setBaseURL(writeLatexHostname);
|
||||
Util.setServiceName(config.getServiceName());
|
||||
Util.setHostname(config.getHostname());
|
||||
Util.setSSL(config.getSSL());
|
||||
Util.setPostbackURL(config.getPostbackURL());
|
||||
Util.setPort(config.getPort());
|
||||
}
|
||||
|
||||
@@ -67,10 +66,9 @@ public class WLGitBridgeServer {
|
||||
jettyServer.start();
|
||||
System.out.println();
|
||||
System.out.println(Util.getServiceName() + "-Git Bridge server started");
|
||||
System.out.println("Hostname: " + Util.getHostname());
|
||||
System.out.println("Listening on port: " + port);
|
||||
System.out.println("SSL enabled: " + Util.getSSLConfig().isEnabled());
|
||||
System.out.println("Bridged to: " + writeLatexHostname);
|
||||
System.out.println("Postback URL: " + Util.getPostbackURL());
|
||||
System.out.println("Root git directory path: " + rootGitDirectoryPath);
|
||||
} catch (BindException e) {
|
||||
e.printStackTrace();
|
||||
|
||||
@@ -26,7 +26,7 @@ public class WLReceivePackFactory implements ReceivePackFactory<HttpServletReque
|
||||
@Override
|
||||
public ReceivePack create(HttpServletRequest httpServletRequest, Repository repository) throws ServiceNotEnabledException, ServiceNotAuthorizedException {
|
||||
ReceivePack receivePack = new ReceivePack(repository);
|
||||
String hostname = Util.getHostname();
|
||||
String hostname = Util.getPostbackURL();
|
||||
if (hostname == null) {
|
||||
hostname = httpServletRequest.getLocalName();
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ public class Util {
|
||||
private static String HOSTNAME;
|
||||
private static SSLConfig SSL_CONFIG;
|
||||
private static int PORT;
|
||||
private static String POSTBACK_URL;
|
||||
|
||||
public static String entries(int entries) {
|
||||
if (entries == 1) {
|
||||
@@ -69,22 +70,6 @@ public class Util {
|
||||
return SERVICE_NAME;
|
||||
}
|
||||
|
||||
public static void setHostname(String hostname) {
|
||||
HOSTNAME = hostname;
|
||||
}
|
||||
|
||||
public static String getHostname() {
|
||||
return HOSTNAME;
|
||||
}
|
||||
|
||||
public static SSLConfig getSSLConfig() {
|
||||
return SSL_CONFIG;
|
||||
}
|
||||
|
||||
public static void setSSL(SSLConfig ssl) {
|
||||
SSL_CONFIG = ssl;
|
||||
}
|
||||
|
||||
public static int getPort() {
|
||||
return PORT;
|
||||
}
|
||||
@@ -93,4 +78,11 @@ public class Util {
|
||||
PORT = port;
|
||||
}
|
||||
|
||||
public static void setPostbackURL(String postbackURL) {
|
||||
POSTBACK_URL = postbackURL;
|
||||
}
|
||||
|
||||
public static String getPostbackURL() {
|
||||
return POSTBACK_URL;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,11 +25,7 @@ public class WLDirectoryNodeSnapshot implements CandidateSnapshot {
|
||||
public WLDirectoryNodeSnapshot(WLProject project, WLDirectoryNode directoryNode, String hostname, String postbackKey, CandidateSnapshotCallback callback) {
|
||||
previousVersionID = project.getLatestSnapshotID();
|
||||
projectName = project.getName();
|
||||
String protocol = "http";
|
||||
if (Util.getSSLConfig().isEnabled()) {
|
||||
protocol += "s";
|
||||
}
|
||||
projectURL = protocol + "://" + hostname + ":" + Util.getPort() + "/" + projectName;
|
||||
projectURL = Util.getPostbackURL() + projectName;
|
||||
|
||||
this.directoryNode = directoryNode;
|
||||
this.postbackKey = postbackKey;
|
||||
|
||||
Reference in New Issue
Block a user