Commit f7f6cdfe authored by Christophe Dumez's avatar Christophe Dumez

- Improved editPath to work with directories whenever possible

- Display fix in show highlighted file content function


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@6556 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 6cafee54
...@@ -381,19 +381,30 @@ class SubversionTool(UniqueObject, Folder): ...@@ -381,19 +381,30 @@ class SubversionTool(UniqueObject, Folder):
# path is the path in svn working copy # path is the path in svn working copy
# return edit_path in zodb to edit it
# return '#' if no zodb path is found
def editPath(self, bt, path): def editPath(self, bt, path):
"""Return path to edit file """Return path to edit file
""" """
if os.path.isdir(path): if 'bt' in path.split('/'):
# not in zodb
return '#' return '#'
svn_path = bt.getPortalObject().portal_preferences.getPreference('subversion_working_copy') svn_path = bt.getPortalObject().portal_preferences.getPreference('subversion_working_copy')
if not svn_path: if not svn_path:
raise 'Error: Please set working copy path in Subversion preferences !' raise 'Error: Please set working copy path in Subversion preferences !'
if svn_path[-1] != '/': if svn_path[-1] != '/':
svn_path += '/' svn_path += '/'
svn_path = svn_path + bt.getTitle() + '/' svn_path = svn_path + bt.getTitle()
edit_path = path.replace(svn_path, '') edit_path = path.replace(svn_path, '')
if edit_path.strip() == '':
# not in zodb
return '#'
if edit_path[0] == '/':
edit_path = edit_path[1:]
edit_path = '/'.join(edit_path.split('/')[1:]) edit_path = '/'.join(edit_path.split('/')[1:])
if edit_path.strip() == '':
# not in zodb
return '#'
tmp = re.search('\\.[\w]+$', edit_path) tmp = re.search('\\.[\w]+$', edit_path)
if tmp: if tmp:
extension = tmp.string[tmp.start():tmp.end()].strip() extension = tmp.string[tmp.start():tmp.end()].strip()
...@@ -459,7 +470,7 @@ class SubversionTool(UniqueObject, Folder): ...@@ -459,7 +470,7 @@ class SubversionTool(UniqueObject, Folder):
if os.path.exists(file_path): if os.path.exists(file_path):
if os.path.isdir(file_path): if os.path.isdir(file_path):
text = "<b>"+file_path+"</b><hr>" text = "<b>"+file_path+"</b><hr>"
text = file_path +" is a folder!" text += file_path +" is a folder!"
else: else:
head = "<b>"+file_path+"</b> <a href='"+self.editPath(bt, file_path)+"'><img src='imgs/edit.png' border='0'></a><hr>" head = "<b>"+file_path+"</b> <a href='"+self.editPath(bt, file_path)+"'><img src='imgs/edit.png' border='0'></a><hr>"
text = commands.getoutput('enscript -B --color --line-numbers --highlight=html --language=html -o - %s'%file_path) text = commands.getoutput('enscript -B --color --line-numbers --highlight=html --language=html -o - %s'%file_path)
...@@ -478,7 +489,7 @@ class SubversionTool(UniqueObject, Folder): ...@@ -478,7 +489,7 @@ class SubversionTool(UniqueObject, Folder):
text = head + '\n'.join(text.split('\n')[10:-4]) text = head + '\n'.join(text.split('\n')[10:-4])
else : # does not exist else : # does not exist
text = "<b>"+file_path+"</b><hr>" text = "<b>"+file_path+"</b><hr>"
text = file_path +" does not exist!" text += file_path +" does not exist!"
return text return text
security.declareProtected(Permissions.ManagePortal, 'acceptSSLServer') security.declareProtected(Permissions.ManagePortal, 'acceptSSLServer')
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment