Browse Source

서치와 기타 등등

2DU 9 years ago
parent
commit
4b98bd0d7b
3 changed files with 36 additions and 4 deletions
  1. 23 2
      main.py
  2. 6 0
      static/style.css
  3. 7 2
      templates/index.html

+ 23 - 2
main.py

@@ -758,6 +758,27 @@ def history_view(name = None, num = None):
             
 @app.route('/search', methods=['POST'])
 def search():
+    db_ex("select title from data where title like '%" + db_pas(request.form["search"]) + "%'")
+    rows = db_get()
+    if(rows):
+        i = 0
+        
+        div = '<li>문서가 없습니다. <a href="/w/' + url_pas(request.form["search"]) + '">바로가기</a></li><br>'
+        
+        while(True):
+            try:
+                div = div + '<li><a href="/w/' + url_pas(rows[i]['title']) + '">' + rows[i]['title'] + '</a></li>'
+            except:
+                break
+                
+            i += 1
+    else:
+        return '<meta http-equiv="refresh" content="0;url=/w/' + url_pas(request.form["search"]) + '" />'
+        
+    return web_render('index.html', login = login_check(), logo = set_data['name'], data = div, title = '검색')
+
+@app.route('/goto', methods=['POST'])
+def goto():
     db_ex("select title from data where title = '" + db_pas(request.form["search"]) + "'")
     rows = db_get()
     if(rows):
@@ -780,8 +801,8 @@ def search():
         else:
             return '<meta http-equiv="refresh" content="0;url=/w/' + url_pas(request.form["search"]) + '" />'
             
-        return web_render('index.html', login = login_check(), logo = set_data['name'], data = div, title = '검색')
-        
+        return web_render('index.html', login = login_check(), logo = set_data['name'], data = div, title = '검색')    
+
 @app.route('/w/<path:name>')
 @app.route('/w/<path:name>/from/<path:redirect>')
 def read_view(name = None, redirect = None):

+ 6 - 0
static/style.css

@@ -26,6 +26,12 @@
     color: #e5dafb;
 }
 
+button#goto {
+    border-radius: 0;
+    border-left: 0;
+    border-right: 0;
+}
+
 textarea, label, span, body, strong, b, div, h1, h2, h3, h4, h5, h6, h7, input {
 	font-family: "나눔바른고딕", "나눔고딕", "맑은 고딕", "NanumBarunGothic", "NanumGothic", "Malgun Gothic", "sans-serif";
 }

+ 7 - 2
templates/index.html

@@ -1,6 +1,6 @@
 <html>
     <head>
-        <title>{{title}}</title>
+        <title>{{title}} - {{logo}}</title>
         <link rel="stylesheet" href="{{url_for('static', filename='primer.css')}}">
         <link rel="stylesheet" href="{{url_for('static', filename='style.css')}}">
         <link rel="stylesheet" href="{{url_for('static', filename='font-awesome/css/font-awesome.min.css')}}">
@@ -33,7 +33,12 @@
                 <form method="POST" action="/search" id="search">
                     <div class="input-group">
                         <input class="form-control" name="search" type="text">
-                        <span class="input-group-button"><button class="btn"><i class="fa fa-search" aria-hidden="true"></i></button></span>
+                        <span class="input-group-button">
+                            <button id="goto" class="btn" formaction="/goto"><i class="fa fa-share" aria-hidden="true"></i></button>
+                        </span>
+                        <span class="input-group-button">
+                            <button class="btn"><i class="fa fa-search" aria-hidden="true"></i></button>
+                        </span>
                     </div>
                 </form>
             </div>