esoe 2 years ago
parent
commit
8e411eca37
  1. 45
      out/unzip/molokoin/molokoin-client/css/style.css
  2. 23
      out/unzip/molokoin/molokoin-client/index.html
  3. 1
      out/unzip/molokoin/molokoin-client/js/main.js
  4. BIN
      out/zip/molokoin-client-master.zip
  5. 148
      src/main/java/ru/molokoin/sourceListener/SourceListener.java
  6. 13
      src/main/java/ru/molokoin/sourceListener/git/RepoCrafter.java
  7. 32
      src/main/java/ru/molokoin/sourceListener/net/Service.java
  8. 2
      src/main/java/ru/molokoin/sourceListener/opt/Options.java
  9. BIN
      target/classes/ru/molokoin/sourceListener/GitListener.class
  10. BIN
      target/classes/ru/molokoin/sourceListener/RepoCrafter.class
  11. BIN
      target/classes/ru/molokoin/sourceListener/SourceListener.class
  12. BIN
      target/classes/ru/molokoin/sourceListener/git/RepoCrafter.class
  13. BIN
      target/classes/ru/molokoin/sourceListener/net/Service.class
  14. BIN
      target/classes/ru/molokoin/sourceListener/opt/Options.class

45
out/unzip/molokoin/molokoin-client/css/style.css

@ -0,0 +1,45 @@
body {
font-family: Arial;
padding: 20px;
background: #f1f1f1;
}
div {
background-color: rgb(181, 122, 236);
padding: 5px;
margin: 5px;
}
.header{
display: block;
padding: 30px;
font-size: 40px;
text-align: center;
background: rgb(181, 122, 236);
/*position: relative; top: 20px;*/
}
.controls{
/*position: relative; left: 20px;*/
list-style: none; /* Отключение отображения маркеров. */
width: 25%; /* Ширина меню. */
float: left;
/*padding-left: 20px;*/
}
.controls li {
margin: 5px; /* Отступ между блоками по высоте, необходимый для того чтобы пункты меню не сливались */
font-family: Verdana, Arial, Helvetica, sans-serif; /* Тип шрифта пунктов меню */
font-size: 14px; /* Размер текста меню */
}
.controls li a{
display: block; /* Изменение отображения на блочное для того, чтобы иметь возможность задать внутренние отступы. */
padding: 4px 15px; /* Отступы внутри блоков. */
background: #0db5b5; /* Цвет блоков меню. */
color: #3f3f3f; /* Цвет текста в блоках меню. */
text-decoration: none; /* Устранение подчёркивания ссылок. */
position: relative; /* Это необходимо при использовании Internet Explorer 6 для того, чтобы ссылка по всей своей площади была «кликабельной». */
}
.controls li a:hover {
background: #92d3d3; /* Цвет фона при наведении курсора мыши */
color: #6b6b6b; /* Цвет текста при наведении курсора мыши */
}
.mainframe{
background-color: aliceblue;
}

23
out/unzip/molokoin/molokoin-client/index.html

@ -0,0 +1,23 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>molokoin.ru</title>
<link rel="stylesheet" type="text/css" href="css/style.css">
</head>
<body>
<div class="header">
molokoin.ru/ добавить картинку и кнопку авторизации
</div>
<div class="controls">
<li><a href="http://molokoin.ru:3000/esoe">gitea</a></li>
<li><a href="http://www.molokoin.ru:8080">apache</a></li>
<li><a href="http://www.egspt.ru">moodle</a></li>
<li><a href="http://isp12.adminvps.ru">adminvps</a></li>
</div>
<script src="js/main.js"></script>
</body>
</html>

1
out/unzip/molokoin/molokoin-client/js/main.js

@ -0,0 +1 @@
console.log("qu")

BIN
out/zip/molokoin-client-master.zip

Binary file not shown.

148
src/main/java/ru/molokoin/sourceListener/SourceListener.java

@ -1,148 +0,0 @@
package ru.molokoin.sourceListener;
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.nio.file.Path;
import java.nio.file.StandardOpenOption;
import java.util.Enumeration;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
import org.eclipse.jgit.api.Git;
import org.eclipse.jgit.api.errors.GitAPIException;
import org.eclipse.jgit.api.errors.InvalidRemoteException;
import org.eclipse.jgit.api.errors.TransportException;
import org.eclipse.jgit.lib.Repository;
import com.fasterxml.jackson.core.exc.StreamReadException;
import com.fasterxml.jackson.databind.DatabindException;
import com.fasterxml.jackson.databind.ObjectMapper;
public class SourceListener {
public Options opt;
public String optionsPath = "options-home.json";
public SourceListener(){
try {
opt = readOptions();
} catch (StreamReadException e) {
System.out.println(e.getMessage());
e.printStackTrace();
} catch (DatabindException e) {
System.out.println(e.getMessage());
e.printStackTrace();
} catch (IOException e) {
System.out.println(e.getMessage());
e.printStackTrace();
}
}
/**
* Метод запускает бесконечный цикл проверки обновлений в репозитарии.
*/
public void live(){
//
}
/**
* Метод проверяет, поступили ли обновления в репозитарий
* @return
*/
public boolean isUpdated(){
try {
Repository repo = RepoCrafter.copy(opt.getGitLink(), new File(opt.getGitLocalPath()));
System.out.println(repo.getConfig());
System.out.println(repo.getIndexFile());
Git git = new Git(repo);
//repo.close();
} catch (InvalidRemoteException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (TransportException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (GitAPIException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return true;
}
/**
* Извлечение данных из options.json
* @return
* @throws StreamReadException
* @throws DatabindException
* @throws IOException
*/
public Options readOptions() throws StreamReadException, DatabindException, IOException{
Options opt;
ObjectMapper mapper = new ObjectMapper();
opt = mapper.readValue(new File(optionsPath), Options.class);
return opt;
}
public Options getOpt() {
return opt;
}
/**
* распаковка архива
*/
public void extract()throws IOException{
//считываем настройки извлечения
try (ZipFile file = new ZipFile(opt.getZipPath())){
Enumeration<? extends ZipEntry> zipEntries = file.entries();
while (zipEntries.hasMoreElements()){
ZipEntry zipEntry = zipEntries.nextElement();
File newFile = new File(opt.getUnzipPath(), zipEntry.getName());
newFile.getParentFile().mkdirs();
if (!zipEntry.isDirectory()){
try (FileOutputStream outputStream = new FileOutputStream(newFile)){
BufferedInputStream inputStream = new BufferedInputStream(file.getInputStream(zipEntry));
while (inputStream.available() > 0){
outputStream.write(inputStream.read());
}
inputStream.close();
}
}
}
}
}
/**
* скачиваем архив проекта из системы контроля версий,
* или иной файл с другого ресурса ...
*/
public void download(){
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create(opt.getZipLink()))
.build();
try {
HttpResponse<Path> response = client.send(request,
HttpResponse.BodyHandlers.ofFileDownload(Path.of(opt.getDownloadPath()), StandardOpenOption.CREATE, StandardOpenOption.WRITE));
System.out.println(response.statusCode());
System.out.println(response.headers());
Path path = response.body();
System.out.println("Path = " + path);
} catch (Exception e) {
System.out.println(e.getMessage());
}
}
public static void main(String[] args) {
SourceListener ear = new SourceListener();
// try {
// ear.download();
// ear.extract();
// } catch (IOException e) {
// System.out.println(e.getMessage());
// }
ear.isUpdated();
}
}

13
src/main/java/ru/molokoin/sourceListener/RepoCrafter.java → src/main/java/ru/molokoin/sourceListener/git/RepoCrafter.java

@ -1,8 +1,7 @@
package ru.molokoin.sourceListener; package ru.molokoin.sourceListener.git;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.nio.file.Path;
import org.eclipse.jgit.api.Git; import org.eclipse.jgit.api.Git;
import org.eclipse.jgit.api.errors.GitAPIException; import org.eclipse.jgit.api.errors.GitAPIException;
@ -10,8 +9,6 @@ import org.eclipse.jgit.api.errors.InvalidRemoteException;
import org.eclipse.jgit.api.errors.TransportException; import org.eclipse.jgit.api.errors.TransportException;
import org.eclipse.jgit.lib.Repository; import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.storage.file.FileRepositoryBuilder; import org.eclipse.jgit.storage.file.FileRepositoryBuilder;
import org.eclipse.jgit.util.FileUtils;
public class RepoCrafter { public class RepoCrafter {
@ -36,10 +33,10 @@ public class RepoCrafter {
return repository; return repository;
} }
public static Repository copy(String gitLink, File localPath) throws IOException, InvalidRemoteException, TransportException, GitAPIException{ public static Repository copy(String gitLink, String localPath) throws IOException, InvalidRemoteException, TransportException, GitAPIException{
// prepare a new folder for the cloned repository // prepare a new folder for the cloned repository
//File localPath = new File(locationPath); File localFile = new File(localPath);
if(!localPath.delete()) { if(!localFile.delete()) {
throw new IOException("Could not delete temporary file " + localPath); throw new IOException("Could not delete temporary file " + localPath);
} }
@ -47,7 +44,7 @@ public class RepoCrafter {
System.out.println("Cloning from " + gitLink + " to " + localPath); System.out.println("Cloning from " + gitLink + " to " + localPath);
Git result = Git.cloneRepository() Git result = Git.cloneRepository()
.setURI(gitLink) .setURI(gitLink)
.setDirectory(localPath) .setDirectory(localFile)
//.setProgressMonitor(new SimpleProgressMonitor()) //.setProgressMonitor(new SimpleProgressMonitor())
.call(); .call();
// Note: the call() returns an opened repository already which needs to be closed to avoid file handle leaks! // Note: the call() returns an opened repository already which needs to be closed to avoid file handle leaks!

32
src/main/java/ru/molokoin/sourceListener/net/Service.java

@ -0,0 +1,32 @@
package ru.molokoin.sourceListener.net;
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.nio.file.Path;
import java.nio.file.StandardOpenOption;
public class Service {
/**
* Метод cкачивает файл c удаленного ресурса и размещает в указанной папке на локальном устройстве
* @param sourceLink
* @param localPath
*/
public static void download(String sourceLink, String localPath){
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create(sourceLink))
.build();
try {
HttpResponse<Path> response = client.send(request,
HttpResponse.BodyHandlers.ofFileDownload(Path.of(localPath), StandardOpenOption.CREATE, StandardOpenOption.WRITE));
System.out.println(response.statusCode());
System.out.println(response.headers());
Path path = response.body();
System.out.println("Path = " + path);
} catch (Exception e) {
System.out.println(e.getMessage());
}
}
}

2
src/main/java/ru/molokoin/sourceListener/Options.java → src/main/java/ru/molokoin/sourceListener/opt/Options.java

@ -1,4 +1,4 @@
package ru.molokoin.sourceListener; package ru.molokoin.sourceListener.opt;
public class Options { public class Options {
private String zipLink; private String zipLink;

BIN
target/classes/ru/molokoin/sourceListener/GitListener.class

Binary file not shown.

BIN
target/classes/ru/molokoin/sourceListener/RepoCrafter.class

Binary file not shown.

BIN
target/classes/ru/molokoin/sourceListener/SourceListener.class

Binary file not shown.

BIN
target/classes/ru/molokoin/sourceListener/git/RepoCrafter.class

Binary file not shown.

BIN
target/classes/ru/molokoin/sourceListener/net/Service.class

Binary file not shown.

BIN
target/classes/ru/molokoin/sourceListener/Options.class → target/classes/ru/molokoin/sourceListener/opt/Options.class

Binary file not shown.
Loading…
Cancel
Save