page list 업데이트

This commit is contained in:
lbard
2026-01-05 16:59:20 +09:00
parent 7f8b372ed9
commit 8e759144bf
4 changed files with 134 additions and 7 deletions

28
app.py
View File

@@ -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/<string:cate>')
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)
# ============================================
# 관리자 페이지

View File

@@ -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);}

View File

@@ -28,11 +28,11 @@
<div class="menu__close"><button class="uk-icon" uk-icon="icon: close"></button></div>
<div class="menu__box">
<ul>
<li><a href="#a">최신테크뉴스</a></li>
<li><a href="#a">WXN 뉴스</a></li>
<li><a href="#a">IT 요즘</a></li>
<li><a href="#a">IT활용자료(윅슨전용)</a></li>
<li><a href="#a">ETC</a></li>
<li><a href="/list">최신테크뉴스</a></li>
<li><a href="/list/NEWS">WXN 뉴스</a></li>
<li><a href="/list/IT">IT 요즘</a></li>
<!-- <li><a href="/list">IT활용자료(윅슨전용)</a></li> -->
<li><a href="/list/ETC">ETC</a></li>
</ul>
</div>
<ul class="login__section">

92
templates/list.html Normal file
View File

@@ -0,0 +1,92 @@
{% extends 'base.html' %}
{% block content %}
<div class="container">
<div class="content">
{% if not posts %}
<h4 style="margin-top: 100px">작성된 포스트가 없습니다.</h4>
{% else %}
<div class="content__inner">
<ul class="list__posts list__posts0">
</ul>
<ul class="list__posts list__posts1">
</ul>
<ul class="list__posts list__posts2">
</ul>
</div>
<ul class="fake__lists">
{% for r_post in posts %}
<li>
<a href="{{ url_for('post', post_id=r_post.id) }}">
<div class="lists__img">
<img src="{{ r_post.thumbnail_img | default('https://via.placeholder.com/300x200', true) }}" alt="{{ r_post.title }}" onerror="this.onerror=null; this.src='https://via.placeholder.com/300x200';" />
</div>
<div class="lists__desc">
<p class="lists__category">{{ r_post.category }}</p>
<h3 class="lists__title">{{ r_post.title }}</h3>
<p class="lists__content">
{{ r_post.contents | safe }}
</p>
{# <p class="lists__content">{{ r_post.contents | safe }}</p> #}
<p class="lists__date">
<b>{{ (r_post.add_date).strftime("%b %d") }}</b> / {{ (r_post.add_date).strftime("%Y") }}
</p>
</div>
</a>
</li>
{% endfor %}
</ul>
{% endif %}
</div>
</div>
<footer>
<div class="footer__inner">
<div class="footer__info">
<p class="footer__tel">
TEL 02-3141-1305 / 1306 E-mail cser@wixon.co.kr / 기업부설연구소 제 2021154317호
</p>
<address>
서울시 마포구 동교로 215-1 한사 스튜디오 406 (주)윅슨어소시에이츠 / #406 , HANSA Studio, 215-1, Donggyo-ro, Mapo-gu, Seoul, Korea
</address>
<p class="copywriter">
&copy; wixon associates Inc. 2022
</p>
<p class="slogan">
wixon. Who Invariable eXistence On the New era " wixon associates Inc. "
</p>
<ul>
<li><a href="/"><img src="/static/images/opusclam.png" alt="WIXON" /></a></li>
<li><a href="/"><img src="/static/images/lpstock.png" alt="WIXON" /></a></li>
</ul>
</div>
<h2 class="footer__logo">
<a href="/"><img src="/static/images/logo.png" alt="WIXON" /></a>
</h2>
</div>
</footer>
<script>
moment.locale('en');
console.log(moment().format('ll'));
$(document).ready(function() {
const count__lists = $(".fake__lists li").length;
for (let i = 0; i < count__lists; i++) {
let n_1 = i % 3;
switch (n_1) {
case 1.:
$(".list__posts1").append($(".fake__lists li:first-child"));
break;
case 2:
$(".list__posts2").append($(".fake__lists li:first-child"));
break;
case 0:
$(".list__posts0").append($(".fake__lists li:first-child"));
break;
}
}
})
</script>
{% endblock %}
</div>
</body>
</html>