Skip to content

Commit

Permalink
p3x-robot sunday release 2018-5-23 02:09:22
Browse files Browse the repository at this point in the history
  • Loading branch information
p3x-robot committed May 23, 2018
1 parent d049c45 commit ee93692
Show file tree
Hide file tree
Showing 14 changed files with 179 additions and 46 deletions.
2 changes: 1 addition & 1 deletion INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ UrlToolkit {

---

[**P3X-GITLIST**](https://pages.corifeus.com/gitlist) Build v2.7.79-796
[**P3X-GITLIST**](https://pages.corifeus.com/gitlist) Build v2.8.0

[![Like Corifeus @ Facebook](https://img.shields.io/badge/LIKE-Corifeus-3b5998.svg)](https://www.facebook.com/corifeus.software) [![Donate for Corifeus / P3X](https://img.shields.io/badge/Donate-Corifeus-003087.svg)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=QZVM4V6HVZJW6) [![Contact Corifeus / P3X](https://img.shields.io/badge/Contact-P3X-ff9900.svg)](https://www.patrikx3.com/en/front/contact)

Expand Down
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@



# 🤖 P3X Gitlist v2.7.79-796
# 🤖 P3X Gitlist v2.8.0

This is an open-source project. Star this repository if you like it, or even donate! Thank you so much! :)

Expand Down Expand Up @@ -51,6 +51,10 @@ https://github.com/patrikx3/gitlist/releases
You might need to tune your web server, to only parse the `public/index.php` PHP script, so you can view your `php` files in `P3X GitList`.

#### PHP Memory

**By now, I am loading the diffs via `AJAX`. I render in the browser the diffs even deffered. For a huge commit `twig` rendered the `PHP` using over `512MB`, now it works with `128MB`. The browser does not hang anymore.**

##### This what it was before ...
It is possible, that some big commits are huge and for now, it loads everything. In `V3`, everything will be `lazy`, but looks like I had a huge commit and I had to set my `PHP.ini` had to change like:
```text
max_execution_time = 240
Expand Down Expand Up @@ -166,7 +170,7 @@ npm run watch

---

[**P3X-GITLIST**](https://pages.corifeus.com/gitlist) Build v2.7.79-796
[**P3X-GITLIST**](https://pages.corifeus.com/gitlist) Build v2.8.0

[![Like Corifeus @ Facebook](https://img.shields.io/badge/LIKE-Corifeus-3b5998.svg)](https://www.facebook.com/corifeus.software) [![Donate for Corifeus / P3X](https://img.shields.io/badge/Donate-Corifeus-003087.svg)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=QZVM4V6HVZJW6) [![Contact Corifeus / P3X](https://img.shields.io/badge/Contact-P3X-ff9900.svg)](https://www.patrikx3.com/en/front/contact)

Expand Down
2 changes: 1 addition & 1 deletion artifacts/php-7.2-ubuntu.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ sudo apt upgrade -y

---

[**P3X-GITLIST**](https://pages.corifeus.com/gitlist) Build v2.7.79-796
[**P3X-GITLIST**](https://pages.corifeus.com/gitlist) Build v2.8.0

[![Like Corifeus @ Facebook](https://img.shields.io/badge/LIKE-Corifeus-3b5998.svg)](https://www.facebook.com/corifeus.software) [![Donate for Corifeus / P3X](https://img.shields.io/badge/Donate-Corifeus-003087.svg)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=QZVM4V6HVZJW6) [![Contact Corifeus / P3X](https://img.shields.io/badge/Contact-P3X-ff9900.svg)](https://www.patrikx3.com/en/front/contact)

Expand Down
2 changes: 1 addition & 1 deletion changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ require('codemirror/mode/yaml/yaml');

---

[**P3X-GITLIST**](https://pages.corifeus.com/gitlist) Build v2.7.79-796
[**P3X-GITLIST**](https://pages.corifeus.com/gitlist) Build v2.8.0

[![Like Corifeus @ Facebook](https://img.shields.io/badge/LIKE-Corifeus-3b5998.svg)](https://www.facebook.com/corifeus.software) [![Donate for Corifeus / P3X](https://img.shields.io/badge/Donate-Corifeus-003087.svg)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=QZVM4V6HVZJW6) [![Contact Corifeus / P3X](https://img.shields.io/badge/Contact-P3X-ff9900.svg)](https://www.patrikx3.com/en/front/contact)

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "p3x-gitlist",
"version": "2.7.80-796",
"version": "2.8.1-802",
"corifeus": {
"prod-dir": "prod",
"postfix": "b404f41f3eec7159ae91174f26b33b3023b42c4046ca146c927e9ee0787fc06a",
Expand Down
25 changes: 25 additions & 0 deletions src/GitList/Controller/CommitController.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,31 @@ public function connect(Application $app)
$commit = $repository->getCommit($commit);
$branch = $repository->getHead();

if($app['request_stack']->getCurrentRequest()->isXmlHttpRequest()) {
$diffsInstance = $commit->getDiffs();
$diffs = [];
foreach($diffsInstance as $diffInstance) {
$lines = [];
foreach ($diffInstance->getLines() as $lineInstance) {
$lines[] = (object)[
'type' => $lineInstance->getType(),
'num-old' => $lineInstance->getNumOld(),
'num-new' => $lineInstance->getNumNew(),
'line' => $lineInstance->getLine(),
];
}
$diffs[] = (object)[
'file' => $diffInstance->getFile(),
'old' => $diffInstance->getOld(),
'new' => $diffInstance->getNew(),
'index' => $diffInstance->getIndex(),
'lines' => $lines,
];
}
return $app->json($diffs);
};


return $app['twig']->render('commit.twig', array(
'branches' => $repository->getBranches(),
'tags' => $repository->getTags(),
Expand Down
3 changes: 3 additions & 0 deletions src/Gitter/Model/Commit/Commit.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
namespace Gitter\Model\Commit;

use Gitter\Model\Item;
use Gitter\Model\Diff;
use Gitter\Util\DateTime;

class Commit extends Item
Expand All @@ -25,6 +26,8 @@ class Commit extends Item
protected $commiterDate;
protected $message;
protected $body;

/** @var Diff[] */
protected $diffs;

public function importData(array $data)
Expand Down
1 change: 1 addition & 0 deletions src/Gitter/Model/Commit/Diff.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

class Diff extends AbstractModel
{
/** @var DiffLine[] */
protected $lines;
protected $index;
protected $old;
Expand Down
91 changes: 91 additions & 0 deletions src/browser/js/commit.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,107 @@ $(() => {

let deferScroll;
if (diffEditors) {

const generatedDiffs = {};
const generatedDiffsGenerated = {};
const waiter = 10;
let timeout = 10;

$.snackbar({
htmlAllowed: true,
content: `Hang on, loading and rendering diffs deffered via AJAX...`,
timeout: window.gitlist.snapckbarLongTimeout,
})

$.ajax(location).then((diffs) => {
let index = 0;
for(let diff of diffs) {

/*
<table>
{% for line in diff.getLines %}
<tr>
<td class="lineNo">
{% if line.getType != 'chunk' %}
<!-- <a id="{{ diff.index | to_id }}L{{ loop.index }}R{{ line.getNumOld }}"></a> -->
<!-- <a href="#{{ diff.index | to_id }}L{{ loop.index }}R{{ line.getNumOld }}"> -->
{% endif %}
{{ line.getNumOld }}
{% if line.getType != 'chunk' %}
<!-- </a> -->
{% endif %}
</td>
<td class="lineNo">
{% if line.getType != 'chunk' %}
<!-- <a id="{{ diff.index | to_id }}L{{ loop.index }}L{{ line.getNumNew }}"></a> -->
<!-- <a href="#{{ diff.index | to_id }}L{{ loop.index }}L{{ line.getNumNew }}"> -->
{% endif %}
{{ line.getNumNew }}
{% if line.getType != 'chunk' %}
<!-- </a> -->
{% endif %}
</td>
<td style="width: 100%">
<pre{% if line.getType %} class="{{ line.getType }}"{% endif %}>{{ line.getLine }}</pre>
</td>
</tr>
{% endfor %}
</table>
*/
setTimeout(() => {
index++;
let html = '';
html += '<table>';
for(let line of diff.lines) {
// console.log(line)
html += `
<tr>
<td class="lineNo">
${line['num-old']}
</td>
<td class="lineNo">
${line['num-new']}
</td>
<td style="width: 100%">
<pre class="${line.type}">${htmlEncode(line.line)}</pre>
</td>
</tr>
`;
}
html += '</table>';
// console.log(index);
generatedDiffs[index] = html;
console.log(`P3X-GITLIST loading via AJAX and rendering diffs deffered - ${index}`)
}, timeout)
timeout += waiter;
}
}).catch(window.gitlist.ajaxErrorHandler)

for (let diffEditor of diffEditors) {
const $editableHover = $('#' + diffEditor.dataset.diffId);
// console.log(diffEditor.dataset.diffId)
const $diffEditor = $(diffEditor);
$editableHover.on
('click', () => {
clearTimeout(deferScroll)
setTimeout(() => {
//window.gitlist.scrollIntoView(document.getElementById(diffEditor.dataset.diffRef))
window.gitlist.pushHash(`#${diffEditor.dataset.diffRef}`)
const index = diffEditor.dataset.diffIndex;
//console.log(diffEditor)
const showDiff = () => {
if (!generatedDiffs.hasOwnProperty(index)) {
clearTimeout(diffEditor.timeout)
diffEditor.timeout = setTimeout(showDiff, 250);
} else if (!generatedDiffsGenerated.hasOwnProperty()) {
const $div = $(`#p3x-gitlist-diff-ajax-${index}`)
$div.html(generatedDiffs[index])
generatedDiffsGenerated[index] = true;
}
}
showDiff();
$diffEditor.toggle();
$editableHover.toggleClass('active');
}, 0)
Expand Down
10 changes: 2 additions & 8 deletions src/browser/js/file.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,14 +107,8 @@ ${branchInfo}
let filename = window.gitlist.getPaths();
filename = filename.slice(4).join('/');

const errorHandler = (e) => {
$.snackbar({
htmlAllowed: true,
content: e.message,
timeout: window.gitlist.snapckbarLongTimeout,
})
console.error(e);
}

const errorHandler = window.gitlist.ajaxErrorHandler;


const commitModal = $('#p3x-gitlist-modal-commit');
Expand Down
9 changes: 9 additions & 0 deletions src/browser/js/global.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,15 @@ window.gitlist.validate = {
}
*/

window.gitlist.ajaxErrorHandler = (e) => {
$.snackbar({
htmlAllowed: true,
content: e.message,
timeout: window.gitlist.snapckbarLongTimeout,
})
console.error(e);
}

window.gitlist.getPaths = () => {
const currentUrl = new URL(window.location)
if (window.gitlist.basepath !== '') {
Expand Down
36 changes: 5 additions & 31 deletions src/twig/commit.twig
Original file line number Diff line number Diff line change
Expand Up @@ -85,37 +85,11 @@
<div style="clear: both;"></div>
</li>
<li class="list-group-item p3x-gitlist-diff-container" data-diff-ref="p3x-gitlist-diff-{{ loop.index }}"
data-diff-id="p3x-gitlist-diff-data-{{ loop.index }}" style="display: none;">
<div class="p3x-gitlist-diff">
<table>
{% for line in diff.getLines %}
<tr>
<td class="lineNo">
{% if line.getType != 'chunk' %}
<!-- <a id="{{ diff.index | to_id }}L{{ loop.index }}R{{ line.getNumOld }}"></a> -->
<!-- <a href="#{{ diff.index | to_id }}L{{ loop.index }}R{{ line.getNumOld }}"> -->
{% endif %}
{{ line.getNumOld }}
{% if line.getType != 'chunk' %}
<!-- </a> -->
{% endif %}
</td>
<td class="lineNo">
{% if line.getType != 'chunk' %}
<!-- <a id="{{ diff.index | to_id }}L{{ loop.index }}L{{ line.getNumNew }}"></a> -->
<!-- <a href="#{{ diff.index | to_id }}L{{ loop.index }}L{{ line.getNumNew }}"> -->
{% endif %}
{{ line.getNumNew }}
{% if line.getType != 'chunk' %}
<!-- </a> -->
{% endif %}
</td>
<td style="width: 100%">
<pre{% if line.getType %} class="{{ line.getType }}"{% endif %}>{{ line.getLine }}</pre>
</td>
</tr>
{% endfor %}
</table>
data-diff-id="p3x-gitlist-diff-data-{{ loop.index }}" data-diff-index="{{ loop.index }}" style="display: none;">
<div class="p3x-gitlist-diff" id="p3x-gitlist-diff-ajax-{{ loop.index }}">

<div style="opacity: 0.5; margin: 10px;">Hang on, loading and rendering diffs deffered via AJAX...</div>

</div>
</li>
{% endfor %}
Expand Down
2 changes: 1 addition & 1 deletion src/twig/layout.twig
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<link rel="shortcut icon" type="image/png" href="img/favicon.png"/>
<link rel="stylesheet" type="text/css" href="{{ prod_dir }}/css/{{ theme }}.{{ theme_postfix }}.css" id="bootstrap-theme">
<script type="text/javascript">window.gitlist = { lastload: undefined, lastloadSpan: undefined, dark: {{ theme_dark |json_encode|raw }}, isDark: undefined, viewer: undefined, setTheme: undefined, getThemeCookie: undefined, basepath: '{{ app.url_subdir }}', branch: '{{ branch }}', repo: '{{ repo }}', dateFormat: '{{ gitlist_date_format }}', themes: {}, codemirror_full_limit: undefined, browse_type: undefined, search_query: '{{ search_query }}', browserClick: undefined, networkRedraw: undefined, treegraph: undefined, canvasLaneColors: undefined, canvasDotColors: undefined, randomCanvasLaneColors: undefined, loadTheme: '{{ theme }}', codemirrorTheme : {}, scrollIntoView: undefined, markdownRenderer: undefined}</script>
<link href="./prod/webpack/bundle.a58f8cb061166cfac50d.css" rel="stylesheet"><script type="text/javascript" src="./prod/webpack/bundle.a58f8cb061166cfac50d.js"></script></head>
<link href="./prod/webpack/bundle.feeeb69f8df4ec1ee7d1.css" rel="stylesheet"><script type="text/javascript" src="./prod/webpack/bundle.feeeb69f8df4ec1ee7d1.js"></script></head>
<body class="{{ theme_type }}" id="p3x-gitlist-body">

{% block body %}{% endblock %}
Expand Down
32 changes: 32 additions & 0 deletions todo.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
[//]: #@corifeus-header

# 🤖 P3X Gitlist

[//]: #@corifeus-header:end
# TODO
* treegraph pager
* diff by file
* pager not working right with commits
* search has no pager (either of two)
[//]: #@corifeus-footer

---

[**P3X-GITLIST**](https://pages.corifeus.com/gitlist) Build v2.8.0

[![Like Corifeus @ Facebook](https://img.shields.io/badge/LIKE-Corifeus-3b5998.svg)](https://www.facebook.com/corifeus.software) [![Donate for Corifeus / P3X](https://img.shields.io/badge/Donate-Corifeus-003087.svg)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=QZVM4V6HVZJW6) [![Contact Corifeus / P3X](https://img.shields.io/badge/Contact-P3X-ff9900.svg)](https://www.patrikx3.com/en/front/contact)


## P3X Sponsors

[IntelliJ - The most intelligent Java IDE](https://www.jetbrains.com)

[![JetBrains](https://cdn.corifeus.com/assets/svg/jetbrains-logo.svg)](https://www.jetbrains.com/) [![NoSQLBooster](https://cdn.corifeus.com/assets/png/nosqlbooster-70x70.png)](https://www.nosqlbooster.com/)

[The Smartest IDE for MongoDB](https://www.nosqlbooster.com)




[//]: #@corifeus-footer:end

0 comments on commit ee93692

Please sign in to comment.