Browse files

Updated wiki syntax : two brackets are needed now

  • Loading branch information...
1 parent 1f2d787 commit 2a4538efbded6375773b55291a236e2fc573730b @pjgrizel pjgrizel committed May 17, 2011
View
20 twistranet/fixtures/help_en.py
@@ -16,7 +16,7 @@
description_en = "twistranet is a social network "
"tailored for enterprise needs. Learn how to use it within 10 minutes.",
description_fr = "twistranet est un Réseau Social d'Entreprise. <br />"
- "Apprenez à l'utiliser en 10 minutes&nbsp;!",
+ "Apprenez à l'utiliser en 10 minutes!",
text_en = """<h2>Getting started</h2>
<p>
If you can read that document, that probably means you're already connected to twistranet!
@@ -26,15 +26,15 @@
<tr>
<th width="33%">
<p>Find your co-workers</p>
- [address_64]
+ [[Image:address_64]]
</th>
<th width="33%">
<p>Share with your network</p>
- [bubble_64]
+ [[Image:bubble_64]]
</th>
<th width="33%">
<p>Publish content</p>
- [document_64]
+ [[Image:document_64]]
</th>
</tr>
<tr>
@@ -74,15 +74,15 @@
<tr>
<th width="33%">
<p>Trouvez vos collègues</p>
- [address_64]
+ [[Image:address_64]]
</th>
<th width="33%">
<p>Partagez avec votre réseau</p>
- [bubble_64]
+ [[Image:bubble_64]]
</th>
<th width="33%">
<p>Publiez du contenu</p>
- [document_64]
+ [[Image:document_64]]
</th>
</tr>
<tr>
@@ -155,15 +155,15 @@
<tr>
<th width="33%">
<p>Teamwork, teamwork, teamwork!</p>
- [diagram_64]
+ [[Image:diagram_64]]
</th>
<th width="33%">
<p>Easy blogging</p>
- [bubble_64]
+ [[Image:bubble_64]]
</th>
<th width="33%">
<p>Involve stakeholders</p>
- [heart_64]
+ [[Image:heart_64]]
</th>
</tr>
<tr>
View
1 twistranet/project_templates/cogip/fixtures/cogip.py
@@ -82,6 +82,7 @@ def load_cogip():
Community,
slug = service_slug,
title = useraccount['service'],
+ description = useraccount['service'],
permissions = "blog",
logged_account = username,
force_update = True,
View
4 twistranet/twistapp/locale/fr/LC_MESSAGES/django.po
@@ -976,7 +976,7 @@ msgid ""
" </p>\n"
" <p>\n"
" Want to learn about what you can do in twistranet? "
-"Just take a look here: [help]\n"
+"Just take a look here: [[help]]\n"
" </p>\n"
" "
msgstr ""
@@ -988,7 +988,7 @@ msgstr ""
"sur quoi vous travaillez dans le formulaire ci-dessous et cliquez sur "
"'Envoyer'. </p> <p> Envie d'en savoir plus sur "
"<strong>twistranet</strong>&nbsp;? Consultez l'aide en ligne ici : "
-"[help]. </p>\n"
+"[[help]]. </p>\n"
" "
#: .\views\account_views.py:99
View
46 twistranet/twistapp/templatetags/wiki.py
@@ -25,8 +25,10 @@
non_a_tag = re.compile(r"""[^"']%s[^"']""" % URL_REGEX)
account_slug_regex = re.compile(r"@(?P<Alias>%s)" % slugify.SLUG_REGEX)
account_id_regex = re.compile(r"@(?P<Alias>\d+)")
-content_slug_regex = re.compile(r"\[\s*(?P<Alias>%s)\s*\]" % slugify.SLUG_REGEX)
-content_id_regex = re.compile(r"\[\s*(?P<Alias>\d+)\s*\]")
+content_slug_regex = re.compile(r"\[\[\s*(?P<Alias>%s)\s*\]\]" % slugify.SLUG_REGEX)
+content_id_regex = re.compile(r"\[\[\s*(?P<Alias>\d+)\s*\]\]")
+resource_slug_regex = re.compile(r"\[\[\s*[a-zA-Z_]+:(?P<Alias>%s)\s*\]\]" % slugify.SLUG_REGEX)
+resource_id_regex = re.compile(r"\[\[\s*[a-zA-Z_]+:(?P<Alias>\d+)\s*\]\]")
def resource_image(resource):
"""
@@ -43,23 +45,35 @@ def resource_image(resource):
return """<a href="%(url)s" title="%(title)s"><img class="image-inline" src="%(thumburl)s" alt="%(title)s" /></a>""" % d
return """<a href="%(url)s" title="%(title)s"><img class="file-icon" src="%(thumburl)s" /><span>%(title)s</span></a>""" % d
+def unbracket(text):
+ """
+ Remove brackets
+ """
+ save_text = text
+ text = re.sub(r"\[\[\s*[a-zA-Z_]+:", "", text)
+ text = re.sub(r"\[\[\s*", "", text)
+ text = re.sub(r"\s*\]\]", "", text)
+ print "%s => %s" % (save_text, text, )
+ return text
matches = (
- # regex, fast_reverse, func, model, lookup field
- (account_id_regex, 'account_by_id', None, Account, "id", ),
- (account_slug_regex, 'account_by_slug', None, Account, "slug", ),
-# (content_id_regex, 'content_by_id', None, Content, "id", ),
- (content_slug_regex, 'content_by_slug', None, Content, "slug", ),
- (content_id_regex, 'resource_by_id', resource_image, Resource, "id", ),
-# (content_slug_regex, 'resource_by_slug', resource_image, Resource, "slug", ),
+
+ # regex, fast_reverse, full_func, fast_func, model, lookup field
+ (account_id_regex, 'account_by_id', None, None, Account, "id", ),
+ (account_slug_regex, 'account_by_slug', None, None, Account, "slug", ),
+# (content_id_regex, 'content_by_id', None, None, Content, "id", ),
+ (content_slug_regex, 'content_by_slug', None, unbracket, Content, "slug", ),
+ (resource_id_regex, 'resource_by_id', resource_image, unbracket, Resource, "id", ),
+ (resource_slug_regex, 'resource_by_slug', resource_image, unbracket, Resource, "slug", ),
)
class Subf(object):
- def __init__(self, lookup, fast_reverse, func, model, lookup_field, ):
+ def __init__(self, lookup, fast_reverse, full_func, fast_func, model, lookup_field, ):
self.lookup = lookup
self.fast_reverse = fast_reverse
- self.func = func
+ self.full_func = full_func
+ self.fast_func = fast_func
self.model = model
self.lookup_field = lookup_field
@@ -69,8 +83,10 @@ def __call__(self, match):
Function passed to re.sub()
"""
label = match.group(0)
+ label = self.fast_func and self.fast_func(label) or label
title = None
obj = None
+
if self.lookup:
try:
kw = {self.lookup_field: match.groupdict()['Alias']}
@@ -85,8 +101,8 @@ def __call__(self, match):
else:
url = reverse(self.fast_reverse, args = (match.groupdict()['Alias'],))
- if self.func and obj:
- subst = self.func(obj)
+ if self.full_func and obj:
+ subst = self.full_func(obj)
else:
subst = '<a href="%s" title="%s">%s</a>' % (url, title or label, label)
@@ -118,8 +134,8 @@ def escape_wiki(text, lookup = False, autoescape=None):
text = conditional_escape(text)
# Replace the global matches
- for regex, fast_reverse, func, model_class, lookup_field in matches:
- subf = Subf(lookup, fast_reverse, func, model_class, lookup_field )
+ for regex, fast_reverse, full_func, fast_func, model_class, lookup_field in matches:
+ subf = Subf(lookup, fast_reverse, full_func, fast_func, model_class, lookup_field )
text = regex.sub(subf, text)

0 comments on commit 2a4538e

Please sign in to comment.