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

https://github.com/openNAMU/openNAMU/issues/1789

and fix bug
잉여개발기 (SPDV) 3 лет назад
Родитель
Сommit
bf1f8b83cf
4 измененных файлов с 22 добавлено и 24 удалено
  1. 10 3
      route/main_setting_main.py
  2. 1 19
      route/tool/func.py
  3. 6 1
      route/tool/func_render_namumark.py
  4. 5 1
      route/view_xref.py

+ 10 - 3
route/main_setting_main.py

@@ -36,7 +36,8 @@ def main_setting_main(db_set):
             32 : ['wiki_access_password', ''],
             33 : ['history_recording_off', ''],
             34 : ['namumark_compatible', ''],
-            35 : ['user_name_view', '']
+            35 : ['user_name_view', ''],
+            36 : ['link_case_insensitive', '']
         }
 
         if flask.request.method == 'POST':
@@ -86,7 +87,7 @@ def main_setting_main(db_set):
                 else:
                     tls_select += '<option value="' + tls_select_one + '">' + tls_select_one + '</option>'
 
-            check_box_div = ['', '', '', '', '', '', '', '', '', '', '', '']
+            check_box_div = ['', '', '', '', '', '', '', '', '', '', '', '', '']
             for i in range(0, len(check_box_div)):
                 if i == 0:
                     acl_num = 7
@@ -110,6 +111,8 @@ def main_setting_main(db_set):
                     acl_num = 34
                 elif i == 11:
                     acl_num = 35
+                elif i == 12:
+                    acl_num = 36
 
                 if d_list[acl_num]:
                     check_box_div[i] = 'checked="checked"'
@@ -190,8 +193,12 @@ def main_setting_main(db_set):
                         <hr class="main_hr">
                         <select name="skin">''' + load_skin(d_list[5] if d_list[5] != '' else 'ringo') + '''</select>
 
-                        <hr class="main_hr">
+                        <h2>''' + load_lang('render_set') + '''</h2>
                         <input type="checkbox" name="namumark_compatible" ''' + check_box_div[10] + '''> ''' + load_lang('namumark_fully_compatible_mode') + '''
+                        <hr class="main_hr">
+                        
+                        <input type="checkbox" name="link_case_insensitive" ''' + check_box_div[12] + '''> ''' + load_lang('link_case_insensitive') + '''
+                        <hr class="main_hr">
 
                         <h2>''' + load_lang('login_set') + '''</h2>
                         <input type="checkbox" name="reg" ''' + check_box_div[0] + '''> ''' + load_lang('no_register') + '''

+ 1 - 19
route/tool/func.py

@@ -176,7 +176,6 @@ class get_db_connect:
                 port = int(self.db_set['mysql_port']),
                 autocommit = True
             )
-            curs = self.conn.cursor()
 
             try:
                 self.conn.select_db(self.db_set['name'])
@@ -187,6 +186,7 @@ class get_db_connect:
         return self.conn
     
     def __exit__(self, exc_type, exc_value, traceback):
+        self.conn.commit()
         load_conn(self.conn_sub)
         self.conn.close()
 
@@ -708,8 +708,6 @@ def set_init_always(ver_num):
         if db_data:
             global_wiki_set['wiki_access_password'] = db_data[0][0]
     
-    conn.commit()
-    
 def set_init():
     curs = conn.cursor()
 
@@ -739,8 +737,6 @@ def set_init():
             ['smtp_security', 'starttls']
         ]:
             curs.execute(db_change("insert into other (name, data, coverage) values (?, ?, '')"), [i[0], i[1]])
-        
-    conn.commit()
 
 # Func-simple
 ## Func-simple-without_DB
@@ -1708,7 +1704,6 @@ def admin_check(num = None, what = None, name = ''):
                     curs.execute(db_change(
                         "insert into re_admin (who, what, time) values (?, ?, ?)"
                     ), [ip, what, time_data])
-                    conn.commit()
 
                 return 1
 
@@ -2027,7 +2022,6 @@ def ban_check(ip = None, tool = ''):
         "update rb set ongoing = '' " + \
         "where end < ? and end != '' and ongoing = '1'"
     ), [get_time()])
-    conn.commit()
 
     curs.execute(db_change("" + \
         "select login, block from rb " + \
@@ -2288,8 +2282,6 @@ def do_add_thread(thread_code, thread_data, thread_top = '', thread_id = ''):
         thread_code
     ])
     
-    conn.commit()
-    
 def do_reload_recent_thread(topic_num, date, name = None, sub = None):
     curs = conn.cursor()
 
@@ -2309,15 +2301,12 @@ def do_reload_recent_thread(topic_num, date, name = None, sub = None):
             date
         ])
 
-    conn.commit()
-
 def add_alarm(who, context):
     curs = conn.cursor()
 
     curs.execute(db_change(
         'insert into alarm (name, data, date) values (?, ?, ?)'
     ), [who, context, get_time()])
-    conn.commit()
     
 def add_user(user_name, user_pw, user_email = '', user_encode = ''):
     curs = conn.cursor()
@@ -2360,8 +2349,6 @@ def add_user(user_name, user_pw, user_email = '', user_encode = ''):
             user_name,
             user_email
         ])
-        
-    conn.commit()
     
 def ua_plus(u_id, u_ip, u_agent, time):
     curs = conn.cursor()
@@ -2379,7 +2366,6 @@ def ua_plus(u_id, u_ip, u_agent, time):
             u_agent, 
             time
         ])
-        conn.commit()
 
 def ban_insert(name, end, why, login, blocker, type_d = None):
     curs = conn.cursor()
@@ -2433,8 +2419,6 @@ def ban_insert(name, end, why, login, blocker, type_d = None):
             login
         ])
 
-    conn.commit()
-
 def history_plus(title, data, date, ip, send, leng, t_check = '', mode = ''):
     curs = conn.cursor()
     # 여기 좀 느린 듯
@@ -2538,8 +2522,6 @@ def history_plus(title, data, date, ip, send, leng, t_check = '', mode = ''):
 def re_error(data):
     curs = conn.cursor()
 
-    conn.commit()
-
     if data == '/ban':
         if ban_check() == 1:
             end = '<div id="opennamu_get_user_info">' + ip_check() + '</div>'

+ 6 - 1
route/tool/func_render_namumark.py

@@ -51,6 +51,10 @@ class class_do_render_namumark:
         self.render_data_cdn = ''
         self.render_data_js = ''
 
+        self.curs.execute(db_change('select data from other where name = "link_case_insensitive"'))
+        db_data = self.curs.fetchall()
+        self.link_case_insensitive = ' collate nocase' if db_data and db_data[0][0] != '' else ''
+
     def get_tool_lang(self, name):
         if name in self.lang_data:
             return self.lang_data[name]
@@ -1013,13 +1017,14 @@ class class_do_render_namumark:
 
                     link_exist = ''
                     if link_main != '':
-                        self.curs.execute(db_change("select title from data where title = ?"), [link_main])
+                        self.curs.execute(db_change("select title from data where title = ?" + self.link_case_insensitive), [link_main])
                         db_data = self.curs.fetchall()
                         if not db_data:
                             self.data_backlink += [[self.doc_name, link_main, 'no']]
                             self.data_backlink += [[self.doc_name, link_main, '']]
                             link_exist = 'opennamu_not_exist_link'
                         else:
+                            link_main = db_data[0][0]
                             self.data_backlink += [[self.doc_name, link_main, '']]
 
                     link_same = ''

+ 5 - 1
route/view_xref.py

@@ -21,10 +21,14 @@ def view_xref(name = 'Test', xref_type = 1):
 
         div += '<ul class="opennamu_ul">'
 
+        curs.execute(db_change('select data from other where name = "link_case_insensitive"'))
+        db_data = curs.fetchall()
+        link_case_insensitive = ' collate nocase' if db_data and db_data[0][0] != '' else ''
+
         sql_insert = ['link', 'title'] if xref_type == 1 else ['title', 'link']
         curs.execute(db_change("" + \
             "select distinct " + sql_insert[0] + ", type from back " + \
-            "where " + sql_insert[1] + " = ? and not type = 'no' and not type = 'nothing'" + \
+            "where " + sql_insert[1] + " = ?" + link_case_insensitive + " and not type = 'no' and not type = 'nothing' " + \
             "order by type asc, " + sql_insert[0] + " asc limit ?, 50" + \
         ""), [
             name,