news-cms-module 0.1.2 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +92 -0
- package/config/index.js +3 -3
- package/controllers/NewsController.js +266 -60
- package/controllers/StatController.js +22 -15
- package/index.js +18 -32
- package/middlewares/authAdminMiddleware.js +22 -0
- package/middlewares/multerMiddleware.js +45 -0
- package/middlewares/parseForm.js +15 -0
- package/models/News.js +1 -0
- package/models/index.js +7 -9
- package/package.json +4 -1
- package/public/img/Main.png +0 -0
- package/public/img/berita-terkait.png +0 -0
- package/public/img/berita.png +0 -0
- package/public/img/berita2.png +0 -0
- package/public/img/detail1.png +0 -0
- package/public/img/detail2.png +0 -0
- package/public/img/logo.png +0 -0
- package/public/js/script.js +92 -0
- package/public/style.css +1620 -0
- package/routes/index.js +41 -28
- package/services/NewsService.js +199 -34
- package/services/StatService.js +14 -5
- package/services/index.js +3 -3
- package/validations/mainValidation.js +25 -0
- package/validations/newsValidations.js +84 -0
- package/views/admin/create_news.ejs +312 -0
- package/views/admin/dashboard.ejs +104 -0
- package/views/admin/detailadmin.ejs +202 -0
- package/views/admin/list.ejs +331 -0
- package/views/admin/update_news.ejs +360 -0
- package/views/detail.ejs +235 -0
- package/views/home.ejs +220 -0
- package/views/list.ejs +0 -0
package/views/home.ejs
ADDED
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="id">
|
|
3
|
+
|
|
4
|
+
<head>
|
|
5
|
+
<meta charset="UTF-8" />
|
|
6
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
7
|
+
<title>Beranda - DeNews</title>
|
|
8
|
+
|
|
9
|
+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css" />
|
|
10
|
+
|
|
11
|
+
<link rel="stylesheet" href="/berita/style.css" />
|
|
12
|
+
</head>
|
|
13
|
+
|
|
14
|
+
<body>
|
|
15
|
+
<nav class="navbar">
|
|
16
|
+
<i class="fa-solid fa-bars" id="menu-icon"></i>
|
|
17
|
+
<div class="logo">
|
|
18
|
+
<a href="/berita/list"><img src="/berita/img/logo.png" alt="Logo DeNews" /></a>
|
|
19
|
+
</div>
|
|
20
|
+
|
|
21
|
+
<ul class="menu">
|
|
22
|
+
<li>
|
|
23
|
+
<a href="/berita/list" class="<%= !query.category ? 'active' : '' %>">Beranda</a>
|
|
24
|
+
</li>
|
|
25
|
+
<li class="dropdown">
|
|
26
|
+
<a href="#" class="dropdown-toggle <%= query.category ? 'active' : '' %>">
|
|
27
|
+
Kategori <i class="fa-solid fa-chevron-down"></i>
|
|
28
|
+
</a>
|
|
29
|
+
<ul class="dropdown-menu">
|
|
30
|
+
<% categories.forEach(cat=> { %>
|
|
31
|
+
<li>
|
|
32
|
+
<a href="?category=<%= cat %>" class="<%= query.category === cat ? 'dropdown-active' : '' %>">
|
|
33
|
+
<%= cat.charAt(0).toUpperCase() + cat.slice(1) %>
|
|
34
|
+
</a>
|
|
35
|
+
</li>
|
|
36
|
+
<% }); %>
|
|
37
|
+
</ul>
|
|
38
|
+
</li>
|
|
39
|
+
</ul>
|
|
40
|
+
|
|
41
|
+
<div class="search-login">
|
|
42
|
+
<form action="/berita/list" method="GET" class="search-bar">
|
|
43
|
+
<% if (query.category) { %>
|
|
44
|
+
<input type="hidden" name="category" value="<%= query.category %>" />
|
|
45
|
+
<% } %>
|
|
46
|
+
<i class="fa-solid fa-magnifying-glass"></i>
|
|
47
|
+
<div class="input-box">
|
|
48
|
+
<input type="text" name="title" placeholder="Cari berita..." value="<%= query.title %>" />
|
|
49
|
+
</div>
|
|
50
|
+
</form>
|
|
51
|
+
</div>
|
|
52
|
+
</nav>
|
|
53
|
+
|
|
54
|
+
<main class="container">
|
|
55
|
+
<% if (!query.title && trending && trending.length> 0 ) { const hero = trending[0];
|
|
56
|
+
%>
|
|
57
|
+
|
|
58
|
+
<section class="hero-section">
|
|
59
|
+
<div class="hero-card">
|
|
60
|
+
<a href="/berita/post/<%= hero.slug %>">
|
|
61
|
+
<img src="<%= hero.imagePath
|
|
62
|
+
? hero.imagePath.replace('public/', '/berita/')
|
|
63
|
+
: '/berita/img/Main.png' %>" alt="<%= hero.title %>" class="hero-image" />
|
|
64
|
+
|
|
65
|
+
<div class="hero-content">
|
|
66
|
+
<span class="badge-trending"> 🔥 Trending </span>
|
|
67
|
+
|
|
68
|
+
<h2 class="hero-title">
|
|
69
|
+
<%= hero.title %>
|
|
70
|
+
</h2>
|
|
71
|
+
|
|
72
|
+
<div class="meta-white">
|
|
73
|
+
<span>Oleh: <%= hero.authorName %></span>
|
|
74
|
+
<span>|</span>
|
|
75
|
+
<span>
|
|
76
|
+
<%= new Date(hero.createdAt).toLocaleDateString('id-ID', { day: 'numeric' , month: 'long' ,
|
|
77
|
+
year: 'numeric' }) %>
|
|
78
|
+
</span>
|
|
79
|
+
<span>|</span>
|
|
80
|
+
<span>
|
|
81
|
+
<%= hero.category %>
|
|
82
|
+
</span>
|
|
83
|
+
<% if (hero.views) { %>
|
|
84
|
+
<span>|</span>
|
|
85
|
+
<span> <i class="fa-solid fa-eye"></i>
|
|
86
|
+
<%= hero.views %>
|
|
87
|
+
</span>
|
|
88
|
+
<% } %>
|
|
89
|
+
</div>
|
|
90
|
+
</div>
|
|
91
|
+
</a>
|
|
92
|
+
</div>
|
|
93
|
+
</section>
|
|
94
|
+
|
|
95
|
+
<% } %>
|
|
96
|
+
<% if (posts && posts.length> 0) { %>
|
|
97
|
+
|
|
98
|
+
<div class="news-layout">
|
|
99
|
+
<section>
|
|
100
|
+
<h2 class="section-title">
|
|
101
|
+
<%= query.title ? `Hasil Pencarian: "${query.title}" ` : (query.category ? `Kategori: ${query.category}`
|
|
102
|
+
: 'Berita Terbaru' ) %>
|
|
103
|
+
</h2>
|
|
104
|
+
|
|
105
|
+
<div class="news-grid">
|
|
106
|
+
<% posts.forEach(post=> { %>
|
|
107
|
+
<a href="/berita/post/<%= post.slug %>" class="news-card">
|
|
108
|
+
<img src="<%= post.imagePath
|
|
109
|
+
? post.imagePath.replace('public/', '/berita/')
|
|
110
|
+
: '/berita/img/berita.png' %>" class="news-thumb" alt="<%= post.title %>" />
|
|
111
|
+
<div class="news-body">
|
|
112
|
+
<h3 class="news-title">
|
|
113
|
+
<%= post.title %>
|
|
114
|
+
</h3>
|
|
115
|
+
<p class="news-meta">
|
|
116
|
+
<%= new Date(post.createdAt).toLocaleDateString('id-ID') %> |
|
|
117
|
+
<%= post.category %>
|
|
118
|
+
</p>
|
|
119
|
+
</div>
|
|
120
|
+
</a>
|
|
121
|
+
<% }) %>
|
|
122
|
+
</div>
|
|
123
|
+
|
|
124
|
+
<nav class="pagination">
|
|
125
|
+
<% if (pagination.hasPrevPage) { %>
|
|
126
|
+
<a href="?page=<%= pagination.currentPage - 1 %>&title=<%= query.title %>&category=<%= query.category %>"
|
|
127
|
+
class="page-item"><</a>
|
|
128
|
+
<% } %>
|
|
129
|
+
<% for (let i=1; i <=pagination.totalPages; i++) { %>
|
|
130
|
+
<a href="?page=<%= i %>&title=<%= query.title %>&category=<%= query.category %>"
|
|
131
|
+
class="page-item <%= pagination.currentPage === i ? 'active' : '' %>">
|
|
132
|
+
<%= i %>
|
|
133
|
+
</a>
|
|
134
|
+
<% } %>
|
|
135
|
+
<% if (pagination.hasNextPage) { %>
|
|
136
|
+
<a href="?page=<%= pagination.currentPage + 1 %>&title=<%= query.title %>&category=<%= query.category %>"
|
|
137
|
+
class="page-item">></a>
|
|
138
|
+
<% } %>
|
|
139
|
+
</nav>
|
|
140
|
+
</section>
|
|
141
|
+
|
|
142
|
+
<aside>
|
|
143
|
+
<div class="sidebar-section">
|
|
144
|
+
<h2 class="section-title">Sedang Trending</h2>
|
|
145
|
+
<div class="sidebar-list">
|
|
146
|
+
<% trending.forEach(item=> { %>
|
|
147
|
+
<a href="/berita/post/<%= item.slug %>" class="mini-card">
|
|
148
|
+
<img
|
|
149
|
+
src="<%= item.imagePath ? item.imagePath.replace('public/', '/berita/') : '/berita/img/berita2.png' %>"
|
|
150
|
+
class="mini-thumb" />
|
|
151
|
+
<div class="mini-content">
|
|
152
|
+
<h4 class="mini-title">
|
|
153
|
+
<%= item.title %>
|
|
154
|
+
</h4>
|
|
155
|
+
<p class="news-meta">
|
|
156
|
+
<%= item.authorName %> | <%= new Date(item.createdAt).toLocaleDateString('id-ID') %>
|
|
157
|
+
</p>
|
|
158
|
+
</div>
|
|
159
|
+
</a>
|
|
160
|
+
<% }); %>
|
|
161
|
+
</div>
|
|
162
|
+
</div>
|
|
163
|
+
</aside>
|
|
164
|
+
</div>
|
|
165
|
+
|
|
166
|
+
<% } else { %>
|
|
167
|
+
|
|
168
|
+
<div style="text-align: center; padding: 50px">
|
|
169
|
+
<i class="fa-solid fa-face-frown" style="font-size: 50px; color: #ccc"></i>
|
|
170
|
+
<h3>Maaf, berita tidak ditemukan.</h3>
|
|
171
|
+
<p>Coba gunakan kata kunci lain atau pilih kategori yang berbeda.</p>
|
|
172
|
+
<a href="/berita/list" class="btn-primary">Kembali ke Beranda</a>
|
|
173
|
+
</div>
|
|
174
|
+
|
|
175
|
+
<% } %>
|
|
176
|
+
</main>
|
|
177
|
+
|
|
178
|
+
<footer class="site-footer">
|
|
179
|
+
<div class="footer-container">
|
|
180
|
+
<div class="footer-top">
|
|
181
|
+
<div class="footer-brand">
|
|
182
|
+
<div class="footer-logo">
|
|
183
|
+
<img src="/berita/img/logo.png" alt="DeNews Logo" class="logo" />
|
|
184
|
+
</div>
|
|
185
|
+
<p class="footer-desc">
|
|
186
|
+
DeNews menyajikan informasi akurat, cepat, dan terpercaya setiap
|
|
187
|
+
hari.
|
|
188
|
+
</p>
|
|
189
|
+
</div>
|
|
190
|
+
|
|
191
|
+
<div class="footer-links">
|
|
192
|
+
<h3 class="footer-heading">Kategori Populer</h3>
|
|
193
|
+
<ul class="category-grid">
|
|
194
|
+
<% categories.slice(0, 8).forEach(cat=> { %>
|
|
195
|
+
<li><a href="/berita/list?category=<%= cat %>">
|
|
196
|
+
<%= cat %>
|
|
197
|
+
</a></li>
|
|
198
|
+
<% }) %>
|
|
199
|
+
</ul>
|
|
200
|
+
</div>
|
|
201
|
+
|
|
202
|
+
<div class="footer-social">
|
|
203
|
+
<h3 class="footer-heading text-white">Ikuti Kami</h3>
|
|
204
|
+
<div class="social-icons">
|
|
205
|
+
<a href="#"><i class="fab fa-facebook-square"></i></a>
|
|
206
|
+
<a href="#"><i class="fab fa-twitter-square"></i></a>
|
|
207
|
+
<a href="#"><i class="fab fa-instagram-square"></i></a>
|
|
208
|
+
</div>
|
|
209
|
+
</div>
|
|
210
|
+
</div>
|
|
211
|
+
<div class="footer-bottom">
|
|
212
|
+
<div class="copyright">© 2025 DeNews.</div>
|
|
213
|
+
</div>
|
|
214
|
+
</div>
|
|
215
|
+
</footer>
|
|
216
|
+
|
|
217
|
+
<script src="/berita/js/script.js"></script>
|
|
218
|
+
</body>
|
|
219
|
+
|
|
220
|
+
</html>
|
package/views/list.ejs
DELETED
|
File without changes
|