changed the LOC graph in the code file view
This commit is contained in:
parent
fcd0091af7
commit
1c291410f6
@ -164,7 +164,7 @@ class Graph extends CI_Controller
|
|||||||
if ($path == '.') $path = ''; /* treat a period specially */
|
if ($path == '.') $path = ''; /* treat a period specially */
|
||||||
$path = $this->_normalize_path ($path);
|
$path = $this->_normalize_path ($path);
|
||||||
|
|
||||||
$cloc = $cloc = $this->subversion->clocRevByFile($projectid, $path, $rev);
|
$cloc = $this->subversion->clocRevByFile($projectid, $path, $rev);
|
||||||
print codepot_json_encode($cloc);
|
print codepot_json_encode($cloc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1486,8 +1486,19 @@ class SubversionModel extends CodeRepoModel
|
|||||||
if ($info === FALSE || $info === NULL || count($info) != 1) return FALSE;
|
if ($info === FALSE || $info === NULL || count($info) != 1) return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($info[0]['kind'] == SVN_NODE_FILE) return FALSE;
|
if ($info[0]['kind'] == SVN_NODE_FILE)
|
||||||
|
{
|
||||||
|
$file = $this->getFile($projectid, $path, $rev);
|
||||||
|
if ($file === FALSE) return FALSE;
|
||||||
|
|
||||||
|
$tfname = @tempnam(__FILE__, 'codepot-cloc-rev-');
|
||||||
|
if ($tfname === FALSE) return FALSE;
|
||||||
|
|
||||||
|
$actual_tfname = $tfname . '.' . pathinfo ($file['name'], PATHINFO_EXTENSION);
|
||||||
|
@file_put_contents ($actual_tfname, $file['content']);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
// pass __FILE__ as the first argument so that tempnam creates a name
|
// pass __FILE__ as the first argument so that tempnam creates a name
|
||||||
// in the system directory. __FILE__ can never be a valid directory.
|
// in the system directory. __FILE__ can never be a valid directory.
|
||||||
$tfname = @tempnam(__FILE__, 'codepot-cloc-rev-');
|
$tfname = @tempnam(__FILE__, 'codepot-cloc-rev-');
|
||||||
@ -1502,8 +1513,9 @@ class SubversionModel extends CodeRepoModel
|
|||||||
@unlink ($tfname);
|
@unlink ($tfname);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$cloc_cmd = sprintf ('%s --quiet --csv --csv-delimiter=":" %s', CODEPOT_CLOC_COMMAND_PATH, $actual_tfname);
|
$cloc_cmd = sprintf('%s --quiet --csv --csv-delimiter=":" %s', CODEPOT_CLOC_COMMAND_PATH, $actual_tfname);
|
||||||
$cloc = @popen ($cloc_cmd, 'r');
|
$cloc = @popen ($cloc_cmd, 'r');
|
||||||
if ($cloc === FALSE)
|
if ($cloc === FALSE)
|
||||||
{
|
{
|
||||||
|
@ -102,6 +102,13 @@
|
|||||||
<script type="text/javascript" src="<?php print base_url_make('/js/jquery-ui.min.js')?>"></script>
|
<script type="text/javascript" src="<?php print base_url_make('/js/jquery-ui.min.js')?>"></script>
|
||||||
<link type="text/css" rel="stylesheet" href="<?php print base_url_make('/css/jquery-ui.css')?>" />
|
<link type="text/css" rel="stylesheet" href="<?php print base_url_make('/css/jquery-ui.css')?>" />
|
||||||
|
|
||||||
|
<!--[if lte IE 8]><script type="text/javascript" src="<?php print base_url_make('/js/excanvas.min.js')?>"></script><![endif]-->
|
||||||
|
<script type="text/javascript" src="<?php print base_url_make('/js/jquery.flot.min.js')?>"></script>
|
||||||
|
<script type="text/javascript" src="<?php print base_url_make('/js/jquery.flot.time.min.js')?>"></script>
|
||||||
|
<script type="text/javascript" src="<?php print base_url_make('/js/jquery.flot.categories.min.js')?>"></script>
|
||||||
|
<script type="text/javascript" src="<?php print base_url_make('/js/jquery.flot.stack.min.js')?>"></script>
|
||||||
|
<script type="text/javascript" src="<?php print base_url_make('/js/jquery.flot.tickrotor.js')?>"></script>
|
||||||
|
|
||||||
<script type="text/javascript" src="<?php print base_url_make('/js/vis.min.js')?>"></script>
|
<script type="text/javascript" src="<?php print base_url_make('/js/vis.min.js')?>"></script>
|
||||||
<link type="text/css" rel="stylesheet" href="<?php print base_url_make('/css/vis.min.css')?>" />
|
<link type="text/css" rel="stylesheet" href="<?php print base_url_make('/css/vis.min.css')?>" />
|
||||||
|
|
||||||
@ -550,6 +557,81 @@ var RevGraphApp = (function ()
|
|||||||
})();
|
})();
|
||||||
|
|
||||||
|
|
||||||
|
var LocGraphApp = (function ()
|
||||||
|
{
|
||||||
|
function App (top_container, graph_container, graph_msgdiv, graph_canvas, graph_button, graph_spin, graph_url, graph_title)
|
||||||
|
{
|
||||||
|
GraphApp.call (this, top_container, graph_container, graph_msgdiv, graph_canvas, graph_button, graph_spin, graph_url, graph_title);
|
||||||
|
this.plot_dataset = null;
|
||||||
|
this.plot_options = null;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
App.prototype = Object.create(GraphApp.prototype);
|
||||||
|
App.prototype.constructor = App;
|
||||||
|
App.prototype.renderGraph = function (data)
|
||||||
|
{
|
||||||
|
if (!data.hasOwnProperty('SUM'))
|
||||||
|
{
|
||||||
|
this.showMessage ('No data to show');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (data.SUM.length != 4)
|
||||||
|
{
|
||||||
|
this.showMessage ('Invalid data to show');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.clearMessage ();
|
||||||
|
|
||||||
|
var pd = [];
|
||||||
|
// files, blank, comment, code
|
||||||
|
// files is always 1.
|
||||||
|
for (var i = 1; i < data.SUM.length ; i++)
|
||||||
|
{
|
||||||
|
pd[i - 1] = [ i - 1, data.SUM[i] ];
|
||||||
|
}
|
||||||
|
this.plot_dataset = [
|
||||||
|
{ label: 'LOC', data: pd }
|
||||||
|
]
|
||||||
|
|
||||||
|
var ticks = [
|
||||||
|
[0, "<?php print $this->lang->line('Blank')?>(" + data.SUM[1] + ")"],
|
||||||
|
[1, "<?php print $this->lang->line('Comment')?>(" + data.SUM[2] + "])"],
|
||||||
|
[2, "<?php print $this->lang->line('Code')?>(" + data.SUM[3] + ")"]
|
||||||
|
];
|
||||||
|
|
||||||
|
this.plot_options = {
|
||||||
|
series: {
|
||||||
|
bars: { show: true }
|
||||||
|
},
|
||||||
|
bars: {
|
||||||
|
align: "center",
|
||||||
|
barWidth: 0.8
|
||||||
|
},
|
||||||
|
xaxis: {
|
||||||
|
axisLabel: "",
|
||||||
|
axisLabelUseCanvas: true,
|
||||||
|
ticks: ticks
|
||||||
|
},
|
||||||
|
yaxis: {
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
App.prototype.resizeGraph = function ()
|
||||||
|
{
|
||||||
|
if (this.plot_dataset != null)
|
||||||
|
{
|
||||||
|
this.graph_canvas.width (this.graph_container.width() - 5);
|
||||||
|
this.graph_canvas.height (this.graph_container.height() - 10);
|
||||||
|
$.plot(this.graph_canvas, this.plot_dataset, this.plot_options);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return App;
|
||||||
|
})();
|
||||||
|
|
||||||
|
|
||||||
$(function () {
|
$(function () {
|
||||||
|
|
||||||
$('#code_file_metadata').accordion({
|
$('#code_file_metadata').accordion({
|
||||||
@ -558,24 +640,20 @@ $(function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
<?php if (!$is_special_stream): ?>
|
<?php if (!$is_special_stream): ?>
|
||||||
$("#code_file_loc_info").hide();
|
|
||||||
btn = $("#code_file_loc_button").button().click (function () {
|
|
||||||
if ($("#code_file_loc_info").is(":visible"))
|
|
||||||
{
|
|
||||||
$("#code_file_loc_info").hide("blind",{},200);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$("#code_file_loc_info").show("blind",{},200);
|
|
||||||
}
|
|
||||||
|
|
||||||
return false; // prevent the default behavior
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
$("#code_file_edit_button").button();
|
$("#code_file_edit_button").button();
|
||||||
<?php endif; ?>
|
|
||||||
|
|
||||||
|
var loc_graph_app = new LocGraphApp (
|
||||||
|
$(window),
|
||||||
|
$("#code_file_loc_graph_container"),
|
||||||
|
$("#code_file_loc_graph_error"),
|
||||||
|
$("#code_file_loc_graph"),
|
||||||
|
$("#code_file_loc_graph_button"),
|
||||||
|
$("#code_file_loc_graph_spin"),
|
||||||
|
codepot_merge_path ("<?php print site_url(); ?>", "/graph/enjson_loc_by_lang/<?php print $project->id; ?>/<?php print $hex_headpath;?><?php print $revreq?>"),
|
||||||
|
"LOC"
|
||||||
|
);
|
||||||
|
loc_graph_app.initWidgets ();
|
||||||
|
<?php endif; ?>
|
||||||
|
|
||||||
var rev_graph_app = new RevGraphApp (
|
var rev_graph_app = new RevGraphApp (
|
||||||
$(window),
|
$(window),
|
||||||
@ -815,9 +893,11 @@ $this->load->view (
|
|||||||
if ((isset($login['id']) && $login['id'] != '') )
|
if ((isset($login['id']) && $login['id'] != '') )
|
||||||
{
|
{
|
||||||
print ' ';
|
print ' ';
|
||||||
print anchor ("code/edit/{$project->id}/{$hex_headpath}{$revreq}", $this->lang->line('Edit'), 'id="code_file_edit_button"');
|
print anchor("code/edit/{$project->id}/{$hex_headpath}{$revreq}", $this->lang->line('Edit'), 'id="code_file_edit_button"');
|
||||||
}
|
}
|
||||||
print anchor ("#", "LOC", "id=code_file_loc_button");
|
/*print anchor ("#", "LOC", "id=code_file_loc_button");*/
|
||||||
|
print '<a id="code_file_loc_graph_button" href="#">';
|
||||||
|
print '<i id="code_file_loc_graph_spin" class="fa"></i>LOC</a>';
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
</div>
|
</div>
|
||||||
@ -905,6 +985,11 @@ $this->load->view (
|
|||||||
<div id="code_file_revision_graph"></div>
|
<div id="code_file_revision_graph"></div>
|
||||||
<div id="code_file_revision_graph_error"></div>
|
<div id="code_file_revision_graph_error"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div id="code_file_loc_graph_container">
|
||||||
|
<div id="code_file_loc_graph"></div>
|
||||||
|
<div id="code_file_loc_graph_error"></div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div style="display:none">
|
<div style="display:none">
|
||||||
@ -989,16 +1074,6 @@ if ($login['settings'] != NULL &&
|
|||||||
}
|
}
|
||||||
|
|
||||||
print '</pre>';
|
print '</pre>';
|
||||||
|
|
||||||
if (!$is_special_stream)
|
|
||||||
{
|
|
||||||
print '<div id="code_file_loc_info" class="codepot-infobox">';
|
|
||||||
print '<div class="title">LOC</div>';
|
|
||||||
/* TODO: show this if it's enabled in the user settings */
|
|
||||||
$graph_url = codepot_merge_path (site_url(), "/code/graph/cloc-file/{$project->id}/{$hex_headpath}{$revreq}");
|
|
||||||
print "<img src='{$graph_url}' id='code_file_loc_info_locgraph' />";
|
|
||||||
print '</div>';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($is_wiki_file)
|
if ($is_wiki_file)
|
||||||
|
@ -490,7 +490,7 @@ var LocFileApp = (function ()
|
|||||||
function App (top_container, graph_container, graph_msgdiv, graph_canvas, graph_button, graph_spin, graph_url, graph_title)
|
function App (top_container, graph_container, graph_msgdiv, graph_canvas, graph_button, graph_spin, graph_url, graph_title)
|
||||||
{
|
{
|
||||||
GraphApp.call (this, top_container, graph_container, graph_msgdiv, graph_canvas, graph_button, graph_spin, graph_url, graph_title);
|
GraphApp.call (this, top_container, graph_container, graph_msgdiv, graph_canvas, graph_button, graph_spin, graph_url, graph_title);
|
||||||
this.cf = null;
|
this.fc = null;
|
||||||
this.loc_data = null;
|
this.loc_data = null;
|
||||||
|
|
||||||
var self = this;
|
var self = this;
|
||||||
|
Loading…
Reference in New Issue
Block a user