2du пре 4 година
родитељ
комит
c602821bdf
6 измењених фајлова са 73 додато и 40 уклоњено
  1. 3 0
      route/main_test_func.py
  2. 0 8
      route/main_upload.py
  3. 1 1
      route/tool/func.py
  4. 41 18
      route/view_read.py
  5. 2 2
      version.json
  6. 26 11
      views/tenshi/index.html

+ 3 - 0
route/main_test_func.py

@@ -2,6 +2,9 @@ import time
 from .tool.func import *
 
 def main_test_func_2(conn):
+    if admin_check() != 1:
+        return re_error('/error/3')
+    
     test_start = time.time()
 
     for _ in range(0, 10000):

+ 0 - 8
route/main_upload.py

@@ -75,21 +75,13 @@ def main_upload_2(conn):
             db_data = curs.fetchall()
             if db_data and db_data[0][0] == 'namumark':
                 file_d = '' + \
-                    '[[file:' + name + ']]\n' + \
-                    '{{{[[file:' + name + ']]}}}\n\n' + \
                     flask.request.form.get('f_lice_sel', 'direct_input') + '\n' + \
-                    (ip if ip_or_user(ip) != 0 else '[[user:' + ip + ']]') + '\n' + \
-                    file_size + 'KB\n' + \
                     '[[category:' + re.sub(r'\]', '_', flask.request.form.get('f_lice_sel', '')) + ']]\n' + \
                     (g_lice if g_lice != '' else '') + \
                 ''
             else:
                 file_d = '' + \
-                    'file:' + name + '\n' + \
-                    '/image/' + e_data + '\n\n' + \
                     flask.request.form.get('f_lice_sel', 'direct_input') + '\n' + \
-                    ip + \
-                    file_size + 'KB\n\n' + \
                     (g_lice if g_lice != '' else '') + \
                 ''
 

+ 1 - 1
route/tool/func.py

@@ -411,7 +411,7 @@ def get_default_admin_group():
 def load_image_url():
     curs.execute(db_change('select data from other where name = "image_where"'))
     image_where = curs.fetchall()
-    image_where = image_where[0][0] if image_where else 'data/images'
+    image_where = image_where[0][0] if image_where else os.path.join('data', 'images')
     
     return image_where
 

+ 41 - 18
route/view_read.py

@@ -4,8 +4,14 @@ def view_read_2(conn, name, doc_rev, doc_from):
     curs = conn.cursor()
 
     sub = ''
-    div = ''
+    menu = []
+    
+    user_doc = ''
+    category_doc = ''
+    file_data = ''
+    
     ip = ip_check()
+    
     name_doc_pass = doc_from
     uppage = re.sub(r"/([^/]+)$", '', name)
     num = str(doc_rev)        
@@ -33,9 +39,37 @@ def view_read_2(conn, name, doc_rev, doc_from):
 
         if category_sub != '':
             category_doc += '<h2 id="cate_under">' + load_lang('under_category') + '</h2><ul class="inside_ul">' + category_sub + '</ul>'
+    elif re.search(r"^user:([^/]*)", name):
+        match = re.search(r"^user:([^/]*)", name)
+        user_name = html.escape(match.group(1))
+        user_doc = '''
+            <div id="get_user_info"></div>
+            <script>load_user_info("''' + user_name + '''");</script>
+            <hr class="main_hr">
+        '''
+        if name == 'user:' + user_name:
+            menu += [['w/' + url_pas(name) + '/' + url_pas(get_time().split()[0]), load_lang('today_doc')]]
+    elif re.search(r"^file:", name):
+        mime_type = re.search(r'([^.]+)$', name)
+        if mime_type:
+            mime_type = mime_type.group(1).lower()
+        else:
+            mime_type = 'jpg'
+            
+        file_name = re.sub(r'\.([^.]+)$', '', name)
+        file_name = re.sub(r'^file:', '', file_name)
+        
+        file_size = str(round(os.path.getsize(os.path.join(load_image_url(), sha224_replace(file_name) + '.' + mime_type)) / 1000, 1))
+        file_data = '''
+            <img src="/image/''' + sha224_replace(file_name) + '''.''' + mime_type + '''">
+            <h2>DATA</h2>
+            <table>
+                <tr><td>URL</td><td><a href="/image/''' + url_pas(sha224_replace(name) + '.' + mime_type) + '''">LINK</a></td></tr>
+                <tr><td>VOLUME</td><td>''' + file_size + '''KB</td></tr>
+            </table>
+            <h2>CONTENT</h2>
+        '''
             
-        div += category_doc
-
     if num != '0':
         curs.execute(db_change("select title from history where title = ? and id = ? and hide = 'O'"), [name, num])
         if curs.fetchall() and admin_check(6) != 1:
@@ -92,7 +126,7 @@ def view_read_2(conn, name, doc_rev, doc_from):
         response_data = 200
 
     if num != '0':
-        menu = [['history/' + url_pas(name), load_lang('history')]]
+        menu += [['history/' + url_pas(name), load_lang('history')]]
         sub = ' (r' + str(num) + ')'
         acl = 0
         r_date = 0
@@ -101,9 +135,9 @@ def view_read_2(conn, name, doc_rev, doc_from):
         acl = 1 if curs.fetchall() else 0
         menu_acl = 1 if acl_check(name) == 1 else 0
         if response_data == 404:
-            menu = [['edit/' + url_pas(name), load_lang('create'), menu_acl]] 
+            menu += [['edit/' + url_pas(name), load_lang('create'), menu_acl]] 
         else:
-            menu = [['edit/' + url_pas(name), load_lang('edit'), menu_acl]]
+            menu += [['edit/' + url_pas(name), load_lang('edit'), menu_acl]]
             
         menu += [
             ['topic/' + url_pas(name), load_lang('discussion'), topic], 
@@ -131,18 +165,7 @@ def view_read_2(conn, name, doc_rev, doc_from):
         r_date = curs.fetchall()
         r_date = r_date[0][0] if r_date else 0
 
-    div = end_data + div
-
-    match = re.search(r"^user:([^/]*)", name)
-    if match:
-        user_name = html.escape(match.group(1))
-        div = '''
-            <div id="get_user_info"></div>
-            <script>load_user_info("''' + user_name + '''");</script>
-            <hr class="main_hr">
-        ''' + div
-        if name == 'user:' + user_name:
-            menu += [['w/' + url_pas(name) + '/' + url_pas(get_time().split()[0]), load_lang('today_doc')]]
+    div = file_data + user_doc + end_data + category_doc
 
     curs.execute(db_change("select data from other where name = 'body'"))
     body = curs.fetchall()

+ 2 - 2
version.json

@@ -1,7 +1,7 @@
 {
     "beta" : {
-        "r_ver" : "v3.4.1-stable (stable1) (beta6) (dev8)",
+        "r_ver" : "v3.5.0-dev (stable1) (beta10) (dev10)",
         "c_ver" : "3500101",
-        "s_ver" : "3500101"
+        "s_ver" : "3500110"
     }
 }

+ 26 - 11
views/tenshi/index.html

@@ -131,18 +131,33 @@
                 <div id="main_top">
                     {% if menu != 0 %}
                         <div id="tool" class="not_mobile">
-                            {% for sub_d in menu %}
-                                <div id="tool_cel">
-                                    {% if sub_d|length > 2 and sub_d[2] == 1 %}
-                                        <a class="menu-item" href="/{{sub_d[0]}}" id="topic_color">{{sub_d[1]}}</a>
-                                    {% else %}
-                                        <a class="menu-item" href="/{{sub_d[0]}}">{{sub_d[1]}}</a>
+                            {% if menu[0] == 1 %}
+                                {% for sub_d in menu %}
+                                    <div id="tool_cel">
+                                        {% if sub_d|length > 2 and sub_d[2] == 1 %}
+                                            <a class="menu-item" href="{{sub_d[0]}}" id="topic_color">{{sub_d[1]}}</a>
+                                        {% else %}
+                                            <a class="menu-item" href="{{sub_d[0]}}">{{sub_d[1]}}</a>
+                                        {% endif %}
+                                    </div>
+                                    {% if menu[loop.index] %}
+                                        |
                                     {% endif %}
-                                </div>
-                                {% if menu[loop.index] %}
-                                    |
-                                {% endif %}
-                            {% endfor %}
+                                {% endfor %}
+                            {% else %}
+                                {% for sub_d in menu %}
+                                    <div id="tool_cel">
+                                        {% if sub_d|length > 2 and sub_d[2] == 1 %}
+                                            <a class="menu-item" href="/{{sub_d[0]}}" id="topic_color">{{sub_d[1]}}</a>
+                                        {% else %}
+                                            <a class="menu-item" href="/{{sub_d[0]}}">{{sub_d[1]}}</a>
+                                        {% endif %}
+                                    </div>
+                                    {% if menu[loop.index] %}
+                                        |
+                                    {% endif %}
+                                {% endfor %}
+                            {% endif %}
                         </div>
                     {% endif %}
                     <h1 id="title">