Misc design tweaks: https://github.com/viewvc/viewvc/issues/163 (1) In the CSS /templates/default/docroot/styles.css, you could change pre to pre-wrap . I had several text files which do not have natural line breaks (= the line breaks will be done by the end user app using auto-wordwrap), so these files generated a 4000 pixel wide website. We should allow some linebreaks using pre-wrap. (2) Strip whitespace from logs messages. (Either via strip(), or maybe just removing full empty lines at beginning and start). diff -U 2 -r viewvc_original/lib/viewvc.py viewvc/lib/viewvc.py --- viewvc_original/lib/viewvc.py 2018-11-01 11:06:14.836993859 +0100 +++ viewvc/lib/viewvc.py 2018-11-01 23:27:40.601850575 +0100 @@ -2108,5 +2142,5 @@ data['author'] = entry.author data['changed'] = entry.changed - data['log'] = lf.get(maxlen=0, htmlize=1) + data['log'] = lf.get(maxlen=0, htmlize=1).strip() data['size'] = entry.size (3) In the template "default", I would recommend changing every 200px column-width value to 300px. 200px is very small for most file names, and most modern computers have enough space on the screen. ========================================== Feature "Show HTTP 401 if a repo lacks read-permission, and HTTP 404 if repo does not exist": https://github.com/viewvc/viewvc/issues/164 Here is a patch I have written. Can somebody please create a PullRequest? diff -U 2 -r viewvc_original/lib/viewvc.py viewvc/lib/viewvc.py --- viewvc_original/lib/viewvc.py 2018-11-01 11:06:14.836993859 +0100 +++ viewvc/lib/viewvc.py 2018-11-01 23:27:40.601850575 +0100 @@ -244,4 +246,5 @@ if self.rootname: + access_violation = 0 roottype, rootpath = locate_root(cfg, self.rootname) if roottype: @@ -277,11 +280,29 @@ raise vclib.ReposNotFound() except vclib.ReposNotFound: + access_violation = 1 pass debug.t_end('select-repos') if self.repos is None: - raise debug.ViewVCException( - 'The root "%s" is unknown. If you believe the value is ' - 'correct, then please double-check your configuration.' - % self.rootname, "404 Not Found") + if access_violation: + if os.environ.get('REMOTE_USER') is not None: + raise debug.ViewVCException( + 'You don\'t have permission to access "%s". Please restart your browser session if you want to login as a different user.' + % (self.rootname), "401 Authorization Required") + else: + raise debug.ViewVCException( + 'You don\'t have permission to access "%s".' + % (self.rootname), "401 Authorization Required") + else: + raise debug.ViewVCException( + 'The root "%s" is unknown. If you believe the value is ' + 'correct, then please double-check your configuration.' + % self.rootname, "404 Not Found") if self.repos: ========================================== Misc encoding problems with Non-ASCII files (ISO-8859-1): https://github.com/viewvc/viewvc/issues/165 I had a lot of problems using code which had comments in my native language (encoded in ISO-8859-1), because UTF-8 was always chosen as default encoding. I have changed the code a bit and added more configuration switches to allow the administrator to have more influence in the encoding that is being used. I have also found a spot where the config value detect_encoding was not queries correctly. Also, another bug was that the encoding-search-algorithm was only available in the plain text files, not in the pygmentized code. Here is a patch I have written. Can somebody please create a PullRequest? diff -U 2 -r viewvc_original/conf/viewvc.conf.dist viewvc/conf/viewvc.conf.dist --- viewvc_original/conf/viewvc.conf.dist 2018-11-01 11:06:14.824994030 +0100 +++ viewvc/conf/viewvc.conf.dist 2018-11-02 18:10:17.305992089 +0100 @@ -349,4 +349,15 @@ [options] +## If the algorithm has problems detecting the encoding of a file, try the system locale (if available) +encoding_try_locale = 1 + +## If the detection of the encoding failed, choose this encoding as last resort +encoding_default = iso-8859-1 + ## root_as_url_component: Interpret the first path component in the URL ## after the script location as the root to use. This is an diff -U 2 -r viewvc_original/lib/viewvc.py viewvc/lib/viewvc.py --- viewvc_original/lib/viewvc.py 2018-11-01 11:06:14.836993859 +0100 +++ viewvc/lib/viewvc.py 2018-11-01 23:27:40.601850575 +0100 @@ -39,4 +39,6 @@ import urllib +import locale + # These modules come from our library (the stub has set up the path) from common import _item, _RCSDIFF_NO_CHANGES, _RCSDIFF_IS_BINARY, _RCSDIFF_ERROR, TemplateData @@ -1697,10 +1718,10 @@ -def detect_encoding(text_block): +def detect_encoding(text_block, cfg): """Return the encoding used by TEXT_BLOCK as detected by the chardet Python module. (Currently, this is used only when syntax highlighting is not enabled/available; otherwise, Pygments does this work for us.)""" # Does the TEXT_BLOCK start with a BOM? for bom, encoding in [('\xef\xbb\xbf', 'utf-8'), @@ -1714,21 +1735,30 @@ # If no recognized BOM, see if chardet can help us. - try: - import chardet + if cfg.options.detect_encoding: + try: + import chardet - # If chardet can confidently claimed a match, we'll use its - # findings. (And if that match is 'ascii' -- which is a subset of - # utf-8 -- we'll just call it 'utf-8' and score a zero transform.) - resp = chardet.detect(text_block) - if resp.get('confidence') == 1.0: - encoding = resp.get('encoding') - if encoding is "ascii": - encoding = "utf-8" - return encoding - except: - pass + # If chardet can confidently claimed a match, we'll use its + # findings. (And if that match is 'ascii' -- which is a subset of + # utf-8 -- we'll just call it 'utf-8' and score a zero transform.) + resp = chardet.detect(text_block) + if resp.get('confidence') == 1.0: + encoding = resp.get('encoding') + if encoding is "ascii": + encoding = cfg.options.encoding_default + return encoding + except: + pass + + # We try the system's default encoding + if cfg.options.encoding_try_locale: + tmp = locale.getdefaultlocale()[1] + if tmp != None: + return tmp - # By default ... we have no idea. - return None + return cfg.options.encoding_default def transcode_text(text, encoding=None): @@ -1750,4 +1780,19 @@ return [] + # If allowed by configuration, try to detect the source encoding + # for this file. We'll assemble a block of data from the file + # contents to do so... 1024 bytes should be enough. + if not encoding: + if cfg.options.detect_encoding: + block_size = 0 + text_block = '' + for i in range(len(file_lines)): + text_block = text_block + file_lines[i] + if len(text_block) >= 1024: + break + encoding = detect_encoding(text_block, cfg) + else: + encoding = cfg.options.encoding_default + # Determine if we should (and can) use Pygments to highlight our # output. Reasons not to include a) being told not to by the @@ -1763,12 +1808,13 @@ get_lexer_for_filename, \ guess_lexer - if not encoding: - encoding = 'guess' - if cfg.options.detect_encoding: - try: - import chardet - encoding = 'chardet' - except (SyntaxError, ImportError): - pass # First, see if there's a Pygments lexer associated with MIME_TYPE. @@ -1807,16 +1853,4 @@ if not pygments_lexer: - # If allowed by configuration, try to detect the source encoding - # for this file. We'll assemble a block of data from the file - # contents to do so... 1024 bytes should be enough. - if not encoding and cfg.options.detect_encoding: - block_size = 0 - text_block = '' - for i in range(len(file_lines)): - text_block = text_block + file_lines[i] - if len(text_block) >= 1024: - break - encoding = detect_encoding(text_block) - # Built output data comprised of marked-up and possibly-transcoded # source text lines wrapped in (possibly dummy) vclib.Annotation ========================================== Feature: Different icon for binary files + add config "cfg.options.download_directly" https://github.com/viewvc/viewvc/issues/166 When I am clicking through the files in a repository where the download option is enabled, I accidently download files very often. Because clicking the file name means "download" for binary files, and "view markup" for text/code files. So I would like to suggest two changes: First, there could be another pictogram so you can easily see which file is code and which file is binary. Second, there could be a configuration switch which does the following: If you click a binary file, then you will always go to the markup view (you might want to enable define hide_binary_garbage in the template). In the markup view, you can see file/revision properties (which you could not see if you had downloaded the file when you clicked the filename), and can download the file explicitly by clicking download in the markup view. Here is a patch I have written. Can somebody please create a PullRequest? (1) Create a 16x16 pictogram templates/default/docroot/images/binary.png. (2) Apply following patch: diff -U 2 -r viewvc_original/conf/viewvc.conf.dist viewvc/conf/viewvc.conf.dist --- viewvc_original/conf/viewvc.conf.dist 2018-11-01 11:06:14.824994030 +0100 +++ viewvc/conf/viewvc.conf.dist 2018-11-02 18:10:17.305992089 +0100 @@ -349,4 +349,15 @@ [options] +## False: In the directory view, clicking a binary file directly leads to its download. +## True: In the directory view, clicking the file leads to the markup view, where the file properties can be shown, and the file can be downloaded +## If set to true, you should set "define hide_binary_garbage" to "1" in temples/default/file.ezt and include "co" in "allowed_views" +download_directly = 0 + ## root_as_url_component: Interpret the first path component in the URL ## after the script location as the root to use. This is an diff -U 2 -r viewvc_original/templates/default/directory.ezt viewvc/templates/default/directory.ezt --- viewvc_original/templates/default/directory.ezt 2018-11-01 11:06:14.844993745 +0100 +++ viewvc/templates/default/directory.ezt 2018-11-01 23:40:06.976438012 +0100 @@ -58,10 +58,10 @@ [end] [for entries] - [define click_href][is entries.pathtype "dir"][entries.view_href][else][if-any entries.prefer_markup][entries.view_href][else][entries.download_href][end][end][end] + [define click_href][is entries.pathtype "dir"][entries.view_href][else][is cfg.options.download_directly "1"][if-any entries.prefer_markup][entries.view_href][else][entries.download_href][end][else][entries.view_href][end][end][end] - - [if-any click_href][end] - + + [if-any click_href][end] + [entries.name][is entries.pathtype "dir"]/[end][if-any click_href][end][if-any entries.lockinfo]locked[end] [is entries.state "dead"](dead)[end] ========================================== Feature: Allow alternating colors for odd and even rows in text files https://github.com/viewvc/viewvc/issues/167 In the text/markup view, it would be great to have alternating colors to odd and even rows. If the user don't want this, they can set the color for odd and even rows to the same value in the CSS file. Here is a patch I have written. Can somebody please create a PullRequest? diff -U 2 -r viewvc_original/templates/default/file.ezt viewvc/templates/default/file.ezt --- viewvc_original/templates/default/file.ezt 2018-11-01 11:06:14.844993745 +0100 +++ viewvc/templates/default/file.ezt 2018-11-01 18:21:04.082246799 +0100 @@ -117,4 +117,5 @@ [define last_rev]0[end] [define rowclass]vc_row_odd[end] +[define rowclass_text]vc_file_line_text_odd[end] [if-any lines] @@ -139,4 +140,10 @@ [end] + [is rowclass_text "vc_file_line_text_even"] + [define rowclass_text]vc_file_line_text_odd[end] + [else] + [define rowclass_text]vc_file_line_text_even[end] + [end] + [lines.line_number] @@ -145,5 +152,5 @@ [is lines.rev last_rev] [else][if-any lines.diff_href][end][lines.rev][if-any lines.diff_href][end][end] [end] - [lines.text] + [lines.text] [define last_rev][lines.rev][end] diff -U 2 -r viewvc_original/templates/default/docroot/styles.css viewvc/templates/default/docroot/styles.css --- viewvc_original/templates/default/docroot/styles.css 2018-11-01 11:06:14.844993745 +0100 +++ viewvc/templates/default/docroot/styles.css 2018-11-01 21:36:02.885390631 +0100 @@ -250,10 +253,18 @@ text-align: right; } -.vc_file_line_text { +.vc_file_line_text_even { border-right-width: 0px; background-color: white; font-family: monospace; text-align: left; white-space: pre; + width: 100%; +} +.vc_file_line_text_odd { + border-right-width: 0px; + background-color: #FAFAFA; + font-family: monospace; + text-align: left; + white-space: pre; width: 100%; } ========================================== Feature: Clicking logo should lead to the main location https://github.com/viewvc/viewvc/issues/168 I find it very distracting that clicking the logo leads to the website of ViewVC. In every page I know, clicking the logo at the top left will lead to the root page. Here is a patch I have written. Can somebody please create a PullRequest? diff -U 2 -r viewvc_original/templates/default/include/header.ezt viewvc/templates/default/include/header.ezt --- viewvc_original/templates/default/include/header.ezt 2018-11-01 11:06:14.844993745 +0100 +++ viewvc/templates/default/include/header.ezt 2018-11-02 00:04:59.985651362 +0100 @@ -19,10 +19,16 @@ ========================================== Feature: Show num of root elements and num of directories https://github.com/viewvc/viewvc/issues/169 Here is a patch I have written. Can somebody please create a PullRequest? diff -U 2 -r viewvc_original/lib/viewvc.py viewvc/lib/viewvc.py --- viewvc_original/lib/viewvc.py 2018-11-01 11:06:14.836993859 +0100 +++ viewvc/lib/viewvc.py 2018-11-01 23:27:40.601850575 +0100 @@ -2251,5 +2285,7 @@ data = common_template_data(request) + data.merge(TemplateData({ + 'num_roots' : len(roots), 'roots' : roots, })) @@ -2327,4 +2363,5 @@ rows = [ ] num_displayed = 0 + num_displayed_dirs = 0 num_dead = 0 @@ -2369,4 +2406,6 @@ continue + num_displayed_dirs = num_displayed_dirs + 1 + row.view_href = request.get_url(view_func=view_directory, where=where_prefix+file.name, @@ -2461,4 +2500,5 @@ escape=1), 'files_shown' : num_displayed, + 'dirs_shown' : num_displayed_dirs, 'num_dead' : num_dead, 'youngest_rev' : None, diff -U 2 -r viewvc_original/templates/default/directory.ezt viewvc/templates/default/directory.ezt --- viewvc_original/templates/default/directory.ezt 2018-11-01 11:06:14.844993745 +0100 +++ viewvc/templates/default/directory.ezt 2018-11-01 23:40:06.976438012 +0100 @@ -133,4 +133,5 @@ [end]
+ [dirs_shown] dir[is dirs_shown "1"][else]s[end] and [files_shown] file[is files_shown "1"][else]s[end] shown
diff -U 2 -r viewvc_original/templates/default/roots.ezt viewvc/templates/default/roots.ezt --- viewvc_original/templates/default/roots.ezt 2018-11-01 11:06:14.844993745 +0100 +++ viewvc/templates/default/roots.ezt 2018-11-01 19:50:12.035189547 +0100 @@ -36,4 +38,11 @@ + +
+
+ [num_roots] item[is num_roots "1"][else]s[end] shown +
+
+