ect (or 2du) 8 лет назад
Родитель
Сommit
d2d4d65fbc
3 измененных файлов с 105 добавлено и 111 удалено
  1. 80 69
      app.py
  2. 4 6
      func.py
  3. 21 36
      views/acme/index.html

+ 80 - 69
app.py

@@ -1,4 +1,5 @@
-from flask import Flask, request, send_from_directory
+# 모듈 불러오기
+from flask import Flask, request, send_from_directory
 from flask_compress import Compress
 from flask_reggie import Reggie
 
@@ -14,15 +15,11 @@ import logging
 import random
 import sys
 
-logging.basicConfig(level = logging.ERROR)
-app = Flask(__name__)
-Reggie(app)
-compress = Compress()
-compress.init_app(app)
-
+# 버전 표기
 r_ver = 'v3.0.0 Beta'
 print('Version : ' + r_ver)
 
+# 나머지 불러오기
 from func import *
 from set_mark.tool import savemark
 
@@ -52,8 +49,18 @@ except:
 conn = sqlite3.connect(set_data['db'] + '.db', check_same_thread = False)
 curs = conn.cursor()
 
-# 스킨 불러오기 부분
-skin_check(conn)
+# 기타 설정 변경
+logging.basicConfig(level = logging.ERROR)
+app = Flask(__name__, template_folder = skin_check(conn))
+Reggie(app)
+compress = Compress()
+compress.init_app(app)
+
+# 템플릿 설정
+def regex(find, replace, data):
+    return re.sub(find, replace, data)
+
+app.jinja_env.filters['regex'] = regex
 
 # 셋업 부분
 curs.execute("create table if not exists data(title text, data text)")
@@ -77,11 +84,13 @@ curs.execute("create table if not exists scan(user text, title text)")
 curs.execute("create table if not exists acl(title text, dec text, dis text, why text)")
 curs.execute("create table if not exists inter(title text, link text)")
 
+# owner 존재 확인
 curs.execute("select name from alist where acl = 'owner'")
 if not curs.fetchall():
     curs.execute("delete from alist where name = 'owner'")
     curs.execute("insert into alist (name, acl) values ('owner', 'owner')")
 
+# 포트 점검
 curs.execute("select data from other where name = 'port'")
 rep_data = curs.fetchall()
 if not rep_data:
@@ -99,6 +108,7 @@ else:
     rep_port = rep_data[0][0]
     print('Port : ' + str(rep_port))
 
+# 비밀 키 점검
 curs.execute("select data from other where name = 'key'")
 rep_data = curs.fetchall()
 if not rep_data:
@@ -115,6 +125,7 @@ else:
     rep_key = rep_data[0][0]
     print('Secret Key : ' + rep_key)
 
+# 한번 개행
 print('')
 
 # 호환성 설정
@@ -182,7 +193,6 @@ try:
 except:
     pass
         
-
 conn.commit()
 
 # 이미지 폴더 생성
@@ -244,7 +254,7 @@ def alarm():
         da += '<li>알림이 없습니다.</li>'
     da += '</ul>'
 
-    return html_minify(template('index', 
+    return html_minify(render_template('index.html', 
         imp = ['알림', wiki_set(conn, 1), custom(conn), other2([0, 0])],
         data = da,
         menu = [['user', '사용자']]
@@ -277,7 +287,7 @@ def inter_wiki():
         if admin == 1:
             div += '<a href="/plus_inter">(추가)</a>'
 
-    return html_minify(template('index', 
+    return html_minify(render_template('index.html', 
         imp = ['인터위키 목록', wiki_set(conn, 1), custom(conn), other2([0, 0])],
         data = div,
         menu = [['other', '기타']]
@@ -303,7 +313,7 @@ def plus_inter():
     
         return redirect('/inter_wiki')
     else:
-        return html_minify(template('index', 
+        return html_minify(render_template('index.html', 
             imp = ['인터위키 목록', wiki_set(conn, 1), custom(conn), other2([0, 0])],
             data = '<form method="post"> \
                         <input placeholder="이름" type="text" name="title"><hr> \
@@ -327,7 +337,7 @@ def edit_set(num = 0):
             x += 1
             li_data += '<li><a href="/edit_set/' + str(x) + '">' + li + '</a></li>'
 
-        return html_minify(template('index', 
+        return html_minify(render_template('index.html', 
             imp = ['설정 편집', wiki_set(conn, 1), custom(conn), other2([0, 0])],
             data = '<h2>메뉴</h2><ul>' + li_data + '</ul>',
             menu = [['manager', '관리자']]
@@ -388,7 +398,7 @@ def edit_set(num = 0):
             if d_list[10]:
                 ch_3 = 'checked="checked"'                
 
-            return html_minify(template('index', 
+            return html_minify(render_template('index.html', 
                 imp = ['기본 설정', wiki_set(conn, 1), custom(conn), other2([0, 0])],
                 data = '<form method="post"> \
                             <span>이름</span><br><br> \
@@ -440,7 +450,7 @@ def edit_set(num = 0):
                 x += 1
             conn.commit()
 
-            return html_minify(template('index', 
+            return html_minify(render_template('index.html', 
                 imp = ['문구 관련', wiki_set(conn, 1), custom(conn), other2([0, 0])],
                 data = '<form method="post"> \
                             <span>가입 약관</span><br><br> \
@@ -470,7 +480,7 @@ def edit_set(num = 0):
             else:
                 data = ''
 
-            return html_minify(template('index', 
+            return html_minify(render_template('index.html', 
                 imp = ['전역 HEAD', wiki_set(conn, 1), custom(conn), other2([0, 0])],
                 data =  '<span>&lt;style&gt;CSS&lt;/style&gt;<br>&lt;script&gt;JS&lt;/script&gt;</span><hr> \
                         <form method="post"> \
@@ -512,7 +522,7 @@ def edit_set(num = 0):
             if not data or data == '':
                 data = ''.join(lines)
 
-            return html_minify(template('index', 
+            return html_minify(render_template('index.html', 
                 imp = ['robots.txt', wiki_set(conn, 1), custom(conn), other2([0, 0])],
                 data =  '<a href="/robots.txt">(보기)</a><hr> \
                         <form method="post"> \
@@ -547,7 +557,7 @@ def edit_set(num = 0):
                 x += 1
             conn.commit()
 
-            return html_minify(template('index', 
+            return html_minify(render_template('index.html', 
                 imp = ['구글 관련', wiki_set(conn, 1), custom(conn), other2([0, 0])],
                 data = '<form method="post"> \
                             <span>리캡차 (HTML)</span><br><br> \
@@ -575,7 +585,7 @@ def not_close_topic():
             
     div += '</ul>'
 
-    return html_minify(template('index', 
+    return html_minify(render_template('index.html', 
         imp = ['열린 토론 목록', wiki_set(conn, 1), custom(conn), other2([0, 0])],
         data = div,
         menu = [['manager', '관리자']]
@@ -605,7 +615,7 @@ def acl_list():
         
     div += '</ul>'
     
-    return html_minify(template('index', 
+    return html_minify(render_template('index.html', 
         imp = ['ACL 문서 목록', wiki_set(conn, 1), custom(conn), other2([0, 0])],
         data = div,
         menu = [['other', '기타']]
@@ -685,7 +695,7 @@ def admin_plus(name = None):
         data += '<li><input type="checkbox" ' + state +  ' name="give" ' + exist_list[6] + '> 권한 부여</li>'
         data += '<li><input type="checkbox" ' + state +  ' name="owner" ' + exist_list[7] + '> 소유자</li></ul>'
 
-        return html_minify(template('index', 
+        return html_minify(render_template('index.html', 
             imp = ['관리 그룹 추가', wiki_set(conn, 1), custom(conn), other2([0, 0])],
             data = '<form method="post">' + data + '<hr><button id="save" ' + state +  ' type="submit">저장</button></form>',
             menu = [['manager', '관리자']]
@@ -708,7 +718,7 @@ def admin_list():
         
     div += '</ul>'
                 
-    return html_minify(template('index', 
+    return html_minify(render_template('index.html', 
         imp = ['관리자 목록', wiki_set(conn, 1), custom(conn), other2([0, 0])],
         data = div,
         menu = [['other', '기타']]
@@ -773,7 +783,7 @@ def user_log():
 
     list_data += next_fix('/user_log?num=', num, user_list)
 
-    return html_minify(template('index', 
+    return html_minify(render_template('index.html', 
         imp = ['사용자 가입 기록', wiki_set(conn, 1), custom(conn), other2([0, 0])],
         data = list_data,
         menu = [['other', '기타']]
@@ -798,7 +808,7 @@ def admin_log():
     list_data += '</ul><hr><ul><li>주의 : 권한 사용 안하고 열람만 해도 기록되는 경우도 있습니다.</li></ul>'
     list_data += next_fix('/admin_log?num=', num, get_list)
 
-    return html_minify(template('index', 
+    return html_minify(render_template('index.html', 
         imp = ['권한 사용 기록', wiki_set(conn, 1), custom(conn), other2([0, 0])],
         data = list_data,
         menu = [['other', '기타']]
@@ -819,7 +829,7 @@ def give_log():
     
     list_data += '</ul><hr><a href="/manager/8">(생성)</a>'
 
-    return html_minify(template('index', 
+    return html_minify(render_template('index.html', 
         imp = ['관리 그룹 목록', wiki_set(conn, 1), custom(conn), other2([0, 0])],
         data = list_data,
         menu = [['other', '기타']]
@@ -912,7 +922,7 @@ def xref(name = None):
       
     div += '</ul>' + next_fix('/xref/' + url_pas(name) + '?num=', num, data_list)
     
-    return html_minify(template('index', 
+    return html_minify(render_template('index.html', 
         imp = [name, wiki_set(conn, 1), custom(conn), other2([' (역링크)', 0])],
         data = div,
         menu = [['w/' + url_pas(name), '문서']]
@@ -938,7 +948,7 @@ def please():
         
     div += '</ul>' + next_fix('/please?num=', num, data_list)
     
-    return html_minify(template('index', 
+    return html_minify(render_template('index.html', 
         imp = ['필요한 문서', wiki_set(conn, 1), custom(conn), other2([0, 0])],
         data = div,
         menu = [['other', '기타']]
@@ -981,7 +991,7 @@ def recent_discuss(tools = 'normal'):
     else:
         div += '</tbody></table>'
             
-    return html_minify(template('index', 
+    return html_minify(render_template('index.html', 
         imp = ['최근 토론내역', wiki_set(conn, 1), custom(conn), other2([m_sub, 0])],
         data = div,
         menu = 0
@@ -1083,7 +1093,7 @@ def block_log(name = None, tool = None, tool2 = None):
     else:
         div += next_fix('/' + url_pas(tool) + '/' + url_pas(name) + '?num=', num, data_list)
                 
-    return html_minify(template('index', 
+    return html_minify(render_template('index.html', 
         imp = ['차단 기록', wiki_set(conn, 1), custom(conn), other2([sub, 0])],
         data = div,
         menu = menu
@@ -1138,7 +1148,7 @@ def deep_search(name = None):
     div += div_plus + '</ul>'
     div += next_fix('/search/' + url_pas(name) + '?num=', num, all_list)
     
-    return html_minify(template('index', 
+    return html_minify(render_template('index.html', 
         imp = [name, wiki_set(conn, 1), custom(conn), other2([' (검색)', 0])],
         data = div,
         menu = 0
@@ -1181,7 +1191,7 @@ def raw_view(name = None, sub_t = None, num = None):
         
         p_data = '<textarea readonly rows="25">' + p_data + '</textarea>'
         
-        return html_minify(template('index', 
+        return html_minify(render_template('index.html', 
             imp = [v_name, wiki_set(conn, 1), custom(conn), other2([sub, 0])],
             data = p_data,
             menu = menu
@@ -1243,7 +1253,7 @@ def revert(name = None):
         if not curs.fetchall():
             return redirect('/w/' + url_pas(name))
 
-        return html_minify(template('index', 
+        return html_minify(render_template('index.html', 
             imp = [name, wiki_set(conn, 1), custom(conn), other2([' (되돌리기)', 0])],
             data =  '<form method="post"> \
                         <span>' + request.args.get('num', '0') + '판으로 되돌리겠습니까?</span><hr> \
@@ -1280,7 +1290,7 @@ def big_delete():
 
         return redirect('/')
     else:
-        return html_minify(template('index', 
+        return html_minify(render_template('index.html', 
             imp = ['많은 문서 삭제', wiki_set(conn, 1), custom(conn), other2([0, 0])],
             data = '<span>문서명 A<br>문서명 B<br>문서명 C<hr>이런 식으로 적으세요.</span><hr> \
                     <form method="post"> \
@@ -1303,7 +1313,7 @@ def edit_filter():
     div += '</ul>'
     div += '<hr><a href="/manager/9">(추가)</a>'
 
-    return html_minify(template('index', 
+    return html_minify(render_template('index.html', 
         imp = ['편집 필터 목록', wiki_set(conn, 1), custom(conn), other2([0, 0])],
         data = div,
         menu = [['manager', '관리자']]
@@ -1348,7 +1358,7 @@ def set_edit_filter(name = None):
         else:
             stat = ''
 
-        return html_minify(template('index', 
+        return html_minify(render_template('index.html', 
             imp = [name, wiki_set(conn, 1), custom(conn), other2([' (편집 필터)', 0])],
             data = '<form method="post"> \
                         <input ' + stat + ' placeholder="분 차단" name="end" value="' + html.escape(time_data) + '" type="text"><br><br><ul><li>비우면 영구 차단</li><li>1달은 28일로 취급</li></ul><hr> \
@@ -1455,7 +1465,7 @@ def edit(name = None):
                 data = get_data[0][0]
                 get_name = ''
 
-        return html_minify(template('index', 
+        return html_minify(render_template('index.html', 
             imp = [name, wiki_set(conn, 1), custom(conn), other2([' (수정)', 0])],
             data = get_name + ' \
                     <form method="post" action="/edit/' + url_pas(name) + action + '"> \
@@ -1493,7 +1503,7 @@ def preview(name = None):
     else:
         action = ''
 
-    return html_minify(template('index', 
+    return html_minify(render_template('index.html', 
         imp = [name, wiki_set(conn, 1), custom(conn), other2([' (미리보기)', 0])],
         data = '<form method="post" action="/edit/' + url_pas(name) + action + '"> \
                     <textarea rows="25" name="content">' + html.escape(request.form['content']) + '</textarea> \
@@ -1542,7 +1552,7 @@ def delete(name = None):
         if not curs.fetchall():
             return redirect('/w/' + url_pas(name))
 
-        return html_minify(template('index', 
+        return html_minify(render_template('index.html', 
             imp = [name, wiki_set(conn, 1), custom(conn), other2([' (삭제)', 0])],
             data = '<form method="post"> \
                         ' + ip_warring(conn) + ' \
@@ -1570,7 +1580,7 @@ def move_data(name = None):
     
     data += '</ul>'
     
-    return html_minify(template('index', 
+    return html_minify(render_template('index.html', 
         imp = [name, wiki_set(conn, 1), custom(conn), other2([' (이동 기록)', 0])],
         data = data,
         menu = [['history/' + url_pas(name), '역사']]
@@ -1618,7 +1628,7 @@ def move(name = None):
         
         return redirect('/w/' + url_pas(request.form['title']))
     else:            
-        return html_minify(template('index', 
+        return html_minify(render_template('index.html', 
             imp = [name, wiki_set(conn, 1), custom(conn), other2([' (이동)', 0])],
             data = '<form method="post"> \
                         ' + ip_warring(conn) + ' \
@@ -1632,7 +1642,7 @@ def move(name = None):
             
 @app.route('/other')
 def other():
-    return html_minify(template('index', 
+    return html_minify(render_template('index.html', 
         imp = ['기타 메뉴', wiki_set(conn, 1), custom(conn), other2([0, 0])],
         data = '<h2>기록</h2><ul><li><a href="/block_log">차단 기록</a></li><li><a href="/user_log">가입 기록</a></li><li><a href="/admin_log">권한 사용 기록</a></li><li><a href="/manager/6">편집 기록</a></li><li><a href="/manager/7">토론 기록</a></li></ul><br><h2>목록</h2><ul><li><a href="/admin_list">관리자 목록</a></li><li><a href="/give_log">관리 그룹 목록</a></li><li><a href="/not_close_topic">열린 토론 목록</a></li></ul><br><h2>기타</h2><ul><li><a href="/title_index">모든 문서</a></li><li><a href="/acl_list">ACL 문서</a></li><li><a href="/please">필요한 문서</a></li><li><a href="/upload">파일 올리기</a></li><li><a href="/manager/10">문서 검색</a></li></ul><br><h2>관리자</h2><ul><li><a href="/manager/1">관리자 메뉴</a></li></ul><br><h2>버전</h2><ul><li>이 오픈나무는 <a href="https://github.com/2DU/openNAMU/blob/master/version.md">' + r_ver + '</a> 입니다.</li></ul>',
         menu = 0
@@ -1643,7 +1653,7 @@ def other():
 def manager(num = 1):
     title_list = [['문서 ACL', '문서명', 'acl'], ['사용자 검사', 0, 'check'], ['사용자 차단', 0, 'ban'], ['권한 주기', 0, 'admin'], ['편집 기록', 0, 'record'], ['토론 기록', 0, 'topic_record'], ['그룹 생성', '그룹명', 'admin_plus'], ['편집 필터 생성', '필터명', 'edit_filter'], ['문서 검색', '문서명', 'search'], ['차단자 검색', 0, 'block_user'], ['관리자 검색', 0, 'block_admin'], ['주시 문서 추가', '문서명', 'watch_list']]
     if num == 1:
-        return html_minify(template('index', 
+        return html_minify(render_template('index.html', 
             imp = ['관리자 메뉴', wiki_set(conn, 1), custom(conn), other2([0, 0])],
             data = '<h2>목록</h2><ul><li><a href="/manager/2">문서 ACL</a></li><li><a href="/manager/3">사용자 검사</a></li><li><a href="/manager/4">사용자 차단</a></li><li><a href="/manager/5">권한 주기</a></li><li><a href="/big_delete">여러 문서 삭제</a></li><li><a href="edit_filter">편집 필터</a></li></ul><br><h2>소유자</h2><ul><li><a href="/indexing">인덱싱 (생성 or 삭제)</a></li><li><a href="/manager/8">관리 그룹 생성</a></li><li><a href="/edit_set">설정 편집</a></li><li><a href="/re_start">서버 재 시작</a></li><li><a href="/inter_wiki">인터위키</a></li></ul>',
             menu = [['other', '기타']]
@@ -1657,7 +1667,7 @@ def manager(num = 1):
             else:
                 placeholder = title_list[(num - 2)][1]
 
-            return html_minify(template('index', 
+            return html_minify(render_template('index.html', 
                 imp = [title_list[(num - 2)][0], wiki_set(conn, 1), custom(conn), other2([0, 0])],
                 data = '<form method="post"> \
                             <input placeholder="' + placeholder + '" name="name" type="text"><hr> \
@@ -1742,7 +1752,7 @@ def title_index():
     else:
         sub = ' (' + str(num) + '개)'
     
-    return html_minify(template('index', 
+    return html_minify(render_template('index.html', 
         imp = ['모든 문서', wiki_set(conn, 1), custom(conn), other2([sub, 0])],
         data = data,
         menu = [['other', '기타']]
@@ -1876,7 +1886,7 @@ def topic_admin(name = None, sub = None, num = None):
     ban = '== 정보 ==\r\n' + ban
     ban = '[목차(없음)]\r\n' + ban
 
-    return html_minify(template('index', 
+    return html_minify(render_template('index.html', 
         imp = ['토론 도구', wiki_set(conn, 1), custom(conn), other2([' (' + str(num) + '번)', 0])],
         data = ban,
         menu = [['topic/' + url_pas(name) + '/sub/' + url_pas(sub) + '#' + str(num), '토론']]
@@ -2033,7 +2043,7 @@ def topic(name = None, sub = None):
 
             data += '<button type="submit">전송</button></form>'
 
-        return html_minify(template('index', 
+        return html_minify(render_template('index.html', 
             imp = [name, wiki_set(conn, 1), custom(conn), other2([' (토론)', 0])],
             data = '<h2 id="topic_top_title">' + sub + '</h2>' + all_data + data,
             menu = [['topic/' + url_pas(name), '목록']]
@@ -2089,7 +2099,7 @@ def close_topic_list(name = None, tool = None):
         if div == '':
             plus = re.sub('^<br>', '', plus)
         
-        return html_minify(template('index', 
+        return html_minify(render_template('index.html', 
             imp = [name, wiki_set(conn, 1), custom(conn), other2([' (' + sub + ')', 0])],
             data =  '<form method="post">' + div + plus + '</form>',
             menu = menu
@@ -2141,7 +2151,7 @@ def login():
         
         return redirect('/user')                            
     else:        
-        return html_minify(template('index',    
+        return html_minify(render_template('index.html',    
             imp = ['로그인', wiki_set(conn, 1), custom(conn), other2([0, 0])],
             data = '<form method="post"> \
                         <input placeholder="아이디" name="id" type="text"><hr> \
@@ -2188,7 +2198,7 @@ def change_password():
         if custom(conn)[2] == 0:
             return redirect('/login')
 
-        return html_minify(template('index',    
+        return html_minify(render_template('index.html',    
             imp = ['비밀번호 변경', wiki_set(conn, 1), custom(conn), other2([0, 0])],
             data = '<form method="post"> \
                         <input placeholder="현재 비밀번호" name="pw" type="password"><hr> \
@@ -2250,7 +2260,7 @@ def user_check(name = None):
     else:
         return re_error(conn, '/error/5')
             
-    return html_minify(template('index',    
+    return html_minify(render_template('index.html',    
         imp = ['다중 검사', wiki_set(conn, 1), custom(conn), other2([0, 0])],
         data = div,
         menu = [['manager', '관리자']]
@@ -2261,7 +2271,7 @@ def plus_check(name):
     if request.method == 'POST':
         return redirect('/check/' + url_pas(name) + '?plus=' + url_pas(request.form['name2']))
     else:
-        return html_minify(template('index',
+        return html_minify(render_template('index.html',
             imp = ['대상 추가', wiki_set(conn, 1), custom(conn), other2([0, 0])],
             data = '<form method="post"> \
                         <input placeholder="비교 대상" name="name2" type="text"><hr> \
@@ -2320,7 +2330,7 @@ def register():
         if data and data[0][0] != '':
             contract = data[0][0] + '<hr>'
 
-        return html_minify(template('index',    
+        return html_minify(render_template('index.html',    
             imp = ['회원가입', wiki_set(conn, 1), custom(conn), other2([0, 0])],
             data = '<form method="post"> \
                         ' + contract + ' \
@@ -2382,7 +2392,7 @@ def user_ban(name = None):
 
             data = '<input placeholder="사유" name="why" type="text"><hr><input placeholder="분 차단" name="end" type="text"><br><br><ul><li>비우면 영구 차단</li><li>1달은 28일로 취급</li></ul><hr>' + plus
 
-        return html_minify(template('index', 
+        return html_minify(render_template('index.html', 
             imp = [name, wiki_set(conn, 1), custom(conn), other2([' (' + now + ')', 0])],
             data = '<form method="post">' + data + '<button type="submit">' + now + '</button></form>',
             menu = [['manager', '관리자']]
@@ -2466,7 +2476,7 @@ def acl(name = None):
         else:
             plus = '<option value="admin" ' + acl_list[0] + '>관리자</option>'
             
-        return html_minify(template('index', 
+        return html_minify(render_template('index.html', 
             imp = [name, wiki_set(conn, 1), custom(conn), other2([' (ACL)', 0])],
             data = '<form method="post"> \
                         <span>현재 ACL : ' + now + '</span><hr> \
@@ -2534,7 +2544,7 @@ def user_admin(name = None):
                     else:
                         div += '<option value="' + data[0] + '">' + data[0] + '</option>'
         
-        return html_minify(template('index', 
+        return html_minify(render_template('index.html', 
             imp = [name, wiki_set(conn, 1), custom(conn), other2([' (권한 부여)', 0])],
             data =  '<form method="post"> \
                         <select name="select">' + div + '</select><hr> \
@@ -2562,7 +2572,7 @@ def diff_data(name = None):
                 diff_data = difflib.SequenceMatcher(None, first_data, second_data)
                 result = diff(diff_data)
             
-            return html_minify(template('index', 
+            return html_minify(render_template('index.html', 
                 imp = [name, wiki_set(conn, 1), custom(conn), other2([' (비교)', 0])],
                 data = '<pre>' + result + '</pre>',
                 menu = [['history/' + url_pas(name), '역사']]
@@ -2582,7 +2592,7 @@ def down(name = None):
         
     div += '</ul>'
     
-    return html_minify(template('index', 
+    return html_minify(render_template('index.html', 
         imp = [name, wiki_set(conn, 1), custom(conn), other2([' (하위)', 0])],
         data = div,
         menu = [['w/' + url_pas(name), '문서']]
@@ -2665,9 +2675,10 @@ def read_view(name = None):
     data = curs.fetchall()
     if data:
         else_data = data[0][1]
+        response_data = 200
     else:
         data_none = 1
-        response.status = 404
+        response_data = 404
         else_data = ''
 
     if not num:
@@ -2750,11 +2761,11 @@ def read_view(name = None):
 
     div = end_data + div
 
-    return html_minify(template('index', 
+    return html_minify(render_template('index.html', 
         imp = [name, wiki_set(conn, 1), custom(conn), other2([sub + acl, r_date])],
         data = div,
         menu = menu
-    ))
+    ), response_data)
 
 @app.route('/topic_record/<name>')
 def user_topic_list(name = None):
@@ -2798,7 +2809,7 @@ def user_topic_list(name = None):
     else:
         sub = 0 
     
-    return html_minify(template('index', 
+    return html_minify(render_template('index.html', 
         imp = ['토론 기록', wiki_set(conn, 1), custom(conn), other2([sub, 0])],
         data = div,
         menu = [['other', '기타'], ['user', '사용자'], ['count/' + url_pas(name), '횟수'], ['record/' + url_pas(name), '편집']]
@@ -2977,7 +2988,7 @@ def recent_changes(name = None, tool = 'record'):
         if sub == '':
             sub = 0
                 
-        return html_minify(template('index', 
+        return html_minify(render_template('index.html', 
             imp = [title, wiki_set(conn, 1), custom(conn), other2([sub, 0])],
             data = div,
             menu = menu
@@ -3049,7 +3060,7 @@ def upload():
         
         return redirect('/w/파일:' + name)            
     else:
-        return html_minify(template('index', 
+        return html_minify(render_template('index.html', 
             imp = ['파일 올리기', wiki_set(conn, 1), custom(conn), other2([0, 0])],
             data =  '<form method="post" enctype="multipart/form-data" accept-charset="utf8"> \
                         <input type="file" name="f_data"><hr> \
@@ -3096,7 +3107,7 @@ def user_info():
         ip_user = ip
         plus = '<li><a href="/login">로그인</a></li>'
 
-    return html_minify(template('index', 
+    return html_minify(render_template('index.html', 
         imp = ['사용자 메뉴', wiki_set(conn, 1), custom(conn), other2([0, 0])],
         data =  '<h2>상태</h2><ul><li>' + ip_user + ' <a href="/record/' + url_pas(ip) + '">(기록)</a></li><li>권한 상태 : ' + acl + '</li></ul><br><h2>로그인</h2><ul>' + plus + '<li><a href="/register">회원가입</a></li></ul><br><h2>사용자 기능</h2><ul><li><a href="/acl/사용자:' + url_pas(ip) + '">사용자 문서 ACL</a></li><li><a href="/custom_head">사용자 HEAD</a></li></ul><br><h2>기타</h2><ul><li><a href="/alarm">알림</a></li><li><a href="/watch_list">주시 문서</a></li><li><a href="/count">활동 횟수</a></li></ul>',
         menu = 0
@@ -3120,7 +3131,7 @@ def email():
         else:
             email = ''
 
-        return html_minify(template('index',    
+        return html_minify(render_template('index.html',    
             imp = ['이메일 수정', wiki_set(conn, 1), custom(conn), other2([0, 0])],
             data = '<form method="post"> \
                         <input placeholder="이메일" name="email" type="text" value="' + email + '"><hr> \
@@ -3147,7 +3158,7 @@ def watch_list():
 
     div += '<a href="/manager/13">(추가)</a>'
 
-    return html_minify(template('index', 
+    return html_minify(render_template('index.html', 
         imp = ['편집 필터 목록', wiki_set(conn, 1), custom(conn), other2([0, 0])],
         data = div,
         menu = [['manager', '관리자']]
@@ -3207,7 +3218,7 @@ def custom_head_view():
 
         start += '<span>&lt;style&gt;CSS&lt;/style&gt;<br>&lt;script&gt;JS&lt;/script&gt;</span><hr>'
 
-        return html_minify(template('index', 
+        return html_minify(render_template('index.html', 
             imp = ['사용자 HEAD', wiki_set(conn, 1), custom(conn), other2([0, 0])],
             data =  start + ' \
                     <form method="post"> \
@@ -3239,7 +3250,7 @@ def count_edit(name = None):
     else:
         t_data = 0
 
-    return html_minify(template('index', 
+    return html_minify(render_template('index.html', 
         imp = ['활동 횟수', wiki_set(conn, 1), custom(conn), other2([0, 0])],
         data = '<ul><li><a href="/record/' + url_pas(that) + '">편집 횟수</a> : ' + str(data) + '</li><li><a href="/topic_record/' + url_pas(that) + '">토론 횟수</a> : ' + str(t_data) + '</a></li></ul>',
         menu = [['user', '사용자']]

+ 4 - 6
func.py

@@ -1,6 +1,4 @@
-from bottle import template, TEMPLATE_PATH, response
-
-from flask import session
+from flask import session, render_template
 
 import json
 import sqlite3
@@ -87,7 +85,7 @@ def skin_check(conn):
     except:
         pass
 
-    TEMPLATE_PATH.insert(0, skin)
+    return skin
 
 def next_fix(link, num, page, end = 50):
     list_data = ''
@@ -492,7 +490,7 @@ def re_error(conn, data):
                 if d[0][1] != '':
                     end += '<li>사유 : ' + d[0][1] + '</li>'
 
-        return html_minify(template('index', 
+        return html_minify(render_template('index.html', 
             imp = ['권한 오류', wiki_set(conn, 1), custom(conn), other2([0, 0])],
             data = '<h2>권한 상태</h2><ul>' + end + '</ul>',
             menu = 0
@@ -572,7 +570,7 @@ def re_error(conn, data):
             data = '???'
 
         if title:
-            return html_minify(template('index', 
+            return html_minify(render_template('index.html', 
                 imp = [title, wiki_set(conn, 1), custom(conn), other2([0, 0])],
                 data = '<h2>오류 발생</h2><ul><li>' + data + '</li></ul>',
                 menu = 0

+ 21 - 36
views/acme/index.tpl → views/acme/index.html

@@ -9,8 +9,8 @@
         <script src="/views/acme/js/jquery.min.js"></script>
         <script src="/views/acme/js/bootstrap.min.js"></script>
         <link rel="stylesheet" href="/views/acme/css/font-awesome/css/font-awesome.min.css">
-        {{!imp[1][5]}}
-        {{!imp[2][3]}}
+        {{imp[1][5]|safe}}
+        {{imp[2][3]|safe}}
         <meta name="twitter:creator" content="@{{imp[1][0]}}">
         <meta name="twitter:title" content="{{imp[0]}}">
         <meta name="twitter:site" content="@{{imp[1][0]}}">
@@ -28,7 +28,7 @@
                         <span class="icon-bar"></span>
                     </button>
                     <a class="navbar-brand" href="/" style="margin-top: 30px;">
-                        {{!imp[1][4]}}
+                        {{imp[1][4]|safe}}
                     </a>
                 </div>
                 <div class="navbar-collapse collapse">
@@ -73,22 +73,14 @@
                         </li>       
                         <li>
                             <a href="/user">
-                                % if(imp[2][2] == 1):
+                                {% if imp[2][2] == 1 %}
                                     <i class="fa fa-user" aria-hidden="true"></i>
-                                % elif(imp[2][2] == 0):
+                                {% elif imp[2][2] == 0 %}
                                     <i class="fa fa-user-times" aria-hidden="true"></i>
-                                % else:
+                                {% else %}
                                     <i class="fa fa-user-secret" aria-hidden="true"></i>
-                                % end
-
-                                % if(imp[2][4] != ''):
-                                    % import hashlib
-                                    % md5_email = hashlib.md5(imp[2][4].encode()).hexdigest()
-                                    
-                                    <img src="http://www.gravatar.com/avatar/{{md5_email}}?s=30">
-                                % else:
-                                    사용자
-                                % end
+                                {% endif %}
+                                사용자
                             </a>
                         </li>  
                     </ul>
@@ -102,33 +94,26 @@
                         <div class="col-lg-4 col-sm-4">
                             <h1>
                                 {{imp[0]}}
-                                % if(imp[3][0] != 0):
+                                {% if imp[3][0] != 0 %}
                                     <sub>{{imp[3][0]}}</sub>
-                                % end
+                                {% endif %}
                             </h1>
                         </div>
                         <div class="col-lg-8 col-sm-8">
                             <ol class="breadcrumb pull-right">   
                                 <li style="margin: 0;">
-                                    % if(menu != 0):
-                                        % i = 1
-                                        % for sub_d in menu:
-                                            % if(sub_d[1] == 1):
+                                    {% if menu != 0 %}
+                                        {% for sub_d in menu %}
+                                            {% if sub_d[1] == 1 %}
                                                 <a class="menu-item" href="/{{sub_d[0]}}" id="open">토론</a>
-                                            % elif(sub_d[1] == 0):
+                                            {% elif sub_d[1] == 0 %}
                                                 <a class="menu-item" href="/{{sub_d[0]}}">토론</a>
-                                            % else:
+                                            {% else %}
                                                 <a class="menu-item" href="/{{sub_d[0]}}">{{sub_d[1]}}</a>
-                                            % end
-                                            % try:
-                                                % d = menu[i]
-                                                ㆍ
-                                            % except:
-                                                % break
-                                            % end
-                                            % i += 1
-                                        % end
-                                    % end
+                                            {% endif %}
+                                            ㆍ
+                                        {% endfor %}
+                                    {% endif %}
                                 </li>
                             </ol>
                         </div>
@@ -138,7 +123,7 @@
             <div class="container">
                 <div class="row">
                     <div class="col-md-10 col-md-offset-1 mar-b-30">
-                        {{!data}}
+                        {{data|safe}}
                     </div>
                 </div>
             </div>
@@ -158,7 +143,7 @@
             <div class="container">
                 <div class="row">
                     <div class="copyright">
-                        {{!imp[1][1]}}
+                        {{imp[1][1]|safe}}
                         <span id="left_end" class="pull-right">
                             <a href="https://github.com/2DU/openNAMU">
                                 <img src="/views/acme/img/on2.png" alt="opennamu" style="width: 100px;">