diff --git a/filebrowser/base.py b/filebrowser/base.py index eca1aa4..c6f3639 100644 --- a/filebrowser/base.py +++ b/filebrowser/base.py @@ -9,7 +9,8 @@ # filebrowser imports from filebrowser.settings import * -from filebrowser.functions import get_file_type, url_join, is_selectable, get_version_path +from filebrowser.functions import get_file_type, url_join, is_selectable, \ + get_version_path, path_strip from django.utils.encoding import force_unicode # PIL import @@ -30,8 +31,8 @@ class FileObject(object): """ def __init__(self, path): - self.path = path - self.url_rel = path.replace("\\","/") + self.path = path_strip(path, DIRECTORY) + self.url_rel = self.path.replace("\\","/") self.head = os.path.split(path)[0] self.filename = os.path.split(path)[1] self.filename_lower = self.filename.lower() # important for sorting @@ -85,7 +86,7 @@ def _path_full(self): """ return os.path.join(MEDIA_ROOT, self.path) path_full = property(_path_full) - + def _path_relative(self): return self.path path_relative = property(_path_relative) @@ -115,7 +116,11 @@ def _url_save(self): URL used for the filebrowsefield. """ if SAVE_FULL_URL: - return self.url_full + if SAVE_DOMAIN_URL: + from django.contrib.sites.models import Site + return 'http://%s%s' % (Site.objects.get_current().domain, self.url_full) + else: + return self.url_full else: return self.url_rel url_save = property(_url_save) diff --git a/filebrowser/functions.py b/filebrowser/functions.py index f546dc2..dfc5839 100755 --- a/filebrowser/functions.py +++ b/filebrowser/functions.py @@ -371,4 +371,12 @@ def convert_filename(value): else: return value +def path_strip(path, root): + if not path or not root: + return path + path = os.path.normcase(path) + root = os.path.normcase(root) + if path.startswith(root): + return path[len(root):] + return path diff --git a/filebrowser/locale/pt/LC_MESSAGES/django.mo b/filebrowser/locale/pt/LC_MESSAGES/django.mo new file mode 100644 index 0000000..08e9a25 Binary files /dev/null and b/filebrowser/locale/pt/LC_MESSAGES/django.mo differ diff --git a/filebrowser/locale/pt/LC_MESSAGES/django.po b/filebrowser/locale/pt/LC_MESSAGES/django.po new file mode 100644 index 0000000..881c1aa --- /dev/null +++ b/filebrowser/locale/pt/LC_MESSAGES/django.po @@ -0,0 +1,377 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2012-02-25 16:22+0000\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=(n != 1)\n" + +#: fields.py:58 +#, python-format +msgid "Extension %(ext)s is not allowed. Only %(allowed)s is allowed." +msgstr "Extensão %(ext)s não é permitida. Apenas %(allowed)s é permitida." + +#: forms.py:26 templates/filebrowser/versions.html:63 +msgid "Name" +msgstr "Nome" + +#: forms.py:26 forms.py:32 forms.py:49 forms.py:55 +msgid "Only letters, numbers, underscores, spaces and hyphens are allowed." +msgstr "Somente letras, números, sublinhados, espaços e hífens são permitidos." + +#: forms.py:35 forms.py:58 +msgid "The Folder already exists." +msgstr "A pasta já existe." + +#: forms.py:49 +msgid "New Name" +msgstr "Novo Nome" + +#: forms.py:60 +msgid "The File already exists." +msgstr "O ficheiro já existe." + +#: settings.py:119 +msgid "Folder" +msgstr "Pasta" + +#: settings.py:120 +msgid "Image" +msgstr "Imagem" + +#: settings.py:121 +msgid "Video" +msgstr "" + +#: settings.py:122 +msgid "Document" +msgstr "Documento" + +#: settings.py:123 +msgid "Audio" +msgstr "" + +#: settings.py:124 +msgid "Code" +msgstr "Código" + +#: views.py:58 views.py:168 views.py:223 views.py:321 views.py:403 +#: views.py:464 +msgid "The requested Folder does not exist." +msgstr "A pasta que solicitou não existe." + +#: views.py:62 +msgid "Error finding Upload-Folder. Maybe it does not exist?" +msgstr "Erro ao localizar o upload da pasta. Talvez ela não existe?" + +#: views.py:145 templates/filebrowser/append.html:5 +#: templates/filebrowser/append.html:7 +#: templates/filebrowser/include/breadcrumbs.html:8 +#: templates/filebrowser/include/breadcrumbs.html:10 +msgid "FileBrowser" +msgstr "Explorador de Arquivos" + +#: views.py:186 +#, python-format +msgid "The Folder %s was successfully created." +msgstr "A pasta %s foi criada com sucesso." + +#: views.py:195 +msgid "Permission denied." +msgstr "Permissão negada." + +#: views.py:197 +msgid "Error creating folder." +msgstr "Erro ao criar pasta." + +#: views.py:204 views.py:207 templates/filebrowser/index.html:48 +msgid "New Folder" +msgstr "Nova Pasta" + +#: views.py:235 +msgid "Select files to upload" +msgstr "Seleccione os ficheiros para upload" + +#: views.py:239 templates/filebrowser/index.html:49 +#: templates/filebrowser/upload.html:111 +msgid "Upload" +msgstr "" + +#: views.py:323 views.py:405 views.py:466 +msgid "The requested File does not exist." +msgstr "A ficheiro que solicitou não existe." + +#: views.py:346 +#, python-format +msgid "The file %s was successfully deleted." +msgstr "O arquivo %s foi eliminado com sucesso." + +#: views.py:362 +#, python-format +msgid "The folder %s was successfully deleted." +msgstr "A pasta %s foi eliminada com sucesso." + +#: views.py:432 +msgid "Renaming was successful." +msgstr "Renomeação foi bem sucedida." + +#: views.py:437 +msgid "Error." +msgstr "Erro" + +#: views.py:445 +#, python-format +msgid "Rename \"%s\"" +msgstr "Renomear \"%s\"" + +#: views.py:448 templates/filebrowser/include/filelisting.html:86 +msgid "Rename" +msgstr "Renomear" + +#: views.py:474 views.py:477 +#, python-format +msgid "Versions for \"%s\"" +msgstr "Versões para \"%s\"" + +#: templates/filebrowser/makedir.html:24 templates/filebrowser/rename.html:25 +msgid "Please correct the following errors." +msgstr "Por favor, corrija os seguintes erros." + +#: templates/filebrowser/makedir.html:33 templates/filebrowser/upload.html:101 +msgid "" +"The Name will be converted to lowercase. Spaces will be replaced with " +"underscores." +msgstr "" +"O Nome será convertido para minúsculas. Espaços serão substituídos por " +"sublinhados" + +#: templates/filebrowser/makedir.html:39 templates/filebrowser/rename.html:36 +msgid "Submit" +msgstr "Submeter" + +#: templates/filebrowser/upload.html:47 +msgid "BROWSE" +msgstr "Pesquisar" + +#: templates/filebrowser/upload.html:48 +msgid "An Error occured" +msgstr "Ocorreu um erro" + +#: templates/filebrowser/upload.html:49 +msgid "Completed" +msgstr "Concluído" + +#: templates/filebrowser/upload.html:50 +msgid "Do you want to replace the file" +msgstr "Quer substituir o ficheiro" + +#: templates/filebrowser/upload.html:51 +msgid "KB" +msgstr "" + +#: templates/filebrowser/upload.html:52 +msgid "MB" +msgstr "" + +#: templates/filebrowser/upload.html:85 +msgid "Help" +msgstr "Ajuda" + +#: templates/filebrowser/upload.html:89 +msgid "Allowed" +msgstr "Permitido" + +#: templates/filebrowser/upload.html:95 +msgid "Max. Filesize" +msgstr "Max. Tamanho" + +#: templates/filebrowser/upload.html:109 +msgid "Clear Queue" +msgstr "Limpar fila" + +#: templates/filebrowser/versions.html:66 +msgid "Image Version" +msgstr "Versão da imagem" + +#: templates/filebrowser/versions.html:69 +msgid "Debug" +msgstr "" + +#: templates/filebrowser/versions.html:83 +#: templates/filebrowser/versions.html:95 +#: templates/filebrowser/versions.html:107 +#: templates/filebrowser/include/filelisting.html:11 +#: templates/filebrowser/include/filelisting.html:23 +#: templates/filebrowser/include/filelisting.html:35 +msgid "Select" +msgstr "Seleccionar" + +#: templates/filebrowser/versions.html:118 +msgid "Width" +msgstr "Largura" + +#: templates/filebrowser/versions.html:119 +msgid "Height" +msgstr "Altura" + +#: templates/filebrowser/include/breadcrumbs.html:5 +msgid "Home" +msgstr "" + +#: templates/filebrowser/include/filelisting.html:50 +msgid "View Image" +msgstr "Ver Imagem" + +#: templates/filebrowser/include/filelisting.html:73 +msgid "Versions" +msgstr "Versões" + +#: templates/filebrowser/include/filelisting.html:92 +msgid "Are you sure you want to delete this file?" +msgstr "Tem certeza de que deseja excluir este ficheiro?" + +#: templates/filebrowser/include/filelisting.html:92 +msgid "Delete File" +msgstr "Excluir ficheiro" + +#: templates/filebrowser/include/filelisting.html:95 +msgid "Are you sure you want to delete this Folder?" +msgstr "Tem certeza de que deseja excluir esta pasta" + +#: templates/filebrowser/include/filelisting.html:95 +msgid "Delete Folder" +msgstr "Excluir pasta" + +#: templates/filebrowser/include/filter.html:3 +msgid "Filter" +msgstr "Filtro" + +#: templates/filebrowser/include/filter.html:9 +msgid "By Date" +msgstr "Por Data" + +#: templates/filebrowser/include/filter.html:11 +msgid "Any Date" +msgstr "Qualquer Data" + +#: templates/filebrowser/include/filter.html:13 +msgid "Today" +msgstr "Hoje" + +#: templates/filebrowser/include/filter.html:15 +msgid "Past 7 days" +msgstr "Últimos 7 dias" + +#: templates/filebrowser/include/filter.html:17 +msgid "Past 30 days" +msgstr "Últimos 30 dias" + +#: templates/filebrowser/include/filter.html:19 +msgid "This year" +msgstr "Este ano" + +#: templates/filebrowser/include/filter.html:27 +msgid "By Type" +msgstr "Por Tipo" + +#: templates/filebrowser/include/filter.html:29 +msgid "All" +msgstr "Tudo" + +#: templates/filebrowser/include/paginator.html:5 +msgid "No Items Found" +msgstr "Nenhum item encontrado" + +#: templates/filebrowser/include/paginator.html:11 +#, python-format +msgid "%(counter)s Item" +msgid_plural "%(counter)s Items" +msgstr[0] "%(counter)s Item" +msgstr[1] "%(counter)s Itens" + +#: templates/filebrowser/include/paginator.html:26 +msgid "No Items" +msgstr "Nenhum Item" + +#: templates/filebrowser/include/search.html:3 +#, python-format +msgid "1 result" +msgid_plural "%(counter)s results" +msgstr[0] "1 resultados" +msgstr[1] "%(counter)s resultados" + +#: templates/filebrowser/include/search.html:4 +#: templates/filebrowser/include/toolbar.html:19 +#, python-format +msgid "%(full_result_count)s total" +msgstr "" + +#: templates/filebrowser/include/search.html:5 +msgid "Clear Restrictions" +msgstr "Limpar Restrictions" + +#: templates/filebrowser/include/search.html:7 +#: templates/filebrowser/include/toolbar.html:16 +msgid "Search" +msgstr "Pesquisar" + +#: templates/filebrowser/include/search.html:19 +msgid "Go" +msgstr "Ir" + +#: templates/filebrowser/include/search.html:24 +#, python-format +msgid "%(counter)s Item found" +msgid_plural "%(counter)s Items found" +msgstr[0] "%(counter)s Item encontrado" +msgstr[1] "%(counter)s Itens encontrados" + +#: templates/filebrowser/include/search.html:25 +#, python-format +msgid "%(counter)s Item total" +msgid_plural "%(counter)s Items total" +msgstr[0] "%(counter)s Item total" +msgstr[1] "%(counter)s Itens total" + +#: templates/filebrowser/include/tableheader.html:9 +#: templates/filebrowser/include/tableheader.html:10 +msgid "Type" +msgstr "tipo" + +#: templates/filebrowser/include/tableheader.html:12 +msgid "Thumbnail" +msgstr "Miniatura" + +#: templates/filebrowser/include/tableheader.html:14 +#: templates/filebrowser/include/tableheader.html:15 +msgid "Filename" +msgstr "Nome do ficheiro" + +#: templates/filebrowser/include/tableheader.html:17 +#: templates/filebrowser/include/tableheader.html:18 +msgid "Size" +msgstr "Tamanho" + +#: templates/filebrowser/include/tableheader.html:20 +#: templates/filebrowser/include/tableheader.html:21 +msgid "Date" +msgstr "Data" + +#: templates/filebrowser/include/toolbar.html:19 +#, python-format +msgid "%(counter)s result" +msgid_plural "%(counter)s results" +msgstr[0] "%(counter)s resultado" +msgstr[1] "%(counter)s resultados" diff --git a/filebrowser/settings.py b/filebrowser/settings.py index cd30086..972313e 100755 --- a/filebrowser/settings.py +++ b/filebrowser/settings.py @@ -87,6 +87,8 @@ # or False (default) to save path relative to MEDIA_URL. # Note: Full URL does not necessarily means absolute URL. SAVE_FULL_URL = getattr(settings, "FILEBROWSER_SAVE_FULL_URL", True) +#Absolute URL +SAVE_DOMAIN_URL = getattr(settings,"FILEBROWSER_SAVE_ABSOLUTE_URL", False) # If set to True, the FileBrowser will not try to import a mis-installed PIL. STRICT_PIL = getattr(settings, 'FILEBROWSER_STRICT_PIL', False) # PIL's Error "Suspension not allowed here" work around: diff --git a/filebrowser/templatetags/fb_tags.py b/filebrowser/templatetags/fb_tags.py index 3106cf5..2f9e37f 100644 --- a/filebrowser/templatetags/fb_tags.py +++ b/filebrowser/templatetags/fb_tags.py @@ -152,5 +152,5 @@ def custom_admin_media_prefix(): from django.contrib.admin.templatetags import admin_media_prefix except ImportError: from django.contrib.admin.templatetags.adminmedia import admin_media_prefix - return admin_media_prefix + return admin_media_prefix()