From cbb0657cfacf5f745d6da3ef80b2dd9d1d8d502e Mon Sep 17 00:00:00 2001 From: Gitea Date: Sun, 1 Nov 2020 17:15:50 -0600 Subject: Update styles --- gitweb.cgi | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 57 insertions(+), 10 deletions(-) (limited to 'gitweb.cgi') diff --git a/gitweb.cgi b/gitweb.cgi index 2992e0f..1938a7c 100755 --- a/gitweb.cgi +++ b/gitweb.cgi @@ -78,6 +78,7 @@ sub evaluate_uri { our $home_link = $my_uri || "/"; } +my %lang_counts = (); our $default_owner = ""; # core git executable to use @@ -265,6 +266,18 @@ our %avatar_size = ( 'double' => 32 ); +our %language_types = ( + 'c' => 'c', + 'h' => 'c', + 'java' => 'java', + 'py' => 'python', + 'js' => 'javascript', + 'json' => 'json', + 'html' => 'html', + 'css' => 'css', + 'sh' => 'shell' +); + # Used to set the maximum load that we will still respond to gitweb queries. # If server load exceed this value then return "503 server busy" error. # If gitweb cannot determined server load, it is taken to be 0. @@ -4693,6 +4706,7 @@ sub git_print_tree_entry { my %base_key = (); $base_key{'hash_base'} = $hash_base if defined $hash_base; + # The format of a table row is: mode list link. Where mode is # the mode of the entry, list is the name of the entry, an href, # and link is the action links of the entry. @@ -4706,6 +4720,12 @@ sub git_print_tree_entry { $cgi->a({-href => href(action=>"blob", hash=>$t->{'hash'}, file_name=>"$basedir$t->{'name'}", %base_key), -class => "list"}, esc_path($t->{'name'})); + + my $ext = $t->{'name'} =~ s/.*\.//r; + if(exists $language_types{$ext} and exists $t->{'size'}){ + $lang_counts{$ext}+=$t->{'size'}; + } + if (S_ISLNK(oct $t->{'mode'})) { my $link_target = git_get_link_target($t->{'hash'}); if ($link_target) { @@ -4755,6 +4775,7 @@ sub git_print_tree_entry { file_name=>"$basedir$t->{'name'}", %base_key)}, "tree"); + if (defined $hash_base) { print " | " . $cgi->a({-href => href(action=>"history", hash_base=>$hash_base, @@ -5684,7 +5705,7 @@ sub format_sort_th { if ($order eq $name) { $sort_th .= "$header\n"; } else { - $sort_th .= "" . + $sort_th .= "" . $cgi->a({-href => href(-replay=>1, order=>$name), -class => "header"}, $header) . "\n"; @@ -5727,7 +5748,7 @@ sub git_project_list_rows { -class => "list"}, esc_html_match_hl($pr->{'path'}, $search_regexp)) . "\n" . - "" . $cgi->a({-href => href(project=>$pr->{'path'}, action=>"summary"), + "" . $cgi->a({-href => href(project=>$pr->{'path'}, action=>"summary"), -class => "list", -title => $pr->{'descr_long'}}, $search_regexp @@ -5744,7 +5765,7 @@ sub git_project_list_rows { } print"" . $cgi->a({-href => href(project=>$pr->{'path'}, action=>"summary")}, "summary") . " | " . - $cgi->a({-href => href(project=>$pr->{'path'}, action=>"shortlog")}, "shortlog") . " | " . + #$cgi->a({-href => href(project=>$pr->{'path'}, action=>"shortlog")}, "shortlog") . " | " . $cgi->a({-href => href(project=>$pr->{'path'}, action=>"log")}, "log") . " | " . $cgi->a({-href => href(project=>$pr->{'path'}, action=>"tree")}, "tree") . ($pr->{'forks'} ? " | " . $cgi->a({-href => href(project=>$pr->{'path'}, action=>"forks")}, "forks") : '') . @@ -6563,14 +6584,15 @@ sub git_summary { git_print_page_nav('summary','', $head); my $proj_head_hash = git_get_head_hash($project); - print "
 
\n"; + #print "
 
\n"; print "
"; # --------------------------- README - print "
"; if (!$prevent_xss) { + my $file_name = "README.md"; my $readme_blob_hash = git_get_hash_by_path($proj_head_hash, "README.md", "blob"); if ($readme_blob_hash) { # if README.md exists + print "
"; #print "
readme
\n"; my $cmd_markdownify = $GIT . " " . git_cmd() . " cat-file blob " . $readme_blob_hash . " | pandoc |"; open FOO, $cmd_markdownify or die_error(500, "Open git-cat-file blob '$hash' failed"); @@ -6578,9 +6600,9 @@ sub git_summary { print $_; } close(FOO); + print "
"; } } - print "
"; # --------------------------- END README #------------------------ Projects list table print "\n"; @@ -7221,6 +7243,8 @@ sub git_tree_only { print "\n"; } + + %lang_counts = (); foreach my $line (@entries) { my %t = parse_ls_tree_line($line, -z => 1, -l => $show_sizes); @@ -7235,8 +7259,29 @@ sub git_tree_only { print "\n"; } - print "
\n" . - "
"; + print "\n"; + print_lang_counts(); + print ""; + +} + +sub print_lang_counts { + + my $total = 0; + for (keys %lang_counts){ + $total += $lang_counts{$_}; + } + if($total == 0) { + return; + } + print "
Found: "; + for (keys %lang_counts){ + my $percent = %lang_counts{$_}/$total * 100; + my $type = $language_types{$_}; + printf("%d%% %s ", $percent, $type); + } + print "
\n"; + } sub git_tree { @@ -7330,6 +7375,7 @@ sub git_tree { print "\n"; } + %lang_counts = (); foreach my $line (@entries) { my %t = parse_ls_tree_line($line, -z => 1, -l => $show_sizes); @@ -7344,8 +7390,9 @@ sub git_tree { print "\n"; } - print "\n" . - ""; + print "\n"; + print_lang_counts(); + print "\n"; git_footer_html(); } -- cgit v1.2.3