Finish issue #401: Support MIME type overrides in ViewVC configuration.
Trade the 'mime_types_file' option for 'mime_types_files' -- an ordered list of MIME mapping files to consult. And provide our own (empty) mapping file that folks can use to override the mappings provided by other such files. * mimetypes.conf.dist New file. * viewvc.conf.dist (mime_types_files): Was mime_types_file, and now accepts multiple values. * lib/config.py (Config._force_multi_value): Add "mime_types_files" to the list of multi-value configuration options. (Config.set_defaults): Track rename of mime_types_file parameter, now setting the default to a list containing only "mimetypes.conf". * lib/viewvc.py (load_config): Track new name and format of mime_types_files option. * viewvc-install (FILE_INFO_LIST): Also install mimetypes.conf.dist as itself and as mimetypes.conf. * INSTALL (INSTALLING VIEWVC): Update reference to renamed configuration option. * docs/upgrading-howto.html Update this document. git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@2101 8cb11bc2-c004-0410-86c3-e597b4017df7remotes/test-suite
parent
e1575692be
commit
2dc51276ce
2
INSTALL
2
INSTALL
|
@ -139,7 +139,7 @@ installation instructions.
|
|||
default_root
|
||||
root_as_url_component
|
||||
rcs_dir
|
||||
mime_types_file
|
||||
mime_types_files
|
||||
|
||||
There are some other options that are usually nice to change. See
|
||||
viewvc.conf for more information. ViewVC provides a working,
|
||||
|
|
|
@ -325,6 +325,10 @@ td {
|
|||
"svn:mime-type" property value, set the <code>svn_ignore_mimetype</code>
|
||||
configuration option.</p>
|
||||
|
||||
<p>Speaking of MIME types, the option <code>mime_types_file</code> is
|
||||
now <code>mime_types_files</code>, as it now carries multiple paths
|
||||
to MIME mappings files, ordered by preference.</p>
|
||||
|
||||
<p>The <code>use_rcsparse</code> option was moved from the "general"
|
||||
section to the "options" section.</p>
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@ import fnmatch
|
|||
class Config:
|
||||
_sections = ('general', 'utilities', 'options', 'cvsdb', 'templates')
|
||||
_force_multi_value = ('cvs_roots', 'svn_roots', 'languages', 'kv_files',
|
||||
'root_parents', 'allowed_views')
|
||||
'root_parents', 'allowed_views', 'mime_types_files')
|
||||
|
||||
def __init__(self):
|
||||
for section in self._sections:
|
||||
|
@ -197,7 +197,7 @@ class Config:
|
|||
self.general.svn_roots = { }
|
||||
self.general.root_parents = []
|
||||
self.general.default_root = ''
|
||||
self.general.mime_types_file = ''
|
||||
self.general.mime_types_files = ["mimetypes.conf"]
|
||||
self.general.address = ''
|
||||
self.general.kv_files = [ ]
|
||||
self.general.languages = ['en-us']
|
||||
|
|
|
@ -4025,9 +4025,14 @@ def load_config(pathname=None, server=None):
|
|||
cfg.set_defaults()
|
||||
cfg.load_config(pathname, server and server.getenv("HTTP_HOST"))
|
||||
|
||||
# load mime types file
|
||||
if cfg.general.mime_types_file:
|
||||
mimetypes.init([cfg.general.mime_types_file])
|
||||
# Load mime types file(s), but reverse the order -- our
|
||||
# configuration uses a most-to-least preferred approach, but the
|
||||
# 'mimetypes' package wants things the other way around.
|
||||
if cfg.general.mime_types_files:
|
||||
files = cfg.general.mime_types_files[:]
|
||||
files.reverse()
|
||||
files = map(lambda x: os.path.join(os.path.dirname(pathname), x), files)
|
||||
mimetypes.init(files)
|
||||
|
||||
debug.t_end('load-config')
|
||||
return cfg
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
#---------------------------------------------------------------------------
|
||||
#
|
||||
# MIME type mapping file for ViewVC
|
||||
#
|
||||
# Information on ViewVC is located at the following web site:
|
||||
# http://viewvc.org/
|
||||
#
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
# THE FORMAT OF THIS FILE
|
||||
#
|
||||
# This file contains records -- one per line -- of the following format:
|
||||
#
|
||||
# MIME_TYPE [EXTENSION [EXTENSION ...]]
|
||||
#
|
||||
# where whitespace separates the MIME_TYPE from the EXTENSION(s),
|
||||
# and the EXTENSIONs from each other.
|
||||
#
|
||||
# For example:
|
||||
#
|
||||
# text/x-csh csh
|
||||
# text/x-csrc c
|
||||
# text/x-diff diff patch
|
||||
# image/png png
|
||||
# image/jpeg jpeg jpg jpe
|
||||
#
|
||||
# By default, this file is left empty, allowing ViewVC to continue
|
||||
# consulting it first without overriding the MIME type mappings
|
||||
# found in more standard mapping files (such as those provided as
|
||||
# part of the operating system or web server software).
|
||||
#
|
||||
#
|
|
@ -62,6 +62,8 @@ FILE_INFO_LIST = [
|
|||
("viewvc.conf.dist", "viewvc.conf", 0644, 0, 1, 0),
|
||||
("cvsgraph.conf.dist", "cvsgraph.conf.dist", 0644, 0, 0, 0),
|
||||
("cvsgraph.conf.dist", "cvsgraph.conf", 0644, 0, 1, 0),
|
||||
("mimetypes.conf.dist", "mimetypes.conf.dist", 0644, 0, 0, 0),
|
||||
("mimetypes.conf.dist", "mimetypes.conf", 0644, 0, 1, 0),
|
||||
]
|
||||
if sys.platform == "win32":
|
||||
FILE_INFO_LIST.extend([
|
||||
|
|
|
@ -60,7 +60,7 @@
|
|||
# default_root
|
||||
# root_as_url_component
|
||||
# rcs_dir
|
||||
# mime_types_file
|
||||
# mime_types_files
|
||||
# the many options in the [utilities] section
|
||||
#
|
||||
# It is usually desirable to change the following variables:
|
||||
|
@ -127,13 +127,26 @@ cvs_roots = cvs: /home/cvsroot
|
|||
default_root = cvs
|
||||
|
||||
#
|
||||
# This is a pathname to a MIME types file to help viewvc to guess the
|
||||
# correct MIME type on checkout. If you are having problems with the
|
||||
# default guess on the MIME type, then uncomment this option and point
|
||||
# it at a MIME type file.
|
||||
# This is a list of pathnames to a set of MIME type mapping files to
|
||||
# help ViewVC guess the correct MIME type of a versioned file. The
|
||||
# pathnames listed here are specified in order of authoritativeness
|
||||
# either as absolute paths or relative to this configuration file.
|
||||
#
|
||||
# For example, you can use the mime.types provided by Apache here:
|
||||
#mime_types_file = /usr/local/apache2/conf/mime.types
|
||||
# As a convenience, ViewVC provides a MIME type mapping file
|
||||
# (mimetypes.conf) which is, by default, the preferred provider of
|
||||
# MIME type mapping answers, but which is also empty. If you find
|
||||
# that ViewVC is unable to accurately guess MIME types based on the
|
||||
# extensions of some of your versioned files, you can add records of
|
||||
# your preferred mappings to the provided mimetypes.conf file (or to
|
||||
# your system's mapping files, if you wish).
|
||||
#
|
||||
# You might, for example, wish to have ViewVC also consult the mapping
|
||||
# files provided by your operating system and Apache.
|
||||
#
|
||||
# mime_types_files = mimetypes.conf,
|
||||
# /etc/mime.types,
|
||||
# /usr/local/apache2/conf/mime.types
|
||||
mime_types_files = mimetypes.conf
|
||||
|
||||
# The address of the local repository maintainer. (This option is
|
||||
# provided only as a convenience for ViewVC installations which are
|
||||
|
|
Loading…
Reference in New Issue