Просмотр исходного кода

Merge pull request #296 from 2DU/master

베타로 상향
ect (or 2du) 8 лет назад
Родитель
Сommit
12cbe5d17a
4 измененных файлов с 143 добавлено и 78 удалено
  1. 108 56
      app.py
  2. 4 15
      func.py
  3. 30 6
      set_mark/table.py
  4. 1 1
      views/acme/css/bootstrap-reset.css

+ 108 - 56
app.py

@@ -7,12 +7,7 @@ import threading
 import logging
 logging.basicConfig(level = logging.ERROR)
 
-session_opts = {
-    'session.type': 'dbm',
-    'session.data_dir': './app_session/',
-    'session.auto': 1
-}
-
+session_opts = { 'session.type' : 'dbm', 'session.data_dir' : './app_session/', 'session.auto' : 1 }
 app = beaker.middleware.SessionMiddleware(app(), session_opts)
 BaseRequest.MEMFILE_MAX = 1000 ** 4
 r_ver = '2.5.1'
@@ -649,9 +644,15 @@ def user_log(num = 1):
         else:
             count = 0
 
-        list_data += '<hr><li>이 위키에는 ' + str(count) + '명의 사람이 있습니다.</li>'
+        list_data += '</ul><hr><ul><li>이 위키에는 ' + str(count) + '명의 사람이 있습니다.</li>'
         
-    list_data += '</ul><hr><a href="/user_log/' + str(num - 1) + '">(이전)</a> <a href="/user_log/' + str(num + 1) + '">(이후)</a>'
+    if(num == 1):
+        if(len(user_list) == 50):
+            list_data += '</ul><hr><a href="/user_log/' + str(num + 1) + '">(이후)</a>'
+    elif(len(user_list) != 50):
+        list_data += '</ul><hr><a href="/user_log/' + str(num - 1) + '">(이전)</a>'
+    else:
+        list_data += '</ul><hr><a href="/user_log/' + str(num - 1) + '">(이전)</a> <a href="/user_log/' + str(num + 1) + '">(이후)</a>'
 
     return(html_minify(template('index', 
         imp = ['사용자 가입 기록', wiki_set(conn, 1), custom(conn), other2([0, 0])],
@@ -675,27 +676,28 @@ def user_log(num = 1):
         ip = ip_pas(conn, data[0])
         list_data += '<li>' + ip + ' / ' + data[1] + ' / ' + data[2] + '</li>'
 
-    list_data += '</ul><hr><span>주의 : 권한 사용 안하고 열람만 해도 기록되는 경우도 있습니다.</span><hr>'
-    list_data += '<a href="/admin_log/' + str(num - 1) + '">(이전)</a> <a href="/admin_log/' + str(num + 1) + '">(이후)</a>'
+    list_data += '</ul><hr><ul><li>주의 : 권한 사용 안하고 열람만 해도 기록되는 경우도 있습니다.</li></ul>'
+
+    if(num == 1):
+        if(len(get_list) == 50):
+            list_data += '<hr><a href="/admin_log/' + str(num + 1) + '">(이후)</a>'
+    elif(len(get_list) != 50):
+        list_data += '<hr><a href="/admin_log/' + str(num - 1) + '">(이전)</a>'
+    else:
+        list_data += '<hr><a href="/admin_log/' + str(num - 1) + '">(이전)</a> <a href="/admin_log/' + str(num + 1) + '">(이후)</a>'
 
     return(html_minify(template('index', 
-        imp = ['관리자 권한 기록', wiki_set(conn, 1), custom(conn), other2([0, 0])],
+        imp = ['권한 사용 기록', wiki_set(conn, 1), custom(conn), other2([0, 0])],
         data = list_data,
         menu = [['other', '기타']]
     )))
 
 @route('/give_log')
-@route('/give_log/<num:int>')
-def give_log(num = 1):
-    if(num * 50 > 0):
-        sql_num = num * 50 - 50
-    else:
-        sql_num = 0
-        
+def give_log():        
     list_data = '<ul>'
     back = ''
 
-    curs.execute("select distinct name from alist order by name asc limit ?, '50'", [str(sql_num)])
+    curs.execute("select distinct name from alist order by name asc")
     get_list = curs.fetchall()
     for data in get_list:                      
         if(back != data[0]):
@@ -704,7 +706,6 @@ def give_log(num = 1):
         list_data += '<li><a href="/admin_plus/' + url_pas(data[0]) + '">' + data[0] + '</a></li>'
     
     list_data += '</ul><hr><a href="/manager/8">(생성)</a>'
-    list_data += '<hr><a href="/give_log/' + str(num - 1) + '">(이전)</a> <a href="/give_log/' + str(num + 1) + '">(이후)</a>'
 
     return(html_minify(template('index', 
         imp = ['권한 목록', wiki_set(conn, 1), custom(conn), other2([0, 0])],
@@ -745,7 +746,8 @@ def xref(name = None, num = 1):
     div = '<ul>'
     
     curs.execute("select link, type from back where title = ? and not type = 'cat' and not type = 'no' order by link asc limit ?, '50'", [name, str(sql_num)])
-    for data in curs.fetchall():
+    data_list = curs.fetchall()
+    for data in data_list:
         div += '<li><a href="/w/' + url_pas(data[0]) + '">' + data[0] + '</a>'
         
         if(data[1]):
@@ -763,7 +765,13 @@ def xref(name = None, num = 1):
         if(re.search('^틀:', data[0])):
             div += '<li><a id="inside" href="/xref/' + url_pas(data[0]) + '">' + data[0] + '</a> (역링크)</li>'
       
-    div += '</ul><hr><a href="/xref/' + url_pas(name) + '/num/' + str(num - 1) + '">(이전)</a> <a href="/xref/' + url_pas(name) + '/num/' + str(num + 1) + '">(이후)</a>'
+    if(num == 1):
+        if(len(data_list) == 50):
+            div += '</ul><hr><a href="/xref/' + url_pas(name) + '/num/' + str(num + 1) + '">(이후)</a>'
+    elif(len(data_list) != 50):
+        div += '</ul><hr><a href="/xref/' + url_pas(name) + '/num/' + str(num - 1) + '">(이전)</a>'
+    else:
+        div += '</ul><hr><a href="/xref/' + url_pas(name) + '/num/' + str(num - 1) + '">(이전)</a> <a href="/xref/' + url_pas(name) + '/num/' + str(num + 1) + '">(이후)</a>'
     
     return(html_minify(template('index', 
         imp = [name, wiki_set(conn, 1), custom(conn), other2([' (역링크)', 0])],
@@ -783,12 +791,19 @@ def please(num = 1):
     var = ''
     
     curs.execute("select distinct title from back where type = 'no' order by title asc limit ?, '50'", [str(sql_num)])
-    for data in curs.fetchall():
+    data_list = curs.fetchall()
+    for data in data_list:
         if(var != data[0]):
             div += '<li><a class="not_thing" href="/w/' + url_pas(data[0]) + '">' + data[0] + '</a></li>'        
             var = data[0]
         
-    div += '</ul><hr><a href="/please/' + str(num - 1) + '">(이전)</a> <a href="/please/' + str(num + 1) + '">(이후)</a>'
+    if(num == 1):
+        if(len(data_list) == 50):
+            div += '</ul><hr><a href="/please/' + str(num + 1) + '">(이후)</a>'
+    elif(len(data_list) != 50):
+        div += '</ul><hr><a href="/please/' + str(num - 1) + '">(이전)</a>'
+    else:
+        div += '</ul><hr><a href="/please/' + str(num - 1) + '">(이전)</a> <a href="/please/' + str(num + 1) + '">(이후)</a>'
     
     return(html_minify(template('index', 
         imp = ['필요한 문서', wiki_set(conn, 1), custom(conn), other2([0, 0])],
@@ -894,7 +909,9 @@ def block_log(num = 1, name = None, tool = None, tool2 = None):
 
             curs.execute("select why, block, blocker, end, today from rb where blocker = ? order by today desc limit ?, '50'", [name, str(sql_num)])
 
-    for data in curs.fetchall():
+    data_list = curs.fetchall()
+
+    for data in data_list:
         why = html.escape(data[0])
 
         if(why == ''):
@@ -915,7 +932,14 @@ def block_log(num = 1, name = None, tool = None, tool2 = None):
         div += '<tr><td colspan="3">' + why + '</td></tr>'
 
     div += '</tbody></table><hr>'
-    div += '<a href="/block_log/' + str(num - 1) + '">(이전)</a> <a href="/block_log/' + str(num + 1) + '">(이후)</a>'
+
+    if(num == 1):
+        if(len(data_list) == 50):
+            div += '<a href="/block_log/' + str(num + 1) + '">(이후)</a>'
+    elif(len(data_list) != 50):
+        div += '<a href="/block_log/' + str(num - 1) + '">(이전)</a>'
+    else:
+        div += '<a href="/block_log/' + str(num - 1) + '">(이전)</a> <a href="/block_log/' + str(num + 1) + '">(이후)</a>'
                 
     return(html_minify(template('index', 
         imp = ['차단 기록', wiki_set(conn, 1), custom(conn), other2([sub, 0])],
@@ -947,18 +971,16 @@ def deep_search(name = None, num = 1):
     div = '<ul>'
     div_plus = ''
     no = 0
-
-    curs.execute("select distinct title from data where title like ? or data like ? order by case when title like ? then 1 else 2 end limit ?, '50'", ['%' + name + '%', '%' + name + '%', '%' + name + '%', str(sql_num)])
-    all_list = curs.fetchall()
+    start = 2
 
     curs.execute("select title from data where title = ?", [name])
-    exist = curs.fetchall()
-    if(exist):
+    if(curs.fetchall()):
         div = '<ul><li>문서로 <a href="/w/' + url_pas(name) + '">바로가기</a></li><hr>'
     else:
         div = '<ul><li>문서가 없습니다. <a class="not_thing" href="/w/' + url_pas(name) + '">바로가기</a></li><hr>'
-    
-    start = 2
+
+    curs.execute("select distinct title from data where title like ? or data like ? order by case when title like ? then 1 else 2 end limit ?, '50'", ['%' + name + '%', '%' + name + '%', '%' + name + '%', str(sql_num)])
+    all_list = curs.fetchall()
     if(all_list):
         for data in all_list:
             try:
@@ -985,7 +1007,14 @@ def deep_search(name = None, num = 1):
         div += '<li>검색 결과 없음</li>'
 
     div += div_plus
-    div += '</ul><hr><a href="/search/' + url_pas(name) + '/' + str(num - 1) + '">(이전)</a> <a href="/search/' + url_pas(name) + '/' + str(num + 1) + '">(이후)</a>'
+
+    if(num == 1):
+        if(len(all_list) == 50):
+            div += '</ul><hr><a href="/search/' + url_pas(name) + '/' + str(num + 1) + '">(이후)</a>'
+    elif(len(all_list) != 50):
+        div += '</ul><hr><a href="/search/' + url_pas(name) + '/' + str(num - 1) + '">(이전)</a>'
+    else:
+        div += '</ul><hr><a href="/search/' + url_pas(name) + '/' + str(num - 1) + '">(이전)</a> <a href="/search/' + url_pas(name) + '/' + str(num + 1) + '">(이후)</a>'
     
     return(html_minify(template('index', 
         imp = [name, wiki_set(conn, 1), custom(conn), other2([' (검색)', 0])],
@@ -1268,7 +1297,6 @@ def edit(name = None, name2 = None, num = None):
             for data_list in data:
                 match = re.compile(data_list[0])
                 if(match.search(request.forms.content)):
-                    print(data_list[1])
                     if(data_list[1] == 'X'):
                         rb_plus(conn, ip, '', get_time(), '도구:편집 필터', '편집 필터에 의한 차단')
                         curs.execute("insert into ban (block, end, why, band) values (?, '', ?, '')", [ip, '편집 필터에 의한 차단'])
@@ -1442,7 +1470,6 @@ def preview(name = None, num = None):
 
     ip = ip_check()
     can = acl_check(conn, name)
-    captcha = captcha_get(conn)
     
     if(can == 1):
         return(re_error(conn, '/ban'))
@@ -1462,7 +1489,6 @@ def preview(name = None, num = None):
                     <textarea rows="25" name="content">' + html.escape(request.forms.content) + '</textarea> \
                     <textarea style="display: none;" name="otent">' + html.escape(request.forms.otent) + '</textarea><hr> \
                     <input placeholder="사유" name="send" type="text"><hr> \
-                    ' + captcha + ' \
                     <button id="preview" class="btn btn-primary" type="submit">저장</button> \
                     <button id="preview" class="btn" type="submit" formaction="/preview/' + url_pas(name) + action + '">미리보기</button> \
                 </form><hr>' + enddata,
@@ -1524,16 +1550,8 @@ def delete(name = None):
         )))            
             
 @route('/move_data/<name:path>')
-@route('/move_data/<name:path>/num/<num:int>')
-def move_data(name = None, num = 1):
-    if(num * 50 > 0):
-        sql_num = num * 50 - 50
-    else:
-        sql_num = 0
-
-    data = '<ul>'
-    
-    curs.execute("select send, date, ip from history where send like ? or send like ? order by date desc limit ?, '50'", ['%<a href="/w/' + url_pas(name) + '">' + name + '</a> 이동)%', '%(<a href="/w/' + url_pas(name) + '">' + name + '</a>%', str(sql_num)])
+def move_data(name = None):    
+    curs.execute("select send, date, ip from history where send like ? or send like ? order by date desc", ['%<a href="/w/' + url_pas(name) + '">' + name + '</a> 이동)%', '%(<a href="/w/' + url_pas(name) + '">' + name + '</a>%'])
     for for_data in curs.fetchall():
         match = re.findall('<a href="\/w\/(?:(?:(?!">).)+)">((?:(?!<\/a>).)+)<\/a>', for_data[0])
         send = re.sub('\([^\)]+\)$', '', for_data[0])
@@ -1543,7 +1561,7 @@ def move_data(name = None, num = 1):
         data += '<li><a href="/move_data/' + url_pas(match[0]) + '">' + match[0] + '</a> - <a href="/move_data/' + url_pas(match[1]) + '">' + match[1] + '</a>'
         data += ' / ' + for_data[2] + ' / ' + for_data[1] + ' / ' + send + '</li>'
     
-    data += '</ul><hr><a href="/move_data/' + url_pas(name) + '/num/' + str(num - 1) + '">(이전)</a> <a href="/move_data/' + url_pas(name) + '/num/' + str(num + 1) + '">(이후)</a>'
+    data = '<ul>' + data + '</ul>'
     
     return(html_minify(template('index', 
         imp = [name, wiki_set(conn, 1), custom(conn), other2([' (이동 기록)', 0])],
@@ -1620,7 +1638,7 @@ def other():
                             '== 기록 ==\r\n' + \
                             ' * [[wiki:block_log|차단 기록]]\r\n' + \
                             ' * [[wiki:user_log|가입 기록]]\r\n' + \
-                            ' * [[wiki:admin_log|권한 기록]]\r\n' + \
+                            ' * [[wiki:admin_log|권한 사용 기록]]\r\n' + \
                             ' * [[wiki:manager/6|편집 기록]]\r\n' + \
                             ' * [[wiki:manager/7|토론 기록]]\r\n' + \
                             '== 목록 ==\r\n' + \
@@ -1759,7 +1777,13 @@ def title_index(num = 100, page = 1):
         data += '<li>나머지 문서는 총 ' + str(count_end[5]) + '개의 문서가 있습니다.</li>'
 
     if(num != 0):
-        data += '</ul><hr><a href="/title_index/' + str(num) + '/' + str(page - 1) + '">(이전)</a> <a href="/title_index/' + str(num) + '/' + str(page + 1) + '">(이후)</a>'
+        if(page == 1):
+            if(len(title_list) == num):
+                data += '</ul><hr><a href="/title_index/' + str(num) + '/' + str(page + 1) + '">(이후)</a>'
+        elif(len(title_list) != num):
+            data += '</ul><hr><a href="/title_index/' + str(num) + '/' + str(page - 1) + '">(이전)</a>'
+        else:
+            data += '</ul><hr><a href="/title_index/' + str(num) + '/' + str(page - 1) + '">(이전)</a> <a href="/title_index/' + str(num) + '/' + str(page + 1) + '">(이후)</a>'
     
     if(' (' + str(num) + '개)' == ' (0개)'):
         sub = 0
@@ -2886,7 +2910,8 @@ def user_topic_list(name = None, num = 1):
     div = '<a href="/record/' + url_pas(name) + '">(편집 기록)</a><hr>' + div
     
     curs.execute("select title, id, sub, ip, date from topic where ip = ? order by date desc limit ?, '50'", [name, str(sql_num)])
-    for data in curs.fetchall():
+    data_list = curs.fetchall()
+    for data in data_list:
         title = html.escape(data[0])
         sub = html.escape(data[2])
             
@@ -2905,7 +2930,14 @@ def user_topic_list(name = None, num = 1):
         div += '<td>' + ip + ban +  '</td><td>' + data[4] + '</td></tr>'
 
     div += '</tbody></table>'
-    div += '<hr><a href="/topic_record/' + url_pas(name) + '/' + str(num - 1) + '">(이전)</a> <a href="/topic_record/' + url_pas(name) + '/' + str(num + 1) + '">(이후)</a>'
+
+    if(num == 1):
+        if(len(data_list) == 50):
+            div += '<hr><a href="/topic_record/' + url_pas(name) + '/' + str(num + 1) + '">(이후)</a>'
+    elif(len(data_list) != 50):
+        div += '<hr><a href="/topic_record/' + url_pas(name) + '/' + str(num - 1) + '">(이전)</a>'
+    else:
+        div += '<hr><a href="/topic_record/' + url_pas(name) + '/' + str(num - 1) + '">(이전)</a> <a href="/topic_record/' + url_pas(name) + '/' + str(num + 1) + '">(이후)</a>'
                 
     curs.execute("select end, why from ban where block = ?", [name])
     ban_it = curs.fetchall()
@@ -2989,7 +3021,8 @@ def recent_changes(name = None, num = 1, what = 'all', tool = 'record'):
 
                 curs.execute("select id, title, date, ip, send, leng from history where send like ? order by date desc limit 50", [sql])
 
-        for data in curs.fetchall():    
+        data_list = curs.fetchall()
+        for data in data_list:    
             select += '<option value="' + data[0] + '">' + data[0] + '</option>'     
             send = '<br>'
             if(data[4]):
@@ -3064,7 +3097,14 @@ def recent_changes(name = None, num = 1, what = 'all', tool = 'record'):
                 title = name
                 sub += ' (역사)'
                 menu = [['w/' + url_pas(name), '문서'], ['move_data/' + url_pas(name), '이동 기록']]
-                div += '<hr><a href="/history/' + url_pas(name) + '/num/' + str(num - 1) + '">(이전)</a> <a href="/history/' + url_pas(name) + '/num/' + str(num + 1) + '">(이후)</a>'
+                
+                if(num == 1):
+                    if(len(data_list) == 50):
+                        div += '<hr><a href="/history/' + url_pas(name) + '/num/' + str(num + 1) + '">(이후)</a>'
+                elif(len(data_list) != 50):
+                    div += '<hr><a href="/history/' + url_pas(name) + '/num/' + str(num - 1) + '">(이전)</a>'
+                else:
+                    div += '<hr><a href="/history/' + url_pas(name) + '/num/' + str(num - 1) + '">(이전)</a> <a href="/history/' + url_pas(name) + '/num/' + str(num + 1) + '">(이후)</a>'
             else:
                 curs.execute("select end, why from ban where block = ?", [name])
                 ban_it = curs.fetchall()
@@ -3074,9 +3114,21 @@ def recent_changes(name = None, num = 1, what = 'all', tool = 'record'):
                 title = '편집 기록'
                 menu = [['other', '기타'], ['user', '사용자'], ['count/' + url_pas(name), '횟수']]
                 if(what):
-                    div += '<hr><a href="/record/' + url_pas(name) + '/' + str(num - 1) + '/' + url_pas(what) + '">(이전)</a> <a href="/record/' + url_pas(name) + '/' + str(num + 1) + '/' + url_pas(what) + '">(이후)</a>'
+                    if(num == 1):
+                        if(len(data_list) == 50):
+                            div += '<hr><a href="/record/' + url_pas(name) + '/' + str(num + 1) + '/' + url_pas(what) + '">(이후)</a>'
+                    elif(len(data_list) != 50):
+                        div += '<hr><a href="/record/' + url_pas(name) + '/' + str(num - 1) + '/' + url_pas(what) + '">(이전)</a>'
+                    else:
+                        div += '<hr><a href="/record/' + url_pas(name) + '/' + str(num - 1) + '/' + url_pas(what) + '">(이전)</a> <a href="/record/' + url_pas(name) + '/' + str(num + 1) + '/' + url_pas(what) + '">(이후)</a>'
                 else:
-                    div += '<hr><a href="/record/' + url_pas(name) + '/' + str(num - 1) + '">(이전)</a> <a href="/record/' + url_pas(name) + '/' + str(num + 1) + '">(이후)</a>'
+                    if(num == 1):
+                        if(len(data_list) == 50):
+                            div += '<hr><a href="/record/' + url_pas(name) + '/' + str(num + 1) + '">(이후)</a>'
+                    elif(len(data_list) != 50):
+                        div += '<hr><a href="/record/' + url_pas(name) + '/' + str(num - 1) + '">(이전)</a>'
+                    else:
+                        div += '<hr><a href="/record/' + url_pas(name) + '/' + str(num - 1) + '">(이전)</a> <a href="/record/' + url_pas(name) + '/' + str(num + 1) + '">(이후)</a>'
 
                 if(what != 'all'):
                     menu += [['record/' + url_pas(name), '일반']]

+ 4 - 15
func.py

@@ -17,12 +17,7 @@ from set_mark.mark import *
 from set_mark.link import url_pas
 from set_mark.link import sha224
     
-session_opts = {
-    'session.type': 'dbm',
-    'session.data_dir': './app_session/',
-    'session.auto': 1
-}
-
+session_opts = { 'session.type' : 'dbm', 'session.data_dir' : './app_session/', 'session.auto' : 1 }
 app = beaker.middleware.SessionMiddleware(app(), session_opts)
 
 def captcha_get(conn):
@@ -30,7 +25,7 @@ def captcha_get(conn):
     curs = conn.cursor()
 
     data = ''
-    if(re.search('\.|:', ip_check()) and (not session.get('Awaken') or session.get('Awaken') != 1)):
+    if(re.search('\.|:', ip_check())):
         curs.execute('select data from other where name = "recaptcha"')
         recaptcha = curs.fetchall()
         if(recaptcha and recaptcha[0][0] != ''):
@@ -46,7 +41,7 @@ def captcha_post(response, conn, num = 1):
     curs = conn.cursor()
 
     if(num == 1):
-        if(re.search('\.|:', ip_check()) and (not session.get('Awaken') or session.get('Awaken') != 1) and captcha_get(conn) != ''):
+        if(re.search('\.|:', ip_check()) and captcha_get(conn) != ''):
             curs.execute('select data from other where name = "sec_re"')
             sec_re = curs.fetchall()
             if(sec_re and sec_re[0][0] != ''):
@@ -57,12 +52,6 @@ def captcha_post(response, conn, num = 1):
                 else:
                     json_data = data.json()
 
-                    try:
-                        json_data['error-codes']
-                        return(0)
-                    except:
-                        pass
-
                     if(data.status_code == 200 and json_data['success'] == True):
                         return(0)
                     else:
@@ -72,7 +61,7 @@ def captcha_post(response, conn, num = 1):
         else:
             return(0)
     else:
-        session['Awaken'] = 1
+        pass
 
 def skin_check(conn):
     curs = conn.cursor()

+ 30 - 6
set_mark/table.py

@@ -136,7 +136,7 @@ def table(data):
             results = m.groups()
             table = results[0]
             while(1):
-                a = re.search("^(\|\|(?:(?:\|\|)*))((?:&lt;(?:(?:(?!&gt;).)*)&gt;)*)((?:(?!\|\|).)*)", table)
+                a = re.search("^(\|\|(?:(?:\|\|)*))((?:&lt;(?:(?:(?!&gt;).)*)&gt;)*)((?:(?!\|\||<\/td>).)*)", table)
                 if(a):
                     row = ''
                     cel = ''
@@ -160,14 +160,22 @@ def table(data):
                         table = re.sub("^(\|\|(?:(?:\|\|)*))((?:&lt;(?:(?:(?!&gt;).)*)&gt;)*)", "<table " + table_class + " " + alltable + "><tbody><tr " + rowstyle + "><td " + cel + " " + row + " " + celstyle + ">", table, 1)
                     else:
                         cel = 'colspan="' + str(round(len(result[0]) / 2)) + '"'
-                        table = re.sub("^(\|\|(?:(?:\|\|)*))((?:&lt;(?:(?:(?!&gt;).)*)&gt;)*)", "<table><tbody><tr><td " + cel + ">", table, 1)
+
+                        if(re.search('^ (.*) $', result[2])):
+                            celstyle += 'text-align: center;'
+                        elif(re.search('^ (.*)$', result[2])):
+                            celstyle += 'text-align: right;'
+                        elif(re.search('^(.*) $', result[2])):
+                            celstyle += 'text-align: left;'
+
+                        table = re.sub("^(\|\|(?:(?:\|\|)*))((?:&lt;(?:(?:(?!&gt;).)*)&gt;)*)", "<table><tbody><tr><td " + cel + " style='" + celstyle + "'>", table, 1)
                 else:
                     break
                     
             table = re.sub("\|\|$", "</td></tr></tbody></table>", table)
             
             while(1):
-                b = re.search("\|\|\r\n(\|\|(?:(?:\|\|)*))((?:&lt;(?:(?:(?!&gt;).)*)&gt;)*)((?:(?!\|\|).)*)", table)
+                b = re.search("\|\|\r\n(\|\|(?:(?:\|\|)*))((?:&lt;(?:(?:(?!&gt;).)*)&gt;)*)((?:(?!\|\||<\/td>).)*)", table)
                 if(b):
                     row = ''
                     cel = ''
@@ -186,12 +194,20 @@ def table(data):
                         table = re.sub("\|\|\r\n(\|\|(?:(?:\|\|)*))((?:&lt;(?:(?:(?!&gt;).)*)&gt;)*)", "</td></tr><tr " + rowstyle + "><td " + cel + " " + row + " " + celstyle + ">", table, 1)
                     else:
                         cel = 'colspan="' + str(round(len(result[0]) / 2)) + '"'
-                        table = re.sub("\|\|\r\n(\|\|(?:(?:\|\|)*))((?:&lt;(?:(?:(?!&gt;).)*)&gt;)*)", "</td></tr><tr><td " + cel + ">", table, 1)
+
+                        if(re.search('^ (.*) $', result[2])):
+                            celstyle += 'text-align: center;'
+                        elif(re.search('^ (.*)$', result[2])):
+                            celstyle += 'text-align: right;'
+                        elif(re.search('^(.*) $', result[2])):
+                            celstyle += 'text-align: left;'
+
+                        table = re.sub("\|\|\r\n(\|\|(?:(?:\|\|)*))((?:&lt;(?:(?:(?!&gt;).)*)&gt;)*)", "</td></tr><tr><td " + cel + " style='" + celstyle + "'>", table, 1)
                 else:
                     break
 
             while(1):
-                c = re.search("(\|\|(?:(?:\|\|)*))((?:&lt;(?:(?:(?!&gt;).)*)&gt;)*)((?:(?!\|\|).)*)", table)
+                c = re.search("(\|\|(?:(?:\|\|)*))((?:&lt;(?:(?:(?!&gt;).)*)&gt;)*)((?:(?!\|\||<\/td>).)*)", table)
                 if(c):
                     row = ''
                     cel = ''
@@ -208,7 +224,15 @@ def table(data):
                         table = re.sub("(\|\|(?:(?:\|\|)*))((?:&lt;(?:(?:(?!&gt;).)*)&gt;)*)", "</td><td " + cel + " " + row + " " + celstyle + ">", table, 1)
                     else:
                         cel = 'colspan="' + str(round(len(result[0]) / 2)) + '"'
-                        table = re.sub("(\|\|(?:(?:\|\|)*))((?:&lt;(?:(?:(?!&gt;).)*)&gt;)*)", "</td><td " + cel + ">", table, 1)
+
+                        if(re.search('^ (.*) $', result[2])):
+                            celstyle += 'text-align: center;'
+                        elif(re.search('^ (.*)$', result[2])):
+                            celstyle += 'text-align: right;'
+                        elif(re.search('^(.*) $', result[2])):
+                            celstyle += 'text-align: left;'
+
+                        table = re.sub("(\|\|(?:(?:\|\|)*))((?:&lt;(?:(?:(?!&gt;).)*)&gt;)*)", "</td><td " + cel + " style='" + celstyle + "'>", table, 1)
                 else:
                     break
             

+ 1 - 1
views/acme/css/bootstrap-reset.css

@@ -388,7 +388,7 @@ input {
     border: 1px solid black;
     padding: 5px;
     margin-top: -30px;
-    margin-bottom: 10px;
+    margin-bottom: 20px;
     word-break: break-all;
 }