Skip to content

Commit b587d42

Browse files
committed
#5-08-2024
1 parent 7e99646 commit b587d42

3 files changed

Lines changed: 100 additions & 1 deletion

File tree

apps_cms/theme1/site_files/css/articlePage.css

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
align-items: center;
5757
flex-direction: row;
5858
}
59-
.writerArea{
59+
.writerArea {
6060
background: var(--background2);
6161
padding: 1rem;
6262
border-radius: 5px;
@@ -157,3 +157,26 @@
157157

158158
@media (max-width: 767px) {
159159
}
160+
.steps {
161+
background: red;
162+
padding: 50px;
163+
border-radius: 50px;
164+
border: 5px solid #fff;
165+
}
166+
.steps h2 {
167+
font-size: 70px;
168+
margin-bottom: 50px;
169+
}
170+
.steps .counter {
171+
color: #000000;
172+
text-align: center;
173+
font-size: 60px;
174+
font-weight: bold;
175+
}
176+
.steps a {
177+
display: none;
178+
font-size: 50px;
179+
background: #4caf50;
180+
font-weight: bold;
181+
border: 2px solid #000;
182+
}

apps_cms/theme1/site_files/html/article.html

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,9 +160,17 @@ <h1 class="d-flex text-center">##data.article.$title##</h1>
160160
<span class="bold"> ##word.related Search##</span>
161161
<a x-list1="article.$keyWordsList" rel="nofollow" href="/results?search_query=##item1.##"> <i>##item1.##</i> </a>
162162
</div>
163+
163164
<div class="related-tags">
164165
<a x-list1="article.$tagsList" rel="nofollow" href="/results?tag=##item1.##"> <b>##item1.##</b> </a>
165166
</div>
167+
168+
<div x-data="shortLink.id" class="steps">
169+
<h2 class="center">Step ##data.shortLink.step## / ##data.shortLink.maxStep##</h2>
170+
<h3 class="counter">Waiting <span></span> sec</h3>
171+
<a href="/article/random" class="btn"> Click to Next Step >>>> </a>
172+
</div>
173+
166174
<div x-data="setting.showArticleAd" x-import="theme1/ad-article.html" class="related-ads"></div>
167175
</div>
168176
</div>
@@ -191,5 +199,25 @@ <h1 class="d-flex text-center">##data.article.$title##</h1>
191199
</div>
192200
<div x-import="theme1/wedgite.html"></div>
193201
<footer x-import="theme1/footer.html" class="footer d-flex flex-column justify-content-center align-items-center"></footer>
202+
<script x-data="shortLink">
203+
let counterTimeout = parseInt('##data.shortLink.timeout##' || 30);
204+
window.countInterval = setInterval(() => {
205+
if ((counter = document.querySelector('.counter span'))) {
206+
let count = parseInt(counter.innerText || counterTimeout);
207+
count--;
208+
if (count < 0) {
209+
clearInterval(window.countInterval);
210+
if ((a = document.querySelector('.steps h3'))) {
211+
a.style.display = 'none';
212+
}
213+
if ((a = document.querySelector('.steps a'))) {
214+
a.style.display = 'block';
215+
}
216+
} else {
217+
counter.innerText = count;
218+
}
219+
}
220+
}, 1000);
221+
</script>
194222
</body>
195223
</html>

cms.js

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,43 @@ site.get(
424424
}
425425
);
426426

427+
site.$shortLinkList = site.connectCollection('shortLinkList');
428+
site.shortLinkList = [];
429+
site.$shortLinkList.findMany({}, (err, docs) => {
430+
if (!err && docs) {
431+
site.shortLinkList = docs;
432+
}
433+
});
434+
site.onGET('/s/create', (req, res) => {
435+
let shortLink = {
436+
guid: site.md5(new Date().getTime().toString() + Math.random().toString()),
437+
url: req.query.url || 'https://social-browser.com',
438+
step: parseInt(req.query.step || 0),
439+
maxStep: parseInt(req.query.maxstep || 4),
440+
timeout: parseInt(req.query.timeout || 30),
441+
};
442+
site.$shortLinkList.add(shortLink, (err, doc) => {
443+
if (!err && doc) {
444+
site.shortLinkList.push(doc);
445+
res.end('https://' + req.host + '/s/' + doc.guid);
446+
}
447+
});
448+
});
449+
site.onGET('/s/:guid', (req, res) => {
450+
req.session.shortLink = site.shortLinkList.find((s) => s.guid == req.params.guid) || {
451+
guid: req.params.guid,
452+
url: req.query.url || 'https://social-browser.com/download/' + site.md5(req.params.guid),
453+
step: 0,
454+
maxStep: 4,
455+
timeout: 30,
456+
};
457+
458+
req.session.$save();
459+
460+
req.params.guid = 'random';
461+
site.callRoute('/article/:guid', req, res);
462+
});
463+
427464
site.get(
428465
{
429466
name: ['/article/:guid/:title', '/torrent/:guid/:title', '/article/:guid', '/a/:guid', '/torrent/:guid'],
@@ -512,6 +549,17 @@ site.get(
512549
}
513550
options.latestList = site.getLatestArticles(article);
514551
options.topNews = site.getTopArticles(options.filter, article.category);
552+
if (req.session.shortLink) {
553+
req.session.shortLink.step++;
554+
if (req.session.shortLink.step > req.session.shortLink.maxStep) {
555+
res.redirect(req.session.shortLink.url);
556+
req.session.shortLink = null;
557+
req.session.$save();
558+
return;
559+
}
560+
req.session.$save();
561+
options.shortLink = req.session.shortLink;
562+
}
515563

516564
res.render('theme1/article.html', options, {
517565
parser: 'html css js',

0 commit comments

Comments
 (0)