Commits

hoverhell committed 955fe28

modified pagination re in cmds

  • Participants
  • Parent commits b45f179

Comments (0)

Files changed (1)

File snapboard/cmds.py

 post_id_re_f = r'(?P<post_form_id>' + Post.id_m_re_f + r')'
 cmd_tag = r'[#!]'
 
-## XMPP-pagination stuff: x_ipp - items per page (optional).
-xmpppaginate_re = r'(?:(?P<x_ipp>\d+) (?P<x_page>\d+)|(?P<x_page>\d+))'
+### XMPP-pagination stuff: x_ipp - items per page (optional).
+## NOTE: enclosed as a whole in the unnamed group to be able to do
+##  `...nate_re + '?' + ...`
+## FAIL: can't define x_page twice.
+#xmpppaginate_re = r'(?:(?P<x_ipp>\d+) (?P<x_page>\d+)|(?P<x_page>\d+))'
+xmpppaginate_re = r'(?:/(?:(?P<x_ipp>\d+)/)?(?P<x_page>\d+))'
 
 ## Make a regexp (for command-word) with optional short form.
 cmd_word = lambda x, l=1: r'(?i)%s(?:%s)' % (x[:l], x[l:])
     (r'^' + cmd_word('last') + cmd_tag +
       '(?P<thread_id>\d+)l(?: (?P<num_posts>\d+))?$',
       thread_latest, {}, 'snapboard_thread_latest'),
-    (r'^' + cmd_tag + '( ' + xmpppaginate_re + '?)?$',
-      thread_index, {}, 'snapboard_thread_index'),  # spaces!
+    (r'^' + cmd_tag + xmpppaginate_re + '?$',
+      thread_index, {}, 'snapboard_thread_index'),
     (r'^/$', category_index, {}, 'snapboard_category_index'),
     (r'^/(?P<cat_id>[^/]+)$',
       category_thread_index, {}, 'category_thread_index'),
 
     (r'^' + cmd_tag + post_id_re_f + '$',
       thread_post, {}, 'snapboard_thread_post'),
+    ## XXX: The '[^ ]' there is to avoid mess between '# 10' and '#  10'
+    #(r'^' + cmd_tag + post_id_re_f + r'? (?P<POST_text>[^ ](.*\n?)+)',
+    #  post_reply, {}, 'snapboard_post_reply'),
     (r'^' + cmd_tag + post_id_re_f + r'? (?P<POST_text>(.*\n?)+)',
       post_reply, {}, 'snapboard_post_reply'),
     (r'^' + cmd_word('edit') + cmd_tag +