Commits

reorx  committed f9b3967

before go

  • Participants
  • Parent commits a2e4a92

Comments (0)

Files changed (11)

File custom/tests.pyc

Binary file added.

File my_filters/__init__.py

Empty file added.

File my_filters/__init__.pyc

Binary file added.

File my_filters/templatetags/__init__.py

Empty file added.

File my_filters/templatetags/__init__.pyc

Binary file added.

File my_filters/templatetags/my_filters.py

+#coding=utf-8
+
+from django import template
+from django.utils.encoding import force_unicode
+from django.template.defaultfilters import stringfilter
+
+register = template.Library()
+
+@register.filter
+@stringfilter
+def numRise(value, r):
+    return str(int(value) + int(r))
+
+@register.filter
+@stringfilter
+def numFall(value, r):
+    return str(int(value) - int(r))
+
+
+# before
+@register.filter
+@stringfilter
+def truncatefilter(value, num):
+    try:
+        length = int(num)
+    except ValeError:
+        return value
+    unicode_value = force_unicode(value)
+    if length < unicode_value.__len__():
+        value = unicode_value[:length] + '...'
+    else:
+        value = unicode_value
+    return value
+truncatefilter.is_safe = True
+

File my_filters/templatetags/my_filters.pyc

Binary file added.

File utils/__init__.py

Empty file added.

File utils/__init__.pyc

Binary file added.
+def getPageFinal(a,l):
+    if a%l == 0: return a/l - 1
+    else: return a/l
+
+def pageSplit(list,limit,now):
+
+    new_list = []
+    new_list = list[limit*now:limit*(now+1)]
+    # page dealt
+
+    final = getPageFinal(len(list),limit)
+
+    class page:pass
+    page.list = []
+
+    if now < 4: # pre 3 not change show style
+        if final < 5:
+            for i in range(final + 1):
+                page.list.append(str(i))
+        else:
+            for i in range(5):
+                page.list.append(str(i))
+            if final > 4:
+                page.list.append('...')
+    else: # show pre 2 and next 2(if has)
+        page.list.append('...')
+        for i in now-2, now-1:
+            page.list.append(str(i))
+        page.list.append(str(now))
+        if (final - now) <= 2:
+            print range(final - now)
+            for i in range(final - now):
+                page.list.append(str(now+i+1))
+            if final> 4:
+                page.list.append('...')
+
+    page.now = str(now)
+    page.pre = str(now-1)
+    page.next = str(now+1)
+    page.final = str(final)
+
+    return new_list,page
+
+

File utils/fn.pyc

Binary file added.