mirror of
https://github.com/S2-/gitlit
synced 2025-08-02 20:30:05 +02:00
Compare commits
64 Commits
v1.2.0
...
dependabot
Author | SHA1 | Date | |
---|---|---|---|
![]() |
de716997cd | ||
44b4183597
|
|||
cfce0edaa9
|
|||
5edd143318
|
|||
e576161518
|
|||
7a63056ef3
|
|||
efd9d13454
|
|||
9836f5c918
|
|||
6c9787fea1
|
|||
16138409f9
|
|||
f604749ce8
|
|||
a259bd3e14
|
|||
e3ed1c6e44
|
|||
5d60c8baac
|
|||
8afc7fdac1
|
|||
e934617a03
|
|||
9f696e12f9
|
|||
b326c45593
|
|||
c905040f0e
|
|||
a171760bd6
|
|||
ce50a38e35
|
|||
133f72df2a
|
|||
bebaf95f70
|
|||
e719261427
|
|||
1fe4d0d90c
|
|||
9873246826
|
|||
b8a94f650f
|
|||
e97a5c1fc2
|
|||
3d020a3ddd
|
|||
8765f99f19
|
|||
cee594fcd9
|
|||
3c4d33eb83
|
|||
48b5f33eb9
|
|||
64b500f414
|
|||
caeaab14b8
|
|||
94e7c5ce71
|
|||
cdafb7a006
|
|||
6c2bc3397e
|
|||
a6666452d7
|
|||
e9feebce51
|
|||
510e4786b7
|
|||
b540eae1b9
|
|||
8f3705ba74
|
|||
e032eb2ab0
|
|||
519d719545
|
|||
f8076499ba
|
|||
edeadfd7fc
|
|||
9c26b8fb10
|
|||
b0f3ba27b5 | |||
99c858e5a7 | |||
9f02f5f27c | |||
48ecb505d7 | |||
a04c84abb4 | |||
31c19d5534 | |||
171b79e355 | |||
4178caa94a | |||
7cae3f33ec | |||
3952948a15 | |||
011a78a75f | |||
e0ad69a5b1 | |||
e994b98dcc | |||
6431183092 | |||
28acea0c74 | |||
f69e80e306 |
@@ -19,6 +19,8 @@ gitlit /home/s2/myApp
|
||||
|
||||
If no folder is specified, gitlit looks at the current path.
|
||||
|
||||
You can also drag&drop a folder inside the main window.
|
||||
|
||||
## contribute
|
||||
|
||||
The code is very easy. Just clone the repo and have look!
|
||||
@@ -43,6 +45,9 @@ npm install
|
||||
npm run dist
|
||||
```
|
||||
|
||||
## notes
|
||||
Since version 2.0.1 the app auto updates itself using the [github-app-updater](https://www.npmjs.com/package/github-app-updater).
|
||||
|
||||
## license
|
||||
|
||||
ISC
|
||||
|
@@ -1,3 +1,12 @@
|
||||
html {
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.jumbotron {
|
||||
height: 640px;
|
||||
margin-bottom: 0px;
|
||||
}
|
||||
|
||||
.js-container {
|
||||
margin: 5px;
|
||||
}
|
||||
@@ -40,3 +49,13 @@ table.sortable thead {
|
||||
table.sortable .sorttable_nosort {
|
||||
cursor: default;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* updater
|
||||
*/
|
||||
.updatenotice {
|
||||
position: fixed;
|
||||
bottom: 5px;
|
||||
right: 5px;
|
||||
}
|
||||
|
@@ -3,7 +3,6 @@
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>gitlit</title>
|
||||
|
||||
<script>if (typeof module === 'object') {window.module = module; module = undefined;}</script>
|
||||
|
||||
@@ -14,15 +13,16 @@
|
||||
<script type="text/javascript" src="../node_modules/pnotify/dist/iife/PNotifyButtons.js"></script>
|
||||
|
||||
<script type="text/javascript" src="../node_modules/ejs/ejs.js"></script>
|
||||
<script type="text/javascript" src="js/templates.js"></script>
|
||||
<script type="text/javascript" src="../node_modules/ejs-render-remote/ejs-render-remote.js"></script>
|
||||
<script type="text/javascript" src="js/sorttable.js"></script>
|
||||
|
||||
<link href="../node_modules/bootstrap/dist/css/bootstrap.css" rel="stylesheet">
|
||||
<link href="css/app.css" rel="stylesheet">
|
||||
</head>
|
||||
<body>
|
||||
<div class="js-container">
|
||||
</div>
|
||||
<div class="js-container"></div>
|
||||
<script src="js/index.js"></script>
|
||||
|
||||
<div class="js-updatenotice btn btn-warning btn-sm updatenotice" style="display:none" disabled>Update ready to install</div>
|
||||
</body>
|
||||
</html>
|
||||
|
@@ -2,27 +2,83 @@
|
||||
const ipcRenderer = require('electron').ipcRenderer;
|
||||
const remote = require('electron').remote;
|
||||
const electronFind = require('electron-find');
|
||||
const dialog = remote.require('electron').dialog;
|
||||
const shell = require('electron').shell;
|
||||
|
||||
let findInPage = new electronFind.FindInPage(remote.getCurrentWebContents());
|
||||
|
||||
let firstRun = true;
|
||||
|
||||
//events
|
||||
|
||||
//update stuff
|
||||
ipcRenderer.on('update', (event, state) => {
|
||||
if (state.event === 'updateAvailable') {
|
||||
$('.js-updatenotice').text(`New version ${state.version} available. Click here to download.`);
|
||||
$('.js-updatenotice').show();
|
||||
$('.js-updatenotice').prop('disabled', false);
|
||||
$('.js-updatenotice').prop('state', 'ready-to-download');
|
||||
$('.js-updatenotice').data('asset', state.asset);
|
||||
}
|
||||
|
||||
if (state.event === 'updateReadyToInstall') {
|
||||
$('.js-updatenotice').text(`New version ready to install. Click here to start installer.`);
|
||||
$('.js-updatenotice').show();
|
||||
$('.js-updatenotice').prop('disabled', false);
|
||||
$('.js-updatenotice').prop('state', 'ready-to-install');
|
||||
$('.js-updatenotice').data('file', state.file);
|
||||
}
|
||||
});
|
||||
|
||||
$(document).on('click', '.js-updatenotice', (ev) => {
|
||||
ev.preventDefault();
|
||||
if ($('.js-updatenotice').prop('disabled')) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ($('.js-updatenotice').prop('state') === 'ready-to-download') {
|
||||
$('.js-updatenotice').prop('disabled', true);
|
||||
$('.js-updatenotice').text(`Downloading new version...`);
|
||||
ipcRenderer.send('downloadUpdate', $('.js-updatenotice').data('asset'));
|
||||
} else if ($('.js-updatenotice').prop('state') === 'ready-to-install') {
|
||||
$('.js-updatenotice').prop('disabled', true);
|
||||
$('.js-updatenotice').text(`Launching installer...`);
|
||||
ipcRenderer.send('installUpdate', $('.js-updatenotice').data('file'));
|
||||
}
|
||||
});
|
||||
//end update stuff
|
||||
|
||||
|
||||
ipcRenderer.on('fileList', (event, files) => {
|
||||
firstRun = false;
|
||||
if (files && files.length > 0) {
|
||||
$('.files-table-container').html(gitlit.templates.files({files: files}));
|
||||
sorttable.makeSortable($('.js-filestable')[0]);
|
||||
var myTH = document.getElementsByTagName('th')[0];
|
||||
sorttable.innerSortFunction.apply(myTH, []);
|
||||
ejs.preloadTemplate('templates/files.ejs')
|
||||
.then(t => {
|
||||
$('.files-table-container').html(ejs.rr(t, {files: files}));
|
||||
sorttable.makeSortable($('.js-filestable')[0]);
|
||||
var myTH = document.getElementsByTagName('th')[0];
|
||||
sorttable.innerSortFunction.apply(myTH, []);
|
||||
});
|
||||
} else {
|
||||
$('.files-table-container').html(gitlit.templates.noGitLfsFiles());
|
||||
$('.files-table-container').html(ejs.rr('templates/noGitLfsFiles.ejs'));
|
||||
}
|
||||
});
|
||||
|
||||
ipcRenderer.on('repoDir', (event, repoDir) => {
|
||||
$('.js-container').html(gitlit.templates.main());
|
||||
$('.js-repo-dir').text('current repo dir: ' + repoDir).show();
|
||||
ejs.preloadTemplate('templates/main.ejs')
|
||||
.then(t => {
|
||||
$('.js-container').html(ejs.rr(t));
|
||||
$('.js-repo-dir').text('current repo dir: ' + repoDir).show();
|
||||
});
|
||||
});
|
||||
|
||||
ipcRenderer.on('isNoGitLfsRepo', (event, repoDir) => {
|
||||
$('.js-container').html(gitlit.templates.isNoGitLfsRepo({repoDir: repoDir}));
|
||||
if (firstRun) {
|
||||
firstRun = false;
|
||||
$('.js-container').html(ejs.rr('templates/firstRun.ejs', {repoDir: repoDir}));
|
||||
} else {
|
||||
$('.js-container').html(ejs.rr('templates/isNoGitLfsRepo.ejs', {repoDir: repoDir}));
|
||||
}
|
||||
});
|
||||
|
||||
ipcRenderer.on('notification', (event, notification) => {
|
||||
@@ -76,6 +132,24 @@
|
||||
window.location.reload(false);
|
||||
});
|
||||
|
||||
$(document).on('click', '.js-open-folder', (ev) => {
|
||||
ev.preventDefault();
|
||||
|
||||
dialog.showOpenDialog({
|
||||
properties: ['openDirectory']
|
||||
})
|
||||
.then((path) => {
|
||||
if (path && path.filePaths.length > 0) {
|
||||
ipcRenderer.send('restart', path.filePaths[0]);
|
||||
};
|
||||
});
|
||||
});
|
||||
|
||||
$(document).on('click', 'a[href^="http"]', function(event) {
|
||||
event.preventDefault();
|
||||
shell.openExternal(this.href);
|
||||
});
|
||||
|
||||
$(document).on('keypress', (ev) => {
|
||||
//ctrl + f
|
||||
if (ev.ctrlKey && ev.charCode == 6) {
|
||||
|
@@ -1,63 +0,0 @@
|
||||
window.gitlit = window.gitlit || {};
|
||||
gitlit.templates = {
|
||||
main: ejs.compile(`
|
||||
<div class="alert alert-success js-repo-dir" style="display:none;"></div>
|
||||
<div class="files-table-container">
|
||||
<div class="alert alert-primary" role="alert">
|
||||
Getting file list...
|
||||
</div>
|
||||
</div>
|
||||
`),
|
||||
files: ejs.compile(`
|
||||
<table class="table table-striped sortable js-filestable">
|
||||
<thead class="thead-light">
|
||||
<tr>
|
||||
<th>file</th>
|
||||
<th>status</th>
|
||||
<th class="sorttable_nosort">action</th>
|
||||
</tr>
|
||||
<thead>
|
||||
|
||||
<tbody>
|
||||
<% files.forEach((file) => { %>
|
||||
<tr>
|
||||
<td><%= file.file %></td>
|
||||
<td><%= file.lockedBy ? file.lockedBy + ' (id: ' + file.id + ')' : 'not locked' %></td>
|
||||
<td>
|
||||
<a class="btn btn-primary btn-sm js-lock"
|
||||
href="javascript:///"
|
||||
data-file="<%= file.file %>"
|
||||
style="<%= file.lockedBy ? 'display: none;' : '' %>"
|
||||
>
|
||||
Lock
|
||||
</a>
|
||||
<a class="btn btn-danger btn-sm js-unlock"
|
||||
href="javascript:///"
|
||||
data-file="<%= file.file %>"
|
||||
style="<%= file.lockedBy ? '' : 'display: none;' %>"
|
||||
>
|
||||
Unlock
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
<% }); %>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<div class="float-right">
|
||||
<a class="btn btn-secondary btn-sm js-refresh" href="javascript:///">
|
||||
Refresh
|
||||
</a>
|
||||
</div>
|
||||
`),
|
||||
isNoGitLfsRepo: ejs.compile(`
|
||||
<div class="alert alert-danger">
|
||||
<%= repoDir %> is not a git lfs repo.
|
||||
</div>
|
||||
`),
|
||||
noGitLfsFiles: ejs.compile(`
|
||||
<div class="alert alert-info">
|
||||
no files tracked with lfs here.
|
||||
</div>
|
||||
`)
|
||||
};
|
67
app/main.js
67
app/main.js
@@ -3,6 +3,7 @@ const path = require('path');
|
||||
const url = require('url');
|
||||
const electronLocalshortcut = require('electron-localshortcut');
|
||||
const exec = require('child_process').exec;
|
||||
const gau = require('github-app-updater');
|
||||
const args = require('minimist')(process.defaultApp ? process.argv.slice(3) : process.argv.slice(1), {
|
||||
default: {
|
||||
_: process.cwd()
|
||||
@@ -13,9 +14,49 @@ let win;
|
||||
let repoDir = path.resolve(path.normalize(args._.join(' ')));
|
||||
let repoRootDir = repoDir;
|
||||
|
||||
//auto update stuff
|
||||
if (process.platform === 'win32') {
|
||||
setTimeout(() => {
|
||||
gau.checkForUpdate({
|
||||
currentVersion: app.getVersion(),
|
||||
repo: 'https://api.github.com/repos/S2-/gitlit/releases/latest',
|
||||
assetMatch: /.+setup.+exe/i
|
||||
});
|
||||
|
||||
gau.onUpdateAvailable = (version, asset) => {
|
||||
win.webContents.send('update', {
|
||||
event: 'updateAvailable',
|
||||
version: version,
|
||||
asset: asset
|
||||
});
|
||||
};
|
||||
|
||||
gau.onNewVersionReadyToInstall = (file) => {
|
||||
win.webContents.send('update', {
|
||||
event: 'updateReadyToInstall',
|
||||
file: file
|
||||
});
|
||||
};
|
||||
|
||||
ipcMain.on('downloadUpdate', (event, asset) => {
|
||||
gau.downloadNewVersion(asset);
|
||||
});
|
||||
|
||||
ipcMain.on('installUpdate', (event, file) => {
|
||||
gau.executeUpdate(file);
|
||||
win.webContents.send('update', {
|
||||
event: 'updateInstalling'
|
||||
});
|
||||
app.quit();
|
||||
});
|
||||
}, 5000);
|
||||
}
|
||||
|
||||
//end update stuff
|
||||
|
||||
function getLfsFileList(dir, cb) {
|
||||
exec('git ls-files | git check-attr --stdin lockable', {
|
||||
maxBuffer: 1024 * 1024,
|
||||
maxBuffer: (1024 * 1024) * 10, //10MB
|
||||
cwd: dir
|
||||
},
|
||||
(error, stdout, stderr) => {
|
||||
@@ -47,7 +88,7 @@ function getLfsFileList(dir, cb) {
|
||||
|
||||
function getLfsLocks(dir, cb) {
|
||||
exec('git lfs locks', {
|
||||
maxBuffer: 1024 * 1024,
|
||||
maxBuffer: (1024 * 1024) * 10, //10MB
|
||||
cwd: dir
|
||||
},
|
||||
(error, stdout, stderr) => {
|
||||
@@ -126,7 +167,15 @@ function loadRepoPage() {
|
||||
|
||||
function createWindow() {
|
||||
// Create the browser window.
|
||||
win = new BrowserWindow({width: 800, height: 600});
|
||||
win = new BrowserWindow({
|
||||
title: 'gitlit v' + app.getVersion(),
|
||||
width: 800,
|
||||
height: 700,
|
||||
webPreferences: {
|
||||
nodeIntegration: true,
|
||||
enableRemoteModule: true
|
||||
}
|
||||
});
|
||||
win.setMenu(null);
|
||||
|
||||
// and load the index.html of the app.
|
||||
@@ -147,7 +196,7 @@ function createWindow() {
|
||||
|
||||
function startup(cb) {
|
||||
exec('git rev-parse --show-toplevel', {
|
||||
maxBuffer: 1024 * 1024,
|
||||
maxBuffer: (1024 * 1024) * 10, //10MB
|
||||
cwd: repoDir
|
||||
},
|
||||
(error, stdout, stderr) => {
|
||||
@@ -170,7 +219,7 @@ function startup(cb) {
|
||||
|
||||
ipcMain.on('unlock', (event, file) => {
|
||||
exec('git lfs unlock "' + file + '"', {
|
||||
maxBuffer: 1024 * 1024,
|
||||
maxBuffer: (1024 * 1024) * 10, //10MB
|
||||
cwd: repoDir
|
||||
},
|
||||
(error, stdout, stderr) => {
|
||||
@@ -193,7 +242,7 @@ ipcMain.on('unlock', (event, file) => {
|
||||
|
||||
ipcMain.on('lock', (event, file) => {
|
||||
exec('git lfs lock --json "' + file + '"', {
|
||||
maxBuffer: 1024 * 1024,
|
||||
maxBuffer: (1024 * 1024) * 10, //10MB
|
||||
cwd: repoDir
|
||||
},
|
||||
(error, stdout, stderr) => {
|
||||
@@ -223,9 +272,3 @@ ipcMain.on('restart', (event, newRepoDir) => {
|
||||
app.on('ready', () => {
|
||||
startup(createWindow);
|
||||
});
|
||||
|
||||
app.on('window-all-closed', function() {
|
||||
if (process.platform != 'darwin') {
|
||||
app.quit();
|
||||
}
|
||||
});
|
||||
|
44
app/templates/files.ejs
Normal file
44
app/templates/files.ejs
Normal file
@@ -0,0 +1,44 @@
|
||||
<table class="table table-striped sortable js-filestable">
|
||||
<thead class="thead-light">
|
||||
<tr>
|
||||
<th>file</th>
|
||||
<th>status</th>
|
||||
<th class="sorttable_nosort">action</th>
|
||||
</tr>
|
||||
<thead>
|
||||
|
||||
<tbody>
|
||||
<% files.forEach((file) => { %>
|
||||
<tr>
|
||||
<td><%= file.file %></td>
|
||||
<td><%= file.lockedBy ? file.lockedBy + ' (id: ' + file.id + ')' : 'not locked' %></td>
|
||||
<td>
|
||||
<a class="btn btn-primary btn-sm js-lock"
|
||||
href="javascript:///"
|
||||
data-file="<%= file.file %>"
|
||||
style="<%= file.lockedBy ? 'display: none;' : '' %>"
|
||||
>
|
||||
Lock
|
||||
</a>
|
||||
<a class="btn btn-danger btn-sm js-unlock"
|
||||
href="javascript:///"
|
||||
data-file="<%= file.file %>"
|
||||
style="<%= file.lockedBy ? '' : 'display: none;' %>"
|
||||
>
|
||||
Unlock
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
<% }); %>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<div class="float-right">
|
||||
<div style="display: inline;">
|
||||
<a class="btn btn-primary btn-sm js-open-folder" href="javascript:///">Open another folder</a>
|
||||
<input type="file" style="display: none" class="js-open-folder-input" webkitdirectory />
|
||||
</div>
|
||||
<a class="btn btn-secondary btn-sm js-refresh" href="javascript:///">
|
||||
Refresh
|
||||
</a>
|
||||
</div>
|
12
app/templates/firstRun.ejs
Normal file
12
app/templates/firstRun.ejs
Normal file
@@ -0,0 +1,12 @@
|
||||
<div class="jumbotron text-center">
|
||||
<img src="../logo/logo.png">
|
||||
<h1>gitlit</h1>
|
||||
<p class="lead">Handle git lfs locks with ease</p>
|
||||
<div class="text-center">
|
||||
<a class="btn btn-primary btn-lg js-open-folder" href="javascript:///">Open git repository folder</a>
|
||||
<input type="file" style="display: none" class="js-open-folder-input" webkitdirectory />
|
||||
</div>
|
||||
<p>
|
||||
<a href="https://github.com/S2-/gitlit">Homepage</a>
|
||||
</p>
|
||||
</div>
|
4
app/templates/isNoGitLfsRepo.ejs
Normal file
4
app/templates/isNoGitLfsRepo.ejs
Normal file
@@ -0,0 +1,4 @@
|
||||
<div class="alert alert-danger">
|
||||
<%= repoDir %> is not a git lfs repo.
|
||||
</div>
|
||||
<%- ejs.rr('templates/openFolder.ejs') %>
|
6
app/templates/main.ejs
Normal file
6
app/templates/main.ejs
Normal file
@@ -0,0 +1,6 @@
|
||||
<div class="alert alert-success js-repo-dir" style="display:none;"></div>
|
||||
<div class="files-table-container">
|
||||
<div class="alert alert-primary" role="alert">
|
||||
Getting file list...
|
||||
</div>
|
||||
</div>
|
4
app/templates/noGitLfsFiles.ejs
Normal file
4
app/templates/noGitLfsFiles.ejs
Normal file
@@ -0,0 +1,4 @@
|
||||
<div class="alert alert-info">
|
||||
no files tracked with lfs here.
|
||||
</div>
|
||||
<%- ejs.rr('templates/openFolder.ejs') %>
|
3
app/templates/openFolder.ejs
Normal file
3
app/templates/openFolder.ejs
Normal file
@@ -0,0 +1,3 @@
|
||||
<div class="text-center">
|
||||
<a class="btn btn-primary js-open-folder" href="javascript:///">Open another folder</a>
|
||||
</div>
|
3564
package-lock.json
generated
3564
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
28
package.json
28
package.json
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "gitlit",
|
||||
"version": "1.2.0",
|
||||
"version": "2.0.16",
|
||||
"description": "",
|
||||
"main": "app/main.js",
|
||||
"build": {
|
||||
@@ -27,26 +27,28 @@
|
||||
}
|
||||
},
|
||||
"dependencies": {
|
||||
"animate.css": "^3.5.2",
|
||||
"bootstrap": "^4.1.3",
|
||||
"ejs": "^2.6.1",
|
||||
"animate.css": "^4.1.1",
|
||||
"bootstrap": "^4.6.0",
|
||||
"ejs": "^3.1.6",
|
||||
"ejs-render-remote": "^1.0.13",
|
||||
"electron-find": "^1.0.6",
|
||||
"electron-localshortcut": "^3.1.0",
|
||||
"jquery": "^3.3.1",
|
||||
"electron-localshortcut": "^3.2.1",
|
||||
"github-app-updater": "^1.0.5",
|
||||
"jquery": "^3.6.0",
|
||||
"material-design-icons": "^3.0.1",
|
||||
"minimist": "^1.2.0",
|
||||
"minimist": "^1.2.5",
|
||||
"nonblockjs": "^1.0.8",
|
||||
"pnotify": "^4.0.0-alpha.4",
|
||||
"popper.js": "^1.14.3"
|
||||
"pnotify": "^4.0.1",
|
||||
"popper.js": "^1.16.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"electron": "^3.0.3",
|
||||
"electron-builder": "^20.43.0"
|
||||
"electron": "^13.1.2",
|
||||
"electron-builder": "^22.11.7"
|
||||
},
|
||||
"scripts": {
|
||||
"start": "electron .",
|
||||
"pack": "electron-builder --linux --win --dir",
|
||||
"dist": "electron-builder --linux --win"
|
||||
"pack": "electron-builder --linux --win portable nsis --dir --publish=never",
|
||||
"dist": "electron-builder --linux --win portable nsis --publish=never"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
Reference in New Issue
Block a user