# # # patch "ChangeLog" # from [6bcd5af9c26c0b608797df77504f6ca232f558c1] # to [356aa12709506db7f10ce9cbe43b7a69da776e2f] # # patch "config.py.example" # from [5caa9b078dfa5d31e27b8f21464014d619dc9b66] # to [782031278d2d977661b7e566495c264626557f3a] # # patch "fdo/sharedmimeinfo.py" # from [4ee53b521b7103c8434435a904cd6692b569548d] # to [4b489fb1a64f036d67adc35089de586cac893ae7] # # patch "templates/revisionbrowse.html" # from [66d38381f187bc229bccd5489ad81693460b68e9] # to [1e37ebc587a7706215d068e0e27b9b3de31b0656] # # patch "viewmtn.py" # from [076d0c375da6061f4076d409d9fefe2d4621aa29] # to [fe2ae21cd72112b293f7523e31338fc417759bf5] # ============================================================ --- ChangeLog 6bcd5af9c26c0b608797df77504f6ca232f558c1 +++ ChangeLog 356aa12709506db7f10ce9cbe43b7a69da776e2f @@ -1,3 +1,10 @@ +2007-07-05 Grahame Bowland + + * support remapping MIME types, to allow + work arounds for unhelpful shared-mime-info. + * show the MIME type via "title" attribute + on icon links + 2007-07-04 Grahame Bowland * apply selection_func in __get_last_changes ============================================================ --- config.py.example 5caa9b078dfa5d31e27b8f21464014d619dc9b66 +++ config.py.example 782031278d2d977661b7e566495c264626557f3a @@ -80,4 +80,9 @@ icon_size = '16' icon_theme = 'gnome' icon_size = '16' - +# Some installations may have shared MIME info that is +# unhelpful. Forced remappings can be placed in the +# following hash table (uncomment it to enable it) +# +# mime_map = { 'application/x-python' : 'text/plain' } +# ============================================================ --- fdo/sharedmimeinfo.py 4ee53b521b7103c8434435a904cd6692b569548d +++ fdo/sharedmimeinfo.py 4b489fb1a64f036d67adc35089de586cac893ae7 @@ -252,7 +252,7 @@ class LookupHelper: return rv class LookupHelper: - def __init__(self): + def __init__(self, remap_lookup=None): self.glob_lookup = GlobLookup() self.magic_lookup = MagicLookup() nontext_chars = "\x01\x02\x03\x04\x05\x06\x0e\x0f"\ @@ -261,6 +261,7 @@ class LookupHelper: self.nontext = {} for char in nontext_chars: self.nontext[char] = True + self.remap_lookup = remap_lookup def is_binary(self, str): for char in str: @@ -268,7 +269,7 @@ class LookupHelper: return True return False - def lookup(self, filename, data): + def __lookup(self, filename, data): # spec says we try >= 80 priority magic matchers, then filename, then the other matchers threshold = 80 priorities = self.magic_lookup.priorities() @@ -289,6 +290,13 @@ class LookupHelper: return 'application/octet-stream' else: return 'text/plain' + + def lookup(self, *args, **kwargs): + rv = self.__lookup(*args, **kwargs) + if self.remap_lookup and self.remap_lookup.has_key(rv): + return self.remap_lookup[rv] + else: + return rv if __name__ == '__main__': c = LookupHelper() ============================================================ --- templates/revisionbrowse.html 66d38381f187bc229bccd5489ad81693460b68e9 +++ templates/revisionbrowse.html 1e37ebc587a7706215d068e0e27b9b3de31b0656 @@ -28,7 +28,7 @@ $branch_links #for $stanza_type, $this_path, $author, $ago, $content_mark, $shortlog, $mime_type in $entries - $mime_type + $mime_type #filter Filter ============================================================ --- viewmtn.py 076d0c375da6061f4076d409d9fefe2d4621aa29 +++ viewmtn.py fe2ae21cd72112b293f7523e31338fc417759bf5 @@ -355,7 +355,7 @@ ops = mtn.Operations([config.monotone, c renderer = Renderer() ops = mtn.Operations([config.monotone, config.dbfile]) -mimehelp = sharedmimeinfo.LookupHelper() +mimehelp = sharedmimeinfo.LookupHelper(getattr(config, "mime_map", None)) mimeicon = icontheme.MimeIcon(icontheme.IconTheme(config.icon_theme), config.icon_size) class Index: