feat: add issue page branch creation feature via custom footer template and update deployment script UI

This commit is contained in:
Ümit Tunç
2026-04-27 17:53:20 +03:00
parent 5d7d939f93
commit 4c6f2f1ead
3 changed files with 115 additions and 9 deletions
+5
View File
@@ -0,0 +1,5 @@
{
"files.associations": {
"*.tmpl": "html"
}
}
+93
View File
@@ -0,0 +1,93 @@
<script>
console.log("osadasdk");
console.log("TruncGit Custom Hook: footer.tmpl loaded");
document.addEventListener('DOMContentLoaded', function () {
console.log("TruncGit Custom Hook: DOMContentLoaded");
// Sadece issue sayfalarında çalış
if (!window.location.pathname.includes('/issues/')) {
console.log("TruncGit: Not an issue page");
return;
}
const sidebar = document.querySelector('.issue-content-right.ui.segment') ||
document.querySelector('.issue-content-right') ||
document.querySelector('.issue-sidebar-column') ||
document.querySelector('.issue-sidebar') ||
document.querySelector('.ui.stackable.grid .four.wide.column');
if (!sidebar) {
console.log("TruncGit: Sidebar not found");
return;
}
const btnContainer = document.createElement('div');
btnContainer.className = 'item';
btnContainer.innerHTML = `
<div class="ui divider"></div>
<div class="ui segment" id="custom-branch-segment" style="padding: 10px; background: #f0fff4; border: 1px solid #c6f6d5;">
<h4 class="ui header" style="margin-bottom: 10px;">Quick Actions</h4>
<button class="ui green fluid button" id="custom-create-branch-btn">
<i class="octicon octicon-git-branch"></i>
Create Branch for Task
</button>
</div>
`;
sidebar.prepend(btnContainer);
document.getElementById('custom-create-branch-btn').addEventListener('click', function () {
const btn = this;
const issueId = window.location.pathname.split('/').pop();
const titleEl = document.querySelector('.issue-title-text') || document.querySelector('#issue-title') || document.querySelector('.title');
const issueTitle = titleEl ? titleEl.innerText.trim() : 'task';
let slug = issueTitle.toLowerCase()
.replace(/ç/g, 'c').replace(/ğ/g, 'g').replace(/ı/g, 'i')
.replace(/ö/g, 'o').replace(/ş/g, 's').replace(/ü/g, 'u')
.replace(/[^a-z0-9]+/g, '-')
.replace(/^-+|-+$/g, '');
const branchName = `issue-${issueId}-${slug}`;
btn.classList.add('loading', 'disabled');
const csrf = document.querySelector('meta[name="_csrf"]')?.content;
const repoPath = window.location.pathname.split('/').slice(1, 3).join('/');
fetch(`/api/v1/repos/${repoPath}`)
.then(r => r.json())
.then(repoData => {
const baseBranch = repoData.default_branch || 'master';
return fetch(`/api/v1/repos/${repoPath}/branches`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-Csrf-Token': csrf
},
body: JSON.stringify({
new_branch_name: branchName,
old_branch_name: baseBranch
})
});
})
.then(res => {
if (res.ok) {
window.location.reload();
} else {
return res.json().then(data => {
alert('Hata: ' + (data.message || 'Branch oluşturulamadı.'));
btn.classList.remove('loading', 'disabled');
});
}
})
.catch(err => {
console.error(err);
alert('Hata oluştu. Detaylar konsolda.');
btn.classList.remove('loading', 'disabled');
});
});
});
</script>
+17 -9
View File
@@ -1,5 +1,13 @@
#!/bin/bash
# Renk Tanımlamaları
GREEN='\033[0;32m'
BLUE='\033[0;34m'
CYAN='\033[0;36m'
YELLOW='\033[1;33m'
RED='\033[0;31m'
NC='\033[0m' # No Color
# Gitea Özelleştirme Uygulama Betiği
# Bu betik custom_files klasöründeki değişiklikleri canlı sisteme yansıtır.
@@ -7,11 +15,11 @@
USER_UID=$(grep USER_UID .env | cut -d '=' -f2 || echo 1003)
USER_GID=$(grep USER_GID .env | cut -d '=' -f2 || echo 1003)
echo "--- Gitea Özelleştirmeleri Uygulanıyor ---"
echo -e "${BLUE}--- TruncGit Özelleştirmeleri Uygulanıyor ---${NC}"
# 1. CSS Dosyasını Güncelle
if [ -f "./custom_files/css/custom.css" ]; then
echo "[+] CSS güncelleniyor..."
echo -e "${CYAN}[+] CSS güncelleniyor...${NC}"
mkdir -p ./data/gitea/public/assets/css
cp ./custom_files/css/custom.css ./data/gitea/public/assets/css/custom.css
chown $USER_UID:$USER_GID ./data/gitea/public/assets/css/custom.css
@@ -20,7 +28,7 @@ fi
# 2. Resim Dosyalarını Güncelle (Logo, Favicon vb.)
if [ -d "./custom_files/img" ]; then
echo "[+] Resimler güncelleniyor..."
echo -e "${CYAN}[+] Resimler güncelleniyor...${NC}"
mkdir -p ./data/gitea/public/assets/img
cp -r ./custom_files/img/* ./data/gitea/public/assets/img/
chown -R $USER_UID:$USER_GID ./data/gitea/public/assets/img
@@ -30,7 +38,7 @@ fi
# 3. Şablonları (Templates) Güncelle
if [ -d "./custom_files/templates" ]; then
echo "[+] Şablonlar güncelleniyor..."
echo -e "${CYAN}[+] Şablonlar güncelleniyor...${NC}"
mkdir -p ./data/gitea/templates
cp -r ./custom_files/templates/* ./data/gitea/templates/
chown -R $USER_UID:$USER_GID ./data/gitea/templates
@@ -38,14 +46,14 @@ fi
# 4. Yapılandırma (app.ini) Güncelle
if [ -f "./custom_files/conf/app.ini" ]; then
echo "[+] app.ini güncelleniyor..."
echo -e "${CYAN}[+] app.ini güncelleniyor...${NC}"
cp ./custom_files/conf/app.ini ./data/gitea/conf/app.ini
chown $USER_UID:$USER_GID ./data/gitea/conf/app.ini
chmod 600 ./data/gitea/conf/app.ini
fi
# 5. Gitea Servisini Onar ve Yeniden Baslat
echo "[+] Gitea servisi onariliyor ve yeniden baslatiliyor..."
echo -e "${YELLOW}[!] Gitea servisi onarılıyor ve yeniden başlatılıyor...${NC}"
docker compose down
sudo fuser -k -9 ./db/ibdata1 2>/dev/null
sudo rm -f ./db/ibdata1.lock
@@ -54,6 +62,6 @@ sudo rm -f ./db/*.pid
sudo chown -R 999:999 ./db
docker compose up -d
echo "--- İşlem Tamamlandı ---"
echo "Not: CSS ve Logo değişiklikleri anında yansır (Ctrl+F5 gerekebilir)."
echo "Not: app.ini ve Şablon değişiklikleri servis yeniden başladığı için aktif olmuştur."
echo -e "${GREEN}--- İşlem Başarıyla Tamamlandı ---${NC}"
echo -e "${BLUE}Not:${NC} CSS ve Logo değişiklikleri için ${YELLOW}Ctrl+F5${NC} gerekebilir."
echo -e "${BLUE}Not:${NC} Şablon değişiklikleri servis yeniden başladığı için aktif olmuştur."