nodebb-plugin-niki-loyalty 1.0.1 → 1.0.2
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/library.js +12 -4
- package/package.json +1 -1
- package/templates/admin/plugins/quickstart/partials/sorted-list/form.tpl +0 -10
- package/templates/admin/plugins/quickstart/partials/sorted-list/item.tpl +0 -12
- package/templates/admin/plugins/quickstart.tpl +0 -68
- package/templates/quickstart.tpl +0 -7
package/library.js
CHANGED
|
@@ -9,18 +9,21 @@ const Plugin = {};
|
|
|
9
9
|
// --- AYARLAR ---
|
|
10
10
|
const SETTINGS = {
|
|
11
11
|
pointsPerHeartbeat: 5, // Her vuruşta kaç puan?
|
|
12
|
-
heartbeatInterval: 60, // Kaç saniyede bir
|
|
13
|
-
dailyCap: 250 // Günlük maksimum puan
|
|
12
|
+
heartbeatInterval: 60, // Kaç saniyede bir
|
|
13
|
+
dailyCap: 250 // Günlük maksimum puan
|
|
14
14
|
};
|
|
15
15
|
|
|
16
16
|
Plugin.init = async function (params) {
|
|
17
17
|
const router = params.router;
|
|
18
18
|
const middleware = params.middleware;
|
|
19
|
+
|
|
20
|
+
// Konsolda bu yazıyı görmelisin, görmüyorsan plugin aktif değildir.
|
|
21
|
+
console.log('✅ Niki Loyalty Plugin: Başlatılıyor...');
|
|
19
22
|
|
|
20
23
|
// API: Kalp Atışı (Puan Kazanma)
|
|
21
24
|
router.post('/api/niki-loyalty/heartbeat', middleware.ensureLoggedIn, async (req, res) => {
|
|
22
25
|
const uid = req.uid;
|
|
23
|
-
const today = new Date().toISOString().slice(0, 10).replace(/-/g, ''); // 20251214
|
|
26
|
+
const today = new Date().toISOString().slice(0, 10).replace(/-/g, ''); // 20251214 formatı
|
|
24
27
|
|
|
25
28
|
// 1. Günlük Limiti Kontrol Et
|
|
26
29
|
const dailyKey = `niki:daily:${uid}:${today}`;
|
|
@@ -45,8 +48,11 @@ Plugin.init = async function (params) {
|
|
|
45
48
|
});
|
|
46
49
|
|
|
47
50
|
// SAYFA: Cüzdan (/niki-wallet)
|
|
51
|
+
// setupPageRoute: NodeBB'nin yeni sayfa oluşturma yardımcısıdır.
|
|
48
52
|
routeHelpers.setupPageRoute(router, '/niki-wallet', middleware, [], async (req, res) => {
|
|
49
53
|
const uid = req.uid;
|
|
54
|
+
|
|
55
|
+
// Giriş yapmamışsa login sayfasına at
|
|
50
56
|
if (!uid) return res.redirect('/login');
|
|
51
57
|
|
|
52
58
|
const today = new Date().toISOString().slice(0, 10).replace(/-/g, '');
|
|
@@ -64,13 +70,15 @@ Plugin.init = async function (params) {
|
|
|
64
70
|
let dailyPercent = (dailyScore / SETTINGS.dailyCap) * 100;
|
|
65
71
|
if (dailyPercent > 100) dailyPercent = 100;
|
|
66
72
|
|
|
73
|
+
// niki-wallet.tpl dosyasını render et
|
|
67
74
|
res.render('niki-wallet', {
|
|
68
75
|
title: 'Niki Cüzdan',
|
|
69
76
|
points: currentPoints,
|
|
70
77
|
dailyScore: dailyScore,
|
|
71
78
|
dailyCap: SETTINGS.dailyCap,
|
|
72
79
|
dailyPercent: dailyPercent,
|
|
73
|
-
user: userData
|
|
80
|
+
user: userData,
|
|
81
|
+
breadcrumbs: routeHelpers.buildBreadcrumbs([{ text: 'Niki Cüzdan' }]) // Breadcrumb ekledim (opsiyonel şıklık)
|
|
74
82
|
});
|
|
75
83
|
});
|
|
76
84
|
};
|
package/package.json
CHANGED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
<form>
|
|
2
|
-
<div class="mb-3">
|
|
3
|
-
<label class="form-label" for="name">Name</label>
|
|
4
|
-
<input type="text" id="name" name="name" class="form-control" placeholder="Name" />
|
|
5
|
-
</div>
|
|
6
|
-
<div class="mb-3">
|
|
7
|
-
<label class="form-label" for="description">Description</label>
|
|
8
|
-
<input type="text" id="description" name="description" class="form-control" placeholder="Description" />
|
|
9
|
-
</div>
|
|
10
|
-
</form>
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
<li data-type="item" class="list-group-item">
|
|
2
|
-
<div class="d-flex gap-2 justify-content-between align-items-start">
|
|
3
|
-
<div class="flex-grow-1">
|
|
4
|
-
<strong>{name}</strong><br />
|
|
5
|
-
<small>{description}</small>
|
|
6
|
-
</div>
|
|
7
|
-
<div class="d-flex gap-1 flex-nowrap">
|
|
8
|
-
<button type="button" data-type="edit" class="btn btn-sm btn-info">Edit</button>
|
|
9
|
-
<button type="button" data-type="remove" class="btn btn-sm btn-danger">Delete</button>
|
|
10
|
-
</div>
|
|
11
|
-
</div>
|
|
12
|
-
</li>
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
<div class="acp-page-container">
|
|
2
|
-
<!-- IMPORT admin/partials/settings/header.tpl -->
|
|
3
|
-
|
|
4
|
-
<div class="row m-0">
|
|
5
|
-
<div id="spy-container" class="col-12 col-md-8 px-0 mb-4" tabindex="0">
|
|
6
|
-
<form role="form" class="quickstart-settings">
|
|
7
|
-
<div class="mb-4">
|
|
8
|
-
<h5 class="fw-bold tracking-tight settings-header">General</h5>
|
|
9
|
-
|
|
10
|
-
<p class="lead">
|
|
11
|
-
Adjust these settings. You can then retrieve these settings in code via:
|
|
12
|
-
<br/><code>await meta.settings.get('quickstart');</code>
|
|
13
|
-
</p>
|
|
14
|
-
<div class="mb-3">
|
|
15
|
-
<label class="form-label" for="setting-1">Setting 1</label>
|
|
16
|
-
<input type="text" id="setting-1" name="setting-1" title="Setting 1" class="form-control" placeholder="Setting 1">
|
|
17
|
-
</div>
|
|
18
|
-
<div class="mb-3">
|
|
19
|
-
<label class="form-label" for="setting-2">Setting 2</label>
|
|
20
|
-
<input type="text" id="setting-2" name="setting-2" title="Setting 2" class="form-control" placeholder="Setting 2">
|
|
21
|
-
</div>
|
|
22
|
-
|
|
23
|
-
<div class="form-check form-switch">
|
|
24
|
-
<input type="checkbox" class="form-check-input" id="setting-3" name="setting-3">
|
|
25
|
-
<label for="setting-3" class="form-check-label">Setting 3</label>
|
|
26
|
-
</div>
|
|
27
|
-
</div>
|
|
28
|
-
|
|
29
|
-
<div class="mb-4">
|
|
30
|
-
<h5 class="fw-bold tracking-tight settings-header">Colors</h5>
|
|
31
|
-
|
|
32
|
-
<p class="alert" id="preview">
|
|
33
|
-
Here is some preview text. Use the inputs below to modify this alert's appearance.
|
|
34
|
-
</p>
|
|
35
|
-
<div class="mb-3 d-flex gap-2">
|
|
36
|
-
<label class="form-label" for="color">Foreground</label>
|
|
37
|
-
<input data-settings="colorpicker" type="color" id="color" name="color" title="Background Color" class="form-control p-1" placeholder="#ffffff" value="#ffffff" style="width: 64px;"/>
|
|
38
|
-
</div>
|
|
39
|
-
<div class="mb-3 d-flex gap-2">
|
|
40
|
-
<label class="form-label" for="bgColor">Background</label>
|
|
41
|
-
<input data-settings="colorpicker" type="color" id="bgColor" name="bgColor" title="Background Color" class="form-control p-1" placeholder="#000000" value="#000000" style="width: 64px;" />
|
|
42
|
-
</div>
|
|
43
|
-
</div>
|
|
44
|
-
|
|
45
|
-
<div class="mb-4">
|
|
46
|
-
<h5 class="fw-bold tracking-tight settings-header">Sorted List</h5>
|
|
47
|
-
|
|
48
|
-
<div class="mb-3" data-type="sorted-list" data-sorted-list="sample-list" data-item-template="admin/plugins/quickstart/partials/sorted-list/item" data-form-template="admin/plugins/quickstart/partials/sorted-list/form">
|
|
49
|
-
<ul data-type="list" class="list-group mb-2"></ul>
|
|
50
|
-
<button type="button" data-type="add" class="btn btn-info">Add Item</button>
|
|
51
|
-
</div>
|
|
52
|
-
</div>
|
|
53
|
-
|
|
54
|
-
<div>
|
|
55
|
-
<h5 class="fw-bold tracking-tight settings-header">Uploads</h5>
|
|
56
|
-
|
|
57
|
-
<label class="form-label" for="uploadedImage">Upload Image</label>
|
|
58
|
-
<div class="d-flex gap-1">
|
|
59
|
-
<input id="uploadedImage" name="uploadedImage" type="text" class="form-control" />
|
|
60
|
-
<input value="Upload" data-action="upload" data-target="uploadedImage" type="button" class="btn btn-light" />
|
|
61
|
-
</div>
|
|
62
|
-
</div>
|
|
63
|
-
</form>
|
|
64
|
-
</div>
|
|
65
|
-
|
|
66
|
-
<!-- IMPORT admin/partials/settings/toc.tpl -->
|
|
67
|
-
</div>
|
|
68
|
-
</div>
|