{"thread":{"id":"21502","subject":"[PATCH] gitweb: Support for no project list on gitweb front page","startedAt":"2009-11-06T15:11:05Z","lastAt":"2009-11-16T17:52:29Z","messageCount":3,"participants":["Petr Baudis","J.H."],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"126983","messageId":"1257520265-16699-1-git-send-email-pasky@suse.cz","threadId":"21502","inReplyTo":null,"subject":"[PATCH] gitweb: Support for no project list on gitweb front page","fromName":"Petr Baudis","fromEmail":"pasky@suse.cz","sentAt":"2009-11-06T15:11:05Z","receivedAt":"2009-11-06T15:11:05Z","isPatch":true,"sender":{"key":"pasky@ucw.cz","avatar":"https://avatars.githubusercontent.com/u/18439?v=4"},"body":"On very large sites like repo.or.cz (but maybe also git.debian.org,\ngit.kernel.org, etc.), it is desirable not to have the project list\non the front page since generating it is significant overhead and it\ntakes significant data transfer and load time for the user, who might\nprefer to instead use the search form and possibly content tags to\nnavigate to the target project. A link to the full list of projects is\nstill available on the front page for users who wish to browse it. The\nwhole feature is turned off by default.\n\nThe patch introduces a new config variable $frontpage_no_project_list,\nby default 0 keeping the current behavior; if set to 1, no project list\nwill be shown, but all projects will be still scanned if ctags are\nenabled; if set to 2, no project will be shown and no projects will\nbe scanned while showing the front page. The compromise value of 1 is\nuseful for sites where project scan time is not an issue or which\nuse additional project list caching patches.\n\nThe patch furthermore modifies project_list action not to show the\nindex text, and introduces new default action frontpage which is by\ndefault identical to old project_list action, but can be further\ncontrolled by the $frontpage_no_project_list variable.\n\nSigned-off-by: Petr Baudis <pasky@suse.cz>\n\n---\n gitweb/README      |    8 ++++++++\n gitweb/gitweb.css  |    5 +++++\n gitweb/gitweb.perl |   32 +++++++++++++++++++++++++++++---\n 3 files changed, 42 insertions(+), 3 deletions(-)\n\ndiff --git a/gitweb/README b/gitweb/README\nindex 66c6a93..c5fd1b8 100644\n--- a/gitweb/README\n+++ b/gitweb/README\n@@ -223,6 +223,14 @@ not include variables usually directly set during build):\n    repositories from launching cross-site scripting (XSS) attacks.  Set this\n    to true if you don't trust the content of your repositories. The default\n    is false.\n+ * $frontpage_no_project_list\n+   If 0, the gitweb frontpage will contain the project list; if 1 instead,\n+   it will contain just the index text, search form, tag cloud (if enabled)\n+   and a link to the actual project list. The page is reduced, but all\n+   projects still need to be scanned for the tag cloud construction. If the\n+   option is set to 2, not even the tag cloud will be shown; this is fastest.\n+   This option is useful for sites with large amount of projects. The default\n+   is 0.\n \n \n Projects list file format\ndiff --git a/gitweb/gitweb.css b/gitweb/gitweb.css\nindex cb3f0ba..9fee3f0 100644\n--- a/gitweb/gitweb.css\n+++ b/gitweb/gitweb.css\n@@ -97,6 +97,11 @@ div.readme {\n \tpadding: 8px;\n }\n \n+p.projectlist_link {\n+\ttext-align: center;\n+\tfont-weight: bold;\n+}\n+\n a.title:hover {\n \tbackground-color: #d9d8d1;\n }\ndiff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\nindex 97e88b4..48326a4 100755\n--- a/gitweb/gitweb.perl\n+++ b/gitweb/gitweb.perl\n@@ -152,6 +152,11 @@ our @diff_opts = ('-M'); # taken from git_commit\n # the gitweb domain.\n our $prevent_xss = 0;\n \n+# Whether to include project list on the gitweb front page; 0 means yes,\n+# 1 means no list but show tag cloud if enabled (all projects still need\n+# to be scanned), 2 means no list and no tag cloud (very fast)\n+our $frontpage_no_project_list = 0;\n+\n # information about snapshot formats that gitweb is capable of serving\n our %known_snapshot_formats = (\n \t# name => {\n@@ -601,6 +606,7 @@ our %actions = (\n \t\"object\" => \\&git_object,\n \t# those below don't need $project\n \t\"opml\" => \\&git_opml,\n+\t\"frontpage\" => \\&git_frontpage,\n \t\"project_list\" => \\&git_project_list,\n \t\"project_index\" => \\&git_project_index,\n );\n@@ -901,13 +907,13 @@ if (!defined $action) {\n \t} elsif (defined $project) {\n \t\t$action = 'summary';\n \t} else {\n-\t\t$action = 'project_list';\n+\t\t$action = 'frontpage';\n \t}\n }\n if (!defined($actions{$action})) {\n \tdie_error(400, \"Unknown action\");\n }\n-if ($action !~ m/^(?:opml|project_list|project_index)$/ &&\n+if ($action !~ m/^(?:opml|frontpage|project_list|project_index)$/ &&\n     !$project) {\n \tdie_error(400, \"Project needed\");\n }\n@@ -4377,6 +4383,7 @@ sub git_project_list_body {\n \n sub git_project_search_form {\n \tprint $cgi->startform(-method => \"get\") .\n+\t      $cgi->hidden({-name=>\"a\", -value=>\"project_list\"}) . \"\\n\" .\n \t      \"<p class=\\\"projsearch\\\">Search:\\n\" .\n \t      $cgi->textfield(-name => \"s\", -value => $searchtext) . \"\\n\" .\n \t      \"</p>\" .\n@@ -4665,7 +4672,7 @@ sub git_search_grep_body {\n ## ======================================================================\n ## actions\n \n-sub git_project_list {\n+sub git_frontpage {\n \tgit_header_html();\n \tif (-f $home_text) {\n \t\tprint \"<div class=\\\"index_include\\\">\\n\";\n@@ -4673,6 +4680,25 @@ sub git_project_list {\n \t\tprint \"</div>\\n\";\n \t}\n \tgit_project_search_form();\n+\tif (not $frontpage_no_project_list) {\n+\t\tgit_project_list_all();\n+\t} else {\n+\t\tmy $show_ctags = gitweb_check_feature('ctags');\n+\t\tif ($frontpage_no_project_list == 1 and $show_ctags) {\n+\t\t\tmy @list = git_get_projects_list();\n+\t\t\tmy @projects = fill_project_list_info(\\@list, gitweb_check_feature('forks'), $show_ctags);\n+\t\t\tgit_project_list_ctags(\\@projects);\n+\t\t}\n+\t\tprint \"<p class=\\\"projectlist_link\\\">\" .\n+\t\t\t$cgi->a({-href => href(action=>'project_list')}, \"Browse all projects\") .\n+\t\t\t\"</p>\\n\";\n+\t}\n+\tgit_footer_html();\n+}\n+\n+sub git_project_list {\n+\tgit_header_html();\n+\tgit_project_search_form();\n \tgit_project_list_all();\n \tgit_footer_html();\n }\n-- \ntg: (e731dcd..) t/frontpage/separate (depends on: t/frontpage/ctags)\n"},{"id":"127000","messageId":"4AF472E5.1000602@eaglescrag.net","threadId":"21502","inReplyTo":"1257520265-16699-1-git-send-email-pasky@suse.cz","subject":"Re: [PATCH] gitweb: Support for no project list on gitweb front page","fromName":"J.H.","fromEmail":"warthog19@eaglescrag.net","sentAt":"2009-11-06T19:03:01Z","receivedAt":"2009-11-06T19:03:01Z","isPatch":true,"sender":{"key":"warthog19@eaglescrag.net","avatar":null},"body":"Petr Baudis wrote:\n> On very large sites like repo.or.cz (but maybe also git.debian.org,\n> git.kernel.org, etc.),\n\nI think between our own caching (which I'll be submitting a cleaned up \npatch for here shortly for mainline inclusion) and our users want to \n*NOT* deal with searching or pagination this actually isn't that useful \nto us, despite having a signifigant number of projects, and the front \npage (at leas for us) only weighing in at 567,710bytes means that we are \nmoving less data to show the git.kernel.org page than facebook does to \nshow their home screen (I.E. anything modern can trivially cope with that)\n\n> it is desirable not to have the project list\n> on the front page since generating it is significant overhead and it\n> takes significant data transfer and load time for the user, who might\n> prefer to instead use the search form and possibly content tags to\n> navigate to the target project. A link to the full list of projects is\n> still available on the front page for users who wish to browse it. The\n> whole feature is turned off by default.\n> \n> The patch introduces a new config variable $frontpage_no_project_list,\n> by default 0 keeping the current behavior; if set to 1, no project list\n> will be shown, but all projects will be still scanned if ctags are\n> enabled; if set to 2, no project will be shown and no projects will\n> be scanned while showing the front page. The compromise value of 1 is\n> useful for sites where project scan time is not an issue or which\n> use additional project list caching patches.\n\nI question the need for 0,1,2.  If the site doesn't want something like \nthe tag cloud they are already going to turn it off with the normal \ncloud system.  I think this should be either a bitmask or an array to \nexplicitly turn particular things on or off, or a binary value that \nwould *ONLY* deal with showing the project listing.\n\n- John 'Warthog9' Hawley\n"},{"id":"127691","messageId":"20091116175228.GJ17748@machine.or.cz","threadId":"21502","inReplyTo":"4AF472E5.1000602@eaglescrag.net","subject":"Re: [PATCH] gitweb: Support for no project list on gitweb front page","fromName":"Petr Baudis","fromEmail":"pasky@suse.cz","sentAt":"2009-11-16T17:52:29Z","receivedAt":"2009-11-16T17:52:29Z","isPatch":true,"sender":{"key":"pasky@ucw.cz","avatar":"https://avatars.githubusercontent.com/u/18439?v=4"},"body":"On Fri, Nov 06, 2009 at 11:03:01AM -0800, J.H. wrote:\n> Petr Baudis wrote:\n> >On very large sites like repo.or.cz (but maybe also git.debian.org,\n> >git.kernel.org, etc.),\n> \n> I think between our own caching (which I'll be submitting a cleaned\n> up patch for here shortly for mainline inclusion) and our users want\n> to *NOT* deal with searching or pagination this actually isn't that\n> useful to us, despite having a signifigant number of projects, and\n> the front page (at leas for us) only weighing in at 567,710bytes\n> means that we are moving less data to show the git.kernel.org page\n> than facebook does to show their home screen (I.E. anything modern\n> can trivially cope with that)\n\nSure, you still have much fewer projects than repo.or.cz. :-)\nPerhaps others will still find it useful.\n\n> >it is desirable not to have the project list\n> >on the front page since generating it is significant overhead and it\n> >takes significant data transfer and load time for the user, who might\n> >prefer to instead use the search form and possibly content tags to\n> >navigate to the target project. A link to the full list of projects is\n> >still available on the front page for users who wish to browse it. The\n> >whole feature is turned off by default.\n> >\n> >The patch introduces a new config variable $frontpage_no_project_list,\n> >by default 0 keeping the current behavior; if set to 1, no project list\n> >will be shown, but all projects will be still scanned if ctags are\n> >enabled; if set to 2, no project will be shown and no projects will\n> >be scanned while showing the front page. The compromise value of 1 is\n> >useful for sites where project scan time is not an issue or which\n> >use additional project list caching patches.\n> \n> I question the need for 0,1,2.  If the site doesn't want something\n> like the tag cloud they are already going to turn it off with the\n> normal cloud system.  I think this should be either a bitmask or an\n> array to explicitly turn particular things on or off, or a binary\n> value that would *ONLY* deal with showing the project listing.\n\nI have no problem with either way, 2 seemed useful so that people can\ncontinue to use ctags but have the front page without any project\nscanning whatsoever, but if people think it makes no sense to have it,\nI can drop it. I will resend the patch with this being a bitmask\ninstead, though.\n\n-- \n\t\t\t\tPetr \"Pasky\" Baudis\nA lot of people have my books on their bookshelves.\nThat's the problem, they need to read them. -- Don Knuth\n"}]}