Upload per ZIP-Tool (1/1)
This commit is contained in:
1 parent
25d5da1419
commit
36dc2acaae
2 files changed
+99
-3
No files matched your search
@@ -17,6 +17,9 @@ Gitea-Server kommuniziert.
|
||||
beim Hochladen übersprungen (auch dann nicht gelöscht, wenn "Dateien löschen, die nicht mehr in der ZIP
|
||||
enthalten sind" aktiv ist).
|
||||
4. Commit-Nachricht anpassen (optional) und "Jetzt hochladen" klicken.
|
||||
5. Optional: Unter "Release erstellen" Tag, Titel und Beschreibung eintragen, die gewählte ZIP
|
||||
und/oder weitere Dateien als Anhang auswählen und "Release erstellen" klicken. Das geht auch
|
||||
unabhängig vom Hochladen, sobald ein Repo gewählt ist.
|
||||
|
||||
Vorhandene Dateien mit gleichem Pfad werden aktualisiert statt doppelt
|
||||
angelegt. Über die Checkbox "Dateien im Repo löschen, die nicht mehr in
|
||||
|
||||
+96
-3
@@ -30,11 +30,12 @@
|
||||
.card .step-num{display:inline-flex;align-items:center;justify-content:center;width:22px;height:22px;
|
||||
border-radius:50%;background:var(--accent);color:#111;font-size:.8rem;font-weight:700;margin-right:8px;}
|
||||
label{display:block;font-size:.85rem;color:var(--muted);margin:12px 0 4px;}
|
||||
input[type=text],input[type=password],input[type=url],select{
|
||||
input[type=text],input[type=password],input[type=url],select,textarea{
|
||||
width:100%;padding:9px 10px;border:1px solid var(--border);border-radius:6px;font-size:.93rem;
|
||||
background:var(--panel-alt);color:var(--text);
|
||||
}
|
||||
input::placeholder{color:#5b5f66;}
|
||||
input::placeholder,textarea::placeholder{color:#5b5f66;}
|
||||
textarea{font-family:inherit;resize:vertical;}
|
||||
input[type=checkbox]{margin-right:6px;accent-color:var(--accent);}
|
||||
.checkline{display:flex;align-items:center;font-size:.85rem;color:var(--muted);margin-top:10px;}
|
||||
.row{display:flex;gap:12px;flex-wrap:wrap;}
|
||||
@@ -170,6 +171,30 @@
|
||||
<div id="log"></div>
|
||||
</div>
|
||||
|
||||
<div class="card disabled-section" id="releaseCard">
|
||||
<h2><span class="step-num">5</span>Release erstellen (optional)</h2>
|
||||
<p class="hint">Legt zum gewählten Repo ein Release an und hängt auf Wunsch Dateien daran. Unabhängig vom Hochladen oben nutzbar.</p>
|
||||
<div class="row">
|
||||
<div>
|
||||
<label for="relTag">Tag</label>
|
||||
<input type="text" id="relTag" placeholder="v1.0.0">
|
||||
</div>
|
||||
<div>
|
||||
<label for="relName">Titel</label>
|
||||
<input type="text" id="relName" placeholder="Version 1.0.0">
|
||||
</div>
|
||||
</div>
|
||||
<label for="relBody">Beschreibung</label>
|
||||
<textarea id="relBody" rows="4" placeholder="Was ist neu?"></textarea>
|
||||
<label class="checkline"><input type="checkbox" id="relUseZip"> Die in Schritt 3 gewählte ZIP-Datei als Anhang hochladen</label>
|
||||
<label for="relFiles">Weitere Dateien als Anhang</label>
|
||||
<input type="file" id="relFiles" multiple>
|
||||
<label class="checkline"><input type="checkbox" id="relDraft"> Als Entwurf speichern (noch nicht veröffentlicht)</label>
|
||||
<label class="checkline"><input type="checkbox" id="relPre"> Als Vorabversion markieren</label>
|
||||
<button id="btnRelease">Release erstellen</button>
|
||||
<div id="releaseStatus" class="status"></div>
|
||||
</div>
|
||||
|
||||
</main>
|
||||
|
||||
<footer>
|
||||
@@ -192,6 +217,7 @@
|
||||
<li>Konto/Organisation wählen, dann ein vorhandenes Repo auswählen <strong>oder</strong> einen neuen Namen eingeben und "Repo erstellen".</li>
|
||||
<li>ZIP-Datei auswählen. Enthält sie einen einzelnen umschließenden Ordner, wird der auf Wunsch automatisch entfernt.</li>
|
||||
<li>Commit-Nachricht anpassen (optional) und "Jetzt hochladen" klicken.</li>
|
||||
<li>Optional: Unter "Release erstellen" Tag, Titel und Beschreibung eintragen, Dateien als Anhang wählen und ein Release anlegen.</li>
|
||||
</ol>
|
||||
<p>Dateien mit gleichem Pfad wie im Repo werden aktualisiert statt doppelt angelegt. Über
|
||||
"Zugangsdaten in diesem Browser speichern" (Einstellungen, Zahnrad oben rechts) müssen Server,
|
||||
@@ -397,6 +423,7 @@
|
||||
}
|
||||
state.repo = null;
|
||||
disable("zipCard");
|
||||
disable("releaseCard");
|
||||
}
|
||||
|
||||
el("ownerSelect").addEventListener("change", function(){
|
||||
@@ -406,11 +433,12 @@
|
||||
|
||||
el("repoSelect").addEventListener("change", function(){
|
||||
var i = this.value;
|
||||
if(i === ""){ state.repo = null; disable("zipCard"); return; }
|
||||
if(i === ""){ state.repo = null; disable("zipCard"); disable("releaseCard"); return; }
|
||||
var r = state.repos[i];
|
||||
state.repo = { owner: r.owner.login, name: r.name, defaultBranch: r.default_branch || "main" };
|
||||
setStatus("repoStatus", "Ausgewählt: " + r.full_name + " (Branch: " + state.repo.defaultBranch + ")", "ok");
|
||||
enable("zipCard");
|
||||
enable("releaseCard");
|
||||
});
|
||||
|
||||
// ---- Schritt 2: Neues Repo erstellen ----
|
||||
@@ -441,6 +469,7 @@
|
||||
el("zipFile").addEventListener("change", async function(){
|
||||
var file = this.files[0];
|
||||
if(!file) return;
|
||||
state.zipFile = file;
|
||||
setStatus("zipStatus", "Lese ZIP...", "");
|
||||
try{
|
||||
var zip = await JSZip.loadAsync(file);
|
||||
@@ -587,6 +616,70 @@
|
||||
}
|
||||
});
|
||||
|
||||
// ---- Schritt 5: Release erstellen ----
|
||||
el("btnRelease").addEventListener("click", async function(){
|
||||
if(!state.repo){ setStatus("releaseStatus", "Bitte zuerst ein Repo wählen.", "err"); return; }
|
||||
var tag = el("relTag").value.trim();
|
||||
if(!tag){ setStatus("releaseStatus", "Bitte einen Tag eingeben, z.B. v1.0.0.", "err"); return; }
|
||||
var btn = el("btnRelease");
|
||||
btn.disabled = true;
|
||||
var base = "/api/v1/repos/" + state.repo.owner + "/" + state.repo.name + "/releases";
|
||||
var rel = null;
|
||||
try{
|
||||
setStatus("releaseStatus", "Erstelle Release...", "");
|
||||
rel = await apiFetch(base, {
|
||||
method: "POST",
|
||||
body: JSON.stringify({
|
||||
tag_name: tag,
|
||||
target_commitish: state.repo.defaultBranch,
|
||||
name: el("relName").value.trim() || tag,
|
||||
body: el("relBody").value,
|
||||
draft: el("relDraft").checked,
|
||||
prerelease: el("relPre").checked
|
||||
})
|
||||
});
|
||||
|
||||
var files = [];
|
||||
if(el("relUseZip").checked && state.zipFile) files.push(state.zipFile);
|
||||
Array.prototype.forEach.call(el("relFiles").files, function(f){ files.push(f); });
|
||||
|
||||
for(var i = 0; i < files.length; i++){
|
||||
setStatus("releaseStatus", "Lade Anhang " + (i+1) + " von " + files.length + ": " + files[i].name, "");
|
||||
var fd = new FormData();
|
||||
fd.append("attachment", files[i], files[i].name);
|
||||
// Kein Content-Type setzen: der Browser ergänzt Multipart-Grenze selbst
|
||||
var res = await fetch(apiUrl(base + "/" + rel.id + "/assets?name=" + encodeURIComponent(files[i].name)), {
|
||||
method: "POST",
|
||||
headers: { "Authorization": state.authHeader },
|
||||
body: fd
|
||||
});
|
||||
if(!res.ok){
|
||||
var msg = "HTTP " + res.status;
|
||||
try{ var b = await res.json(); if(b && b.message) msg += ": " + b.message; }catch(e){}
|
||||
throw new Error("Anhang '" + files[i].name + "' fehlgeschlagen (" + msg + ")");
|
||||
}
|
||||
}
|
||||
|
||||
var out = el("releaseStatus");
|
||||
out.className = "status ok";
|
||||
out.textContent = "Release '" + tag + "' erstellt" + (files.length ? " mit " + files.length + " Anhang/Anhängen" : "") + ". ";
|
||||
if(rel.html_url){
|
||||
var a = document.createElement("a");
|
||||
a.href = rel.html_url;
|
||||
a.target = "_blank";
|
||||
a.rel = "noopener";
|
||||
a.style.color = "var(--accent)";
|
||||
a.textContent = "Im Browser öffnen";
|
||||
out.appendChild(a);
|
||||
}
|
||||
}catch(e){
|
||||
var hint = rel ? " Das Release selbst wurde bereits angelegt, den Rest bitte in Gitea ergänzen." : "";
|
||||
setStatus("releaseStatus", "Fehler: " + e.message + hint, "err");
|
||||
}finally{
|
||||
btn.disabled = false;
|
||||
}
|
||||
});
|
||||
|
||||
})();
|
||||
</script>
|
||||
</body>
|
||||
|
||||
Reference in new issue
Block a user