Skip to content

Instantly share code, notes, and snippets.

@faried
Created October 30, 2009 12:48
Show Gist options
  • Save faried/222313 to your computer and use it in GitHub Desktop.
Save faried/222313 to your computer and use it in GitHub Desktop.
Index: settings.py
===================================================================
--- settings.py (revision 117)
+++ settings.py (working copy)
@@ -372,8 +372,8 @@
# Things to measure to taste
MAX_COMMENT_LENGTH = 2000
+MAX_POST_LENGTH = 140
# Gdata Stuff
GDATA_CONSUMER_KEY = ''
GDATA_CONSUMER_SECRET = ''
Index: js/core.js
===================================================================
--- js/core.js (revision 117)
+++ js/core.js (working copy)
@@ -86,7 +86,7 @@
count: function () {
var value = counter.el.value;
var count = value.length;
- chars_left = 140 - count;
+ chars_left = maxpostlength - count;
if (chars_left >= 0) {
if ($(counter.target.parentNode).is('.overlimit')) {
$(counter.target.parentNode).removeClass("overlimit");
@@ -113,7 +113,7 @@
str = "1 character over limit";
}
}
- var ok = (count > 0 && count < 141) && (value.replace(counter.re,"") != counter.el._value);
+ var ok = (count > 0 && count <= maxpostlength) && (value.replace(counter.re,"") != counter.el._value);
counter.button.disabled = !ok;
counter.target.nodeValue = str;
}
Index: common/api.py
===================================================================
--- common/api.py (revision 117)
+++ common/api.py (working copy)
@@ -70,7 +70,7 @@
# Max length of a message. Conciseness is a virtue.
# UIs should prevent posting longer messages. API will truncate
# posts longer than this.
-MAX_POST_LENGTH = 140
+MAX_POST_LENGTH = settings.MAX_POST_LENGTH
# How many contacts we are willing to count to update an actor's
# contact_count or follower_count properties
Index: common/templates/message_form.html
===================================================================
--- common/templates/message_form.html (revision 117)
+++ common/templates/message_form.html (working copy)
@@ -27,7 +27,10 @@
{% endifequal %}
</p>
{% if not request.mobile %}
- <p id="counter">140 characters left</p>
+ <script type="text/javascript">
+ var maxpostlength = {{ MAX_POST_LENGTH }};
+ </script>
+ <p id="counter">{{ MAX_POST_LENGTH }} characters left</p>
<p id="icons">
<label for="icon" id="icon-label">Icon</label>
<select name="icon" id="icon">
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment