From 8e759144bf44fb9bab568be5c994b7d6abc45d29 Mon Sep 17 00:00:00 2001 From: lbard Date: Mon, 5 Jan 2026 16:59:20 +0900 Subject: [PATCH] =?UTF-8?q?page=20list=20=EC=97=85=EB=8D=B0=EC=9D=B4?= =?UTF-8?q?=ED=8A=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app.py | 28 ++++++++++++++ static/css/style.css | 7 ++++ templates/base.html | 14 +++---- templates/list.html | 92 ++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 134 insertions(+), 7 deletions(-) create mode 100644 templates/list.html diff --git a/app.py b/app.py index 93c2466..2aad106 100644 --- a/app.py +++ b/app.py @@ -265,6 +265,34 @@ def delete_post(id): else: return jsonify(success=False, message='Could not delete the post'), 500 +@app.route('/list') +@app.route('/list/') +def list(cate=None): + params = () + cate_condition = "" + + if cate: + cate_condition = "AND `category` = %s" + params = (cate,) + + if 'user_info' in session: # 로그인된 사용자 + query = f"""SELECT `id`, `title`, `category`, `thumbnail_img`, `contents`, `add_date` + FROM `blog` + WHERE `use_yn` = 'Y' {cate_condition} + ORDER BY `add_date` DESC;""" + else: + query = f"""SELECT `id`, `title`, `category`, `thumbnail_img`, `contents`, `add_date` + FROM `blog` + WHERE `use_yn` = 'Y' AND `public_yn` = 'Y' {cate_condition} + ORDER BY `add_date` DESC;""" + + r, posts = sql_execute(query, params, is_data=True) + + # 태그 제거 후 150자로 제한 + for post in posts: + post['contents'] = remove_html_tags(post['contents'])[:150] + + return render_template('list.html', posts=posts) # ============================================ # 관리자 페이지 diff --git a/static/css/style.css b/static/css/style.css index 2b262f0..cc42c7d 100644 --- a/static/css/style.css +++ b/static/css/style.css @@ -273,3 +273,10 @@ /* login */ .uk-form-stacked{min-width:640px;width:30%;margin:0 auto;} .login__btn{width:100%;} + + /* list css */ + .list__posts{float:left;width:30%;padding-right:3%;} + .list__posts li{width:100%;height:auto;} + .list__posts li a{display:block;width:100%;height:100%;} + .list__posts li:hover{text-shadow:1px 0px 1px RGBA(0,0,0,0.3);} + .list__posts li:hover .lists__img{box-shadow:1px 1px 5px RGBA(144,20,68,0.2);} diff --git a/templates/base.html b/templates/base.html index 4893600..93970f9 100644 --- a/templates/base.html +++ b/templates/base.html @@ -28,11 +28,11 @@