Permalink
Browse files

Merge trunk inside

  • Loading branch information...
2 parents c1b189a + 8fbb937 commit 1046a7cfdadc512750b52be6465f6bb385507f24 @macadames macadames committed Oct 3, 2011
View
@@ -1,3 +1,40 @@
+1.1.4, 2011/10/04
+=================
+
+- minor fix for mixed emails : the good mime type is multipart/related
+
+- important fix : The send images as attachments was broken
+ attachments were sent but the html tag was always containing inline images
+
+1.1.3, 2011/09/15
+=================
+
+- Fix https://github.com/numericube/twistranet/issues/27
+ (submit comment button disappears after a wall reload)
+
+- Fix https://github.com/numericube/twistranet/issues/31
+ (stop walls reload when a comment form is not empty)
+
+- Do not erase comment text field when clicking on "show all comments"
+
+- Now the number of comments is more visible
+ see ticket https://github.com/numericube/twistranet/issues/24
+
+1.1.2, 2011/08/30
+=================
+
+- Fix ticket https://github.com/numericube/twistranet/issues/7
+
+- Fix ticket https://github.com/numericube/twistranet/issues/28
+
+- Open external links in new window, new local setting true/false added
+ first part of ticket https://github.com/numericube/twistranet/issues/23
+
+1.1.1, 2011/07/29
+==================
+
+- fix sorl thumbnail error with CMJK images
+ https://github.com/numericube/twistranet/issues/22
1.1.0, 2011/05/16
==================
@@ -1,3 +1,3 @@
__author__ = 'numeriCube'
-VERSION = (1, 1, 0)
+VERSION = (1, 1, 4)
__version__ = '.'.join(map(str, VERSION))
@@ -214,7 +214,6 @@ def __call__(self, sender, **kwargs):
# Prepare messages
msg = EmailMultiAlternatives(subject, text_content, from_email, [ to ], )
if html_content:
- msg.attach_alternative(html_content, "text/html")
if getattr(settings, 'SEND_EMAIL_IMAGES_AS_ATTACHMENTS', DEFAULT_SEND_EMAIL_IMAGES_AS_ATTACHMENTS):
# we replace img links by img Mime Images
mimeimages = []
@@ -240,8 +239,9 @@ def replace_img_url(match):
img_url_expr = re.compile('(?P<attribute>src)\s*=\s*([\'\"])(%s)?(?P<urlpath>[^\"\']*)\\2' %domain, re.IGNORECASE)
html_content = img_url_expr.sub(replace_img_url, html_content)
+ msg.attach_alternative(html_content, "text/html")
if mimeimages:
- msg.mixed_subtype = 'relative'
+ msg.mixed_subtype = 'related'
for fkey, name, is_static in mimeimages:
if cache_mimeimages.has_key(fkey):
msgImage = cache_mimeimages[fkey]
@@ -255,6 +255,9 @@ def replace_img_url(match):
msgImage.add_header('Content-ID', '<%s>' % name)
msgImage.add_header('Content-Disposition', 'inline')
msg.attach(msgImage)
+ # just inline images
+ else:
+ msg.attach_alternative(html_content, "text/html")
# Send safely
try:
log.debug("Sending mail: '%s' from '%s' to '%s'" % (subject, from_email, to))
@@ -50,6 +50,8 @@
# Timeout for walls automatic reload in ms, 0 = no reload
WALLS_RELOAD_TIMEOUT = 120000
+# Open external links in a new window
+EXTERNAL_LINKS_NEW_WIN = True
# #
# Hosting settings #
# #
@@ -300,9 +300,6 @@
cursor: default;
}
-
-.comment_count {font-weight: bold;}
-
.few-comments .comment_count,
.add-comment .comment_count {display: none;}
@@ -32,22 +32,30 @@ loadLastComment = function(comments_container, html) {
jq('form:first', comments_container).before(html);
window.setTimeout(function() {jq('.comment-description-field', comments_container).trigger('focusout')}, 3);
twistranet.showCommentsActions();
+ comments_container.initExternalLinks();
}
loadComments = function(ID, html) {
comments_container = jq("#view_comments"+ID);
+ prev_comment = jq('.comment-description-field', comments_container).val();
comments_container.empty();
comments_container.prepend(html);
jq("#view"+ID).parent().css('visibility','hidden');
twistranet.showCommentsActions();
commentOnSubmit(comments_container);
commentOnFocus(comments_container);
- jq('.comment-description-field', comments_container).focus();
+ comment_field = jq('.comment-description-field', comments_container);
+ /* XXX TODO JMG : load only the comments, no more the comment form here
+ need some template + js refactor */
+ comment_field.val(prev_comment);
+ comment_field.focus();
+ comments_container.initExternalLinks();
}
commentOnFocus = function(comments_container) {
jq('.comment-description-field', comments_container).val(base_comment_message);
jq('.comment-description-field', comments_container).focusin(function(){
+ jq('#reload_wall').val('');
comment = jq(this).val();
if (comment==base_comment_message) jq(this).val('');
jq(this).addClass('comment-active');
@@ -60,6 +68,7 @@ commentOnFocus = function(comments_container) {
if (!comment) {
jq(this).removeClass('comment-active');
jq(this).val(base_comment_message);
+ jq('#reload_wall').val('1');
jq('input[type=submit]', comments_container).hide();
}
});
@@ -339,7 +339,7 @@ addInlineMessage = function (msg, msgtype) {
reloadWall = function() {
- if (!reset_reload_timeout) {
+ if (jq('#reload_wall').val()=='1' && !reset_reload_timeout) {
jq('#content').waitLoading('top:150px;left:47%;');
jq.ajax({
type: "GET",
@@ -355,11 +355,13 @@ reloadWall = function() {
jq(document).ready(function() {
jq('#content').stopWaitLoading();
jq('.fieldset-inline-form:last').after(htmlcontent);
- if (reloadtimeout && jq('#reload_wall').val()=='1') window.setTimeout(reloadWall,reloadtimeout);
+ if (reloadtimeout) window.setTimeout(reloadWall,reloadtimeout);
setFirstAndLast('#content', '.post');
// for now we just remove all possibles messages (for deletion, etc ...)
// but we could want to add a new message here ?
jq("#tn-message").remove();
+ jq("#content").initExternalLinks();
+ twistranet.initCommentForms();
});
},
error: function(jqXHR, textStatus, errorThrown) {
@@ -371,7 +373,7 @@ reloadWall = function() {
}
else {
reset_reload_timeout=0;
- if (reloadtimeout && jq('#reload_wall').val()=='1') window.setTimeout(reloadWall,reloadtimeout);
+ if (reloadtimeout) window.setTimeout(reloadWall,reloadtimeout);
}
}
// main class
@@ -398,6 +400,7 @@ var twistranet = {
this.formInputsHints();
this.loadUploaders();
this.initWysiwygBrowser();
+ $('body').initExternalLinks();
},
setBrowserProperties : function(e) {
if (! this.browser_width){
@@ -441,6 +444,15 @@ var twistranet = {
block.remove();
}
});
+ },
+ initExternalLinks: function() {
+ if (external_links_new_win) {
+ jq("a[href^='http:']", this).each(function(){
+ if(jq(this).attr("href").search(location.host) == -1){
+ jq(this).attr("target", "_blank");
+ }
+ });
+ }
}
});
},
@@ -482,6 +494,8 @@ var twistranet = {
success: function(htmlcontent){
bottomBar.replaceWith(htmlcontent);
setFirstAndLast('#content', '.post');
+ jq("#content").initExternalLinks();
+ self.initCommentForms();
}
});
return false;
@@ -521,6 +535,8 @@ var twistranet = {
self.formInputsHints();
self.loadUploaders();
tnResourceWidget();
+ jq("#content").initExternalLinks();
+ self.initCommentForms();
});
}
});
@@ -576,11 +592,11 @@ var twistranet = {
},
showCommentsActions: function(e){
/* show content actions on post mouseover */
- jq('.comment').bind('mouseenter', function(){
+ jq('.comment').live('mouseenter', function(){
jq(this).addClass('activecomment');
jq(this).parents('.post').removeClass('activepost');
});
- jq('.comment').bind('mouseleave', function(){
+ jq('.comment').live('mouseleave', function(){
jq(this).removeClass('activecomment');
jq(this).parents('.post').addClass('activepost');
});
@@ -10,8 +10,8 @@ class ForgottenPasswordForm(forms.Form):
User Creation form.
We add a few things to make this shiny.
"""
- email = forms.EmailField(
- label = _("Enter your email address:"),
+ email = forms.CharField(
+ label = _("Enter your email address or username:"),
max_length = 40,
)
@@ -22,14 +22,21 @@ def clean_email(self,):
email = self.cleaned_data["email"]
# Check that user exists
- try:
- user = User.objects.get(email = email)
- except User.DoesNotExist:
- raise forms.ValidationError(_("This email is not registerd."))
-
+ # email could be username or user email
+ # we always return the user email to the view
+ if "@" in email:
+ try:
+ user = User.objects.get(email = email)
+ except User.DoesNotExist:
+ raise forms.ValidationError(_("This email is not registered."))
+ else:
+ try:
+ user = User.objects.get(username = email)
+ except User.DoesNotExist:
+ raise forms.ValidationError(_("This username is not registered."))
# Check that password is valid
if user.password == UNUSABLE_PASSWORD:
- raise forms.ValidationError(_("Can't retrieve password for this email. Ask your system administrator."))
+ raise forms.ValidationError(_("Can't retrieve password for this user or email. Ask your system administrator."))
return user.email
class Meta:
@@ -1,5 +1,7 @@
from django.core.cache import cache
from django.conf import settings
+from django.utils.html import *
+
def _get_site_name_or_baseline(return_baseline = False):
"""
@@ -130,4 +132,70 @@ def _check_file_size(data):
data.seek(0, os.SEEK_SET )
if file_size<=max_size:
return 1
- return 0
+ return 0
+
+# XXX mut be removed when django ticket https://code.djangoproject.com/ticket/9655
+# will be resolved
+def twist_urlize(text, trim_url_limit=None, nofollow=False, autoescape=False):
+ """
+ BASED on django.utils.html urlize
+ but also fix the bug https://code.djangoproject.com/ticket/9655
+
+ Original text :
+
+ Converts any URLs in text into clickable links.
+
+ Works on http://, https://, www. links and links ending in .org, .net or
+ .com. Links can have trailing punctuation (periods, commas, close-parens)
+ and leading punctuation (opening parens) and it'll still do the right
+ thing.
+
+ If trim_url_limit is not None, the URLs in link text longer than this limit
+ will truncated to trim_url_limit-3 characters and appended with an elipsis.
+
+ If nofollow is True, the URLs in link text will get a rel="nofollow"
+ attribute.
+
+ If autoescape is True, the link text and URLs will get autoescaped.
+ """
+ trim_url = lambda x, limit=trim_url_limit: limit is not None and (len(x) > limit and ('%s...' % x[:max(0, limit - 3)])) or x
+ safe_input = isinstance(text, SafeData)
+ words = word_split_re.split(force_unicode(text))
+ nofollow_attr = nofollow and ' rel="nofollow"' or ''
+ for i, word in enumerate(words):
+ match = None
+ if '.' in word or '@' in word or ':' in word:
+ match = punctuation_re.match(word)
+ if match:
+ lead, middle, trail = match.groups()
+ # Make URL we want to point to.
+ url = None
+ if middle.startswith('http://') or middle.startswith('https://'):
+ # XXX : The fix is here
+ url = urlquote(middle, safe='/%&=:;#?+*')
+ elif middle.startswith('www.') or ('@' not in middle and \
+ middle and middle[0] in string.ascii_letters + string.digits and \
+ (middle.endswith('.org') or middle.endswith('.net') or middle.endswith('.com'))):
+ url = urlquote('http://%s' % middle, safe='/&=:;#?+*')
+ elif '@' in middle and not ':' in middle and simple_email_re.match(middle):
+ url = 'mailto:%s' % middle
+ nofollow_attr = ''
+ # Make link.
+ if url:
+ trimmed = trim_url(middle)
+ if autoescape and not safe_input:
+ lead, trail = escape(lead), escape(trail)
+ url, trimmed = escape(url), escape(trimmed)
+ middle = '<a href="%s"%s>%s</a>' % (url, nofollow_attr, trimmed)
+ words[i] = mark_safe('%s%s%s' % (lead, middle, trail))
+ else:
+ if safe_input:
+ words[i] = mark_safe(word)
+ elif autoescape:
+ words[i] = escape(word)
+ elif safe_input:
+ words[i] = mark_safe(word)
+ elif autoescape:
+ words[i] = escape(word)
+ return u''.join(words)
+twist_urlize = allow_lazy(twist_urlize, unicode)
Binary file not shown.
Oops, something went wrong.

0 comments on commit 1046a7c

Please sign in to comment.