import logging
logger = logging.getLogger("fnp.wiki")
-_PCHARS_DICT = dict(zip((ord(x) for x in u"ĄĆĘŁŃÓŚŻŹąćęłńóśżź "), u"ACELNOSZZacelnoszz_"))
+
+# _PCHARS_DICT = dict(zip((ord(x) for x in u"ĄĆĘŁŃÓŚŻŹąćęłńóśżź "), u"ACELNOSZZacelnoszz_"))
+_PCHARS_DICT = dict(zip((ord(x) for x in u" "), u"_"))
# I know this is barbaric, but I didn't find a better solution ;(
def split_name(name):
parts = name.translate(_PCHARS_DICT).split('__')
- logger.info("SPLIT %r -> %r", name, parts)
return parts
def join_name(*parts, **kwargs):
<button type="button" id="make-diff-button">{% trans "Compare versions" %}</button>
<button type="button" id="tag-changeset-button">{% trans "Mark version" %}</button>
<button id="open-preview-button"
- data-basehref="{% url wiki_details_readonly document_name %}">{% trans "View version" %}</button>
+ data-basehref="{% url wiki_editor_readonly document_name %}">{% trans "View version" %}</button>
</div>
<div id="history-view">
register = template.Library()
-# from wiki.models import split_name
+from wiki.models import split_name
@register.filter
@stringfilter
os.system("pip install -r %s" % os.path.join(ROOT, 'etc', 'requirements.txt'))
print "done."
-ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
PYTHON = os.path.join(ROOT, 'pythonenv', 'bin', 'python')
PYTHON_SITE = os.path.join(ROOT, 'pythonenv', 'lib', 'python2.6', 'site-packages')
PROJECT_NAME = 'redakcja'
-PROJECT_ROOT = os.path.join(ROOT, 'app')
+PROJECT_ROOT = os.path.join(ROOT, 'application')
MEDIA_ROOT = os.path.join(ROOT, 'www', 'media')
def _find_filectx(self, title, rev=None):
"""Find the last revision in which the file existed."""
- repo_file = self._title_to_file(title)
- changectx = self._changectx() # start with tip
- visited = set()
+ tip = self._changectx() # start with tip
- stack = [changectx]
- visited.add(changectx)
+ def tree_search(tip, repo_file):
+ logging.info("Searching for %r", repo_file)
+ current = tip
+ visited = set()
- while repo_file not in changectx:
- if not stack:
- raise DocumentNotFound(title)
+ stack = [current]
+ visited.add(current)
- changectx = stack.pop()
- for parent in changectx.parents():
- if parent not in visited:
- stack.append(parent)
- visited.add(parent)
+ while repo_file not in current:
+ if not stack:
+ raise LookupError
- try:
- fctx = changectx[repo_file]
+ current = stack.pop()
+ for parent in current.parents():
+ if parent not in visited:
+ stack.append(parent)
+ visited.add(parent)
+ fctx = current[repo_file]
if rev is not None:
fctx = fctx.filectx(rev)
fctx.filerev()
-
return fctx
+
+ try:
+ return tree_search(tip, self._title_to_file(title))
except (IndexError, LookupError) as e:
- raise DocumentNotFound(title)
+ logging.info("XML file not found, trying plain")
+ try:
+ return tree_search(tip, self._title_to_file(title, type=''))
+ except (IndexError, LookupError) as e:
+ raise DocumentNotFound(title)
def page_history(self, title):
"""Iterate over the page's history."""
# Import localsettings file, which may override settings defined here
+from localsettings import *
+
try:
import logging
if os.path.isfile(LOGGING_CONFIG_FILE):
else:
import sys
logging.basicConfig(stream=sys.stderr)
-except NameError:
- print "No logging"
- pass
except ImportError as exc:
raise